From f62c219725730583a23cd953eacfa7876555761a Mon Sep 17 00:00:00 2001 From: cp3hnu Date: Mon, 29 Apr 2024 17:26:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E6=B1=89=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - label_studio/frontend/dist/react-app/index.js | 91069 ++++++++++++++++ .../dist/react-app/index.js.LICENSE.txt | 122 + .../frontend/dist/react-app/index.js.map | 1 + label_studio/frontend/dist/react-app/main.css | 3649 + .../frontend/dist/react-app/main.css.map | 1 + label_studio/frontend/package-lock.json | 15362 ++- .../frontend/src/app/AsyncPage/AsyncPage.js | 8 +- .../frontend/src/app/ErrorBoundary.js | 4 +- .../frontend/src/components/Error/Error.js | 7 +- .../components/Form/Elements/Select/Select.js | 2 +- .../Form/Elements/Select/Select.styl | 5 + .../frontend/src/components/Form/Form.js | 2 +- .../components/Form/Validation/Validators.js | 8 +- .../src/components/Menubar/Menubar.js | 8 +- .../frontend/src/components/Modal/Modal.js | 6 +- .../src/pages/CreateProject/Config/Config.js | 44 +- .../src/pages/CreateProject/Config/Preview.js | 2 +- .../CreateProject/Config/TemplatesList.js | 4 +- .../src/pages/CreateProject/CreateProject.js | 12 +- .../src/pages/CreateProject/Import/Import.js | 33 +- .../pages/CreateProject/Import/ImportModal.js | 6 +- .../CreateProject/utils/useDraftProject.js | 4 +- .../src/pages/DataManager/DataManager.js | 18 +- .../src/pages/ExportPage/ExportPage.js | 14 +- .../ExportToPlatform/ExportToPlatform.js | 1 - .../src/pages/PeoplePage/PeopleList.js | 6 +- .../src/pages/PeoplePage/PeoplePage.js | 6 +- .../src/pages/PeoplePage/SelectedUser.js | 12 +- .../frontend/src/pages/Projects/Projects.js | 4 +- .../src/pages/Projects/ProjectsList.js | 8 +- .../frontend/src/pages/Settings/DangerZone.js | 24 +- .../src/pages/Settings/GeneralSettings.js | 20 +- .../pages/Settings/InstructionsSettings.js | 12 +- .../src/pages/Settings/LabelingSettings.js | 9 +- .../MachineLearningList.js | 27 +- .../MachineLearningSettings.js | 40 +- .../Settings/StorageSettings/StorageCard.js | 10 +- .../Settings/StorageSettings/StorageForm.js | 11 +- .../Settings/StorageSettings/StorageSet.js | 15 +- .../StorageSettings/StorageSettings.js | 7 +- .../StorageSettings/StorageSummary.js | 15 +- .../frontend/src/providers/ApiProvider.js | 6 +- 43 files changed, 104631 insertions(+), 5994 deletions(-) create mode 100644 label_studio/frontend/dist/react-app/index.js create mode 100644 label_studio/frontend/dist/react-app/index.js.LICENSE.txt create mode 100644 label_studio/frontend/dist/react-app/index.js.map create mode 100644 label_studio/frontend/dist/react-app/main.css create mode 100644 label_studio/frontend/dist/react-app/main.css.map diff --git a/.gitignore b/.gitignore index 920844f..a4a05f8 100644 --- a/.gitignore +++ b/.gitignore @@ -34,7 +34,6 @@ label_studio/core/static_build label_studio/core/version_.py label_studio/core/core label_studio/tests/test_data/tasks_and_annotations.json -label_studio/frontend/dist/react-app archive diff --git a/label_studio/frontend/dist/react-app/index.js b/label_studio/frontend/dist/react-app/index.js new file mode 100644 index 0000000..42b0c3d --- /dev/null +++ b/label_studio/frontend/dist/react-app/index.js @@ -0,0 +1,91069 @@ +/******/ (() => { // webpackBootstrap +/******/ var __webpack_modules__ = ({ + +/***/ "./node_modules/@babel/runtime/helpers/esm/extends.js": +/*!************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/extends.js ***! + \************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ _extends) +/* harmony export */ }); +function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); +} + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js": +/*!******************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js ***! + \******************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ _inheritsLoose) +/* harmony export */ }); +/* harmony import */ var _babel_runtime_helpers_esm_setPrototypeOf__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/setPrototypeOf */ "./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js"); + +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + (0,_babel_runtime_helpers_esm_setPrototypeOf__WEBPACK_IMPORTED_MODULE_0__.default)(subClass, superClass); +} + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ _objectWithoutPropertiesLoose) +/* harmony export */ }); +function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; +} + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js": +/*!*******************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js ***! + \*******************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ _setPrototypeOf) +/* harmony export */ }); +function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); +} + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/backend.js": +/*!*****************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/backend.js ***! + \*****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "BrowserBackend": () => (/* binding */ BrowserBackend) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/core/esm/basebackend.js"); +/* harmony import */ var _sentry_types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/types */ "./node_modules/@sentry/types/esm/severity.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/supports.js"); +/* harmony import */ var _eventbuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./eventbuilder */ "./node_modules/@sentry/browser/esm/eventbuilder.js"); +/* harmony import */ var _transports__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./transports */ "./node_modules/@sentry/browser/esm/transports/fetch.js"); +/* harmony import */ var _transports__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./transports */ "./node_modules/@sentry/browser/esm/transports/xhr.js"); + + + + + + +/** + * The Sentry Browser SDK Backend. + * @hidden + */ +var BrowserBackend = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(BrowserBackend, _super); + function BrowserBackend() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @inheritDoc + */ + BrowserBackend.prototype.eventFromException = function (exception, hint) { + return (0,_eventbuilder__WEBPACK_IMPORTED_MODULE_1__.eventFromException)(this._options, exception, hint); + }; + /** + * @inheritDoc + */ + BrowserBackend.prototype.eventFromMessage = function (message, level, hint) { + if (level === void 0) { level = _sentry_types__WEBPACK_IMPORTED_MODULE_2__.Severity.Info; } + return (0,_eventbuilder__WEBPACK_IMPORTED_MODULE_1__.eventFromMessage)(this._options, message, level, hint); + }; + /** + * @inheritDoc + */ + BrowserBackend.prototype._setupTransport = function () { + if (!this._options.dsn) { + // We return the noop transport here in case there is no Dsn. + return _super.prototype._setupTransport.call(this); + } + var transportOptions = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._options.transportOptions), { dsn: this._options.dsn, tunnel: this._options.tunnel, _metadata: this._options._metadata }); + if (this._options.transport) { + return new this._options.transport(transportOptions); + } + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.supportsFetch)()) { + return new _transports__WEBPACK_IMPORTED_MODULE_4__.FetchTransport(transportOptions); + } + return new _transports__WEBPACK_IMPORTED_MODULE_5__.XHRTransport(transportOptions); + }; + return BrowserBackend; +}(_sentry_core__WEBPACK_IMPORTED_MODULE_6__.BaseBackend)); + +//# sourceMappingURL=backend.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/client.js": +/*!****************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/client.js ***! + \****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "BrowserClient": () => (/* binding */ BrowserClient) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/core/esm/version.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/core/esm/baseclient.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _backend__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./backend */ "./node_modules/@sentry/browser/esm/backend.js"); +/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./helpers */ "./node_modules/@sentry/browser/esm/helpers.js"); +/* harmony import */ var _integrations__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./integrations */ "./node_modules/@sentry/browser/esm/integrations/breadcrumbs.js"); + + + + + + +/** + * The Sentry Browser SDK Client. + * + * @see BrowserOptions for documentation on configuration options. + * @see SentryClient for usage documentation. + */ +var BrowserClient = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(BrowserClient, _super); + /** + * Creates a new Browser SDK instance. + * + * @param options Configuration options for this SDK. + */ + function BrowserClient(options) { + if (options === void 0) { options = {}; } + var _this = this; + options._metadata = options._metadata || {}; + options._metadata.sdk = options._metadata.sdk || { + name: 'sentry.javascript.browser', + packages: [ + { + name: 'npm:@sentry/browser', + version: _sentry_core__WEBPACK_IMPORTED_MODULE_1__.SDK_VERSION, + }, + ], + version: _sentry_core__WEBPACK_IMPORTED_MODULE_1__.SDK_VERSION, + }; + _this = _super.call(this, _backend__WEBPACK_IMPORTED_MODULE_2__.BrowserBackend, options) || this; + return _this; + } + /** + * Show a report dialog to the user to send feedback to a specific event. + * + * @param options Set individual options for the dialog + */ + BrowserClient.prototype.showReportDialog = function (options) { + if (options === void 0) { options = {}; } + // doesn't work without a document (React Native) + var document = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.getGlobalObject)().document; + if (!document) { + return; + } + if (!this._isEnabled()) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_4__.logger.error('Trying to call showReportDialog with Sentry Client disabled'); + return; + } + (0,_helpers__WEBPACK_IMPORTED_MODULE_5__.injectReportDialog)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, options), { dsn: options.dsn || this.getDsn() })); + }; + /** + * @inheritDoc + */ + BrowserClient.prototype._prepareEvent = function (event, scope, hint) { + event.platform = event.platform || 'javascript'; + return _super.prototype._prepareEvent.call(this, event, scope, hint); + }; + /** + * @inheritDoc + */ + BrowserClient.prototype._sendEvent = function (event) { + var integration = this.getIntegration(_integrations__WEBPACK_IMPORTED_MODULE_6__.Breadcrumbs); + if (integration) { + integration.addSentryBreadcrumb(event); + } + _super.prototype._sendEvent.call(this, event); + }; + return BrowserClient; +}(_sentry_core__WEBPACK_IMPORTED_MODULE_7__.BaseClient)); + +//# sourceMappingURL=client.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/eventbuilder.js": +/*!**********************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/eventbuilder.js ***! + \**********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "eventFromException": () => (/* binding */ eventFromException), +/* harmony export */ "eventFromMessage": () => (/* binding */ eventFromMessage), +/* harmony export */ "eventFromUnknownInput": () => (/* binding */ eventFromUnknownInput), +/* harmony export */ "eventFromString": () => (/* binding */ eventFromString) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/types */ "./node_modules/@sentry/types/esm/severity.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/syncpromise.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/is.js"); +/* harmony import */ var _parsers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./parsers */ "./node_modules/@sentry/browser/esm/parsers.js"); +/* harmony import */ var _tracekit__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tracekit */ "./node_modules/@sentry/browser/esm/tracekit.js"); + + + + + +/** + * Builds and Event from a Exception + * @hidden + */ +function eventFromException(options, exception, hint) { + var syntheticException = (hint && hint.syntheticException) || undefined; + var event = eventFromUnknownInput(exception, syntheticException, { + attachStacktrace: options.attachStacktrace, + }); + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.addExceptionMechanism)(event, { + handled: true, + type: 'generic', + }); + event.level = _sentry_types__WEBPACK_IMPORTED_MODULE_1__.Severity.Error; + if (hint && hint.event_id) { + event.event_id = hint.event_id; + } + return _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.SyncPromise.resolve(event); +} +/** + * Builds and Event from a Message + * @hidden + */ +function eventFromMessage(options, message, level, hint) { + if (level === void 0) { level = _sentry_types__WEBPACK_IMPORTED_MODULE_1__.Severity.Info; } + var syntheticException = (hint && hint.syntheticException) || undefined; + var event = eventFromString(message, syntheticException, { + attachStacktrace: options.attachStacktrace, + }); + event.level = level; + if (hint && hint.event_id) { + event.event_id = hint.event_id; + } + return _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.SyncPromise.resolve(event); +} +/** + * @hidden + */ +function eventFromUnknownInput(exception, syntheticException, options) { + if (options === void 0) { options = {}; } + var event; + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.isErrorEvent)(exception) && exception.error) { + // If it is an ErrorEvent with `error` property, extract it to get actual Error + var errorEvent = exception; + // eslint-disable-next-line no-param-reassign + exception = errorEvent.error; + event = (0,_parsers__WEBPACK_IMPORTED_MODULE_4__.eventFromStacktrace)((0,_tracekit__WEBPACK_IMPORTED_MODULE_5__.computeStackTrace)(exception)); + return event; + } + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.isDOMError)(exception) || (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.isDOMException)(exception)) { + // If it is a DOMError or DOMException (which are legacy APIs, but still supported in some browsers) + // then we just extract the name, code, and message, as they don't provide anything else + // https://developer.mozilla.org/en-US/docs/Web/API/DOMError + // https://developer.mozilla.org/en-US/docs/Web/API/DOMException + var domException = exception; + var name_1 = domException.name || ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.isDOMError)(domException) ? 'DOMError' : 'DOMException'); + var message = domException.message ? name_1 + ": " + domException.message : name_1; + event = eventFromString(message, syntheticException, options); + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.addExceptionTypeValue)(event, message); + if ('code' in domException) { + event.tags = (0,tslib__WEBPACK_IMPORTED_MODULE_6__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_6__.__assign)({}, event.tags), { 'DOMException.code': "" + domException.code }); + } + return event; + } + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.isError)(exception)) { + // we have a real Error object, do nothing + event = (0,_parsers__WEBPACK_IMPORTED_MODULE_4__.eventFromStacktrace)((0,_tracekit__WEBPACK_IMPORTED_MODULE_5__.computeStackTrace)(exception)); + return event; + } + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.isPlainObject)(exception) || (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.isEvent)(exception)) { + // If it is plain Object or Event, serialize it manually and extract options + // This will allow us to group events based on top-level keys + // which is much better than creating new group when any key/value change + var objectException = exception; + event = (0,_parsers__WEBPACK_IMPORTED_MODULE_4__.eventFromPlainObject)(objectException, syntheticException, options.rejection); + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.addExceptionMechanism)(event, { + synthetic: true, + }); + return event; + } + // If none of previous checks were valid, then it means that it's not: + // - an instance of DOMError + // - an instance of DOMException + // - an instance of Event + // - an instance of Error + // - a valid ErrorEvent (one with an error property) + // - a plain Object + // + // So bail out and capture it as a simple message: + event = eventFromString(exception, syntheticException, options); + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.addExceptionTypeValue)(event, "" + exception, undefined); + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.addExceptionMechanism)(event, { + synthetic: true, + }); + return event; +} +/** + * @hidden + */ +function eventFromString(input, syntheticException, options) { + if (options === void 0) { options = {}; } + var event = { + message: input, + }; + if (options.attachStacktrace && syntheticException) { + var stacktrace = (0,_tracekit__WEBPACK_IMPORTED_MODULE_5__.computeStackTrace)(syntheticException); + var frames_1 = (0,_parsers__WEBPACK_IMPORTED_MODULE_4__.prepareFramesForEvent)(stacktrace.stack); + event.stacktrace = { + frames: frames_1, + }; + } + return event; +} +//# sourceMappingURL=eventbuilder.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/helpers.js": +/*!*****************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/helpers.js ***! + \*****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "shouldIgnoreOnError": () => (/* binding */ shouldIgnoreOnError), +/* harmony export */ "ignoreNextOnError": () => (/* binding */ ignoreNextOnError), +/* harmony export */ "wrap": () => (/* binding */ wrap), +/* harmony export */ "injectReportDialog": () => (/* binding */ injectReportDialog) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/minimal/esm/index.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/core/esm/api.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); + + + +var ignoreOnError = 0; +/** + * @hidden + */ +function shouldIgnoreOnError() { + return ignoreOnError > 0; +} +/** + * @hidden + */ +function ignoreNextOnError() { + // onerror should trigger before setTimeout + ignoreOnError += 1; + setTimeout(function () { + ignoreOnError -= 1; + }); +} +/** + * Instruments the given function and sends an event to Sentry every time the + * function throws an exception. + * + * @param fn A function to wrap. + * @returns The wrapped function. + * @hidden + */ +function wrap(fn, options, before) { + if (options === void 0) { options = {}; } + if (typeof fn !== 'function') { + return fn; + } + try { + // We don't wanna wrap it twice + if (fn.__sentry__) { + return fn; + } + // If this has already been wrapped in the past, return that wrapped function + if (fn.__sentry_wrapped__) { + return fn.__sentry_wrapped__; + } + } + catch (e) { + // Just accessing custom props in some Selenium environments + // can cause a "Permission denied" exception (see raven-js#495). + // Bail on wrapping and return the function as-is (defers to window.onerror). + return fn; + } + /* eslint-disable prefer-rest-params */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + var sentryWrapped = function () { + var args = Array.prototype.slice.call(arguments); + try { + if (before && typeof before === 'function') { + before.apply(this, arguments); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access + var wrappedArguments = args.map(function (arg) { return wrap(arg, options); }); + if (fn.handleEvent) { + // Attempt to invoke user-land function + // NOTE: If you are a Sentry user, and you are seeing this stack frame, it + // means the sentry.javascript SDK caught an error invoking your application code. This + // is expected behavior and NOT indicative of a bug with sentry.javascript. + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + return fn.handleEvent.apply(this, wrappedArguments); + } + // Attempt to invoke user-land function + // NOTE: If you are a Sentry user, and you are seeing this stack frame, it + // means the sentry.javascript SDK caught an error invoking your application code. This + // is expected behavior and NOT indicative of a bug with sentry.javascript. + return fn.apply(this, wrappedArguments); + } + catch (ex) { + ignoreNextOnError(); + (0,_sentry_core__WEBPACK_IMPORTED_MODULE_0__.withScope)(function (scope) { + scope.addEventProcessor(function (event) { + var processedEvent = (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__assign)({}, event); + if (options.mechanism) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.addExceptionTypeValue)(processedEvent, undefined, undefined); + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.addExceptionMechanism)(processedEvent, options.mechanism); + } + processedEvent.extra = (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_1__.__assign)({}, processedEvent.extra), { arguments: args }); + return processedEvent; + }); + (0,_sentry_core__WEBPACK_IMPORTED_MODULE_0__.captureException)(ex); + }); + throw ex; + } + }; + /* eslint-enable prefer-rest-params */ + // Accessing some objects may throw + // ref: https://github.com/getsentry/sentry-javascript/issues/1168 + try { + for (var property in fn) { + if (Object.prototype.hasOwnProperty.call(fn, property)) { + sentryWrapped[property] = fn[property]; + } + } + } + catch (_oO) { } // eslint-disable-line no-empty + fn.prototype = fn.prototype || {}; + sentryWrapped.prototype = fn.prototype; + Object.defineProperty(fn, '__sentry_wrapped__', { + enumerable: false, + value: sentryWrapped, + }); + // Signal that this function has been wrapped/filled already + // for both debugging and to prevent it to being wrapped/filled twice + Object.defineProperties(sentryWrapped, { + __sentry__: { + enumerable: false, + value: true, + }, + __sentry_original__: { + enumerable: false, + value: fn, + }, + }); + // Restore original function name (not all browsers allow that) + try { + var descriptor = Object.getOwnPropertyDescriptor(sentryWrapped, 'name'); + if (descriptor.configurable) { + Object.defineProperty(sentryWrapped, 'name', { + get: function () { + return fn.name; + }, + }); + } + // eslint-disable-next-line no-empty + } + catch (_oO) { } + return sentryWrapped; +} +/** + * Injects the Report Dialog script + * @hidden + */ +function injectReportDialog(options) { + if (options === void 0) { options = {}; } + if (!options.eventId) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.error("Missing eventId option in showReportDialog call"); + return; + } + if (!options.dsn) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.error("Missing dsn option in showReportDialog call"); + return; + } + var script = document.createElement('script'); + script.async = true; + script.src = new _sentry_core__WEBPACK_IMPORTED_MODULE_4__.API(options.dsn).getReportDialogEndpoint(options); + if (options.onLoad) { + // eslint-disable-next-line @typescript-eslint/unbound-method + script.onload = options.onLoad; + } + (document.head || document.body).appendChild(script); +} +//# sourceMappingURL=helpers.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/integrations/breadcrumbs.js": +/*!**********************************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/integrations/breadcrumbs.js ***! + \**********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Breadcrumbs": () => (/* binding */ Breadcrumbs) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/hub/esm/hub.js"); +/* harmony import */ var _sentry_types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @sentry/types */ "./node_modules/@sentry/types/esm/severity.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/instrument.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/string.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/browser.js"); + +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable max-lines */ + + + +/** + * Default Breadcrumbs instrumentations + * TODO: Deprecated - with v6, this will be renamed to `Instrument` + */ +var Breadcrumbs = /** @class */ (function () { + /** + * @inheritDoc + */ + function Breadcrumbs(options) { + /** + * @inheritDoc + */ + this.name = Breadcrumbs.id; + this._options = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({ console: true, dom: true, fetch: true, history: true, sentry: true, xhr: true }, options); + } + /** + * Create a breadcrumb of `sentry` from the events themselves + */ + Breadcrumbs.prototype.addSentryBreadcrumb = function (event) { + if (!this._options.sentry) { + return; + } + (0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)().addBreadcrumb({ + category: "sentry." + (event.type === 'transaction' ? 'transaction' : 'event'), + event_id: event.event_id, + level: event.level, + message: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.getEventDescription)(event), + }, { + event: event, + }); + }; + /** + * Instrument browser built-ins w/ breadcrumb capturing + * - Console API + * - DOM API (click/typing) + * - XMLHttpRequest API + * - Fetch API + * - History API + */ + Breadcrumbs.prototype.setupOnce = function () { + var _this = this; + if (this._options.console) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.addInstrumentationHandler)({ + callback: function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + _this._consoleBreadcrumb.apply(_this, (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)(args)); + }, + type: 'console', + }); + } + if (this._options.dom) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.addInstrumentationHandler)({ + callback: function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + _this._domBreadcrumb.apply(_this, (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)(args)); + }, + type: 'dom', + }); + } + if (this._options.xhr) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.addInstrumentationHandler)({ + callback: function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + _this._xhrBreadcrumb.apply(_this, (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)(args)); + }, + type: 'xhr', + }); + } + if (this._options.fetch) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.addInstrumentationHandler)({ + callback: function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + _this._fetchBreadcrumb.apply(_this, (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)(args)); + }, + type: 'fetch', + }); + } + if (this._options.history) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.addInstrumentationHandler)({ + callback: function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + _this._historyBreadcrumb.apply(_this, (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)(args)); + }, + type: 'history', + }); + } + }; + /** + * Creates breadcrumbs from console API calls + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Breadcrumbs.prototype._consoleBreadcrumb = function (handlerData) { + var breadcrumb = { + category: 'console', + data: { + arguments: handlerData.args, + logger: 'console', + }, + level: _sentry_types__WEBPACK_IMPORTED_MODULE_4__.Severity.fromString(handlerData.level), + message: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.safeJoin)(handlerData.args, ' '), + }; + if (handlerData.level === 'assert') { + if (handlerData.args[0] === false) { + breadcrumb.message = "Assertion failed: " + ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.safeJoin)(handlerData.args.slice(1), ' ') || 'console.assert'); + breadcrumb.data.arguments = handlerData.args.slice(1); + } + else { + // Don't capture a breadcrumb for passed assertions + return; + } + } + (0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)().addBreadcrumb(breadcrumb, { + input: handlerData.args, + level: handlerData.level, + }); + }; + /** + * Creates breadcrumbs from DOM API calls + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Breadcrumbs.prototype._domBreadcrumb = function (handlerData) { + var target; + var keyAttrs = typeof this._options.dom === 'object' ? this._options.dom.serializeAttribute : undefined; + if (typeof keyAttrs === 'string') { + keyAttrs = [keyAttrs]; + } + // Accessing event.target can throw (see getsentry/raven-js#838, #768) + try { + target = handlerData.event.target + ? (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.htmlTreeAsString)(handlerData.event.target, keyAttrs) + : (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.htmlTreeAsString)(handlerData.event, keyAttrs); + } + catch (e) { + target = ''; + } + if (target.length === 0) { + return; + } + (0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)().addBreadcrumb({ + category: "ui." + handlerData.name, + message: target, + }, { + event: handlerData.event, + name: handlerData.name, + global: handlerData.global, + }); + }; + /** + * Creates breadcrumbs from XHR API calls + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Breadcrumbs.prototype._xhrBreadcrumb = function (handlerData) { + if (handlerData.endTimestamp) { + // We only capture complete, non-sentry requests + if (handlerData.xhr.__sentry_own_request__) { + return; + } + var _a = handlerData.xhr.__sentry_xhr__ || {}, method = _a.method, url = _a.url, status_code = _a.status_code, body = _a.body; + (0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)().addBreadcrumb({ + category: 'xhr', + data: { + method: method, + url: url, + status_code: status_code, + }, + type: 'http', + }, { + xhr: handlerData.xhr, + input: body, + }); + return; + } + }; + /** + * Creates breadcrumbs from fetch API calls + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Breadcrumbs.prototype._fetchBreadcrumb = function (handlerData) { + // We only capture complete fetch requests + if (!handlerData.endTimestamp) { + return; + } + if (handlerData.fetchData.url.match(/sentry_key/) && handlerData.fetchData.method === 'POST') { + // We will not create breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests) + return; + } + if (handlerData.error) { + (0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)().addBreadcrumb({ + category: 'fetch', + data: handlerData.fetchData, + level: _sentry_types__WEBPACK_IMPORTED_MODULE_4__.Severity.Error, + type: 'http', + }, { + data: handlerData.error, + input: handlerData.args, + }); + } + else { + (0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)().addBreadcrumb({ + category: 'fetch', + data: (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, handlerData.fetchData), { status_code: handlerData.response.status }), + type: 'http', + }, { + input: handlerData.args, + response: handlerData.response, + }); + } + }; + /** + * Creates breadcrumbs from history API calls + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Breadcrumbs.prototype._historyBreadcrumb = function (handlerData) { + var global = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.getGlobalObject)(); + var from = handlerData.from; + var to = handlerData.to; + var parsedLoc = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.parseUrl)(global.location.href); + var parsedFrom = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.parseUrl)(from); + var parsedTo = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.parseUrl)(to); + // Initial pushState doesn't provide `from` information + if (!parsedFrom.path) { + parsedFrom = parsedLoc; + } + // Use only the path component of the URL if the URL matches the current + // document (almost all the time when using pushState) + if (parsedLoc.protocol === parsedTo.protocol && parsedLoc.host === parsedTo.host) { + to = parsedTo.relative; + } + if (parsedLoc.protocol === parsedFrom.protocol && parsedLoc.host === parsedFrom.host) { + from = parsedFrom.relative; + } + (0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)().addBreadcrumb({ + category: 'navigation', + data: { + from: from, + to: to, + }, + }); + }; + /** + * @inheritDoc + */ + Breadcrumbs.id = 'Breadcrumbs'; + return Breadcrumbs; +}()); + +//# sourceMappingURL=breadcrumbs.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/integrations/dedupe.js": +/*!*****************************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/integrations/dedupe.js ***! + \*****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Dedupe": () => (/* binding */ Dedupe) +/* harmony export */ }); +/** Deduplication filter */ +var Dedupe = /** @class */ (function () { + function Dedupe() { + /** + * @inheritDoc + */ + this.name = Dedupe.id; + } + /** + * @inheritDoc + */ + Dedupe.prototype.setupOnce = function (addGlobalEventProcessor, getCurrentHub) { + addGlobalEventProcessor(function (currentEvent) { + var self = getCurrentHub().getIntegration(Dedupe); + if (self) { + // Juuust in case something goes wrong + try { + if (self._shouldDropEvent(currentEvent, self._previousEvent)) { + return null; + } + } + catch (_oO) { + return (self._previousEvent = currentEvent); + } + return (self._previousEvent = currentEvent); + } + return currentEvent; + }); + }; + /** JSDoc */ + Dedupe.prototype._shouldDropEvent = function (currentEvent, previousEvent) { + if (!previousEvent) { + return false; + } + if (this._isSameMessageEvent(currentEvent, previousEvent)) { + return true; + } + if (this._isSameExceptionEvent(currentEvent, previousEvent)) { + return true; + } + return false; + }; + /** JSDoc */ + Dedupe.prototype._isSameMessageEvent = function (currentEvent, previousEvent) { + var currentMessage = currentEvent.message; + var previousMessage = previousEvent.message; + // If neither event has a message property, they were both exceptions, so bail out + if (!currentMessage && !previousMessage) { + return false; + } + // If only one event has a stacktrace, but not the other one, they are not the same + if ((currentMessage && !previousMessage) || (!currentMessage && previousMessage)) { + return false; + } + if (currentMessage !== previousMessage) { + return false; + } + if (!this._isSameFingerprint(currentEvent, previousEvent)) { + return false; + } + if (!this._isSameStacktrace(currentEvent, previousEvent)) { + return false; + } + return true; + }; + /** JSDoc */ + Dedupe.prototype._getFramesFromEvent = function (event) { + var exception = event.exception; + if (exception) { + try { + // @ts-ignore Object could be undefined + return exception.values[0].stacktrace.frames; + } + catch (_oO) { + return undefined; + } + } + else if (event.stacktrace) { + return event.stacktrace.frames; + } + return undefined; + }; + /** JSDoc */ + Dedupe.prototype._isSameStacktrace = function (currentEvent, previousEvent) { + var currentFrames = this._getFramesFromEvent(currentEvent); + var previousFrames = this._getFramesFromEvent(previousEvent); + // If neither event has a stacktrace, they are assumed to be the same + if (!currentFrames && !previousFrames) { + return true; + } + // If only one event has a stacktrace, but not the other one, they are not the same + if ((currentFrames && !previousFrames) || (!currentFrames && previousFrames)) { + return false; + } + currentFrames = currentFrames; + previousFrames = previousFrames; + // If number of frames differ, they are not the same + if (previousFrames.length !== currentFrames.length) { + return false; + } + // Otherwise, compare the two + for (var i = 0; i < previousFrames.length; i++) { + var frameA = previousFrames[i]; + var frameB = currentFrames[i]; + if (frameA.filename !== frameB.filename || + frameA.lineno !== frameB.lineno || + frameA.colno !== frameB.colno || + frameA.function !== frameB.function) { + return false; + } + } + return true; + }; + /** JSDoc */ + Dedupe.prototype._getExceptionFromEvent = function (event) { + return event.exception && event.exception.values && event.exception.values[0]; + }; + /** JSDoc */ + Dedupe.prototype._isSameExceptionEvent = function (currentEvent, previousEvent) { + var previousException = this._getExceptionFromEvent(previousEvent); + var currentException = this._getExceptionFromEvent(currentEvent); + if (!previousException || !currentException) { + return false; + } + if (previousException.type !== currentException.type || previousException.value !== currentException.value) { + return false; + } + if (!this._isSameFingerprint(currentEvent, previousEvent)) { + return false; + } + if (!this._isSameStacktrace(currentEvent, previousEvent)) { + return false; + } + return true; + }; + /** JSDoc */ + Dedupe.prototype._isSameFingerprint = function (currentEvent, previousEvent) { + var currentFingerprint = currentEvent.fingerprint; + var previousFingerprint = previousEvent.fingerprint; + // If neither event has a fingerprint, they are assumed to be the same + if (!currentFingerprint && !previousFingerprint) { + return true; + } + // If only one event has a fingerprint, but not the other one, they are not the same + if ((currentFingerprint && !previousFingerprint) || (!currentFingerprint && previousFingerprint)) { + return false; + } + currentFingerprint = currentFingerprint; + previousFingerprint = previousFingerprint; + // Otherwise, compare the two + try { + return !!(currentFingerprint.join('') === previousFingerprint.join('')); + } + catch (_oO) { + return false; + } + }; + /** + * @inheritDoc + */ + Dedupe.id = 'Dedupe'; + return Dedupe; +}()); + +//# sourceMappingURL=dedupe.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/integrations/globalhandlers.js": +/*!*************************************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/integrations/globalhandlers.js ***! + \*************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "GlobalHandlers": () => (/* binding */ GlobalHandlers) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/hub/esm/hub.js"); +/* harmony import */ var _sentry_types__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @sentry/types */ "./node_modules/@sentry/types/esm/severity.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/instrument.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/is.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _eventbuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../eventbuilder */ "./node_modules/@sentry/browser/esm/eventbuilder.js"); +/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../helpers */ "./node_modules/@sentry/browser/esm/helpers.js"); + +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ + + + + + +/** Global handlers */ +var GlobalHandlers = /** @class */ (function () { + /** JSDoc */ + function GlobalHandlers(options) { + /** + * @inheritDoc + */ + this.name = GlobalHandlers.id; + /** JSDoc */ + this._onErrorHandlerInstalled = false; + /** JSDoc */ + this._onUnhandledRejectionHandlerInstalled = false; + this._options = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({ onerror: true, onunhandledrejection: true }, options); + } + /** + * @inheritDoc + */ + GlobalHandlers.prototype.setupOnce = function () { + Error.stackTraceLimit = 50; + if (this._options.onerror) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log('Global Handler attached: onerror'); + this._installGlobalOnErrorHandler(); + } + if (this._options.onunhandledrejection) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log('Global Handler attached: onunhandledrejection'); + this._installGlobalOnUnhandledRejectionHandler(); + } + }; + /** JSDoc */ + GlobalHandlers.prototype._installGlobalOnErrorHandler = function () { + var _this = this; + if (this._onErrorHandlerInstalled) { + return; + } + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.addInstrumentationHandler)({ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + callback: function (data) { + var error = data.error; + var currentHub = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_3__.getCurrentHub)(); + var hasIntegration = currentHub.getIntegration(GlobalHandlers); + var isFailedOwnDelivery = error && error.__sentry_own_request__ === true; + if (!hasIntegration || (0,_helpers__WEBPACK_IMPORTED_MODULE_4__.shouldIgnoreOnError)() || isFailedOwnDelivery) { + return; + } + var client = currentHub.getClient(); + var event = error === undefined && (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.isString)(data.msg) + ? _this._eventFromIncompleteOnError(data.msg, data.url, data.line, data.column) + : _this._enhanceEventWithInitialFrame((0,_eventbuilder__WEBPACK_IMPORTED_MODULE_6__.eventFromUnknownInput)(error || data.msg, undefined, { + attachStacktrace: client && client.getOptions().attachStacktrace, + rejection: false, + }), data.url, data.line, data.column); + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.addExceptionMechanism)(event, { + handled: false, + type: 'onerror', + }); + currentHub.captureEvent(event, { + originalException: error, + }); + }, + type: 'error', + }); + this._onErrorHandlerInstalled = true; + }; + /** JSDoc */ + GlobalHandlers.prototype._installGlobalOnUnhandledRejectionHandler = function () { + var _this = this; + if (this._onUnhandledRejectionHandlerInstalled) { + return; + } + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.addInstrumentationHandler)({ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + callback: function (e) { + var error = e; + // dig the object of the rejection out of known event types + try { + // PromiseRejectionEvents store the object of the rejection under 'reason' + // see https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent + if ('reason' in e) { + error = e.reason; + } + // something, somewhere, (likely a browser extension) effectively casts PromiseRejectionEvents + // to CustomEvents, moving the `promise` and `reason` attributes of the PRE into + // the CustomEvent's `detail` attribute, since they're not part of CustomEvent's spec + // see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent and + // https://github.com/getsentry/sentry-javascript/issues/2380 + else if ('detail' in e && 'reason' in e.detail) { + error = e.detail.reason; + } + } + catch (_oO) { + // no-empty + } + var currentHub = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_3__.getCurrentHub)(); + var hasIntegration = currentHub.getIntegration(GlobalHandlers); + var isFailedOwnDelivery = error && error.__sentry_own_request__ === true; + if (!hasIntegration || (0,_helpers__WEBPACK_IMPORTED_MODULE_4__.shouldIgnoreOnError)() || isFailedOwnDelivery) { + return true; + } + var client = currentHub.getClient(); + var event = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.isPrimitive)(error) + ? _this._eventFromRejectionWithPrimitive(error) + : (0,_eventbuilder__WEBPACK_IMPORTED_MODULE_6__.eventFromUnknownInput)(error, undefined, { + attachStacktrace: client && client.getOptions().attachStacktrace, + rejection: true, + }); + event.level = _sentry_types__WEBPACK_IMPORTED_MODULE_8__.Severity.Error; + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.addExceptionMechanism)(event, { + handled: false, + type: 'onunhandledrejection', + }); + currentHub.captureEvent(event, { + originalException: error, + }); + return; + }, + type: 'unhandledrejection', + }); + this._onUnhandledRejectionHandlerInstalled = true; + }; + /** + * This function creates a stack from an old, error-less onerror handler. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + GlobalHandlers.prototype._eventFromIncompleteOnError = function (msg, url, line, column) { + var ERROR_TYPES_RE = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i; + // If 'message' is ErrorEvent, get real message from inside + var message = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.isErrorEvent)(msg) ? msg.message : msg; + var name; + var groups = message.match(ERROR_TYPES_RE); + if (groups) { + name = groups[1]; + message = groups[2]; + } + var event = { + exception: { + values: [ + { + type: name || 'Error', + value: message, + }, + ], + }, + }; + return this._enhanceEventWithInitialFrame(event, url, line, column); + }; + /** + * Create an event from a promise rejection where the `reason` is a primitive. + * + * @param reason: The `reason` property of the promise rejection + * @returns An Event object with an appropriate `exception` value + */ + GlobalHandlers.prototype._eventFromRejectionWithPrimitive = function (reason) { + return { + exception: { + values: [ + { + type: 'UnhandledRejection', + // String() is needed because the Primitive type includes symbols (which can't be automatically stringified) + value: "Non-Error promise rejection captured with value: " + String(reason), + }, + ], + }, + }; + }; + /** JSDoc */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + GlobalHandlers.prototype._enhanceEventWithInitialFrame = function (event, url, line, column) { + event.exception = event.exception || {}; + event.exception.values = event.exception.values || []; + event.exception.values[0] = event.exception.values[0] || {}; + event.exception.values[0].stacktrace = event.exception.values[0].stacktrace || {}; + event.exception.values[0].stacktrace.frames = event.exception.values[0].stacktrace.frames || []; + var colno = isNaN(parseInt(column, 10)) ? undefined : column; + var lineno = isNaN(parseInt(line, 10)) ? undefined : line; + var filename = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.isString)(url) && url.length > 0 ? url : (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.getLocationHref)(); + if (event.exception.values[0].stacktrace.frames.length === 0) { + event.exception.values[0].stacktrace.frames.push({ + colno: colno, + filename: filename, + function: '?', + in_app: true, + lineno: lineno, + }); + } + return event; + }; + /** + * @inheritDoc + */ + GlobalHandlers.id = 'GlobalHandlers'; + return GlobalHandlers; +}()); + +//# sourceMappingURL=globalhandlers.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/integrations/linkederrors.js": +/*!***********************************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/integrations/linkederrors.js ***! + \***********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "LinkedErrors": () => (/* binding */ LinkedErrors) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/hub/esm/scope.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/hub/esm/hub.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/is.js"); +/* harmony import */ var _parsers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../parsers */ "./node_modules/@sentry/browser/esm/parsers.js"); +/* harmony import */ var _tracekit__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../tracekit */ "./node_modules/@sentry/browser/esm/tracekit.js"); + + + + + +var DEFAULT_KEY = 'cause'; +var DEFAULT_LIMIT = 5; +/** Adds SDK info to an event. */ +var LinkedErrors = /** @class */ (function () { + /** + * @inheritDoc + */ + function LinkedErrors(options) { + if (options === void 0) { options = {}; } + /** + * @inheritDoc + */ + this.name = LinkedErrors.id; + this._key = options.key || DEFAULT_KEY; + this._limit = options.limit || DEFAULT_LIMIT; + } + /** + * @inheritDoc + */ + LinkedErrors.prototype.setupOnce = function () { + (0,_sentry_core__WEBPACK_IMPORTED_MODULE_0__.addGlobalEventProcessor)(function (event, hint) { + var self = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)().getIntegration(LinkedErrors); + if (self) { + return self._handler(event, hint); + } + return event; + }); + }; + /** + * @inheritDoc + */ + LinkedErrors.prototype._handler = function (event, hint) { + if (!event.exception || !event.exception.values || !hint || !(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.isInstanceOf)(hint.originalException, Error)) { + return event; + } + var linkedErrors = this._walkErrorTree(hint.originalException, this._key); + event.exception.values = (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__spread)(linkedErrors, event.exception.values); + return event; + }; + /** + * @inheritDoc + */ + LinkedErrors.prototype._walkErrorTree = function (error, key, stack) { + if (stack === void 0) { stack = []; } + if (!(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.isInstanceOf)(error[key], Error) || stack.length + 1 >= this._limit) { + return stack; + } + var stacktrace = (0,_tracekit__WEBPACK_IMPORTED_MODULE_4__.computeStackTrace)(error[key]); + var exception = (0,_parsers__WEBPACK_IMPORTED_MODULE_5__.exceptionFromStacktrace)(stacktrace); + return this._walkErrorTree(error[key], key, (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__spread)([exception], stack)); + }; + /** + * @inheritDoc + */ + LinkedErrors.id = 'LinkedErrors'; + return LinkedErrors; +}()); + +//# sourceMappingURL=linkederrors.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/integrations/trycatch.js": +/*!*******************************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/integrations/trycatch.js ***! + \*******************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "TryCatch": () => (/* binding */ TryCatch) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/object.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/stacktrace.js"); +/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../helpers */ "./node_modules/@sentry/browser/esm/helpers.js"); + + + +var DEFAULT_EVENT_TARGET = [ + 'EventTarget', + 'Window', + 'Node', + 'ApplicationCache', + 'AudioTrackList', + 'ChannelMergerNode', + 'CryptoOperation', + 'EventSource', + 'FileReader', + 'HTMLUnknownElement', + 'IDBDatabase', + 'IDBRequest', + 'IDBTransaction', + 'KeyOperation', + 'MediaController', + 'MessagePort', + 'ModalWindow', + 'Notification', + 'SVGElementInstance', + 'Screen', + 'TextTrack', + 'TextTrackCue', + 'TextTrackList', + 'WebSocket', + 'WebSocketWorker', + 'Worker', + 'XMLHttpRequest', + 'XMLHttpRequestEventTarget', + 'XMLHttpRequestUpload', +]; +/** Wrap timer functions and event targets to catch errors and provide better meta data */ +var TryCatch = /** @class */ (function () { + /** + * @inheritDoc + */ + function TryCatch(options) { + /** + * @inheritDoc + */ + this.name = TryCatch.id; + this._options = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({ XMLHttpRequest: true, eventTarget: true, requestAnimationFrame: true, setInterval: true, setTimeout: true }, options); + } + /** + * Wrap timer functions and event targets to catch errors + * and provide better metadata. + */ + TryCatch.prototype.setupOnce = function () { + var global = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.getGlobalObject)(); + if (this._options.setTimeout) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.fill)(global, 'setTimeout', this._wrapTimeFunction.bind(this)); + } + if (this._options.setInterval) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.fill)(global, 'setInterval', this._wrapTimeFunction.bind(this)); + } + if (this._options.requestAnimationFrame) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.fill)(global, 'requestAnimationFrame', this._wrapRAF.bind(this)); + } + if (this._options.XMLHttpRequest && 'XMLHttpRequest' in global) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.fill)(XMLHttpRequest.prototype, 'send', this._wrapXHR.bind(this)); + } + if (this._options.eventTarget) { + var eventTarget = Array.isArray(this._options.eventTarget) ? this._options.eventTarget : DEFAULT_EVENT_TARGET; + eventTarget.forEach(this._wrapEventTarget.bind(this)); + } + }; + /** JSDoc */ + TryCatch.prototype._wrapTimeFunction = function (original) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var originalCallback = args[0]; + args[0] = (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.wrap)(originalCallback, { + mechanism: { + data: { function: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.getFunctionName)(original) }, + handled: true, + type: 'instrument', + }, + }); + return original.apply(this, args); + }; + }; + /** JSDoc */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + TryCatch.prototype._wrapRAF = function (original) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return function (callback) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + return original.call(this, (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.wrap)(callback, { + mechanism: { + data: { + function: 'requestAnimationFrame', + handler: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.getFunctionName)(original), + }, + handled: true, + type: 'instrument', + }, + })); + }; + }; + /** JSDoc */ + TryCatch.prototype._wrapEventTarget = function (target) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + var global = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.getGlobalObject)(); + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + var proto = global[target] && global[target].prototype; + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) { + return; + } + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.fill)(proto, 'addEventListener', function (original) { + return function (eventName, fn, options) { + try { + if (typeof fn.handleEvent === 'function') { + fn.handleEvent = (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.wrap)(fn.handleEvent.bind(fn), { + mechanism: { + data: { + function: 'handleEvent', + handler: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.getFunctionName)(fn), + target: target, + }, + handled: true, + type: 'instrument', + }, + }); + } + } + catch (err) { + // can sometimes get 'Permission denied to access property "handle Event' + } + return original.call(this, eventName, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.wrap)(fn, { + mechanism: { + data: { + function: 'addEventListener', + handler: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.getFunctionName)(fn), + target: target, + }, + handled: true, + type: 'instrument', + }, + }), options); + }; + }); + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.fill)(proto, 'removeEventListener', function (originalRemoveEventListener) { + return function (eventName, fn, options) { + var _a; + /** + * There are 2 possible scenarios here: + * + * 1. Someone passes a callback, which was attached prior to Sentry initialization, or by using unmodified + * method, eg. `document.addEventListener.call(el, name, handler). In this case, we treat this function + * as a pass-through, and call original `removeEventListener` with it. + * + * 2. Someone passes a callback, which was attached after Sentry was initialized, which means that it was using + * our wrapped version of `addEventListener`, which internally calls `wrap` helper. + * This helper "wraps" whole callback inside a try/catch statement, and attached appropriate metadata to it, + * in order for us to make a distinction between wrapped/non-wrapped functions possible. + * If a function was wrapped, it has additional property of `__sentry_wrapped__`, holding the handler. + * + * When someone adds a handler prior to initialization, and then do it again, but after, + * then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible + * to get rid of the initial handler and it'd stick there forever. + */ + var wrappedEventHandler = fn; + try { + var originalEventHandler = (_a = wrappedEventHandler) === null || _a === void 0 ? void 0 : _a.__sentry_wrapped__; + if (originalEventHandler) { + originalRemoveEventListener.call(this, eventName, originalEventHandler, options); + } + } + catch (e) { + // ignore, accessing __sentry_wrapped__ will throw in some Selenium environments + } + return originalRemoveEventListener.call(this, eventName, wrappedEventHandler, options); + }; + }); + }; + /** JSDoc */ + TryCatch.prototype._wrapXHR = function (originalSend) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + // eslint-disable-next-line @typescript-eslint/no-this-alias + var xhr = this; + var xmlHttpRequestProps = ['onload', 'onerror', 'onprogress', 'onreadystatechange']; + xmlHttpRequestProps.forEach(function (prop) { + if (prop in xhr && typeof xhr[prop] === 'function') { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.fill)(xhr, prop, function (original) { + var wrapOptions = { + mechanism: { + data: { + function: prop, + handler: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.getFunctionName)(original), + }, + handled: true, + type: 'instrument', + }, + }; + // If Instrument integration has been called before TryCatch, get the name of original function + if (original.__sentry_original__) { + wrapOptions.mechanism.data.handler = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.getFunctionName)(original.__sentry_original__); + } + // Otherwise wrap directly + return (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.wrap)(original, wrapOptions); + }); + } + }); + return originalSend.apply(this, args); + }; + }; + /** + * @inheritDoc + */ + TryCatch.id = 'TryCatch'; + return TryCatch; +}()); + +//# sourceMappingURL=trycatch.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/integrations/useragent.js": +/*!********************************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/integrations/useragent.js ***! + \********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "UserAgent": () => (/* binding */ UserAgent) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/hub/esm/scope.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/hub/esm/hub.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); + + + +var global = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)(); +/** UserAgent */ +var UserAgent = /** @class */ (function () { + function UserAgent() { + /** + * @inheritDoc + */ + this.name = UserAgent.id; + } + /** + * @inheritDoc + */ + UserAgent.prototype.setupOnce = function () { + (0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.addGlobalEventProcessor)(function (event) { + var _a, _b, _c; + if ((0,_sentry_core__WEBPACK_IMPORTED_MODULE_2__.getCurrentHub)().getIntegration(UserAgent)) { + // if none of the information we want exists, don't bother + if (!global.navigator && !global.location && !global.document) { + return event; + } + // grab as much info as exists and add it to the event + var url = ((_a = event.request) === null || _a === void 0 ? void 0 : _a.url) || ((_b = global.location) === null || _b === void 0 ? void 0 : _b.href); + var referrer = (global.document || {}).referrer; + var userAgent = (global.navigator || {}).userAgent; + var headers = (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_3__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_3__.__assign)({}, (_c = event.request) === null || _c === void 0 ? void 0 : _c.headers), (referrer && { Referer: referrer })), (userAgent && { 'User-Agent': userAgent })); + var request = (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_3__.__assign)({}, (url && { url: url })), { headers: headers }); + return (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_3__.__assign)({}, event), { request: request }); + } + return event; + }); + }; + /** + * @inheritDoc + */ + UserAgent.id = 'UserAgent'; + return UserAgent; +}()); + +//# sourceMappingURL=useragent.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/parsers.js": +/*!*****************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/parsers.js ***! + \*****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "exceptionFromStacktrace": () => (/* binding */ exceptionFromStacktrace), +/* harmony export */ "eventFromPlainObject": () => (/* binding */ eventFromPlainObject), +/* harmony export */ "eventFromStacktrace": () => (/* binding */ eventFromStacktrace), +/* harmony export */ "prepareFramesForEvent": () => (/* binding */ prepareFramesForEvent) +/* harmony export */ }); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/is.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/object.js"); +/* harmony import */ var _tracekit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tracekit */ "./node_modules/@sentry/browser/esm/tracekit.js"); + + +var STACKTRACE_LIMIT = 50; +/** + * This function creates an exception from an TraceKitStackTrace + * @param stacktrace TraceKitStackTrace that will be converted to an exception + * @hidden + */ +function exceptionFromStacktrace(stacktrace) { + var frames = prepareFramesForEvent(stacktrace.stack); + var exception = { + type: stacktrace.name, + value: stacktrace.message, + }; + if (frames && frames.length) { + exception.stacktrace = { frames: frames }; + } + if (exception.type === undefined && exception.value === '') { + exception.value = 'Unrecoverable error caught'; + } + return exception; +} +/** + * @hidden + */ +function eventFromPlainObject(exception, syntheticException, rejection) { + var event = { + exception: { + values: [ + { + type: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.isEvent)(exception) ? exception.constructor.name : rejection ? 'UnhandledRejection' : 'Error', + value: "Non-Error " + (rejection ? 'promise rejection' : 'exception') + " captured with keys: " + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.extractExceptionKeysForMessage)(exception), + }, + ], + }, + extra: { + __serialized__: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.normalizeToSize)(exception), + }, + }; + if (syntheticException) { + var stacktrace = (0,_tracekit__WEBPACK_IMPORTED_MODULE_2__.computeStackTrace)(syntheticException); + var frames_1 = prepareFramesForEvent(stacktrace.stack); + event.stacktrace = { + frames: frames_1, + }; + } + return event; +} +/** + * @hidden + */ +function eventFromStacktrace(stacktrace) { + var exception = exceptionFromStacktrace(stacktrace); + return { + exception: { + values: [exception], + }, + }; +} +/** + * @hidden + */ +function prepareFramesForEvent(stack) { + if (!stack || !stack.length) { + return []; + } + var localStack = stack; + var firstFrameFunction = localStack[0].func || ''; + var lastFrameFunction = localStack[localStack.length - 1].func || ''; + // If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call) + if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) { + localStack = localStack.slice(1); + } + // If stack ends with one of our internal API calls, remove it (ends, meaning it's the bottom of the stack - aka top-most call) + if (lastFrameFunction.indexOf('sentryWrapped') !== -1) { + localStack = localStack.slice(0, -1); + } + // The frame where the crash happened, should be the last entry in the array + return localStack + .slice(0, STACKTRACE_LIMIT) + .map(function (frame) { return ({ + colno: frame.column === null ? undefined : frame.column, + filename: frame.url || localStack[0].url, + function: frame.func || '?', + in_app: true, + lineno: frame.line === null ? undefined : frame.line, + }); }) + .reverse(); +} +//# sourceMappingURL=parsers.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/sdk.js": +/*!*************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/sdk.js ***! + \*************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "defaultIntegrations": () => (/* binding */ defaultIntegrations), +/* harmony export */ "init": () => (/* binding */ init), +/* harmony export */ "showReportDialog": () => (/* binding */ showReportDialog), +/* harmony export */ "lastEventId": () => (/* binding */ lastEventId), +/* harmony export */ "forceLoad": () => (/* binding */ forceLoad), +/* harmony export */ "onLoad": () => (/* binding */ onLoad), +/* harmony export */ "flush": () => (/* binding */ flush), +/* harmony export */ "close": () => (/* binding */ close), +/* harmony export */ "wrap": () => (/* binding */ wrap) +/* harmony export */ }); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/core/esm/integrations/inboundfilters.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/core/esm/integrations/functiontostring.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/core/esm/sdk.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/hub/esm/hub.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/syncpromise.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/instrument.js"); +/* harmony import */ var _client__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./client */ "./node_modules/@sentry/browser/esm/client.js"); +/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./helpers */ "./node_modules/@sentry/browser/esm/helpers.js"); +/* harmony import */ var _integrations__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./integrations */ "./node_modules/@sentry/browser/esm/integrations/trycatch.js"); +/* harmony import */ var _integrations__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./integrations */ "./node_modules/@sentry/browser/esm/integrations/breadcrumbs.js"); +/* harmony import */ var _integrations__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./integrations */ "./node_modules/@sentry/browser/esm/integrations/globalhandlers.js"); +/* harmony import */ var _integrations__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./integrations */ "./node_modules/@sentry/browser/esm/integrations/linkederrors.js"); +/* harmony import */ var _integrations__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./integrations */ "./node_modules/@sentry/browser/esm/integrations/dedupe.js"); +/* harmony import */ var _integrations__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./integrations */ "./node_modules/@sentry/browser/esm/integrations/useragent.js"); + + + + + +var defaultIntegrations = [ + new _sentry_core__WEBPACK_IMPORTED_MODULE_0__.InboundFilters(), + new _sentry_core__WEBPACK_IMPORTED_MODULE_1__.FunctionToString(), + new _integrations__WEBPACK_IMPORTED_MODULE_2__.TryCatch(), + new _integrations__WEBPACK_IMPORTED_MODULE_3__.Breadcrumbs(), + new _integrations__WEBPACK_IMPORTED_MODULE_4__.GlobalHandlers(), + new _integrations__WEBPACK_IMPORTED_MODULE_5__.LinkedErrors(), + new _integrations__WEBPACK_IMPORTED_MODULE_6__.Dedupe(), + new _integrations__WEBPACK_IMPORTED_MODULE_7__.UserAgent(), +]; +/** + * The Sentry Browser SDK Client. + * + * To use this SDK, call the {@link init} function as early as possible when + * loading the web page. To set context information or send manual events, use + * the provided methods. + * + * @example + * + * ``` + * + * import { init } from '@sentry/browser'; + * + * init({ + * dsn: '__DSN__', + * // ... + * }); + * ``` + * + * @example + * ``` + * + * import { configureScope } from '@sentry/browser'; + * configureScope((scope: Scope) => { + * scope.setExtra({ battery: 0.7 }); + * scope.setTag({ user_mode: 'admin' }); + * scope.setUser({ id: '4711' }); + * }); + * ``` + * + * @example + * ``` + * + * import { addBreadcrumb } from '@sentry/browser'; + * addBreadcrumb({ + * message: 'My Breadcrumb', + * // ... + * }); + * ``` + * + * @example + * + * ``` + * + * import * as Sentry from '@sentry/browser'; + * Sentry.captureMessage('Hello, world!'); + * Sentry.captureException(new Error('Good bye')); + * Sentry.captureEvent({ + * message: 'Manual', + * stacktrace: [ + * // ... + * ], + * }); + * ``` + * + * @see {@link BrowserOptions} for documentation on configuration options. + */ +function init(options) { + if (options === void 0) { options = {}; } + if (options.defaultIntegrations === undefined) { + options.defaultIntegrations = defaultIntegrations; + } + if (options.release === undefined) { + var window_1 = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_8__.getGlobalObject)(); + // This supports the variable that sentry-webpack-plugin injects + if (window_1.SENTRY_RELEASE && window_1.SENTRY_RELEASE.id) { + options.release = window_1.SENTRY_RELEASE.id; + } + } + if (options.autoSessionTracking === undefined) { + options.autoSessionTracking = true; + } + (0,_sentry_core__WEBPACK_IMPORTED_MODULE_9__.initAndBind)(_client__WEBPACK_IMPORTED_MODULE_10__.BrowserClient, options); + if (options.autoSessionTracking) { + startSessionTracking(); + } +} +/** + * Present the user with a report dialog. + * + * @param options Everything is optional, we try to fetch all info need from the global scope. + */ +function showReportDialog(options) { + if (options === void 0) { options = {}; } + if (!options.eventId) { + options.eventId = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_11__.getCurrentHub)().lastEventId(); + } + var client = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_11__.getCurrentHub)().getClient(); + if (client) { + client.showReportDialog(options); + } +} +/** + * This is the getter for lastEventId. + * + * @returns The last event id of a captured event. + */ +function lastEventId() { + return (0,_sentry_core__WEBPACK_IMPORTED_MODULE_11__.getCurrentHub)().lastEventId(); +} +/** + * This function is here to be API compatible with the loader. + * @hidden + */ +function forceLoad() { + // Noop +} +/** + * This function is here to be API compatible with the loader. + * @hidden + */ +function onLoad(callback) { + callback(); +} +/** + * A promise that resolves when all current events have been sent. + * If you provide a timeout and the queue takes longer to drain the promise returns false. + * + * @param timeout Maximum time in ms the client should wait. + */ +function flush(timeout) { + var client = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_11__.getCurrentHub)().getClient(); + if (client) { + return client.flush(timeout); + } + return _sentry_utils__WEBPACK_IMPORTED_MODULE_12__.SyncPromise.reject(false); +} +/** + * A promise that resolves when all current events have been sent. + * If you provide a timeout and the queue takes longer to drain the promise returns false. + * + * @param timeout Maximum time in ms the client should wait. + */ +function close(timeout) { + var client = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_11__.getCurrentHub)().getClient(); + if (client) { + return client.close(timeout); + } + return _sentry_utils__WEBPACK_IMPORTED_MODULE_12__.SyncPromise.reject(false); +} +/** + * Wrap code within a try/catch block so the SDK is able to capture errors. + * + * @param fn A function to wrap. + * + * @returns The result of wrapped function call. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function wrap(fn) { + return (0,_helpers__WEBPACK_IMPORTED_MODULE_13__.wrap)(fn)(); +} +/** + * Enable automatic Session Tracking for the initial page load. + */ +function startSessionTracking() { + var window = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_8__.getGlobalObject)(); + var document = window.document; + if (typeof document === 'undefined') { + _sentry_utils__WEBPACK_IMPORTED_MODULE_14__.logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.'); + return; + } + var hub = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_11__.getCurrentHub)(); + // The only way for this to be false is for there to be a version mismatch between @sentry/browser (>= 6.0.0) and + // @sentry/hub (< 5.27.0). In the simple case, there won't ever be such a mismatch, because the two packages are + // pinned at the same version in package.json, but there are edge cases where it's possible. See + // https://github.com/getsentry/sentry-javascript/issues/3207 and + // https://github.com/getsentry/sentry-javascript/issues/3234 and + // https://github.com/getsentry/sentry-javascript/issues/3278. + if (typeof hub.startSession !== 'function' || typeof hub.captureSession !== 'function') { + return; + } + // The session duration for browser sessions does not track a meaningful + // concept that can be used as a metric. + // Automatically captured sessions are akin to page views, and thus we + // discard their duration. + hub.startSession({ ignoreDuration: true }); + hub.captureSession(); + // We want to create a session for every navigation as well + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_15__.addInstrumentationHandler)({ + callback: function (_a) { + var from = _a.from, to = _a.to; + // Don't create an additional session for the initial route or if the location did not change + if (from === undefined || from === to) { + return; + } + hub.startSession({ ignoreDuration: true }); + hub.captureSession(); + }, + type: 'history', + }); +} +//# sourceMappingURL=sdk.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/tracekit.js": +/*!******************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/tracekit.js ***! + \******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "computeStackTrace": () => (/* binding */ computeStackTrace) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/** + * This was originally forked from https://github.com/occ/TraceKit, but has since been + * largely modified and is now maintained as part of Sentry JS SDK. + */ + +// global reference to slice +var UNKNOWN_FUNCTION = '?'; +// Chromium based browsers: Chrome, Brave, new Opera, new Edge +var chrome = /^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack||[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i; +// gecko regex: `(?:bundle|\d+\.js)`: `bundle` is for react native, `\d+\.js` also but specifically for ram bundles because it +// generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js +// We need this specific case for now because we want no other regex to match. +var gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i; +var winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i; +var geckoEval = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i; +var chromeEval = /\((\S*)(?::(\d+))(?::(\d+))\)/; +// Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108 +var reactMinifiedRegexp = /Minified React error #\d+;/i; +/** JSDoc */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types +function computeStackTrace(ex) { + var stack = null; + var popSize = 0; + if (ex) { + if (typeof ex.framesToPop === 'number') { + popSize = ex.framesToPop; + } + else if (reactMinifiedRegexp.test(ex.message)) { + popSize = 1; + } + } + try { + // This must be tried first because Opera 10 *destroys* + // its stacktrace property if you try to access the stack + // property first!! + stack = computeStackTraceFromStacktraceProp(ex); + if (stack) { + return popFrames(stack, popSize); + } + } + catch (e) { + // no-empty + } + try { + stack = computeStackTraceFromStackProp(ex); + if (stack) { + return popFrames(stack, popSize); + } + } + catch (e) { + // no-empty + } + return { + message: extractMessage(ex), + name: ex && ex.name, + stack: [], + failed: true, + }; +} +/** JSDoc */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any, complexity +function computeStackTraceFromStackProp(ex) { + if (!ex || !ex.stack) { + return null; + } + var stack = []; + var lines = ex.stack.split('\n'); + var isEval; + var submatch; + var parts; + var element; + for (var i = 0; i < lines.length; ++i) { + if ((parts = chrome.exec(lines[i]))) { + var isNative = parts[2] && parts[2].indexOf('native') === 0; // start of line + isEval = parts[2] && parts[2].indexOf('eval') === 0; // start of line + if (isEval && (submatch = chromeEval.exec(parts[2]))) { + // throw out eval line/column and use top-most line/column number + parts[2] = submatch[1]; // url + parts[3] = submatch[2]; // line + parts[4] = submatch[3]; // column + } + // Arpad: Working with the regexp above is super painful. it is quite a hack, but just stripping the `address at ` + // prefix here seems like the quickest solution for now. + var url = parts[2] && parts[2].indexOf('address at ') === 0 ? parts[2].substr('address at '.length) : parts[2]; + // Kamil: One more hack won't hurt us right? Understanding and adding more rules on top of these regexps right now + // would be way too time consuming. (TODO: Rewrite whole RegExp to be more readable) + var func = parts[1] || UNKNOWN_FUNCTION; + var isSafariExtension = func.indexOf('safari-extension') !== -1; + var isSafariWebExtension = func.indexOf('safari-web-extension') !== -1; + if (isSafariExtension || isSafariWebExtension) { + func = func.indexOf('@') !== -1 ? func.split('@')[0] : UNKNOWN_FUNCTION; + url = isSafariExtension ? "safari-extension:" + url : "safari-web-extension:" + url; + } + element = { + url: url, + func: func, + args: isNative ? [parts[2]] : [], + line: parts[3] ? +parts[3] : null, + column: parts[4] ? +parts[4] : null, + }; + } + else if ((parts = winjs.exec(lines[i]))) { + element = { + url: parts[2], + func: parts[1] || UNKNOWN_FUNCTION, + args: [], + line: +parts[3], + column: parts[4] ? +parts[4] : null, + }; + } + else if ((parts = gecko.exec(lines[i]))) { + isEval = parts[3] && parts[3].indexOf(' > eval') > -1; + if (isEval && (submatch = geckoEval.exec(parts[3]))) { + // throw out eval line/column and use top-most line number + parts[1] = parts[1] || "eval"; + parts[3] = submatch[1]; + parts[4] = submatch[2]; + parts[5] = ''; // no column when eval + } + else if (i === 0 && !parts[5] && ex.columnNumber !== void 0) { + // FireFox uses this awesome columnNumber property for its top frame + // Also note, Firefox's column number is 0-based and everything else expects 1-based, + // so adding 1 + // NOTE: this hack doesn't work if top-most frame is eval + stack[0].column = ex.columnNumber + 1; + } + element = { + url: parts[3], + func: parts[1] || UNKNOWN_FUNCTION, + args: parts[2] ? parts[2].split(',') : [], + line: parts[4] ? +parts[4] : null, + column: parts[5] ? +parts[5] : null, + }; + } + else { + continue; + } + if (!element.func && element.line) { + element.func = UNKNOWN_FUNCTION; + } + stack.push(element); + } + if (!stack.length) { + return null; + } + return { + message: extractMessage(ex), + name: ex.name, + stack: stack, + }; +} +/** JSDoc */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function computeStackTraceFromStacktraceProp(ex) { + if (!ex || !ex.stacktrace) { + return null; + } + // Access and store the stacktrace property before doing ANYTHING + // else to it because Opera is not very good at providing it + // reliably in other circumstances. + var stacktrace = ex.stacktrace; + var opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i; + var opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:]+)>|([^)]+))\((.*)\))? in (.*):\s*$/i; + var lines = stacktrace.split('\n'); + var stack = []; + var parts; + for (var line = 0; line < lines.length; line += 2) { + var element = null; + if ((parts = opera10Regex.exec(lines[line]))) { + element = { + url: parts[2], + func: parts[3], + args: [], + line: +parts[1], + column: null, + }; + } + else if ((parts = opera11Regex.exec(lines[line]))) { + element = { + url: parts[6], + func: parts[3] || parts[4], + args: parts[5] ? parts[5].split(',') : [], + line: +parts[1], + column: +parts[2], + }; + } + if (element) { + if (!element.func && element.line) { + element.func = UNKNOWN_FUNCTION; + } + stack.push(element); + } + } + if (!stack.length) { + return null; + } + return { + message: extractMessage(ex), + name: ex.name, + stack: stack, + }; +} +/** Remove N number of frames from the stack */ +function popFrames(stacktrace, popSize) { + try { + return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, stacktrace), { stack: stacktrace.stack.slice(popSize) }); + } + catch (e) { + return stacktrace; + } +} +/** + * There are cases where stacktrace.message is an Event object + * https://github.com/getsentry/sentry-javascript/issues/1949 + * In this specific case we try to extract stacktrace.message.error.message + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function extractMessage(ex) { + var message = ex && ex.message; + if (!message) { + return 'No error message'; + } + if (message.error && typeof message.error.message === 'string') { + return message.error.message; + } + return message; +} +//# sourceMappingURL=tracekit.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/transports/base.js": +/*!*************************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/transports/base.js ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "BaseTransport": () => (/* binding */ BaseTransport) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/core/esm/api.js"); +/* harmony import */ var _sentry_types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/types */ "./node_modules/@sentry/types/esm/status.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/promisebuffer.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/error.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); + + + + +var CATEGORY_MAPPING = { + event: 'error', + transaction: 'transaction', + session: 'session', + attachment: 'attachment', +}; +/** Base Transport class implementation */ +var BaseTransport = /** @class */ (function () { + function BaseTransport(options) { + this.options = options; + /** A simple buffer holding all requests. */ + this._buffer = new _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.PromiseBuffer(30); + /** Locks transport after receiving rate limits in a response */ + this._rateLimits = {}; + this._api = new _sentry_core__WEBPACK_IMPORTED_MODULE_1__.API(options.dsn, options._metadata, options.tunnel); + // eslint-disable-next-line deprecation/deprecation + this.url = this._api.getStoreEndpointWithUrlEncodedAuth(); + } + /** + * @inheritDoc + */ + BaseTransport.prototype.sendEvent = function (_) { + throw new _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.SentryError('Transport Class has to implement `sendEvent` method'); + }; + /** + * @inheritDoc + */ + BaseTransport.prototype.close = function (timeout) { + return this._buffer.drain(timeout); + }; + /** + * Handle Sentry repsonse for promise-based transports. + */ + BaseTransport.prototype._handleResponse = function (_a) { + var requestType = _a.requestType, response = _a.response, headers = _a.headers, resolve = _a.resolve, reject = _a.reject; + var status = _sentry_types__WEBPACK_IMPORTED_MODULE_3__.Status.fromHttpCode(response.status); + /** + * "The name is case-insensitive." + * https://developer.mozilla.org/en-US/docs/Web/API/Headers/get + */ + var limited = this._handleRateLimit(headers); + if (limited) + _sentry_utils__WEBPACK_IMPORTED_MODULE_4__.logger.warn("Too many " + requestType + " requests, backing off until: " + this._disabledUntil(requestType)); + if (status === _sentry_types__WEBPACK_IMPORTED_MODULE_3__.Status.Success) { + resolve({ status: status }); + return; + } + reject(response); + }; + /** + * Gets the time that given category is disabled until for rate limiting + */ + BaseTransport.prototype._disabledUntil = function (requestType) { + var category = CATEGORY_MAPPING[requestType]; + return this._rateLimits[category] || this._rateLimits.all; + }; + /** + * Checks if a category is rate limited + */ + BaseTransport.prototype._isRateLimited = function (requestType) { + return this._disabledUntil(requestType) > new Date(Date.now()); + }; + /** + * Sets internal _rateLimits from incoming headers. Returns true if headers contains a non-empty rate limiting header. + */ + BaseTransport.prototype._handleRateLimit = function (headers) { + var e_1, _a, e_2, _b; + var now = Date.now(); + var rlHeader = headers['x-sentry-rate-limits']; + var raHeader = headers['retry-after']; + if (rlHeader) { + try { + // rate limit headers are of the form + //
,
,.. + // where each
is of the form + // : : : + // where + // is a delay in ms + // is the event type(s) (error, transaction, etc) being rate limited and is of the form + // ;;... + // is what's being limited (org, project, or key) - ignored by SDK + // is an arbitrary string like "org_quota" - ignored by SDK + for (var _c = (0,tslib__WEBPACK_IMPORTED_MODULE_5__.__values)(rlHeader.trim().split(',')), _d = _c.next(); !_d.done; _d = _c.next()) { + var limit = _d.value; + var parameters = limit.split(':', 2); + var headerDelay = parseInt(parameters[0], 10); + var delay = (!isNaN(headerDelay) ? headerDelay : 60) * 1000; // 60sec default + try { + for (var _e = (e_2 = void 0, (0,tslib__WEBPACK_IMPORTED_MODULE_5__.__values)(parameters[1].split(';'))), _f = _e.next(); !_f.done; _f = _e.next()) { + var category = _f.value; + this._rateLimits[category || 'all'] = new Date(now + delay); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_f && !_f.done && (_b = _e.return)) _b.call(_e); + } + finally { if (e_2) throw e_2.error; } + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_d && !_d.done && (_a = _c.return)) _a.call(_c); + } + finally { if (e_1) throw e_1.error; } + } + return true; + } + else if (raHeader) { + this._rateLimits.all = new Date(now + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.parseRetryAfterHeader)(now, raHeader)); + return true; + } + return false; + }; + return BaseTransport; +}()); + +//# sourceMappingURL=base.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/transports/fetch.js": +/*!**************************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/transports/fetch.js ***! + \**************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "FetchTransport": () => (/* binding */ FetchTransport) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/core/esm/request.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/supports.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/syncpromise.js"); +/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./base */ "./node_modules/@sentry/browser/esm/transports/base.js"); + + + + +/** + * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers. + * Whenever someone wraps the Fetch API and returns the wrong promise chain, + * this chain becomes orphaned and there is no possible way to capture it's rejections + * other than allowing it bubble up to this very handler. eg. + * + * const f = window.fetch; + * window.fetch = function () { + * const p = f.apply(this, arguments); + * + * p.then(function() { + * console.log('hi.'); + * }); + * + * return p; + * } + * + * `p.then(function () { ... })` is producing a completely separate promise chain, + * however, what's returned is `p` - the result of original `fetch` call. + * + * This mean, that whenever we use the Fetch API to send our own requests, _and_ + * some ad-blocker blocks it, this orphaned chain will _always_ reject, + * effectively causing another event to be captured. + * This makes a whole process become an infinite loop, which we need to somehow + * deal with, and break it in one way or another. + * + * To deal with this issue, we are making sure that we _always_ use the real + * browser Fetch API, instead of relying on what `window.fetch` exposes. + * The only downside to this would be missing our own requests as breadcrumbs, + * but because we are already not doing this, it should be just fine. + * + * Possible failed fetch error messages per-browser: + * + * Chrome: Failed to fetch + * Edge: Failed to Fetch + * Firefox: NetworkError when attempting to fetch resource + * Safari: resource blocked by content blocker + */ +function getNativeFetchImplementation() { + /* eslint-disable @typescript-eslint/unbound-method */ + var _a, _b; + // Fast path to avoid DOM I/O + var global = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)(); + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.isNativeFetch)(global.fetch)) { + return global.fetch.bind(global); + } + var document = global.document; + var fetchImpl = global.fetch; + // eslint-disable-next-line deprecation/deprecation + if (typeof ((_a = document) === null || _a === void 0 ? void 0 : _a.createElement) === "function") { + try { + var sandbox = document.createElement('iframe'); + sandbox.hidden = true; + document.head.appendChild(sandbox); + if ((_b = sandbox.contentWindow) === null || _b === void 0 ? void 0 : _b.fetch) { + fetchImpl = sandbox.contentWindow.fetch; + } + document.head.removeChild(sandbox); + } + catch (e) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e); + } + } + return fetchImpl.bind(global); + /* eslint-enable @typescript-eslint/unbound-method */ +} +/** `fetch` based transport */ +var FetchTransport = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__extends)(FetchTransport, _super); + function FetchTransport(options, fetchImpl) { + if (fetchImpl === void 0) { fetchImpl = getNativeFetchImplementation(); } + var _this = _super.call(this, options) || this; + _this._fetch = fetchImpl; + return _this; + } + /** + * @inheritDoc + */ + FetchTransport.prototype.sendEvent = function (event) { + return this._sendRequest((0,_sentry_core__WEBPACK_IMPORTED_MODULE_4__.eventToSentryRequest)(event, this._api), event); + }; + /** + * @inheritDoc + */ + FetchTransport.prototype.sendSession = function (session) { + return this._sendRequest((0,_sentry_core__WEBPACK_IMPORTED_MODULE_4__.sessionToSentryRequest)(session, this._api), session); + }; + /** + * @param sentryRequest Prepared SentryRequest to be delivered + * @param originalPayload Original payload used to create SentryRequest + */ + FetchTransport.prototype._sendRequest = function (sentryRequest, originalPayload) { + var _this = this; + if (this._isRateLimited(sentryRequest.type)) { + return Promise.reject({ + event: originalPayload, + type: sentryRequest.type, + reason: "Transport for " + sentryRequest.type + " requests locked till " + this._disabledUntil(sentryRequest.type) + " due to too many requests.", + status: 429, + }); + } + var options = { + body: sentryRequest.body, + method: 'POST', + // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default + // https://caniuse.com/#feat=referrer-policy + // It doesn't. And it throw exception instead of ignoring this parameter... + // REF: https://github.com/getsentry/raven-js/issues/1233 + referrerPolicy: ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.supportsReferrerPolicy)() ? 'origin' : ''), + }; + if (this.options.fetchParameters !== undefined) { + Object.assign(options, this.options.fetchParameters); + } + if (this.options.headers !== undefined) { + options.headers = this.options.headers; + } + return this._buffer.add(function () { + return new _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.SyncPromise(function (resolve, reject) { + void _this._fetch(sentryRequest.url, options) + .then(function (response) { + var headers = { + 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'), + 'retry-after': response.headers.get('Retry-After'), + }; + _this._handleResponse({ + requestType: sentryRequest.type, + response: response, + headers: headers, + resolve: resolve, + reject: reject, + }); + }) + .catch(reject); + }); + }); + }; + return FetchTransport; +}(_base__WEBPACK_IMPORTED_MODULE_6__.BaseTransport)); + +//# sourceMappingURL=fetch.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/browser/esm/transports/xhr.js": +/*!************************************************************!*\ + !*** ./node_modules/@sentry/browser/esm/transports/xhr.js ***! + \************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "XHRTransport": () => (/* binding */ XHRTransport) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/core */ "./node_modules/@sentry/core/esm/request.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/syncpromise.js"); +/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base */ "./node_modules/@sentry/browser/esm/transports/base.js"); + + + + +/** `XHR` based transport */ +var XHRTransport = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(XHRTransport, _super); + function XHRTransport() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @inheritDoc + */ + XHRTransport.prototype.sendEvent = function (event) { + return this._sendRequest((0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.eventToSentryRequest)(event, this._api), event); + }; + /** + * @inheritDoc + */ + XHRTransport.prototype.sendSession = function (session) { + return this._sendRequest((0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.sessionToSentryRequest)(session, this._api), session); + }; + /** + * @param sentryRequest Prepared SentryRequest to be delivered + * @param originalPayload Original payload used to create SentryRequest + */ + XHRTransport.prototype._sendRequest = function (sentryRequest, originalPayload) { + var _this = this; + if (this._isRateLimited(sentryRequest.type)) { + return Promise.reject({ + event: originalPayload, + type: sentryRequest.type, + reason: "Transport for " + sentryRequest.type + " requests locked till " + this._disabledUntil(sentryRequest.type) + " due to too many requests.", + status: 429, + }); + } + return this._buffer.add(function () { + return new _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.SyncPromise(function (resolve, reject) { + var request = new XMLHttpRequest(); + request.onreadystatechange = function () { + if (request.readyState === 4) { + var headers = { + 'x-sentry-rate-limits': request.getResponseHeader('X-Sentry-Rate-Limits'), + 'retry-after': request.getResponseHeader('Retry-After'), + }; + _this._handleResponse({ requestType: sentryRequest.type, response: request, headers: headers, resolve: resolve, reject: reject }); + } + }; + request.open('POST', sentryRequest.url); + for (var header in _this.options.headers) { + if (_this.options.headers.hasOwnProperty(header)) { + request.setRequestHeader(header, _this.options.headers[header]); + } + } + request.send(sentryRequest.body); + }); + }); + }; + return XHRTransport; +}(_base__WEBPACK_IMPORTED_MODULE_3__.BaseTransport)); + +//# sourceMappingURL=xhr.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/core/esm/api.js": +/*!**********************************************!*\ + !*** ./node_modules/@sentry/core/esm/api.js ***! + \**********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "API": () => (/* binding */ API) +/* harmony export */ }); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/dsn.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/object.js"); + +var SENTRY_API_VERSION = '7'; +/** + * Helper class to provide urls, headers and metadata that can be used to form + * different types of requests to Sentry endpoints. + * Supports both envelopes and regular event requests. + **/ +var API = /** @class */ (function () { + /** Create a new instance of API */ + function API(dsn, metadata, tunnel) { + if (metadata === void 0) { metadata = {}; } + this.dsn = dsn; + this._dsnObject = new _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.Dsn(dsn); + this.metadata = metadata; + this._tunnel = tunnel; + } + /** Returns the Dsn object. */ + API.prototype.getDsn = function () { + return this._dsnObject; + }; + /** Does this transport force envelopes? */ + API.prototype.forceEnvelope = function () { + return !!this._tunnel; + }; + /** Returns the prefix to construct Sentry ingestion API endpoints. */ + API.prototype.getBaseApiEndpoint = function () { + var dsn = this.getDsn(); + var protocol = dsn.protocol ? dsn.protocol + ":" : ''; + var port = dsn.port ? ":" + dsn.port : ''; + return protocol + "//" + dsn.host + port + (dsn.path ? "/" + dsn.path : '') + "/api/"; + }; + /** Returns the store endpoint URL. */ + API.prototype.getStoreEndpoint = function () { + return this._getIngestEndpoint('store'); + }; + /** + * Returns the store endpoint URL with auth in the query string. + * + * Sending auth as part of the query string and not as custom HTTP headers avoids CORS preflight requests. + */ + API.prototype.getStoreEndpointWithUrlEncodedAuth = function () { + return this.getStoreEndpoint() + "?" + this._encodedAuth(); + }; + /** + * Returns the envelope endpoint URL with auth in the query string. + * + * Sending auth as part of the query string and not as custom HTTP headers avoids CORS preflight requests. + */ + API.prototype.getEnvelopeEndpointWithUrlEncodedAuth = function () { + if (this.forceEnvelope()) { + return this._tunnel; + } + return this._getEnvelopeEndpoint() + "?" + this._encodedAuth(); + }; + /** Returns only the path component for the store endpoint. */ + API.prototype.getStoreEndpointPath = function () { + var dsn = this.getDsn(); + return (dsn.path ? "/" + dsn.path : '') + "/api/" + dsn.projectId + "/store/"; + }; + /** + * Returns an object that can be used in request headers. + * This is needed for node and the old /store endpoint in sentry + */ + API.prototype.getRequestHeaders = function (clientName, clientVersion) { + // CHANGE THIS to use metadata but keep clientName and clientVersion compatible + var dsn = this.getDsn(); + var header = ["Sentry sentry_version=" + SENTRY_API_VERSION]; + header.push("sentry_client=" + clientName + "/" + clientVersion); + header.push("sentry_key=" + dsn.publicKey); + if (dsn.pass) { + header.push("sentry_secret=" + dsn.pass); + } + return { + 'Content-Type': 'application/json', + 'X-Sentry-Auth': header.join(', '), + }; + }; + /** Returns the url to the report dialog endpoint. */ + API.prototype.getReportDialogEndpoint = function (dialogOptions) { + if (dialogOptions === void 0) { dialogOptions = {}; } + var dsn = this.getDsn(); + var endpoint = this.getBaseApiEndpoint() + "embed/error-page/"; + var encodedOptions = []; + encodedOptions.push("dsn=" + dsn.toString()); + for (var key in dialogOptions) { + if (key === 'dsn') { + continue; + } + if (key === 'user') { + if (!dialogOptions.user) { + continue; + } + if (dialogOptions.user.name) { + encodedOptions.push("name=" + encodeURIComponent(dialogOptions.user.name)); + } + if (dialogOptions.user.email) { + encodedOptions.push("email=" + encodeURIComponent(dialogOptions.user.email)); + } + } + else { + encodedOptions.push(encodeURIComponent(key) + "=" + encodeURIComponent(dialogOptions[key])); + } + } + if (encodedOptions.length) { + return endpoint + "?" + encodedOptions.join('&'); + } + return endpoint; + }; + /** Returns the envelope endpoint URL. */ + API.prototype._getEnvelopeEndpoint = function () { + return this._getIngestEndpoint('envelope'); + }; + /** Returns the ingest API endpoint for target. */ + API.prototype._getIngestEndpoint = function (target) { + if (this._tunnel) { + return this._tunnel; + } + var base = this.getBaseApiEndpoint(); + var dsn = this.getDsn(); + return "" + base + dsn.projectId + "/" + target + "/"; + }; + /** Returns a URL-encoded string with auth config suitable for a query string. */ + API.prototype._encodedAuth = function () { + var dsn = this.getDsn(); + var auth = { + // We send only the minimum set of required information. See + // https://github.com/getsentry/sentry-javascript/issues/2572. + sentry_key: dsn.publicKey, + sentry_version: SENTRY_API_VERSION, + }; + return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.urlEncode)(auth); + }; + return API; +}()); + +//# sourceMappingURL=api.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/core/esm/basebackend.js": +/*!******************************************************!*\ + !*** ./node_modules/@sentry/core/esm/basebackend.js ***! + \******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "BaseBackend": () => (/* binding */ BaseBackend) +/* harmony export */ }); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/error.js"); +/* harmony import */ var _transports_noop__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./transports/noop */ "./node_modules/@sentry/core/esm/transports/noop.js"); + + +/** + * This is the base implemention of a Backend. + * @hidden + */ +var BaseBackend = /** @class */ (function () { + /** Creates a new backend instance. */ + function BaseBackend(options) { + this._options = options; + if (!this._options.dsn) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.warn('No DSN provided, backend will not do anything.'); + } + this._transport = this._setupTransport(); + } + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + BaseBackend.prototype.eventFromException = function (_exception, _hint) { + throw new _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.SentryError('Backend has to implement `eventFromException` method'); + }; + /** + * @inheritDoc + */ + BaseBackend.prototype.eventFromMessage = function (_message, _level, _hint) { + throw new _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.SentryError('Backend has to implement `eventFromMessage` method'); + }; + /** + * @inheritDoc + */ + BaseBackend.prototype.sendEvent = function (event) { + void this._transport.sendEvent(event).then(null, function (reason) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.error("Error while sending event: " + reason); + }); + }; + /** + * @inheritDoc + */ + BaseBackend.prototype.sendSession = function (session) { + if (!this._transport.sendSession) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.warn("Dropping session because custom transport doesn't implement sendSession"); + return; + } + void this._transport.sendSession(session).then(null, function (reason) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.error("Error while sending session: " + reason); + }); + }; + /** + * @inheritDoc + */ + BaseBackend.prototype.getTransport = function () { + return this._transport; + }; + /** + * Sets up the transport so it can be used later to send requests. + */ + BaseBackend.prototype._setupTransport = function () { + return new _transports_noop__WEBPACK_IMPORTED_MODULE_2__.NoopTransport(); + }; + return BaseBackend; +}()); + +//# sourceMappingURL=basebackend.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/core/esm/baseclient.js": +/*!*****************************************************!*\ + !*** ./node_modules/@sentry/core/esm/baseclient.js ***! + \*****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "BaseClient": () => (/* binding */ BaseClient) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_hub__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @sentry/hub */ "./node_modules/@sentry/hub/esm/scope.js"); +/* harmony import */ var _sentry_types__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @sentry/types */ "./node_modules/@sentry/types/esm/session.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/dsn.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/is.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/syncpromise.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/time.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/object.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/string.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/error.js"); +/* harmony import */ var _integration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./integration */ "./node_modules/@sentry/core/esm/integration.js"); + +/* eslint-disable max-lines */ + + + + +/** + * Base implementation for all JavaScript SDK clients. + * + * Call the constructor with the corresponding backend constructor and options + * specific to the client subclass. To access these options later, use + * {@link Client.getOptions}. Also, the Backend instance is available via + * {@link Client.getBackend}. + * + * If a Dsn is specified in the options, it will be parsed and stored. Use + * {@link Client.getDsn} to retrieve the Dsn at any moment. In case the Dsn is + * invalid, the constructor will throw a {@link SentryException}. Note that + * without a valid Dsn, the SDK will not send any events to Sentry. + * + * Before sending an event via the backend, it is passed through + * {@link BaseClient._prepareEvent} to add SDK information and scope data + * (breadcrumbs and context). To add more custom information, override this + * method and extend the resulting prepared event. + * + * To issue automatically created events (e.g. via instrumentation), use + * {@link Client.captureEvent}. It will prepare the event and pass it through + * the callback lifecycle. To issue auto-breadcrumbs, use + * {@link Client.addBreadcrumb}. + * + * @example + * class NodeClient extends BaseClient { + * public constructor(options: NodeOptions) { + * super(NodeBackend, options); + * } + * + * // ... + * } + */ +var BaseClient = /** @class */ (function () { + /** + * Initializes this client instance. + * + * @param backendClass A constructor function to create the backend. + * @param options Options for the client. + */ + function BaseClient(backendClass, options) { + /** Array of used integrations. */ + this._integrations = {}; + /** Number of call being processed */ + this._processing = 0; + this._backend = new backendClass(options); + this._options = options; + if (options.dsn) { + this._dsn = new _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.Dsn(options.dsn); + } + } + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + BaseClient.prototype.captureException = function (exception, hint, scope) { + var _this = this; + var eventId = hint && hint.event_id; + this._process(this._getBackend() + .eventFromException(exception, hint) + .then(function (event) { return _this._captureEvent(event, hint, scope); }) + .then(function (result) { + eventId = result; + })); + return eventId; + }; + /** + * @inheritDoc + */ + BaseClient.prototype.captureMessage = function (message, level, hint, scope) { + var _this = this; + var eventId = hint && hint.event_id; + var promisedEvent = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.isPrimitive)(message) + ? this._getBackend().eventFromMessage(String(message), level, hint) + : this._getBackend().eventFromException(message, hint); + this._process(promisedEvent + .then(function (event) { return _this._captureEvent(event, hint, scope); }) + .then(function (result) { + eventId = result; + })); + return eventId; + }; + /** + * @inheritDoc + */ + BaseClient.prototype.captureEvent = function (event, hint, scope) { + var eventId = hint && hint.event_id; + this._process(this._captureEvent(event, hint, scope).then(function (result) { + eventId = result; + })); + return eventId; + }; + /** + * @inheritDoc + */ + BaseClient.prototype.captureSession = function (session) { + if (!this._isEnabled()) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.warn('SDK not enabled, will not capture session.'); + return; + } + if (!(typeof session.release === 'string')) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.warn('Discarded session because of missing or non-string release'); + } + else { + this._sendSession(session); + // After sending, we set init false to indicate it's not the first occurrence + session.update({ init: false }); + } + }; + /** + * @inheritDoc + */ + BaseClient.prototype.getDsn = function () { + return this._dsn; + }; + /** + * @inheritDoc + */ + BaseClient.prototype.getOptions = function () { + return this._options; + }; + /** + * @inheritDoc + */ + BaseClient.prototype.flush = function (timeout) { + var _this = this; + return this._isClientProcessing(timeout).then(function (ready) { + return _this._getBackend() + .getTransport() + .close(timeout) + .then(function (transportFlushed) { return ready && transportFlushed; }); + }); + }; + /** + * @inheritDoc + */ + BaseClient.prototype.close = function (timeout) { + var _this = this; + return this.flush(timeout).then(function (result) { + _this.getOptions().enabled = false; + return result; + }); + }; + /** + * Sets up the integrations + */ + BaseClient.prototype.setupIntegrations = function () { + if (this._isEnabled()) { + this._integrations = (0,_integration__WEBPACK_IMPORTED_MODULE_3__.setupIntegrations)(this._options); + } + }; + /** + * @inheritDoc + */ + BaseClient.prototype.getIntegration = function (integration) { + try { + return this._integrations[integration.id] || null; + } + catch (_oO) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.warn("Cannot retrieve integration " + integration.id + " from the current Client"); + return null; + } + }; + /** Updates existing session based on the provided event */ + BaseClient.prototype._updateSessionFromEvent = function (session, event) { + var e_1, _a; + var crashed = false; + var errored = false; + var exceptions = event.exception && event.exception.values; + if (exceptions) { + errored = true; + try { + for (var exceptions_1 = (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__values)(exceptions), exceptions_1_1 = exceptions_1.next(); !exceptions_1_1.done; exceptions_1_1 = exceptions_1.next()) { + var ex = exceptions_1_1.value; + var mechanism = ex.mechanism; + if (mechanism && mechanism.handled === false) { + crashed = true; + break; + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (exceptions_1_1 && !exceptions_1_1.done && (_a = exceptions_1.return)) _a.call(exceptions_1); + } + finally { if (e_1) throw e_1.error; } + } + } + // A session is updated and that session update is sent in only one of the two following scenarios: + // 1. Session with non terminal status and 0 errors + an error occurred -> Will set error count to 1 and send update + // 2. Session with non terminal status and 1 error + a crash occurred -> Will set status crashed and send update + var sessionNonTerminal = session.status === _sentry_types__WEBPACK_IMPORTED_MODULE_5__.SessionStatus.Ok; + var shouldUpdateAndSend = (sessionNonTerminal && session.errors === 0) || (sessionNonTerminal && crashed); + if (shouldUpdateAndSend) { + session.update((0,tslib__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_4__.__assign)({}, (crashed && { status: _sentry_types__WEBPACK_IMPORTED_MODULE_5__.SessionStatus.Crashed })), { errors: session.errors || Number(errored || crashed) })); + this.captureSession(session); + } + }; + /** Deliver captured session to Sentry */ + BaseClient.prototype._sendSession = function (session) { + this._getBackend().sendSession(session); + }; + /** Waits for the client to be done with processing. */ + BaseClient.prototype._isClientProcessing = function (timeout) { + var _this = this; + return new _sentry_utils__WEBPACK_IMPORTED_MODULE_6__.SyncPromise(function (resolve) { + var ticked = 0; + var tick = 1; + var interval = setInterval(function () { + if (_this._processing == 0) { + clearInterval(interval); + resolve(true); + } + else { + ticked += tick; + if (timeout && ticked >= timeout) { + clearInterval(interval); + resolve(false); + } + } + }, tick); + }); + }; + /** Returns the current backend. */ + BaseClient.prototype._getBackend = function () { + return this._backend; + }; + /** Determines whether this SDK is enabled and a valid Dsn is present. */ + BaseClient.prototype._isEnabled = function () { + return this.getOptions().enabled !== false && this._dsn !== undefined; + }; + /** + * Adds common information to events. + * + * The information includes release and environment from `options`, + * breadcrumbs and context (extra, tags and user) from the scope. + * + * Information that is already present in the event is never overwritten. For + * nested objects, such as the context, keys are merged. + * + * @param event The original event. + * @param hint May contain additional information about the original exception. + * @param scope A scope containing event metadata. + * @returns A new event with more information. + */ + BaseClient.prototype._prepareEvent = function (event, scope, hint) { + var _this = this; + var _a = this.getOptions().normalizeDepth, normalizeDepth = _a === void 0 ? 3 : _a; + var prepared = (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_4__.__assign)({}, event), { event_id: event.event_id || (hint && hint.event_id ? hint.event_id : (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.uuid4)()), timestamp: event.timestamp || (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_8__.dateTimestampInSeconds)() }); + this._applyClientOptions(prepared); + this._applyIntegrationsMetadata(prepared); + // If we have scope given to us, use it as the base for further modifications. + // This allows us to prevent unnecessary copying of data if `captureContext` is not provided. + var finalScope = scope; + if (hint && hint.captureContext) { + finalScope = _sentry_hub__WEBPACK_IMPORTED_MODULE_9__.Scope.clone(finalScope).update(hint.captureContext); + } + // We prepare the result here with a resolved Event. + var result = _sentry_utils__WEBPACK_IMPORTED_MODULE_6__.SyncPromise.resolve(prepared); + // This should be the last thing called, since we want that + // {@link Hub.addEventProcessor} gets the finished prepared event. + if (finalScope) { + // In case we have a hub we reassign it. + result = finalScope.applyToEvent(prepared, hint); + } + return result.then(function (evt) { + if (typeof normalizeDepth === 'number' && normalizeDepth > 0) { + return _this._normalizeEvent(evt, normalizeDepth); + } + return evt; + }); + }; + /** + * Applies `normalize` function on necessary `Event` attributes to make them safe for serialization. + * Normalized keys: + * - `breadcrumbs.data` + * - `user` + * - `contexts` + * - `extra` + * @param event Event + * @returns Normalized event + */ + BaseClient.prototype._normalizeEvent = function (event, depth) { + if (!event) { + return null; + } + var normalized = (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_4__.__assign)({}, event), (event.breadcrumbs && { + breadcrumbs: event.breadcrumbs.map(function (b) { return ((0,tslib__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_4__.__assign)({}, b), (b.data && { + data: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_10__.normalize)(b.data, depth), + }))); }), + })), (event.user && { + user: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_10__.normalize)(event.user, depth), + })), (event.contexts && { + contexts: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_10__.normalize)(event.contexts, depth), + })), (event.extra && { + extra: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_10__.normalize)(event.extra, depth), + })); + // event.contexts.trace stores information about a Transaction. Similarly, + // event.spans[] stores information about child Spans. Given that a + // Transaction is conceptually a Span, normalization should apply to both + // Transactions and Spans consistently. + // For now the decision is to skip normalization of Transactions and Spans, + // so this block overwrites the normalized event to add back the original + // Transaction information prior to normalization. + if (event.contexts && event.contexts.trace) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + normalized.contexts.trace = event.contexts.trace; + } + return normalized; + }; + /** + * Enhances event using the client configuration. + * It takes care of all "static" values like environment, release and `dist`, + * as well as truncating overly long values. + * @param event event instance to be enhanced + */ + BaseClient.prototype._applyClientOptions = function (event) { + var options = this.getOptions(); + var environment = options.environment, release = options.release, dist = options.dist, _a = options.maxValueLength, maxValueLength = _a === void 0 ? 250 : _a; + if (!('environment' in event)) { + event.environment = 'environment' in options ? environment : 'production'; + } + if (event.release === undefined && release !== undefined) { + event.release = release; + } + if (event.dist === undefined && dist !== undefined) { + event.dist = dist; + } + if (event.message) { + event.message = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_11__.truncate)(event.message, maxValueLength); + } + var exception = event.exception && event.exception.values && event.exception.values[0]; + if (exception && exception.value) { + exception.value = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_11__.truncate)(exception.value, maxValueLength); + } + var request = event.request; + if (request && request.url) { + request.url = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_11__.truncate)(request.url, maxValueLength); + } + }; + /** + * This function adds all used integrations to the SDK info in the event. + * @param event The event that will be filled with all integrations. + */ + BaseClient.prototype._applyIntegrationsMetadata = function (event) { + var integrationsArray = Object.keys(this._integrations); + if (integrationsArray.length > 0) { + event.sdk = event.sdk || {}; + event.sdk.integrations = (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__spread)((event.sdk.integrations || []), integrationsArray); + } + }; + /** + * Tells the backend to send this event + * @param event The Sentry event to send + */ + BaseClient.prototype._sendEvent = function (event) { + this._getBackend().sendEvent(event); + }; + /** + * Processes the event and logs an error in case of rejection + * @param event + * @param hint + * @param scope + */ + BaseClient.prototype._captureEvent = function (event, hint, scope) { + return this._processEvent(event, hint, scope).then(function (finalEvent) { + return finalEvent.event_id; + }, function (reason) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.error(reason); + return undefined; + }); + }; + /** + * Processes an event (either error or message) and sends it to Sentry. + * + * This also adds breadcrumbs and context information to the event. However, + * platform specific meta data (such as the User's IP address) must be added + * by the SDK implementor. + * + * + * @param event The event to send to Sentry. + * @param hint May contain additional information about the original exception. + * @param scope A scope containing event metadata. + * @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send. + */ + BaseClient.prototype._processEvent = function (event, hint, scope) { + var _this = this; + // eslint-disable-next-line @typescript-eslint/unbound-method + var _a = this.getOptions(), beforeSend = _a.beforeSend, sampleRate = _a.sampleRate; + if (!this._isEnabled()) { + return _sentry_utils__WEBPACK_IMPORTED_MODULE_6__.SyncPromise.reject(new _sentry_utils__WEBPACK_IMPORTED_MODULE_12__.SentryError('SDK not enabled, will not capture event.')); + } + var isTransaction = event.type === 'transaction'; + // 1.0 === 100% events are sent + // 0.0 === 0% events are sent + // Sampling for transaction happens somewhere else + if (!isTransaction && typeof sampleRate === 'number' && Math.random() > sampleRate) { + return _sentry_utils__WEBPACK_IMPORTED_MODULE_6__.SyncPromise.reject(new _sentry_utils__WEBPACK_IMPORTED_MODULE_12__.SentryError("Discarding event because it's not included in the random sample (sampling rate = " + sampleRate + ")")); + } + return this._prepareEvent(event, scope, hint) + .then(function (prepared) { + if (prepared === null) { + throw new _sentry_utils__WEBPACK_IMPORTED_MODULE_12__.SentryError('An event processor returned null, will not send event.'); + } + var isInternalException = hint && hint.data && hint.data.__sentry__ === true; + if (isInternalException || isTransaction || !beforeSend) { + return prepared; + } + var beforeSendResult = beforeSend(prepared, hint); + return _this._ensureBeforeSendRv(beforeSendResult); + }) + .then(function (processedEvent) { + if (processedEvent === null) { + throw new _sentry_utils__WEBPACK_IMPORTED_MODULE_12__.SentryError('`beforeSend` returned `null`, will not send event.'); + } + var session = scope && scope.getSession && scope.getSession(); + if (!isTransaction && session) { + _this._updateSessionFromEvent(session, processedEvent); + } + _this._sendEvent(processedEvent); + return processedEvent; + }) + .then(null, function (reason) { + if (reason instanceof _sentry_utils__WEBPACK_IMPORTED_MODULE_12__.SentryError) { + throw reason; + } + _this.captureException(reason, { + data: { + __sentry__: true, + }, + originalException: reason, + }); + throw new _sentry_utils__WEBPACK_IMPORTED_MODULE_12__.SentryError("Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: " + reason); + }); + }; + /** + * Occupies the client with processing and event + */ + BaseClient.prototype._process = function (promise) { + var _this = this; + this._processing += 1; + void promise.then(function (value) { + _this._processing -= 1; + return value; + }, function (reason) { + _this._processing -= 1; + return reason; + }); + }; + /** + * Verifies that return value of configured `beforeSend` is of expected type. + */ + BaseClient.prototype._ensureBeforeSendRv = function (rv) { + var nullErr = '`beforeSend` method has to return `null` or a valid event.'; + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.isThenable)(rv)) { + return rv.then(function (event) { + if (!((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.isPlainObject)(event) || event === null)) { + throw new _sentry_utils__WEBPACK_IMPORTED_MODULE_12__.SentryError(nullErr); + } + return event; + }, function (e) { + throw new _sentry_utils__WEBPACK_IMPORTED_MODULE_12__.SentryError("beforeSend rejected with " + e); + }); + } + else if (!((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.isPlainObject)(rv) || rv === null)) { + throw new _sentry_utils__WEBPACK_IMPORTED_MODULE_12__.SentryError(nullErr); + } + return rv; + }; + return BaseClient; +}()); + +//# sourceMappingURL=baseclient.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/core/esm/integration.js": +/*!******************************************************!*\ + !*** ./node_modules/@sentry/core/esm/integration.js ***! + \******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "installedIntegrations": () => (/* binding */ installedIntegrations), +/* harmony export */ "getIntegrationsToSetup": () => (/* binding */ getIntegrationsToSetup), +/* harmony export */ "setupIntegration": () => (/* binding */ setupIntegration), +/* harmony export */ "setupIntegrations": () => (/* binding */ setupIntegrations) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_hub__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/hub */ "./node_modules/@sentry/hub/esm/scope.js"); +/* harmony import */ var _sentry_hub__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/hub */ "./node_modules/@sentry/hub/esm/hub.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); + + + +var installedIntegrations = []; +/** + * @private + */ +function filterDuplicates(integrations) { + return integrations.reduce(function (acc, integrations) { + if (acc.every(function (accIntegration) { return integrations.name !== accIntegration.name; })) { + acc.push(integrations); + } + return acc; + }, []); +} +/** Gets integration to install */ +function getIntegrationsToSetup(options) { + var defaultIntegrations = (options.defaultIntegrations && (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)(options.defaultIntegrations)) || []; + var userIntegrations = options.integrations; + var integrations = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)(filterDuplicates(defaultIntegrations)); + if (Array.isArray(userIntegrations)) { + // Filter out integrations that are also included in user options + integrations = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)(integrations.filter(function (integrations) { + return userIntegrations.every(function (userIntegration) { return userIntegration.name !== integrations.name; }); + }), filterDuplicates(userIntegrations)); + } + else if (typeof userIntegrations === 'function') { + integrations = userIntegrations(integrations); + integrations = Array.isArray(integrations) ? integrations : [integrations]; + } + // Make sure that if present, `Debug` integration will always run last + var integrationsNames = integrations.map(function (i) { return i.name; }); + var alwaysLastToRun = 'Debug'; + if (integrationsNames.indexOf(alwaysLastToRun) !== -1) { + integrations.push.apply(integrations, (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)(integrations.splice(integrationsNames.indexOf(alwaysLastToRun), 1))); + } + return integrations; +} +/** Setup given integration */ +function setupIntegration(integration) { + if (installedIntegrations.indexOf(integration.name) !== -1) { + return; + } + integration.setupOnce(_sentry_hub__WEBPACK_IMPORTED_MODULE_1__.addGlobalEventProcessor, _sentry_hub__WEBPACK_IMPORTED_MODULE_2__.getCurrentHub); + installedIntegrations.push(integration.name); + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log("Integration installed: " + integration.name); +} +/** + * Given a list of integration instances this installs them all. When `withDefaults` is set to `true` then all default + * integrations are added unless they were already provided before. + * @param integrations array of integration instances + * @param withDefault should enable default integrations + */ +function setupIntegrations(options) { + var integrations = {}; + getIntegrationsToSetup(options).forEach(function (integration) { + integrations[integration.name] = integration; + setupIntegration(integration); + }); + return integrations; +} +//# sourceMappingURL=integration.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/core/esm/integrations/functiontostring.js": +/*!************************************************************************!*\ + !*** ./node_modules/@sentry/core/esm/integrations/functiontostring.js ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "FunctionToString": () => (/* binding */ FunctionToString) +/* harmony export */ }); +var originalFunctionToString; +/** Patch toString calls to return proper name for wrapped functions */ +var FunctionToString = /** @class */ (function () { + function FunctionToString() { + /** + * @inheritDoc + */ + this.name = FunctionToString.id; + } + /** + * @inheritDoc + */ + FunctionToString.prototype.setupOnce = function () { + // eslint-disable-next-line @typescript-eslint/unbound-method + originalFunctionToString = Function.prototype.toString; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Function.prototype.toString = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var context = this.__sentry_original__ || this; + return originalFunctionToString.apply(context, args); + }; + }; + /** + * @inheritDoc + */ + FunctionToString.id = 'FunctionToString'; + return FunctionToString; +}()); + +//# sourceMappingURL=functiontostring.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/core/esm/integrations/inboundfilters.js": +/*!**********************************************************************!*\ + !*** ./node_modules/@sentry/core/esm/integrations/inboundfilters.js ***! + \**********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "InboundFilters": () => (/* binding */ InboundFilters) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_hub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/hub */ "./node_modules/@sentry/hub/esm/scope.js"); +/* harmony import */ var _sentry_hub__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/hub */ "./node_modules/@sentry/hub/esm/hub.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/string.js"); + + + +// "Script error." is hard coded into browsers for errors that it can't read. +// this is the result of a script being pulled in from an external domain and CORS. +var DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script error\.? on line 0$/]; +/** Inbound filters configurable by the user */ +var InboundFilters = /** @class */ (function () { + function InboundFilters(_options) { + if (_options === void 0) { _options = {}; } + this._options = _options; + /** + * @inheritDoc + */ + this.name = InboundFilters.id; + } + /** + * @inheritDoc + */ + InboundFilters.prototype.setupOnce = function () { + (0,_sentry_hub__WEBPACK_IMPORTED_MODULE_0__.addGlobalEventProcessor)(function (event) { + var hub = (0,_sentry_hub__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)(); + if (!hub) { + return event; + } + var self = hub.getIntegration(InboundFilters); + if (self) { + var client = hub.getClient(); + var clientOptions = client ? client.getOptions() : {}; + // This checks prevents most of the occurrences of the bug linked below: + // https://github.com/getsentry/sentry-javascript/issues/2622 + // The bug is caused by multiple SDK instances, where one is minified and one is using non-mangled code. + // Unfortunatelly we cannot fix it reliably (thus reserved property in rollup's terser config), + // as we cannot force people using multiple instances in their apps to sync SDK versions. + var options = typeof self._mergeOptions === 'function' ? self._mergeOptions(clientOptions) : {}; + if (typeof self._shouldDropEvent !== 'function') { + return event; + } + return self._shouldDropEvent(event, options) ? null : event; + } + return event; + }); + }; + /** JSDoc */ + InboundFilters.prototype._shouldDropEvent = function (event, options) { + if (this._isSentryError(event, options)) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.warn("Event dropped due to being internal Sentry Error.\nEvent: " + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.getEventDescription)(event)); + return true; + } + if (this._isIgnoredError(event, options)) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.warn("Event dropped due to being matched by `ignoreErrors` option.\nEvent: " + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.getEventDescription)(event)); + return true; + } + if (this._isDeniedUrl(event, options)) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.warn("Event dropped due to being matched by `denyUrls` option.\nEvent: " + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.getEventDescription)(event) + ".\nUrl: " + this._getEventFilterUrl(event)); + return true; + } + if (!this._isAllowedUrl(event, options)) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.warn("Event dropped due to not being matched by `allowUrls` option.\nEvent: " + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.getEventDescription)(event) + ".\nUrl: " + this._getEventFilterUrl(event)); + return true; + } + return false; + }; + /** JSDoc */ + InboundFilters.prototype._isSentryError = function (event, options) { + if (!options.ignoreInternal) { + return false; + } + try { + return ((event && + event.exception && + event.exception.values && + event.exception.values[0] && + event.exception.values[0].type === 'SentryError') || + false); + } + catch (_oO) { + return false; + } + }; + /** JSDoc */ + InboundFilters.prototype._isIgnoredError = function (event, options) { + if (!options.ignoreErrors || !options.ignoreErrors.length) { + return false; + } + return this._getPossibleEventMessages(event).some(function (message) { + // Not sure why TypeScript complains here... + return options.ignoreErrors.some(function (pattern) { return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.isMatchingPattern)(message, pattern); }); + }); + }; + /** JSDoc */ + InboundFilters.prototype._isDeniedUrl = function (event, options) { + // TODO: Use Glob instead? + if (!options.denyUrls || !options.denyUrls.length) { + return false; + } + var url = this._getEventFilterUrl(event); + return !url ? false : options.denyUrls.some(function (pattern) { return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.isMatchingPattern)(url, pattern); }); + }; + /** JSDoc */ + InboundFilters.prototype._isAllowedUrl = function (event, options) { + // TODO: Use Glob instead? + if (!options.allowUrls || !options.allowUrls.length) { + return true; + } + var url = this._getEventFilterUrl(event); + return !url ? true : options.allowUrls.some(function (pattern) { return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.isMatchingPattern)(url, pattern); }); + }; + /** JSDoc */ + InboundFilters.prototype._mergeOptions = function (clientOptions) { + if (clientOptions === void 0) { clientOptions = {}; } + return { + allowUrls: (0,tslib__WEBPACK_IMPORTED_MODULE_5__.__spread)((this._options.whitelistUrls || []), (this._options.allowUrls || []), (clientOptions.whitelistUrls || []), (clientOptions.allowUrls || [])), + denyUrls: (0,tslib__WEBPACK_IMPORTED_MODULE_5__.__spread)((this._options.blacklistUrls || []), (this._options.denyUrls || []), (clientOptions.blacklistUrls || []), (clientOptions.denyUrls || [])), + ignoreErrors: (0,tslib__WEBPACK_IMPORTED_MODULE_5__.__spread)((this._options.ignoreErrors || []), (clientOptions.ignoreErrors || []), DEFAULT_IGNORE_ERRORS), + ignoreInternal: typeof this._options.ignoreInternal !== 'undefined' ? this._options.ignoreInternal : true, + }; + }; + /** JSDoc */ + InboundFilters.prototype._getPossibleEventMessages = function (event) { + if (event.message) { + return [event.message]; + } + if (event.exception) { + try { + var _a = (event.exception.values && event.exception.values[0]) || {}, _b = _a.type, type = _b === void 0 ? '' : _b, _c = _a.value, value = _c === void 0 ? '' : _c; + return ["" + value, type + ": " + value]; + } + catch (oO) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.error("Cannot extract message for event " + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.getEventDescription)(event)); + return []; + } + } + return []; + }; + /** JSDoc */ + InboundFilters.prototype._getEventFilterUrl = function (event) { + try { + if (event.stacktrace) { + var frames_1 = event.stacktrace.frames; + return (frames_1 && frames_1[frames_1.length - 1].filename) || null; + } + if (event.exception) { + var frames_2 = event.exception.values && event.exception.values[0].stacktrace && event.exception.values[0].stacktrace.frames; + return (frames_2 && frames_2[frames_2.length - 1].filename) || null; + } + return null; + } + catch (oO) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.error("Cannot extract url for event " + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.getEventDescription)(event)); + return null; + } + }; + /** + * @inheritDoc + */ + InboundFilters.id = 'InboundFilters'; + return InboundFilters; +}()); + +//# sourceMappingURL=inboundfilters.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/core/esm/request.js": +/*!**************************************************!*\ + !*** ./node_modules/@sentry/core/esm/request.js ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "sessionToSentryRequest": () => (/* binding */ sessionToSentryRequest), +/* harmony export */ "eventToSentryRequest": () => (/* binding */ eventToSentryRequest) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); + +/** Extract sdk info from from the API metadata */ +function getSdkMetadataForEnvelopeHeader(api) { + if (!api.metadata || !api.metadata.sdk) { + return; + } + var _a = api.metadata.sdk, name = _a.name, version = _a.version; + return { name: name, version: version }; +} +/** + * Apply SdkInfo (name, version, packages, integrations) to the corresponding event key. + * Merge with existing data if any. + **/ +function enhanceEventWithSdkInfo(event, sdkInfo) { + if (!sdkInfo) { + return event; + } + event.sdk = event.sdk || {}; + event.sdk.name = event.sdk.name || sdkInfo.name; + event.sdk.version = event.sdk.version || sdkInfo.version; + event.sdk.integrations = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)((event.sdk.integrations || []), (sdkInfo.integrations || [])); + event.sdk.packages = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)((event.sdk.packages || []), (sdkInfo.packages || [])); + return event; +} +/** Creates a SentryRequest from a Session. */ +function sessionToSentryRequest(session, api) { + var sdkInfo = getSdkMetadataForEnvelopeHeader(api); + var envelopeHeaders = JSON.stringify((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({ sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (api.forceEnvelope() && { dsn: api.getDsn().toString() }))); + // I know this is hacky but we don't want to add `session` to request type since it's never rate limited + var type = 'aggregates' in session ? 'sessions' : 'session'; + var itemHeaders = JSON.stringify({ + type: type, + }); + return { + body: envelopeHeaders + "\n" + itemHeaders + "\n" + JSON.stringify(session), + type: type, + url: api.getEnvelopeEndpointWithUrlEncodedAuth(), + }; +} +/** Creates a SentryRequest from an event. */ +function eventToSentryRequest(event, api) { + var sdkInfo = getSdkMetadataForEnvelopeHeader(api); + var eventType = event.type || 'event'; + var useEnvelope = eventType === 'transaction' || api.forceEnvelope(); + var _a = event.debug_meta || {}, transactionSampling = _a.transactionSampling, metadata = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__rest)(_a, ["transactionSampling"]); + var _b = transactionSampling || {}, samplingMethod = _b.method, sampleRate = _b.rate; + if (Object.keys(metadata).length === 0) { + delete event.debug_meta; + } + else { + event.debug_meta = metadata; + } + var req = { + body: JSON.stringify(sdkInfo ? enhanceEventWithSdkInfo(event, api.metadata.sdk) : event), + type: eventType, + url: useEnvelope ? api.getEnvelopeEndpointWithUrlEncodedAuth() : api.getStoreEndpointWithUrlEncodedAuth(), + }; + // https://develop.sentry.dev/sdk/envelopes/ + // Since we don't need to manipulate envelopes nor store them, there is no + // exported concept of an Envelope with operations including serialization and + // deserialization. Instead, we only implement a minimal subset of the spec to + // serialize events inline here. + if (useEnvelope) { + var envelopeHeaders = JSON.stringify((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({ event_id: event.event_id, sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (api.forceEnvelope() && { dsn: api.getDsn().toString() }))); + var itemHeaders = JSON.stringify({ + type: eventType, + // TODO: Right now, sampleRate may or may not be defined (it won't be in the cases of inheritance and + // explicitly-set sampling decisions). Are we good with that? + sample_rates: [{ id: samplingMethod, rate: sampleRate }], + }); + // The trailing newline is optional. We intentionally don't send it to avoid + // sending unnecessary bytes. + // + // const envelope = `${envelopeHeaders}\n${itemHeaders}\n${req.body}\n`; + var envelope = envelopeHeaders + "\n" + itemHeaders + "\n" + req.body; + req.body = envelope; + } + return req; +} +//# sourceMappingURL=request.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/core/esm/sdk.js": +/*!**********************************************!*\ + !*** ./node_modules/@sentry/core/esm/sdk.js ***! + \**********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "initAndBind": () => (/* binding */ initAndBind) +/* harmony export */ }); +/* harmony import */ var _sentry_hub__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/hub */ "./node_modules/@sentry/hub/esm/hub.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); + + +/** + * Internal function to create a new SDK client instance. The client is + * installed and then bound to the current scope. + * + * @param clientClass The client class to instantiate. + * @param options Options to pass to the client. + */ +function initAndBind(clientClass, options) { + var _a; + if (options.debug === true) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.enable(); + } + var hub = (0,_sentry_hub__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)(); + (_a = hub.getScope()) === null || _a === void 0 ? void 0 : _a.update(options.initialScope); + var client = new clientClass(options); + hub.bindClient(client); +} +//# sourceMappingURL=sdk.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/core/esm/transports/noop.js": +/*!**********************************************************!*\ + !*** ./node_modules/@sentry/core/esm/transports/noop.js ***! + \**********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "NoopTransport": () => (/* binding */ NoopTransport) +/* harmony export */ }); +/* harmony import */ var _sentry_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/types */ "./node_modules/@sentry/types/esm/status.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/syncpromise.js"); + + +/** Noop transport */ +var NoopTransport = /** @class */ (function () { + function NoopTransport() { + } + /** + * @inheritDoc + */ + NoopTransport.prototype.sendEvent = function (_) { + return _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.SyncPromise.resolve({ + reason: "NoopTransport: Event has been skipped because no Dsn is configured.", + status: _sentry_types__WEBPACK_IMPORTED_MODULE_1__.Status.Skipped, + }); + }; + /** + * @inheritDoc + */ + NoopTransport.prototype.close = function (_) { + return _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.SyncPromise.resolve(true); + }; + return NoopTransport; +}()); + +//# sourceMappingURL=noop.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/core/esm/version.js": +/*!**************************************************!*\ + !*** ./node_modules/@sentry/core/esm/version.js ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SDK_VERSION": () => (/* binding */ SDK_VERSION) +/* harmony export */ }); +var SDK_VERSION = '6.8.0'; +//# sourceMappingURL=version.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/hub/esm/hub.js": +/*!*********************************************!*\ + !*** ./node_modules/@sentry/hub/esm/hub.js ***! + \*********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "API_VERSION": () => (/* binding */ API_VERSION), +/* harmony export */ "Hub": () => (/* binding */ Hub), +/* harmony export */ "getMainCarrier": () => (/* binding */ getMainCarrier), +/* harmony export */ "makeMain": () => (/* binding */ makeMain), +/* harmony export */ "getCurrentHub": () => (/* binding */ getCurrentHub), +/* harmony export */ "getActiveDomain": () => (/* binding */ getActiveDomain), +/* harmony export */ "getHubFromCarrier": () => (/* binding */ getHubFromCarrier), +/* harmony export */ "setHubOnCarrier": () => (/* binding */ setHubOnCarrier) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_types__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @sentry/types */ "./node_modules/@sentry/types/esm/session.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/time.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/node.js"); +/* harmony import */ var _scope__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./scope */ "./node_modules/@sentry/hub/esm/scope.js"); +/* harmony import */ var _session__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./session */ "./node_modules/@sentry/hub/esm/session.js"); + +/* eslint-disable max-lines */ + + + + +/** + * API compatibility version of this hub. + * + * WARNING: This number should only be increased when the global interface + * changes and new methods are introduced. + * + * @hidden + */ +var API_VERSION = 4; +/** + * Default maximum number of breadcrumbs added to an event. Can be overwritten + * with {@link Options.maxBreadcrumbs}. + */ +var DEFAULT_BREADCRUMBS = 100; +/** + * @inheritDoc + */ +var Hub = /** @class */ (function () { + /** + * Creates a new instance of the hub, will push one {@link Layer} into the + * internal stack on creation. + * + * @param client bound to the hub. + * @param scope bound to the hub. + * @param version number, higher number means higher priority. + */ + function Hub(client, scope, _version) { + if (scope === void 0) { scope = new _scope__WEBPACK_IMPORTED_MODULE_0__.Scope(); } + if (_version === void 0) { _version = API_VERSION; } + this._version = _version; + /** Is a {@link Layer}[] containing the client and scope */ + this._stack = [{}]; + this.getStackTop().scope = scope; + this.bindClient(client); + } + /** + * @inheritDoc + */ + Hub.prototype.isOlderThan = function (version) { + return this._version < version; + }; + /** + * @inheritDoc + */ + Hub.prototype.bindClient = function (client) { + var top = this.getStackTop(); + top.client = client; + if (client && client.setupIntegrations) { + client.setupIntegrations(); + } + }; + /** + * @inheritDoc + */ + Hub.prototype.pushScope = function () { + // We want to clone the content of prev scope + var scope = _scope__WEBPACK_IMPORTED_MODULE_0__.Scope.clone(this.getScope()); + this.getStack().push({ + client: this.getClient(), + scope: scope, + }); + return scope; + }; + /** + * @inheritDoc + */ + Hub.prototype.popScope = function () { + if (this.getStack().length <= 1) + return false; + return !!this.getStack().pop(); + }; + /** + * @inheritDoc + */ + Hub.prototype.withScope = function (callback) { + var scope = this.pushScope(); + try { + callback(scope); + } + finally { + this.popScope(); + } + }; + /** + * @inheritDoc + */ + Hub.prototype.getClient = function () { + return this.getStackTop().client; + }; + /** Returns the scope of the top stack. */ + Hub.prototype.getScope = function () { + return this.getStackTop().scope; + }; + /** Returns the scope stack for domains or the process. */ + Hub.prototype.getStack = function () { + return this._stack; + }; + /** Returns the topmost scope layer in the order domain > local > process. */ + Hub.prototype.getStackTop = function () { + return this._stack[this._stack.length - 1]; + }; + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + Hub.prototype.captureException = function (exception, hint) { + var eventId = (this._lastEventId = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.uuid4)()); + var finalHint = hint; + // If there's no explicit hint provided, mimick the same thing that would happen + // in the minimal itself to create a consistent behavior. + // We don't do this in the client, as it's the lowest level API, and doing this, + // would prevent user from having full control over direct calls. + if (!hint) { + var syntheticException = void 0; + try { + throw new Error('Sentry syntheticException'); + } + catch (exception) { + syntheticException = exception; + } + finalHint = { + originalException: exception, + syntheticException: syntheticException, + }; + } + this._invokeClient('captureException', exception, (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, finalHint), { event_id: eventId })); + return eventId; + }; + /** + * @inheritDoc + */ + Hub.prototype.captureMessage = function (message, level, hint) { + var eventId = (this._lastEventId = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.uuid4)()); + var finalHint = hint; + // If there's no explicit hint provided, mimick the same thing that would happen + // in the minimal itself to create a consistent behavior. + // We don't do this in the client, as it's the lowest level API, and doing this, + // would prevent user from having full control over direct calls. + if (!hint) { + var syntheticException = void 0; + try { + throw new Error(message); + } + catch (exception) { + syntheticException = exception; + } + finalHint = { + originalException: message, + syntheticException: syntheticException, + }; + } + this._invokeClient('captureMessage', message, level, (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, finalHint), { event_id: eventId })); + return eventId; + }; + /** + * @inheritDoc + */ + Hub.prototype.captureEvent = function (event, hint) { + var eventId = (this._lastEventId = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.uuid4)()); + this._invokeClient('captureEvent', event, (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, hint), { event_id: eventId })); + return eventId; + }; + /** + * @inheritDoc + */ + Hub.prototype.lastEventId = function () { + return this._lastEventId; + }; + /** + * @inheritDoc + */ + Hub.prototype.addBreadcrumb = function (breadcrumb, hint) { + var _a = this.getStackTop(), scope = _a.scope, client = _a.client; + if (!scope || !client) + return; + // eslint-disable-next-line @typescript-eslint/unbound-method + var _b = (client.getOptions && client.getOptions()) || {}, _c = _b.beforeBreadcrumb, beforeBreadcrumb = _c === void 0 ? null : _c, _d = _b.maxBreadcrumbs, maxBreadcrumbs = _d === void 0 ? DEFAULT_BREADCRUMBS : _d; + if (maxBreadcrumbs <= 0) + return; + var timestamp = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.dateTimestampInSeconds)(); + var mergedBreadcrumb = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({ timestamp: timestamp }, breadcrumb); + var finalBreadcrumb = beforeBreadcrumb + ? (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.consoleSandbox)(function () { return beforeBreadcrumb(mergedBreadcrumb, hint); }) + : mergedBreadcrumb; + if (finalBreadcrumb === null) + return; + scope.addBreadcrumb(finalBreadcrumb, maxBreadcrumbs); + }; + /** + * @inheritDoc + */ + Hub.prototype.setUser = function (user) { + var scope = this.getScope(); + if (scope) + scope.setUser(user); + }; + /** + * @inheritDoc + */ + Hub.prototype.setTags = function (tags) { + var scope = this.getScope(); + if (scope) + scope.setTags(tags); + }; + /** + * @inheritDoc + */ + Hub.prototype.setExtras = function (extras) { + var scope = this.getScope(); + if (scope) + scope.setExtras(extras); + }; + /** + * @inheritDoc + */ + Hub.prototype.setTag = function (key, value) { + var scope = this.getScope(); + if (scope) + scope.setTag(key, value); + }; + /** + * @inheritDoc + */ + Hub.prototype.setExtra = function (key, extra) { + var scope = this.getScope(); + if (scope) + scope.setExtra(key, extra); + }; + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Hub.prototype.setContext = function (name, context) { + var scope = this.getScope(); + if (scope) + scope.setContext(name, context); + }; + /** + * @inheritDoc + */ + Hub.prototype.configureScope = function (callback) { + var _a = this.getStackTop(), scope = _a.scope, client = _a.client; + if (scope && client) { + callback(scope); + } + }; + /** + * @inheritDoc + */ + Hub.prototype.run = function (callback) { + var oldHub = makeMain(this); + try { + callback(this); + } + finally { + makeMain(oldHub); + } + }; + /** + * @inheritDoc + */ + Hub.prototype.getIntegration = function (integration) { + var client = this.getClient(); + if (!client) + return null; + try { + return client.getIntegration(integration); + } + catch (_oO) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_4__.logger.warn("Cannot retrieve integration " + integration.id + " from the current Hub"); + return null; + } + }; + /** + * @inheritDoc + */ + Hub.prototype.startSpan = function (context) { + return this._callExtensionMethod('startSpan', context); + }; + /** + * @inheritDoc + */ + Hub.prototype.startTransaction = function (context, customSamplingContext) { + return this._callExtensionMethod('startTransaction', context, customSamplingContext); + }; + /** + * @inheritDoc + */ + Hub.prototype.traceHeaders = function () { + return this._callExtensionMethod('traceHeaders'); + }; + /** + * @inheritDoc + */ + Hub.prototype.captureSession = function (endSession) { + if (endSession === void 0) { endSession = false; } + // both send the update and pull the session from the scope + if (endSession) { + return this.endSession(); + } + // only send the update + this._sendSessionUpdate(); + }; + /** + * @inheritDoc + */ + Hub.prototype.endSession = function () { + var _a, _b, _c, _d, _e; + (_c = (_b = (_a = this.getStackTop()) === null || _a === void 0 ? void 0 : _a.scope) === null || _b === void 0 ? void 0 : _b.getSession()) === null || _c === void 0 ? void 0 : _c.close(); + this._sendSessionUpdate(); + // the session is over; take it off of the scope + (_e = (_d = this.getStackTop()) === null || _d === void 0 ? void 0 : _d.scope) === null || _e === void 0 ? void 0 : _e.setSession(); + }; + /** + * @inheritDoc + */ + Hub.prototype.startSession = function (context) { + var _a = this.getStackTop(), scope = _a.scope, client = _a.client; + var _b = (client && client.getOptions()) || {}, release = _b.release, environment = _b.environment; + // Will fetch userAgent if called from browser sdk + var global = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.getGlobalObject)(); + var userAgent = (global.navigator || {}).userAgent; + var session = new _session__WEBPACK_IMPORTED_MODULE_5__.Session((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({ release: release, + environment: environment }, (scope && { user: scope.getUser() })), (userAgent && { userAgent: userAgent })), context)); + if (scope) { + // End existing session if there's one + var currentSession = scope.getSession && scope.getSession(); + if (currentSession && currentSession.status === _sentry_types__WEBPACK_IMPORTED_MODULE_6__.SessionStatus.Ok) { + currentSession.update({ status: _sentry_types__WEBPACK_IMPORTED_MODULE_6__.SessionStatus.Exited }); + } + this.endSession(); + // Afterwards we set the new session on the scope + scope.setSession(session); + } + return session; + }; + /** + * Sends the current Session on the scope + */ + Hub.prototype._sendSessionUpdate = function () { + var _a = this.getStackTop(), scope = _a.scope, client = _a.client; + if (!scope) + return; + var session = scope.getSession && scope.getSession(); + if (session) { + if (client && client.captureSession) { + client.captureSession(session); + } + } + }; + /** + * Internal helper function to call a method on the top client if it exists. + * + * @param method The method to call on the client. + * @param args Arguments to pass to the client function. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Hub.prototype._invokeClient = function (method) { + var _a; + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + var _b = this.getStackTop(), scope = _b.scope, client = _b.client; + if (client && client[method]) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any + (_a = client)[method].apply(_a, (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__spread)(args, [scope])); + } + }; + /** + * Calls global extension method and binding current instance to the function call + */ + // @ts-ignore Function lacks ending return statement and return type does not include 'undefined'. ts(2366) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Hub.prototype._callExtensionMethod = function (method) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + var carrier = getMainCarrier(); + var sentry = carrier.__SENTRY__; + if (sentry && sentry.extensions && typeof sentry.extensions[method] === 'function') { + return sentry.extensions[method].apply(this, args); + } + _sentry_utils__WEBPACK_IMPORTED_MODULE_4__.logger.warn("Extension method " + method + " couldn't be found, doing nothing."); + }; + return Hub; +}()); + +/** + * Returns the global shim registry. + * + * FIXME: This function is problematic, because despite always returning a valid Carrier, + * it has an optional `__SENTRY__` property, which then in turn requires us to always perform an unnecessary check + * at the call-site. We always access the carrier through this function, so we can guarantee that `__SENTRY__` is there. + **/ +function getMainCarrier() { + var carrier = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.getGlobalObject)(); + carrier.__SENTRY__ = carrier.__SENTRY__ || { + extensions: {}, + hub: undefined, + }; + return carrier; +} +/** + * Replaces the current main hub with the passed one on the global object + * + * @returns The old replaced hub + */ +function makeMain(hub) { + var registry = getMainCarrier(); + var oldHub = getHubFromCarrier(registry); + setHubOnCarrier(registry, hub); + return oldHub; +} +/** + * Returns the default hub instance. + * + * If a hub is already registered in the global carrier but this module + * contains a more recent version, it replaces the registered version. + * Otherwise, the currently registered hub will be returned. + */ +function getCurrentHub() { + // Get main carrier (global for every environment) + var registry = getMainCarrier(); + // If there's no hub, or its an old API, assign a new one + if (!hasHubOnCarrier(registry) || getHubFromCarrier(registry).isOlderThan(API_VERSION)) { + setHubOnCarrier(registry, new Hub()); + } + // Prefer domains over global if they are there (applicable only to Node environment) + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.isNodeEnv)()) { + return getHubFromActiveDomain(registry); + } + // Return hub that lives on a global object + return getHubFromCarrier(registry); +} +/** + * Returns the active domain, if one exists + * @deprecated No longer used; remove in v7 + * @returns The domain, or undefined if there is no active domain + */ +// eslint-disable-next-line deprecation/deprecation +function getActiveDomain() { + _sentry_utils__WEBPACK_IMPORTED_MODULE_4__.logger.warn('Function `getActiveDomain` is deprecated and will be removed in a future version.'); + var sentry = getMainCarrier().__SENTRY__; + return sentry && sentry.extensions && sentry.extensions.domain && sentry.extensions.domain.active; +} +/** + * Try to read the hub from an active domain, and fallback to the registry if one doesn't exist + * @returns discovered hub + */ +function getHubFromActiveDomain(registry) { + var _a, _b, _c; + try { + var activeDomain = (_c = (_b = (_a = getMainCarrier().__SENTRY__) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.domain) === null || _c === void 0 ? void 0 : _c.active; + // If there's no active domain, just return global hub + if (!activeDomain) { + return getHubFromCarrier(registry); + } + // If there's no hub on current domain, or it's an old API, assign a new one + if (!hasHubOnCarrier(activeDomain) || getHubFromCarrier(activeDomain).isOlderThan(API_VERSION)) { + var registryHubTopStack = getHubFromCarrier(registry).getStackTop(); + setHubOnCarrier(activeDomain, new Hub(registryHubTopStack.client, _scope__WEBPACK_IMPORTED_MODULE_0__.Scope.clone(registryHubTopStack.scope))); + } + // Return hub that lives on a domain + return getHubFromCarrier(activeDomain); + } + catch (_Oo) { + // Return hub that lives on a global object + return getHubFromCarrier(registry); + } +} +/** + * This will tell whether a carrier has a hub on it or not + * @param carrier object + */ +function hasHubOnCarrier(carrier) { + return !!(carrier && carrier.__SENTRY__ && carrier.__SENTRY__.hub); +} +/** + * This will create a new {@link Hub} and add to the passed object on + * __SENTRY__.hub. + * @param carrier object + * @hidden + */ +function getHubFromCarrier(carrier) { + if (carrier && carrier.__SENTRY__ && carrier.__SENTRY__.hub) + return carrier.__SENTRY__.hub; + carrier.__SENTRY__ = carrier.__SENTRY__ || {}; + carrier.__SENTRY__.hub = new Hub(); + return carrier.__SENTRY__.hub; +} +/** + * This will set passed {@link Hub} on the passed object's __SENTRY__.hub attribute + * @param carrier object + * @param hub Hub + * @returns A boolean indicating success or failure + */ +function setHubOnCarrier(carrier, hub) { + if (!carrier) + return false; + carrier.__SENTRY__ = carrier.__SENTRY__ || {}; + carrier.__SENTRY__.hub = hub; + return true; +} +//# sourceMappingURL=hub.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/hub/esm/scope.js": +/*!***********************************************!*\ + !*** ./node_modules/@sentry/hub/esm/scope.js ***! + \***********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Scope": () => (/* binding */ Scope), +/* harmony export */ "addGlobalEventProcessor": () => (/* binding */ addGlobalEventProcessor) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/is.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/time.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/syncpromise.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); + + +/** + * Absolute maximum number of breadcrumbs added to an event. + * The `maxBreadcrumbs` option cannot be higher than this value. + */ +var MAX_BREADCRUMBS = 100; +/** + * Holds additional event information. {@link Scope.applyToEvent} will be + * called by the client before an event will be sent. + */ +var Scope = /** @class */ (function () { + function Scope() { + /** Flag if notifiying is happening. */ + this._notifyingListeners = false; + /** Callback for client to receive scope changes. */ + this._scopeListeners = []; + /** Callback list that will be called after {@link applyToEvent}. */ + this._eventProcessors = []; + /** Array of breadcrumbs. */ + this._breadcrumbs = []; + /** User */ + this._user = {}; + /** Tags */ + this._tags = {}; + /** Extra */ + this._extra = {}; + /** Contexts */ + this._contexts = {}; + } + /** + * Inherit values from the parent scope. + * @param scope to clone. + */ + Scope.clone = function (scope) { + var newScope = new Scope(); + if (scope) { + newScope._breadcrumbs = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)(scope._breadcrumbs); + newScope._tags = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, scope._tags); + newScope._extra = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, scope._extra); + newScope._contexts = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, scope._contexts); + newScope._user = scope._user; + newScope._level = scope._level; + newScope._span = scope._span; + newScope._session = scope._session; + newScope._transactionName = scope._transactionName; + newScope._fingerprint = scope._fingerprint; + newScope._eventProcessors = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)(scope._eventProcessors); + newScope._requestSession = scope._requestSession; + } + return newScope; + }; + /** + * Add internal on change listener. Used for sub SDKs that need to store the scope. + * @hidden + */ + Scope.prototype.addScopeListener = function (callback) { + this._scopeListeners.push(callback); + }; + /** + * @inheritDoc + */ + Scope.prototype.addEventProcessor = function (callback) { + this._eventProcessors.push(callback); + return this; + }; + /** + * @inheritDoc + */ + Scope.prototype.setUser = function (user) { + this._user = user || {}; + if (this._session) { + this._session.update({ user: user }); + } + this._notifyScopeListeners(); + return this; + }; + /** + * @inheritDoc + */ + Scope.prototype.getUser = function () { + return this._user; + }; + /** + * @inheritDoc + */ + Scope.prototype.getRequestSession = function () { + return this._requestSession; + }; + /** + * @inheritDoc + */ + Scope.prototype.setRequestSession = function (requestSession) { + this._requestSession = requestSession; + return this; + }; + /** + * @inheritDoc + */ + Scope.prototype.setTags = function (tags) { + this._tags = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._tags), tags); + this._notifyScopeListeners(); + return this; + }; + /** + * @inheritDoc + */ + Scope.prototype.setTag = function (key, value) { + var _a; + this._tags = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._tags), (_a = {}, _a[key] = value, _a)); + this._notifyScopeListeners(); + return this; + }; + /** + * @inheritDoc + */ + Scope.prototype.setExtras = function (extras) { + this._extra = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._extra), extras); + this._notifyScopeListeners(); + return this; + }; + /** + * @inheritDoc + */ + Scope.prototype.setExtra = function (key, extra) { + var _a; + this._extra = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._extra), (_a = {}, _a[key] = extra, _a)); + this._notifyScopeListeners(); + return this; + }; + /** + * @inheritDoc + */ + Scope.prototype.setFingerprint = function (fingerprint) { + this._fingerprint = fingerprint; + this._notifyScopeListeners(); + return this; + }; + /** + * @inheritDoc + */ + Scope.prototype.setLevel = function (level) { + this._level = level; + this._notifyScopeListeners(); + return this; + }; + /** + * @inheritDoc + */ + Scope.prototype.setTransactionName = function (name) { + this._transactionName = name; + this._notifyScopeListeners(); + return this; + }; + /** + * Can be removed in major version. + * @deprecated in favor of {@link this.setTransactionName} + */ + Scope.prototype.setTransaction = function (name) { + return this.setTransactionName(name); + }; + /** + * @inheritDoc + */ + Scope.prototype.setContext = function (key, context) { + var _a; + if (context === null) { + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete this._contexts[key]; + } + else { + this._contexts = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._contexts), (_a = {}, _a[key] = context, _a)); + } + this._notifyScopeListeners(); + return this; + }; + /** + * @inheritDoc + */ + Scope.prototype.setSpan = function (span) { + this._span = span; + this._notifyScopeListeners(); + return this; + }; + /** + * @inheritDoc + */ + Scope.prototype.getSpan = function () { + return this._span; + }; + /** + * @inheritDoc + */ + Scope.prototype.getTransaction = function () { + var _a, _b, _c, _d; + // often, this span will be a transaction, but it's not guaranteed to be + var span = this.getSpan(); + // try it the new way first + if ((_a = span) === null || _a === void 0 ? void 0 : _a.transaction) { + return (_b = span) === null || _b === void 0 ? void 0 : _b.transaction; + } + // fallback to the old way (known bug: this only finds transactions with sampled = true) + if ((_d = (_c = span) === null || _c === void 0 ? void 0 : _c.spanRecorder) === null || _d === void 0 ? void 0 : _d.spans[0]) { + return span.spanRecorder.spans[0]; + } + // neither way found a transaction + return undefined; + }; + /** + * @inheritDoc + */ + Scope.prototype.setSession = function (session) { + if (!session) { + delete this._session; + } + else { + this._session = session; + } + this._notifyScopeListeners(); + return this; + }; + /** + * @inheritDoc + */ + Scope.prototype.getSession = function () { + return this._session; + }; + /** + * @inheritDoc + */ + Scope.prototype.update = function (captureContext) { + if (!captureContext) { + return this; + } + if (typeof captureContext === 'function') { + var updatedScope = captureContext(this); + return updatedScope instanceof Scope ? updatedScope : this; + } + if (captureContext instanceof Scope) { + this._tags = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._tags), captureContext._tags); + this._extra = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._extra), captureContext._extra); + this._contexts = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._contexts), captureContext._contexts); + if (captureContext._user && Object.keys(captureContext._user).length) { + this._user = captureContext._user; + } + if (captureContext._level) { + this._level = captureContext._level; + } + if (captureContext._fingerprint) { + this._fingerprint = captureContext._fingerprint; + } + if (captureContext._requestSession) { + this._requestSession = captureContext._requestSession; + } + } + else if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.isPlainObject)(captureContext)) { + // eslint-disable-next-line no-param-reassign + captureContext = captureContext; + this._tags = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._tags), captureContext.tags); + this._extra = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._extra), captureContext.extra); + this._contexts = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._contexts), captureContext.contexts); + if (captureContext.user) { + this._user = captureContext.user; + } + if (captureContext.level) { + this._level = captureContext.level; + } + if (captureContext.fingerprint) { + this._fingerprint = captureContext.fingerprint; + } + if (captureContext.requestSession) { + this._requestSession = captureContext.requestSession; + } + } + return this; + }; + /** + * @inheritDoc + */ + Scope.prototype.clear = function () { + this._breadcrumbs = []; + this._tags = {}; + this._extra = {}; + this._user = {}; + this._contexts = {}; + this._level = undefined; + this._transactionName = undefined; + this._fingerprint = undefined; + this._requestSession = undefined; + this._span = undefined; + this._session = undefined; + this._notifyScopeListeners(); + return this; + }; + /** + * @inheritDoc + */ + Scope.prototype.addBreadcrumb = function (breadcrumb, maxBreadcrumbs) { + var maxCrumbs = typeof maxBreadcrumbs === 'number' ? Math.min(maxBreadcrumbs, MAX_BREADCRUMBS) : MAX_BREADCRUMBS; + // No data has been changed, so don't notify scope listeners + if (maxCrumbs <= 0) { + return this; + } + var mergedBreadcrumb = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({ timestamp: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.dateTimestampInSeconds)() }, breadcrumb); + this._breadcrumbs = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)(this._breadcrumbs, [mergedBreadcrumb]).slice(-maxCrumbs); + this._notifyScopeListeners(); + return this; + }; + /** + * @inheritDoc + */ + Scope.prototype.clearBreadcrumbs = function () { + this._breadcrumbs = []; + this._notifyScopeListeners(); + return this; + }; + /** + * Applies the current context and fingerprint to the event. + * Note that breadcrumbs will be added by the client. + * Also if the event has already breadcrumbs on it, we do not merge them. + * @param event Event + * @param hint May contain additional informartion about the original exception. + * @hidden + */ + Scope.prototype.applyToEvent = function (event, hint) { + var _a; + if (this._extra && Object.keys(this._extra).length) { + event.extra = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._extra), event.extra); + } + if (this._tags && Object.keys(this._tags).length) { + event.tags = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._tags), event.tags); + } + if (this._user && Object.keys(this._user).length) { + event.user = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._user), event.user); + } + if (this._contexts && Object.keys(this._contexts).length) { + event.contexts = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._contexts), event.contexts); + } + if (this._level) { + event.level = this._level; + } + if (this._transactionName) { + event.transaction = this._transactionName; + } + // We want to set the trace context for normal events only if there isn't already + // a trace context on the event. There is a product feature in place where we link + // errors with transaction and it relys on that. + if (this._span) { + event.contexts = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({ trace: this._span.getTraceContext() }, event.contexts); + var transactionName = (_a = this._span.transaction) === null || _a === void 0 ? void 0 : _a.name; + if (transactionName) { + event.tags = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({ transaction: transactionName }, event.tags); + } + } + this._applyFingerprint(event); + event.breadcrumbs = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)((event.breadcrumbs || []), this._breadcrumbs); + event.breadcrumbs = event.breadcrumbs.length > 0 ? event.breadcrumbs : undefined; + return this._notifyEventProcessors((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)(getGlobalEventProcessors(), this._eventProcessors), event, hint); + }; + /** + * This will be called after {@link applyToEvent} is finished. + */ + Scope.prototype._notifyEventProcessors = function (processors, event, hint, index) { + var _this = this; + if (index === void 0) { index = 0; } + return new _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.SyncPromise(function (resolve, reject) { + var processor = processors[index]; + if (event === null || typeof processor !== 'function') { + resolve(event); + } + else { + var result = processor((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, event), hint); + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.isThenable)(result)) { + void result + .then(function (final) { return _this._notifyEventProcessors(processors, final, hint, index + 1).then(resolve); }) + .then(null, reject); + } + else { + void _this._notifyEventProcessors(processors, result, hint, index + 1) + .then(resolve) + .then(null, reject); + } + } + }); + }; + /** + * This will be called on every set call. + */ + Scope.prototype._notifyScopeListeners = function () { + var _this = this; + // We need this check for this._notifyingListeners to be able to work on scope during updates + // If this check is not here we'll produce endless recursion when something is done with the scope + // during the callback. + if (!this._notifyingListeners) { + this._notifyingListeners = true; + this._scopeListeners.forEach(function (callback) { + callback(_this); + }); + this._notifyingListeners = false; + } + }; + /** + * Applies fingerprint from the scope to the event if there's one, + * uses message if there's one instead or get rid of empty fingerprint + */ + Scope.prototype._applyFingerprint = function (event) { + // Make sure it's an array first and we actually have something in place + event.fingerprint = event.fingerprint + ? Array.isArray(event.fingerprint) + ? event.fingerprint + : [event.fingerprint] + : []; + // If we have something on the scope, then merge it with event + if (this._fingerprint) { + event.fingerprint = event.fingerprint.concat(this._fingerprint); + } + // If we have no data at all, remove empty array default + if (event.fingerprint && !event.fingerprint.length) { + delete event.fingerprint; + } + }; + return Scope; +}()); + +/** + * Retruns the global event processors. + */ +function getGlobalEventProcessors() { + /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */ + var global = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.getGlobalObject)(); + global.__SENTRY__ = global.__SENTRY__ || {}; + global.__SENTRY__.globalEventProcessors = global.__SENTRY__.globalEventProcessors || []; + return global.__SENTRY__.globalEventProcessors; + /* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */ +} +/** + * Add a EventProcessor to be kept globally. + * @param callback EventProcessor to add + */ +function addGlobalEventProcessor(callback) { + getGlobalEventProcessors().push(callback); +} +//# sourceMappingURL=scope.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/hub/esm/session.js": +/*!*************************************************!*\ + !*** ./node_modules/@sentry/hub/esm/session.js ***! + \*************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Session": () => (/* binding */ Session) +/* harmony export */ }); +/* harmony import */ var _sentry_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/types */ "./node_modules/@sentry/types/esm/session.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/time.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/object.js"); + + +/** + * @inheritdoc + */ +var Session = /** @class */ (function () { + function Session(context) { + this.errors = 0; + this.sid = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.uuid4)(); + this.duration = 0; + this.status = _sentry_types__WEBPACK_IMPORTED_MODULE_1__.SessionStatus.Ok; + this.init = true; + this.ignoreDuration = false; + // Both timestamp and started are in seconds since the UNIX epoch. + var startingTime = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.timestampInSeconds)(); + this.timestamp = startingTime; + this.started = startingTime; + if (context) { + this.update(context); + } + } + /** JSDoc */ + // eslint-disable-next-line complexity + Session.prototype.update = function (context) { + if (context === void 0) { context = {}; } + if (context.user) { + if (!this.ipAddress && context.user.ip_address) { + this.ipAddress = context.user.ip_address; + } + if (!this.did && !context.did) { + this.did = context.user.id || context.user.email || context.user.username; + } + } + this.timestamp = context.timestamp || (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.timestampInSeconds)(); + if (context.ignoreDuration) { + this.ignoreDuration = context.ignoreDuration; + } + if (context.sid) { + // Good enough uuid validation. — Kamil + this.sid = context.sid.length === 32 ? context.sid : (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.uuid4)(); + } + if (context.init !== undefined) { + this.init = context.init; + } + if (!this.did && context.did) { + this.did = "" + context.did; + } + if (typeof context.started === 'number') { + this.started = context.started; + } + if (this.ignoreDuration) { + this.duration = undefined; + } + else if (typeof context.duration === 'number') { + this.duration = context.duration; + } + else { + var duration = this.timestamp - this.started; + this.duration = duration >= 0 ? duration : 0; + } + if (context.release) { + this.release = context.release; + } + if (context.environment) { + this.environment = context.environment; + } + if (!this.ipAddress && context.ipAddress) { + this.ipAddress = context.ipAddress; + } + if (!this.userAgent && context.userAgent) { + this.userAgent = context.userAgent; + } + if (typeof context.errors === 'number') { + this.errors = context.errors; + } + if (context.status) { + this.status = context.status; + } + }; + /** JSDoc */ + Session.prototype.close = function (status) { + if (status) { + this.update({ status: status }); + } + else if (this.status === _sentry_types__WEBPACK_IMPORTED_MODULE_1__.SessionStatus.Ok) { + this.update({ status: _sentry_types__WEBPACK_IMPORTED_MODULE_1__.SessionStatus.Exited }); + } + else { + this.update(); + } + }; + /** JSDoc */ + Session.prototype.toJSON = function () { + return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.dropUndefinedKeys)({ + sid: "" + this.sid, + init: this.init, + // Make sure that sec is converted to ms for date constructor + started: new Date(this.started * 1000).toISOString(), + timestamp: new Date(this.timestamp * 1000).toISOString(), + status: this.status, + errors: this.errors, + did: typeof this.did === 'number' || typeof this.did === 'string' ? "" + this.did : undefined, + duration: this.duration, + attrs: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.dropUndefinedKeys)({ + release: this.release, + environment: this.environment, + ip_address: this.ipAddress, + user_agent: this.userAgent, + }), + }); + }; + return Session; +}()); + +//# sourceMappingURL=session.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/minimal/esm/index.js": +/*!***************************************************!*\ + !*** ./node_modules/@sentry/minimal/esm/index.js ***! + \***************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "captureException": () => (/* binding */ captureException), +/* harmony export */ "captureMessage": () => (/* binding */ captureMessage), +/* harmony export */ "captureEvent": () => (/* binding */ captureEvent), +/* harmony export */ "configureScope": () => (/* binding */ configureScope), +/* harmony export */ "addBreadcrumb": () => (/* binding */ addBreadcrumb), +/* harmony export */ "setContext": () => (/* binding */ setContext), +/* harmony export */ "setExtras": () => (/* binding */ setExtras), +/* harmony export */ "setTags": () => (/* binding */ setTags), +/* harmony export */ "setExtra": () => (/* binding */ setExtra), +/* harmony export */ "setTag": () => (/* binding */ setTag), +/* harmony export */ "setUser": () => (/* binding */ setUser), +/* harmony export */ "withScope": () => (/* binding */ withScope), +/* harmony export */ "_callOnClient": () => (/* binding */ _callOnClient), +/* harmony export */ "startTransaction": () => (/* binding */ startTransaction) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_hub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/hub */ "./node_modules/@sentry/hub/esm/hub.js"); + + +/** + * This calls a function on the current hub. + * @param method function to call on hub. + * @param args to pass to function. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function callOnHub(method) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + var hub = (0,_sentry_hub__WEBPACK_IMPORTED_MODULE_0__.getCurrentHub)(); + if (hub && hub[method]) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return hub[method].apply(hub, (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__spread)(args)); + } + throw new Error("No hub defined or " + method + " was not found on the hub, please open a bug report."); +} +/** + * Captures an exception event and sends it to Sentry. + * + * @param exception An exception-like object. + * @returns The generated eventId. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types +function captureException(exception, captureContext) { + var syntheticException; + try { + throw new Error('Sentry syntheticException'); + } + catch (exception) { + syntheticException = exception; + } + return callOnHub('captureException', exception, { + captureContext: captureContext, + originalException: exception, + syntheticException: syntheticException, + }); +} +/** + * Captures a message event and sends it to Sentry. + * + * @param message The message to send to Sentry. + * @param level Define the level of the message. + * @returns The generated eventId. + */ +function captureMessage(message, captureContext) { + var syntheticException; + try { + throw new Error(message); + } + catch (exception) { + syntheticException = exception; + } + // This is necessary to provide explicit scopes upgrade, without changing the original + // arity of the `captureMessage(message, level)` method. + var level = typeof captureContext === 'string' ? captureContext : undefined; + var context = typeof captureContext !== 'string' ? { captureContext: captureContext } : undefined; + return callOnHub('captureMessage', message, level, (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__assign)({ originalException: message, syntheticException: syntheticException }, context)); +} +/** + * Captures a manually created event and sends it to Sentry. + * + * @param event The event to send to Sentry. + * @returns The generated eventId. + */ +function captureEvent(event) { + return callOnHub('captureEvent', event); +} +/** + * Callback to set context information onto the scope. + * @param callback Callback function that receives Scope. + */ +function configureScope(callback) { + callOnHub('configureScope', callback); +} +/** + * Records a new breadcrumb which will be attached to future events. + * + * Breadcrumbs will be added to subsequent events to provide more context on + * user's actions prior to an error or crash. + * + * @param breadcrumb The breadcrumb to record. + */ +function addBreadcrumb(breadcrumb) { + callOnHub('addBreadcrumb', breadcrumb); +} +/** + * Sets context data with the given name. + * @param name of the context + * @param context Any kind of data. This data will be normalized. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function setContext(name, context) { + callOnHub('setContext', name, context); +} +/** + * Set an object that will be merged sent as extra data with the event. + * @param extras Extras object to merge into current context. + */ +function setExtras(extras) { + callOnHub('setExtras', extras); +} +/** + * Set an object that will be merged sent as tags data with the event. + * @param tags Tags context object to merge into current context. + */ +function setTags(tags) { + callOnHub('setTags', tags); +} +/** + * Set key:value that will be sent as extra data with the event. + * @param key String of extra + * @param extra Any kind of data. This data will be normalized. + */ +function setExtra(key, extra) { + callOnHub('setExtra', key, extra); +} +/** + * Set key:value that will be sent as tags data with the event. + * + * Can also be used to unset a tag, by passing `undefined`. + * + * @param key String key of tag + * @param value Value of tag + */ +function setTag(key, value) { + callOnHub('setTag', key, value); +} +/** + * Updates user context information for future events. + * + * @param user User context object to be set in the current context. Pass `null` to unset the user. + */ +function setUser(user) { + callOnHub('setUser', user); +} +/** + * Creates a new scope with and executes the given operation within. + * The scope is automatically removed once the operation + * finishes or throws. + * + * This is essentially a convenience function for: + * + * pushScope(); + * callback(); + * popScope(); + * + * @param callback that will be enclosed into push/popScope. + */ +function withScope(callback) { + callOnHub('withScope', callback); +} +/** + * Calls a function on the latest client. Use this with caution, it's meant as + * in "internal" helper so we don't need to expose every possible function in + * the shim. It is not guaranteed that the client actually implements the + * function. + * + * @param method The method to call on the client/client. + * @param args Arguments to pass to the client/fontend. + * @hidden + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function _callOnClient(method) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + callOnHub.apply(void 0, (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__spread)(['_invokeClient', method], args)); +} +/** + * Starts a new `Transaction` and returns it. This is the entry point to manual tracing instrumentation. + * + * A tree structure can be built by adding child spans to the transaction, and child spans to other spans. To start a + * new child span within the transaction or any span, call the respective `.startChild()` method. + * + * Every child span must be finished before the transaction is finished, otherwise the unfinished spans are discarded. + * + * The transaction must be finished with a call to its `.finish()` method, at which point the transaction with all its + * finished child spans will be sent to Sentry. + * + * @param context Properties of the new `Transaction`. + * @param customSamplingContext Information given to the transaction sampling function (along with context-dependent + * default values). See {@link Options.tracesSampler}. + * + * @returns The transaction which was just started + */ +function startTransaction(context, customSamplingContext) { + return callOnHub('startTransaction', (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__assign)({}, context), customSamplingContext); +} +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/react/esm/reactrouter.js": +/*!*******************************************************!*\ + !*** ./node_modules/@sentry/react/esm/reactrouter.js ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "reactRouterV4Instrumentation": () => (/* binding */ reactRouterV4Instrumentation), +/* harmony export */ "reactRouterV5Instrumentation": () => (/* binding */ reactRouterV5Instrumentation), +/* harmony export */ "withSentryRouting": () => (/* binding */ withSentryRouting) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! hoist-non-react-statics */ "./node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js"); +/* harmony import */ var hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); + + + + +/* eslint-enable @typescript-eslint/no-explicit-any */ +var global = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.getGlobalObject)(); +var activeTransaction; +function reactRouterV4Instrumentation(history, routes, matchPath) { + return createReactRouterInstrumentation(history, 'react-router-v4', routes, matchPath); +} +function reactRouterV5Instrumentation(history, routes, matchPath) { + return createReactRouterInstrumentation(history, 'react-router-v5', routes, matchPath); +} +function createReactRouterInstrumentation(history, name, allRoutes, matchPath) { + if (allRoutes === void 0) { allRoutes = []; } + function getInitPathName() { + if (history && history.location) { + return history.location.pathname; + } + if (global && global.location) { + return global.location.pathname; + } + return undefined; + } + function getTransactionName(pathname) { + if (allRoutes === [] || !matchPath) { + return pathname; + } + var branches = matchRoutes(allRoutes, pathname, matchPath); + // eslint-disable-next-line @typescript-eslint/prefer-for-of + for (var x = 0; x < branches.length; x++) { + if (branches[x].match.isExact) { + return branches[x].match.path; + } + } + return pathname; + } + return function (customStartTransaction, startTransactionOnPageLoad, startTransactionOnLocationChange) { + if (startTransactionOnPageLoad === void 0) { startTransactionOnPageLoad = true; } + if (startTransactionOnLocationChange === void 0) { startTransactionOnLocationChange = true; } + var initPathName = getInitPathName(); + if (startTransactionOnPageLoad && initPathName) { + activeTransaction = customStartTransaction({ + name: getTransactionName(initPathName), + op: 'pageload', + tags: { + 'routing.instrumentation': name, + }, + }); + } + if (startTransactionOnLocationChange && history.listen) { + history.listen(function (location, action) { + if (action && (action === 'PUSH' || action === 'POP')) { + if (activeTransaction) { + activeTransaction.finish(); + } + var tags = { + 'routing.instrumentation': name, + }; + activeTransaction = customStartTransaction({ + name: getTransactionName(location.pathname), + op: 'navigation', + tags: tags, + }); + } + }); + } + }; +} +/** + * Matches a set of routes to a pathname + * Based on implementation from + */ +function matchRoutes(routes, pathname, matchPath, branch) { + if (branch === void 0) { branch = []; } + routes.some(function (route) { + var match = route.path + ? matchPath(pathname, route) + : branch.length + ? branch[branch.length - 1].match // use parent match + : computeRootMatch(pathname); // use default "root" match + if (match) { + branch.push({ route: route, match: match }); + if (route.routes) { + matchRoutes(route.routes, pathname, matchPath, branch); + } + } + return !!match; + }); + return branch; +} +function computeRootMatch(pathname) { + return { path: '/', url: '/', params: {}, isExact: pathname === '/' }; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function withSentryRouting(Route) { + var componentDisplayName = Route.displayName || Route.name; + var WrappedRoute = function (props) { + if (activeTransaction && props && props.computedMatch && props.computedMatch.isExact) { + activeTransaction.setName(props.computedMatch.path); + } + return react__WEBPACK_IMPORTED_MODULE_1__.createElement(Route, (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__assign)({}, props)); + }; + WrappedRoute.displayName = "sentryRoute(" + componentDisplayName + ")"; + hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_0___default()(WrappedRoute, Route); + return WrappedRoute; +} +//# sourceMappingURL=reactrouter.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/browser/backgroundtab.js": +/*!*******************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/browser/backgroundtab.js ***! + \*******************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "registerBackgroundTabDetection": () => (/* binding */ registerBackgroundTabDetection) +/* harmony export */ }); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _spanstatus__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../spanstatus */ "./node_modules/@sentry/tracing/esm/spanstatus.js"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils */ "./node_modules/@sentry/tracing/esm/utils.js"); + + + +var global = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)(); +/** + * Add a listener that cancels and finishes a transaction when the global + * document is hidden. + */ +function registerBackgroundTabDetection() { + if (global && global.document) { + global.document.addEventListener('visibilitychange', function () { + var activeTransaction = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.getActiveTransaction)(); + if (global.document.hidden && activeTransaction) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.log("[Tracing] Transaction: " + _spanstatus__WEBPACK_IMPORTED_MODULE_3__.SpanStatus.Cancelled + " -> since tab moved to the background, op: " + activeTransaction.op); + // We should not set status if it is already set, this prevent important statuses like + // error or data loss from being overwritten on transaction. + if (!activeTransaction.status) { + activeTransaction.setStatus(_spanstatus__WEBPACK_IMPORTED_MODULE_3__.SpanStatus.Cancelled); + } + activeTransaction.setTag('visibilitychange', 'document.hidden'); + activeTransaction.finish(); + } + }); + } + else { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.warn('[Tracing] Could not set up background tab detection due to lack of global document'); + } +} +//# sourceMappingURL=backgroundtab.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/browser/browsertracing.js": +/*!********************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/browser/browsertracing.js ***! + \********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DEFAULT_MAX_TRANSACTION_DURATION_SECONDS": () => (/* binding */ DEFAULT_MAX_TRANSACTION_DURATION_SECONDS), +/* harmony export */ "BrowserTracing": () => (/* binding */ BrowserTracing), +/* harmony export */ "getHeaderContext": () => (/* binding */ getHeaderContext), +/* harmony export */ "getMetaContent": () => (/* binding */ getMetaContent) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _hubextensions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../hubextensions */ "./node_modules/@sentry/tracing/esm/hubextensions.js"); +/* harmony import */ var _idletransaction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../idletransaction */ "./node_modules/@sentry/tracing/esm/idletransaction.js"); +/* harmony import */ var _spanstatus__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../spanstatus */ "./node_modules/@sentry/tracing/esm/spanstatus.js"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils */ "./node_modules/@sentry/tracing/esm/utils.js"); +/* harmony import */ var _backgroundtab__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./backgroundtab */ "./node_modules/@sentry/tracing/esm/browser/backgroundtab.js"); +/* harmony import */ var _metrics__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./metrics */ "./node_modules/@sentry/tracing/esm/browser/metrics.js"); +/* harmony import */ var _request__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./request */ "./node_modules/@sentry/tracing/esm/browser/request.js"); +/* harmony import */ var _router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./router */ "./node_modules/@sentry/tracing/esm/browser/router.js"); + + + + + + + + + + +var DEFAULT_MAX_TRANSACTION_DURATION_SECONDS = 600; +var DEFAULT_BROWSER_TRACING_OPTIONS = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({ idleTimeout: _idletransaction__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_IDLE_TIMEOUT, markBackgroundTransactions: true, maxTransactionDuration: DEFAULT_MAX_TRANSACTION_DURATION_SECONDS, routingInstrumentation: _router__WEBPACK_IMPORTED_MODULE_2__.instrumentRoutingWithDefaults, startTransactionOnLocationChange: true, startTransactionOnPageLoad: true }, _request__WEBPACK_IMPORTED_MODULE_3__.defaultRequestInstrumentationOptions); +/** + * The Browser Tracing integration automatically instruments browser pageload/navigation + * actions as transactions, and captures requests, metrics and errors as spans. + * + * The integration can be configured with a variety of options, and can be extended to use + * any routing library. This integration uses {@see IdleTransaction} to create transactions. + */ +var BrowserTracing = /** @class */ (function () { + function BrowserTracing(_options) { + /** + * @inheritDoc + */ + this.name = BrowserTracing.id; + this._metrics = new _metrics__WEBPACK_IMPORTED_MODULE_4__.MetricsInstrumentation(); + this._emitOptionsWarning = false; + var tracingOrigins = _request__WEBPACK_IMPORTED_MODULE_3__.defaultRequestInstrumentationOptions.tracingOrigins; + // NOTE: Logger doesn't work in constructors, as it's initialized after integrations instances + if (_options && + _options.tracingOrigins && + Array.isArray(_options.tracingOrigins) && + _options.tracingOrigins.length !== 0) { + tracingOrigins = _options.tracingOrigins; + } + else { + this._emitOptionsWarning = true; + } + this.options = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, DEFAULT_BROWSER_TRACING_OPTIONS), _options), { tracingOrigins: tracingOrigins }); + } + /** + * @inheritDoc + */ + BrowserTracing.prototype.setupOnce = function (_, getCurrentHub) { + var _this = this; + this._getCurrentHub = getCurrentHub; + if (this._emitOptionsWarning) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.logger.warn('[Tracing] You need to define `tracingOrigins` in the options. Set an array of urls or patterns to trace.'); + _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.logger.warn("[Tracing] We added a reasonable default for you: " + _request__WEBPACK_IMPORTED_MODULE_3__.defaultRequestInstrumentationOptions.tracingOrigins); + } + // eslint-disable-next-line @typescript-eslint/unbound-method + var _a = this.options, instrumentRouting = _a.routingInstrumentation, startTransactionOnLocationChange = _a.startTransactionOnLocationChange, startTransactionOnPageLoad = _a.startTransactionOnPageLoad, markBackgroundTransactions = _a.markBackgroundTransactions, traceFetch = _a.traceFetch, traceXHR = _a.traceXHR, tracingOrigins = _a.tracingOrigins, shouldCreateSpanForRequest = _a.shouldCreateSpanForRequest; + instrumentRouting(function (context) { return _this._createRouteTransaction(context); }, startTransactionOnPageLoad, startTransactionOnLocationChange); + if (markBackgroundTransactions) { + (0,_backgroundtab__WEBPACK_IMPORTED_MODULE_6__.registerBackgroundTabDetection)(); + } + (0,_request__WEBPACK_IMPORTED_MODULE_3__.instrumentOutgoingRequests)({ traceFetch: traceFetch, traceXHR: traceXHR, tracingOrigins: tracingOrigins, shouldCreateSpanForRequest: shouldCreateSpanForRequest }); + }; + /** Create routing idle transaction. */ + BrowserTracing.prototype._createRouteTransaction = function (context) { + var _this = this; + if (!this._getCurrentHub) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.logger.warn("[Tracing] Did not create " + context.op + " transaction because _getCurrentHub is invalid."); + return undefined; + } + // eslint-disable-next-line @typescript-eslint/unbound-method + var _a = this.options, beforeNavigate = _a.beforeNavigate, idleTimeout = _a.idleTimeout, maxTransactionDuration = _a.maxTransactionDuration; + var parentContextFromHeader = context.op === 'pageload' ? getHeaderContext() : undefined; + var expandedContext = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, context), parentContextFromHeader), { trimEnd: true }); + var modifiedContext = typeof beforeNavigate === 'function' ? beforeNavigate(expandedContext) : expandedContext; + // For backwards compatibility reasons, beforeNavigate can return undefined to "drop" the transaction (prevent it + // from being sent to Sentry). + var finalContext = modifiedContext === undefined ? (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, expandedContext), { sampled: false }) : modifiedContext; + if (finalContext.sampled === false) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.logger.log("[Tracing] Will not send " + finalContext.op + " transaction because of beforeNavigate."); + } + _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.logger.log("[Tracing] Starting " + finalContext.op + " transaction on scope"); + var hub = this._getCurrentHub(); + var location = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.getGlobalObject)().location; + var idleTransaction = (0,_hubextensions__WEBPACK_IMPORTED_MODULE_8__.startIdleTransaction)(hub, finalContext, idleTimeout, true, { location: location }); + idleTransaction.registerBeforeFinishCallback(function (transaction, endTimestamp) { + _this._metrics.addPerformanceEntries(transaction); + adjustTransactionDuration((0,_utils__WEBPACK_IMPORTED_MODULE_9__.secToMs)(maxTransactionDuration), transaction, endTimestamp); + }); + return idleTransaction; + }; + /** + * @inheritDoc + */ + BrowserTracing.id = 'BrowserTracing'; + return BrowserTracing; +}()); + +/** + * Gets transaction context from a sentry-trace meta. + * + * @returns Transaction context data from the header or undefined if there's no header or the header is malformed + */ +function getHeaderContext() { + var header = getMetaContent('sentry-trace'); + if (header) { + return (0,_utils__WEBPACK_IMPORTED_MODULE_9__.extractTraceparentData)(header); + } + return undefined; +} +/** Returns the value of a meta tag */ +function getMetaContent(metaName) { + var el = document.querySelector("meta[name=" + metaName + "]"); + return el ? el.getAttribute('content') : null; +} +/** Adjusts transaction value based on max transaction duration */ +function adjustTransactionDuration(maxDuration, transaction, endTimestamp) { + var diff = endTimestamp - transaction.startTimestamp; + var isOutdatedTransaction = endTimestamp && (diff > maxDuration || diff < 0); + if (isOutdatedTransaction) { + transaction.setStatus(_spanstatus__WEBPACK_IMPORTED_MODULE_10__.SpanStatus.DeadlineExceeded); + transaction.setTag('maxTransactionDurationExceeded', 'true'); + } +} +//# sourceMappingURL=browsertracing.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/browser/metrics.js": +/*!*************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/browser/metrics.js ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "MetricsInstrumentation": () => (/* binding */ MetricsInstrumentation), +/* harmony export */ "addResourceSpans": () => (/* binding */ addResourceSpans), +/* harmony export */ "_startChild": () => (/* binding */ _startChild) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/node.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/time.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/browser.js"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils */ "./node_modules/@sentry/tracing/esm/utils.js"); +/* harmony import */ var _web_vitals_getCLS__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./web-vitals/getCLS */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/getCLS.js"); +/* harmony import */ var _web_vitals_getFID__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./web-vitals/getFID */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/getFID.js"); +/* harmony import */ var _web_vitals_getLCP__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./web-vitals/getLCP */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/getLCP.js"); +/* harmony import */ var _web_vitals_lib_getFirstHidden__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./web-vitals/lib/getFirstHidden */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/getFirstHidden.js"); + + + + + + + +var global = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)(); +/** Class tracking metrics */ +var MetricsInstrumentation = /** @class */ (function () { + function MetricsInstrumentation() { + var _a; + this._measurements = {}; + this._performanceCursor = 0; + if (!(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.isNodeEnv)() && ((_a = global) === null || _a === void 0 ? void 0 : _a.performance)) { + if (global.performance.mark) { + global.performance.mark('sentry-tracing-init'); + } + this._trackCLS(); + this._trackLCP(); + this._trackFID(); + } + } + /** Add performance related spans to a transaction */ + MetricsInstrumentation.prototype.addPerformanceEntries = function (transaction) { + var _this = this; + if (!global || !global.performance || !global.performance.getEntries || !_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.browserPerformanceTimeOrigin) { + // Gatekeeper if performance API not available + return; + } + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] Adding & adjusting spans using Performance API'); + var timeOrigin = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.browserPerformanceTimeOrigin); + var entryScriptSrc; + if (global.document) { + // eslint-disable-next-line @typescript-eslint/prefer-for-of + for (var i = 0; i < document.scripts.length; i++) { + // We go through all scripts on the page and look for 'data-entry' + // We remember the name and measure the time between this script finished loading and + // our mark 'sentry-tracing-init' + if (document.scripts[i].dataset.entry === 'true') { + entryScriptSrc = document.scripts[i].src; + break; + } + } + } + var entryScriptStartTimestamp; + var tracingInitMarkStartTime; + var responseStartTimestamp; + var requestStartTimestamp; + global.performance + .getEntries() + .slice(this._performanceCursor) + .forEach(function (entry) { + var startTime = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(entry.startTime); + var duration = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(entry.duration); + if (transaction.op === 'navigation' && timeOrigin + startTime < transaction.startTimestamp) { + return; + } + switch (entry.entryType) { + case 'navigation': { + addNavigationSpans(transaction, entry, timeOrigin); + responseStartTimestamp = timeOrigin + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(entry.responseStart); + requestStartTimestamp = timeOrigin + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(entry.requestStart); + break; + } + case 'mark': + case 'paint': + case 'measure': { + var startTimestamp = addMeasureSpans(transaction, entry, startTime, duration, timeOrigin); + if (tracingInitMarkStartTime === undefined && entry.name === 'sentry-tracing-init') { + tracingInitMarkStartTime = startTimestamp; + } + // capture web vitals + var firstHidden = (0,_web_vitals_lib_getFirstHidden__WEBPACK_IMPORTED_MODULE_5__.getFirstHidden)(); + // Only report if the page wasn't hidden prior to the web vital. + var shouldRecord = entry.startTime < firstHidden.timeStamp; + if (entry.name === 'first-paint' && shouldRecord) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Measurements] Adding FP'); + _this._measurements['fp'] = { value: entry.startTime }; + _this._measurements['mark.fp'] = { value: startTimestamp }; + } + if (entry.name === 'first-contentful-paint' && shouldRecord) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Measurements] Adding FCP'); + _this._measurements['fcp'] = { value: entry.startTime }; + _this._measurements['mark.fcp'] = { value: startTimestamp }; + } + break; + } + case 'resource': { + var resourceName = entry.name.replace(window.location.origin, ''); + var endTimestamp = addResourceSpans(transaction, entry, resourceName, startTime, duration, timeOrigin); + // We remember the entry script end time to calculate the difference to the first init mark + if (entryScriptStartTimestamp === undefined && (entryScriptSrc || '').indexOf(resourceName) > -1) { + entryScriptStartTimestamp = endTimestamp; + } + break; + } + default: + // Ignore other entry types. + } + }); + if (entryScriptStartTimestamp !== undefined && tracingInitMarkStartTime !== undefined) { + _startChild(transaction, { + description: 'evaluation', + endTimestamp: tracingInitMarkStartTime, + op: 'script', + startTimestamp: entryScriptStartTimestamp, + }); + } + this._performanceCursor = Math.max(performance.getEntries().length - 1, 0); + this._trackNavigator(transaction); + // Measurements are only available for pageload transactions + if (transaction.op === 'pageload') { + // normalize applicable web vital values to be relative to transaction.startTimestamp + var timeOrigin_1 = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.browserPerformanceTimeOrigin); + // Generate TTFB (Time to First Byte), which measured as the time between the beginning of the transaction and the + // start of the response in milliseconds + if (typeof responseStartTimestamp === 'number') { + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Measurements] Adding TTFB'); + this._measurements['ttfb'] = { value: (responseStartTimestamp - transaction.startTimestamp) * 1000 }; + if (typeof requestStartTimestamp === 'number' && requestStartTimestamp <= responseStartTimestamp) { + // Capture the time spent making the request and receiving the first byte of the response. + // This is the time between the start of the request and the start of the response in milliseconds. + this._measurements['ttfb.requestTime'] = { value: (responseStartTimestamp - requestStartTimestamp) * 1000 }; + } + } + ['fcp', 'fp', 'lcp'].forEach(function (name) { + if (!_this._measurements[name] || timeOrigin_1 >= transaction.startTimestamp) { + return; + } + // The web vitals, fcp, fp, lcp, and ttfb, all measure relative to timeOrigin. + // Unfortunately, timeOrigin is not captured within the transaction span data, so these web vitals will need + // to be adjusted to be relative to transaction.startTimestamp. + var oldValue = _this._measurements[name].value; + var measurementTimestamp = timeOrigin_1 + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(oldValue); + // normalizedValue should be in milliseconds + var normalizedValue = Math.abs((measurementTimestamp - transaction.startTimestamp) * 1000); + var delta = normalizedValue - oldValue; + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log("[Measurements] Normalized " + name + " from " + oldValue + " to " + normalizedValue + " (" + delta + ")"); + _this._measurements[name].value = normalizedValue; + }); + if (this._measurements['mark.fid'] && this._measurements['fid']) { + // create span for FID + _startChild(transaction, { + description: 'first input delay', + endTimestamp: this._measurements['mark.fid'].value + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(this._measurements['fid'].value), + op: 'web.vitals', + startTimestamp: this._measurements['mark.fid'].value, + }); + } + transaction.setMeasurements(this._measurements); + this._tagMetricInfo(transaction); + } + }; + /** Add LCP / CLS data to transaction to allow debugging */ + MetricsInstrumentation.prototype._tagMetricInfo = function (transaction) { + if (this._lcpEntry) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Measurements] Adding LCP Data'); + // Capture Properties of the LCP element that contributes to the LCP. + if (this._lcpEntry.element) { + transaction.setTag('lcp.element', (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.htmlTreeAsString)(this._lcpEntry.element)); + } + if (this._lcpEntry.id) { + transaction.setTag('lcp.id', this._lcpEntry.id); + } + if (this._lcpEntry.url) { + // Trim URL to the first 200 characters. + transaction.setTag('lcp.url', this._lcpEntry.url.trim().slice(0, 200)); + } + transaction.setTag('lcp.size', this._lcpEntry.size); + } + if (this._clsEntry) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Measurements] Adding CLS Data'); + this._clsEntry.sources.map(function (source, index) { + return transaction.setTag("cls.source." + (index + 1), (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.htmlTreeAsString)(source.node)); + }); + } + }; + /** Starts tracking the Cumulative Layout Shift on the current page. */ + MetricsInstrumentation.prototype._trackCLS = function () { + var _this = this; + (0,_web_vitals_getCLS__WEBPACK_IMPORTED_MODULE_7__.getCLS)(function (metric) { + var entry = metric.entries.pop(); + if (!entry) { + return; + } + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Measurements] Adding CLS'); + _this._measurements['cls'] = { value: metric.value }; + _this._clsEntry = entry; + }); + }; + /** + * Capture the information of the user agent. + */ + MetricsInstrumentation.prototype._trackNavigator = function (transaction) { + var navigator = global.navigator; + if (!navigator) { + return; + } + // track network connectivity + var connection = navigator.connection; + if (connection) { + if (connection.effectiveType) { + transaction.setTag('effectiveConnectionType', connection.effectiveType); + } + if (connection.type) { + transaction.setTag('connectionType', connection.type); + } + if (isMeasurementValue(connection.rtt)) { + this._measurements['connection.rtt'] = { value: connection.rtt }; + } + if (isMeasurementValue(connection.downlink)) { + this._measurements['connection.downlink'] = { value: connection.downlink }; + } + } + if (isMeasurementValue(navigator.deviceMemory)) { + transaction.setTag('deviceMemory', String(navigator.deviceMemory)); + } + if (isMeasurementValue(navigator.hardwareConcurrency)) { + transaction.setTag('hardwareConcurrency', String(navigator.hardwareConcurrency)); + } + }; + /** Starts tracking the Largest Contentful Paint on the current page. */ + MetricsInstrumentation.prototype._trackLCP = function () { + var _this = this; + (0,_web_vitals_getLCP__WEBPACK_IMPORTED_MODULE_8__.getLCP)(function (metric) { + var entry = metric.entries.pop(); + if (!entry) { + return; + } + var timeOrigin = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.browserPerformanceTimeOrigin); + var startTime = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(entry.startTime); + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Measurements] Adding LCP'); + _this._measurements['lcp'] = { value: metric.value }; + _this._measurements['mark.lcp'] = { value: timeOrigin + startTime }; + _this._lcpEntry = entry; + }); + }; + /** Starts tracking the First Input Delay on the current page. */ + MetricsInstrumentation.prototype._trackFID = function () { + var _this = this; + (0,_web_vitals_getFID__WEBPACK_IMPORTED_MODULE_9__.getFID)(function (metric) { + var entry = metric.entries.pop(); + if (!entry) { + return; + } + var timeOrigin = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.browserPerformanceTimeOrigin); + var startTime = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(entry.startTime); + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Measurements] Adding FID'); + _this._measurements['fid'] = { value: metric.value }; + _this._measurements['mark.fid'] = { value: timeOrigin + startTime }; + }); + }; + return MetricsInstrumentation; +}()); + +/** Instrument navigation entries */ +function addNavigationSpans(transaction, entry, timeOrigin) { + addPerformanceNavigationTiming({ transaction: transaction, entry: entry, event: 'unloadEvent', timeOrigin: timeOrigin }); + addPerformanceNavigationTiming({ transaction: transaction, entry: entry, event: 'redirect', timeOrigin: timeOrigin }); + addPerformanceNavigationTiming({ transaction: transaction, entry: entry, event: 'domContentLoadedEvent', timeOrigin: timeOrigin }); + addPerformanceNavigationTiming({ transaction: transaction, entry: entry, event: 'loadEvent', timeOrigin: timeOrigin }); + addPerformanceNavigationTiming({ transaction: transaction, entry: entry, event: 'connect', timeOrigin: timeOrigin }); + addPerformanceNavigationTiming({ + transaction: transaction, + entry: entry, + event: 'secureConnection', + timeOrigin: timeOrigin, + eventEnd: 'connectEnd', + description: 'TLS/SSL', + }); + addPerformanceNavigationTiming({ + transaction: transaction, + entry: entry, + event: 'fetch', + timeOrigin: timeOrigin, + eventEnd: 'domainLookupStart', + description: 'cache', + }); + addPerformanceNavigationTiming({ transaction: transaction, entry: entry, event: 'domainLookup', timeOrigin: timeOrigin, description: 'DNS' }); + addRequest(transaction, entry, timeOrigin); +} +/** Create measure related spans */ +function addMeasureSpans(transaction, entry, startTime, duration, timeOrigin) { + var measureStartTimestamp = timeOrigin + startTime; + var measureEndTimestamp = measureStartTimestamp + duration; + _startChild(transaction, { + description: entry.name, + endTimestamp: measureEndTimestamp, + op: entry.entryType, + startTimestamp: measureStartTimestamp, + }); + return measureStartTimestamp; +} +/** Create resource-related spans */ +function addResourceSpans(transaction, entry, resourceName, startTime, duration, timeOrigin) { + // we already instrument based on fetch and xhr, so we don't need to + // duplicate spans here. + if (entry.initiatorType === 'xmlhttprequest' || entry.initiatorType === 'fetch') { + return undefined; + } + var data = {}; + if ('transferSize' in entry) { + data['Transfer Size'] = entry.transferSize; + } + if ('encodedBodySize' in entry) { + data['Encoded Body Size'] = entry.encodedBodySize; + } + if ('decodedBodySize' in entry) { + data['Decoded Body Size'] = entry.decodedBodySize; + } + var startTimestamp = timeOrigin + startTime; + var endTimestamp = startTimestamp + duration; + _startChild(transaction, { + description: resourceName, + endTimestamp: endTimestamp, + op: entry.initiatorType ? "resource." + entry.initiatorType : 'resource', + startTimestamp: startTimestamp, + data: data, + }); + return endTimestamp; +} +/** Create performance navigation related spans */ +function addPerformanceNavigationTiming(props) { + var transaction = props.transaction, entry = props.entry, event = props.event, timeOrigin = props.timeOrigin, eventEnd = props.eventEnd, description = props.description; + var end = eventEnd ? entry[eventEnd] : entry[event + "End"]; + var start = entry[event + "Start"]; + if (!start || !end) { + return; + } + _startChild(transaction, { + op: 'browser', + description: (description !== null && description !== void 0 ? description : event), + startTimestamp: timeOrigin + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(start), + endTimestamp: timeOrigin + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(end), + }); +} +/** Create request and response related spans */ +function addRequest(transaction, entry, timeOrigin) { + _startChild(transaction, { + op: 'browser', + description: 'request', + startTimestamp: timeOrigin + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(entry.requestStart), + endTimestamp: timeOrigin + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(entry.responseEnd), + }); + _startChild(transaction, { + op: 'browser', + description: 'response', + startTimestamp: timeOrigin + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(entry.responseStart), + endTimestamp: timeOrigin + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.msToSec)(entry.responseEnd), + }); +} +/** + * Helper function to start child on transactions. This function will make sure that the transaction will + * use the start timestamp of the created child span if it is earlier than the transactions actual + * start timestamp. + */ +function _startChild(transaction, _a) { + var startTimestamp = _a.startTimestamp, ctx = (0,tslib__WEBPACK_IMPORTED_MODULE_10__.__rest)(_a, ["startTimestamp"]); + if (startTimestamp && transaction.startTimestamp > startTimestamp) { + transaction.startTimestamp = startTimestamp; + } + return transaction.startChild((0,tslib__WEBPACK_IMPORTED_MODULE_10__.__assign)({ startTimestamp: startTimestamp }, ctx)); +} +/** + * Checks if a given value is a valid measurement value. + */ +function isMeasurementValue(value) { + return typeof value === 'number' && isFinite(value); +} +//# sourceMappingURL=metrics.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/browser/request.js": +/*!*************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/browser/request.js ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DEFAULT_TRACING_ORIGINS": () => (/* binding */ DEFAULT_TRACING_ORIGINS), +/* harmony export */ "defaultRequestInstrumentationOptions": () => (/* binding */ defaultRequestInstrumentationOptions), +/* harmony export */ "instrumentOutgoingRequests": () => (/* binding */ instrumentOutgoingRequests), +/* harmony export */ "fetchCallback": () => (/* binding */ fetchCallback), +/* harmony export */ "xhrCallback": () => (/* binding */ xhrCallback) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/string.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/instrument.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/is.js"); +/* harmony import */ var _spanstatus__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../spanstatus */ "./node_modules/@sentry/tracing/esm/spanstatus.js"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils */ "./node_modules/@sentry/tracing/esm/utils.js"); + + + + +var DEFAULT_TRACING_ORIGINS = ['localhost', /^\//]; +var defaultRequestInstrumentationOptions = { + traceFetch: true, + traceXHR: true, + tracingOrigins: DEFAULT_TRACING_ORIGINS, +}; +/** Registers span creators for xhr and fetch requests */ +function instrumentOutgoingRequests(_options) { + // eslint-disable-next-line @typescript-eslint/unbound-method + var _a = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, defaultRequestInstrumentationOptions), _options), traceFetch = _a.traceFetch, traceXHR = _a.traceXHR, tracingOrigins = _a.tracingOrigins, shouldCreateSpanForRequest = _a.shouldCreateSpanForRequest; + // We should cache url -> decision so that we don't have to compute + // regexp everytime we create a request. + var urlMap = {}; + var defaultShouldCreateSpan = function (url) { + if (urlMap[url]) { + return urlMap[url]; + } + var origins = tracingOrigins; + urlMap[url] = + origins.some(function (origin) { return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.isMatchingPattern)(url, origin); }) && + !(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.isMatchingPattern)(url, 'sentry_key'); + return urlMap[url]; + }; + // We want that our users don't have to re-implement shouldCreateSpanForRequest themselves + // That's why we filter out already unwanted Spans from tracingOrigins + var shouldCreateSpan = defaultShouldCreateSpan; + if (typeof shouldCreateSpanForRequest === 'function') { + shouldCreateSpan = function (url) { + return defaultShouldCreateSpan(url) && shouldCreateSpanForRequest(url); + }; + } + var spans = {}; + if (traceFetch) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.addInstrumentationHandler)({ + callback: function (handlerData) { + fetchCallback(handlerData, shouldCreateSpan, spans); + }, + type: 'fetch', + }); + } + if (traceXHR) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.addInstrumentationHandler)({ + callback: function (handlerData) { + xhrCallback(handlerData, shouldCreateSpan, spans); + }, + type: 'xhr', + }); + } +} +/** + * Create and track fetch request spans + */ +function fetchCallback(handlerData, shouldCreateSpan, spans) { + if (!(0,_utils__WEBPACK_IMPORTED_MODULE_3__.hasTracingEnabled)() || !(handlerData.fetchData && shouldCreateSpan(handlerData.fetchData.url))) { + return; + } + if (handlerData.endTimestamp && handlerData.fetchData.__span) { + var span = spans[handlerData.fetchData.__span]; + if (span) { + if (handlerData.response) { + // TODO (kmclb) remove this once types PR goes through + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + span.setHttpStatus(handlerData.response.status); + } + else if (handlerData.error) { + span.setStatus(_spanstatus__WEBPACK_IMPORTED_MODULE_4__.SpanStatus.InternalError); + } + span.finish(); + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete spans[handlerData.fetchData.__span]; + } + return; + } + var activeTransaction = (0,_utils__WEBPACK_IMPORTED_MODULE_3__.getActiveTransaction)(); + if (activeTransaction) { + var span = activeTransaction.startChild({ + data: (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, handlerData.fetchData), { type: 'fetch' }), + description: handlerData.fetchData.method + " " + handlerData.fetchData.url, + op: 'http', + }); + handlerData.fetchData.__span = span.spanId; + spans[span.spanId] = span; + var request = (handlerData.args[0] = handlerData.args[0]); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + var options = (handlerData.args[1] = handlerData.args[1] || {}); + var headers = options.headers; + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.isInstanceOf)(request, Request)) { + headers = request.headers; + } + if (headers) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + if (typeof headers.append === 'function') { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + headers.append('sentry-trace', span.toTraceparent()); + } + else if (Array.isArray(headers)) { + headers = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__spread)(headers, [['sentry-trace', span.toTraceparent()]]); + } + else { + headers = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, headers), { 'sentry-trace': span.toTraceparent() }); + } + } + else { + headers = { 'sentry-trace': span.toTraceparent() }; + } + options.headers = headers; + } +} +/** + * Create and track xhr request spans + */ +function xhrCallback(handlerData, shouldCreateSpan, spans) { + var _a, _b; + if (!(0,_utils__WEBPACK_IMPORTED_MODULE_3__.hasTracingEnabled)() || ((_a = handlerData.xhr) === null || _a === void 0 ? void 0 : _a.__sentry_own_request__) || + !(((_b = handlerData.xhr) === null || _b === void 0 ? void 0 : _b.__sentry_xhr__) && shouldCreateSpan(handlerData.xhr.__sentry_xhr__.url))) { + return; + } + var xhr = handlerData.xhr.__sentry_xhr__; + // check first if the request has finished and is tracked by an existing span which should now end + if (handlerData.endTimestamp && handlerData.xhr.__sentry_xhr_span_id__) { + var span = spans[handlerData.xhr.__sentry_xhr_span_id__]; + if (span) { + span.setHttpStatus(xhr.status_code); + span.finish(); + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete spans[handlerData.xhr.__sentry_xhr_span_id__]; + } + return; + } + // if not, create a new span to track it + var activeTransaction = (0,_utils__WEBPACK_IMPORTED_MODULE_3__.getActiveTransaction)(); + if (activeTransaction) { + var span = activeTransaction.startChild({ + data: (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, xhr.data), { type: 'xhr', method: xhr.method, url: xhr.url }), + description: xhr.method + " " + xhr.url, + op: 'http', + }); + handlerData.xhr.__sentry_xhr_span_id__ = span.spanId; + spans[handlerData.xhr.__sentry_xhr_span_id__] = span; + if (handlerData.xhr.setRequestHeader) { + try { + handlerData.xhr.setRequestHeader('sentry-trace', span.toTraceparent()); + } + catch (_) { + // Error: InvalidStateError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED. + } + } + } +} +//# sourceMappingURL=request.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/browser/router.js": +/*!************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/browser/router.js ***! + \************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "instrumentRoutingWithDefaults": () => (/* binding */ instrumentRoutingWithDefaults) +/* harmony export */ }); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/instrument.js"); + +var global = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)(); +/** + * Default function implementing pageload and navigation transactions + */ +function instrumentRoutingWithDefaults(customStartTransaction, startTransactionOnPageLoad, startTransactionOnLocationChange) { + if (startTransactionOnPageLoad === void 0) { startTransactionOnPageLoad = true; } + if (startTransactionOnLocationChange === void 0) { startTransactionOnLocationChange = true; } + if (!global || !global.location) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.warn('Could not initialize routing instrumentation due to invalid location'); + return; + } + var startingUrl = global.location.href; + var activeTransaction; + if (startTransactionOnPageLoad) { + activeTransaction = customStartTransaction({ name: global.location.pathname, op: 'pageload' }); + } + if (startTransactionOnLocationChange) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.addInstrumentationHandler)({ + callback: function (_a) { + var to = _a.to, from = _a.from; + /** + * This early return is there to account for some cases where a navigation transaction starts right after + * long-running pageload. We make sure that if `from` is undefined and a valid `startingURL` exists, we don't + * create an uneccessary navigation transaction. + * + * This was hard to duplicate, but this behavior stopped as soon as this fix was applied. This issue might also + * only be caused in certain development environments where the usage of a hot module reloader is causing + * errors. + */ + if (from === undefined && startingUrl && startingUrl.indexOf(to) !== -1) { + startingUrl = undefined; + return; + } + if (from !== to) { + startingUrl = undefined; + if (activeTransaction) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log("[Tracing] Finishing current transaction with op: " + activeTransaction.op); + // If there's an open transaction on the scope, we need to finish it before creating an new one. + activeTransaction.finish(); + } + activeTransaction = customStartTransaction({ name: global.location.pathname, op: 'navigation' }); + } + }, + type: 'history', + }); + } +} +//# sourceMappingURL=router.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/browser/web-vitals/getCLS.js": +/*!***********************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/browser/web-vitals/getCLS.js ***! + \***********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getCLS": () => (/* binding */ getCLS) +/* harmony export */ }); +/* harmony import */ var _lib_bindReporter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/bindReporter */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/bindReporter.js"); +/* harmony import */ var _lib_initMetric__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/initMetric */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/initMetric.js"); +/* harmony import */ var _lib_observe__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/observe */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/observe.js"); +/* harmony import */ var _lib_onHidden__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lib/onHidden */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/onHidden.js"); +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + + +var getCLS = function (onReport, reportAllChanges) { + if (reportAllChanges === void 0) { reportAllChanges = false; } + var metric = (0,_lib_initMetric__WEBPACK_IMPORTED_MODULE_0__.initMetric)('CLS', 0); + var report; + var entryHandler = function (entry) { + // Only count layout shifts without recent user input. + if (!entry.hadRecentInput) { + metric.value += entry.value; + metric.entries.push(entry); + report(); + } + }; + var po = (0,_lib_observe__WEBPACK_IMPORTED_MODULE_1__.observe)('layout-shift', entryHandler); + if (po) { + report = (0,_lib_bindReporter__WEBPACK_IMPORTED_MODULE_2__.bindReporter)(onReport, metric, po, reportAllChanges); + (0,_lib_onHidden__WEBPACK_IMPORTED_MODULE_3__.onHidden)(function (_a) { + var isUnloading = _a.isUnloading; + po.takeRecords().map(entryHandler); + if (isUnloading) { + metric.isFinal = true; + } + report(); + }); + } +}; +//# sourceMappingURL=getCLS.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/browser/web-vitals/getFID.js": +/*!***********************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/browser/web-vitals/getFID.js ***! + \***********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getFID": () => (/* binding */ getFID) +/* harmony export */ }); +/* harmony import */ var _lib_bindReporter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lib/bindReporter */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/bindReporter.js"); +/* harmony import */ var _lib_getFirstHidden__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/getFirstHidden */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/getFirstHidden.js"); +/* harmony import */ var _lib_initMetric__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/initMetric */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/initMetric.js"); +/* harmony import */ var _lib_observe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/observe */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/observe.js"); +/* harmony import */ var _lib_onHidden__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lib/onHidden */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/onHidden.js"); +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + + + +var getFID = function (onReport) { + var metric = (0,_lib_initMetric__WEBPACK_IMPORTED_MODULE_0__.initMetric)('FID'); + var firstHidden = (0,_lib_getFirstHidden__WEBPACK_IMPORTED_MODULE_1__.getFirstHidden)(); + var entryHandler = function (entry) { + // Only report if the page wasn't hidden prior to the first input. + if (entry.startTime < firstHidden.timeStamp) { + metric.value = entry.processingStart - entry.startTime; + metric.entries.push(entry); + metric.isFinal = true; + report(); + } + }; + var po = (0,_lib_observe__WEBPACK_IMPORTED_MODULE_2__.observe)('first-input', entryHandler); + var report = (0,_lib_bindReporter__WEBPACK_IMPORTED_MODULE_3__.bindReporter)(onReport, metric, po); + if (po) { + (0,_lib_onHidden__WEBPACK_IMPORTED_MODULE_4__.onHidden)(function () { + po.takeRecords().map(entryHandler); + po.disconnect(); + }, true); + } + else { + if (window.perfMetrics && window.perfMetrics.onFirstInputDelay) { + window.perfMetrics.onFirstInputDelay(function (value, event) { + // Only report if the page wasn't hidden prior to the first input. + if (event.timeStamp < firstHidden.timeStamp) { + metric.value = value; + metric.isFinal = true; + metric.entries = [ + { + entryType: 'first-input', + name: event.type, + target: event.target, + cancelable: event.cancelable, + startTime: event.timeStamp, + processingStart: event.timeStamp + value, + }, + ]; + report(); + } + }); + } + } +}; +//# sourceMappingURL=getFID.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/browser/web-vitals/getLCP.js": +/*!***********************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/browser/web-vitals/getLCP.js ***! + \***********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getLCP": () => (/* binding */ getLCP) +/* harmony export */ }); +/* harmony import */ var _lib_bindReporter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lib/bindReporter */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/bindReporter.js"); +/* harmony import */ var _lib_getFirstHidden__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/getFirstHidden */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/getFirstHidden.js"); +/* harmony import */ var _lib_initMetric__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/initMetric */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/initMetric.js"); +/* harmony import */ var _lib_observe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/observe */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/observe.js"); +/* harmony import */ var _lib_onHidden__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./lib/onHidden */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/onHidden.js"); +/* harmony import */ var _lib_whenInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lib/whenInput */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/whenInput.js"); +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + + + + +var getLCP = function (onReport, reportAllChanges) { + if (reportAllChanges === void 0) { reportAllChanges = false; } + var metric = (0,_lib_initMetric__WEBPACK_IMPORTED_MODULE_0__.initMetric)('LCP'); + var firstHidden = (0,_lib_getFirstHidden__WEBPACK_IMPORTED_MODULE_1__.getFirstHidden)(); + var report; + var entryHandler = function (entry) { + // The startTime attribute returns the value of the renderTime if it is not 0, + // and the value of the loadTime otherwise. + var value = entry.startTime; + // If the page was hidden prior to paint time of the entry, + // ignore it and mark the metric as final, otherwise add the entry. + if (value < firstHidden.timeStamp) { + metric.value = value; + metric.entries.push(entry); + } + else { + metric.isFinal = true; + } + report(); + }; + var po = (0,_lib_observe__WEBPACK_IMPORTED_MODULE_2__.observe)('largest-contentful-paint', entryHandler); + if (po) { + report = (0,_lib_bindReporter__WEBPACK_IMPORTED_MODULE_3__.bindReporter)(onReport, metric, po, reportAllChanges); + var onFinal = function () { + if (!metric.isFinal) { + po.takeRecords().map(entryHandler); + metric.isFinal = true; + report(); + } + }; + void (0,_lib_whenInput__WEBPACK_IMPORTED_MODULE_4__.whenInput)().then(onFinal); + (0,_lib_onHidden__WEBPACK_IMPORTED_MODULE_5__.onHidden)(onFinal, true); + } +}; +//# sourceMappingURL=getLCP.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/bindReporter.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/bindReporter.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "bindReporter": () => (/* binding */ bindReporter) +/* harmony export */ }); +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var bindReporter = function (callback, metric, po, observeAllUpdates) { + var prevValue; + return function () { + if (po && metric.isFinal) { + po.disconnect(); + } + if (metric.value >= 0) { + if (observeAllUpdates || metric.isFinal || document.visibilityState === 'hidden') { + metric.delta = metric.value - (prevValue || 0); + // Report the metric if there's a non-zero delta, if the metric is + // final, or if no previous value exists (which can happen in the case + // of the document becoming hidden when the metric value is 0). + // See: https://github.com/GoogleChrome/web-vitals/issues/14 + if (metric.delta || metric.isFinal || prevValue === undefined) { + callback(metric); + prevValue = metric.value; + } + } + } + }; +}; +//# sourceMappingURL=bindReporter.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/generateUniqueID.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/generateUniqueID.js ***! + \*************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "generateUniqueID": () => (/* binding */ generateUniqueID) +/* harmony export */ }); +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Performantly generate a unique, 27-char string by combining the current + * timestamp with a 13-digit random number. + * @return {string} + */ +var generateUniqueID = function () { + return Date.now() + "-" + (Math.floor(Math.random() * (9e12 - 1)) + 1e12); +}; +//# sourceMappingURL=generateUniqueID.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/getFirstHidden.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/getFirstHidden.js ***! + \***********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getFirstHidden": () => (/* binding */ getFirstHidden) +/* harmony export */ }); +/* harmony import */ var _onHidden__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./onHidden */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/onHidden.js"); +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var firstHiddenTime; +var getFirstHidden = function () { + if (firstHiddenTime === undefined) { + // If the document is hidden when this code runs, assume it was hidden + // since navigation start. This isn't a perfect heuristic, but it's the + // best we can do until an API is available to support querying past + // visibilityState. + firstHiddenTime = document.visibilityState === 'hidden' ? 0 : Infinity; + // Update the time if/when the document becomes hidden. + (0,_onHidden__WEBPACK_IMPORTED_MODULE_0__.onHidden)(function (_a) { + var timeStamp = _a.timeStamp; + return (firstHiddenTime = timeStamp); + }, true); + } + return { + get timeStamp() { + return firstHiddenTime; + }, + }; +}; +//# sourceMappingURL=getFirstHidden.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/initMetric.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/initMetric.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "initMetric": () => (/* binding */ initMetric) +/* harmony export */ }); +/* harmony import */ var _generateUniqueID__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./generateUniqueID */ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/generateUniqueID.js"); +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var initMetric = function (name, value) { + if (value === void 0) { value = -1; } + return { + name: name, + value: value, + delta: 0, + entries: [], + id: (0,_generateUniqueID__WEBPACK_IMPORTED_MODULE_0__.generateUniqueID)(), + isFinal: false, + }; +}; +//# sourceMappingURL=initMetric.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/observe.js": +/*!****************************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/observe.js ***! + \****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "observe": () => (/* binding */ observe) +/* harmony export */ }); +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Takes a performance entry type and a callback function, and creates a + * `PerformanceObserver` instance that will observe the specified entry type + * with buffering enabled and call the callback _for each entry_. + * + * This function also feature-detects entry support and wraps the logic in a + * try/catch to avoid errors in unsupporting browsers. + */ +var observe = function (type, callback) { + try { + if (PerformanceObserver.supportedEntryTypes.includes(type)) { + var po = new PerformanceObserver(function (l) { return l.getEntries().map(callback); }); + po.observe({ type: type, buffered: true }); + return po; + } + } + catch (e) { + // Do nothing. + } + return; +}; +//# sourceMappingURL=observe.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/onHidden.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/onHidden.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "onHidden": () => (/* binding */ onHidden) +/* harmony export */ }); +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var isUnloading = false; +var listenersAdded = false; +var onPageHide = function (event) { + isUnloading = !event.persisted; +}; +var addListeners = function () { + addEventListener('pagehide', onPageHide); + // `beforeunload` is needed to fix this bug: + // https://bugs.chromium.org/p/chromium/issues/detail?id=987409 + // eslint-disable-next-line @typescript-eslint/no-empty-function + addEventListener('beforeunload', function () { }); +}; +var onHidden = function (cb, once) { + if (once === void 0) { once = false; } + if (!listenersAdded) { + addListeners(); + listenersAdded = true; + } + addEventListener('visibilitychange', function (_a) { + var timeStamp = _a.timeStamp; + if (document.visibilityState === 'hidden') { + cb({ timeStamp: timeStamp, isUnloading: isUnloading }); + } + }, { capture: true, once: once }); +}; +//# sourceMappingURL=onHidden.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/whenInput.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/browser/web-vitals/lib/whenInput.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "whenInput": () => (/* binding */ whenInput) +/* harmony export */ }); +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var inputPromise; +var whenInput = function () { + if (!inputPromise) { + inputPromise = new Promise(function (r) { + return ['scroll', 'keydown', 'pointerdown'].map(function (type) { + addEventListener(type, r, { + once: true, + passive: true, + capture: true, + }); + }); + }); + } + return inputPromise; +}; +//# sourceMappingURL=whenInput.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/errors.js": +/*!****************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/errors.js ***! + \****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "registerErrorInstrumentation": () => (/* binding */ registerErrorInstrumentation) +/* harmony export */ }); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/instrument.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _spanstatus__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./spanstatus */ "./node_modules/@sentry/tracing/esm/spanstatus.js"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./node_modules/@sentry/tracing/esm/utils.js"); + + + +/** + * Configures global error listeners + */ +function registerErrorInstrumentation() { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.addInstrumentationHandler)({ + callback: errorCallback, + type: 'error', + }); + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.addInstrumentationHandler)({ + callback: errorCallback, + type: 'unhandledrejection', + }); +} +/** + * If an error or unhandled promise occurs, we mark the active transaction as failed + */ +function errorCallback() { + var activeTransaction = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.getActiveTransaction)(); + if (activeTransaction) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.log("[Tracing] Transaction: " + _spanstatus__WEBPACK_IMPORTED_MODULE_3__.SpanStatus.InternalError + " -> Global error occured"); + activeTransaction.setStatus(_spanstatus__WEBPACK_IMPORTED_MODULE_3__.SpanStatus.InternalError); + } +} +//# sourceMappingURL=errors.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/hubextensions.js": +/*!***********************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/hubextensions.js ***! + \***********************************************************/ +/***/ ((module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "startIdleTransaction": () => (/* binding */ startIdleTransaction), +/* harmony export */ "_addTracingExtensions": () => (/* binding */ _addTracingExtensions), +/* harmony export */ "addExtensionMethods": () => (/* binding */ addExtensionMethods) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_hub__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @sentry/hub */ "./node_modules/@sentry/hub/esm/hub.js"); +/* harmony import */ var _sentry_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/types */ "./node_modules/@sentry/types/esm/transaction.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/node.js"); +/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./errors */ "./node_modules/@sentry/tracing/esm/errors.js"); +/* harmony import */ var _idletransaction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./idletransaction */ "./node_modules/@sentry/tracing/esm/idletransaction.js"); +/* harmony import */ var _transaction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./transaction */ "./node_modules/@sentry/tracing/esm/transaction.js"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ "./node_modules/@sentry/tracing/esm/utils.js"); +/* module decorator */ module = __webpack_require__.hmd(module); + + + + + + + + +/** Returns all trace headers that are currently on the top scope. */ +function traceHeaders() { + var scope = this.getScope(); + if (scope) { + var span = scope.getSpan(); + if (span) { + return { + 'sentry-trace': span.toTraceparent(), + }; + } + } + return {}; +} +/** + * Makes a sampling decision for the given transaction and stores it on the transaction. + * + * Called every time a transaction is created. Only transactions which emerge with a `sampled` value of `true` will be + * sent to Sentry. + * + * @param hub: The hub off of which to read config options + * @param transaction: The transaction needing a sampling decision + * @param samplingContext: Default and user-provided data which may be used to help make the decision + * + * @returns The given transaction with its `sampled` value set + */ +function sample(transaction, options, samplingContext) { + // nothing to do if tracing is not enabled + if (!(0,_utils__WEBPACK_IMPORTED_MODULE_0__.hasTracingEnabled)()) { + transaction.sampled = false; + return transaction; + } + // if the user has forced a sampling decision by passing a `sampled` value in their transaction context, go with that + if (transaction.sampled !== undefined) { + transaction.setMetadata({ + transactionSampling: { method: _sentry_types__WEBPACK_IMPORTED_MODULE_1__.TransactionSamplingMethod.Explicit }, + }); + return transaction; + } + // we would have bailed already if neither `tracesSampler` nor `tracesSampleRate` were defined, so one of these should + // work; prefer the hook if so + var sampleRate; + if (typeof options.tracesSampler === 'function') { + sampleRate = options.tracesSampler(samplingContext); + transaction.setMetadata({ + transactionSampling: { + method: _sentry_types__WEBPACK_IMPORTED_MODULE_1__.TransactionSamplingMethod.Sampler, + // cast to number in case it's a boolean + rate: Number(sampleRate), + }, + }); + } + else if (samplingContext.parentSampled !== undefined) { + sampleRate = samplingContext.parentSampled; + transaction.setMetadata({ + transactionSampling: { method: _sentry_types__WEBPACK_IMPORTED_MODULE_1__.TransactionSamplingMethod.Inheritance }, + }); + } + else { + sampleRate = options.tracesSampleRate; + transaction.setMetadata({ + transactionSampling: { + method: _sentry_types__WEBPACK_IMPORTED_MODULE_1__.TransactionSamplingMethod.Rate, + // cast to number in case it's a boolean + rate: Number(sampleRate), + }, + }); + } + // Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The + // only valid values are booleans or numbers between 0 and 1.) + if (!isValidSampleRate(sampleRate)) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.warn("[Tracing] Discarding transaction because of invalid sample rate."); + transaction.sampled = false; + return transaction; + } + // if the function returned 0 (or false), or if `tracesSampleRate` is 0, it's a sign the transaction should be dropped + if (!sampleRate) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.log("[Tracing] Discarding transaction because " + (typeof options.tracesSampler === 'function' + ? 'tracesSampler returned 0 or false' + : 'a negative sampling decision was inherited or tracesSampleRate is set to 0')); + transaction.sampled = false; + return transaction; + } + // Now we roll the dice. Math.random is inclusive of 0, but not of 1, so strict < is safe here. In case sampleRate is + // a boolean, the < comparison will cause it to be automatically cast to 1 if it's true and 0 if it's false. + transaction.sampled = Math.random() < sampleRate; + // if we're not going to keep it, we're done + if (!transaction.sampled) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.log("[Tracing] Discarding transaction because it's not included in the random sample (sampling rate = " + Number(sampleRate) + ")"); + return transaction; + } + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.log("[Tracing] starting " + transaction.op + " transaction - " + transaction.name); + return transaction; +} +/** + * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1). + */ +function isValidSampleRate(rate) { + // we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (isNaN(rate) || !(typeof rate === 'number' || typeof rate === 'boolean')) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.warn("[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got " + JSON.stringify(rate) + " of type " + JSON.stringify(typeof rate) + "."); + return false; + } + // in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false + if (rate < 0 || rate > 1) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.warn("[Tracing] Given sample rate is invalid. Sample rate must be between 0 and 1. Got " + rate + "."); + return false; + } + return true; +} +/** + * Creates a new transaction and adds a sampling decision if it doesn't yet have one. + * + * The Hub.startTransaction method delegates to this method to do its work, passing the Hub instance in as `this`, as if + * it had been called on the hub directly. Exists as a separate function so that it can be injected into the class as an + * "extension method." + * + * @param this: The Hub starting the transaction + * @param transactionContext: Data used to configure the transaction + * @param CustomSamplingContext: Optional data to be provided to the `tracesSampler` function (if any) + * + * @returns The new transaction + * + * @see {@link Hub.startTransaction} + */ +function _startTransaction(transactionContext, customSamplingContext) { + var _a, _b; + var options = ((_a = this.getClient()) === null || _a === void 0 ? void 0 : _a.getOptions()) || {}; + var transaction = new _transaction__WEBPACK_IMPORTED_MODULE_3__.Transaction(transactionContext, this); + transaction = sample(transaction, options, (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__assign)({ parentSampled: transactionContext.parentSampled, transactionContext: transactionContext }, customSamplingContext)); + if (transaction.sampled) { + transaction.initSpanRecorder((_b = options._experiments) === null || _b === void 0 ? void 0 : _b.maxSpans); + } + return transaction; +} +/** + * Create new idle transaction. + */ +function startIdleTransaction(hub, transactionContext, idleTimeout, onScope, customSamplingContext) { + var _a, _b; + var options = ((_a = hub.getClient()) === null || _a === void 0 ? void 0 : _a.getOptions()) || {}; + var transaction = new _idletransaction__WEBPACK_IMPORTED_MODULE_5__.IdleTransaction(transactionContext, hub, idleTimeout, onScope); + transaction = sample(transaction, options, (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__assign)({ parentSampled: transactionContext.parentSampled, transactionContext: transactionContext }, customSamplingContext)); + if (transaction.sampled) { + transaction.initSpanRecorder((_b = options._experiments) === null || _b === void 0 ? void 0 : _b.maxSpans); + } + return transaction; +} +/** + * @private + */ +function _addTracingExtensions() { + var carrier = (0,_sentry_hub__WEBPACK_IMPORTED_MODULE_6__.getMainCarrier)(); + if (!carrier.__SENTRY__) { + return; + } + carrier.__SENTRY__.extensions = carrier.__SENTRY__.extensions || {}; + if (!carrier.__SENTRY__.extensions.startTransaction) { + carrier.__SENTRY__.extensions.startTransaction = _startTransaction; + } + if (!carrier.__SENTRY__.extensions.traceHeaders) { + carrier.__SENTRY__.extensions.traceHeaders = traceHeaders; + } +} +/** + * @private + */ +function _autoloadDatabaseIntegrations() { + var carrier = (0,_sentry_hub__WEBPACK_IMPORTED_MODULE_6__.getMainCarrier)(); + if (!carrier.__SENTRY__) { + return; + } + var packageToIntegrationMapping = { + mongodb: function () { + var integration = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.dynamicRequire)(module, './integrations/mongo'); + return new integration.Mongo(); + }, + mongoose: function () { + var integration = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.dynamicRequire)(module, './integrations/mongo'); + return new integration.Mongo({ mongoose: true }); + }, + mysql: function () { + var integration = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.dynamicRequire)(module, './integrations/mysql'); + return new integration.Mysql(); + }, + pg: function () { + var integration = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.dynamicRequire)(module, './integrations/postgres'); + return new integration.Postgres(); + }, + }; + var mappedPackages = Object.keys(packageToIntegrationMapping) + .filter(function (moduleName) { return !!(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.loadModule)(moduleName); }) + .map(function (pkg) { + try { + return packageToIntegrationMapping[pkg](); + } + catch (e) { + return undefined; + } + }) + .filter(function (p) { return p; }); + if (mappedPackages.length > 0) { + carrier.__SENTRY__.integrations = (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__spread)((carrier.__SENTRY__.integrations || []), mappedPackages); + } +} +/** + * This patches the global object and injects the Tracing extensions methods + */ +function addExtensionMethods() { + _addTracingExtensions(); + // Detect and automatically load specified integrations. + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.isNodeEnv)()) { + _autoloadDatabaseIntegrations(); + } + // If an error happens globally, we should make sure transaction status is set to error. + (0,_errors__WEBPACK_IMPORTED_MODULE_8__.registerErrorInstrumentation)(); +} +//# sourceMappingURL=hubextensions.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/idletransaction.js": +/*!*************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/idletransaction.js ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DEFAULT_IDLE_TIMEOUT": () => (/* binding */ DEFAULT_IDLE_TIMEOUT), +/* harmony export */ "IdleTransactionSpanRecorder": () => (/* binding */ IdleTransactionSpanRecorder), +/* harmony export */ "IdleTransaction": () => (/* binding */ IdleTransaction) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/time.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _span__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./span */ "./node_modules/@sentry/tracing/esm/span.js"); +/* harmony import */ var _spanstatus__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spanstatus */ "./node_modules/@sentry/tracing/esm/spanstatus.js"); +/* harmony import */ var _transaction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./transaction */ "./node_modules/@sentry/tracing/esm/transaction.js"); + + + + + +var DEFAULT_IDLE_TIMEOUT = 1000; +/** + * @inheritDoc + */ +var IdleTransactionSpanRecorder = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(IdleTransactionSpanRecorder, _super); + function IdleTransactionSpanRecorder(_pushActivity, _popActivity, transactionSpanId, maxlen) { + if (transactionSpanId === void 0) { transactionSpanId = ''; } + var _this = _super.call(this, maxlen) || this; + _this._pushActivity = _pushActivity; + _this._popActivity = _popActivity; + _this.transactionSpanId = transactionSpanId; + return _this; + } + /** + * @inheritDoc + */ + IdleTransactionSpanRecorder.prototype.add = function (span) { + var _this = this; + // We should make sure we do not push and pop activities for + // the transaction that this span recorder belongs to. + if (span.spanId !== this.transactionSpanId) { + // We patch span.finish() to pop an activity after setting an endTimestamp. + span.finish = function (endTimestamp) { + span.endTimestamp = typeof endTimestamp === 'number' ? endTimestamp : (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.timestampWithMs)(); + _this._popActivity(span.spanId); + }; + // We should only push new activities if the span does not have an end timestamp. + if (span.endTimestamp === undefined) { + this._pushActivity(span.spanId); + } + } + _super.prototype.add.call(this, span); + }; + return IdleTransactionSpanRecorder; +}(_span__WEBPACK_IMPORTED_MODULE_2__.SpanRecorder)); + +/** + * An IdleTransaction is a transaction that automatically finishes. It does this by tracking child spans as activities. + * You can have multiple IdleTransactions active, but if the `onScope` option is specified, the idle transaction will + * put itself on the scope on creation. + */ +var IdleTransaction = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(IdleTransaction, _super); + function IdleTransaction(transactionContext, _idleHub, + // The time to wait in ms until the idle transaction will be finished. Default: 1000 + _idleTimeout, + // If an idle transaction should be put itself on and off the scope automatically. + _onScope) { + if (_idleTimeout === void 0) { _idleTimeout = DEFAULT_IDLE_TIMEOUT; } + if (_onScope === void 0) { _onScope = false; } + var _this = _super.call(this, transactionContext, _idleHub) || this; + _this._idleHub = _idleHub; + _this._idleTimeout = _idleTimeout; + _this._onScope = _onScope; + // Activities store a list of active spans + _this.activities = {}; + // Stores reference to the timeout that calls _beat(). + _this._heartbeatTimer = 0; + // Amount of times heartbeat has counted. Will cause transaction to finish after 3 beats. + _this._heartbeatCounter = 0; + // We should not use heartbeat if we finished a transaction + _this._finished = false; + _this._beforeFinishCallbacks = []; + if (_idleHub && _onScope) { + // There should only be one active transaction on the scope + clearActiveTransaction(_idleHub); + // We set the transaction here on the scope so error events pick up the trace + // context and attach it to the error. + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log("Setting idle transaction on scope. Span ID: " + _this.spanId); + _idleHub.configureScope(function (scope) { return scope.setSpan(_this); }); + } + _this._initTimeout = setTimeout(function () { + if (!_this._finished) { + _this.finish(); + } + }, _this._idleTimeout); + return _this; + } + /** {@inheritDoc} */ + IdleTransaction.prototype.finish = function (endTimestamp) { + var e_1, _a; + var _this = this; + if (endTimestamp === void 0) { endTimestamp = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.timestampWithMs)(); } + this._finished = true; + this.activities = {}; + if (this.spanRecorder) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] finishing IdleTransaction', new Date(endTimestamp * 1000).toISOString(), this.op); + try { + for (var _b = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__values)(this._beforeFinishCallbacks), _c = _b.next(); !_c.done; _c = _b.next()) { + var callback = _c.value; + callback(this, endTimestamp); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + this.spanRecorder.spans = this.spanRecorder.spans.filter(function (span) { + // If we are dealing with the transaction itself, we just return it + if (span.spanId === _this.spanId) { + return true; + } + // We cancel all pending spans with status "cancelled" to indicate the idle transaction was finished early + if (!span.endTimestamp) { + span.endTimestamp = endTimestamp; + span.setStatus(_spanstatus__WEBPACK_IMPORTED_MODULE_4__.SpanStatus.Cancelled); + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] cancelling span since transaction ended early', JSON.stringify(span, undefined, 2)); + } + var keepSpan = span.startTimestamp < endTimestamp; + if (!keepSpan) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] discarding Span since it happened after Transaction was finished', JSON.stringify(span, undefined, 2)); + } + return keepSpan; + }); + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] flushing IdleTransaction'); + } + else { + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] No active IdleTransaction'); + } + // this._onScope is true if the transaction was previously on the scope. + if (this._onScope) { + clearActiveTransaction(this._idleHub); + } + return _super.prototype.finish.call(this, endTimestamp); + }; + /** + * Register a callback function that gets excecuted before the transaction finishes. + * Useful for cleanup or if you want to add any additional spans based on current context. + * + * This is exposed because users have no other way of running something before an idle transaction + * finishes. + */ + IdleTransaction.prototype.registerBeforeFinishCallback = function (callback) { + this._beforeFinishCallbacks.push(callback); + }; + /** + * @inheritDoc + */ + IdleTransaction.prototype.initSpanRecorder = function (maxlen) { + var _this = this; + if (!this.spanRecorder) { + var pushActivity = function (id) { + if (_this._finished) { + return; + } + _this._pushActivity(id); + }; + var popActivity = function (id) { + if (_this._finished) { + return; + } + _this._popActivity(id); + }; + this.spanRecorder = new IdleTransactionSpanRecorder(pushActivity, popActivity, this.spanId, maxlen); + // Start heartbeat so that transactions do not run forever. + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('Starting heartbeat'); + this._pingHeartbeat(); + } + this.spanRecorder.add(this); + }; + /** + * Start tracking a specific activity. + * @param spanId The span id that represents the activity + */ + IdleTransaction.prototype._pushActivity = function (spanId) { + if (this._initTimeout) { + clearTimeout(this._initTimeout); + this._initTimeout = undefined; + } + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log("[Tracing] pushActivity: " + spanId); + this.activities[spanId] = true; + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] new activities count', Object.keys(this.activities).length); + }; + /** + * Remove an activity from usage + * @param spanId The span id that represents the activity + */ + IdleTransaction.prototype._popActivity = function (spanId) { + var _this = this; + if (this.activities[spanId]) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log("[Tracing] popActivity " + spanId); + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete this.activities[spanId]; + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] new activities count', Object.keys(this.activities).length); + } + if (Object.keys(this.activities).length === 0) { + var timeout = this._idleTimeout; + // We need to add the timeout here to have the real endtimestamp of the transaction + // Remember timestampWithMs is in seconds, timeout is in ms + var end_1 = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.timestampWithMs)() + timeout / 1000; + setTimeout(function () { + if (!_this._finished) { + _this.finish(end_1); + } + }, timeout); + } + }; + /** + * Checks when entries of this.activities are not changing for 3 beats. + * If this occurs we finish the transaction. + */ + IdleTransaction.prototype._beat = function () { + clearTimeout(this._heartbeatTimer); + // We should not be running heartbeat if the idle transaction is finished. + if (this._finished) { + return; + } + var keys = Object.keys(this.activities); + var heartbeatString = keys.length ? keys.reduce(function (prev, current) { return prev + current; }) : ''; + if (heartbeatString === this._prevHeartbeatString) { + this._heartbeatCounter += 1; + } + else { + this._heartbeatCounter = 1; + } + this._prevHeartbeatString = heartbeatString; + if (this._heartbeatCounter >= 3) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log("[Tracing] Transaction finished because of no change for 3 heart beats"); + this.setStatus(_spanstatus__WEBPACK_IMPORTED_MODULE_4__.SpanStatus.DeadlineExceeded); + this.setTag('heartbeat', 'failed'); + this.finish(); + } + else { + this._pingHeartbeat(); + } + }; + /** + * Pings the heartbeat + */ + IdleTransaction.prototype._pingHeartbeat = function () { + var _this = this; + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log("pinging Heartbeat -> current counter: " + this._heartbeatCounter); + this._heartbeatTimer = setTimeout(function () { + _this._beat(); + }, 5000); + }; + return IdleTransaction; +}(_transaction__WEBPACK_IMPORTED_MODULE_5__.Transaction)); + +/** + * Reset active transaction on scope + */ +function clearActiveTransaction(hub) { + if (hub) { + var scope = hub.getScope(); + if (scope) { + var transaction = scope.getTransaction(); + if (transaction) { + scope.setSpan(undefined); + } + } + } +} +//# sourceMappingURL=idletransaction.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/index.js": +/*!***************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/index.js ***! + \***************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Integrations": () => (/* binding */ Integrations), +/* harmony export */ "Span": () => (/* reexport safe */ _span__WEBPACK_IMPORTED_MODULE_3__.Span), +/* harmony export */ "Transaction": () => (/* reexport safe */ _transaction__WEBPACK_IMPORTED_MODULE_4__.Transaction), +/* harmony export */ "registerRequestInstrumentation": () => (/* reexport safe */ _browser__WEBPACK_IMPORTED_MODULE_5__.instrumentOutgoingRequests), +/* harmony export */ "defaultRequestInstrumentationOptions": () => (/* reexport safe */ _browser__WEBPACK_IMPORTED_MODULE_5__.defaultRequestInstrumentationOptions), +/* harmony export */ "SpanStatus": () => (/* reexport safe */ _spanstatus__WEBPACK_IMPORTED_MODULE_6__.SpanStatus), +/* harmony export */ "IdleTransaction": () => (/* reexport safe */ _idletransaction__WEBPACK_IMPORTED_MODULE_7__.IdleTransaction), +/* harmony export */ "startIdleTransaction": () => (/* reexport safe */ _hubextensions__WEBPACK_IMPORTED_MODULE_8__.startIdleTransaction), +/* harmony export */ "addExtensionMethods": () => (/* reexport safe */ _hubextensions__WEBPACK_IMPORTED_MODULE_8__.addExtensionMethods), +/* harmony export */ "extractTraceparentData": () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_9__.extractTraceparentData), +/* harmony export */ "getActiveTransaction": () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_9__.getActiveTransaction), +/* harmony export */ "hasTracingEnabled": () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_9__.hasTracingEnabled), +/* harmony export */ "stripUrlQueryAndFragment": () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_10__.stripUrlQueryAndFragment), +/* harmony export */ "TRACEPARENT_REGEXP": () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_9__.TRACEPARENT_REGEXP) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _browser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./browser */ "./node_modules/@sentry/tracing/esm/browser/browsertracing.js"); +/* harmony import */ var _hubextensions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./hubextensions */ "./node_modules/@sentry/tracing/esm/hubextensions.js"); +/* harmony import */ var _integrations__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./integrations */ "./node_modules/@sentry/tracing/esm/integrations/index.js"); +/* harmony import */ var _span__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./span */ "./node_modules/@sentry/tracing/esm/span.js"); +/* harmony import */ var _transaction__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./transaction */ "./node_modules/@sentry/tracing/esm/transaction.js"); +/* harmony import */ var _browser__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./browser */ "./node_modules/@sentry/tracing/esm/browser/request.js"); +/* harmony import */ var _spanstatus__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spanstatus */ "./node_modules/@sentry/tracing/esm/spanstatus.js"); +/* harmony import */ var _idletransaction__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./idletransaction */ "./node_modules/@sentry/tracing/esm/idletransaction.js"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utils */ "./node_modules/@sentry/tracing/esm/utils.js"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./utils */ "./node_modules/@sentry/utils/esm/misc.js"); + + + + +var Integrations = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, _integrations__WEBPACK_IMPORTED_MODULE_1__), { BrowserTracing: _browser__WEBPACK_IMPORTED_MODULE_2__.BrowserTracing }); + + + + + + + +// We are patching the global object with our hub extension methods +(0,_hubextensions__WEBPACK_IMPORTED_MODULE_8__.addExtensionMethods)(); + + +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/integrations/express.js": +/*!******************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/integrations/express.js ***! + \******************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Express": () => (/* binding */ Express) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); + + +/** + * Express integration + * + * Provides an request and error handler for Express framework as well as tracing capabilities + */ +var Express = /** @class */ (function () { + /** + * @inheritDoc + */ + function Express(options) { + if (options === void 0) { options = {}; } + /** + * @inheritDoc + */ + this.name = Express.id; + this._router = options.router || options.app; + this._methods = (Array.isArray(options.methods) ? options.methods : []).concat('use'); + } + /** + * @inheritDoc + */ + Express.prototype.setupOnce = function () { + if (!this._router) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.error('ExpressIntegration is missing an Express instance'); + return; + } + instrumentMiddlewares(this._router, this._methods); + }; + /** + * @inheritDoc + */ + Express.id = 'Express'; + return Express; +}()); + +/** + * Wraps original middleware function in a tracing call, which stores the info about the call as a span, + * and finishes it once the middleware is done invoking. + * + * Express middlewares have 3 various forms, thus we have to take care of all of them: + * // sync + * app.use(function (req, res) { ... }) + * // async + * app.use(function (req, res, next) { ... }) + * // error handler + * app.use(function (err, req, res, next) { ... }) + * + * They all internally delegate to the `router[method]` of the given application instance. + */ +// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any +function wrap(fn, method) { + var arity = fn.length; + switch (arity) { + case 2: { + return function (req, res) { + var transaction = res.__sentry_transaction; + if (transaction) { + var span_1 = transaction.startChild({ + description: fn.name, + op: "middleware." + method, + }); + res.once('finish', function () { + span_1.finish(); + }); + } + return fn.call(this, req, res); + }; + } + case 3: { + return function (req, res, next) { + var _a; + var transaction = res.__sentry_transaction; + var span = (_a = transaction) === null || _a === void 0 ? void 0 : _a.startChild({ + description: fn.name, + op: "middleware." + method, + }); + fn.call(this, req, res, function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var _a; + (_a = span) === null || _a === void 0 ? void 0 : _a.finish(); + next.call.apply(next, (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__spread)([this], args)); + }); + }; + } + case 4: { + return function (err, req, res, next) { + var _a; + var transaction = res.__sentry_transaction; + var span = (_a = transaction) === null || _a === void 0 ? void 0 : _a.startChild({ + description: fn.name, + op: "middleware." + method, + }); + fn.call(this, err, req, res, function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var _a; + (_a = span) === null || _a === void 0 ? void 0 : _a.finish(); + next.call.apply(next, (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__spread)([this], args)); + }); + }; + } + default: { + throw new Error("Express middleware takes 2-4 arguments. Got: " + arity); + } + } +} +/** + * Takes all the function arguments passed to the original `app` or `router` method, eg. `app.use` or `router.use` + * and wraps every function, as well as array of functions with a call to our `wrap` method. + * We have to take care of the arrays as well as iterate over all of the arguments, + * as `app.use` can accept middlewares in few various forms. + * + * app.use([], ) + * app.use([], , ...) + * app.use([], ...[]) + */ +function wrapMiddlewareArgs(args, method) { + return args.map(function (arg) { + if (typeof arg === 'function') { + return wrap(arg, method); + } + if (Array.isArray(arg)) { + return arg.map(function (a) { + if (typeof a === 'function') { + return wrap(a, method); + } + return a; + }); + } + return arg; + }); +} +/** + * Patches original router to utilize our tracing functionality + */ +function patchMiddleware(router, method) { + var originalCallback = router[method]; + router[method] = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return originalCallback.call.apply(originalCallback, (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__spread)([this], wrapMiddlewareArgs(args, method))); + }; + return router; +} +/** + * Patches original router methods + */ +function instrumentMiddlewares(router, methods) { + if (methods === void 0) { methods = []; } + methods.forEach(function (method) { return patchMiddleware(router, method); }); +} +//# sourceMappingURL=express.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/integrations/index.js": +/*!****************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/integrations/index.js ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Express": () => (/* reexport safe */ _express__WEBPACK_IMPORTED_MODULE_0__.Express), +/* harmony export */ "Postgres": () => (/* reexport safe */ _postgres__WEBPACK_IMPORTED_MODULE_1__.Postgres), +/* harmony export */ "Mysql": () => (/* reexport safe */ _mysql__WEBPACK_IMPORTED_MODULE_2__.Mysql), +/* harmony export */ "Mongo": () => (/* reexport safe */ _mongo__WEBPACK_IMPORTED_MODULE_3__.Mongo) +/* harmony export */ }); +/* harmony import */ var _express__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./express */ "./node_modules/@sentry/tracing/esm/integrations/express.js"); +/* harmony import */ var _postgres__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postgres */ "./node_modules/@sentry/tracing/esm/integrations/postgres.js"); +/* harmony import */ var _mysql__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./mysql */ "./node_modules/@sentry/tracing/esm/integrations/mysql.js"); +/* harmony import */ var _mongo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mongo */ "./node_modules/@sentry/tracing/esm/integrations/mongo.js"); + + + + +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/integrations/mongo.js": +/*!****************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/integrations/mongo.js ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Mongo": () => (/* binding */ Mongo) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/node.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/object.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/is.js"); + + +var OPERATIONS = [ + 'aggregate', + 'bulkWrite', + 'countDocuments', + 'createIndex', + 'createIndexes', + 'deleteMany', + 'deleteOne', + 'distinct', + 'drop', + 'dropIndex', + 'dropIndexes', + 'estimatedDocumentCount', + 'find', + 'findOne', + 'findOneAndDelete', + 'findOneAndReplace', + 'findOneAndUpdate', + 'indexes', + 'indexExists', + 'indexInformation', + 'initializeOrderedBulkOp', + 'insertMany', + 'insertOne', + 'isCapped', + 'mapReduce', + 'options', + 'parallelCollectionScan', + 'rename', + 'replaceOne', + 'stats', + 'updateMany', + 'updateOne', +]; +// All of the operations above take `options` and `callback` as their final parameters, but some of them +// take additional parameters as well. For those operations, this is a map of +// { : [] }, as a way to know what to call the operation's +// positional arguments when we add them to the span's `data` object later +var OPERATION_SIGNATURES = { + // aggregate intentionally not included because `pipeline` arguments are too complex to serialize well + // see https://github.com/getsentry/sentry-javascript/pull/3102 + bulkWrite: ['operations'], + countDocuments: ['query'], + createIndex: ['fieldOrSpec'], + createIndexes: ['indexSpecs'], + deleteMany: ['filter'], + deleteOne: ['filter'], + distinct: ['key', 'query'], + dropIndex: ['indexName'], + find: ['query'], + findOne: ['query'], + findOneAndDelete: ['filter'], + findOneAndReplace: ['filter', 'replacement'], + findOneAndUpdate: ['filter', 'update'], + indexExists: ['indexes'], + insertMany: ['docs'], + insertOne: ['doc'], + mapReduce: ['map', 'reduce'], + rename: ['newName'], + replaceOne: ['filter', 'doc'], + updateMany: ['filter', 'update'], + updateOne: ['filter', 'update'], +}; +/** Tracing integration for mongo package */ +var Mongo = /** @class */ (function () { + /** + * @inheritDoc + */ + function Mongo(options) { + if (options === void 0) { options = {}; } + /** + * @inheritDoc + */ + this.name = Mongo.id; + this._operations = Array.isArray(options.operations) + ? options.operations + : OPERATIONS; + this._describeOperations = 'describeOperations' in options ? options.describeOperations : true; + this._useMongoose = !!options.useMongoose; + } + /** + * @inheritDoc + */ + Mongo.prototype.setupOnce = function (_, getCurrentHub) { + var moduleName = this._useMongoose ? 'mongoose' : 'mongodb'; + var pkg = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.loadModule)(moduleName); + if (!pkg) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error("Mongo Integration was unable to require `" + moduleName + "` package."); + return; + } + this._instrumentOperations(pkg.Collection, this._operations, getCurrentHub); + }; + /** + * Patches original collection methods + */ + Mongo.prototype._instrumentOperations = function (collection, operations, getCurrentHub) { + var _this = this; + operations.forEach(function (operation) { return _this._patchOperation(collection, operation, getCurrentHub); }); + }; + /** + * Patches original collection to utilize our tracing functionality + */ + Mongo.prototype._patchOperation = function (collection, operation, getCurrentHub) { + if (!(operation in collection.prototype)) + return; + var getSpanContext = this._getSpanContextFromOperationArguments.bind(this); + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.fill)(collection.prototype, operation, function (orig) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var _a, _b, _c, _d; + var lastArg = args[args.length - 1]; + var scope = getCurrentHub().getScope(); + var parentSpan = (_a = scope) === null || _a === void 0 ? void 0 : _a.getSpan(); + // Check if the operation was passed a callback. (mapReduce requires a different check, as + // its (non-callback) arguments can also be functions.) + if (typeof lastArg !== 'function' || (operation === 'mapReduce' && args.length === 2)) { + var span_1 = (_b = parentSpan) === null || _b === void 0 ? void 0 : _b.startChild(getSpanContext(this, operation, args)); + var maybePromise = orig.call.apply(orig, (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__spread)([this], args)); + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.isThenable)(maybePromise)) { + return maybePromise.then(function (res) { + var _a; + (_a = span_1) === null || _a === void 0 ? void 0 : _a.finish(); + return res; + }); + } + else { + (_c = span_1) === null || _c === void 0 ? void 0 : _c.finish(); + return maybePromise; + } + } + var span = (_d = parentSpan) === null || _d === void 0 ? void 0 : _d.startChild(getSpanContext(this, operation, args.slice(0, -1))); + return orig.call.apply(orig, (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__spread)([this], args.slice(0, -1), [function (err, result) { + var _a; + (_a = span) === null || _a === void 0 ? void 0 : _a.finish(); + lastArg(err, result); + }])); + }; + }); + }; + /** + * Form a SpanContext based on the user input to a given operation. + */ + Mongo.prototype._getSpanContextFromOperationArguments = function (collection, operation, args) { + var data = { + collectionName: collection.collectionName, + dbName: collection.dbName, + namespace: collection.namespace, + }; + var spanContext = { + op: "db", + description: operation, + data: data, + }; + // If the operation takes no arguments besides `options` and `callback`, or if argument + // collection is disabled for this operation, just return early. + var signature = OPERATION_SIGNATURES[operation]; + var shouldDescribe = Array.isArray(this._describeOperations) + ? this._describeOperations.includes(operation) + : this._describeOperations; + if (!signature || !shouldDescribe) { + return spanContext; + } + try { + // Special case for `mapReduce`, as the only one accepting functions as arguments. + if (operation === 'mapReduce') { + var _a = (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__read)(args, 2), map = _a[0], reduce = _a[1]; + data[signature[0]] = typeof map === 'string' ? map : map.name || ''; + data[signature[1]] = typeof reduce === 'string' ? reduce : reduce.name || ''; + } + else { + for (var i = 0; i < signature.length; i++) { + data[signature[i]] = JSON.stringify(args[i]); + } + } + } + catch (_oO) { + // no-empty + } + return spanContext; + }; + /** + * @inheritDoc + */ + Mongo.id = 'Mongo'; + return Mongo; +}()); + +//# sourceMappingURL=mongo.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/integrations/mysql.js": +/*!****************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/integrations/mysql.js ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Mysql": () => (/* binding */ Mysql) +/* harmony export */ }); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/node.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/object.js"); + +/** Tracing integration for node-mysql package */ +var Mysql = /** @class */ (function () { + function Mysql() { + /** + * @inheritDoc + */ + this.name = Mysql.id; + } + /** + * @inheritDoc + */ + Mysql.prototype.setupOnce = function (_, getCurrentHub) { + var pkg = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.loadModule)('mysql/lib/Connection.js'); + if (!pkg) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error('Mysql Integration was unable to require `mysql` package.'); + return; + } + // The original function will have one of these signatures: + // function (callback) => void + // function (options, callback) => void + // function (options, values, callback) => void + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.fill)(pkg, 'createQuery', function (orig) { + return function (options, values, callback) { + var _a, _b; + var scope = getCurrentHub().getScope(); + var parentSpan = (_a = scope) === null || _a === void 0 ? void 0 : _a.getSpan(); + var span = (_b = parentSpan) === null || _b === void 0 ? void 0 : _b.startChild({ + description: typeof options === 'string' ? options : options.sql, + op: "db", + }); + if (typeof callback === 'function') { + return orig.call(this, options, values, function (err, result, fields) { + var _a; + (_a = span) === null || _a === void 0 ? void 0 : _a.finish(); + callback(err, result, fields); + }); + } + if (typeof values === 'function') { + return orig.call(this, options, function (err, result, fields) { + var _a; + (_a = span) === null || _a === void 0 ? void 0 : _a.finish(); + values(err, result, fields); + }); + } + return orig.call(this, options, values, callback); + }; + }); + }; + /** + * @inheritDoc + */ + Mysql.id = 'Mysql'; + return Mysql; +}()); + +//# sourceMappingURL=mysql.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/integrations/postgres.js": +/*!*******************************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/integrations/postgres.js ***! + \*******************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Postgres": () => (/* binding */ Postgres) +/* harmony export */ }); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/node.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/object.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/is.js"); + +/** Tracing integration for node-postgres package */ +var Postgres = /** @class */ (function () { + function Postgres() { + /** + * @inheritDoc + */ + this.name = Postgres.id; + } + /** + * @inheritDoc + */ + Postgres.prototype.setupOnce = function (_, getCurrentHub) { + var pkg = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.loadModule)('pg'); + if (!pkg) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error('Postgres Integration was unable to require `pg` package.'); + return; + } + /** + * function (query, callback) => void + * function (query, params, callback) => void + * function (query) => Promise + * function (query, params) => Promise + * function (pg.Cursor) => pg.Cursor + */ + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.fill)(pkg.Client.prototype, 'query', function (orig) { + return function (config, values, callback) { + var _a, _b, _c; + var scope = getCurrentHub().getScope(); + var parentSpan = (_a = scope) === null || _a === void 0 ? void 0 : _a.getSpan(); + var span = (_b = parentSpan) === null || _b === void 0 ? void 0 : _b.startChild({ + description: typeof config === 'string' ? config : config.text, + op: "db", + }); + if (typeof callback === 'function') { + return orig.call(this, config, values, function (err, result) { + var _a; + (_a = span) === null || _a === void 0 ? void 0 : _a.finish(); + callback(err, result); + }); + } + if (typeof values === 'function') { + return orig.call(this, config, function (err, result) { + var _a; + (_a = span) === null || _a === void 0 ? void 0 : _a.finish(); + values(err, result); + }); + } + var rv = typeof values !== 'undefined' ? orig.call(this, config, values) : orig.call(this, config); + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.isThenable)(rv)) { + return rv.then(function (res) { + var _a; + (_a = span) === null || _a === void 0 ? void 0 : _a.finish(); + return res; + }); + } + (_c = span) === null || _c === void 0 ? void 0 : _c.finish(); + return rv; + }; + }); + }; + /** + * @inheritDoc + */ + Postgres.id = 'Postgres'; + return Postgres; +}()); + +//# sourceMappingURL=postgres.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/span.js": +/*!**************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/span.js ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SpanRecorder": () => (/* binding */ SpanRecorder), +/* harmony export */ "Span": () => (/* binding */ Span) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/time.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/object.js"); +/* harmony import */ var _spanstatus__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./spanstatus */ "./node_modules/@sentry/tracing/esm/spanstatus.js"); + + + +/** + * Keeps track of finished spans for a given transaction + * @internal + * @hideconstructor + * @hidden + */ +var SpanRecorder = /** @class */ (function () { + function SpanRecorder(maxlen) { + if (maxlen === void 0) { maxlen = 1000; } + this.spans = []; + this._maxlen = maxlen; + } + /** + * This is just so that we don't run out of memory while recording a lot + * of spans. At some point we just stop and flush out the start of the + * trace tree (i.e.the first n spans with the smallest + * start_timestamp). + */ + SpanRecorder.prototype.add = function (span) { + if (this.spans.length > this._maxlen) { + span.spanRecorder = undefined; + } + else { + this.spans.push(span); + } + }; + return SpanRecorder; +}()); + +/** + * Span contains all data about a span + */ +var Span = /** @class */ (function () { + /** + * You should never call the constructor manually, always use `Sentry.startTransaction()` + * or call `startChild()` on an existing span. + * @internal + * @hideconstructor + * @hidden + */ + function Span(spanContext) { + /** + * @inheritDoc + */ + this.traceId = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.uuid4)(); + /** + * @inheritDoc + */ + this.spanId = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.uuid4)().substring(16); + /** + * Timestamp in seconds when the span was created. + */ + this.startTimestamp = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.timestampWithMs)(); + /** + * @inheritDoc + */ + this.tags = {}; + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + this.data = {}; + if (!spanContext) { + return this; + } + if (spanContext.traceId) { + this.traceId = spanContext.traceId; + } + if (spanContext.spanId) { + this.spanId = spanContext.spanId; + } + if (spanContext.parentSpanId) { + this.parentSpanId = spanContext.parentSpanId; + } + // We want to include booleans as well here + if ('sampled' in spanContext) { + this.sampled = spanContext.sampled; + } + if (spanContext.op) { + this.op = spanContext.op; + } + if (spanContext.description) { + this.description = spanContext.description; + } + if (spanContext.data) { + this.data = spanContext.data; + } + if (spanContext.tags) { + this.tags = spanContext.tags; + } + if (spanContext.status) { + this.status = spanContext.status; + } + if (spanContext.startTimestamp) { + this.startTimestamp = spanContext.startTimestamp; + } + if (spanContext.endTimestamp) { + this.endTimestamp = spanContext.endTimestamp; + } + } + /** + * @inheritDoc + * @deprecated + */ + Span.prototype.child = function (spanContext) { + return this.startChild(spanContext); + }; + /** + * @inheritDoc + */ + Span.prototype.startChild = function (spanContext) { + var childSpan = new Span((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, spanContext), { parentSpanId: this.spanId, sampled: this.sampled, traceId: this.traceId })); + childSpan.spanRecorder = this.spanRecorder; + if (childSpan.spanRecorder) { + childSpan.spanRecorder.add(childSpan); + } + childSpan.transaction = this.transaction; + return childSpan; + }; + /** + * @inheritDoc + */ + Span.prototype.setTag = function (key, value) { + var _a; + this.tags = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, this.tags), (_a = {}, _a[key] = value, _a)); + return this; + }; + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + Span.prototype.setData = function (key, value) { + var _a; + this.data = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, this.data), (_a = {}, _a[key] = value, _a)); + return this; + }; + /** + * @inheritDoc + */ + Span.prototype.setStatus = function (value) { + this.status = value; + return this; + }; + /** + * @inheritDoc + */ + Span.prototype.setHttpStatus = function (httpStatus) { + this.setTag('http.status_code', String(httpStatus)); + var spanStatus = _spanstatus__WEBPACK_IMPORTED_MODULE_3__.SpanStatus.fromHttpCode(httpStatus); + if (spanStatus !== _spanstatus__WEBPACK_IMPORTED_MODULE_3__.SpanStatus.UnknownError) { + this.setStatus(spanStatus); + } + return this; + }; + /** + * @inheritDoc + */ + Span.prototype.isSuccess = function () { + return this.status === _spanstatus__WEBPACK_IMPORTED_MODULE_3__.SpanStatus.Ok; + }; + /** + * @inheritDoc + */ + Span.prototype.finish = function (endTimestamp) { + this.endTimestamp = typeof endTimestamp === 'number' ? endTimestamp : (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.timestampWithMs)(); + }; + /** + * @inheritDoc + */ + Span.prototype.toTraceparent = function () { + var sampledString = ''; + if (this.sampled !== undefined) { + sampledString = this.sampled ? '-1' : '-0'; + } + return this.traceId + "-" + this.spanId + sampledString; + }; + /** + * @inheritDoc + */ + Span.prototype.toContext = function () { + return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.dropUndefinedKeys)({ + data: this.data, + description: this.description, + endTimestamp: this.endTimestamp, + op: this.op, + parentSpanId: this.parentSpanId, + sampled: this.sampled, + spanId: this.spanId, + startTimestamp: this.startTimestamp, + status: this.status, + tags: this.tags, + traceId: this.traceId, + }); + }; + /** + * @inheritDoc + */ + Span.prototype.updateWithContext = function (spanContext) { + var _a, _b, _c, _d, _e; + this.data = (_a = spanContext.data, (_a !== null && _a !== void 0 ? _a : {})); + this.description = spanContext.description; + this.endTimestamp = spanContext.endTimestamp; + this.op = spanContext.op; + this.parentSpanId = spanContext.parentSpanId; + this.sampled = spanContext.sampled; + this.spanId = (_b = spanContext.spanId, (_b !== null && _b !== void 0 ? _b : this.spanId)); + this.startTimestamp = (_c = spanContext.startTimestamp, (_c !== null && _c !== void 0 ? _c : this.startTimestamp)); + this.status = spanContext.status; + this.tags = (_d = spanContext.tags, (_d !== null && _d !== void 0 ? _d : {})); + this.traceId = (_e = spanContext.traceId, (_e !== null && _e !== void 0 ? _e : this.traceId)); + return this; + }; + /** + * @inheritDoc + */ + Span.prototype.getTraceContext = function () { + return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.dropUndefinedKeys)({ + data: Object.keys(this.data).length > 0 ? this.data : undefined, + description: this.description, + op: this.op, + parent_span_id: this.parentSpanId, + span_id: this.spanId, + status: this.status, + tags: Object.keys(this.tags).length > 0 ? this.tags : undefined, + trace_id: this.traceId, + }); + }; + /** + * @inheritDoc + */ + Span.prototype.toJSON = function () { + return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.dropUndefinedKeys)({ + data: Object.keys(this.data).length > 0 ? this.data : undefined, + description: this.description, + op: this.op, + parent_span_id: this.parentSpanId, + span_id: this.spanId, + start_timestamp: this.startTimestamp, + status: this.status, + tags: Object.keys(this.tags).length > 0 ? this.tags : undefined, + timestamp: this.endTimestamp, + trace_id: this.traceId, + }); + }; + return Span; +}()); + +//# sourceMappingURL=span.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/spanstatus.js": +/*!********************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/spanstatus.js ***! + \********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SpanStatus": () => (/* binding */ SpanStatus) +/* harmony export */ }); +/** The status of an Span. */ +// eslint-disable-next-line import/export +var SpanStatus; +(function (SpanStatus) { + /** The operation completed successfully. */ + SpanStatus["Ok"] = "ok"; + /** Deadline expired before operation could complete. */ + SpanStatus["DeadlineExceeded"] = "deadline_exceeded"; + /** 401 Unauthorized (actually does mean unauthenticated according to RFC 7235) */ + SpanStatus["Unauthenticated"] = "unauthenticated"; + /** 403 Forbidden */ + SpanStatus["PermissionDenied"] = "permission_denied"; + /** 404 Not Found. Some requested entity (file or directory) was not found. */ + SpanStatus["NotFound"] = "not_found"; + /** 429 Too Many Requests */ + SpanStatus["ResourceExhausted"] = "resource_exhausted"; + /** Client specified an invalid argument. 4xx. */ + SpanStatus["InvalidArgument"] = "invalid_argument"; + /** 501 Not Implemented */ + SpanStatus["Unimplemented"] = "unimplemented"; + /** 503 Service Unavailable */ + SpanStatus["Unavailable"] = "unavailable"; + /** Other/generic 5xx. */ + SpanStatus["InternalError"] = "internal_error"; + /** Unknown. Any non-standard HTTP status code. */ + SpanStatus["UnknownError"] = "unknown_error"; + /** The operation was cancelled (typically by the user). */ + SpanStatus["Cancelled"] = "cancelled"; + /** Already exists (409) */ + SpanStatus["AlreadyExists"] = "already_exists"; + /** Operation was rejected because the system is not in a state required for the operation's */ + SpanStatus["FailedPrecondition"] = "failed_precondition"; + /** The operation was aborted, typically due to a concurrency issue. */ + SpanStatus["Aborted"] = "aborted"; + /** Operation was attempted past the valid range. */ + SpanStatus["OutOfRange"] = "out_of_range"; + /** Unrecoverable data loss or corruption */ + SpanStatus["DataLoss"] = "data_loss"; +})(SpanStatus || (SpanStatus = {})); +// eslint-disable-next-line @typescript-eslint/no-namespace, import/export +(function (SpanStatus) { + /** + * Converts a HTTP status code into a {@link SpanStatus}. + * + * @param httpStatus The HTTP response status code. + * @returns The span status or {@link SpanStatus.UnknownError}. + */ + function fromHttpCode(httpStatus) { + if (httpStatus < 400) { + return SpanStatus.Ok; + } + if (httpStatus >= 400 && httpStatus < 500) { + switch (httpStatus) { + case 401: + return SpanStatus.Unauthenticated; + case 403: + return SpanStatus.PermissionDenied; + case 404: + return SpanStatus.NotFound; + case 409: + return SpanStatus.AlreadyExists; + case 413: + return SpanStatus.FailedPrecondition; + case 429: + return SpanStatus.ResourceExhausted; + default: + return SpanStatus.InvalidArgument; + } + } + if (httpStatus >= 500 && httpStatus < 600) { + switch (httpStatus) { + case 501: + return SpanStatus.Unimplemented; + case 503: + return SpanStatus.Unavailable; + case 504: + return SpanStatus.DeadlineExceeded; + default: + return SpanStatus.InternalError; + } + } + return SpanStatus.UnknownError; + } + SpanStatus.fromHttpCode = fromHttpCode; +})(SpanStatus || (SpanStatus = {})); +//# sourceMappingURL=spanstatus.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/transaction.js": +/*!*********************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/transaction.js ***! + \*********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Transaction": () => (/* binding */ Transaction) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _sentry_hub__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/hub */ "./node_modules/@sentry/hub/esm/hub.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/is.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/object.js"); +/* harmony import */ var _span__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./span */ "./node_modules/@sentry/tracing/esm/span.js"); + + + + +/** JSDoc */ +var Transaction = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(Transaction, _super); + /** + * This constructor should never be called manually. Those instrumenting tracing should use + * `Sentry.startTransaction()`, and internal methods should use `hub.startTransaction()`. + * @internal + * @hideconstructor + * @hidden + */ + function Transaction(transactionContext, hub) { + var _this = _super.call(this, transactionContext) || this; + _this._measurements = {}; + /** + * The reference to the current hub. + */ + _this._hub = (0,_sentry_hub__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)(); + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.isInstanceOf)(hub, _sentry_hub__WEBPACK_IMPORTED_MODULE_1__.Hub)) { + _this._hub = hub; + } + _this.name = transactionContext.name || ''; + _this.metadata = transactionContext.metadata || {}; + _this._trimEnd = transactionContext.trimEnd; + // this is because transactions are also spans, and spans have a transaction pointer + _this.transaction = _this; + return _this; + } + /** + * JSDoc + */ + Transaction.prototype.setName = function (name) { + this.name = name; + }; + /** + * Attaches SpanRecorder to the span itself + * @param maxlen maximum number of spans that can be recorded + */ + Transaction.prototype.initSpanRecorder = function (maxlen) { + if (maxlen === void 0) { maxlen = 1000; } + if (!this.spanRecorder) { + this.spanRecorder = new _span__WEBPACK_IMPORTED_MODULE_3__.SpanRecorder(maxlen); + } + this.spanRecorder.add(this); + }; + /** + * Set observed measurements for this transaction. + * @hidden + */ + Transaction.prototype.setMeasurements = function (measurements) { + this._measurements = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, measurements); + }; + /** + * Set metadata for this transaction. + * @hidden + */ + Transaction.prototype.setMetadata = function (newMetadata) { + this.metadata = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this.metadata), newMetadata); + }; + /** + * @inheritDoc + */ + Transaction.prototype.finish = function (endTimestamp) { + var _this = this; + // This transaction is already finished, so we should not flush it again. + if (this.endTimestamp !== undefined) { + return undefined; + } + if (!this.name) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_4__.logger.warn('Transaction has no name, falling back to ``.'); + this.name = ''; + } + // just sets the end timestamp + _super.prototype.finish.call(this, endTimestamp); + if (this.sampled !== true) { + // At this point if `sampled !== true` we want to discard the transaction. + _sentry_utils__WEBPACK_IMPORTED_MODULE_4__.logger.log('[Tracing] Discarding transaction because its trace was not chosen to be sampled.'); + return undefined; + } + var finishedSpans = this.spanRecorder ? this.spanRecorder.spans.filter(function (s) { return s !== _this && s.endTimestamp; }) : []; + if (this._trimEnd && finishedSpans.length > 0) { + this.endTimestamp = finishedSpans.reduce(function (prev, current) { + if (prev.endTimestamp && current.endTimestamp) { + return prev.endTimestamp > current.endTimestamp ? prev : current; + } + return prev; + }).endTimestamp; + } + var transaction = { + contexts: { + trace: this.getTraceContext(), + }, + spans: finishedSpans, + start_timestamp: this.startTimestamp, + tags: this.tags, + timestamp: this.endTimestamp, + transaction: this.name, + type: 'transaction', + debug_meta: this.metadata, + }; + var hasMeasurements = Object.keys(this._measurements).length > 0; + if (hasMeasurements) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_4__.logger.log('[Measurements] Adding measurements to transaction', JSON.stringify(this._measurements, undefined, 2)); + transaction.measurements = this._measurements; + } + _sentry_utils__WEBPACK_IMPORTED_MODULE_4__.logger.log("[Tracing] Finishing " + this.op + " transaction: " + this.name + "."); + return this._hub.captureEvent(transaction); + }; + /** + * @inheritDoc + */ + Transaction.prototype.toContext = function () { + var spanContext = _super.prototype.toContext.call(this); + return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.dropUndefinedKeys)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, spanContext), { name: this.name, trimEnd: this._trimEnd })); + }; + /** + * @inheritDoc + */ + Transaction.prototype.updateWithContext = function (transactionContext) { + var _a; + _super.prototype.updateWithContext.call(this, transactionContext); + this.name = (_a = transactionContext.name, (_a !== null && _a !== void 0 ? _a : '')); + this._trimEnd = transactionContext.trimEnd; + return this; + }; + return Transaction; +}(_span__WEBPACK_IMPORTED_MODULE_3__.Span)); + +//# sourceMappingURL=transaction.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/tracing/esm/utils.js": +/*!***************************************************!*\ + !*** ./node_modules/@sentry/tracing/esm/utils.js ***! + \***************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "TRACEPARENT_REGEXP": () => (/* binding */ TRACEPARENT_REGEXP), +/* harmony export */ "hasTracingEnabled": () => (/* binding */ hasTracingEnabled), +/* harmony export */ "extractTraceparentData": () => (/* binding */ extractTraceparentData), +/* harmony export */ "getActiveTransaction": () => (/* binding */ getActiveTransaction), +/* harmony export */ "msToSec": () => (/* binding */ msToSec), +/* harmony export */ "secToMs": () => (/* binding */ secToMs), +/* harmony export */ "stripUrlQueryAndFragment": () => (/* reexport safe */ _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.stripUrlQueryAndFragment) +/* harmony export */ }); +/* harmony import */ var _sentry_hub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/hub */ "./node_modules/@sentry/hub/esm/hub.js"); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/utils */ "./node_modules/@sentry/utils/esm/misc.js"); + +var TRACEPARENT_REGEXP = new RegExp('^[ \\t]*' + // whitespace + '([0-9a-f]{32})?' + // trace_id + '-?([0-9a-f]{16})?' + // span_id + '-?([01])?' + // sampled + '[ \\t]*$'); +/** + * Determines if tracing is currently enabled. + * + * Tracing is enabled when at least one of `tracesSampleRate` and `tracesSampler` is defined in the SDK config. + */ +function hasTracingEnabled(options) { + if (options === void 0) { options = (_a = (0,_sentry_hub__WEBPACK_IMPORTED_MODULE_0__.getCurrentHub)() + .getClient()) === null || _a === void 0 ? void 0 : _a.getOptions(); } + var _a; + if (!options) { + return false; + } + return 'tracesSampleRate' in options || 'tracesSampler' in options; +} +/** + * Extract transaction context data from a `sentry-trace` header. + * + * @param traceparent Traceparent string + * + * @returns Object containing data from the header, or undefined if traceparent string is malformed + */ +function extractTraceparentData(traceparent) { + var matches = traceparent.match(TRACEPARENT_REGEXP); + if (matches) { + var parentSampled = void 0; + if (matches[3] === '1') { + parentSampled = true; + } + else if (matches[3] === '0') { + parentSampled = false; + } + return { + traceId: matches[1], + parentSampled: parentSampled, + parentSpanId: matches[2], + }; + } + return undefined; +} +/** Grabs active transaction off scope, if any */ +function getActiveTransaction(hub) { + if (hub === void 0) { hub = (0,_sentry_hub__WEBPACK_IMPORTED_MODULE_0__.getCurrentHub)(); } + var _a, _b; + return (_b = (_a = hub) === null || _a === void 0 ? void 0 : _a.getScope()) === null || _b === void 0 ? void 0 : _b.getTransaction(); +} +/** + * Converts from milliseconds to seconds + * @param time time in ms + */ +function msToSec(time) { + return time / 1000; +} +/** + * Converts from seconds to milliseconds + * @param time time in seconds + */ +function secToMs(time) { + return time * 1000; +} +// so it can be used in manual instrumentation without necessitating a hard dependency on @sentry/utils + +//# sourceMappingURL=utils.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/types/esm/session.js": +/*!***************************************************!*\ + !*** ./node_modules/@sentry/types/esm/session.js ***! + \***************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SessionStatus": () => (/* binding */ SessionStatus), +/* harmony export */ "RequestSessionStatus": () => (/* binding */ RequestSessionStatus) +/* harmony export */ }); +/** + * Session Status + */ +var SessionStatus; +(function (SessionStatus) { + /** JSDoc */ + SessionStatus["Ok"] = "ok"; + /** JSDoc */ + SessionStatus["Exited"] = "exited"; + /** JSDoc */ + SessionStatus["Crashed"] = "crashed"; + /** JSDoc */ + SessionStatus["Abnormal"] = "abnormal"; +})(SessionStatus || (SessionStatus = {})); +var RequestSessionStatus; +(function (RequestSessionStatus) { + /** JSDoc */ + RequestSessionStatus["Ok"] = "ok"; + /** JSDoc */ + RequestSessionStatus["Errored"] = "errored"; + /** JSDoc */ + RequestSessionStatus["Crashed"] = "crashed"; +})(RequestSessionStatus || (RequestSessionStatus = {})); +//# sourceMappingURL=session.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/types/esm/severity.js": +/*!****************************************************!*\ + !*** ./node_modules/@sentry/types/esm/severity.js ***! + \****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Severity": () => (/* binding */ Severity) +/* harmony export */ }); +/** JSDoc */ +// eslint-disable-next-line import/export +var Severity; +(function (Severity) { + /** JSDoc */ + Severity["Fatal"] = "fatal"; + /** JSDoc */ + Severity["Error"] = "error"; + /** JSDoc */ + Severity["Warning"] = "warning"; + /** JSDoc */ + Severity["Log"] = "log"; + /** JSDoc */ + Severity["Info"] = "info"; + /** JSDoc */ + Severity["Debug"] = "debug"; + /** JSDoc */ + Severity["Critical"] = "critical"; +})(Severity || (Severity = {})); +// eslint-disable-next-line @typescript-eslint/no-namespace, import/export +(function (Severity) { + /** + * Converts a string-based level into a {@link Severity}. + * + * @param level string representation of Severity + * @returns Severity + */ + function fromString(level) { + switch (level) { + case 'debug': + return Severity.Debug; + case 'info': + return Severity.Info; + case 'warn': + case 'warning': + return Severity.Warning; + case 'error': + return Severity.Error; + case 'fatal': + return Severity.Fatal; + case 'critical': + return Severity.Critical; + case 'log': + default: + return Severity.Log; + } + } + Severity.fromString = fromString; +})(Severity || (Severity = {})); +//# sourceMappingURL=severity.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/types/esm/status.js": +/*!**************************************************!*\ + !*** ./node_modules/@sentry/types/esm/status.js ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Status": () => (/* binding */ Status) +/* harmony export */ }); +/** The status of an event. */ +// eslint-disable-next-line import/export +var Status; +(function (Status) { + /** The status could not be determined. */ + Status["Unknown"] = "unknown"; + /** The event was skipped due to configuration or callbacks. */ + Status["Skipped"] = "skipped"; + /** The event was sent to Sentry successfully. */ + Status["Success"] = "success"; + /** The client is currently rate limited and will try again later. */ + Status["RateLimit"] = "rate_limit"; + /** The event could not be processed. */ + Status["Invalid"] = "invalid"; + /** A server-side error ocurred during submission. */ + Status["Failed"] = "failed"; +})(Status || (Status = {})); +// eslint-disable-next-line @typescript-eslint/no-namespace, import/export +(function (Status) { + /** + * Converts a HTTP status code into a {@link Status}. + * + * @param code The HTTP response status code. + * @returns The send status or {@link Status.Unknown}. + */ + function fromHttpCode(code) { + if (code >= 200 && code < 300) { + return Status.Success; + } + if (code === 429) { + return Status.RateLimit; + } + if (code >= 400 && code < 500) { + return Status.Invalid; + } + if (code >= 500) { + return Status.Failed; + } + return Status.Unknown; + } + Status.fromHttpCode = fromHttpCode; +})(Status || (Status = {})); +//# sourceMappingURL=status.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/types/esm/transaction.js": +/*!*******************************************************!*\ + !*** ./node_modules/@sentry/types/esm/transaction.js ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "TransactionSamplingMethod": () => (/* binding */ TransactionSamplingMethod) +/* harmony export */ }); +var TransactionSamplingMethod; +(function (TransactionSamplingMethod) { + TransactionSamplingMethod["Explicit"] = "explicitly_set"; + TransactionSamplingMethod["Sampler"] = "client_sampler"; + TransactionSamplingMethod["Rate"] = "client_rate"; + TransactionSamplingMethod["Inheritance"] = "inheritance"; +})(TransactionSamplingMethod || (TransactionSamplingMethod = {})); +//# sourceMappingURL=transaction.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/browser.js": +/*!***************************************************!*\ + !*** ./node_modules/@sentry/utils/esm/browser.js ***! + \***************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "htmlTreeAsString": () => (/* binding */ htmlTreeAsString) +/* harmony export */ }); +/* harmony import */ var _is__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./is */ "./node_modules/@sentry/utils/esm/is.js"); + +/** + * Given a child DOM element, returns a query-selector statement describing that + * and its ancestors + * e.g. [HTMLElement] => body > div > input#foo.btn[name=baz] + * @returns generated DOM path + */ +function htmlTreeAsString(elem, keyAttrs) { + // try/catch both: + // - accessing event.target (see getsentry/raven-js#838, #768) + // - `htmlTreeAsString` because it's complex, and just accessing the DOM incorrectly + // - can throw an exception in some circumstances. + try { + var currentElem = elem; + var MAX_TRAVERSE_HEIGHT = 5; + var MAX_OUTPUT_LEN = 80; + var out = []; + var height = 0; + var len = 0; + var separator = ' > '; + var sepLength = separator.length; + var nextStr = void 0; + // eslint-disable-next-line no-plusplus + while (currentElem && height++ < MAX_TRAVERSE_HEIGHT) { + nextStr = _htmlElementAsString(currentElem, keyAttrs); + // bail out if + // - nextStr is the 'html' element + // - the length of the string that would be created exceeds MAX_OUTPUT_LEN + // (ignore this limit if we are on the first iteration) + if (nextStr === 'html' || (height > 1 && len + out.length * sepLength + nextStr.length >= MAX_OUTPUT_LEN)) { + break; + } + out.push(nextStr); + len += nextStr.length; + currentElem = currentElem.parentNode; + } + return out.reverse().join(separator); + } + catch (_oO) { + return ''; + } +} +/** + * Returns a simple, query-selector representation of a DOM element + * e.g. [HTMLElement] => input#foo.btn[name=baz] + * @returns generated DOM path + */ +function _htmlElementAsString(el, keyAttrs) { + var _a, _b; + var elem = el; + var out = []; + var className; + var classes; + var key; + var attr; + var i; + if (!elem || !elem.tagName) { + return ''; + } + out.push(elem.tagName.toLowerCase()); + // Pairs of attribute keys defined in `serializeAttribute` and their values on element. + var keyAttrPairs = ((_a = keyAttrs) === null || _a === void 0 ? void 0 : _a.length) ? keyAttrs.filter(function (keyAttr) { return elem.getAttribute(keyAttr); }).map(function (keyAttr) { return [keyAttr, elem.getAttribute(keyAttr)]; }) + : null; + if ((_b = keyAttrPairs) === null || _b === void 0 ? void 0 : _b.length) { + keyAttrPairs.forEach(function (keyAttrPair) { + out.push("[" + keyAttrPair[0] + "=\"" + keyAttrPair[1] + "\"]"); + }); + } + else { + if (elem.id) { + out.push("#" + elem.id); + } + // eslint-disable-next-line prefer-const + className = elem.className; + if (className && (0,_is__WEBPACK_IMPORTED_MODULE_0__.isString)(className)) { + classes = className.split(/\s+/); + for (i = 0; i < classes.length; i++) { + out.push("." + classes[i]); + } + } + } + var allowedAttrs = ['type', 'name', 'title', 'alt']; + for (i = 0; i < allowedAttrs.length; i++) { + key = allowedAttrs[i]; + attr = elem.getAttribute(key); + if (attr) { + out.push("[" + key + "=\"" + attr + "\"]"); + } + } + return out.join(''); +} +//# sourceMappingURL=browser.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/dsn.js": +/*!***********************************************!*\ + !*** ./node_modules/@sentry/utils/esm/dsn.js ***! + \***********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Dsn": () => (/* binding */ Dsn) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./error */ "./node_modules/@sentry/utils/esm/error.js"); + + +/** Regular expression used to parse a Dsn. */ +var DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/; +/** Error message */ +var ERROR_MESSAGE = 'Invalid Dsn'; +/** The Sentry Dsn, identifying a Sentry instance and project. */ +var Dsn = /** @class */ (function () { + /** Creates a new Dsn component */ + function Dsn(from) { + if (typeof from === 'string') { + this._fromString(from); + } + else { + this._fromComponents(from); + } + this._validate(); + } + /** + * Renders the string representation of this Dsn. + * + * By default, this will render the public representation without the password + * component. To get the deprecated private representation, set `withPassword` + * to true. + * + * @param withPassword When set to true, the password will be included. + */ + Dsn.prototype.toString = function (withPassword) { + if (withPassword === void 0) { withPassword = false; } + var _a = this, host = _a.host, path = _a.path, pass = _a.pass, port = _a.port, projectId = _a.projectId, protocol = _a.protocol, publicKey = _a.publicKey; + return (protocol + "://" + publicKey + (withPassword && pass ? ":" + pass : '') + + ("@" + host + (port ? ":" + port : '') + "/" + (path ? path + "/" : path) + projectId)); + }; + /** Parses a string into this Dsn. */ + Dsn.prototype._fromString = function (str) { + var match = DSN_REGEX.exec(str); + if (!match) { + throw new _error__WEBPACK_IMPORTED_MODULE_0__.SentryError(ERROR_MESSAGE); + } + var _a = (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__read)(match.slice(1), 6), protocol = _a[0], publicKey = _a[1], _b = _a[2], pass = _b === void 0 ? '' : _b, host = _a[3], _c = _a[4], port = _c === void 0 ? '' : _c, lastPath = _a[5]; + var path = ''; + var projectId = lastPath; + var split = projectId.split('/'); + if (split.length > 1) { + path = split.slice(0, -1).join('/'); + projectId = split.pop(); + } + if (projectId) { + var projectMatch = projectId.match(/^\d+/); + if (projectMatch) { + projectId = projectMatch[0]; + } + } + this._fromComponents({ host: host, pass: pass, path: path, projectId: projectId, port: port, protocol: protocol, publicKey: publicKey }); + }; + /** Maps Dsn components into this instance. */ + Dsn.prototype._fromComponents = function (components) { + // TODO this is for backwards compatibility, and can be removed in a future version + if ('user' in components && !('publicKey' in components)) { + components.publicKey = components.user; + } + this.user = components.publicKey || ''; + this.protocol = components.protocol; + this.publicKey = components.publicKey || ''; + this.pass = components.pass || ''; + this.host = components.host; + this.port = components.port || ''; + this.path = components.path || ''; + this.projectId = components.projectId; + }; + /** Validates this Dsn and throws on error. */ + Dsn.prototype._validate = function () { + var _this = this; + ['protocol', 'publicKey', 'host', 'projectId'].forEach(function (component) { + if (!_this[component]) { + throw new _error__WEBPACK_IMPORTED_MODULE_0__.SentryError(ERROR_MESSAGE + ": " + component + " missing"); + } + }); + if (!this.projectId.match(/^\d+$/)) { + throw new _error__WEBPACK_IMPORTED_MODULE_0__.SentryError(ERROR_MESSAGE + ": Invalid projectId " + this.projectId); + } + if (this.protocol !== 'http' && this.protocol !== 'https') { + throw new _error__WEBPACK_IMPORTED_MODULE_0__.SentryError(ERROR_MESSAGE + ": Invalid protocol " + this.protocol); + } + if (this.port && isNaN(parseInt(this.port, 10))) { + throw new _error__WEBPACK_IMPORTED_MODULE_0__.SentryError(ERROR_MESSAGE + ": Invalid port " + this.port); + } + }; + return Dsn; +}()); + +//# sourceMappingURL=dsn.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/error.js": +/*!*************************************************!*\ + !*** ./node_modules/@sentry/utils/esm/error.js ***! + \*************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SentryError": () => (/* binding */ SentryError) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _polyfill__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./polyfill */ "./node_modules/@sentry/utils/esm/polyfill.js"); + + +/** An error emitted by Sentry SDKs and related utilities. */ +var SentryError = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(SentryError, _super); + function SentryError(message) { + var _newTarget = this.constructor; + var _this = _super.call(this, message) || this; + _this.message = message; + _this.name = _newTarget.prototype.constructor.name; + (0,_polyfill__WEBPACK_IMPORTED_MODULE_1__.setPrototypeOf)(_this, _newTarget.prototype); + return _this; + } + return SentryError; +}(Error)); + +//# sourceMappingURL=error.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/instrument.js": +/*!******************************************************!*\ + !*** ./node_modules/@sentry/utils/esm/instrument.js ***! + \******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "addInstrumentationHandler": () => (/* binding */ addInstrumentationHandler) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _is__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./is */ "./node_modules/@sentry/utils/esm/is.js"); +/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./logger */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _misc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./misc */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _object__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./object */ "./node_modules/@sentry/utils/esm/object.js"); +/* harmony import */ var _stacktrace__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stacktrace */ "./node_modules/@sentry/utils/esm/stacktrace.js"); +/* harmony import */ var _supports__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./supports */ "./node_modules/@sentry/utils/esm/supports.js"); + + + + + + + +var global = (0,_misc__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)(); +/** + * Instrument native APIs to call handlers that can be used to create breadcrumbs, APM spans etc. + * - Console API + * - Fetch API + * - XHR API + * - History API + * - DOM API (click/typing) + * - Error API + * - UnhandledRejection API + */ +var handlers = {}; +var instrumented = {}; +/** Instruments given API */ +function instrument(type) { + if (instrumented[type]) { + return; + } + instrumented[type] = true; + switch (type) { + case 'console': + instrumentConsole(); + break; + case 'dom': + instrumentDOM(); + break; + case 'xhr': + instrumentXHR(); + break; + case 'fetch': + instrumentFetch(); + break; + case 'history': + instrumentHistory(); + break; + case 'error': + instrumentError(); + break; + case 'unhandledrejection': + instrumentUnhandledRejection(); + break; + default: + _logger__WEBPACK_IMPORTED_MODULE_1__.logger.warn('unknown instrumentation type:', type); + } +} +/** + * Add handler that will be called when given type of instrumentation triggers. + * Use at your own risk, this might break without changelog notice, only used internally. + * @hidden + */ +function addInstrumentationHandler(handler) { + if (!handler || typeof handler.type !== 'string' || typeof handler.callback !== 'function') { + return; + } + handlers[handler.type] = handlers[handler.type] || []; + handlers[handler.type].push(handler.callback); + instrument(handler.type); +} +/** JSDoc */ +function triggerHandlers(type, data) { + var e_1, _a; + if (!type || !handlers[type]) { + return; + } + try { + for (var _b = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__values)(handlers[type] || []), _c = _b.next(); !_c.done; _c = _b.next()) { + var handler = _c.value; + try { + handler(data); + } + catch (e) { + _logger__WEBPACK_IMPORTED_MODULE_1__.logger.error("Error while triggering instrumentation handler.\nType: " + type + "\nName: " + (0,_stacktrace__WEBPACK_IMPORTED_MODULE_3__.getFunctionName)(handler) + "\nError: " + e); + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } +} +/** JSDoc */ +function instrumentConsole() { + if (!('console' in global)) { + return; + } + ['debug', 'info', 'warn', 'error', 'log', 'assert'].forEach(function (level) { + if (!(level in global.console)) { + return; + } + (0,_object__WEBPACK_IMPORTED_MODULE_4__.fill)(global.console, level, function (originalConsoleLevel) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + triggerHandlers('console', { args: args, level: level }); + // this fails for some browsers. :( + if (originalConsoleLevel) { + Function.prototype.apply.call(originalConsoleLevel, global.console, args); + } + }; + }); + }); +} +/** JSDoc */ +function instrumentFetch() { + if (!(0,_supports__WEBPACK_IMPORTED_MODULE_5__.supportsNativeFetch)()) { + return; + } + (0,_object__WEBPACK_IMPORTED_MODULE_4__.fill)(global, 'fetch', function (originalFetch) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var handlerData = { + args: args, + fetchData: { + method: getFetchMethod(args), + url: getFetchUrl(args), + }, + startTimestamp: Date.now(), + }; + triggerHandlers('fetch', (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, handlerData)); + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + return originalFetch.apply(global, args).then(function (response) { + triggerHandlers('fetch', (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, handlerData), { endTimestamp: Date.now(), response: response })); + return response; + }, function (error) { + triggerHandlers('fetch', (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, handlerData), { endTimestamp: Date.now(), error: error })); + // NOTE: If you are a Sentry user, and you are seeing this stack frame, + // it means the sentry.javascript SDK caught an error invoking your application code. + // This is expected behavior and NOT indicative of a bug with sentry.javascript. + throw error; + }); + }; + }); +} +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/** Extract `method` from fetch call arguments */ +function getFetchMethod(fetchArgs) { + if (fetchArgs === void 0) { fetchArgs = []; } + if ('Request' in global && (0,_is__WEBPACK_IMPORTED_MODULE_6__.isInstanceOf)(fetchArgs[0], Request) && fetchArgs[0].method) { + return String(fetchArgs[0].method).toUpperCase(); + } + if (fetchArgs[1] && fetchArgs[1].method) { + return String(fetchArgs[1].method).toUpperCase(); + } + return 'GET'; +} +/** Extract `url` from fetch call arguments */ +function getFetchUrl(fetchArgs) { + if (fetchArgs === void 0) { fetchArgs = []; } + if (typeof fetchArgs[0] === 'string') { + return fetchArgs[0]; + } + if ('Request' in global && (0,_is__WEBPACK_IMPORTED_MODULE_6__.isInstanceOf)(fetchArgs[0], Request)) { + return fetchArgs[0].url; + } + return String(fetchArgs[0]); +} +/* eslint-enable @typescript-eslint/no-unsafe-member-access */ +/** JSDoc */ +function instrumentXHR() { + if (!('XMLHttpRequest' in global)) { + return; + } + // Poor man's implementation of ES6 `Map`, tracking and keeping in sync key and value separately. + var requestKeys = []; + var requestValues = []; + var xhrproto = XMLHttpRequest.prototype; + (0,_object__WEBPACK_IMPORTED_MODULE_4__.fill)(xhrproto, 'open', function (originalOpen) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + // eslint-disable-next-line @typescript-eslint/no-this-alias + var xhr = this; + var url = args[1]; + xhr.__sentry_xhr__ = { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + method: (0,_is__WEBPACK_IMPORTED_MODULE_6__.isString)(args[0]) ? args[0].toUpperCase() : args[0], + url: args[1], + }; + // if Sentry key appears in URL, don't capture it as a request + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + if ((0,_is__WEBPACK_IMPORTED_MODULE_6__.isString)(url) && xhr.__sentry_xhr__.method === 'POST' && url.match(/sentry_key/)) { + xhr.__sentry_own_request__ = true; + } + var onreadystatechangeHandler = function () { + if (xhr.readyState === 4) { + try { + // touching statusCode in some platforms throws + // an exception + if (xhr.__sentry_xhr__) { + xhr.__sentry_xhr__.status_code = xhr.status; + } + } + catch (e) { + /* do nothing */ + } + try { + var requestPos = requestKeys.indexOf(xhr); + if (requestPos !== -1) { + // Make sure to pop both key and value to keep it in sync. + requestKeys.splice(requestPos); + var args_1 = requestValues.splice(requestPos)[0]; + if (xhr.__sentry_xhr__ && args_1[0] !== undefined) { + xhr.__sentry_xhr__.body = args_1[0]; + } + } + } + catch (e) { + /* do nothing */ + } + triggerHandlers('xhr', { + args: args, + endTimestamp: Date.now(), + startTimestamp: Date.now(), + xhr: xhr, + }); + } + }; + if ('onreadystatechange' in xhr && typeof xhr.onreadystatechange === 'function') { + (0,_object__WEBPACK_IMPORTED_MODULE_4__.fill)(xhr, 'onreadystatechange', function (original) { + return function () { + var readyStateArgs = []; + for (var _i = 0; _i < arguments.length; _i++) { + readyStateArgs[_i] = arguments[_i]; + } + onreadystatechangeHandler(); + return original.apply(xhr, readyStateArgs); + }; + }); + } + else { + xhr.addEventListener('readystatechange', onreadystatechangeHandler); + } + return originalOpen.apply(xhr, args); + }; + }); + (0,_object__WEBPACK_IMPORTED_MODULE_4__.fill)(xhrproto, 'send', function (originalSend) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + requestKeys.push(this); + requestValues.push(args); + triggerHandlers('xhr', { + args: args, + startTimestamp: Date.now(), + xhr: this, + }); + return originalSend.apply(this, args); + }; + }); +} +var lastHref; +/** JSDoc */ +function instrumentHistory() { + if (!(0,_supports__WEBPACK_IMPORTED_MODULE_5__.supportsHistory)()) { + return; + } + var oldOnPopState = global.onpopstate; + global.onpopstate = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var to = global.location.href; + // keep track of the current URL state, as we always receive only the updated state + var from = lastHref; + lastHref = to; + triggerHandlers('history', { + from: from, + to: to, + }); + if (oldOnPopState) { + // Apparently this can throw in Firefox when incorrectly implemented plugin is installed. + // https://github.com/getsentry/sentry-javascript/issues/3344 + // https://github.com/bugsnag/bugsnag-js/issues/469 + try { + return oldOnPopState.apply(this, args); + } + catch (_oO) { + // no-empty + } + } + }; + /** @hidden */ + function historyReplacementFunction(originalHistoryFunction) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var url = args.length > 2 ? args[2] : undefined; + if (url) { + // coerce to string (this is what pushState does) + var from = lastHref; + var to = String(url); + // keep track of the current URL state, as we always receive only the updated state + lastHref = to; + triggerHandlers('history', { + from: from, + to: to, + }); + } + return originalHistoryFunction.apply(this, args); + }; + } + (0,_object__WEBPACK_IMPORTED_MODULE_4__.fill)(global.history, 'pushState', historyReplacementFunction); + (0,_object__WEBPACK_IMPORTED_MODULE_4__.fill)(global.history, 'replaceState', historyReplacementFunction); +} +var debounceDuration = 1000; +var debounceTimerID; +var lastCapturedEvent; +/** + * Decide whether the current event should finish the debounce of previously captured one. + * @param previous previously captured event + * @param current event to be captured + */ +function shouldShortcircuitPreviousDebounce(previous, current) { + // If there was no previous event, it should always be swapped for the new one. + if (!previous) { + return true; + } + // If both events have different type, then user definitely performed two separate actions. e.g. click + keypress. + if (previous.type !== current.type) { + return true; + } + try { + // If both events have the same type, it's still possible that actions were performed on different targets. + // e.g. 2 clicks on different buttons. + if (previous.target !== current.target) { + return true; + } + } + catch (e) { + // just accessing `target` property can throw an exception in some rare circumstances + // see: https://github.com/getsentry/sentry-javascript/issues/838 + } + // If both events have the same type _and_ same `target` (an element which triggered an event, _not necessarily_ + // to which an event listener was attached), we treat them as the same action, as we want to capture + // only one breadcrumb. e.g. multiple clicks on the same button, or typing inside a user input box. + return false; +} +/** + * Decide whether an event should be captured. + * @param event event to be captured + */ +function shouldSkipDOMEvent(event) { + // We are only interested in filtering `keypress` events for now. + if (event.type !== 'keypress') { + return false; + } + try { + var target = event.target; + if (!target || !target.tagName) { + return true; + } + // Only consider keypress events on actual input elements. This will disregard keypresses targeting body + // e.g.tabbing through elements, hotkeys, etc. + if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) { + return false; + } + } + catch (e) { + // just accessing `target` property can throw an exception in some rare circumstances + // see: https://github.com/getsentry/sentry-javascript/issues/838 + } + return true; +} +/** + * Wraps addEventListener to capture UI breadcrumbs + * @param handler function that will be triggered + * @param globalListener indicates whether event was captured by the global event listener + * @returns wrapped breadcrumb events handler + * @hidden + */ +function makeDOMEventHandler(handler, globalListener) { + if (globalListener === void 0) { globalListener = false; } + return function (event) { + // It's possible this handler might trigger multiple times for the same + // event (e.g. event propagation through node ancestors). + // Ignore if we've already captured that event. + if (!event || lastCapturedEvent === event) { + return; + } + // We always want to skip _some_ events. + if (shouldSkipDOMEvent(event)) { + return; + } + var name = event.type === 'keypress' ? 'input' : event.type; + // If there is no debounce timer, it means that we can safely capture the new event and store it for future comparisons. + if (debounceTimerID === undefined) { + handler({ + event: event, + name: name, + global: globalListener, + }); + lastCapturedEvent = event; + } + // If there is a debounce awaiting, see if the new event is different enough to treat it as a unique one. + // If that's the case, emit the previous event and store locally the newly-captured DOM event. + else if (shouldShortcircuitPreviousDebounce(lastCapturedEvent, event)) { + handler({ + event: event, + name: name, + global: globalListener, + }); + lastCapturedEvent = event; + } + // Start a new debounce timer that will prevent us from capturing multiple events that should be grouped together. + clearTimeout(debounceTimerID); + debounceTimerID = global.setTimeout(function () { + debounceTimerID = undefined; + }, debounceDuration); + }; +} +/** JSDoc */ +function instrumentDOM() { + if (!('document' in global)) { + return; + } + // Make it so that any click or keypress that is unhandled / bubbled up all the way to the document triggers our dom + // handlers. (Normally we have only one, which captures a breadcrumb for each click or keypress.) Do this before + // we instrument `addEventListener` so that we don't end up attaching this handler twice. + var triggerDOMHandler = triggerHandlers.bind(null, 'dom'); + var globalDOMEventHandler = makeDOMEventHandler(triggerDOMHandler, true); + global.document.addEventListener('click', globalDOMEventHandler, false); + global.document.addEventListener('keypress', globalDOMEventHandler, false); + // After hooking into click and keypress events bubbled up to `document`, we also hook into user-handled + // clicks & keypresses, by adding an event listener of our own to any element to which they add a listener. That + // way, whenever one of their handlers is triggered, ours will be, too. (This is needed because their handler + // could potentially prevent the event from bubbling up to our global listeners. This way, our handler are still + // guaranteed to fire at least once.) + ['EventTarget', 'Node'].forEach(function (target) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + var proto = global[target] && global[target].prototype; + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins + if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) { + return; + } + (0,_object__WEBPACK_IMPORTED_MODULE_4__.fill)(proto, 'addEventListener', function (originalAddEventListener) { + return function (type, listener, options) { + if (type === 'click' || type == 'keypress') { + try { + var el = this; + var handlers_1 = (el.__sentry_instrumentation_handlers__ = el.__sentry_instrumentation_handlers__ || {}); + var handlerForType = (handlers_1[type] = handlers_1[type] || { refCount: 0 }); + if (!handlerForType.handler) { + var handler = makeDOMEventHandler(triggerDOMHandler); + handlerForType.handler = handler; + originalAddEventListener.call(this, type, handler, options); + } + handlerForType.refCount += 1; + } + catch (e) { + // Accessing dom properties is always fragile. + // Also allows us to skip `addEventListenrs` calls with no proper `this` context. + } + } + return originalAddEventListener.call(this, type, listener, options); + }; + }); + (0,_object__WEBPACK_IMPORTED_MODULE_4__.fill)(proto, 'removeEventListener', function (originalRemoveEventListener) { + return function (type, listener, options) { + if (type === 'click' || type == 'keypress') { + try { + var el = this; + var handlers_2 = el.__sentry_instrumentation_handlers__ || {}; + var handlerForType = handlers_2[type]; + if (handlerForType) { + handlerForType.refCount -= 1; + // If there are no longer any custom handlers of the current type on this element, we can remove ours, too. + if (handlerForType.refCount <= 0) { + originalRemoveEventListener.call(this, type, handlerForType.handler, options); + handlerForType.handler = undefined; + delete handlers_2[type]; // eslint-disable-line @typescript-eslint/no-dynamic-delete + } + // If there are no longer any custom handlers of any type on this element, cleanup everything. + if (Object.keys(handlers_2).length === 0) { + delete el.__sentry_instrumentation_handlers__; + } + } + } + catch (e) { + // Accessing dom properties is always fragile. + // Also allows us to skip `addEventListenrs` calls with no proper `this` context. + } + } + return originalRemoveEventListener.call(this, type, listener, options); + }; + }); + }); +} +var _oldOnErrorHandler = null; +/** JSDoc */ +function instrumentError() { + _oldOnErrorHandler = global.onerror; + global.onerror = function (msg, url, line, column, error) { + triggerHandlers('error', { + column: column, + error: error, + line: line, + msg: msg, + url: url, + }); + if (_oldOnErrorHandler) { + // eslint-disable-next-line prefer-rest-params + return _oldOnErrorHandler.apply(this, arguments); + } + return false; + }; +} +var _oldOnUnhandledRejectionHandler = null; +/** JSDoc */ +function instrumentUnhandledRejection() { + _oldOnUnhandledRejectionHandler = global.onunhandledrejection; + global.onunhandledrejection = function (e) { + triggerHandlers('unhandledrejection', e); + if (_oldOnUnhandledRejectionHandler) { + // eslint-disable-next-line prefer-rest-params + return _oldOnUnhandledRejectionHandler.apply(this, arguments); + } + return true; + }; +} +//# sourceMappingURL=instrument.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/is.js": +/*!**********************************************!*\ + !*** ./node_modules/@sentry/utils/esm/is.js ***! + \**********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "isError": () => (/* binding */ isError), +/* harmony export */ "isErrorEvent": () => (/* binding */ isErrorEvent), +/* harmony export */ "isDOMError": () => (/* binding */ isDOMError), +/* harmony export */ "isDOMException": () => (/* binding */ isDOMException), +/* harmony export */ "isString": () => (/* binding */ isString), +/* harmony export */ "isPrimitive": () => (/* binding */ isPrimitive), +/* harmony export */ "isPlainObject": () => (/* binding */ isPlainObject), +/* harmony export */ "isEvent": () => (/* binding */ isEvent), +/* harmony export */ "isElement": () => (/* binding */ isElement), +/* harmony export */ "isRegExp": () => (/* binding */ isRegExp), +/* harmony export */ "isThenable": () => (/* binding */ isThenable), +/* harmony export */ "isSyntheticEvent": () => (/* binding */ isSyntheticEvent), +/* harmony export */ "isInstanceOf": () => (/* binding */ isInstanceOf) +/* harmony export */ }); +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** + * Checks whether given value's type is one of a few Error or Error-like + * {@link isError}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ +function isError(wat) { + switch (Object.prototype.toString.call(wat)) { + case '[object Error]': + return true; + case '[object Exception]': + return true; + case '[object DOMException]': + return true; + default: + return isInstanceOf(wat, Error); + } +} +/** + * Checks whether given value's type is ErrorEvent + * {@link isErrorEvent}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ +function isErrorEvent(wat) { + return Object.prototype.toString.call(wat) === '[object ErrorEvent]'; +} +/** + * Checks whether given value's type is DOMError + * {@link isDOMError}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ +function isDOMError(wat) { + return Object.prototype.toString.call(wat) === '[object DOMError]'; +} +/** + * Checks whether given value's type is DOMException + * {@link isDOMException}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ +function isDOMException(wat) { + return Object.prototype.toString.call(wat) === '[object DOMException]'; +} +/** + * Checks whether given value's type is a string + * {@link isString}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ +function isString(wat) { + return Object.prototype.toString.call(wat) === '[object String]'; +} +/** + * Checks whether given value's is a primitive (undefined, null, number, boolean, string, bigint, symbol) + * {@link isPrimitive}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ +function isPrimitive(wat) { + return wat === null || (typeof wat !== 'object' && typeof wat !== 'function'); +} +/** + * Checks whether given value's type is an object literal + * {@link isPlainObject}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ +function isPlainObject(wat) { + return Object.prototype.toString.call(wat) === '[object Object]'; +} +/** + * Checks whether given value's type is an Event instance + * {@link isEvent}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ +function isEvent(wat) { + return typeof Event !== 'undefined' && isInstanceOf(wat, Event); +} +/** + * Checks whether given value's type is an Element instance + * {@link isElement}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ +function isElement(wat) { + return typeof Element !== 'undefined' && isInstanceOf(wat, Element); +} +/** + * Checks whether given value's type is an regexp + * {@link isRegExp}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ +function isRegExp(wat) { + return Object.prototype.toString.call(wat) === '[object RegExp]'; +} +/** + * Checks whether given value has a then function. + * @param wat A value to be checked. + */ +function isThenable(wat) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + return Boolean(wat && wat.then && typeof wat.then === 'function'); +} +/** + * Checks whether given value's type is a SyntheticEvent + * {@link isSyntheticEvent}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ +function isSyntheticEvent(wat) { + return isPlainObject(wat) && 'nativeEvent' in wat && 'preventDefault' in wat && 'stopPropagation' in wat; +} +/** + * Checks whether given value's type is an instance of provided constructor. + * {@link isInstanceOf}. + * + * @param wat A value to be checked. + * @param base A constructor to be used in a check. + * @returns A boolean representing the result. + */ +function isInstanceOf(wat, base) { + try { + return wat instanceof base; + } + catch (_e) { + return false; + } +} +//# sourceMappingURL=is.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/logger.js": +/*!**************************************************!*\ + !*** ./node_modules/@sentry/utils/esm/logger.js ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "logger": () => (/* binding */ logger) +/* harmony export */ }); +/* harmony import */ var _misc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./misc */ "./node_modules/@sentry/utils/esm/misc.js"); +/* eslint-disable @typescript-eslint/no-explicit-any */ + +// TODO: Implement different loggers for different environments +var global = (0,_misc__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)(); +/** Prefix for logging strings */ +var PREFIX = 'Sentry Logger '; +/** JSDoc */ +var Logger = /** @class */ (function () { + /** JSDoc */ + function Logger() { + this._enabled = false; + } + /** JSDoc */ + Logger.prototype.disable = function () { + this._enabled = false; + }; + /** JSDoc */ + Logger.prototype.enable = function () { + this._enabled = true; + }; + /** JSDoc */ + Logger.prototype.log = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!this._enabled) { + return; + } + (0,_misc__WEBPACK_IMPORTED_MODULE_0__.consoleSandbox)(function () { + global.console.log(PREFIX + "[Log]: " + args.join(' ')); + }); + }; + /** JSDoc */ + Logger.prototype.warn = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!this._enabled) { + return; + } + (0,_misc__WEBPACK_IMPORTED_MODULE_0__.consoleSandbox)(function () { + global.console.warn(PREFIX + "[Warn]: " + args.join(' ')); + }); + }; + /** JSDoc */ + Logger.prototype.error = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!this._enabled) { + return; + } + (0,_misc__WEBPACK_IMPORTED_MODULE_0__.consoleSandbox)(function () { + global.console.error(PREFIX + "[Error]: " + args.join(' ')); + }); + }; + return Logger; +}()); +// Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used +global.__SENTRY__ = global.__SENTRY__ || {}; +var logger = global.__SENTRY__.logger || (global.__SENTRY__.logger = new Logger()); + +//# sourceMappingURL=logger.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/memo.js": +/*!************************************************!*\ + !*** ./node_modules/@sentry/utils/esm/memo.js ***! + \************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Memo": () => (/* binding */ Memo) +/* harmony export */ }); +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** + * Memo class used for decycle json objects. Uses WeakSet if available otherwise array. + */ +var Memo = /** @class */ (function () { + function Memo() { + this._hasWeakSet = typeof WeakSet === 'function'; + this._inner = this._hasWeakSet ? new WeakSet() : []; + } + /** + * Sets obj to remember. + * @param obj Object to remember + */ + Memo.prototype.memoize = function (obj) { + if (this._hasWeakSet) { + if (this._inner.has(obj)) { + return true; + } + this._inner.add(obj); + return false; + } + // eslint-disable-next-line @typescript-eslint/prefer-for-of + for (var i = 0; i < this._inner.length; i++) { + var value = this._inner[i]; + if (value === obj) { + return true; + } + } + this._inner.push(obj); + return false; + }; + /** + * Removes object from internal storage. + * @param obj Object to forget + */ + Memo.prototype.unmemoize = function (obj) { + if (this._hasWeakSet) { + this._inner.delete(obj); + } + else { + for (var i = 0; i < this._inner.length; i++) { + if (this._inner[i] === obj) { + this._inner.splice(i, 1); + break; + } + } + } + }; + return Memo; +}()); + +//# sourceMappingURL=memo.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/misc.js": +/*!************************************************!*\ + !*** ./node_modules/@sentry/utils/esm/misc.js ***! + \************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getGlobalObject": () => (/* binding */ getGlobalObject), +/* harmony export */ "uuid4": () => (/* binding */ uuid4), +/* harmony export */ "parseUrl": () => (/* binding */ parseUrl), +/* harmony export */ "getEventDescription": () => (/* binding */ getEventDescription), +/* harmony export */ "consoleSandbox": () => (/* binding */ consoleSandbox), +/* harmony export */ "addExceptionTypeValue": () => (/* binding */ addExceptionTypeValue), +/* harmony export */ "addExceptionMechanism": () => (/* binding */ addExceptionMechanism), +/* harmony export */ "getLocationHref": () => (/* binding */ getLocationHref), +/* harmony export */ "parseSemver": () => (/* binding */ parseSemver), +/* harmony export */ "parseRetryAfterHeader": () => (/* binding */ parseRetryAfterHeader), +/* harmony export */ "addContextToFrame": () => (/* binding */ addContextToFrame), +/* harmony export */ "stripUrlQueryAndFragment": () => (/* binding */ stripUrlQueryAndFragment) +/* harmony export */ }); +/* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node */ "./node_modules/@sentry/utils/esm/node.js"); +/* harmony import */ var _string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./string */ "./node_modules/@sentry/utils/esm/string.js"); + + +var fallbackGlobalObject = {}; +/** + * Safely get global scope object + * + * @returns Global scope object + */ +function getGlobalObject() { + return ((0,_node__WEBPACK_IMPORTED_MODULE_0__.isNodeEnv)() + ? __webpack_require__.g + : typeof window !== 'undefined' + ? window + : typeof self !== 'undefined' + ? self + : fallbackGlobalObject); +} +/** + * UUID4 generator + * + * @returns string Generated UUID4. + */ +function uuid4() { + var global = getGlobalObject(); + var crypto = global.crypto || global.msCrypto; + if (!(crypto === void 0) && crypto.getRandomValues) { + // Use window.crypto API if available + var arr = new Uint16Array(8); + crypto.getRandomValues(arr); + // set 4 in byte 7 + // eslint-disable-next-line no-bitwise + arr[3] = (arr[3] & 0xfff) | 0x4000; + // set 2 most significant bits of byte 9 to '10' + // eslint-disable-next-line no-bitwise + arr[4] = (arr[4] & 0x3fff) | 0x8000; + var pad = function (num) { + var v = num.toString(16); + while (v.length < 4) { + v = "0" + v; + } + return v; + }; + return (pad(arr[0]) + pad(arr[1]) + pad(arr[2]) + pad(arr[3]) + pad(arr[4]) + pad(arr[5]) + pad(arr[6]) + pad(arr[7])); + } + // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523 + return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + // eslint-disable-next-line no-bitwise + var r = (Math.random() * 16) | 0; + // eslint-disable-next-line no-bitwise + var v = c === 'x' ? r : (r & 0x3) | 0x8; + return v.toString(16); + }); +} +/** + * Parses string form of URL into an object + * // borrowed from https://tools.ietf.org/html/rfc3986#appendix-B + * // intentionally using regex and not href parsing trick because React Native and other + * // environments where DOM might not be available + * @returns parsed URL object + */ +function parseUrl(url) { + if (!url) { + return {}; + } + var match = url.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/); + if (!match) { + return {}; + } + // coerce to undefined values to empty string so we don't get 'undefined' + var query = match[6] || ''; + var fragment = match[8] || ''; + return { + host: match[4], + path: match[5], + protocol: match[2], + relative: match[5] + query + fragment, + }; +} +/** + * Extracts either message or type+value from an event that can be used for user-facing logs + * @returns event's description + */ +function getEventDescription(event) { + if (event.message) { + return event.message; + } + if (event.exception && event.exception.values && event.exception.values[0]) { + var exception = event.exception.values[0]; + if (exception.type && exception.value) { + return exception.type + ": " + exception.value; + } + return exception.type || exception.value || event.event_id || ''; + } + return event.event_id || ''; +} +/** JSDoc */ +function consoleSandbox(callback) { + var global = getGlobalObject(); + var levels = ['debug', 'info', 'warn', 'error', 'log', 'assert']; + if (!('console' in global)) { + return callback(); + } + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + var originalConsole = global.console; + var wrappedLevels = {}; + // Restore all wrapped console methods + levels.forEach(function (level) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + if (level in global.console && originalConsole[level].__sentry_original__) { + wrappedLevels[level] = originalConsole[level]; + originalConsole[level] = originalConsole[level].__sentry_original__; + } + }); + // Perform callback manipulations + var result = callback(); + // Revert restoration to wrapped state + Object.keys(wrappedLevels).forEach(function (level) { + originalConsole[level] = wrappedLevels[level]; + }); + return result; +} +/** + * Adds exception values, type and value to an synthetic Exception. + * @param event The event to modify. + * @param value Value of the exception. + * @param type Type of the exception. + * @hidden + */ +function addExceptionTypeValue(event, value, type) { + event.exception = event.exception || {}; + event.exception.values = event.exception.values || []; + event.exception.values[0] = event.exception.values[0] || {}; + event.exception.values[0].value = event.exception.values[0].value || value || ''; + event.exception.values[0].type = event.exception.values[0].type || type || 'Error'; +} +/** + * Adds exception mechanism to a given event. + * @param event The event to modify. + * @param mechanism Mechanism of the mechanism. + * @hidden + */ +function addExceptionMechanism(event, mechanism) { + if (mechanism === void 0) { mechanism = {}; } + // TODO: Use real type with `keyof Mechanism` thingy and maybe make it better? + try { + // @ts-ignore Type 'Mechanism | {}' is not assignable to type 'Mechanism | undefined' + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + event.exception.values[0].mechanism = event.exception.values[0].mechanism || {}; + Object.keys(mechanism).forEach(function (key) { + // @ts-ignore Mechanism has no index signature + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + event.exception.values[0].mechanism[key] = mechanism[key]; + }); + } + catch (_oO) { + // no-empty + } +} +/** + * A safe form of location.href + */ +function getLocationHref() { + try { + return document.location.href; + } + catch (oO) { + return ''; + } +} +// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string +var SEMVER_REGEXP = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/; +/** + * Parses input into a SemVer interface + * @param input string representation of a semver version + */ +function parseSemver(input) { + var match = input.match(SEMVER_REGEXP) || []; + var major = parseInt(match[1], 10); + var minor = parseInt(match[2], 10); + var patch = parseInt(match[3], 10); + return { + buildmetadata: match[5], + major: isNaN(major) ? undefined : major, + minor: isNaN(minor) ? undefined : minor, + patch: isNaN(patch) ? undefined : patch, + prerelease: match[4], + }; +} +var defaultRetryAfter = 60 * 1000; // 60 seconds +/** + * Extracts Retry-After value from the request header or returns default value + * @param now current unix timestamp + * @param header string representation of 'Retry-After' header + */ +function parseRetryAfterHeader(now, header) { + if (!header) { + return defaultRetryAfter; + } + var headerDelay = parseInt("" + header, 10); + if (!isNaN(headerDelay)) { + return headerDelay * 1000; + } + var headerDate = Date.parse("" + header); + if (!isNaN(headerDate)) { + return headerDate - now; + } + return defaultRetryAfter; +} +/** + * This function adds context (pre/post/line) lines to the provided frame + * + * @param lines string[] containing all lines + * @param frame StackFrame that will be mutated + * @param linesOfContext number of context lines we want to add pre/post + */ +function addContextToFrame(lines, frame, linesOfContext) { + if (linesOfContext === void 0) { linesOfContext = 5; } + var lineno = frame.lineno || 0; + var maxLines = lines.length; + var sourceLine = Math.max(Math.min(maxLines, lineno - 1), 0); + frame.pre_context = lines + .slice(Math.max(0, sourceLine - linesOfContext), sourceLine) + .map(function (line) { return (0,_string__WEBPACK_IMPORTED_MODULE_1__.snipLine)(line, 0); }); + frame.context_line = (0,_string__WEBPACK_IMPORTED_MODULE_1__.snipLine)(lines[Math.min(maxLines - 1, sourceLine)], frame.colno || 0); + frame.post_context = lines + .slice(Math.min(sourceLine + 1, maxLines), sourceLine + 1 + linesOfContext) + .map(function (line) { return (0,_string__WEBPACK_IMPORTED_MODULE_1__.snipLine)(line, 0); }); +} +/** + * Strip the query string and fragment off of a given URL or path (if present) + * + * @param urlPath Full URL or path, including possible query string and/or fragment + * @returns URL or path without query string or fragment + */ +function stripUrlQueryAndFragment(urlPath) { + // eslint-disable-next-line no-useless-escape + return urlPath.split(/[\?#]/, 1)[0]; +} +//# sourceMappingURL=misc.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/node.js": +/*!************************************************!*\ + !*** ./node_modules/@sentry/utils/esm/node.js ***! + \************************************************/ +/***/ ((module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "isNodeEnv": () => (/* binding */ isNodeEnv), +/* harmony export */ "dynamicRequire": () => (/* binding */ dynamicRequire), +/* harmony export */ "loadModule": () => (/* binding */ loadModule) +/* harmony export */ }); +/* module decorator */ module = __webpack_require__.hmd(module); +/** + * Checks whether we're in the Node.js or Browser environment + * + * @returns Answer to given question + */ +function isNodeEnv() { + return Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'; +} +/** + * Requires a module which is protected against bundler minification. + * + * @param request The module path to resolve + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any +function dynamicRequire(mod, request) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + return mod.require(request); +} +/** + * Helper for dynamically loading module that should work with linked dependencies. + * The problem is that we _should_ be using `require(require.resolve(moduleName, { paths: [cwd()] }))` + * However it's _not possible_ to do that with Webpack, as it has to know all the dependencies during + * build time. `require.resolve` is also not available in any other way, so we cannot create, + * a fake helper like we do with `dynamicRequire`. + * + * We always prefer to use local package, thus the value is not returned early from each `try/catch` block. + * That is to mimic the behavior of `require.resolve` exactly. + * + * @param moduleName module name to require + * @returns possibly required module + */ +function loadModule(moduleName) { + var mod; + try { + mod = dynamicRequire(module, moduleName); + } + catch (e) { + // no-empty + } + try { + var cwd = dynamicRequire(module, 'process').cwd; + mod = dynamicRequire(module, cwd() + "/node_modules/" + moduleName); + } + catch (e) { + // no-empty + } + return mod; +} +//# sourceMappingURL=node.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/object.js": +/*!**************************************************!*\ + !*** ./node_modules/@sentry/utils/esm/object.js ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "fill": () => (/* binding */ fill), +/* harmony export */ "urlEncode": () => (/* binding */ urlEncode), +/* harmony export */ "normalizeToSize": () => (/* binding */ normalizeToSize), +/* harmony export */ "walk": () => (/* binding */ walk), +/* harmony export */ "normalize": () => (/* binding */ normalize), +/* harmony export */ "extractExceptionKeysForMessage": () => (/* binding */ extractExceptionKeysForMessage), +/* harmony export */ "dropUndefinedKeys": () => (/* binding */ dropUndefinedKeys) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _browser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./browser */ "./node_modules/@sentry/utils/esm/browser.js"); +/* harmony import */ var _is__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./is */ "./node_modules/@sentry/utils/esm/is.js"); +/* harmony import */ var _memo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./memo */ "./node_modules/@sentry/utils/esm/memo.js"); +/* harmony import */ var _stacktrace__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stacktrace */ "./node_modules/@sentry/utils/esm/stacktrace.js"); +/* harmony import */ var _string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./string */ "./node_modules/@sentry/utils/esm/string.js"); + + + + + + +/** + * Replace a method in an object with a wrapped version of itself. + * + * @param source An object that contains a method to be wrapped. + * @param name The name of the method to be wrapped. + * @param replacementFactory A higher-order function that takes the original version of the given method and returns a + * wrapped version. Note: The function returned by `replacementFactory` needs to be a non-arrow function, in order to + * preserve the correct value of `this`, and the original method must be called using `origMethod.call(this, )` or `origMethod.apply(this, [])` (rather than being called directly), again to preserve `this`. + * @returns void + */ +function fill(source, name, replacementFactory) { + if (!(name in source)) { + return; + } + var original = source[name]; + var wrapped = replacementFactory(original); + // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work + // otherwise it'll throw "TypeError: Object.defineProperties called on non-object" + if (typeof wrapped === 'function') { + try { + wrapped.prototype = wrapped.prototype || {}; + Object.defineProperties(wrapped, { + __sentry_original__: { + enumerable: false, + value: original, + }, + }); + } + catch (_Oo) { + // This can throw if multiple fill happens on a global object like XMLHttpRequest + // Fixes https://github.com/getsentry/sentry-javascript/issues/2043 + } + } + source[name] = wrapped; +} +/** + * Encodes given object into url-friendly format + * + * @param object An object that contains serializable values + * @returns string Encoded + */ +function urlEncode(object) { + return Object.keys(object) + .map(function (key) { return encodeURIComponent(key) + "=" + encodeURIComponent(object[key]); }) + .join('&'); +} +/** + * Transforms any object into an object literal with all its attributes + * attached to it. + * + * @param value Initial source that we have to transform in order for it to be usable by the serializer + */ +function getWalkSource(value) { + if ((0,_is__WEBPACK_IMPORTED_MODULE_0__.isError)(value)) { + var error = value; + var err = { + message: error.message, + name: error.name, + stack: error.stack, + }; + for (var i in error) { + if (Object.prototype.hasOwnProperty.call(error, i)) { + err[i] = error[i]; + } + } + return err; + } + if ((0,_is__WEBPACK_IMPORTED_MODULE_0__.isEvent)(value)) { + var event_1 = value; + var source = {}; + source.type = event_1.type; + // Accessing event.target can throw (see getsentry/raven-js#838, #768) + try { + source.target = (0,_is__WEBPACK_IMPORTED_MODULE_0__.isElement)(event_1.target) + ? (0,_browser__WEBPACK_IMPORTED_MODULE_1__.htmlTreeAsString)(event_1.target) + : Object.prototype.toString.call(event_1.target); + } + catch (_oO) { + source.target = ''; + } + try { + source.currentTarget = (0,_is__WEBPACK_IMPORTED_MODULE_0__.isElement)(event_1.currentTarget) + ? (0,_browser__WEBPACK_IMPORTED_MODULE_1__.htmlTreeAsString)(event_1.currentTarget) + : Object.prototype.toString.call(event_1.currentTarget); + } + catch (_oO) { + source.currentTarget = ''; + } + if (typeof CustomEvent !== 'undefined' && (0,_is__WEBPACK_IMPORTED_MODULE_0__.isInstanceOf)(value, CustomEvent)) { + source.detail = event_1.detail; + } + for (var i in event_1) { + if (Object.prototype.hasOwnProperty.call(event_1, i)) { + source[i] = event_1; + } + } + return source; + } + return value; +} +/** Calculates bytes size of input string */ +function utf8Length(value) { + // eslint-disable-next-line no-bitwise + return ~-encodeURI(value).split(/%..|./).length; +} +/** Calculates bytes size of input object */ +function jsonSize(value) { + return utf8Length(JSON.stringify(value)); +} +/** JSDoc */ +function normalizeToSize(object, +// Default Node.js REPL depth +depth, +// 100kB, as 200kB is max payload size, so half sounds reasonable +maxSize) { + if (depth === void 0) { depth = 3; } + if (maxSize === void 0) { maxSize = 100 * 1024; } + var serialized = normalize(object, depth); + if (jsonSize(serialized) > maxSize) { + return normalizeToSize(object, depth - 1, maxSize); + } + return serialized; +} +/** + * Transform any non-primitive, BigInt, or Symbol-type value into a string. Acts as a no-op on strings, numbers, + * booleans, null, and undefined. + * + * @param value The value to stringify + * @returns For non-primitive, BigInt, and Symbol-type values, a string denoting the value's type, type and value, or + * type and `description` property, respectively. For non-BigInt, non-Symbol primitives, returns the original value, + * unchanged. + */ +function serializeValue(value) { + var type = Object.prototype.toString.call(value); + // Node.js REPL notation + if (typeof value === 'string') { + return value; + } + if (type === '[object Object]') { + return '[Object]'; + } + if (type === '[object Array]') { + return '[Array]'; + } + var normalized = normalizeValue(value); + return (0,_is__WEBPACK_IMPORTED_MODULE_0__.isPrimitive)(normalized) ? normalized : type; +} +/** + * normalizeValue() + * + * Takes unserializable input and make it serializable friendly + * + * - translates undefined/NaN values to "[undefined]"/"[NaN]" respectively, + * - serializes Error objects + * - filter global objects + */ +function normalizeValue(value, key) { + if (key === 'domain' && value && typeof value === 'object' && value._events) { + return '[Domain]'; + } + if (key === 'domainEmitter') { + return '[DomainEmitter]'; + } + if (typeof __webpack_require__.g !== 'undefined' && value === __webpack_require__.g) { + return '[Global]'; + } + if (typeof window !== 'undefined' && value === window) { + return '[Window]'; + } + if (typeof document !== 'undefined' && value === document) { + return '[Document]'; + } + // React's SyntheticEvent thingy + if ((0,_is__WEBPACK_IMPORTED_MODULE_0__.isSyntheticEvent)(value)) { + return '[SyntheticEvent]'; + } + if (typeof value === 'number' && value !== value) { + return '[NaN]'; + } + if (value === void 0) { + return '[undefined]'; + } + if (typeof value === 'function') { + return "[Function: " + (0,_stacktrace__WEBPACK_IMPORTED_MODULE_2__.getFunctionName)(value) + "]"; + } + // symbols and bigints are considered primitives by TS, but aren't natively JSON-serilaizable + if (typeof value === 'symbol') { + return "[" + String(value) + "]"; + } + if (typeof value === 'bigint') { + return "[BigInt: " + String(value) + "]"; + } + return value; +} +/** + * Walks an object to perform a normalization on it + * + * @param key of object that's walked in current iteration + * @param value object to be walked + * @param depth Optional number indicating how deep should walking be performed + * @param memo Optional Memo class handling decycling + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function walk(key, value, depth, memo) { + if (depth === void 0) { depth = +Infinity; } + if (memo === void 0) { memo = new _memo__WEBPACK_IMPORTED_MODULE_3__.Memo(); } + // If we reach the maximum depth, serialize whatever has left + if (depth === 0) { + return serializeValue(value); + } + /* eslint-disable @typescript-eslint/no-unsafe-member-access */ + // If value implements `toJSON` method, call it and return early + if (value !== null && value !== undefined && typeof value.toJSON === 'function') { + return value.toJSON(); + } + /* eslint-enable @typescript-eslint/no-unsafe-member-access */ + // If normalized value is a primitive, there are no branches left to walk, so we can just bail out, as theres no point in going down that branch any further + var normalized = normalizeValue(value, key); + if ((0,_is__WEBPACK_IMPORTED_MODULE_0__.isPrimitive)(normalized)) { + return normalized; + } + // Create source that we will use for next itterations, either objectified error object (Error type with extracted keys:value pairs) or the input itself + var source = getWalkSource(value); + // Create an accumulator that will act as a parent for all future itterations of that branch + var acc = Array.isArray(value) ? [] : {}; + // If we already walked that branch, bail out, as it's circular reference + if (memo.memoize(value)) { + return '[Circular ~]'; + } + // Walk all keys of the source + for (var innerKey in source) { + // Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration. + if (!Object.prototype.hasOwnProperty.call(source, innerKey)) { + continue; + } + // Recursively walk through all the child nodes + acc[innerKey] = walk(innerKey, source[innerKey], depth - 1, memo); + } + // Once walked through all the branches, remove the parent from memo storage + memo.unmemoize(value); + // Return accumulated values + return acc; +} +/** + * normalize() + * + * - Creates a copy to prevent original input mutation + * - Skip non-enumerablers + * - Calls `toJSON` if implemented + * - Removes circular references + * - Translates non-serializeable values (undefined/NaN/Functions) to serializable format + * - Translates known global objects/Classes to a string representations + * - Takes care of Error objects serialization + * - Optionally limit depth of final output + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function normalize(input, depth) { + try { + return JSON.parse(JSON.stringify(input, function (key, value) { return walk(key, value, depth); })); + } + catch (_oO) { + return '**non-serializable**'; + } +} +/** + * Given any captured exception, extract its keys and create a sorted + * and truncated list that will be used inside the event message. + * eg. `Non-error exception captured with keys: foo, bar, baz` + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function extractExceptionKeysForMessage(exception, maxLength) { + if (maxLength === void 0) { maxLength = 40; } + var keys = Object.keys(getWalkSource(exception)); + keys.sort(); + if (!keys.length) { + return '[object has no keys]'; + } + if (keys[0].length >= maxLength) { + return (0,_string__WEBPACK_IMPORTED_MODULE_4__.truncate)(keys[0], maxLength); + } + for (var includedKeys = keys.length; includedKeys > 0; includedKeys--) { + var serialized = keys.slice(0, includedKeys).join(', '); + if (serialized.length > maxLength) { + continue; + } + if (includedKeys === keys.length) { + return serialized; + } + return (0,_string__WEBPACK_IMPORTED_MODULE_4__.truncate)(serialized, maxLength); + } + return ''; +} +/** + * Given any object, return the new object with removed keys that value was `undefined`. + * Works recursively on objects and arrays. + */ +function dropUndefinedKeys(val) { + var e_1, _a; + if ((0,_is__WEBPACK_IMPORTED_MODULE_0__.isPlainObject)(val)) { + var obj = val; + var rv = {}; + try { + for (var _b = (0,tslib__WEBPACK_IMPORTED_MODULE_5__.__values)(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + if (typeof obj[key] !== 'undefined') { + rv[key] = dropUndefinedKeys(obj[key]); + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + return rv; + } + if (Array.isArray(val)) { + return val.map(dropUndefinedKeys); + } + return val; +} +//# sourceMappingURL=object.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/polyfill.js": +/*!****************************************************!*\ + !*** ./node_modules/@sentry/utils/esm/polyfill.js ***! + \****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "setPrototypeOf": () => (/* binding */ setPrototypeOf) +/* harmony export */ }); +var setPrototypeOf = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties); +/** + * setPrototypeOf polyfill using __proto__ + */ +// eslint-disable-next-line @typescript-eslint/ban-types +function setProtoOf(obj, proto) { + // @ts-ignore __proto__ does not exist on obj + obj.__proto__ = proto; + return obj; +} +/** + * setPrototypeOf polyfill using mixin + */ +// eslint-disable-next-line @typescript-eslint/ban-types +function mixinProperties(obj, proto) { + for (var prop in proto) { + // eslint-disable-next-line no-prototype-builtins + if (!obj.hasOwnProperty(prop)) { + // @ts-ignore typescript complains about indexing so we remove + obj[prop] = proto[prop]; + } + } + return obj; +} +//# sourceMappingURL=polyfill.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/promisebuffer.js": +/*!*********************************************************!*\ + !*** ./node_modules/@sentry/utils/esm/promisebuffer.js ***! + \*********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "PromiseBuffer": () => (/* binding */ PromiseBuffer) +/* harmony export */ }); +/* harmony import */ var _error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./error */ "./node_modules/@sentry/utils/esm/error.js"); +/* harmony import */ var _syncpromise__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./syncpromise */ "./node_modules/@sentry/utils/esm/syncpromise.js"); + + +/** A simple queue that holds promises. */ +var PromiseBuffer = /** @class */ (function () { + function PromiseBuffer(_limit) { + this._limit = _limit; + /** Internal set of queued Promises */ + this._buffer = []; + } + /** + * Says if the buffer is ready to take more requests + */ + PromiseBuffer.prototype.isReady = function () { + return this._limit === undefined || this.length() < this._limit; + }; + /** + * Add a promise to the queue. + * + * @param taskProducer A function producing any PromiseLike; In previous versions this used to be `task: PromiseLike`, + * however, Promises were instantly created on the call-site, making them fall through the buffer limit. + * @returns The original promise. + */ + PromiseBuffer.prototype.add = function (taskProducer) { + var _this = this; + if (!this.isReady()) { + return _syncpromise__WEBPACK_IMPORTED_MODULE_0__.SyncPromise.reject(new _error__WEBPACK_IMPORTED_MODULE_1__.SentryError('Not adding Promise due to buffer limit reached.')); + } + var task = taskProducer(); + if (this._buffer.indexOf(task) === -1) { + this._buffer.push(task); + } + void task + .then(function () { return _this.remove(task); }) + .then(null, function () { + return _this.remove(task).then(null, function () { + // We have to add this catch here otherwise we have an unhandledPromiseRejection + // because it's a new Promise chain. + }); + }); + return task; + }; + /** + * Remove a promise to the queue. + * + * @param task Can be any PromiseLike + * @returns Removed promise. + */ + PromiseBuffer.prototype.remove = function (task) { + var removedTask = this._buffer.splice(this._buffer.indexOf(task), 1)[0]; + return removedTask; + }; + /** + * This function returns the number of unresolved promises in the queue. + */ + PromiseBuffer.prototype.length = function () { + return this._buffer.length; + }; + /** + * This will drain the whole queue, returns true if queue is empty or drained. + * If timeout is provided and the queue takes longer to drain, the promise still resolves but with false. + * + * @param timeout Number in ms to wait until it resolves with false. + */ + PromiseBuffer.prototype.drain = function (timeout) { + var _this = this; + return new _syncpromise__WEBPACK_IMPORTED_MODULE_0__.SyncPromise(function (resolve) { + var capturedSetTimeout = setTimeout(function () { + if (timeout && timeout > 0) { + resolve(false); + } + }, timeout); + void _syncpromise__WEBPACK_IMPORTED_MODULE_0__.SyncPromise.all(_this._buffer) + .then(function () { + clearTimeout(capturedSetTimeout); + resolve(true); + }) + .then(null, function () { + resolve(true); + }); + }); + }; + return PromiseBuffer; +}()); + +//# sourceMappingURL=promisebuffer.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/stacktrace.js": +/*!******************************************************!*\ + !*** ./node_modules/@sentry/utils/esm/stacktrace.js ***! + \******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getFunctionName": () => (/* binding */ getFunctionName) +/* harmony export */ }); +var defaultFunctionName = ''; +/** + * Safely extract function name from itself + */ +function getFunctionName(fn) { + try { + if (!fn || typeof fn !== 'function') { + return defaultFunctionName; + } + return fn.name || defaultFunctionName; + } + catch (e) { + // Just accessing custom props in some Selenium environments + // can cause a "Permission denied" exception (see raven-js#495). + return defaultFunctionName; + } +} +//# sourceMappingURL=stacktrace.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/string.js": +/*!**************************************************!*\ + !*** ./node_modules/@sentry/utils/esm/string.js ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "truncate": () => (/* binding */ truncate), +/* harmony export */ "snipLine": () => (/* binding */ snipLine), +/* harmony export */ "safeJoin": () => (/* binding */ safeJoin), +/* harmony export */ "isMatchingPattern": () => (/* binding */ isMatchingPattern) +/* harmony export */ }); +/* harmony import */ var _is__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./is */ "./node_modules/@sentry/utils/esm/is.js"); + +/** + * Truncates given string to the maximum characters count + * + * @param str An object that contains serializable values + * @param max Maximum number of characters in truncated string (0 = unlimited) + * @returns string Encoded + */ +function truncate(str, max) { + if (max === void 0) { max = 0; } + if (typeof str !== 'string' || max === 0) { + return str; + } + return str.length <= max ? str : str.substr(0, max) + "..."; +} +/** + * This is basically just `trim_line` from + * https://github.com/getsentry/sentry/blob/master/src/sentry/lang/javascript/processor.py#L67 + * + * @param str An object that contains serializable values + * @param max Maximum number of characters in truncated string + * @returns string Encoded + */ +function snipLine(line, colno) { + var newLine = line; + var ll = newLine.length; + if (ll <= 150) { + return newLine; + } + if (colno > ll) { + // eslint-disable-next-line no-param-reassign + colno = ll; + } + var start = Math.max(colno - 60, 0); + if (start < 5) { + start = 0; + } + var end = Math.min(start + 140, ll); + if (end > ll - 5) { + end = ll; + } + if (end === ll) { + start = Math.max(end - 140, 0); + } + newLine = newLine.slice(start, end); + if (start > 0) { + newLine = "'{snip} " + newLine; + } + if (end < ll) { + newLine += ' {snip}'; + } + return newLine; +} +/** + * Join values in array + * @param input array of values to be joined together + * @param delimiter string to be placed in-between values + * @returns Joined values + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function safeJoin(input, delimiter) { + if (!Array.isArray(input)) { + return ''; + } + var output = []; + // eslint-disable-next-line @typescript-eslint/prefer-for-of + for (var i = 0; i < input.length; i++) { + var value = input[i]; + try { + output.push(String(value)); + } + catch (e) { + output.push('[value cannot be serialized]'); + } + } + return output.join(delimiter); +} +/** + * Checks if the value matches a regex or includes the string + * @param value The string value to be checked against + * @param pattern Either a regex or a string that must be contained in value + */ +function isMatchingPattern(value, pattern) { + if (!(0,_is__WEBPACK_IMPORTED_MODULE_0__.isString)(value)) { + return false; + } + if ((0,_is__WEBPACK_IMPORTED_MODULE_0__.isRegExp)(pattern)) { + return pattern.test(value); + } + if (typeof pattern === 'string') { + return value.indexOf(pattern) !== -1; + } + return false; +} +//# sourceMappingURL=string.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/supports.js": +/*!****************************************************!*\ + !*** ./node_modules/@sentry/utils/esm/supports.js ***! + \****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "supportsErrorEvent": () => (/* binding */ supportsErrorEvent), +/* harmony export */ "supportsDOMError": () => (/* binding */ supportsDOMError), +/* harmony export */ "supportsDOMException": () => (/* binding */ supportsDOMException), +/* harmony export */ "supportsFetch": () => (/* binding */ supportsFetch), +/* harmony export */ "isNativeFetch": () => (/* binding */ isNativeFetch), +/* harmony export */ "supportsNativeFetch": () => (/* binding */ supportsNativeFetch), +/* harmony export */ "supportsReportingObserver": () => (/* binding */ supportsReportingObserver), +/* harmony export */ "supportsReferrerPolicy": () => (/* binding */ supportsReferrerPolicy), +/* harmony export */ "supportsHistory": () => (/* binding */ supportsHistory) +/* harmony export */ }); +/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./logger */ "./node_modules/@sentry/utils/esm/logger.js"); +/* harmony import */ var _misc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./misc */ "./node_modules/@sentry/utils/esm/misc.js"); + + +/** + * Tells whether current environment supports ErrorEvent objects + * {@link supportsErrorEvent}. + * + * @returns Answer to the given question. + */ +function supportsErrorEvent() { + try { + new ErrorEvent(''); + return true; + } + catch (e) { + return false; + } +} +/** + * Tells whether current environment supports DOMError objects + * {@link supportsDOMError}. + * + * @returns Answer to the given question. + */ +function supportsDOMError() { + try { + // Chrome: VM89:1 Uncaught TypeError: Failed to construct 'DOMError': + // 1 argument required, but only 0 present. + // @ts-ignore It really needs 1 argument, not 0. + new DOMError(''); + return true; + } + catch (e) { + return false; + } +} +/** + * Tells whether current environment supports DOMException objects + * {@link supportsDOMException}. + * + * @returns Answer to the given question. + */ +function supportsDOMException() { + try { + new DOMException(''); + return true; + } + catch (e) { + return false; + } +} +/** + * Tells whether current environment supports Fetch API + * {@link supportsFetch}. + * + * @returns Answer to the given question. + */ +function supportsFetch() { + if (!('fetch' in (0,_misc__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)())) { + return false; + } + try { + new Headers(); + new Request(''); + new Response(); + return true; + } + catch (e) { + return false; + } +} +/** + * isNativeFetch checks if the given function is a native implementation of fetch() + */ +// eslint-disable-next-line @typescript-eslint/ban-types +function isNativeFetch(func) { + return func && /^function fetch\(\)\s+\{\s+\[native code\]\s+\}$/.test(func.toString()); +} +/** + * Tells whether current environment supports Fetch API natively + * {@link supportsNativeFetch}. + * + * @returns true if `window.fetch` is natively implemented, false otherwise + */ +function supportsNativeFetch() { + if (!supportsFetch()) { + return false; + } + var global = (0,_misc__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)(); + // Fast path to avoid DOM I/O + // eslint-disable-next-line @typescript-eslint/unbound-method + if (isNativeFetch(global.fetch)) { + return true; + } + // window.fetch is implemented, but is polyfilled or already wrapped (e.g: by a chrome extension) + // so create a "pure" iframe to see if that has native fetch + var result = false; + var doc = global.document; + // eslint-disable-next-line deprecation/deprecation + if (doc && typeof doc.createElement === "function") { + try { + var sandbox = doc.createElement('iframe'); + sandbox.hidden = true; + doc.head.appendChild(sandbox); + if (sandbox.contentWindow && sandbox.contentWindow.fetch) { + // eslint-disable-next-line @typescript-eslint/unbound-method + result = isNativeFetch(sandbox.contentWindow.fetch); + } + doc.head.removeChild(sandbox); + } + catch (err) { + _logger__WEBPACK_IMPORTED_MODULE_1__.logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', err); + } + } + return result; +} +/** + * Tells whether current environment supports ReportingObserver API + * {@link supportsReportingObserver}. + * + * @returns Answer to the given question. + */ +function supportsReportingObserver() { + return 'ReportingObserver' in (0,_misc__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)(); +} +/** + * Tells whether current environment supports Referrer Policy API + * {@link supportsReferrerPolicy}. + * + * @returns Answer to the given question. + */ +function supportsReferrerPolicy() { + // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default + // https://caniuse.com/#feat=referrer-policy + // It doesn't. And it throw exception instead of ignoring this parameter... + // REF: https://github.com/getsentry/raven-js/issues/1233 + if (!supportsFetch()) { + return false; + } + try { + new Request('_', { + referrerPolicy: 'origin', + }); + return true; + } + catch (e) { + return false; + } +} +/** + * Tells whether current environment supports History API + * {@link supportsHistory}. + * + * @returns Answer to the given question. + */ +function supportsHistory() { + // NOTE: in Chrome App environment, touching history.pushState, *even inside + // a try/catch block*, will cause Chrome to output an error to console.error + // borrowed from: https://github.com/angular/angular.js/pull/13945/files + var global = (0,_misc__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)(); + /* eslint-disable @typescript-eslint/no-unsafe-member-access */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + var chrome = global.chrome; + var isChromePackagedApp = chrome && chrome.app && chrome.app.runtime; + /* eslint-enable @typescript-eslint/no-unsafe-member-access */ + var hasHistoryApi = 'history' in global && !!global.history.pushState && !!global.history.replaceState; + return !isChromePackagedApp && hasHistoryApi; +} +//# sourceMappingURL=supports.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/syncpromise.js": +/*!*******************************************************!*\ + !*** ./node_modules/@sentry/utils/esm/syncpromise.js ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SyncPromise": () => (/* binding */ SyncPromise) +/* harmony export */ }); +/* harmony import */ var _is__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./is */ "./node_modules/@sentry/utils/esm/is.js"); +/* eslint-disable @typescript-eslint/explicit-function-return-type */ +/* eslint-disable @typescript-eslint/typedef */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +/** SyncPromise internal states */ +var States; +(function (States) { + /** Pending */ + States["PENDING"] = "PENDING"; + /** Resolved / OK */ + States["RESOLVED"] = "RESOLVED"; + /** Rejected / Error */ + States["REJECTED"] = "REJECTED"; +})(States || (States = {})); +/** + * Thenable class that behaves like a Promise and follows it's interface + * but is not async internally + */ +var SyncPromise = /** @class */ (function () { + function SyncPromise(executor) { + var _this = this; + this._state = States.PENDING; + this._handlers = []; + /** JSDoc */ + this._resolve = function (value) { + _this._setResult(States.RESOLVED, value); + }; + /** JSDoc */ + this._reject = function (reason) { + _this._setResult(States.REJECTED, reason); + }; + /** JSDoc */ + this._setResult = function (state, value) { + if (_this._state !== States.PENDING) { + return; + } + if ((0,_is__WEBPACK_IMPORTED_MODULE_0__.isThenable)(value)) { + void value.then(_this._resolve, _this._reject); + return; + } + _this._state = state; + _this._value = value; + _this._executeHandlers(); + }; + // TODO: FIXME + /** JSDoc */ + this._attachHandler = function (handler) { + _this._handlers = _this._handlers.concat(handler); + _this._executeHandlers(); + }; + /** JSDoc */ + this._executeHandlers = function () { + if (_this._state === States.PENDING) { + return; + } + var cachedHandlers = _this._handlers.slice(); + _this._handlers = []; + cachedHandlers.forEach(function (handler) { + if (handler.done) { + return; + } + if (_this._state === States.RESOLVED) { + if (handler.onfulfilled) { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + handler.onfulfilled(_this._value); + } + } + if (_this._state === States.REJECTED) { + if (handler.onrejected) { + handler.onrejected(_this._value); + } + } + handler.done = true; + }); + }; + try { + executor(this._resolve, this._reject); + } + catch (e) { + this._reject(e); + } + } + /** JSDoc */ + SyncPromise.resolve = function (value) { + return new SyncPromise(function (resolve) { + resolve(value); + }); + }; + /** JSDoc */ + SyncPromise.reject = function (reason) { + return new SyncPromise(function (_, reject) { + reject(reason); + }); + }; + /** JSDoc */ + SyncPromise.all = function (collection) { + return new SyncPromise(function (resolve, reject) { + if (!Array.isArray(collection)) { + reject(new TypeError("Promise.all requires an array as input.")); + return; + } + if (collection.length === 0) { + resolve([]); + return; + } + var counter = collection.length; + var resolvedCollection = []; + collection.forEach(function (item, index) { + void SyncPromise.resolve(item) + .then(function (value) { + resolvedCollection[index] = value; + counter -= 1; + if (counter !== 0) { + return; + } + resolve(resolvedCollection); + }) + .then(null, reject); + }); + }); + }; + /** JSDoc */ + SyncPromise.prototype.then = function (onfulfilled, onrejected) { + var _this = this; + return new SyncPromise(function (resolve, reject) { + _this._attachHandler({ + done: false, + onfulfilled: function (result) { + if (!onfulfilled) { + // TODO: ¯\_(ツ)_/¯ + // TODO: FIXME + resolve(result); + return; + } + try { + resolve(onfulfilled(result)); + return; + } + catch (e) { + reject(e); + return; + } + }, + onrejected: function (reason) { + if (!onrejected) { + reject(reason); + return; + } + try { + resolve(onrejected(reason)); + return; + } + catch (e) { + reject(e); + return; + } + }, + }); + }); + }; + /** JSDoc */ + SyncPromise.prototype.catch = function (onrejected) { + return this.then(function (val) { return val; }, onrejected); + }; + /** JSDoc */ + SyncPromise.prototype.finally = function (onfinally) { + var _this = this; + return new SyncPromise(function (resolve, reject) { + var val; + var isRejected; + return _this.then(function (value) { + isRejected = false; + val = value; + if (onfinally) { + onfinally(); + } + }, function (reason) { + isRejected = true; + val = reason; + if (onfinally) { + onfinally(); + } + }).then(function () { + if (isRejected) { + reject(val); + return; + } + resolve(val); + }); + }); + }; + /** JSDoc */ + SyncPromise.prototype.toString = function () { + return '[object SyncPromise]'; + }; + return SyncPromise; +}()); + +//# sourceMappingURL=syncpromise.js.map + +/***/ }), + +/***/ "./node_modules/@sentry/utils/esm/time.js": +/*!************************************************!*\ + !*** ./node_modules/@sentry/utils/esm/time.js ***! + \************************************************/ +/***/ ((module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "dateTimestampInSeconds": () => (/* binding */ dateTimestampInSeconds), +/* harmony export */ "timestampInSeconds": () => (/* binding */ timestampInSeconds), +/* harmony export */ "timestampWithMs": () => (/* binding */ timestampWithMs), +/* harmony export */ "usingPerformanceAPI": () => (/* binding */ usingPerformanceAPI), +/* harmony export */ "_browserPerformanceTimeOriginMode": () => (/* binding */ _browserPerformanceTimeOriginMode), +/* harmony export */ "browserPerformanceTimeOrigin": () => (/* binding */ browserPerformanceTimeOrigin) +/* harmony export */ }); +/* harmony import */ var _misc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./misc */ "./node_modules/@sentry/utils/esm/misc.js"); +/* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node */ "./node_modules/@sentry/utils/esm/node.js"); +/* module decorator */ module = __webpack_require__.hmd(module); + + +/** + * A TimestampSource implementation for environments that do not support the Performance Web API natively. + * + * Note that this TimestampSource does not use a monotonic clock. A call to `nowSeconds` may return a timestamp earlier + * than a previously returned value. We do not try to emulate a monotonic behavior in order to facilitate debugging. It + * is more obvious to explain "why does my span have negative duration" than "why my spans have zero duration". + */ +var dateTimestampSource = { + nowSeconds: function () { return Date.now() / 1000; }, +}; +/** + * Returns a wrapper around the native Performance API browser implementation, or undefined for browsers that do not + * support the API. + * + * Wrapping the native API works around differences in behavior from different browsers. + */ +function getBrowserPerformance() { + var performance = (0,_misc__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)().performance; + if (!performance || !performance.now) { + return undefined; + } + // Replace performance.timeOrigin with our own timeOrigin based on Date.now(). + // + // This is a partial workaround for browsers reporting performance.timeOrigin such that performance.timeOrigin + + // performance.now() gives a date arbitrarily in the past. + // + // Additionally, computing timeOrigin in this way fills the gap for browsers where performance.timeOrigin is + // undefined. + // + // The assumption that performance.timeOrigin + performance.now() ~= Date.now() is flawed, but we depend on it to + // interact with data coming out of performance entries. + // + // Note that despite recommendations against it in the spec, browsers implement the Performance API with a clock that + // might stop when the computer is asleep (and perhaps under other circumstances). Such behavior causes + // performance.timeOrigin + performance.now() to have an arbitrary skew over Date.now(). In laptop computers, we have + // observed skews that can be as long as days, weeks or months. + // + // See https://github.com/getsentry/sentry-javascript/issues/2590. + // + // BUG: despite our best intentions, this workaround has its limitations. It mostly addresses timings of pageload + // transactions, but ignores the skew built up over time that can aversely affect timestamps of navigation + // transactions of long-lived web pages. + var timeOrigin = Date.now() - performance.now(); + return { + now: function () { return performance.now(); }, + timeOrigin: timeOrigin, + }; +} +/** + * Returns the native Performance API implementation from Node.js. Returns undefined in old Node.js versions that don't + * implement the API. + */ +function getNodePerformance() { + try { + var perfHooks = (0,_node__WEBPACK_IMPORTED_MODULE_1__.dynamicRequire)(module, 'perf_hooks'); + return perfHooks.performance; + } + catch (_) { + return undefined; + } +} +/** + * The Performance API implementation for the current platform, if available. + */ +var platformPerformance = (0,_node__WEBPACK_IMPORTED_MODULE_1__.isNodeEnv)() ? getNodePerformance() : getBrowserPerformance(); +var timestampSource = platformPerformance === undefined + ? dateTimestampSource + : { + nowSeconds: function () { return (platformPerformance.timeOrigin + platformPerformance.now()) / 1000; }, + }; +/** + * Returns a timestamp in seconds since the UNIX epoch using the Date API. + */ +var dateTimestampInSeconds = dateTimestampSource.nowSeconds.bind(dateTimestampSource); +/** + * Returns a timestamp in seconds since the UNIX epoch using either the Performance or Date APIs, depending on the + * availability of the Performance API. + * + * See `usingPerformanceAPI` to test whether the Performance API is used. + * + * BUG: Note that because of how browsers implement the Performance API, the clock might stop when the computer is + * asleep. This creates a skew between `dateTimestampInSeconds` and `timestampInSeconds`. The + * skew can grow to arbitrary amounts like days, weeks or months. + * See https://github.com/getsentry/sentry-javascript/issues/2590. + */ +var timestampInSeconds = timestampSource.nowSeconds.bind(timestampSource); +// Re-exported with an old name for backwards-compatibility. +var timestampWithMs = timestampInSeconds; +/** + * A boolean that is true when timestampInSeconds uses the Performance API to produce monotonic timestamps. + */ +var usingPerformanceAPI = platformPerformance !== undefined; +/** + * Internal helper to store what is the source of browserPerformanceTimeOrigin below. For debugging only. + */ +var _browserPerformanceTimeOriginMode; +/** + * The number of milliseconds since the UNIX epoch. This value is only usable in a browser, and only when the + * performance API is available. + */ +var browserPerformanceTimeOrigin = (function () { + // Unfortunately browsers may report an inaccurate time origin data, through either performance.timeOrigin or + // performance.timing.navigationStart, which results in poor results in performance data. We only treat time origin + // data as reliable if they are within a reasonable threshold of the current time. + var performance = (0,_misc__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)().performance; + if (!performance || !performance.now) { + _browserPerformanceTimeOriginMode = 'none'; + return undefined; + } + var threshold = 3600 * 1000; + var performanceNow = performance.now(); + var dateNow = Date.now(); + // if timeOrigin isn't available set delta to threshold so it isn't used + var timeOriginDelta = performance.timeOrigin + ? Math.abs(performance.timeOrigin + performanceNow - dateNow) + : threshold; + var timeOriginIsReliable = timeOriginDelta < threshold; + // While performance.timing.navigationStart is deprecated in favor of performance.timeOrigin, performance.timeOrigin + // is not as widely supported. Namely, performance.timeOrigin is undefined in Safari as of writing. + // Also as of writing, performance.timing is not available in Web Workers in mainstream browsers, so it is not always + // a valid fallback. In the absence of an initial time provided by the browser, fallback to the current time from the + // Date API. + // eslint-disable-next-line deprecation/deprecation + var navigationStart = performance.timing && performance.timing.navigationStart; + var hasNavigationStart = typeof navigationStart === 'number'; + // if navigationStart isn't available set delta to threshold so it isn't used + var navigationStartDelta = hasNavigationStart ? Math.abs(navigationStart + performanceNow - dateNow) : threshold; + var navigationStartIsReliable = navigationStartDelta < threshold; + if (timeOriginIsReliable || navigationStartIsReliable) { + // Use the more reliable time origin + if (timeOriginDelta <= navigationStartDelta) { + _browserPerformanceTimeOriginMode = 'timeOrigin'; + return performance.timeOrigin; + } + else { + _browserPerformanceTimeOriginMode = 'navigationStart'; + return navigationStart; + } + } + // Either both timeOrigin and navigationStart are skewed or neither is available, fallback to Date. + _browserPerformanceTimeOriginMode = 'dateNow'; + return dateNow; +})(); +//# sourceMappingURL=time.js.map + +/***/ }), + +/***/ "./src/assets/icons/all-projects.svg": +/*!*******************************************!*\ + !*** ./src/assets/icons/all-projects.svg ***! + \*******************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M4 13c0-2.828 0-4.243.879-5.121C5.757 7 7.172 7 10 7h6c2.828 0 4.243 0 5.121.879C22 8.757 22 10.172 22 13v2c0 2.828 0 4.243-.879 5.121C20.243 21 18.828 21 16 21h-6c-2.828 0-4.243 0-5.121-.879C4 19.243 4 17.828 4 15v-2z", + fill: "#fff" +}); + +var _ref2 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M21.5 13v2c0 1.428-.001 2.45-.105 3.225-.103.762-.296 1.212-.627 1.543-.331.33-.781.524-1.543.627-.776.104-1.797.105-3.225.105h-6c-1.428 0-2.45-.001-3.225-.105-.762-.103-1.212-.296-1.543-.627-.33-.331-.524-.781-.627-1.543C4.501 17.45 4.5 16.428 4.5 15v-2c0-1.428.001-2.45.105-3.225.103-.762.296-1.212.627-1.543.331-.33.781-.524 1.543-.627C7.55 7.501 8.572 7.5 10 7.5h6c1.428 0 2.45.001 3.225.105.762.103 1.212.296 1.543.627.33.331.524.781.627 1.543.104.776.105 1.797.105 3.225z", + stroke: "#000", + strokeOpacity: 0.15 +}); + +var _ref3 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M2 11c0-2.828 0-4.243.879-5.121C3.757 5 5.172 5 8 5h6c2.828 0 4.243 0 5.121.879C20 6.757 20 8.172 20 11v2c0 2.828 0 4.243-.879 5.121C18.243 19 16.828 19 14 19H8c-2.828 0-4.243 0-5.121-.879C2 17.243 2 15.828 2 13v-2z", + fill: "#fff" +}); + +var _ref4 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M19.5 11v2c0 1.428-.001 2.45-.105 3.225-.103.762-.296 1.212-.627 1.543-.331.33-.781.524-1.543.627-.776.104-1.797.105-3.225.105H8c-1.428 0-2.45-.001-3.225-.105-.762-.103-1.212-.296-1.543-.627-.33-.331-.524-.781-.627-1.543C2.501 15.45 2.5 14.428 2.5 13v-2c0-1.428.001-2.45.105-3.225.103-.762.296-1.212.627-1.543.331-.33.781-.524 1.543-.627C5.55 5.501 6.572 5.5 8 5.5h6c1.428 0 2.45.001 3.225.105.762.103 1.212.296 1.543.627.33.331.524.781.627 1.543.104.776.105 1.797.105 3.225z", + stroke: "#000", + strokeOpacity: 0.15 +}); + +var _ref5 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M0 5.211c0-2.07 0-3.104.489-3.852a3 3 0 01.87-.87C2.107 0 3.14 0 5.21 0h.986c.192 0 .288 0 .378.005a3 3 0 012.21 1.183c.055.073.109.152.215.312s.16.24.214.312a3 3 0 002.21 1.183c.091.005.187.005.379.005h.986c2.07 0 3.104 0 3.852.489a3 3 0 01.87.87C18 5.107 18 6.14 18 8.21V11c0 2.828 0 4.243-.879 5.121C16.243 17 14.828 17 12 17H6c-2.828 0-4.243 0-5.121-.879C0 15.243 0 13.828 0 11V5.211z", + fill: "#fff" +}); + +var _ref6 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M17.5 8.211V11c0 1.428-.001 2.45-.105 3.225-.103.762-.296 1.212-.627 1.543-.331.33-.781.524-1.543.627-.776.104-1.797.105-3.225.105H6c-1.428 0-2.45-.001-3.225-.105-.762-.103-1.212-.296-1.543-.627-.33-.331-.524-.781-.627-1.543C.501 13.45.5 12.428.5 11V5.211C.5 4.166.5 3.42.559 2.84c.057-.572.166-.928.348-1.207a2.5 2.5 0 01.725-.725C1.912.725 2.267.616 2.84.56 3.419.5 4.166.5 5.211.5h.986c.198 0 .276 0 .348.005a2.5 2.5 0 011.842.985c.044.058.087.123.197.287l.01.015c.097.146.158.237.222.322a3.5 3.5 0 002.578 1.38c.106.006.216.006.392.006h1.003c1.045 0 1.792 0 2.372.059.572.057.928.166 1.207.348a2.5 2.5 0 01.725.725c.182.28.291.635.348 1.207.058.58.059 1.327.059 2.372z", + stroke: "#000", + strokeOpacity: 0.15 +}); + +function SvgAllProjects(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + viewBox: "0 0 22 21", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref, _ref2, _ref3, _ref4, _ref5, _ref6); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgAllProjects); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/bell.svg": +/*!***********************************!*\ + !*** ./src/assets/icons/bell.svg ***! + \***********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M9 0a1.5 1.5 0 00-1.5 1.5V5h3V1.5A1.5 1.5 0 009 0zm0 20c1.38 0 2.5-1.343 2.5-3s-1.12-3-2.5-3-2.5 1.343-2.5 3 1.12 3 2.5 3z", + fill: "#07F", + fillOpacity: 0.5 +}); + +var _ref2 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M.5 14a1.172 1.172 0 00.828 2h15.344a1.172 1.172 0 00.828-2c-1.521-1.521-2.161-.232-2.5-5-.315-4.433-2-6.5-6-6.5S3.32 4.592 3 9c-.346 4.764-.97 3.47-2.5 5z", + fill: "#07F" +}); + +function SvgBell(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 18, + height: 20, + viewBox: "0 0 18 20", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref, _ref2); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgBell); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/book.svg": +/*!***********************************!*\ + !*** ./src/assets/icons/book.svg ***! + \***********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M0 2.992c0-1.023 0-1.535.211-1.89a1.5 1.5 0 01.82-.657c.392-.129.891-.018 1.89.204l5.038 1.12c.388.086.583.13.779.146a3 3 0 00.524 0c.196-.017.39-.06.78-.146l5.037-1.12c.999-.222 1.498-.333 1.89-.204a1.5 1.5 0 01.82.658c.211.354.211.866.211 1.889v9.441c0 .916 0 1.374-.162 1.752a2.001 2.001 0 01-.669.833c-.334.24-.78.34-1.675.539l-5.106 1.135c-.518.115-.777.172-1.039.195-.232.02-.466.02-.698 0-.262-.023-.521-.08-1.04-.195l-5.105-1.135c-.894-.199-1.341-.298-1.675-.539a2 2 0 01-.669-.833C0 13.807 0 13.349 0 12.433V2.992z", + fill: "#000", + fillOpacity: 0.4 +}); + +var _ref2 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("mask", { + id: "book_svg__a", + maskUnits: "userSpaceOnUse", + x: 0, + y: 0, + width: 18, + height: 17 +}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M0 2.992c0-1.023 0-1.535.211-1.89a1.5 1.5 0 01.82-.657c.392-.129.891-.018 1.89.204l5.038 1.12c.388.086.583.13.779.146a3 3 0 00.524 0c.196-.017.39-.06.78-.146l5.037-1.12c.999-.222 1.498-.333 1.89-.204a1.5 1.5 0 01.82.658c.211.354.211.866.211 1.889v9.441c0 .916 0 1.374-.162 1.752a2.001 2.001 0 01-.669.833c-.334.24-.78.34-1.675.539l-5.106 1.135c-.518.115-.777.172-1.039.195-.232.02-.466.02-.698 0-.262-.023-.521-.08-1.04-.195l-5.105-1.135c-.894-.199-1.341-.298-1.675-.539a2 2 0 01-.669-.833C0 13.807 0 13.349 0 12.433V2.992z", + fill: "#fff" +})); + +var _ref3 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("g", { + mask: "url(#book_svg__a)", + fill: "#000" +}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M10-1h9v19h-9zM-1-1h9v19h-9z" +})); + +function SvgBook(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 18, + height: 17, + viewBox: "0 0 18 17", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref, _ref2, _ref3); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgBook); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/bulb.svg": +/*!***********************************!*\ + !*** ./src/assets/icons/bulb.svg ***! + \***********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + opacity: 0.9, + d: "M4 11h2M3 8c0-2-1.5-2.5-1.5-4s1-3 3.5-3 3.5 1.5 3.5 3S7 6 7 8", + stroke: "currentColor", + strokeWidth: 2, + strokeLinecap: "square" +}); + +function SvgBulb(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 10, + height: 12, + viewBox: "0 0 10 12", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgBulb); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/check.svg": +/*!************************************!*\ + !*** ./src/assets/icons/check.svg ***! + \************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M2 4l3 3 5-5", + stroke: "currentColor", + strokeWidth: 2, + strokeLinecap: "square" +}); + +function SvgCheck(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 12, + height: 9, + viewBox: "0 0 12 9", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgCheck); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/chevron-left.svg": +/*!*******************************************!*\ + !*** ./src/assets/icons/chevron-left.svg ***! + \*******************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M10 2l-8 8 8 8", + stroke: "currentColor", + strokeWidth: 2, + strokeLinecap: "square" +}); + +function SvgChevronLeft(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 12, + height: 20, + viewBox: "0 0 12 20", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgChevronLeft); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/chevron-right.svg": +/*!********************************************!*\ + !*** ./src/assets/icons/chevron-right.svg ***! + \********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M2 2l8 8-8 8", + stroke: "currentColor", + strokeWidth: 2, + strokeLinecap: "square" +}); + +function SvgChevronRight(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 12, + height: 20, + viewBox: "0 0 12 20", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgChevronRight); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/cross.svg": +/*!************************************!*\ + !*** ./src/assets/icons/cross.svg ***! + \************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M14 2L2 14M2 2l12 12", + stroke: "currentColor", + strokeWidth: 2, + strokeLinecap: "square" +}); + +function SvgCross(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 16, + height: 16, + viewBox: "0 0 16 16", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgCross); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/door.svg": +/*!***********************************!*\ + !*** ./src/assets/icons/door.svg ***! + \***********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M.163.819C0 1.139 0 1.559 0 2.4v13.2c0 .84 0 1.26.163 1.581a1.5 1.5 0 00.656.655c.32.164.74.164 1.581.164h9.2c.84 0 1.26 0 1.581-.163a1.5 1.5 0 00.655-.656c.164-.32.164-.74.164-1.581V2.4c0-.84 0-1.26-.164-1.581a1.5 1.5 0 00-.655-.656C12.861 0 12.441 0 11.6 0H2.4C1.56 0 1.14 0 .819.163A1.5 1.5 0 00.163.82zM10 11a2 2 0 100-4 2 2 0 000 4z", + fill: "#000" +}); + +function SvgDoor(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 14, + height: 18, + viewBox: "0 0 14 18", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgDoor); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/ellipsis.svg": +/*!***************************************!*\ + !*** ./src/assets/icons/ellipsis.svg ***! + \***************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M2 7a2 2 0 100 4 2 2 0 000-4zm5 2a2 2 0 114 0 2 2 0 01-4 0zm7 0a2 2 0 114 0 2 2 0 01-4 0z", + fill: "currentColor" +}); + +function SvgEllipsis(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 18, + height: 18, + viewBox: "0 0 18 18", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgEllipsis); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/error.svg": +/*!************************************!*\ + !*** ./src/assets/icons/error.svg ***! + \************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M13.348 10.313c.433.75-.11 1.687-.974 1.687H1.126a1.126 1.126 0 01-.974-1.687L5.776.563a1.126 1.126 0 011.948 0l5.624 9.75zM6.75 8.297a1.078 1.078 0 100 2.156 1.078 1.078 0 000-2.156zM5.726 4.422L5.9 7.609c.008.15.132.266.281.266H7.32c.15 0 .273-.117.28-.266l.175-3.187a.281.281 0 00-.281-.297H6.007a.281.281 0 00-.28.297z", + fill: "#F5222D" +}); + +function SvgError(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 14, + height: 12, + viewBox: "0 0 14 12", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgError); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/folder-empty.svg": +/*!*******************************************!*\ + !*** ./src/assets/icons/folder-empty.svg ***! + \*******************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M.5 5.862c0-1.36.001-2.333.096-3.075.094-.73.272-1.165.574-1.49.04-.044.083-.086.127-.127.325-.302.76-.48 1.49-.574C3.529.501 4.502.5 5.862.5h1.335c.198 0 .276 0 .348.005a2.5 2.5 0 011.842.985l.399-.302-.399.302c.044.058.087.123.197.287l.01.015c.097.146.158.237.222.322a3.5 3.5 0 002.578 1.38c.106.006.216.006.392.006h1.351c1.361 0 2.334.001 3.076.096.73.094 1.165.272 1.49.574.044.04.086.083.127.127.302.325.48.76.574 1.49.095.742.096 1.715.096 3.075V12c0 1.428-.001 2.45-.105 3.225-.103.762-.296 1.212-.627 1.543-.331.33-.781.524-1.543.627-.776.104-1.797.105-3.225.105H6c-1.428 0-2.45-.001-3.225-.105-.762-.103-1.212-.296-1.543-.627-.33-.331-.524-.781-.627-1.543C.501 14.45.5 13.428.5 12V5.862z" +}); + +function SvgFolderEmpty(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + viewBox: "0 0 20 18", + fill: "currentColor", + stroke: "#000", + strokeOpacity: 0.15, + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgFolderEmpty); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/folder.svg": +/*!*************************************!*\ + !*** ./src/assets/icons/folder.svg ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M0 3.2c0-1.12 0-1.68.218-2.108a2 2 0 01.874-.874C1.52 0 2.08 0 3.2 0h2.4c.88 0 1.32 0 1.724.115a3 3 0 01.99.495c.334.254.598.606 1.126 1.31L11 4H0v-.8z", + fill: "#000", + fillOpacity: 0.4 +}); + +var _ref2 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M0 5.4c0-.84 0-1.26.163-1.581a1.5 1.5 0 01.656-.656C1.139 3 1.559 3 2.4 3h13.2c.84 0 1.26 0 1.581.163a1.5 1.5 0 01.655.656c.164.32.164.74.164 1.581v8.2c0 .84 0 1.26-.163 1.581a1.5 1.5 0 01-.656.655c-.32.164-.74.164-1.581.164H2.4c-.84 0-1.26 0-1.581-.164a1.5 1.5 0 01-.656-.655C0 14.861 0 14.441 0 13.6V5.4z", + fill: "#000" +}); + +function SvgFolder(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 18, + height: 16, + viewBox: "0 0 18 16", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref, _ref2); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgFolder); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/gear.svg": +/*!***********************************!*\ + !*** ./src/assets/icons/gear.svg ***! + \***********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("g", { + opacity: 0.23, + stroke: "#000", + strokeWidth: 2 +}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M2.152 10.264l19.696 3.473M21.397 8.58L2.603 15.42M18.428 4.34L5.572 19.66M8.58 2.603l6.84 18.794M4.34 5.572l15.32 12.856M13.736 2.152l-3.473 19.696", + strokeLinecap: "square" +}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("circle", { + cx: 12, + cy: 12, + r: 8, + transform: "rotate(10 12 12)", + fill: "#fff" +}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M12.02 11.993L2.602 15.42M12.026 12.022l7.634 6.406M13.736 2.152L12 12", + strokeLinecap: "square" +}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("circle", { + cx: 12, + cy: 12, + r: 2, + transform: "rotate(10 12 12)", + fill: "#fff" +})); + +function SvgGear(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 24, + height: 24, + viewBox: "0 0 24 24", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgGear); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/github.svg": +/*!*************************************!*\ + !*** ./src/assets/icons/github.svg ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("g", { + clipPath: "url(#github_svg__clip0)", + fill: "#231E1B" +}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M9 .223a9 9 0 00-2.845 17.54c.45.083.615-.196.615-.435 0-.214-.008-.924-.011-1.675-2.506.544-3.033-1.06-3.033-1.06-.41-1.041-.999-1.318-.999-1.318-.816-.559.061-.547.061-.547.904.064 1.38.927 1.38.927.804 1.375 2.106.978 2.619.748.08-.581.314-.98.57-1.204-1.998-.228-4.1-1-4.1-4.447 0-.982.353-1.786.928-2.416-.094-.227-.401-1.142.086-2.382 0 0 .756-.241 2.476.923.718-.2 1.487-.3 2.253-.303a8.624 8.624 0 012.255.303c1.718-1.164 2.472-.923 2.472-.923.49 1.24.182 2.155.088 2.382.577.63.926 1.434.926 2.416 0 3.456-2.106 4.217-4.11 4.44.324.28.612.828.612 1.667 0 1.204-.01 2.173-.01 2.47 0 .24.162.52.618.432A9 9 0 009 .223z" +}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M3.408 13.144c-.02.044-.091.058-.155.027-.066-.03-.101-.091-.08-.136.019-.046.089-.058.154-.028.066.03.103.092.08.137zM3.773 13.55c-.043.04-.127.02-.183-.042-.06-.063-.07-.146-.027-.186.045-.04.125-.021.185.042.058.062.07.146.025.186zM4.128 14.069c-.055.039-.146.003-.201-.078-.055-.08-.055-.175.001-.214.056-.039.145-.005.202.076.055.08.055.177-.002.216zM4.614 14.57c-.05.055-.155.04-.231-.034-.08-.073-.1-.176-.05-.23.05-.055.154-.038.232.035.077.071.1.175.049.229zM5.285 14.86c-.023.07-.124.104-.225.074-.102-.031-.169-.114-.148-.185.02-.072.122-.104.225-.073.103.031.168.113.148.185zM6.02 14.914c.004.075-.083.136-.19.138-.107.003-.195-.059-.195-.132 0-.074.085-.135.192-.137.106-.001.194.058.194.131zM6.706 14.798c.013.073-.061.146-.169.167-.104.02-.2-.025-.214-.097-.014-.074.062-.149.167-.168.107-.02.202.025.216.098z" +})); + +var _ref2 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("defs", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("clipPath", { + id: "github_svg__clip0" +}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + fill: "#fff", + transform: "translate(0 .223)", + d: "M0 0h18v17.554H0z" +}))); + +function SvgGithub(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 18, + height: 18, + viewBox: "0 0 18 18", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref, _ref2); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgGithub); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/info.svg": +/*!***********************************!*\ + !*** ./src/assets/icons/info.svg ***! + \***********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M16 2c2.702 0 5.158.655 7.232 1.828a13.01 13.01 0 014.94 4.94C29.345 10.842 30 13.298 30 16s-.655 5.158-1.828 7.232a13.01 13.01 0 01-4.94 4.94C21.158 29.345 18.702 30 16 30s-5.158-.655-7.232-1.828a13.01 13.01 0 01-4.94-4.94C2.655 21.158 2 18.702 2 16s.655-5.158 1.828-7.232a13.009 13.009 0 014.94-4.94C10.842 2.655 13.298 2 16 2z", + fill: "#09F" +}); + +var _ref2 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M16.501 12.5c.552 0 .98.456.957 1.002l-.416 9.995a1.053 1.053 0 01-.924.996L16 24.5a1.058 1.058 0 01-1.042-1.003l-.355-8.502c-.013-.273-.23-.595-.474-.712l-1.322-.635a.599.599 0 01-.307-.498V13c0-.276.23-.5.502-.5H16.5zM16 7.5a1.5 1.5 0 110 3 1.5 1.5 0 010-3z", + fill: "#fff" +}); + +function SvgInfo(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 32, + height: 32, + viewBox: "0 0 32 32", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref, _ref2); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgInfo); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/minus.svg": +/*!************************************!*\ + !*** ./src/assets/icons/minus.svg ***! + \************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + opacity: 0.9, + d: "M1 1h8", + stroke: "currentColor", + strokeWidth: 2, + strokeLinecap: "square" +}); + +function SvgMinus(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 10, + height: 2, + viewBox: "0 0 10 2", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgMinus); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/person-circle.svg": +/*!********************************************!*\ + !*** ./src/assets/icons/person-circle.svg ***! + \********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("mask", { + id: "person-circle_svg__a", + height: 20, + maskUnits: "userSpaceOnUse", + width: 20, + x: 0, + y: 0 +}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("circle", { + cx: 10, + cy: 10, + fill: "#fff", + r: 10 +})); + +var _ref2 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("circle", { + cx: 10, + cy: 10, + fill: "#000", + fillOpacity: 0.4, + r: 10 +}); + +var _ref3 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("g", { + mask: "url(#person-circle_svg__a)" +}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M3.605 17.411a3 3 0 011.32-2.198l2.183-1.454c.563-.376.608-1.204.153-1.705-.7-.77-1.515-1.912-1.515-3.054 0-2 .25-6 4.25-6s4.25 4 4.25 6c0 1.142-.815 2.284-1.515 3.054-.455.5-.41 1.33.153 1.705l2.182 1.454a3 3 0 011.321 2.198l.249 2.49A1 1 0 0115.641 21H4.351a1 1 0 01-.995-1.1z", + fill: "#000" +})); + +function SvgPersonCircle(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + fill: "none", + height: 20, + viewBox: "0 0 20 20", + width: 20, + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref, _ref2, _ref3); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgPersonCircle); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/pin.svg": +/*!**********************************!*\ + !*** ./src/assets/icons/pin.svg ***! + \**********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("g", { + fillRule: "evenodd", + clipRule: "evenodd", + fill: "#000" +}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M5.08 11.074c.2-.234.3-.351.406-.425a1 1 0 011.076-.04c.11.064.22.173.438.391.218.218.327.327.392.438a1 1 0 01-.041 1.076c-.074.105-.19.206-.425.406l-5.39 4.62A.764.764 0 01.46 16.463l4.62-5.39z", + fillOpacity: 0.6 +}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M10.303 1.697c.594-.594.891-.891 1.233-1.002a1.5 1.5 0 01.928 0c.342.111.639.408 1.233 1.002l2.606 2.606c.594.594.891.891 1.002 1.233a1.5 1.5 0 010 .928c-.111.342-.408.639-1.002 1.233l-2.769 2.769c-.2.2-.299.299-.383.41-.074.099-.14.204-.194.315a4.174 4.174 0 00-.196.526l-.942 2.827c-.271.813-.407 1.22-.66 1.408a1 1 0 01-.77.182c-.31-.055-.613-.359-1.22-.965L2.831 8.831c-.607-.607-.91-.91-.964-1.22a1 1 0 01.181-.77c.188-.253.595-.389 1.408-.66l2.827-.942c.268-.09.401-.134.526-.196a2 2 0 00.315-.194c.111-.084.211-.184.41-.383l2.769-2.769z" +})); + +function SvgPin(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 18, + height: 18, + viewBox: "0 0 18 18", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgPin); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/plus.svg": +/*!***********************************!*\ + !*** ./src/assets/icons/plus.svg ***! + \***********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M8 0v6h6v2H8v6H6V8H0V6h6V0h2z", + fill: "currentColor" +}); + +function SvgPlus(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 14, + height: 14, + viewBox: "0 0 14 14", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgPlus); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/settings.svg": +/*!***************************************!*\ + !*** ./src/assets/icons/settings.svg ***! + \***************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M4 0a4 4 0 100 8h10a4 4 0 000-8H4zm0 10a4 4 0 000 8h10a4 4 0 000-8H4zm2 4a2 2 0 11-4 0 2 2 0 014 0zm8-8a2 2 0 100-4 2 2 0 000 4z", + fill: "#000" +}); + +function SvgSettings(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 18, + height: 18, + viewBox: "0 0 18 18", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgSettings); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/slack.svg": +/*!************************************!*\ + !*** ./src/assets/icons/slack.svg ***! + \************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M3.781 11.375c0 1.041-.85 1.891-1.89 1.891-1.041 0-1.891-.85-1.891-1.89 0-1.041.85-1.892 1.89-1.892h1.891v1.891zM4.734 11.375c0-1.04.85-1.89 1.891-1.89s1.891.85 1.891 1.89v4.735c0 1.04-.85 1.891-1.89 1.891-1.041 0-1.892-.85-1.892-1.891v-4.735z", + fill: "#E01E5A" +}); + +var _ref2 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M6.625 3.782c-1.04 0-1.89-.85-1.89-1.891C4.734.85 5.584 0 6.624 0c1.041 0 1.891.85 1.891 1.891v1.89h-1.89zM6.625 4.734c1.04 0 1.891.85 1.891 1.891s-.85 1.891-1.89 1.891H1.89C.85 8.516 0 7.666 0 6.626c0-1.041.85-1.892 1.89-1.892h4.735z", + fill: "#36C5F0" +}); + +var _ref3 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M14.219 6.625c0-1.04.85-1.89 1.89-1.89 1.041 0 1.892.85 1.892 1.89 0 1.041-.85 1.891-1.891 1.891h-1.891v-1.89zM13.266 6.626c0 1.04-.85 1.89-1.891 1.89-1.04 0-1.891-.85-1.891-1.89V1.89c0-1.04.85-1.891 1.89-1.891 1.042 0 1.892.85 1.892 1.891v4.735z", + fill: "#2EB67D" +}); + +var _ref4 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M11.374 14.219c1.04 0 1.89.85 1.89 1.89 0 1.041-.85 1.892-1.89 1.892s-1.891-.85-1.891-1.891v-1.891h1.89zM11.374 13.266c-1.04 0-1.89-.85-1.89-1.89 0-1.041.85-1.892 1.89-1.892h4.735c1.04 0 1.891.85 1.891 1.891s-.85 1.891-1.891 1.891h-4.735z", + fill: "#ECB22E" +}); + +function SvgSlack(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 18, + height: 18, + viewBox: "0 0 18 18", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref, _ref2, _ref3, _ref4); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgSlack); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/terminal.svg": +/*!***************************************!*\ + !*** ./src/assets/icons/terminal.svg ***! + \***************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("g", { + fillRule: "evenodd", + clipRule: "evenodd", + fill: "#000" +}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M1 1h18v14H1V1z", + fillOpacity: 0.4 +}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M.163.819C0 1.139 0 1.559 0 2.4v11.2c0 .84 0 1.26.163 1.581a1.5 1.5 0 00.656.655c.32.164.74.164 1.581.164h15.2c.84 0 1.26 0 1.581-.164a1.5 1.5 0 00.655-.655c.164-.32.164-.74.164-1.581V2.4c0-.84 0-1.26-.163-1.581a1.5 1.5 0 00-.656-.656C18.861 0 18.441 0 17.6 0H2.4C1.56 0 1.14 0 .819.163A1.5 1.5 0 00.163.82zM5.42 3.815a1.5 1.5 0 00-1.98.124l-.124.142a1.5 1.5 0 00.124 1.98L5.378 8 3.439 9.94l-.124.14a1.5 1.5 0 002.246 1.98l3-3 .124-.14a1.5 1.5 0 00-.124-1.98l-3-3-.142-.125z" +})); + +function SvgTerminal(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 20, + height: 16, + viewBox: "0 0 20 16", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgTerminal); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/thumbs-down.svg": +/*!******************************************!*\ + !*** ./src/assets/icons/thumbs-down.svg ***! + \******************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("rect", { + width: 20, + height: 20, + rx: 4, + fill: "currentColor", + fillOpacity: 0.3 +}); + +var _ref2 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M15.5 9c0-2.485-2.015-4-4.5-4h-.838c-2.326 0-3.488 0-4.339.75-.85.752-.979 1.774-1.234 3.82a9.892 9.892 0 00-.089 1.18C4.5 12.578 5.172 13 7 13h4c2.485 0 4.5-1.515 4.5-4z", + fill: "currentColor" +}); + +var _ref3 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M12.8 11.6l.366.93a1 1 0 00-.366-1.93v1zM8.5 16h-1a1 1 0 001.939.345L8.5 16zm1 0c0-.608.169-1.49.657-2.19.45-.644 1.219-1.21 2.643-1.21v-2c-2.076 0-3.457.884-4.282 2.065C7.73 13.79 7.5 15.109 7.5 16h2zm-1 0l.938.345v.002c0 .001 0 0 0 0 0-.003.003-.008.006-.016l.032-.078a7.95 7.95 0 01.808-1.406c.613-.848 1.548-1.792 2.882-2.316l-.732-1.862c-1.803.708-3.018 1.964-3.771 3.008a9.942 9.942 0 00-.827 1.362 7.843 7.843 0 00-.272.609l-.001.004-.001.002L8.5 16z", + fill: "currentColor" +}); + +function SvgThumbsDown(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 20, + height: 20, + viewBox: "0 0 20 20", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref, _ref2, _ref3); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgThumbsDown); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/thumbs-up.svg": +/*!****************************************!*\ + !*** ./src/assets/icons/thumbs-up.svg ***! + \****************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("rect", { + width: 20, + height: 20, + rx: 4, + fill: "currentColor", + fillOpacity: 0.3 +}); + +var _ref2 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M4.5 11c0 2.485 2.015 4 4.5 4h.838c2.326 0 3.488 0 4.339-.75.85-.752.979-1.774 1.234-3.82.055-.439.089-.845.089-1.18C15.5 7.422 14.828 7 13 7H9c-2.485 0-4.5 1.515-4.5 4z", + fill: "currentColor" +}); + +var _ref3 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M7.2 8.4l-.366-.93A1 1 0 007.2 9.4v-1zM11.5 4h1a1 1 0 00-1.939-.345L11.5 4zm-1 0c0 .609-.169 1.49-.657 2.19-.45.644-1.219 1.21-2.643 1.21v2c2.076 0 3.457-.884 4.282-2.065C12.27 6.21 12.5 4.891 12.5 4h-2zm1 0a143.856 143.856 0 01-.938-.346v-.002.001a7.938 7.938 0 01-.846 1.5C9.103 6 8.168 6.945 6.834 7.469l.732 1.862c1.803-.708 3.018-1.964 3.771-3.008.379-.524.65-1.007.827-1.362a7.928 7.928 0 00.267-.596l.005-.012.002-.005v-.002L11.5 4z", + fill: "currentColor" +}); + +function SvgThumbsUp(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 20, + height: 20, + viewBox: "0 0 20 20", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref, _ref2, _ref3); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgThumbsUp); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/assets/icons/upload.svg": +/*!*************************************!*\ + !*** ./src/assets/icons/upload.svg ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +var _ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "M28 17V0H3C1.337 0 0 1.337 0 3v58c0 1.663 1.337 3 3 3h42c1.663 0 3-1.337 3-3V20H31c-1.65 0-3-1.35-3-3zm8.148 27.001H28v10a2 2 0 01-2 2h-4a2 2 0 01-2-2v-10h-8.148c-1.784 0-2.676-2.161-1.408-3.42L22.496 28.62a2.131 2.131 0 013.005 0L37.554 40.58c1.268 1.259.378 3.42-1.407 3.42zm10.977-30.876L34.888.875A2.998 2.998 0 0032.763 0H32v16h16v-.762a2.99 2.99 0 00-.875-2.113z" +}); + +function SvgUpload(props, svgRef) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({ + width: 48, + height: 64, + viewBox: "0 0 48 64", + fill: "#1890FF", + xmlns: "http://www.w3.org/2000/svg", + ref: svgRef + }, props), _ref); +} + +var ForwardRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(SvgUpload); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ForwardRef); + +/***/ }), + +/***/ "./src/app/App.js": +/*!************************!*\ + !*** ./src/app/App.js ***! + \************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var history__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! history */ "./node_modules/history/esm/history.js"); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js"); +/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router/esm/react-router.js"); +/* harmony import */ var _config_Sentry__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../config/Sentry */ "./src/config/Sentry.ts"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _providers_AppStoreProvider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../providers/AppStoreProvider */ "./src/providers/AppStoreProvider.tsx"); +/* harmony import */ var _providers_ConfigProvider__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../providers/ConfigProvider */ "./src/providers/ConfigProvider.js"); +/* harmony import */ var _providers_LibraryProvider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../providers/LibraryProvider */ "./src/providers/LibraryProvider.js"); +/* harmony import */ var _providers_MultiProvider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../providers/MultiProvider */ "./src/providers/MultiProvider.js"); +/* harmony import */ var _providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../providers/ProjectProvider */ "./src/providers/ProjectProvider.tsx"); +/* harmony import */ var _providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../providers/RoutesProvider */ "./src/providers/RoutesProvider.js"); +/* harmony import */ var _App_styl__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./App.styl */ "./src/app/App.styl"); +/* harmony import */ var _AsyncPage_AsyncPage__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./AsyncPage/AsyncPage */ "./src/app/AsyncPage/AsyncPage.js"); +/* harmony import */ var _ErrorBoundary__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ErrorBoundary */ "./src/app/ErrorBoundary.js"); +/* harmony import */ var _RootPage__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./RootPage */ "./src/app/RootPage.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); +/* global Sentry */ + + + + + + + + + + + + + + + + + +const baseURL = new URL(APP_SETTINGS.hostname || location.origin); +const browserHistory = (0,history__WEBPACK_IMPORTED_MODULE_15__.createBrowserHistory)({ + basename: baseURL.pathname || "/" +}); +window.LSH = browserHistory; +(0,_config_Sentry__WEBPACK_IMPORTED_MODULE_2__.initSentry)(browserHistory); + +const App = ({ + content +}) => { + const libraries = { + lsf: { + scriptSrc: window.EDITOR_JS, + cssSrc: window.EDITOR_CSS, + checkAvailability: () => !!window.LabelStudio + }, + dm: { + scriptSrc: window.DM_JS, + cssSrc: window.DM_CSS, + checkAvailability: () => !!window.DataManager + } + }; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_ErrorBoundary__WEBPACK_IMPORTED_MODULE_12__.default, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(react_router_dom__WEBPACK_IMPORTED_MODULE_16__.Router, { + history: browserHistory, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_providers_MultiProvider__WEBPACK_IMPORTED_MODULE_7__.MultiProvider, { + providers: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_providers_AppStoreProvider__WEBPACK_IMPORTED_MODULE_4__.AppStoreProvider, {}, "app-store"), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_3__.ApiProvider, {}, "api"), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_providers_ConfigProvider__WEBPACK_IMPORTED_MODULE_5__.ConfigProvider, {}, "config"), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_providers_LibraryProvider__WEBPACK_IMPORTED_MODULE_6__.LibraryProvider, { + libraries: libraries + }, "lsf"), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_9__.RoutesProvider, {}, "rotes"), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_8__.ProjectProvider, {}, "project")], + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_AsyncPage_AsyncPage__WEBPACK_IMPORTED_MODULE_11__.AsyncPage, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_RootPage__WEBPACK_IMPORTED_MODULE_13__.RootPage, { + content: content + }) + }) + }) + }) + }); +}; + +const root = document.querySelector('.app-wrapper'); +const content = document.querySelector('#main-content'); +(0,react_dom__WEBPACK_IMPORTED_MODULE_1__.render)( /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(App, { + content: content.innerHTML +}), root); + +/***/ }), + +/***/ "./src/app/AsyncPage/AsyncPage.js": +/*!****************************************!*\ + !*** ./src/app/AsyncPage/AsyncPage.js ***! + \****************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "AsyncPageContext": () => (/* binding */ AsyncPageContext), +/* harmony export */ "AsyncPageConsumer": () => (/* binding */ AsyncPageConsumer), +/* harmony export */ "AsyncPage": () => (/* binding */ AsyncPage) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react-router */ "./node_modules/react-router/esm/react-router.js"); +/* harmony import */ var _components_Error_Error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components/Error/Error */ "./src/components/Error/Error.js"); +/* harmony import */ var _components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../components/Modal/Modal */ "./src/components/Modal/Modal.js"); +/* harmony import */ var _providers_ConfigProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../providers/ConfigProvider */ "./src/providers/ConfigProvider.js"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var _utils_scripts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../utils/scripts */ "./src/utils/scripts.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + +const pageCache = new Map(); + +const pageFromHTML = html => { + const parser = new DOMParser(); + const document = parser.parseFromString(html, 'text/html'); + return document; +}; + +const loadAsyncPage = async url => { + try { + if (pageCache.has(url)) { + return pageCache.get(url); + } else { + const response = await fetch(url); + const html = await response.text(); + + if (response.status === 401) { + location.href = (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_4__.absoluteURL)("/"); + return; + } + + if (!response.ok) { + (0,_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__.modal)({ + body: () => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Error_Error__WEBPACK_IMPORTED_MODULE_1__.ErrorWrapper, { + title: `错误 ${response.status}:${response.statusText}`, + errorId: response.status, + stacktrace: `无法加载 URL ${url}\n\n${html}` + }), + allowClose: false, + style: { + width: 680 + } + }); + return null; + } + + pageCache.set(url, html); + return html; + } + } catch (err) { + (0,_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__.modal)({ + body: () => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Error_Error__WEBPACK_IMPORTED_MODULE_1__.ErrorWrapper, { + possum: false, + title: "无法连接", + message: "服务器无响应" + }), + allowClose: true, + style: { + width: 680 + } + }); + return null; + } +}; +/** + * @param {HTMLElement} oldNode + * @param {HTMLElement} newNode + */ + + +const swapNodes = async (oldNode, newNode) => { + if (oldNode && newNode) { + oldNode.replaceWith(newNode); + await (0,_utils_scripts__WEBPACK_IMPORTED_MODULE_5__.reInsertScripts)(newNode); + } +}; +/** + * @param {Document} oldPage + * @param {Document} newPage + */ + + +const swapAppSettings = async (oldPage, newPage) => { + const oldSettings = oldPage.querySelector('script#app-settings'); + const newSettings = newPage.querySelector('script#app-settings'); + + if (oldSettings && newSettings) { + await (0,_utils_scripts__WEBPACK_IMPORTED_MODULE_5__.replaceScript)(oldSettings, { + sourceScript: newSettings, + forceUpdate: true + }); + } +}; +/** + * @param {Document} oldPage + * @param {Document} newPage + */ + + +const swapContent = async (oldPage, newPage) => { + const currentContent = oldPage.querySelector('#dynamic-content'); + const newContent = newPage.querySelector('#dynamic-content'); + + if (currentContent && newContent) { + await swapNodes(currentContent, newContent); + } else { + await swapNodes(oldPage.body.children[0], newContent, { + removeOld: false + }); + } +}; +/** @param {HTMLElement} nodes */ + + +const nodesToSignatures = nodes => { + return new Set(Array.from(nodes).map(n => n.outerHTML)); +}; +/** + * @param {HTMLHeadElement} oldHead + * @param {HTMLHeadElement} newHead + */ + + +const swapHeadScripts = async (oldHead, newHead) => { + swapNodes(oldHead.querySelector('title'), newHead.querySelector('title')); + const fragment = document.createDocumentFragment(); + Array.from(newHead.querySelectorAll('script')).filter(script => (0,_utils_scripts__WEBPACK_IMPORTED_MODULE_5__.isScriptValid)(script)).forEach(script => fragment.appendChild(script)); + Array.from(oldHead.querySelectorAll('script')).filter(script => (0,_utils_scripts__WEBPACK_IMPORTED_MODULE_5__.isScriptValid)(script)).forEach(script => script.remove()); + oldHead.appendChild(fragment); + await (0,_utils_scripts__WEBPACK_IMPORTED_MODULE_5__.reInsertScripts)(oldHead); +}; +/** + * @param {Document} oldPage + * @param {Document} newPage + */ + + +const swapStylesheets = async (oldPage, newPage) => { + const linkSelector = ['style:not([data-replaced])', 'link[rel=stylesheet]:not([data-replaced])'].join(', '); + const oldStyles = Array.from(oldPage.querySelectorAll(linkSelector)); + const newStyles = Array.from(newPage.querySelectorAll(linkSelector)); + const existingSignatures = nodesToSignatures(oldStyles); + const stylesToReplace = newStyles.filter(style => !existingSignatures.has(style.outerHTML)); + await Promise.all(stylesToReplace.map(style => new Promise(resolve => { + style.onload = () => resolve(style.outerHTML); + + document.head.append(style); + }))); +}; +/** @param {Document} newPage */ + + +const swapPageParts = async (newPage, onReady) => { + document.title = newPage.title; + await swapStylesheets(document, newPage); + await swapHeadScripts(document.head, newPage.head); + await swapAppSettings(document, newPage); + await swapContent(document, newPage); + onReady === null || onReady === void 0 ? void 0 : onReady(); +}; + +const isVisitable = target => { + if (!target) return false; + if (target.dataset.external) return false; + if (target.getAttribute('href').match(/#/)) return false; + if (target.origin !== location.origin) return false; + return true; +}; + +const locationWithoutHash = () => { + const { + href + } = location; + return href.replace(/#(.*)/g, ''); +}; + +const fetchPage = async locationUrl => { + const html = await loadAsyncPage(locationUrl); + return html ? pageFromHTML(html) : null; +}; + +let currentLocation = locationWithoutHash(); + +const useStaticContent = (initialContent, onContentLoad) => { + const [staticContent, setStaticContent] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(initialContent); + const fetchCallback = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async locationUrl => { + currentLocation = locationUrl; + (0,_utils_scripts__WEBPACK_IMPORTED_MODULE_5__.clearScriptsCache)(); + const result = await fetchPage(locationUrl); + + if (result) { + await swapPageParts(result, onContentLoad); + setStaticContent(result); + return true; + } + + return false; + }, []); + return [staticContent, fetchCallback]; +}; + +const AsyncPageContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(null); +const AsyncPageConsumer = AsyncPageContext.Consumer; +const AsyncPage = ({ + children +}) => { + const initialContent = document; + const history = (0,react_router__WEBPACK_IMPORTED_MODULE_7__.useHistory)(); + const config = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_providers_ConfigProvider__WEBPACK_IMPORTED_MODULE_3__.ConfigContext); + const onLoadCallback = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + config.update(window.APP_SETTINGS); + }, []); + const [staticContent, fetchStatic] = useStaticContent(initialContent, onLoadCallback); + const onLinkClick = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async e => { + /**@type {HTMLAnchorElement} */ + const target = e.target.closest('a[href]:not([target]):not([download])'); + if (!isVisitable(target)) return; + if (target.matches('[data-external]')) return; + if (e.metaKey || e.ctrlKey) return; + e.preventDefault(); + const fetched = await fetchStatic(target.href); + + if (fetched) { + history.push(`${(0,_utils_helpers__WEBPACK_IMPORTED_MODULE_4__.removePrefix)(target.pathname)}${target.search}`); + } + }, []); + const onPopState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + const newLocation = locationWithoutHash(); + const isSameLocation = newLocation === currentLocation; + + if (!isSameLocation) { + currentLocation = newLocation; + fetchStatic(newLocation); + } + }, []); // useEffect(onPopState, [location]); + + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + document.addEventListener('click', onLinkClick, { + capture: true + }); + window.addEventListener('popstate', onPopState); + return () => { + document.removeEventListener('click', onLinkClick, { + capture: true + }); + window.removeEventListener('popstate', onPopState); + }; + }, []); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(AsyncPageContext.Provider, { + value: staticContent, + children: children + }); +}; + +/***/ }), + +/***/ "./src/app/ErrorBoundary.js": +/*!**********************************!*\ + !*** ./src/app/ErrorBoundary.js ***! + \**********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ErrorContext": () => (/* binding */ ErrorContext), +/* harmony export */ "default": () => (/* binding */ ErrorBoundary), +/* harmony export */ "ErrorUI": () => (/* binding */ ErrorUI) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _components_Error_Error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../components/Error/Error */ "./src/components/Error/Error.js"); +/* harmony import */ var _components_Modal_ModalPopup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../components/Modal/ModalPopup */ "./src/components/Modal/ModalPopup.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + +const ErrorContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(); +class ErrorBoundary extends react__WEBPACK_IMPORTED_MODULE_0__.Component { + constructor(props) { + super(props); + this.state = { + hasError: false + }; + } + + static getDerivedStateFromError(error) { + // Update state so the next render will show the fallback UI. + return { + hasError: true, + error + }; + } + + componentDidCatch(error, { + componentStack + }) { + // You can also log the error to an error reporting service + this.setState({ + error, + hasError: true, + errorInfo: componentStack + }); + } + + render() { + if (this.state.hasError) { + var _this$state$error$sta, _this$state$error; + + const { + error, + errorInfo + } = this.state; + + const goBack = () => { + // usually this will trigger React Router in the broken app, which is not helpful + history.back(); // so we reload app totally on that previous page after some delay for Router's stuff + + setTimeout(() => location.reload(), 32); + }; + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_components_Modal_ModalPopup__WEBPACK_IMPORTED_MODULE_2__.Modal, { + onHide: () => location.reload(), + style: { + width: "60vw" + }, + visible: true, + bare: true, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("div", { + style: { + padding: 40 + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_components_Error_Error__WEBPACK_IMPORTED_MODULE_1__.ErrorWrapper, { + title: "\u8FD0\u884C\u65F6\u9519\u8BEF", + message: error, + stacktrace: `${errorInfo ? `错误信息:${errorInfo}` : ''}\n\n${(_this$state$error$sta = (_this$state$error = this.state.error) === null || _this$state$error === void 0 ? void 0 : _this$state$error.stack) !== null && _this$state$error$sta !== void 0 ? _this$state$error$sta : ''}`, + onGoBack: goBack, + onReload: () => location.reload() + }) + }) + }); + } + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(ErrorContext.Provider, { + value: { + hasError: this.state.hasError, + error: this.state.error, + errorInfo: this.state.errorInfo, + silence: this.silence, + unsilence: this.unsilence + }, + children: this.props.children + }); + } + +} +const ErrorUI = () => { + const context = react__WEBPACK_IMPORTED_MODULE_0__.useContext(ErrorContext); + return context.hasError && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("div", { + className: "error", + children: "Error occurred" + }); +}; + +/***/ }), + +/***/ "./src/app/RootPage.js": +/*!*****************************!*\ + !*** ./src/app/RootPage.js ***! + \*****************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "RootPage": () => (/* binding */ RootPage) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _components_Menubar_Menubar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../components/Menubar/Menubar */ "./src/components/Menubar/Menubar.js"); +/* harmony import */ var _routes_ProjectRoutes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../routes/ProjectRoutes */ "./src/routes/ProjectRoutes.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + +const RootPage = ({ + content +}) => { + const pinned = localStorage.getItem('sidebar-pinned') === 'true'; + const opened = pinned && localStorage.getItem('sidebar-opened') === 'true'; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_components_Menubar_Menubar__WEBPACK_IMPORTED_MODULE_1__.Menubar, { + enabled: true, + defaultOpened: opened, + defaultPinned: pinned, + onSidebarToggle: visible => localStorage.setItem('sidebar-opened', visible), + onSidebarPin: pinned => localStorage.setItem('sidebar-pinned', pinned), + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_routes_ProjectRoutes__WEBPACK_IMPORTED_MODULE_2__.ProjectRoutes, { + content: content + }) + }); +}; + +/***/ }), + +/***/ "./src/app/StaticContent/StaticContent.js": +/*!************************************************!*\ + !*** ./src/app/StaticContent/StaticContent.js ***! + \************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "StaticContent": () => (/* binding */ StaticContent) +/* harmony export */ }); +/* harmony import */ var html_react_parser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! html-react-parser */ "./node_modules/html-react-parser/index.mjs"); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_scripts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utils/scripts */ "./src/utils/scripts.js"); +/* harmony import */ var _AsyncPage_AsyncPage__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../AsyncPage/AsyncPage */ "./src/app/AsyncPage/AsyncPage.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + +const parseContent = (id, source, children, parse) => { + let result; + let setInnerHTML = false; + + if (!children || children.length === 0 || children instanceof Function) { + var _template$innerHTML; + + const template = source.querySelector(`template#${id}`); + const templateHTML = (_template$innerHTML = template.innerHTML) !== null && _template$innerHTML !== void 0 ? _template$innerHTML : ""; + + if (parse) { + const parsed = (0,html_react_parser__WEBPACK_IMPORTED_MODULE_0__.default)(templateHTML); + const childResult = children instanceof Function ? children(parsed) : false; + result = childResult || parsed; + } else { + const childResult = children instanceof Function ? children(template) : false; + + if (childResult) { + result = childResult; + } else { + result = templateHTML; + setInnerHTML = true; + } + } + } else { + result = children; + } + + return { + children: result, + setInnerHTML + }; +}; + +const StaticContentDrawer = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__.forwardRef(({ + id, + tagName, + children, + source, + onRenderFinished, + parse = false, + raw = false, + ...props +}, ref) => { + const rootRef = ref !== null && ref !== void 0 ? ref : react__WEBPACK_IMPORTED_MODULE_1__.useRef(); + const [content, setContent] = react__WEBPACK_IMPORTED_MODULE_1__.useState(parseContent(id, source, children, parse)); + react__WEBPACK_IMPORTED_MODULE_1__.useEffect(() => { + setContent(parseContent(id, source, children, parse)); + }, [source, children]); + react__WEBPACK_IMPORTED_MODULE_1__.useEffect(() => { + if (rootRef.current) (0,_utils_scripts__WEBPACK_IMPORTED_MODULE_2__.reInsertScripts)(rootRef.current); + onRenderFinished === null || onRenderFinished === void 0 ? void 0 : onRenderFinished(); + }, [content]); + + if (content.setInnerHTML) { + props.dangerouslySetInnerHTML = { + __html: content.children + }; + } else { + props.children = content.children; + } + + return raw === true && content.children ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(react__WEBPACK_IMPORTED_MODULE_1__.Fragment, { + children: content.children + }) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__.createElement(tagName !== null && tagName !== void 0 ? tagName : 'div', { ...props, + ref: rootRef + }); +}); +const StaticContent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__.forwardRef((props, ref) => { + const pageSource = react__WEBPACK_IMPORTED_MODULE_1__.useContext(_AsyncPage_AsyncPage__WEBPACK_IMPORTED_MODULE_3__.AsyncPageContext); + return pageSource ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(StaticContentDrawer, { ...props, + source: pageSource, + ref: ref + }) : null; +}); + +/***/ }), + +/***/ "./src/assets/icons/index.js": +/*!***********************************!*\ + !*** ./src/assets/icons/index.js ***! + \***********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "IconAllProjects": () => (/* reexport safe */ _all_projects_svg__WEBPACK_IMPORTED_MODULE_0__.default), +/* harmony export */ "IconBell": () => (/* reexport safe */ _bell_svg__WEBPACK_IMPORTED_MODULE_1__.default), +/* harmony export */ "IconBook": () => (/* reexport safe */ _book_svg__WEBPACK_IMPORTED_MODULE_2__.default), +/* harmony export */ "LsBulb": () => (/* reexport safe */ _bulb_svg__WEBPACK_IMPORTED_MODULE_3__.default), +/* harmony export */ "LsCheck": () => (/* reexport safe */ _check_svg__WEBPACK_IMPORTED_MODULE_4__.default), +/* harmony export */ "LsChevronLeft": () => (/* reexport safe */ _chevron_left_svg__WEBPACK_IMPORTED_MODULE_5__.default), +/* harmony export */ "LsChevronRight": () => (/* reexport safe */ _chevron_right_svg__WEBPACK_IMPORTED_MODULE_6__.default), +/* harmony export */ "LsCross": () => (/* reexport safe */ _cross_svg__WEBPACK_IMPORTED_MODULE_7__.default), +/* harmony export */ "LsDoor": () => (/* reexport safe */ _door_svg__WEBPACK_IMPORTED_MODULE_8__.default), +/* harmony export */ "LsEllipsis": () => (/* reexport safe */ _ellipsis_svg__WEBPACK_IMPORTED_MODULE_9__.default), +/* harmony export */ "IconEmptyFolder": () => (/* reexport safe */ _folder_empty_svg__WEBPACK_IMPORTED_MODULE_10__.default), +/* harmony export */ "IconError": () => (/* reexport safe */ _error_svg__WEBPACK_IMPORTED_MODULE_11__.default), +/* harmony export */ "IconFolder": () => (/* reexport safe */ _folder_svg__WEBPACK_IMPORTED_MODULE_12__.default), +/* harmony export */ "IconGear": () => (/* reexport safe */ _gear_svg__WEBPACK_IMPORTED_MODULE_13__.default), +/* harmony export */ "LsGitHub": () => (/* reexport safe */ _github_svg__WEBPACK_IMPORTED_MODULE_14__.default), +/* harmony export */ "IconInfo": () => (/* reexport safe */ _info_svg__WEBPACK_IMPORTED_MODULE_15__.default), +/* harmony export */ "LsMinus": () => (/* reexport safe */ _minus_svg__WEBPACK_IMPORTED_MODULE_16__.default), +/* harmony export */ "IconPersonInCircle": () => (/* reexport safe */ _person_circle_svg__WEBPACK_IMPORTED_MODULE_17__.default), +/* harmony export */ "IconPin": () => (/* reexport safe */ _pin_svg__WEBPACK_IMPORTED_MODULE_18__.default), +/* harmony export */ "LsPlus": () => (/* reexport safe */ _plus_svg__WEBPACK_IMPORTED_MODULE_19__.default), +/* harmony export */ "LsSettings": () => (/* reexport safe */ _settings_svg__WEBPACK_IMPORTED_MODULE_20__.default), +/* harmony export */ "LsSlack": () => (/* reexport safe */ _slack_svg__WEBPACK_IMPORTED_MODULE_21__.default), +/* harmony export */ "IconTerminal": () => (/* reexport safe */ _terminal_svg__WEBPACK_IMPORTED_MODULE_22__.default), +/* harmony export */ "LsThumbsDown": () => (/* reexport safe */ _thumbs_down_svg__WEBPACK_IMPORTED_MODULE_23__.default), +/* harmony export */ "LsThumbsUp": () => (/* reexport safe */ _thumbs_up_svg__WEBPACK_IMPORTED_MODULE_24__.default), +/* harmony export */ "IconUpload": () => (/* reexport safe */ _upload_svg__WEBPACK_IMPORTED_MODULE_25__.default) +/* harmony export */ }); +/* harmony import */ var _all_projects_svg__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./all-projects.svg */ "./src/assets/icons/all-projects.svg"); +/* harmony import */ var _bell_svg__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bell.svg */ "./src/assets/icons/bell.svg"); +/* harmony import */ var _book_svg__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./book.svg */ "./src/assets/icons/book.svg"); +/* harmony import */ var _bulb_svg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bulb.svg */ "./src/assets/icons/bulb.svg"); +/* harmony import */ var _check_svg__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./check.svg */ "./src/assets/icons/check.svg"); +/* harmony import */ var _chevron_left_svg__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chevron-left.svg */ "./src/assets/icons/chevron-left.svg"); +/* harmony import */ var _chevron_right_svg__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./chevron-right.svg */ "./src/assets/icons/chevron-right.svg"); +/* harmony import */ var _cross_svg__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./cross.svg */ "./src/assets/icons/cross.svg"); +/* harmony import */ var _door_svg__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./door.svg */ "./src/assets/icons/door.svg"); +/* harmony import */ var _ellipsis_svg__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ellipsis.svg */ "./src/assets/icons/ellipsis.svg"); +/* harmony import */ var _folder_empty_svg__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./folder-empty.svg */ "./src/assets/icons/folder-empty.svg"); +/* harmony import */ var _error_svg__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./error.svg */ "./src/assets/icons/error.svg"); +/* harmony import */ var _folder_svg__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./folder.svg */ "./src/assets/icons/folder.svg"); +/* harmony import */ var _gear_svg__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gear.svg */ "./src/assets/icons/gear.svg"); +/* harmony import */ var _github_svg__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./github.svg */ "./src/assets/icons/github.svg"); +/* harmony import */ var _info_svg__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./info.svg */ "./src/assets/icons/info.svg"); +/* harmony import */ var _minus_svg__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./minus.svg */ "./src/assets/icons/minus.svg"); +/* harmony import */ var _person_circle_svg__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./person-circle.svg */ "./src/assets/icons/person-circle.svg"); +/* harmony import */ var _pin_svg__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./pin.svg */ "./src/assets/icons/pin.svg"); +/* harmony import */ var _plus_svg__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./plus.svg */ "./src/assets/icons/plus.svg"); +/* harmony import */ var _settings_svg__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./settings.svg */ "./src/assets/icons/settings.svg"); +/* harmony import */ var _slack_svg__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./slack.svg */ "./src/assets/icons/slack.svg"); +/* harmony import */ var _terminal_svg__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./terminal.svg */ "./src/assets/icons/terminal.svg"); +/* harmony import */ var _thumbs_down_svg__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./thumbs-down.svg */ "./src/assets/icons/thumbs-down.svg"); +/* harmony import */ var _thumbs_up_svg__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./thumbs-up.svg */ "./src/assets/icons/thumbs-up.svg"); +/* harmony import */ var _upload_svg__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./upload.svg */ "./src/assets/icons/upload.svg"); + + + + + + + + + + + + + + + + + + + + + + + + + + + +/***/ }), + +/***/ "./src/components/Breadcrumbs/Breadcrumbs.js": +/*!***************************************************!*\ + !*** ./src/components/Breadcrumbs/Breadcrumbs.js ***! + \***************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Breadcrumbs": () => (/* binding */ Breadcrumbs) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/esm/react-router-dom.js"); +/* harmony import */ var _providers_ConfigProvider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../providers/ConfigProvider */ "./src/providers/ConfigProvider.js"); +/* harmony import */ var _providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../providers/RoutesProvider */ "./src/providers/RoutesProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var _Dropdown_Dropdown__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Dropdown/Dropdown */ "./src/components/Dropdown/Dropdown.js"); +/* harmony import */ var _Menu_Menu__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Menu/Menu */ "./src/components/Menu/Menu.js"); +/* harmony import */ var _Breadcrumbs_styl__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Breadcrumbs.styl */ "./src/components/Breadcrumbs/Breadcrumbs.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + +const { + Block, + Elem +} = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_3__.BemWithSpecifiContext)(); +const Breadcrumbs = () => { + const config = (0,_providers_ConfigProvider__WEBPACK_IMPORTED_MODULE_1__.useConfig)(); + const reactBreadcrumbs = (0,_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_2__.useBreadcrumbs)(); + const findComponent = (0,_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_2__.useFindRouteComponent)(); + const [breadcrumbs, setBreadcrumbs] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(reactBreadcrumbs); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (reactBreadcrumbs.length) { + setBreadcrumbs(reactBreadcrumbs); + } else if (config.breadcrumbs) { + setBreadcrumbs(config.breadcrumbs); + } + }, [reactBreadcrumbs, config]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(Block, { + name: "breadcrumbs", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(Elem, { + tag: "ul", + name: "list", + children: breadcrumbs.map((item, index, list) => { + var _item$href; + + const isLastItem = index === list.length - 1; + const key = `item-${index}-${item.title}`; + const href = (_item$href = item.href) !== null && _item$href !== void 0 ? _item$href : item.path; + const isInternal = findComponent(href) !== null; + + const title = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(Elem, { + tag: "span", + name: "label", + mod: { + faded: index === item.length - 1 + }, + children: item.title + }); + + const dropdownSubmenu = item.submenu ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_Dropdown_Dropdown__WEBPACK_IMPORTED_MODULE_5__.Dropdown, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_Menu_Menu__WEBPACK_IMPORTED_MODULE_6__.Menu, { + children: item.submenu.map((sub, index) => { + var _sub$href; + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_Menu_Menu__WEBPACK_IMPORTED_MODULE_6__.Menu.Item, { + label: sub.title, + icon: sub.icon, + href: (_sub$href = sub.href) !== null && _sub$href !== void 0 ? _sub$href : sub.path, + active: sub.active + }, `${index}-${item.title}`); + }) + }) + }) : null; + return item.onClick ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(Elem, { + tag: "li", + name: "item", + mod: { + last: isLastItem + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("span", { + onClick: item.onClick, + children: title + }) + }, key) : dropdownSubmenu ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(Elem, { + tag: "li", + component: _Dropdown_Dropdown__WEBPACK_IMPORTED_MODULE_5__.Dropdown.Trigger, + name: "item", + mod: { + last: isLastItem + }, + content: dropdownSubmenu, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("span", { + children: title + }) + }, key) : href && !isLastItem ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(Elem, { + tag: "li", + name: "item", + mod: { + last: isLastItem + }, + children: isInternal ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(react_router_dom__WEBPACK_IMPORTED_MODULE_9__.NavLink, { + to: href, + "data-external": true, + children: title + }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("a", { + href: (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_4__.absoluteURL)(href), + children: title + }) + }, key) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(Elem, { + tag: "li", + name: "item", + mod: { + last: isLastItem + }, + children: title + }, key); + }) + }) + }); +}; + +/***/ }), + +/***/ "./src/components/Button/Button.js": +/*!*****************************************!*\ + !*** ./src/components/Button/Button.js ***! + \*****************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Button": () => (/* binding */ Button) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var _Form_FormContext__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Form/FormContext */ "./src/components/Form/FormContext.js"); +/* harmony import */ var _Button_styl__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Button.styl */ "./src/components/Button/Button.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + +const Button = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(({ + children, + type, + extra, + className, + size, + waiting, + icon, + tag, + look, + ...rest +}, ref) => { + const finalTag = tag !== null && tag !== void 0 ? tag : rest.href ? "a" : "button"; + const mods = { + size, + waiting, + type, + look: look !== null && look !== void 0 ? look : [], + withIcon: !!icon, + withExtra: !!extra + }; + const formSubmitting = react__WEBPACK_IMPORTED_MODULE_0__.useContext(_Form_FormContext__WEBPACK_IMPORTED_MODULE_3__.FormSubmissionContext); + + if (formSubmitting === true) { + var _mods$look, _mods$look$includes; + + if ((_mods$look = mods.look) !== null && _mods$look !== void 0 && (_mods$look$includes = _mods$look.includes) !== null && _mods$look$includes !== void 0 && _mods$look$includes.call(_mods$look, "primary") && type === 'submit') { + mods.waiting = true; + } else { + rest.disabled = true; + } + } + + if (rest.primary) { + mods.look = 'primary'; + delete rest.primary; + } + + const iconElem = react__WEBPACK_IMPORTED_MODULE_0__.useMemo(() => { + if (!icon) return null; + if ((0,_utils_helpers__WEBPACK_IMPORTED_MODULE_2__.isDefined)(icon.props.size)) return icon; + + switch (size) { + case "small": + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.cloneElement(icon, { ...icon.props, + size: 12, + width: 12, + height: 12 + }); + + case "compact": + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.cloneElement(icon, { ...icon.props, + size: 14, + width: 14, + height: 14 + }); + + default: + return icon; + } + }, [icon, size]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_1__.Block, { + name: "button", + mod: mods, + mix: className, + ref: ref, + tag: finalTag, + type: type, + ...rest, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.Fragment, { + children: [iconElem && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_1__.Elem, { + tag: "span", + name: "icon", + children: iconElem + }), iconElem && children ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("span", { + children: children + }) : children, extra !== undefined ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_1__.Elem, { + name: "extra", + children: extra + }) : null] + }) + }); +}); +Button.displayName = "Button"; + +Button.Group = ({ + className, + children, + collapsed +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_1__.Block, { + name: "button-group", + mod: { + collapsed + }, + mix: className, + children: children + }); +}; + +/***/ }), + +/***/ "./src/components/Card/Card.js": +/*!*************************************!*\ + !*** ./src/components/Card/Card.js ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Card": () => (/* binding */ Card) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Card_styl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Card.styl */ "./src/components/Card/Card.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + +const Card = ({ + header, + extra, + children, + style +}) => { + const rootClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)("card"); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)("div", { + className: rootClass, + style: style, + children: [(header || extra) && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)("div", { + className: rootClass.elem("header"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("div", { + className: rootClass.elem("header-content"), + children: header + }), extra && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("div", { + className: rootClass.elem("header-extra"), + children: extra + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("div", { + className: rootClass.elem("content"), + children: children + })] + }); +}; + +/***/ }), + +/***/ "./src/components/Checkbox/Checkbox.js": +/*!*********************************************!*\ + !*** ./src/components/Checkbox/Checkbox.js ***! + \*********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Checkbox": () => (/* binding */ Checkbox) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Checkbox_styl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Checkbox.styl */ "./src/components/Checkbox/Checkbox.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + +const Checkbox = ({ + checked, + indeterminate, + style, + onChange, + children, + ...props +}) => { + const rootClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)("checkbox"); + const checkboxRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createRef(); + const withLabel = !!children; + react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { + checkboxRef.current.indeterminate = indeterminate; + }, [checkboxRef, indeterminate]); + + const checkboxContent = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)("span", { + className: rootClass.elem("box"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("input", { ...props, + ref: checkboxRef, + checked: !!checked, + className: rootClass.elem("input"), + type: "checkbox", + onChange: e => { + onChange === null || onChange === void 0 ? void 0 : onChange(e); + } + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("span", { + className: rootClass.elem("check").mod({ + checked, + indeterminate + }) + })] + }); + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("div", { + className: rootClass.mod({ + withLabel + }).mix(props.className), + style: style, + children: children ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)("label", { + className: rootClass.elem("label"), + children: [checkboxContent, " ", children] + }) : checkboxContent + }); +}; + +/***/ }), + +/***/ "./src/components/Columns/Columns.js": +/*!*******************************************!*\ + !*** ./src/components/Columns/Columns.js ***! + \*******************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Columns": () => (/* binding */ Columns) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Columns_styl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Columns.styl */ "./src/components/Columns/Columns.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + +const Columns = ({ + children, + count, + size, + gap +}) => { + /**@type {import('react').RefObject} */ + const ref = react__WEBPACK_IMPORTED_MODULE_0__.useRef(); + /**@type {import('react').CSSProperties} */ + + const style = { + "--columns": Math.max(1, count !== null && count !== void 0 ? count : 1), + "--column-width": size, + "--column-gap": gap + }; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("div", { + ref: ref, + className: (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)("columns"), + style: style, + children: children + }); +}; + +Columns.Column = ({ + title, + children +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)("div", { + className: (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)("columns").elem("item"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("div", { + className: (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)("columns").elem("title"), + children: title + }), children] + }); +}; + +/***/ }), + +/***/ "./src/components/Description/Description.js": +/*!***************************************************!*\ + !*** ./src/components/Description/Description.js ***! + \***************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Description": () => (/* binding */ Description) +/* harmony export */ }); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Description_styl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Description.styl */ "./src/components/Description/Description.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + +const Description = ({ + children, + className, + size = 'medium', + noOffset = false, + ...rest +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_0__.Block, { + name: "description", + mod: { + size, + noOffset + }, + mix: className, + ...rest, + children: children + }); +}; + +/***/ }), + +/***/ "./src/components/DescriptionList/DescriptionList.js": +/*!***********************************************************!*\ + !*** ./src/components/DescriptionList/DescriptionList.js ***! + \***********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DescriptionList": () => (/* binding */ DescriptionList) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _DescriptionList_styl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./DescriptionList.styl */ "./src/components/DescriptionList/DescriptionList.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + +const DescriptionList = ({ + style, + className, + children +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("dl", { + className: (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)('dl').mix(className), + style: style, + children: children + }); +}; + +DescriptionList.Item = ({ + retmClassName, + descriptionClassName, + term, + descriptionStyle, + termStyle, + children +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.Fragment, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("dt", { + className: (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)('dl').elem('dt').mix(retmClassName), + style: descriptionStyle, + children: term + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("dd", { + className: (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)('dl').elem('dd').mix(descriptionClassName), + style: termStyle, + children: children + })] + }); +}; + +/***/ }), + +/***/ "./src/components/Divider/Divider.js": +/*!*******************************************!*\ + !*** ./src/components/Divider/Divider.js ***! + \*******************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Divider": () => (/* binding */ Divider) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + +const Divider = ({ + height +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("div", { + style: { + height: height + } + }); +}; + +/***/ }), + +/***/ "./src/components/Dropdown/Dropdown.js": +/*!*********************************************!*\ + !*** ./src/components/Dropdown/Dropdown.js ***! + \*********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Dropdown": () => (/* reexport safe */ _DropdownComponent__WEBPACK_IMPORTED_MODULE_0__.Dropdown) +/* harmony export */ }); +/* harmony import */ var _DropdownComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./DropdownComponent */ "./src/components/Dropdown/DropdownComponent.js"); +/* harmony import */ var _DropdownTrigger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./DropdownTrigger */ "./src/components/Dropdown/DropdownTrigger.js"); + + +_DropdownComponent__WEBPACK_IMPORTED_MODULE_0__.Dropdown.Trigger = _DropdownTrigger__WEBPACK_IMPORTED_MODULE_1__.DropdownTrigger; + + +/***/ }), + +/***/ "./src/components/Dropdown/DropdownComponent.js": +/*!******************************************************!*\ + !*** ./src/components/Dropdown/DropdownComponent.js ***! + \******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Dropdown": () => (/* binding */ Dropdown) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../utils/dom */ "./src/utils/dom.js"); +/* harmony import */ var _utils_transition__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../utils/transition */ "./src/utils/transition.js"); +/* harmony import */ var _Dropdown_styl__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Dropdown.styl */ "./src/components/Dropdown/Dropdown.styl"); +/* harmony import */ var _DropdownContext__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./DropdownContext */ "./src/components/Dropdown/DropdownContext.js"); +/* harmony import */ var _DropdownTrigger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./DropdownTrigger */ "./src/components/Dropdown/DropdownTrigger.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + +let lastIndex = 1; +const Dropdown = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(({ + animated = true, + visible = false, + ...props +}, ref) => { + var _useContext, _props$style; + + const rootName = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_2__.cn)("dropdown"); + /**@type {import('react').RefObject} */ + + const dropdown = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const { + triggerRef + } = (_useContext = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_DropdownContext__WEBPACK_IMPORTED_MODULE_6__.DropdownContext)) !== null && _useContext !== void 0 ? _useContext : {}; + const isInline = triggerRef === undefined; + const { + children + } = props; + const [renderable, setRenderable] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(visible); + const [currentVisible, setVisible] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(visible); + const [offset, setOffset] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)({}); + const [visibility, setVisibility] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(visible ? "visible" : null); + const calculatePosition = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + var _triggerRef$current, _props$align; + + const dropdownEl = dropdown.current; + const parent = (_triggerRef$current = triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) !== null && _triggerRef$current !== void 0 ? _triggerRef$current : dropdownEl.parentNode; + const { + left, + top + } = (0,_utils_dom__WEBPACK_IMPORTED_MODULE_3__.alignElements)(parent, dropdownEl, `bottom-${(_props$align = props.align) !== null && _props$align !== void 0 ? _props$align : 'left'}`); + setOffset({ + left, + top + }); + }, [triggerRef]); + const dropdownIndex = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + return lastIndex++; + }, []); + const performAnimation = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async (visible = false) => { + if (props.enabled === false && visible === true) return; + return new Promise(resolve => { + const menu = dropdown.current; + + if (animated !== false) { + (0,_utils_transition__WEBPACK_IMPORTED_MODULE_4__.aroundTransition)(menu, { + transition: () => { + setVisibility(visible ? "appear" : "disappear"); + }, + beforeTransition: () => { + setVisibility(visible ? "before-appear" : "before-disappear"); + }, + afterTransition: () => { + setVisibility(visible ? "visible" : null); + resolve(); + } + }); + } else { + setVisibility(visible ? "visible" : null); + resolve(); + } + }); + }, [animated]); + const changeVisibility = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async visibility => { + var _props$onToggle, _props$onVisibilityCh; + + (_props$onToggle = props.onToggle) === null || _props$onToggle === void 0 ? void 0 : _props$onToggle.call(props, visibility); + await performAnimation(visibility); + setVisible(visibility); + (_props$onVisibilityCh = props.onVisibilityChanged) === null || _props$onVisibilityCh === void 0 ? void 0 : _props$onVisibilityCh.call(props, visibility); + }, [props, performAnimation]); + const close = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + if (currentVisible === false || renderable === false) return; + await changeVisibility(false); + setRenderable(false); + }, [currentVisible, performAnimation, props, renderable]); + const open = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + if (currentVisible === true || renderable === true) return; + setRenderable(true); + }, [currentVisible, performAnimation, props, renderable]); + const toggle = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + const newState = !currentVisible; + + if (newState) { + open(); + } else { + close(); + } + }, [close, currentVisible, open]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (!ref) return; + ref.current = { + dropdown: dropdown.current, + visible: visibility !== null, + toggle, + open, + close + }; + }, [close, open, ref, toggle, dropdown, visibility]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + setVisible(visible); + }, [visible]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (!isInline && visibility === "before-appear") { + calculatePosition(); + } + }, [visibility, calculatePosition, isInline]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (props.enabled === false) performAnimation(false); + }, [props.enabled]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (renderable) changeVisibility(true); + }, [renderable]); + const content = children.props && children.props.type === "Menu" ? /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.cloneElement)(children, { ...children.props, + className: rootName.elem("menu").mix(children.props.className) + }) : children; + const visibilityClasses = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + switch (visibility) { + case "before-appear": + return "before-appear"; + + case "appear": + return "appear before-appear"; + + case "before-disappear": + return "before-disappear"; + + case "disappear": + return "disappear before-disappear"; + + case "visible": + return "visible"; + + default: + return visible ? "visible" : null; + } + }, [visibility, visible]); + const compositeStyles = { ...((_props$style = props.style) !== null && _props$style !== void 0 ? _props$style : {}), + ...(offset !== null && offset !== void 0 ? offset : {}), + zIndex: 1000 + dropdownIndex + }; + + const result = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Block, { + ref: dropdown, + name: "dropdown", + mix: [props.className, visibilityClasses], + style: compositeStyles, + onClick: e => e.stopPropagation(), + children: content + }); + + return renderable ? props.inline === true ? result : /*#__PURE__*/react_dom__WEBPACK_IMPORTED_MODULE_1__.createPortal(result, document.body) : null; +}); +Dropdown.displayName = "Dropdown"; +Dropdown.Trigger = _DropdownTrigger__WEBPACK_IMPORTED_MODULE_7__.DropdownTrigger; + +/***/ }), + +/***/ "./src/components/Dropdown/DropdownContext.js": +/*!****************************************************!*\ + !*** ./src/components/Dropdown/DropdownContext.js ***! + \****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DropdownContext": () => (/* binding */ DropdownContext) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); + +const DropdownContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(); + +/***/ }), + +/***/ "./src/components/Dropdown/DropdownTrigger.js": +/*!****************************************************!*\ + !*** ./src/components/Dropdown/DropdownTrigger.js ***! + \****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DropdownTrigger": () => (/* binding */ DropdownTrigger), +/* harmony export */ "useDropdown": () => (/* binding */ useDropdown) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _DropdownComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./DropdownComponent */ "./src/components/Dropdown/DropdownComponent.js"); +/* harmony import */ var _DropdownContext__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./DropdownContext */ "./src/components/Dropdown/DropdownContext.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + +const DropdownTrigger = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(({ + tag, + children, + dropdown, + content, + toggle, + closeOnClickOutside = true, + ...props +}, ref) => { + var _ref, _triggerEL$props$ref, _triggerEL$props; + + const dropdownRef = (_ref = ref !== null && ref !== void 0 ? ref : dropdown) !== null && _ref !== void 0 ? _ref : (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const triggerEL = react__WEBPACK_IMPORTED_MODULE_0__.Children.only(children); + const [childset] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(new Set()); + /** @type {import('react').RefObject} */ + + const triggerRef = (_triggerEL$props$ref = triggerEL.props.ref) !== null && _triggerEL$props$ref !== void 0 ? _triggerEL$props$ref : (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const parentDropdown = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_DropdownContext__WEBPACK_IMPORTED_MODULE_2__.DropdownContext); + const targetIsInsideDropdown = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(target => { + var _triggerRef$current, _triggerRef$current$c, _dropdownRef$current, _dropdownRef$current$, _dropdownRef$current$2; + + const triggerClicked = (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : (_triggerRef$current$c = _triggerRef$current.contains) === null || _triggerRef$current$c === void 0 ? void 0 : _triggerRef$current$c.call(_triggerRef$current, target); + const dropdownClicked = (_dropdownRef$current = dropdownRef.current) === null || _dropdownRef$current === void 0 ? void 0 : (_dropdownRef$current$ = _dropdownRef$current.dropdown) === null || _dropdownRef$current$ === void 0 ? void 0 : (_dropdownRef$current$2 = _dropdownRef$current$.contains) === null || _dropdownRef$current$2 === void 0 ? void 0 : _dropdownRef$current$2.call(_dropdownRef$current$, target); + const childDropdownClicked = Array.from(childset).reduce((res, child) => { + return res || child.hasTarget(target); + }, false); + return triggerClicked || dropdownClicked || childDropdownClicked; + }, [triggerRef, dropdownRef]); + const handleClick = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(e => { + var _dropdownRef$current2, _dropdownRef$current3; + + if (!closeOnClickOutside) return; + if (targetIsInsideDropdown(e.target)) return; + (_dropdownRef$current2 = dropdownRef.current) === null || _dropdownRef$current2 === void 0 ? void 0 : (_dropdownRef$current3 = _dropdownRef$current2.close) === null || _dropdownRef$current3 === void 0 ? void 0 : _dropdownRef$current3.call(_dropdownRef$current2); + }, [closeOnClickOutside, targetIsInsideDropdown]); + const handleToggle = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(e => { + var _dropdownRef$current4, _dropdownRef$current5, _dropdownRef$current6, _dropdownRef$current7, _dropdownRef$current8; + + const inDropdown = (_dropdownRef$current4 = dropdownRef.current) === null || _dropdownRef$current4 === void 0 ? void 0 : (_dropdownRef$current5 = _dropdownRef$current4.dropdown) === null || _dropdownRef$current5 === void 0 ? void 0 : (_dropdownRef$current6 = _dropdownRef$current5.contains) === null || _dropdownRef$current6 === void 0 ? void 0 : _dropdownRef$current6.call(_dropdownRef$current5, e.target); + if (inDropdown) return e.stopPropagation(); + if (toggle === false) return dropdownRef === null || dropdownRef === void 0 ? void 0 : (_dropdownRef$current7 = dropdownRef.current) === null || _dropdownRef$current7 === void 0 ? void 0 : _dropdownRef$current7.open(); + dropdownRef === null || dropdownRef === void 0 ? void 0 : (_dropdownRef$current8 = dropdownRef.current) === null || _dropdownRef$current8 === void 0 ? void 0 : _dropdownRef$current8.toggle(); + }, [dropdownRef]); + const triggerClone = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.cloneElement)(triggerEL, { ...triggerEL.props, + tag, + key: "dd-trigger", + ref: triggerRef, + onClickCapture: (_triggerEL$props = triggerEL.props) !== null && _triggerEL$props !== void 0 && _triggerEL$props.onClick ? null : handleToggle + }); + const dropdownClone = content ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_DropdownComponent__WEBPACK_IMPORTED_MODULE_1__.Dropdown, { ...props, + ref: dropdownRef, + children: content + }) : null; + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + document.addEventListener("click", handleClick, { + capture: true + }); + return () => document.removeEventListener("click", handleClick, { + capture: true + }); + }, [handleClick]); + const contextValue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => ({ + triggerRef, + dropdown: dropdownRef, + hasTarget: targetIsInsideDropdown, + addChild: child => childset.add(child), + removeChild: child => childset.delete(child), + open: () => { + var _dropdownRef$current9, _dropdownRef$current10; + + return dropdownRef === null || dropdownRef === void 0 ? void 0 : (_dropdownRef$current9 = dropdownRef.current) === null || _dropdownRef$current9 === void 0 ? void 0 : (_dropdownRef$current10 = _dropdownRef$current9.open) === null || _dropdownRef$current10 === void 0 ? void 0 : _dropdownRef$current10.call(_dropdownRef$current9); + }, + close: () => { + var _dropdownRef$current11, _dropdownRef$current12; + + return dropdownRef === null || dropdownRef === void 0 ? void 0 : (_dropdownRef$current11 = dropdownRef.current) === null || _dropdownRef$current11 === void 0 ? void 0 : (_dropdownRef$current12 = _dropdownRef$current11.close) === null || _dropdownRef$current12 === void 0 ? void 0 : _dropdownRef$current12.call(_dropdownRef$current11); + } + }), [triggerRef, dropdownRef]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (!parentDropdown) return; + parentDropdown.addChild(contextValue); + return () => parentDropdown.removeChild(contextValue); + }, []); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)(_DropdownContext__WEBPACK_IMPORTED_MODULE_2__.DropdownContext.Provider, { + value: contextValue, + children: [triggerClone, dropdownClone] + }); +}); +const useDropdown = () => { + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_DropdownContext__WEBPACK_IMPORTED_MODULE_2__.DropdownContext); +}; + +/***/ }), + +/***/ "./src/components/Error/Error.js": +/*!***************************************!*\ + !*** ./src/components/Error/Error.js ***! + \***************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ErrorWrapper": () => (/* binding */ ErrorWrapper) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _assets_icons__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../assets/icons */ "./src/assets/icons/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var _Button_Button__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Button/Button */ "./src/components/Button/Button.js"); +/* harmony import */ var _Space_Space__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Space/Space */ "./src/components/Space/Space.js"); +/* harmony import */ var _Error_styl__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Error.styl */ "./src/components/Error/Error.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + +const SLACK_INVITE_URL = "http://slack.labelstud.io.s3-website-us-east-1.amazonaws.com?source=product-error-msg"; +const ErrorWrapper = ({ + title, + message, + errorId, + stacktrace, + validation, + version, + onGoBack, + onReload, + possum = false +}) => { + const preparedStackTrace = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + return (stacktrace !== null && stacktrace !== void 0 ? stacktrace : "").trim(); + }, [stacktrace]); + const [copied, setCopied] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + const copyStacktrace = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + setCopied(true); + (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_3__.copyText)(preparedStackTrace); + setTimeout(() => setCopied(false), 1200); + }, [preparedStackTrace]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Block, { + name: "error-message", + children: [possum !== false && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + tag: "img", + name: "heidi", + src: (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_3__.absoluteURL)("/static/images/opossum_broken.svg"), + height: "111", + alt: "Heidi's down" + }), title && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "title", + children: title + }), message && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "detail", + dangerouslySetInnerHTML: { + __html: String(message) + } + }), preparedStackTrace && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "stracktrace", + dangerouslySetInnerHTML: { + __html: preparedStackTrace.replace(/(\n)/g, '
') + } + }), (validation === null || validation === void 0 ? void 0 : validation.length) > 0 && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + tag: "ul", + name: "validation", + children: validation.map(([field, errors]) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, { + children: [].concat(errors).map((err, i) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + tag: "li", + name: "message", + dangerouslySetInnerHTML: { + __html: err + } + }, i)) + }, field)) + }), (version || errorId) && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "version", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_Space_Space__WEBPACK_IMPORTED_MODULE_5__.Space, { + children: [version && `Version: ${version}`, errorId && `Error ID: ${errorId}`] + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "actions", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_Space_Space__WEBPACK_IMPORTED_MODULE_5__.Space, { + spread: true, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_Space_Space__WEBPACK_IMPORTED_MODULE_5__.Space, { + size: "small", + children: [preparedStackTrace && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_Button_Button__WEBPACK_IMPORTED_MODULE_4__.Button, { + disabled: copied, + onClick: copyStacktrace, + style: { + width: 180 + }, + children: copied ? "已复制" : "复制堆栈信息" + }), onGoBack && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_Button_Button__WEBPACK_IMPORTED_MODULE_4__.Button, { + onClick: onGoBack, + children: "\u8FD4\u56DE" + }), onReload && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_Button_Button__WEBPACK_IMPORTED_MODULE_4__.Button, { + onClick: onReload, + children: "\u91CD\u65B0\u52A0\u8F7D" + })] + }) + }) + })] + }); +}; + +/***/ }), + +/***/ "./src/components/Error/InlineError.js": +/*!*********************************************!*\ + !*** ./src/components/Error/InlineError.js ***! + \*********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "InlineError": () => (/* binding */ InlineError) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Error__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Error */ "./src/components/Error/Error.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + +const InlineError = ({ + children, + includeValidation, + className, + style +}) => { + const context = react__WEBPACK_IMPORTED_MODULE_0__.useContext(_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_1__.ApiContext); + react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { + context.showModal = false; + }, [context]); + return context.error ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Block, { + name: "inline-error", + mix: className, + style: style, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_Error__WEBPACK_IMPORTED_MODULE_3__.ErrorWrapper, { + possum: false, + ...context.errorFormatter(context.error, { + includeValidation + }) + }), children] + }) : null; +}; + +/***/ }), + +/***/ "./src/components/Form/Elements/Counter/Counter.js": +/*!*********************************************************!*\ + !*** ./src/components/Form/Elements/Counter/Counter.js ***! + \*********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_icons_fa__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react-icons/fa */ "./node_modules/react-icons/fa/index.esm.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Oneof_Oneof__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Oneof/Oneof */ "./src/components/Oneof/Oneof.js"); +/* harmony import */ var _FormField__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../FormField */ "./src/components/Form/FormField.js"); +/* harmony import */ var _Label_Label__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Label/Label */ "./src/components/Form/Elements/Label/Label.js"); +/* harmony import */ var _Counter_styl__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Counter.styl */ "./src/components/Form/Elements/Counter/Counter.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + +const allowedKeys = ['ArrowUp', 'ArrowDown', 'Backspace', 'Delete', /[0-9]/]; +const CounterContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(null); + +const Counter = ({ + label, + className, + validate, + required, + skip, + labelProps, + ...props +}) => { + var _props$min, _props$max, _props$value, _props$autofocus, _props$disabled; + + const [min, max] = [(_props$min = props.min) !== null && _props$min !== void 0 ? _props$min : -Infinity, (_props$max = props.max) !== null && _props$max !== void 0 ? _props$max : Infinity]; + + const normalizeValue = value => Math.max(min, Math.min(max, value)); + + const [currentValue, setCurrentValue] = react__WEBPACK_IMPORTED_MODULE_0__.useState(normalizeValue((_props$value = props.value) !== null && _props$value !== void 0 ? _props$value : 0)); + const [focused, setFocused] = react__WEBPACK_IMPORTED_MODULE_0__.useState((_props$autofocus = props.autofocus) !== null && _props$autofocus !== void 0 ? _props$autofocus : false); + const [disabled, setDisabled] = react__WEBPACK_IMPORTED_MODULE_0__.useState((_props$disabled = props.disabled) !== null && _props$disabled !== void 0 ? _props$disabled : null); + + const setNewValue = value => { + setCurrentValue(normalizeValue(Number(value))); + }; + + const increase = react__WEBPACK_IMPORTED_MODULE_0__.useCallback(() => { + var _props$step; + + setNewValue((currentValue !== null && currentValue !== void 0 ? currentValue : 0) + ((_props$step = props.step) !== null && _props$step !== void 0 ? _props$step : 1)); + }, [currentValue, props.step]); + const decrease = react__WEBPACK_IMPORTED_MODULE_0__.useCallback(() => { + var _props$step2; + + setNewValue((currentValue !== null && currentValue !== void 0 ? currentValue : 0) - ((_props$step2 = props.step) !== null && _props$step2 !== void 0 ? _props$step2 : 1)); + }, [currentValue, props.step]); + /**@type {(e: import('react').SyntheticEvent)} */ + + const onInputHandler = e => { + const allowedKey = allowedKeys.find(k => k instanceof RegExp ? k.test(e.key) : k === e.key); + if (!allowedKey && !e.metaKey) e.preventDefault(); + + if (allowedKey === 'ArrowUp') { + increase(); + e.preventDefault(); + } else if (allowedKey === 'ArrowDown') { + decrease(); + e.preventDefault(); + } + }; + /**@type {(e: import('react').SyntheticEvent)} */ + + + const onPasteHandler = e => { + const content = e.nativeEvent.clipboardData.getData('text'); + const isNumerical = /([0-9]+)/.test(content); + if (!isNumerical) e.preventDefault(); + }; + /**@type {(e: import('react').SyntheticEvent)} */ + + + const onChangeHandler = e => { + var _props$onChange; + + if (e.target.value) { + setCurrentValue(normalizeValue(Number(e.target.value))); + } else { + setCurrentValue(""); + } + + (_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, e); + }; + + const onFocusHandler = e => { + var _props$onFocus; + + setFocused(true); + (_props$onFocus = props.onFocus) === null || _props$onFocus === void 0 ? void 0 : _props$onFocus.call(props, e); + }; + + const onBlurHandler = e => { + var _props$onBlur; + + setFocused(false); + (_props$onBlur = props.onBlur) === null || _props$onBlur === void 0 ? void 0 : _props$onBlur.call(props, e); + }; + + const onClickHandler = (type, input) => e => { + var _document$activeEleme; + + e.preventDefault(); + e.stopPropagation(); + (_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.blur(); + setFocused(); + input.current.focus(); + getSelection().removeAllRanges(); + if (type === 'increase') return increase();else if (type === 'decrease') return decrease(); + }; + + const field = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_FormField__WEBPACK_IMPORTED_MODULE_3__.FormField, { + label: label, + name: props.name, + validate: validate, + required: required, + setValue: setNewValue, + skip: skip, + onDependencyChanged: f => { + if (f.type === 'checkbox') setDisabled(!f.checked); + }, + ...props, + children: (ref, dep) => { + const depDisabled = (dep === null || dep === void 0 ? void 0 : dep.type) === 'checkbox' && (dep === null || dep === void 0 ? void 0 : dep.checked) === false || false; + const fieldDisabled = disabled !== null && disabled !== void 0 ? disabled : depDisabled; + const contextValue = { + currentValue, + min, + max, + disabled: fieldDisabled, + ref, + onClickHandler + }; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(CounterContext.Provider, { + value: contextValue, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_1__.Block, { + name: "counter", + mod: { + focused, + disabled: fieldDisabled + }, + mix: className, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(CounterButton, { + type: "decrease" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_1__.Elem, { + ref: ref, + tag: "input", + name: "input", + type: "text", + disabled: fieldDisabled, + value: currentValue, + onKeyDown: onInputHandler, + onPaste: onPasteHandler, + onChange: onChangeHandler, + onFocus: onFocusHandler, + onBlur: onBlurHandler + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(CounterButton, { + type: "increase" + })] + }) + }); + } + }); + + return label ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_Label_Label__WEBPACK_IMPORTED_MODULE_4__.default, { ...(labelProps !== null && labelProps !== void 0 ? labelProps : {}), + text: label, + required: required, + children: field + }) : field; +}; + +const CounterButton = ({ + type +}) => { + const { + currentValue, + min, + max, + disabled, + ref, + onClickHandler + } = react__WEBPACK_IMPORTED_MODULE_0__.useContext(CounterContext); + const compareLimit = type === 'increase' ? max : min; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_1__.Elem, { + tag: "a", + href: "#", + name: "btn", + mod: { + type, + disabled: currentValue === compareLimit || disabled + }, + onClick: onClickHandler(type, ref), + onMouseDownCapture: e => e.preventDefault(), + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_Oneof_Oneof__WEBPACK_IMPORTED_MODULE_2__.Oneof, { + value: type, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(react_icons_fa__WEBPACK_IMPORTED_MODULE_7__.FaMinus, { + case: "decrease" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(react_icons_fa__WEBPACK_IMPORTED_MODULE_7__.FaPlus, { + case: "increase" + })] + }) + }); +}; + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Counter); + +/***/ }), + +/***/ "./src/components/Form/Elements/Input/Input.js": +/*!*****************************************************!*\ + !*** ./src/components/Form/Elements/Input/Input.js ***! + \*****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _FormField__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../FormField */ "./src/components/Form/FormField.js"); +/* harmony import */ var _Label_Label__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Label/Label */ "./src/components/Form/Elements/Label/Label.js"); +/* harmony import */ var _Input_styl__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Input.styl */ "./src/components/Form/Elements/Input/Input.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + +const Input = ({ + label, + className, + validate, + required, + skip, + labelProps, + ghost, + ...props +}) => { + const classList = [(0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)('input').mod({ + ghost + }), className].join(" ").trim(); + + const input = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_FormField__WEBPACK_IMPORTED_MODULE_2__.FormField, { + label: label, + name: props.name, + validate: validate, + required: required, + skip: skip, + ...props, + children: ref => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("input", { ...props, + ref: ref, + className: classList + }) + }); + + return label ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_Label_Label__WEBPACK_IMPORTED_MODULE_3__.default, { ...(labelProps !== null && labelProps !== void 0 ? labelProps : {}), + text: label, + required: required, + children: input + }) : input; +}; + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Input); + +/***/ }), + +/***/ "./src/components/Form/Elements/Label/Label.js": +/*!*****************************************************!*\ + !*** ./src/components/Form/Elements/Label/Label.js ***! + \*****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Label_styl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Label.styl */ "./src/components/Form/Elements/Label/Label.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + +const Label = ({ + text, + children, + required, + placement, + description, + size, + large, + style, + simple, + flat +}) => { + const rootClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)('label'); + const classList = [rootClass]; + const tagName = simple ? 'div' : 'label'; + const mods = { + size, + large, + flat, + placement, + withDescription: !!description, + empty: !children + }; + classList.push(rootClass.mod(mods)); + return /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(tagName, { + 'className': classList.join(" "), + 'data-required': required, + 'style': style + }, /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.Fragment, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("div", { + className: rootClass.elem('text'), + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)("div", { + className: rootClass.elem('content'), + children: [text, description && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("div", { + className: rootClass.elem("description"), + children: description + })] + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("div", { + className: rootClass.elem('field'), + children: children + })] + })); +}; + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Label); + +/***/ }), + +/***/ "./src/components/Form/Elements/RadioGroup/RadioGroup.js": +/*!***************************************************************!*\ + !*** ./src/components/Form/Elements/RadioGroup/RadioGroup.js ***! + \***************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "RadioGroup": () => (/* binding */ RadioGroup) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var ___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! .. */ "./src/components/Form/Elements/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _FormField__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../FormField */ "./src/components/Form/FormField.js"); +/* harmony import */ var _RadioGroup_styl__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./RadioGroup.styl */ "./src/components/Form/Elements/RadioGroup/RadioGroup.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + +const RadioContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(); +const { + Block, + Elem +} = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_2__.BemWithSpecifiContext)(); +const RadioGroup = ({ + label, + className, + validate, + required, + skip, + simple, + labelProps, + size, + value, + onChange, + children, + ...props +}) => { + const [currentValue, setCurrentValue] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(value); + + const onRadioChange = value => { + setCurrentValue(value); + onChange === null || onChange === void 0 ? void 0 : onChange(value); + }; + + const field = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_FormField__WEBPACK_IMPORTED_MODULE_3__.FormField, { + name: props.name, + label: label, + validate: validate, + required: required, + skip: skip, + setValue: value => setCurrentValue(value), + ...props, + children: (ref, dep, form) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(RadioContext.Provider, { + value: { + value: currentValue, + onChange: value => { + onRadioChange(value); + form.autosubmit(); + }, + setValue: setCurrentValue, + isSimple: simple === true + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(Block, { + name: "radio-group", + mod: { + size, + simple + }, + mix: className, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("input", { + ref: ref, + name: props.name, + type: "hidden", + defaultValue: currentValue + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(Elem, { + name: "buttons", + children: children + })] + }) + }) + }); + + return label ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(___WEBPACK_IMPORTED_MODULE_1__.Label, { ...(labelProps !== null && labelProps !== void 0 ? labelProps : {}), + text: label, + simple: simple, + required: required, + children: field + }) : field; +}; + +const RadioButton = ({ + value, + disabled, + children, + label, + description, + ...props +}) => { + const { + onChange, + setValue, + value: currentValue, + isSimple + } = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(RadioContext); + const checked = value === currentValue; + const clickHandler = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(e => { + e.preventDefault(); + e.stopPropagation(); + onChange(value); + }, [value]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (props.checked) setValue(value); + }, [props.checked]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(Elem, { + name: "button", + mod: { + checked, + disabled + }, + onClickCapture: clickHandler, + children: isSimple ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(___WEBPACK_IMPORTED_MODULE_1__.Label, { + placement: "right", + text: label, + description: description, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("input", { + type: "radio", + value: value, + checked: checked, + readOnly: true, + style: { + pointerEvents: 'none' + } + }) + }) : children + }); +}; + +RadioGroup.Button = RadioButton; + +/***/ }), + +/***/ "./src/components/Form/Elements/Select/Select.js": +/*!*******************************************************!*\ + !*** ./src/components/Form/Elements/Select/Select.js ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _FormField__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../FormField */ "./src/components/Form/FormField.js"); +/* harmony import */ var _Label_Label__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Label/Label */ "./src/components/Form/Elements/Label/Label.js"); +/* harmony import */ var _Select_styl__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Select.styl */ "./src/components/Form/Elements/Select/Select.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + +const Select = ({ + label, + className, + options, + validate, + required, + skip, + labelProps, + ghost, + ...props +}) => { + const rootClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)('select'); + const classList = rootClass.mod({ + ghost + }).mix(className); + + const selectWrapper = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_FormField__WEBPACK_IMPORTED_MODULE_2__.FormField, { + name: props.name, + label: label, + validate: validate, + required: required, + skip: skip, + ...props, + children: ref => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", { + className: classList, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("select", { ...props, + ref: ref, + className: rootClass.elem('list'), + required: true, + children: [props.placeholder && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("option", { + value: "", + disabled: true, + hidden: true, + selected: true, + children: props.placeholder + }), (options !== null && options !== void 0 ? options : []).map(option => { + var _option$value, _option$label, _option$disabled, _option$hidden; + + const value = (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option; + const label = (_option$label = option.label) !== null && _option$label !== void 0 ? _option$label : value; + const disabled = (_option$disabled = option.disabled) !== null && _option$disabled !== void 0 ? _option$disabled : false; + const hidden = (_option$hidden = option.hidden) !== null && _option$hidden !== void 0 ? _option$hidden : false; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("option", { + value: value, + disabled: disabled, + hidden: hidden, + children: label + }, value); + })] + }) + }) + }); + + return label ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_Label_Label__WEBPACK_IMPORTED_MODULE_3__.default, { ...(labelProps !== null && labelProps !== void 0 ? labelProps : {}), + text: label, + required: required, + children: selectWrapper + }) : selectWrapper; +}; + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Select); + +/***/ }), + +/***/ "./src/components/Form/Elements/TextArea/TextArea.js": +/*!***********************************************************!*\ + !*** ./src/components/Form/Elements/TextArea/TextArea.js ***! + \***********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _FormField__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../FormField */ "./src/components/Form/FormField.js"); +/* harmony import */ var _Label_Label__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Label/Label */ "./src/components/Form/Elements/Label/Label.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + +const TextArea = ({ + label, + className, + validate, + required, + skip, + labelProps, + ...props +}) => { + const classList = [(0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)('textarea'), className].join(" ").trim(); + + const input = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_FormField__WEBPACK_IMPORTED_MODULE_2__.FormField, { + label: label, + name: props.name, + validate: validate, + required: required, + skip: skip, + ...props, + children: ref => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)("textarea", { ...props, + ref: ref, + className: classList + }) + }); + + return label ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_Label_Label__WEBPACK_IMPORTED_MODULE_3__.default, { ...(labelProps !== null && labelProps !== void 0 ? labelProps : {}), + text: label, + required: required, + children: input + }) : input; +}; + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (TextArea); + +/***/ }), + +/***/ "./src/components/Form/Elements/Toggle/Toggle.js": +/*!*******************************************************!*\ + !*** ./src/components/Form/Elements/Toggle/Toggle.js ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _FormField__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../FormField */ "./src/components/Form/FormField.js"); +/* harmony import */ var _Label_Label__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Label/Label */ "./src/components/Form/Elements/Label/Label.js"); +/* harmony import */ var _Toggle_styl__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Toggle.styl */ "./src/components/Form/Elements/Toggle/Toggle.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + +const Toggle = ({ + className, + label, + labelProps, + description, + checked, + defaultChecked, + onChange, + validate, + required, + skip, + ...props +}) => { + var _ref; + + const rootClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)('toggle'); + const [isChecked, setIsChecked] = react__WEBPACK_IMPORTED_MODULE_0__.useState((_ref = defaultChecked !== null && defaultChecked !== void 0 ? defaultChecked : checked) !== null && _ref !== void 0 ? _ref : false); + const classList = [rootClass]; + const mods = {}; + if (isChecked) mods.checked = isChecked; + mods.disabled = props.disabled; + classList.push(rootClass.mod(mods), className); + + const formField = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_FormField__WEBPACK_IMPORTED_MODULE_2__.FormField, { + label: label, + name: props.name, + validate: validate, + required: required, + skip: skip, + setValue: value => setIsChecked(value), + ...props, + children: ref => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("div", { + className: classList.join(" "), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("input", { + ref: ref, + ...props, + className: rootClass.elem('input'), + type: "checkbox", + checked: isChecked, + onChange: e => { + setIsChecked(e.target.checked); + onChange === null || onChange === void 0 ? void 0 : onChange(e); + } + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("span", { + className: rootClass.elem('indicator') + })] + }) + }); + + return label ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_Label_Label__WEBPACK_IMPORTED_MODULE_3__.default, { + placement: "right", + required: required, + text: label, + children: formField, + description: description, + ...(labelProps !== null && labelProps !== void 0 ? labelProps : {}) + }) : formField; +}; + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Toggle); + +/***/ }), + +/***/ "./src/components/Form/Elements/index.js": +/*!***********************************************!*\ + !*** ./src/components/Form/Elements/index.js ***! + \***********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Counter": () => (/* reexport safe */ _Counter_Counter__WEBPACK_IMPORTED_MODULE_0__.default), +/* harmony export */ "Input": () => (/* reexport safe */ _Input_Input__WEBPACK_IMPORTED_MODULE_1__.default), +/* harmony export */ "Label": () => (/* reexport safe */ _Label_Label__WEBPACK_IMPORTED_MODULE_2__.default), +/* harmony export */ "Select": () => (/* reexport safe */ _Select_Select__WEBPACK_IMPORTED_MODULE_3__.default), +/* harmony export */ "TextArea": () => (/* reexport safe */ _TextArea_TextArea__WEBPACK_IMPORTED_MODULE_4__.default), +/* harmony export */ "Toggle": () => (/* reexport safe */ _Toggle_Toggle__WEBPACK_IMPORTED_MODULE_5__.default) +/* harmony export */ }); +/* harmony import */ var _Counter_Counter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Counter/Counter */ "./src/components/Form/Elements/Counter/Counter.js"); +/* harmony import */ var _Input_Input__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Input/Input */ "./src/components/Form/Elements/Input/Input.js"); +/* harmony import */ var _Label_Label__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Label/Label */ "./src/components/Form/Elements/Label/Label.js"); +/* harmony import */ var _Select_Select__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Select/Select */ "./src/components/Form/Elements/Select/Select.js"); +/* harmony import */ var _TextArea_TextArea__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./TextArea/TextArea */ "./src/components/Form/Elements/TextArea/TextArea.js"); +/* harmony import */ var _Toggle_Toggle__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Toggle/Toggle */ "./src/components/Form/Elements/Toggle/Toggle.js"); + + + + + + + +/***/ }), + +/***/ "./src/components/Form/Form.js": +/*!*************************************!*\ + !*** ./src/components/Form/Form.js ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Form) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var shallow_equal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! shallow-equal */ "./node_modules/shallow-equal/dist/index.esm.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _providers_MultiProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../providers/MultiProvider */ "./src/providers/MultiProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_debounce__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../utils/debounce */ "./src/utils/debounce.js"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var _Button_Button__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Button/Button */ "./src/components/Button/Button.js"); +/* harmony import */ var _Oneof_Oneof__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Oneof/Oneof */ "./src/components/Oneof/Oneof.js"); +/* harmony import */ var _Space_Space__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Space/Space */ "./src/components/Space/Space.js"); +/* harmony import */ var _Elements__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Elements */ "./src/components/Form/Elements/index.js"); +/* harmony import */ var _Form_styl__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Form.styl */ "./src/components/Form/Form.styl"); +/* harmony import */ var _FormContext__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./FormContext */ "./src/components/Form/FormContext.js"); +/* harmony import */ var _Validation_Validators__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Validation/Validators */ "./src/components/Form/Validation/Validators.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + + + + + + + + + + + + + + +class Form extends react__WEBPACK_IMPORTED_MODULE_0__.Component { + constructor(...args) { + super(...args); + + _defineProperty(this, "state", { + validation: null, + showValidation: true, + submitting: false + }); + + _defineProperty(this, "formElement", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createRef()); + + _defineProperty(this, "apiRef", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createRef()); + + _defineProperty(this, "fields", new Set()); + + _defineProperty(this, "validation", new Map()); + + _defineProperty(this, "onFormSubmitted", async e => { + e.preventDefault(); + this.validateFields(); + + if (!this.validation.size) { + this.setState({ + step: "submitting" + }); + this.submit(); + } else { + this.setState({ + step: "invalid" + }); + } + }); + + _defineProperty(this, "_onAutoSubmit", () => { + this.validateFields(); + + if (!this.validation.size) { + this.submit(); + } + }); + + _defineProperty(this, "onAutoSubmit", this.props.debounce ? (0,_utils_debounce__WEBPACK_IMPORTED_MODULE_5__.debounce)(this._onAutoSubmit, this.props.debounce) : this._onAutoSubmit); + + _defineProperty(this, "onFormChanged", async e => { + var _this$props$onChange, _this$props; + + e.stopPropagation(); + (_this$props$onChange = (_this$props = this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, e); + this.autosubmit(); + }); + } + + get api() { + return this.apiRef.current; + } + + componentDidMount() { + if (this.props.formData) { + this.fillFormData(); + } + } + + componentDidUpdate(prevProps) { + var _prevProps$formData, _this$props$formData; + + const equal = (0,shallow_equal__WEBPACK_IMPORTED_MODULE_1__.shallowEqualObjects)((_prevProps$formData = prevProps.formData) !== null && _prevProps$formData !== void 0 ? _prevProps$formData : {}, (_this$props$formData = this.props.formData) !== null && _this$props$formData !== void 0 ? _this$props$formData : {}); + + if (!equal) { + this.fillFormData(); + } + } + + render() { + const providers = [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_FormContext__WEBPACK_IMPORTED_MODULE_12__.FormContext.Provider, { + value: this + }, "form-ctx"), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_FormContext__WEBPACK_IMPORTED_MODULE_12__.FormValidationContext.Provider, { + value: this.state.validation + }, "form-validation-ctx"), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_FormContext__WEBPACK_IMPORTED_MODULE_12__.FormSubmissionContext.Provider, { + value: this.state.submitting + }, "form-submission-ctx"), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_FormContext__WEBPACK_IMPORTED_MODULE_12__.FormStateContext.Provider, { + value: this.state.state + }, "form-state-ctx"), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_FormContext__WEBPACK_IMPORTED_MODULE_12__.FormResponseContext.Provider, { + value: this.state.lastResponse + }, "form-response"), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_2__.ApiProvider, { + ref: this.apiRef + }, "form-api")]; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_providers_MultiProvider__WEBPACK_IMPORTED_MODULE_3__.MultiProvider, { + providers: providers, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsxs)("form", { + ref: this.formElement, + className: (0,_utils_bem__WEBPACK_IMPORTED_MODULE_4__.cn)('form'), + action: this.props.action, + onSubmit: this.onFormSubmitted, + onChange: this.onFormChanged, + autoComplete: this.props.autoComplete, + autoSave: this.props.autoSave, + style: this.props.style, + children: [this.props.children, this.state.validation && this.state.showValidation && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(ValidationRenderer, { + validation: this.state.validation + })] + }) + }); + } + + registerField(field) { + const existingField = this.getFieldContext(field.name); + + if (!existingField) { + this.fields.add(field); + this.fillFormData(); + } else { + Object.assign(existingField, field); + } + } + + unregisterField(name) { + const field = this.getFieldContext(name); + if (field) this.fields.delete(field); + } + + getField(name) { + var _this$getFieldContext; + + return (_this$getFieldContext = this.getFieldContext(name)) === null || _this$getFieldContext === void 0 ? void 0 : _this$getFieldContext.field; + } + + getFieldContext(name) { + return Array.from(this.fields).find(f => f.name === name); + } + + disableValidationMessage() { + this.setState({ + showValidation: false + }); + } + + enableValidationMessage() { + this.setState({ + showValidation: true + }); + } + + autosubmit() { + if (this.props.autosubmit) { + setTimeout(() => { + this.onAutoSubmit(); + }, 100); + } + } + + assembleFormData({ + asJSON = false, + full = false, + booleansAsNumbers = false, + fieldsFilter + } = {}) { + let fields = Array.from(this.fields); + + if (fieldsFilter instanceof Function) { + fields = fields.filter(fieldsFilter); + } + + const requestBody = fields.reduce((res, { + name, + field, + skip + }) => { + const skipField = skip || this.props.skipEmpty && !field.value; + + if (full === true || !skipField) { + const value = (() => { + const inputValue = field.value; + + if (['checkbox', 'radio'].includes(field.type)) { + if (inputValue !== null && inputValue !== 'on' && inputValue !== 'true') { + return field.checked ? inputValue : null; + } + + return booleansAsNumbers ? Number(field.checked) : field.checked; + } + + return inputValue; + })(); + + if (value !== null) res.push([name, value]); + } + + return res; + }, []); + + if (asJSON) { + return requestBody.reduce((res, [key, value]) => ({ ...res, + [key]: value + }), {}); + } else { + const formData = new FormData(); + requestBody.forEach(([key, value]) => formData.append(key, value)); + return formData; + } + } + + async submit({ + fieldsFilter + } = {}) { + var _this$props$prepareDa, _this$props$prepareDa2, _this$props2; + + this.setState({ + submitting: true, + lastResponse: null + }); + const rawAction = this.formElement.current.getAttribute("action"); + const useApi = this.api.isValidMethod(rawAction); + const data = this.assembleFormData({ + asJSON: useApi, + fieldsFilter + }); + const body = (_this$props$prepareDa = (_this$props$prepareDa2 = (_this$props2 = this.props).prepareData) === null || _this$props$prepareDa2 === void 0 ? void 0 : _this$props$prepareDa2.call(_this$props2, data)) !== null && _this$props$prepareDa !== void 0 ? _this$props$prepareDa : data; + let success = false; + + if (useApi) { + success = await this.submitWithAPI(rawAction, body); + } else { + success = await this.submitWithFetch(body); + } + + this.setState({ + submitting: false, + state: success ? "success" : "fail" + }, () => { + setTimeout(() => { + this.setState({ + state: null + }); + }, 1500); + }); + } + + async submitWithAPI(action, body) { + var _this$props$params; + + const urlParams = (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_6__.objectClean)((_this$props$params = this.props.params) !== null && _this$props$params !== void 0 ? _this$props$params : {}); + const response = await this.api.callApi(action, { + params: urlParams, + body + }); + this.setState({ + lastResponse: response + }); + + if (response === null) { + var _this$props$onError, _this$props3; + + (_this$props$onError = (_this$props3 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props3); + return false; + } else { + var _this$props$onSubmit, _this$props4; + + (_this$props$onSubmit = (_this$props4 = this.props).onSubmit) === null || _this$props$onSubmit === void 0 ? void 0 : _this$props$onSubmit.call(_this$props4, response); + return true; + } + } + + async submitWithFetch(body) { + var _this$props$method; + + const action = this.formElement.current.action; + const method = ((_this$props$method = this.props.method) !== null && _this$props$method !== void 0 ? _this$props$method : 'POST').toUpperCase(); + const response = await fetch(action, { + method, + body + }); + + try { + const result = await response.json(); + this.setState({ + lastResponse: result + }); + + if (result.validation_errors) { + Object.entries(result.validation_errors).forEach(([key, messages]) => { + const field = this.getField(key); + this.validation.set(field.name, { + label: field.label, + field: field.field, + messages + }); + }); + this.setState({ + validation: this.validation + }); + } + + if (response.ok) { + var _this$props$onSubmit2, _this$props5; + + (_this$props$onSubmit2 = (_this$props5 = this.props).onSubmit) === null || _this$props$onSubmit2 === void 0 ? void 0 : _this$props$onSubmit2.call(_this$props5, result); + return true; + } else { + var _this$props$onError2, _this$props6; + + (_this$props$onError2 = (_this$props6 = this.props).onError) === null || _this$props$onError2 === void 0 ? void 0 : _this$props$onError2.call(_this$props6, result); + } + } catch (err) { + var _this$props$onError3, _this$props7; + + console.log(err); + (_this$props$onError3 = (_this$props7 = this.props).onError) === null || _this$props$onError3 === void 0 ? void 0 : _this$props$onError3.call(_this$props7, err); + } + + return false; + } + + validateFields() { + this.validation.clear(); + + for (const field of this.fields) { + const result = this.validateField(field); + + if (result.length) { + this.validation.set(field.name, { + label: field.label, + messages: result, + field: field.field + }); + } + } + + if (this.validation.size) { + this.setState({ + validation: this.validation + }); + } else { + this.setState({ + validation: null + }); + } + + return this.validation.size === 0; + } + + validateField(field) { + var _element$value; + + const messages = []; + const { + validation, + field: element + } = field; + const value = ((_element$value = element.value) === null || _element$value === void 0 ? void 0 : _element$value.trim()) || null; + validation.forEach(validator => { + const result = validator(field.label, value); + if (result) messages.push(result); + }); + return messages; + } + + fillFormData() { + if (!this.props.formData) return; + if (this.fields.size === 0) return; + Object.entries(this.props.formData).forEach(([key, value]) => { + const field = this.getFieldContext(key); + + if (field && field.value !== value) { + field.setValue(value); + } + }); + } + +} + +const ValidationRenderer = ({ + validation +}) => { + const rootClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_4__.cn)('form-validation'); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)("div", { + className: rootClass, + children: Array.from(validation).map(([name, result]) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsxs)("div", { + className: rootClass.elem('group'), + onClick: () => result.field.focus(), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)("div", { + className: rootClass.elem('field'), + children: result.label + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)("div", { + className: rootClass.elem('messages'), + children: result.messages.map((message, i) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)("div", { + className: rootClass.elem('message'), + children: message + }, `${name}-${i}`)) + })] + }, name)) + }); +}; + +Form.Validator = _Validation_Validators__WEBPACK_IMPORTED_MODULE_13__; + +Form.Row = ({ + columnCount, + rowGap, + children, + style, + spread = false +}) => { + const styles = {}; + if (columnCount) styles['--column-count'] = columnCount; + if (rowGap) styles['--row-gap'] = rowGap; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)("div", { + className: (0,_utils_bem__WEBPACK_IMPORTED_MODULE_4__.cn)('form').elem('row').mod({ + spread + }), + style: { ...(style !== null && style !== void 0 ? style : {}), + ...styles + }, + children: children + }); +}; + +Form.Builder = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(({ + fields: defaultFields, + formData: defaultFormData, + fetchFields, + fetchFormData, + children, + formRowStyle, + onSubmit, + withActions, + ...props +}, ref) => { + const formRef = ref !== null && ref !== void 0 ? ref : (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const [fields, setFields] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(defaultFields !== null && defaultFields !== void 0 ? defaultFields : []); + const [formData, setFormData] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(defaultFormData !== null && defaultFormData !== void 0 ? defaultFormData : {}); + + const renderFields = fields => { + return fields.map((field, index) => { + var _field$name; + + if (!field) return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)("div", {}, `spacer-${index}`); + const defaultValue = (formData === null || formData === void 0 ? void 0 : formData[field.name]) || undefined; + const triggerUpdate = props.autosubmit !== true && field.trigger_form_update === true; + const commonProps = { + key: (_field$name = field.name) !== null && _field$name !== void 0 ? _field$name : index, + ...field + }; + + if (triggerUpdate) { + commonProps.onChange = async () => { + await formRef.current.submit({ + fieldsFilter: f => f.name === field.name + }); + await updateFields(); + await updateFormData(); + }; + } + + if (field.type === 'select') { + var _field$value; + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_Elements__WEBPACK_IMPORTED_MODULE_10__.Select, { ...commonProps, + defaultValue: (_field$value = field.value) !== null && _field$value !== void 0 ? _field$value : defaultValue + }); + } else if (field.type === 'counter') { + var _field$value2; + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_Elements__WEBPACK_IMPORTED_MODULE_10__.Counter, { ...commonProps, + defaultValue: (_field$value2 = field.value) !== null && _field$value2 !== void 0 ? _field$value2 : defaultValue + }); + } else if (field.type === 'toggle') { + var _field$value3; + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_Elements__WEBPACK_IMPORTED_MODULE_10__.Toggle, { ...commonProps, + checked: (_field$value3 = field.value) !== null && _field$value3 !== void 0 ? _field$value3 : defaultValue + }); + } else { + var _field$value4; + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_Elements__WEBPACK_IMPORTED_MODULE_10__.Input, { ...commonProps, + defaultValue: (_field$value4 = field.value) !== null && _field$value4 !== void 0 ? _field$value4 : defaultValue + }); + } + }); + }; + + const renderColumns = columns => { + return columns.map((col, index) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)("div", { + className: (0,_utils_bem__WEBPACK_IMPORTED_MODULE_4__.cn)('form').elem('column'), + style: { + width: col.width + }, + children: renderFields(col.fields) + }, index)); + }; + + const updateFields = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + if (fetchFields) { + const newFields = await fetchFields(); + + if (JSON.stringify(fields) !== JSON.stringify(newFields)) { + setFields(newFields); + } + } + }, [fetchFields]); + const updateFormData = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + if (fetchFormData) { + const newFormData = await fetchFormData(); + + if ((0,shallow_equal__WEBPACK_IMPORTED_MODULE_1__.shallowEqualObjects)(formData, newFormData) === false) { + setFormData(newFormData); + } + } + }, [fetchFormData]); + const handleOnSubmit = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async (...args) => { + onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(...args); + await updateFields(); + await updateFormData(); + }, [onSubmit, fetchFormData]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + updateFields(); + }, [updateFields]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + updateFormData(); + }, [updateFormData]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + setFields(defaultFields); + }, [defaultFields]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsxs)(Form, { ...props, + onSubmit: handleOnSubmit, + ref: formRef, + children: [(fields !== null && fields !== void 0 ? fields : []).map(({ + columnCount, + fields, + columns + }, index) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(Form.Row, { + columnCount: columnCount, + style: formRowStyle, + spread: true, + children: columns ? renderColumns(columns) : renderFields(fields) + }, index)), children, props.autosubmit !== true && withActions === true && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(Form.Actions, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_Button_Button__WEBPACK_IMPORTED_MODULE_7__.Button, { + type: "submit", + look: "primary", + style: { + width: 120 + }, + children: "Save" + }) + })] + }); +}); + +Form.Actions = ({ + children, + valid, + extra, + size +}) => { + const rootClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_4__.cn)('form'); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsxs)("div", { + className: rootClass.elem('submit').mod({ + size + }), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)("div", { + className: rootClass.elem('info').mod({ + valid + }), + children: extra + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_Space_Space__WEBPACK_IMPORTED_MODULE_9__.Space, { + children: children + })] + }); +}; + +Form.Indicator = () => { + const state = react__WEBPACK_IMPORTED_MODULE_0__.useContext(_FormContext__WEBPACK_IMPORTED_MODULE_12__.FormStateContext); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Block, { + name: "form-indicator", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_Oneof_Oneof__WEBPACK_IMPORTED_MODULE_8__.Oneof, { + value: state, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + tag: "span", + mod: { + type: state + }, + name: "item", + case: "success", + children: "\u4FDD\u5B58!" + }) + }) + }); +}; + +Form.ResponseParser = ({ + children +}) => { + const callback = children; + + if (callback instanceof Function === false) { + throw new Error("Response Parser only accepts function as a child"); + } + + const response = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_FormContext__WEBPACK_IMPORTED_MODULE_12__.FormResponseContext); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.Fragment, { + children: response ? callback(response) : null + }); +}; + +/***/ }), + +/***/ "./src/components/Form/FormContext.js": +/*!********************************************!*\ + !*** ./src/components/Form/FormContext.js ***! + \********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "FormContext": () => (/* binding */ FormContext), +/* harmony export */ "FormValidationContext": () => (/* binding */ FormValidationContext), +/* harmony export */ "FormSubmissionContext": () => (/* binding */ FormSubmissionContext), +/* harmony export */ "FormStateContext": () => (/* binding */ FormStateContext), +/* harmony export */ "FormResponseContext": () => (/* binding */ FormResponseContext) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); + +const FormContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(); +FormContext.displayName = 'FormContext'; +const FormValidationContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(); +FormValidationContext.displayName = 'FormValidationContext'; +const FormSubmissionContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(); +FormSubmissionContext.displayName = 'FormSubmissionContext'; +const FormStateContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(); +FormStateContext.displayName = 'FormStateContext'; +const FormResponseContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(); +FormResponseContext.displayName = 'FormResponseContext'; + +/***/ }), + +/***/ "./src/components/Form/FormField.js": +/*!******************************************!*\ + !*** ./src/components/Form/FormField.js ***! + \******************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "FormField": () => (/* binding */ FormField) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var _FormContext__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./FormContext */ "./src/components/Form/FormContext.js"); +/* harmony import */ var _Validation_Validators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Validation/Validators */ "./src/components/Form/Validation/Validators.js"); + + + + +const FormField = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(({ + label, + name, + children, + required, + validate, + skip, + setValue, + dependency, + validators, + ...props +}, ref) => { + var _validators$forEach; + + /**@type {Form} */ + const context = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_FormContext__WEBPACK_IMPORTED_MODULE_2__.FormContext); + const [dependencyField, setDependencyField] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + const field = ref !== null && ref !== void 0 ? ref : (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const validation = [...(validate !== null && validate !== void 0 ? validate : [])]; + validators === null || validators === void 0 ? void 0 : (_validators$forEach = validators.forEach) === null || _validators$forEach === void 0 ? void 0 : _validators$forEach.call(validators, validator => { + const [name, value] = validator.split(/:(.+)/).slice(0, 2); + const validatorFunc = _Validation_Validators__WEBPACK_IMPORTED_MODULE_3__[name]; + + if ((0,_utils_helpers__WEBPACK_IMPORTED_MODULE_1__.isDefined)(validatorFunc)) { + if ((0,_utils_helpers__WEBPACK_IMPORTED_MODULE_1__.isDefined)(value)) { + validation.push(validatorFunc(value)); + } else { + validation.push(validatorFunc); + } + } + }); + if (required) validation.push(_Validation_Validators__WEBPACK_IMPORTED_MODULE_3__.required); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (!context || !dependency) return; + let field = null; + const dep = context.getFieldContext(dependency); + + const handler = () => { + var _props$onDependencyCh; + + (_props$onDependencyCh = props.onDependencyChanged) === null || _props$onDependencyCh === void 0 ? void 0 : _props$onDependencyCh.call(props, dep.field); + }; + + if (dep) { + dep.field.addEventListener('change', handler); + field = dep.field; + } else { + console.warn(`Dependency field not found ${dependency}`); + } + + setDependencyField(field); + return () => dep.field.removeEventListener('change', handler); + }, [context, field, dependency]); + const setValueCallback = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(value => { + if (!field || !field.current) return; + /**@type {HTMLInputElement|HTMLTextAreaElement} */ + + const input = field.current; + + if (setValue instanceof Function) { + setValue(value); + } else if (input.type === 'checkbox' || input.type === 'radio') { + input.checked = value !== null && value !== void 0 ? value : input.checked; + } else if (value === null) { + input.value = ""; + } else { + input.value = value; + } + + const evt = document.createEvent("HTMLEvents"); + evt.initEvent("change", false, true); + input.dispatchEvent(evt); + }, [field]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + context === null || context === void 0 ? void 0 : context.registerField({ + label, + name, + validation, + skip, + field: field.current, + setValue: setValueCallback + }); + return () => context === null || context === void 0 ? void 0 : context.unregisterField(name); + }, [field, setValueCallback]); + return children(field, dependencyField, context); +}); + +/***/ }), + +/***/ "./src/components/Form/Validation/Validators.js": +/*!******************************************************!*\ + !*** ./src/components/Form/Validation/Validators.js ***! + \******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "required": () => (/* binding */ required), +/* harmony export */ "matchPattern": () => (/* binding */ matchPattern), +/* harmony export */ "json": () => (/* binding */ json), +/* harmony export */ "regexp": () => (/* binding */ regexp) +/* harmony export */ }); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var _Validation_styl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Validation.styl */ "./src/components/Form/Validation/Validation.styl"); + + +const required = (fieldName, value) => { + if (!(0,_utils_helpers__WEBPACK_IMPORTED_MODULE_0__.isDefined)(value) || (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_0__.isEmptyString)(value)) { + return `${fieldName} 必填`; + } +}; +const matchPattern = pattern => (fieldName, value) => { + pattern = typeof pattern === 'string' ? new RegExp(pattern) : pattern; + + if (!(0,_utils_helpers__WEBPACK_IMPORTED_MODULE_0__.isEmptyString)(value) && value.match(pattern) === null) { + return `${fieldName} 必须匹配模式 ${pattern}`; + } +}; +const json = (fieldName, value) => { + const err = `${fieldName} 必须是有效的 JSON 字符串`; + if (!(0,_utils_helpers__WEBPACK_IMPORTED_MODULE_0__.isDefined)(value) || value.trim().length === 0) return; + + if (/^(\{|\[)/.test(value) === false || /(\}|\])$/.test(value) === false) { + return err; + } + + try { + JSON.parse(value); + } catch (e) { + return err; + } +}; +const regexp = (fieldName, value) => { + try { + new RegExp(value); + } catch (err) { + return `${fieldName} 必须是一个有效的正则表达式`; + } +}; + +/***/ }), + +/***/ "./src/components/Form/index.js": +/*!**************************************!*\ + !*** ./src/components/Form/index.js ***! + \**************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Counter": () => (/* reexport safe */ _Elements__WEBPACK_IMPORTED_MODULE_0__.Counter), +/* harmony export */ "Input": () => (/* reexport safe */ _Elements__WEBPACK_IMPORTED_MODULE_0__.Input), +/* harmony export */ "Label": () => (/* reexport safe */ _Elements__WEBPACK_IMPORTED_MODULE_0__.Label), +/* harmony export */ "Select": () => (/* reexport safe */ _Elements__WEBPACK_IMPORTED_MODULE_0__.Select), +/* harmony export */ "TextArea": () => (/* reexport safe */ _Elements__WEBPACK_IMPORTED_MODULE_0__.TextArea), +/* harmony export */ "Toggle": () => (/* reexport safe */ _Elements__WEBPACK_IMPORTED_MODULE_0__.Toggle), +/* harmony export */ "Form": () => (/* reexport safe */ _Form__WEBPACK_IMPORTED_MODULE_1__.default) +/* harmony export */ }); +/* harmony import */ var _Elements__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Elements */ "./src/components/Form/Elements/index.js"); +/* harmony import */ var _Form__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Form */ "./src/components/Form/Form.js"); + + + +/***/ }), + +/***/ "./src/components/Hamburger/Hamburger.js": +/*!***********************************************!*\ + !*** ./src/components/Hamburger/Hamburger.js ***! + \***********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Hamburger": () => (/* binding */ Hamburger) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Hamburger_styl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Hamburger.styl */ "./src/components/Hamburger/Hamburger.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + +const Hamburger = ({ + opened, + animated = true +}) => { + const root = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)('hamburger'); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)("span", { + className: root.mod({ + animated, + opened + }), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("span", {}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("span", {}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("span", {})] + }); +}; + +/***/ }), + +/***/ "./src/components/Menu/Menu.js": +/*!*************************************!*\ + !*** ./src/components/Menu/Menu.js ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Menu": () => (/* binding */ Menu) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Dropdown_DropdownTrigger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Dropdown/DropdownTrigger */ "./src/components/Dropdown/DropdownTrigger.js"); +/* harmony import */ var _Menu_styl__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Menu.styl */ "./src/components/Menu/Menu.styl"); +/* harmony import */ var _MenuContext__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./MenuContext */ "./src/components/Menu/MenuContext.js"); +/* harmony import */ var _MenuItem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./MenuItem */ "./src/components/Menu/MenuItem.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + +const Menu = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(({ + children, + className, + style, + size, + selectedKeys, + closeDropdownOnItemClick +}, ref) => { + const dropdown = (0,_Dropdown_DropdownTrigger__WEBPACK_IMPORTED_MODULE_2__.useDropdown)(); + const selected = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + return new Set(selectedKeys !== null && selectedKeys !== void 0 ? selectedKeys : []); + }, [selectedKeys]); + const clickHandler = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(e => { + const elem = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)('main-menu').elem('item').closest(e.target); + + if (dropdown && elem && closeDropdownOnItemClick !== false) { + dropdown.close(); + } + }, [dropdown]); + const collapsed = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + return !!dropdown; + }, [dropdown]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_MenuContext__WEBPACK_IMPORTED_MODULE_4__.MenuContext.Provider, { + value: { + selected + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_MenuContext__WEBPACK_IMPORTED_MODULE_4__.Block, { + ref: ref, + tag: "ul", + name: "main-menu", + mod: { + size, + collapsed + }, + mix: className, + style: style, + onClick: clickHandler, + children: children + }) + }); +}); +Menu.Item = _MenuItem__WEBPACK_IMPORTED_MODULE_5__.MenuItem; + +Menu.Spacer = () => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_MenuContext__WEBPACK_IMPORTED_MODULE_4__.Elem, { + block: "main-menu", + tag: "li", + name: "spacer" +}); + +Menu.Divider = () => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_MenuContext__WEBPACK_IMPORTED_MODULE_4__.Elem, { + block: "main-menu", + tag: "li", + name: "divider" +}); + +Menu.Builder = (url, menuItems) => { + return (menuItems !== null && menuItems !== void 0 ? menuItems : []).map((item, index) => { + if (item === "SPACER") return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(Menu.Spacer, {}, index); + if (item === "DIVIDER") return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(Menu.Divider, {}, index); + let pageLabel, pagePath; + + if (Array.isArray(item)) { + [pagePath, pageLabel] = item; + } else { + const { + menuItem, + title, + path + } = item; + pageLabel = title !== null && title !== void 0 ? title : menuItem; + pagePath = path; + } + + if (typeof pagePath === "function") { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(Menu.Item, { + onClick: pagePath, + children: pageLabel + }, index); + } + + const location = `${url}${pagePath}`.replace(/([/]+)/g, '/'); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(Menu.Item, { + to: location, + exact: true, + children: pageLabel + }, index); + }); +}; + +Menu.Group = ({ + children, + title, + className, + style +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_MenuContext__WEBPACK_IMPORTED_MODULE_4__.Block, { + name: "menu-group", + mix: className, + style: style, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_MenuContext__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "title", + children: title + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_MenuContext__WEBPACK_IMPORTED_MODULE_4__.Elem, { + tag: "ul", + name: "list", + children: children + })] + }); +}; + +/***/ }), + +/***/ "./src/components/Menu/MenuContext.js": +/*!********************************************!*\ + !*** ./src/components/Menu/MenuContext.js ***! + \********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "MenuContext": () => (/* binding */ MenuContext), +/* harmony export */ "Block": () => (/* binding */ Block), +/* harmony export */ "Elem": () => (/* binding */ Elem) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); + + +const MenuContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(); +const { + Block, + Elem +} = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.BemWithSpecifiContext)(); + +/***/ }), + +/***/ "./src/components/Menu/MenuItem.js": +/*!*****************************************!*\ + !*** ./src/components/Menu/MenuItem.js ***! + \*****************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "MenuItem": () => (/* binding */ MenuItem) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/esm/react-router-dom.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + +const MenuItem = ({ + children, + label, + icon, + to, + className, + href, + exact = false, + forceReload = false, + active = false, + onClick, + ...rest +}) => { + const rootClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)("main-menu", { + elem: "item" + }); + const classList = [rootClass.toClassName()]; + + const isActive = (() => { + const pathname = location.pathname.replace(/\/$/, ''); + const url = to !== null && to !== void 0 ? to : href; + + if (exact) { + return pathname === url; + } else { + return pathname.includes(url); + } + })(); + + if (isActive || active) classList.push(rootClass.mod({ + active: true + })); + if (className) classList.push(className); + + const linkContent = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.Fragment, { + children: [icon && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("span", { + className: rootClass.elem('item-icon'), + children: icon + }), children !== null && children !== void 0 ? children : label] + }); + + const linkAttributes = { + className: classList.join(' '), + onClick, + ...rest + }; + const activeClassName = rootClass.mod({ + active: true + }).toClassName(); + const finalHref = to !== null && to !== void 0 ? to : href; + + if (forceReload) { + linkAttributes.onClick = () => location.href = to !== null && to !== void 0 ? to : href; + } + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("li", { + children: to ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(react_router_dom__WEBPACK_IMPORTED_MODULE_4__.NavLink, { + to: finalHref, + ...linkAttributes, + exact: exact, + activeClassName: activeClassName, + "data-external": true, + children: linkContent + }) : finalHref ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("a", { + href: (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_2__.absoluteURL)(finalHref), + ...linkAttributes, + children: linkContent + }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("span", { ...linkAttributes, + children: linkContent + }) + }); +}; + +/***/ }), + +/***/ "./src/components/Menubar/Menubar.js": +/*!*******************************************!*\ + !*** ./src/components/Menubar/Menubar.js ***! + \*******************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "MenubarContext": () => (/* binding */ MenubarContext), +/* harmony export */ "Menubar": () => (/* binding */ Menubar) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _app_StaticContent_StaticContent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../app/StaticContent/StaticContent */ "./src/app/StaticContent/StaticContent.js"); +/* harmony import */ var _assets_icons__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../assets/icons */ "./src/assets/icons/index.js"); +/* harmony import */ var _providers_ConfigProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../providers/ConfigProvider */ "./src/providers/ConfigProvider.js"); +/* harmony import */ var _providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../providers/RoutesProvider */ "./src/providers/RoutesProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var _Breadcrumbs_Breadcrumbs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Breadcrumbs/Breadcrumbs */ "./src/components/Breadcrumbs/Breadcrumbs.js"); +/* harmony import */ var _Dropdown_Dropdown__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Dropdown/Dropdown */ "./src/components/Dropdown/Dropdown.js"); +/* harmony import */ var _Hamburger_Hamburger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Hamburger/Hamburger */ "./src/components/Hamburger/Hamburger.js"); +/* harmony import */ var _Menu_Menu__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Menu/Menu */ "./src/components/Menu/Menu.js"); +/* harmony import */ var _Userpic_Userpic__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Userpic/Userpic */ "./src/components/Userpic/Userpic.js"); +/* harmony import */ var _VersionNotifier_VersionNotifier__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../VersionNotifier/VersionNotifier */ "./src/components/VersionNotifier/VersionNotifier.js"); +/* harmony import */ var _Menubar_styl__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Menubar.styl */ "./src/components/Menubar/Menubar.styl"); +/* harmony import */ var _MenuContent_styl__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./MenuContent.styl */ "./src/components/Menubar/MenuContent.styl"); +/* harmony import */ var _MenuSidebar_styl__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./MenuSidebar.styl */ "./src/components/Menubar/MenuSidebar.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + + + + + + + + + +const MenubarContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(); + +const LeftContextMenu = ({ + className +}) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_app_StaticContent_StaticContent__WEBPACK_IMPORTED_MODULE_1__.StaticContent, { + id: "context-menu-left", + className: className, + children: template => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_Breadcrumbs_Breadcrumbs__WEBPACK_IMPORTED_MODULE_7__.Breadcrumbs, { + fromTemplate: template + }) +}); + +const RightContextMenu = ({ + className, + ...props +}) => { + const { + ContextComponent, + contextProps + } = (0,_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_4__.useContextComponent)(); + return ContextComponent ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)("div", { + className: className, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(ContextComponent, { ...props, + ...(contextProps !== null && contextProps !== void 0 ? contextProps : {}) + }) + }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_app_StaticContent_StaticContent__WEBPACK_IMPORTED_MODULE_1__.StaticContent, { + id: "context-menu-right", + className: className + }); +}; + +const Menubar = ({ + enabled, + defaultOpened, + defaultPinned, + children, + onSidebarToggle, + onSidebarPin +}) => { + const menuDropdownRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const useMenuRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const location = (0,_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_4__.useFixedLocation)(); + const config = (0,_providers_ConfigProvider__WEBPACK_IMPORTED_MODULE_3__.useConfig)(); + const [sidebarOpened, setSidebarOpened] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(defaultOpened !== null && defaultOpened !== void 0 ? defaultOpened : false); + const [sidebarPinned, setSidebarPinned] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(defaultPinned !== null && defaultPinned !== void 0 ? defaultPinned : false); + const [PageContext, setPageContext] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)({ + Component: null, + props: {} + }); + const menubarClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_5__.cn)('menu-header'); + const menubarContext = menubarClass.elem('context'); + const sidebarClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_5__.cn)('sidebar'); + const contentClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_5__.cn)('content-wrapper'); + const contextItem = menubarClass.elem('context-item'); + const sidebarPin = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(e => { + e.preventDefault(); + const newState = !sidebarPinned; + setSidebarPinned(newState); + onSidebarPin === null || onSidebarPin === void 0 ? void 0 : onSidebarPin(newState); + }, [sidebarPinned]); + const sidebarToggle = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(visible => { + const newState = visible; + setSidebarOpened(newState); + onSidebarToggle === null || onSidebarToggle === void 0 ? void 0 : onSidebarToggle(newState); + }, [sidebarOpened]); + const providerValue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => ({ + PageContext, + + setContext(ctx) { + setTimeout(() => { + setPageContext({ ...PageContext, + Component: ctx + }); + }); + }, + + setProps(props) { + setTimeout(() => { + setPageContext({ ...PageContext, + props + }); + }); + }, + + contextIsSet(ctx) { + return PageContext.Component === ctx; + } + + }), [PageContext]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + var _useMenuRef$current; + + if (!sidebarPinned) { + var _menuDropdownRef$curr; + + menuDropdownRef === null || menuDropdownRef === void 0 ? void 0 : (_menuDropdownRef$curr = menuDropdownRef.current) === null || _menuDropdownRef$curr === void 0 ? void 0 : _menuDropdownRef$curr.close(); + } + + useMenuRef === null || useMenuRef === void 0 ? void 0 : (_useMenuRef$current = useMenuRef.current) === null || _useMenuRef$current === void 0 ? void 0 : _useMenuRef$current.close(); + }, [location]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsxs)("div", { + className: contentClass, + children: [enabled && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsxs)("div", { + className: menubarClass, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_Dropdown_Dropdown__WEBPACK_IMPORTED_MODULE_8__.Dropdown.Trigger, { + dropdown: menuDropdownRef, + closeOnClickOutside: !sidebarPinned, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsxs)("div", { + className: `${menubarClass.elem('trigger')} main-menu-trigger`, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)("img", { + src: (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_6__.absoluteURL)("/static/icons/logo.png"), + alt: "", + height: "22" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)("span", { + children: "\u667A\u80FD\u8F6F\u4EF6\u5F00\u53D1\u5E73\u53F0" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_Hamburger_Hamburger__WEBPACK_IMPORTED_MODULE_9__.Hamburger, { + opened: sidebarOpened + })] + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsxs)("div", { + className: menubarContext, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(LeftContextMenu, { + className: contextItem.mod({ + left: true + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(RightContextMenu, { + className: contextItem.mod({ + right: true + }) + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_Dropdown_Dropdown__WEBPACK_IMPORTED_MODULE_8__.Dropdown.Trigger, { + ref: useMenuRef, + align: "right", + content: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsxs)(_Menu_Menu__WEBPACK_IMPORTED_MODULE_10__.Menu, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_Menu_Menu__WEBPACK_IMPORTED_MODULE_10__.Menu.Item, { + icon: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_assets_icons__WEBPACK_IMPORTED_MODULE_2__.LsSettings, {}), + label: "\u5E10\u6237\u4E0E\u8BBE\u7F6E", + href: "/user/account", + "data-external": true + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_Menu_Menu__WEBPACK_IMPORTED_MODULE_10__.Menu.Item, { + icon: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_assets_icons__WEBPACK_IMPORTED_MODULE_2__.LsDoor, {}), + label: "\u9000\u51FA\u767B\u5F55", + href: (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_6__.absoluteURL)("/logout"), + "data-external": true + })] + }), + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)("div", { + className: menubarClass.elem('user'), + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_Userpic_Userpic__WEBPACK_IMPORTED_MODULE_11__.Userpic, { + user: config.user + }) + }) + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_VersionNotifier_VersionNotifier__WEBPACK_IMPORTED_MODULE_12__.VersionProvider, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsxs)("div", { + className: contentClass.elem('body'), + children: [enabled && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_Dropdown_Dropdown__WEBPACK_IMPORTED_MODULE_8__.Dropdown, { + ref: menuDropdownRef, + onToggle: sidebarToggle, + onVisibilityChanged: () => window.dispatchEvent(new Event('resize')), + visible: sidebarOpened, + className: [sidebarClass, sidebarClass.mod({ + floating: !sidebarPinned + })].join(" "), + style: { + width: 240 + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsxs)(_Menu_Menu__WEBPACK_IMPORTED_MODULE_10__.Menu, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_Menu_Menu__WEBPACK_IMPORTED_MODULE_10__.Menu.Item, { + label: "\u9879\u76EE", + to: "/projects", + icon: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_assets_icons__WEBPACK_IMPORTED_MODULE_2__.IconFolder, {}), + "data-external": true, + exact: true + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_Menu_Menu__WEBPACK_IMPORTED_MODULE_10__.Menu.Spacer, {}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_Menu_Menu__WEBPACK_IMPORTED_MODULE_10__.Menu.Divider, {}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_Menu_Menu__WEBPACK_IMPORTED_MODULE_10__.Menu.Item, { + icon: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(_assets_icons__WEBPACK_IMPORTED_MODULE_2__.IconPin, {}), + className: sidebarClass.elem('pin'), + onClick: sidebarPin, + active: sidebarPinned, + children: sidebarPinned ? "取消固定菜单" : "固定菜单" + })] + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)(MenubarContext.Provider, { + value: providerValue, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_16__.jsx)("div", { + className: contentClass.elem('content').mod({ + withSidebar: sidebarPinned && sidebarOpened + }), + children: children + }) + })] + }) + })] + }); +}; + +/***/ }), + +/***/ "./src/components/Modal/Modal.js": +/*!***************************************!*\ + !*** ./src/components/Modal/Modal.js ***! + \***************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "confirm": () => (/* binding */ confirm), +/* harmony export */ "info": () => (/* binding */ info), +/* harmony export */ "modal": () => (/* binding */ standaloneModal), +/* harmony export */ "Modal": () => (/* reexport safe */ _ModalPopup__WEBPACK_IMPORTED_MODULE_9__.Modal) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _providers_ConfigProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../providers/ConfigProvider */ "./src/providers/ConfigProvider.js"); +/* harmony import */ var _providers_CurrentUser__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../providers/CurrentUser */ "./src/providers/CurrentUser.js"); +/* harmony import */ var _providers_MultiProvider__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../providers/MultiProvider */ "./src/providers/MultiProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Button_Button__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Button/Button */ "./src/components/Button/Button.js"); +/* harmony import */ var _Space_Space__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Space/Space */ "./src/components/Space/Space.js"); +/* harmony import */ var _ModalPopup__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ModalPopup */ "./src/components/Modal/ModalPopup.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + + + + +const standaloneModal = props => { + const modalRef = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createRef)(); + const rootDiv = document.createElement("div"); + let renderCount = 0; + rootDiv.className = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_6__.cn)("modal-holder").toClassName(); + document.body.appendChild(rootDiv); + + const renderModal = (props, animate) => { + renderCount++; // simple modals don't require any parts of the app and can't cause the loop of death + + (0,react_dom__WEBPACK_IMPORTED_MODULE_1__.render)( /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_providers_MultiProvider__WEBPACK_IMPORTED_MODULE_5__.MultiProvider, { + providers: props.simple ? [] : [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_providers_ConfigProvider__WEBPACK_IMPORTED_MODULE_3__.ConfigProvider, {}, "config"), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_2__.ApiProvider, {}, "api"), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_providers_CurrentUser__WEBPACK_IMPORTED_MODULE_4__.CurrentUserProvider, {}, "current-user")], + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_ModalPopup__WEBPACK_IMPORTED_MODULE_9__.Modal, { + ref: modalRef, + ...props, + onHide: () => { + var _props$onHidden; + + (_props$onHidden = props.onHidden) === null || _props$onHidden === void 0 ? void 0 : _props$onHidden.call(props); + (0,react_dom__WEBPACK_IMPORTED_MODULE_1__.unmountComponentAtNode)(rootDiv); + rootDiv.remove(); + }, + animateAppearance: animate + }) + }, `modal-${renderCount}`), rootDiv); + }; + + renderModal(props, true); + return { + update(newProps) { + renderModal({ ...props, + ...(newProps !== null && newProps !== void 0 ? newProps : {}), + visible: true + }, false); + }, + + close() { + const result = modalRef.current.hide(); + (0,react_dom__WEBPACK_IMPORTED_MODULE_1__.unmountComponentAtNode)(rootDiv); + rootDiv.remove(); + return result; + } + + }; +}; + +const confirm = ({ + okText, + onOk, + cancelText, + onCancel, + buttonLook, + ...props +}) => { + const modal = standaloneModal({ ...props, + allowClose: false, + footer: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsxs)(_Space_Space__WEBPACK_IMPORTED_MODULE_8__.Space, { + align: "end", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_Button_Button__WEBPACK_IMPORTED_MODULE_7__.Button, { + onClick: () => { + onCancel === null || onCancel === void 0 ? void 0 : onCancel(); + modal.close(); + }, + size: "compact", + autoFocus: true, + children: cancelText !== null && cancelText !== void 0 ? cancelText : "取消" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_Button_Button__WEBPACK_IMPORTED_MODULE_7__.Button, { + onClick: () => { + onOk === null || onOk === void 0 ? void 0 : onOk(); + modal.close(); + }, + size: "compact", + look: buttonLook !== null && buttonLook !== void 0 ? buttonLook : 'primary', + children: okText !== null && okText !== void 0 ? okText : "确定" + })] + }) + }); + return modal; +}; +const info = ({ + okText, + onOkPress, + ...props +}) => { + const modal = standaloneModal({ ...props, + footer: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_Space_Space__WEBPACK_IMPORTED_MODULE_8__.Space, { + align: "end", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_Button_Button__WEBPACK_IMPORTED_MODULE_7__.Button, { + onClick: () => { + onOkPress === null || onOkPress === void 0 ? void 0 : onOkPress(); + modal.close(); + }, + look: "primary", + size: "compact", + children: okText !== null && okText !== void 0 ? okText : "确定" + }) + }) + }); + return modal; +}; + + +Object.assign(_ModalPopup__WEBPACK_IMPORTED_MODULE_9__.Modal, { + info, + confirm, + modal: standaloneModal +}); + +/***/ }), + +/***/ "./src/components/Modal/ModalPopup.js": +/*!********************************************!*\ + !*** ./src/components/Modal/ModalPopup.js ***! + \********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Modal": () => (/* binding */ Modal), +/* harmony export */ "useModalControls": () => (/* binding */ useModalControls) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js"); +/* harmony import */ var _assets_icons__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../assets/icons */ "./src/assets/icons/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_transition__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../utils/transition */ "./src/utils/transition.js"); +/* harmony import */ var _Button_Button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Button/Button */ "./src/components/Button/Button.js"); +/* harmony import */ var _Modal_styl__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Modal.styl */ "./src/components/Modal/Modal.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + + + + + + +const { + Block, + Elem +} = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_3__.BemWithSpecifiContext)(); +const ModalContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(); +class Modal extends react__WEBPACK_IMPORTED_MODULE_0__.Component { + constructor(props) { + var _props$visible; + + super(props); + + _defineProperty(this, "modalRef", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createRef()); + + _defineProperty(this, "onClickOutside", e => { + if (!this.modalRef.current) return; + const { + closeOnClickOutside + } = this.props; + const allowClose = this.props.allowClose !== false; + const isInModal = this.modalRef.current.contains(e.target); + const content = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_3__.cn)('modal').elem('content').closest(e.target); + const close = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_3__.cn)('modal').elem('close').closest(e.target); + + if (allowClose && (isInModal && close || content === null && closeOnClickOutside !== false)) { + this.hide(); + } + }); + + _defineProperty(this, "closeOnEscape", e => { + if (this.props.allowClose === false) return; + if (e.key !== 'Escape') return; + if (!this.state.visible) return; + e.stopPropagation(); + e.preventDefault(); + this.hide(); + }); + + this.state = { + title: props.title, + body: props.body, + footer: props.footer, + visible: props.animateAppearance ? false : (_props$visible = props.visible) !== null && _props$visible !== void 0 ? _props$visible : false, + transition: props.visible ? 'visible' : null + }; + } + + componentDidMount() { + if (this.props.animateAppearance) { + setTimeout(() => this.show(), 30); + } + + document.addEventListener('keydown', this.closeOnEscape, { + capture: true + }); + } + + componentWillUnmount() { + document.removeEventListener('keydown', this.closeOnEscape, { + capture: true + }); + } + + componentDidUpdate(prevProps, prevState) { + if (prevState.visible !== this.state.visible) { + document.body.style.overflow = this.state.visible ? 'hidden' : ''; + } + } + + setBody(body) { + this.setState({ + body + }); + } + + show(onShow) { + return new Promise(resolve => { + this.setState({ + visible: true + }, async () => { + var _this$props$onShow, _this$props; + + onShow === null || onShow === void 0 ? void 0 : onShow(); + (_this$props$onShow = (_this$props = this.props).onShow) === null || _this$props$onShow === void 0 ? void 0 : _this$props$onShow.call(_this$props); + await this.transition("appear", resolve); + }); + }); + } + + hide(onHidden) { + return new Promise(resolve => { + this.transition('disappear', () => { + this.setState({ + visible: false + }, () => { + var _this$props$onHide, _this$props2; + + (_this$props$onHide = (_this$props2 = this.props).onHide) === null || _this$props$onHide === void 0 ? void 0 : _this$props$onHide.call(_this$props2); + resolve(); + onHidden === null || onHidden === void 0 ? void 0 : onHidden(); + }); + }); + }); + } + + render() { + if (!this.state.visible) return null; + const bare = this.props.bare; + const mods = { + fullscreen: !!this.props.fullscreen, + bare: this.props.bare, + visible: this.props.visible || this.state.visible + }; + const mixes = [this.transitionClass, this.props.className]; + const modalSizeStyle = {}; + if (this.props.width) modalSizeStyle.width = this.props.width; + if (this.props.height) modalSizeStyle.height = this.props.height; + + const modalContent = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(ModalContext.Provider, { + value: this, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(Block, { + name: "modal", + ref: this.modalRef, + mod: mods, + mix: mixes, + onClick: this.onClickOutside, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(Elem, { + name: "wrapper", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(Elem, { + name: "content", + style: Object.assign({}, this.props.style, modalSizeStyle), + children: [!bare && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(Modal.Header, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(Elem, { + name: "title", + children: this.state.title + }), this.props.allowClose !== false && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(Elem, { + tag: _Button_Button__WEBPACK_IMPORTED_MODULE_5__.Button, + name: "close", + type: "text", + icon: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_assets_icons__WEBPACK_IMPORTED_MODULE_2__.LsCross, {}) + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(Elem, { + name: "body", + mod: { + bare + }, + children: this.body + }), this.props.footer && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(Modal.Footer, { + bare: this.props.bareFooter, + children: this.footer + })] + }) + }) + }) + }); + + return /*#__PURE__*/(0,react_dom__WEBPACK_IMPORTED_MODULE_1__.createPortal)(modalContent, document.body); + } + + transition(type, onFinish) { + return (0,_utils_transition__WEBPACK_IMPORTED_MODULE_4__.aroundTransition)(this.modalRef.current, { + transition: async () => new Promise(resolve => { + this.setState({ + transition: type + }, () => { + resolve(); + }); + }), + beforeTransition: async () => new Promise(resolve => { + this.setState({ + transition: `before-${type}` + }, () => { + resolve(); + }); + }), + afterTransition: async () => new Promise(resolve => { + this.setState({ + transition: type === 'appear' ? "visible" : null + }, () => { + onFinish === null || onFinish === void 0 ? void 0 : onFinish(); + resolve(); + }); + }) + }); + } + + get transitionClass() { + switch (this.state.transition) { + case "before-appear": + return "before-appear"; + + case "appear": + return "appear before-appear"; + + case "before-disappear": + return "before-disappear"; + + case "disappear": + return "disappear before-disappear"; + + case "visible": + return "visible"; + } + + return null; + } + + get body() { + if (this.state.body) { + const Content = this.state.body; + return Content instanceof Function ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(Content, {}) : Content; + } else { + return this.props.children; + } + } + + get footer() { + if (this.state.footer) { + const Content = this.state.footer; + return Content instanceof Function ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(Content, {}) : Content; + } + + return null; + } + +} + +Modal.Header = ({ + children, + divided +}) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(Elem, { + name: "header", + mod: { + divided + }, + children: children +}); + +Modal.Footer = ({ + children, + bare +}) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(Elem, { + name: "footer", + mod: { + bare + }, + children: children +}); + +const useModalControls = () => { + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(ModalContext); +}; + +/***/ }), + +/***/ "./src/components/Oneof/Oneof.js": +/*!***************************************!*\ + !*** ./src/components/Oneof/Oneof.js ***! + \***************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Oneof": () => (/* binding */ Oneof) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); + +const Oneof = ({ + value, + children, + className +}) => { + const selectedChild = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + if (Array.isArray(children)) { + return children.find(c => c.props.case === value) || null; + } else if (children.props.case === value) { + return children; + } + }, [children, value]); + return selectedChild ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.cloneElement(selectedChild, { ...selectedChild.props, + className: [className, selectedChild.props.className].join(" ") + }) : null; +}; + +/***/ }), + +/***/ "./src/components/SidebarMenu/SidebarMenu.js": +/*!***************************************************!*\ + !*** ./src/components/SidebarMenu/SidebarMenu.js ***! + \***************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SidebarMenu": () => (/* binding */ SidebarMenu) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Menu_Menu__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Menu/Menu */ "./src/components/Menu/Menu.js"); +/* harmony import */ var _SidebarMenu_styl__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./SidebarMenu.styl */ "./src/components/SidebarMenu/SidebarMenu.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + +const SidebarMenu = ({ + children, + menu, + path, + menuItems +}) => { + const rootClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)('sidebar-menu'); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)("div", { + className: rootClass, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)("div", { + className: rootClass.elem('navigation'), + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_Menu_Menu__WEBPACK_IMPORTED_MODULE_2__.Menu, { + children: menuItems ? _Menu_Menu__WEBPACK_IMPORTED_MODULE_2__.Menu.Builder(path, menuItems) : menu + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)("div", { + className: rootClass.elem('content'), + children: children + })] + }); +}; + +/***/ }), + +/***/ "./src/components/Space/Space.js": +/*!***************************************!*\ + !*** ./src/components/Space/Space.js ***! + \***************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Space": () => (/* binding */ Space) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Space_styl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Space.styl */ "./src/components/Space/Space.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + +const { + Block +} = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.BemWithSpecifiContext)(); +const Space = ({ + direction = "horizontal", + size, + className, + style, + children, + spread, + stretch, + align +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(Block, { + name: "space", + mod: { + direction, + size, + spread, + stretch, + align + }, + mix: className, + style: style, + children: children + }); +}; + +/***/ }), + +/***/ "./src/components/Spinner/Spinner.js": +/*!*******************************************!*\ + !*** ./src/components/Spinner/Spinner.js ***! + \*******************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Spinner": () => (/* binding */ Spinner) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Spinner_styl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Spinner.styl */ "./src/components/Spinner/Spinner.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + +const Spinner = ({ + className, + style, + size = 32, + stopped = false +}) => { + const rootClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)('spinner'); + const sizeWithUnit = typeof size === 'number' ? `${size}px` : size; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("div", { + className: rootClass.mix(className), + style: { ...(style !== null && style !== void 0 ? style : {}), + '--spinner-size': sizeWithUnit + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)("div", { + className: rootClass.elem('body').mod({ + stopped + }), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("span", {}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("span", {}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("span", {}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("span", {})] + }) + }); +}; + +/***/ }), + +/***/ "./src/components/ToggleItems/ToggleItems.tsx": +/*!****************************************************!*\ + !*** ./src/components/ToggleItems/ToggleItems.tsx ***! + \****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ToggleItems": () => (/* binding */ ToggleItems) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _ToggleItems_styl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ToggleItems.styl */ "./src/components/ToggleItems/ToggleItems.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + +const ToggleItems = ({ + className, + style, + big, + items, + active, + onSelect +}) => { + const rootClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_1__.cn)('toggle-items'); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("ul", { + className: rootClass.mod({ + big + }).mix(className).toString(), + style: style, + children: Object.keys(items).map(item => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("li", { + className: rootClass.elem("item").mod({ + active: item === active + }).toString(), + onClick: () => onSelect(item), + children: items[item] + }, item)) + }); +}; + +/***/ }), + +/***/ "./src/components/Tooltip/Tooltip.js": +/*!*******************************************!*\ + !*** ./src/components/Tooltip/Tooltip.js ***! + \*******************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Tooltip": () => (/* binding */ Tooltip) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../utils/dom */ "./src/utils/dom.js"); +/* harmony import */ var _utils_transition__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../utils/transition */ "./src/utils/transition.js"); +/* harmony import */ var _Tooltip_styl__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Tooltip.styl */ "./src/components/Tooltip/Tooltip.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + +const Tooltip = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(({ + title, + children, + defaultVisible, + disabled, + style +}, ref) => { + if (!children || Array.isArray(children)) { + throw new Error("Tooltip does accept a single child only"); + } + + const triggerElement = ref !== null && ref !== void 0 ? ref : (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const tooltipElement = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const [offset, setOffset] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)({}); + const [visibility, setVisibility] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(defaultVisible ? "visible" : null); + const [injected, setInjected] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + const [align, setAlign] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)('top-center'); + const calculatePosition = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + const { + left, + top, + align: resultAlign + } = (0,_utils_dom__WEBPACK_IMPORTED_MODULE_3__.alignElements)(triggerElement.current, tooltipElement.current, align, 10); + setOffset({ + left, + top + }); + setAlign(resultAlign); + }, [triggerElement.current, tooltipElement.current]); + const performAnimation = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(visible => { + if (tooltipElement.current) { + (0,_utils_transition__WEBPACK_IMPORTED_MODULE_4__.aroundTransition)(tooltipElement.current, { + beforeTransition() { + setVisibility(visible ? "before-appear" : "before-disappear"); + }, + + transition() { + if (visible) calculatePosition(); + setVisibility(visible ? "appear" : "disappear"); + }, + + afterTransition() { + setVisibility(visible ? "visible" : null); + if (visible === false) setInjected(false); + } + + }); + } + }, [injected, calculatePosition, tooltipElement]); + const visibilityClasses = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + switch (visibility) { + case "before-appear": + return "before-appear"; + + case "appear": + return "appear before-appear"; + + case "before-disappear": + return "before-disappear"; + + case "disappear": + return "disappear before-disappear"; + + case "visible": + return "visible"; + + default: + return visibility ? "visible" : null; + } + }, [visibility]); + const tooltip = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => injected ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Block, { + ref: tooltipElement, + name: "tooltip", + mod: { + align + }, + mix: visibilityClasses, + style: { ...offset, + ...(style !== null && style !== void 0 ? style : {}) + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "body", + children: title + }) + }) : null, [injected, offset, title, visibilityClasses, tooltipElement]); + const child = react__WEBPACK_IMPORTED_MODULE_0__.Children.only(children); + const clone = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.cloneElement)(child, { ...child.props, + ref: triggerElement, + + onMouseEnter(e) { + var _child$props$onMouseE, _child$props; + + if (disabled === true) return; + setInjected(true); + (_child$props$onMouseE = (_child$props = child.props).onMouseEnter) === null || _child$props$onMouseE === void 0 ? void 0 : _child$props$onMouseE.call(_child$props, e); + }, + + onMouseLeave(e) { + var _child$props$onMouseL, _child$props2; + + if (disabled === true) return; + performAnimation(false); + (_child$props$onMouseL = (_child$props2 = child.props).onMouseLeave) === null || _child$props$onMouseL === void 0 ? void 0 : _child$props$onMouseL.call(_child$props2, e); + } + + }); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (injected) performAnimation(true); + }, [injected]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.Fragment, { + children: [clone, /*#__PURE__*/(0,react_dom__WEBPACK_IMPORTED_MODULE_1__.createPortal)(tooltip, document.body)] + }); +}); +Tooltip.displayName = "Tooltip"; + +/***/ }), + +/***/ "./src/components/Userpic/Userpic.js": +/*!*******************************************!*\ + !*** ./src/components/Userpic/Userpic.js ***! + \*******************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Userpic": () => (/* binding */ Userpic) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Tooltip_Tooltip__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Tooltip/Tooltip */ "./src/components/Tooltip/Tooltip.js"); +/* harmony import */ var _Userpic_styl__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Userpic.styl */ "./src/components/Userpic/Userpic.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + +const FALLBACK_IMAGE = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='; +const Userpic = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(({ + username, + size, + src, + user, + className, + showUsername, + style, + ...rest +}, ref) => { + var _user$avatar; + + const imgRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const [finalUsername, setFinalUsername] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(username); + const [finalSrc, setFinalSrc] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)((_user$avatar = user === null || user === void 0 ? void 0 : user.avatar) !== null && _user$avatar !== void 0 ? _user$avatar : src); + const [imgVisible, setImgVisible] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + const [nameVisible, setNameVisible] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(true); + + if (size) { + style = Object.assign({ + width: size, + height: size, + fontSize: size * 0.4 + }, style); + } + + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (user) { + const { + first_name, + last_name, + email, + initials, + username + } = user; + + if (initials) { + setFinalUsername(initials); + } else if (username) { + setFinalUsername(username); + } else if (first_name && last_name) { + setFinalUsername(`${first_name[0]}${last_name[0]}`); + } else if (email) { + setFinalUsername(email.substring(0, 2)); + } + + if (user.avatar) setFinalSrc(user.avatar); + } else { + setFinalUsername(username); + setFinalSrc(src); + } + }, [user]); + const onImageLoaded = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + setImgVisible(true); + if (finalSrc !== FALLBACK_IMAGE) setNameVisible(false); + }, [finalSrc]); + + const userpic = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_1__.Block, { + ref: ref, + name: "userpic", + mix: className, + style: style, + ...rest, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_1__.Elem, { + tag: "img", + name: "avatar", + ref: imgRef, + src: finalSrc, + alt: (finalUsername !== null && finalUsername !== void 0 ? finalUsername : "").toUpperCase(), + style: { + opacity: imgVisible ? 1 : 0 + }, + onLoad: onImageLoaded, + onError: () => setFinalSrc(FALLBACK_IMAGE) + }), nameVisible && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_1__.Elem, { + tag: "span", + name: "username", + children: (finalUsername !== null && finalUsername !== void 0 ? finalUsername : "").toUpperCase() + })] + }); + + const userFullName = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + if (user !== null && user !== void 0 && user.first_name || user !== null && user !== void 0 && user.last_name) { + var _user$first_name, _user$last_name; + + return `${(_user$first_name = user === null || user === void 0 ? void 0 : user.first_name) !== null && _user$first_name !== void 0 ? _user$first_name : ''} ${(_user$last_name = user === null || user === void 0 ? void 0 : user.last_name) !== null && _user$last_name !== void 0 ? _user$last_name : ''}`.trim(); + } else if (user !== null && user !== void 0 && user.email) { + return user.email; + } else { + return username; + } + }, [user, username]); + return showUsername && userFullName ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_Tooltip_Tooltip__WEBPACK_IMPORTED_MODULE_2__.Tooltip, { + title: userFullName, + children: userpic + }) : userpic; +}); +Userpic.displayName = 'Userpic'; + +/***/ }), + +/***/ "./src/components/VersionNotifier/VersionNotifier.js": +/*!***********************************************************!*\ + !*** ./src/components/VersionNotifier/VersionNotifier.js ***! + \***********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "VersionProvider": () => (/* binding */ VersionProvider), +/* harmony export */ "VersionNotifier": () => (/* binding */ VersionNotifier) +/* harmony export */ }); +/* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/format/index.js"); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/esm/react-router-dom.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _VersionNotifier_styl__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./VersionNotifier.styl */ "./src/components/VersionNotifier/VersionNotifier.styl"); +/* harmony import */ var _assets_icons__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../assets/icons */ "./src/assets/icons/index.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + +const VersionContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(); +const VersionProvider = ({ + children +}) => { + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_1__.useAPI)(); + const [state, dispatch] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useReducer)((state, action) => { + if (action.type === 'fetch-version') { + return { ...state, + ...action.payload + }; + } + }); + const fetchVersion = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + const response = await api.callApi("version"); + const data = response['label-studio-os-package']; + dispatch({ + type: "fetch-version", + payload: { + version: data.version, + latestVersion: data.latest_version_from_pypi, + newVersion: data.current_version_is_outdated, + updateTime: (0,date_fns__WEBPACK_IMPORTED_MODULE_6__.default)(new Date(data.latest_version_upload_time), 'MMM d') + } + }); + }, [api]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + fetchVersion(); + }, []); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(VersionContext.Provider, { + value: state, + children: children + }); +}; +const VersionNotifier = ({ + showNewVersion, + showCurrentVersion +}) => { + var _useContext; + + const url = "https://pypi.org/project/label-studio/#history"; + const { + newVersion, + updateTime, + latestVersion, + version + } = (_useContext = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(VersionContext)) !== null && _useContext !== void 0 ? _useContext : {}; + return newVersion && showNewVersion ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Block, { + tag: "li", + name: "version-notifier", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("a", { + href: url, + target: "_blank", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "icon", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_assets_icons__WEBPACK_IMPORTED_MODULE_4__.IconBell, {}) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "content", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "title", + "data-date": updateTime, + children: [latestVersion, " Available"] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "description", + children: ["Current version: ", version] + })] + })] + }) + }) : version && showCurrentVersion ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Block, { + tag: react_router_dom__WEBPACK_IMPORTED_MODULE_7__.Link, + name: "current-version", + to: "/version", + target: "_blank", + children: ["v", version] + }) : null; +}; + +/***/ }), + +/***/ "./src/components/index.js": +/*!*********************************!*\ + !*** ./src/components/index.js ***! + \*********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Breadcrumbs": () => (/* reexport safe */ _Breadcrumbs_Breadcrumbs__WEBPACK_IMPORTED_MODULE_0__.Breadcrumbs), +/* harmony export */ "Button": () => (/* reexport safe */ _Button_Button__WEBPACK_IMPORTED_MODULE_1__.Button), +/* harmony export */ "Card": () => (/* reexport safe */ _Card_Card__WEBPACK_IMPORTED_MODULE_2__.Card), +/* harmony export */ "Checkbox": () => (/* reexport safe */ _Checkbox_Checkbox__WEBPACK_IMPORTED_MODULE_3__.Checkbox), +/* harmony export */ "Columns": () => (/* reexport safe */ _Columns_Columns__WEBPACK_IMPORTED_MODULE_4__.Columns), +/* harmony export */ "Dropdown": () => (/* reexport safe */ _Dropdown_Dropdown__WEBPACK_IMPORTED_MODULE_5__.Dropdown), +/* harmony export */ "Hamburger": () => (/* reexport safe */ _Hamburger_Hamburger__WEBPACK_IMPORTED_MODULE_6__.Hamburger), +/* harmony export */ "Menu": () => (/* reexport safe */ _Menu_Menu__WEBPACK_IMPORTED_MODULE_7__.Menu), +/* harmony export */ "Menubar": () => (/* reexport safe */ _Menubar_Menubar__WEBPACK_IMPORTED_MODULE_8__.Menubar), +/* harmony export */ "SidebarMenu": () => (/* reexport safe */ _SidebarMenu_SidebarMenu__WEBPACK_IMPORTED_MODULE_9__.SidebarMenu), +/* harmony export */ "Spinner": () => (/* reexport safe */ _Spinner_Spinner__WEBPACK_IMPORTED_MODULE_10__.Spinner), +/* harmony export */ "ToggleItems": () => (/* reexport safe */ _ToggleItems_ToggleItems__WEBPACK_IMPORTED_MODULE_11__.ToggleItems), +/* harmony export */ "Userpic": () => (/* reexport safe */ _Userpic_Userpic__WEBPACK_IMPORTED_MODULE_12__.Userpic), +/* harmony export */ "VersionNotifier": () => (/* reexport safe */ _VersionNotifier_VersionNotifier__WEBPACK_IMPORTED_MODULE_13__.VersionNotifier) +/* harmony export */ }); +/* harmony import */ var _Breadcrumbs_Breadcrumbs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Breadcrumbs/Breadcrumbs */ "./src/components/Breadcrumbs/Breadcrumbs.js"); +/* harmony import */ var _Button_Button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Button/Button */ "./src/components/Button/Button.js"); +/* harmony import */ var _Card_Card__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Card/Card */ "./src/components/Card/Card.js"); +/* harmony import */ var _Checkbox_Checkbox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Checkbox/Checkbox */ "./src/components/Checkbox/Checkbox.js"); +/* harmony import */ var _Columns_Columns__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Columns/Columns */ "./src/components/Columns/Columns.js"); +/* harmony import */ var _Dropdown_Dropdown__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Dropdown/Dropdown */ "./src/components/Dropdown/Dropdown.js"); +/* harmony import */ var _Hamburger_Hamburger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Hamburger/Hamburger */ "./src/components/Hamburger/Hamburger.js"); +/* harmony import */ var _Menu_Menu__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Menu/Menu */ "./src/components/Menu/Menu.js"); +/* harmony import */ var _Menubar_Menubar__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Menubar/Menubar */ "./src/components/Menubar/Menubar.js"); +/* harmony import */ var _SidebarMenu_SidebarMenu__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./SidebarMenu/SidebarMenu */ "./src/components/SidebarMenu/SidebarMenu.js"); +/* harmony import */ var _Spinner_Spinner__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Spinner/Spinner */ "./src/components/Spinner/Spinner.js"); +/* harmony import */ var _ToggleItems_ToggleItems__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ToggleItems/ToggleItems */ "./src/components/ToggleItems/ToggleItems.tsx"); +/* harmony import */ var _Userpic_Userpic__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Userpic/Userpic */ "./src/components/Userpic/Userpic.js"); +/* harmony import */ var _VersionNotifier_VersionNotifier__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./VersionNotifier/VersionNotifier */ "./src/components/VersionNotifier/VersionNotifier.js"); + + + + + + + + + + + + + + + +/***/ }), + +/***/ "./src/config/ApiConfig.js": +/*!*********************************!*\ + !*** ./src/config/ApiConfig.js ***! + \*********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "API_CONFIG": () => (/* binding */ API_CONFIG) +/* harmony export */ }); +const API_CONFIG = { + gateway: `${window.APP_SETTINGS.hostname}/api`, + endpoints: { + // Users + users: "/users", + me: "/current-user/whoami", + token: "/current-user/token", + // Organization + memberships: "/organizations/:pk/memberships", + inviteLink: "/invite", + resetInviteLink: "POST:/invite/reset-token", + // Project + projects: "/projects", + project: "/projects/:pk", + updateProject: "PATCH:/projects/:pk", + createProject: "POST:/projects", + deleteProject: "DELETE:/projects/:pk", + // Config and Import + configTemplates: "/templates", + validateConfig: "POST:/projects/:pk/validate", + createSampleTask: "POST:/projects/:pk/sample-task", + fileUploads: "/projects/:pk/file-uploads", + deleteFileUploads: "DELETE:/projects/:pk/file-uploads", + importFiles: "POST:/projects/:pk/import", + reimportFiles: "POST:/projects/:pk/reimport", + dataSummary: "/projects/:pk/summary", + // DM + deleteTabs: 'DELETE:/dm/views/reset', + // Storages + listStorages: "/storages/:target?", + storageTypes: "/storages/:target?/types", + storageForms: "/storages/:target?/:type/form", + createStorage: "POST:/storages/:target?/:type", + deleteStorage: "DELETE:/storages/:target?/:type/:pk", + updateStorage: "PATCH:/storages/:target?/:type/:pk", + syncStorage: "POST:/storages/:target?/:type/:pk/sync", + validateStorage: "POST:/storages/:target?/:type/validate", + // ML + mlBackends: "GET:/ml", + mlBackend: "GET:/ml/:pk", + addMLBackend: "POST:/ml", + updateMLBackend: "PATCH:/ml/:pk", + deleteMLBackend: "DELETE:/ml/:pk", + trainMLBackend: "POST:/ml/:pk/train", + predictWithML: "POST:/ml/:pk/predict", + modelVersions: "/projects/:pk/model-versions", + // Export + export: "/projects/:pk/export", + previousExports: "/projects/:pk/export/files", + exportFormats: "/projects/:pk/export/formats", + // Version + version: '/version' + }, + alwaysExpectJSON: false +}; + +/***/ }), + +/***/ "./src/config/Sentry.ts": +/*!******************************!*\ + !*** ./src/config/Sentry.ts ***! + \******************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "initSentry": () => (/* binding */ initSentry), +/* harmony export */ "SentryRoute": () => (/* binding */ SentryRoute) +/* harmony export */ }); +/* harmony import */ var _sentry_browser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sentry/browser */ "./node_modules/@sentry/browser/esm/sdk.js"); +/* harmony import */ var _sentry_browser__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @sentry/browser */ "./node_modules/@sentry/minimal/esm/index.js"); +/* harmony import */ var _sentry_react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @sentry/react */ "./node_modules/@sentry/react/esm/reactrouter.js"); +/* harmony import */ var _sentry_tracing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sentry/tracing */ "./node_modules/@sentry/tracing/esm/index.js"); +/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router/esm/react-router.js"); + + + + +const initSentry = history => { + setTags(); + _sentry_browser__WEBPACK_IMPORTED_MODULE_1__.init({ + dsn: "https://5f51920ff82a4675a495870244869c6b@o227124.ingest.sentry.io/5838868", + integrations: [new _sentry_tracing__WEBPACK_IMPORTED_MODULE_0__.Integrations.BrowserTracing({ + routingInstrumentation: _sentry_react__WEBPACK_IMPORTED_MODULE_2__.reactRouterV5Instrumentation(history) + })], + environment: "development", + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production + tracesSampleRate: 0.25, + release: "label-studio@1.1.0-frontend" + }); +}; + +const setTags = () => { + const tags = {}; + + if (APP_SETTINGS.user.email) { + _sentry_browser__WEBPACK_IMPORTED_MODULE_3__.setUser({ + email: APP_SETTINGS.user.email, + username: APP_SETTINGS.user.username + }); + } + + if (APP_SETTINGS.version) { + Object.entries(APP_SETTINGS.version).forEach(([packageName, data]) => { + const { + version, + commit + } = data !== null && data !== void 0 ? data : {}; + + if (version) { + tags['version-' + packageName] = version; + } + + if (commit) { + tags['commit-' + packageName] = commit; + } + }); + } + + _sentry_browser__WEBPACK_IMPORTED_MODULE_3__.setTags(tags); +}; + +const SentryRoute = _sentry_react__WEBPACK_IMPORTED_MODULE_2__.withSentryRouting(react_router_dom__WEBPACK_IMPORTED_MODULE_4__.Route); + +/***/ }), + +/***/ "./src/index.js": +/*!**********************!*\ + !*** ./src/index.js ***! + \**********************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _app_App__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./app/App */ "./src/app/App.js"); + + +/***/ }), + +/***/ "./src/pages/CreateProject/Config/Config.js": +/*!**************************************************!*\ + !*** ./src/pages/CreateProject/Config/Config.js ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ConfigPage": () => (/* binding */ ConfigPage) +/* harmony export */ }); +/* harmony import */ var codemirror_lib_codemirror_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! codemirror/lib/codemirror.css */ "./node_modules/codemirror/lib/codemirror.css"); +/* harmony import */ var codemirror_mode_xml_xml__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! codemirror/mode/xml/xml */ "./node_modules/codemirror/mode/xml/xml.js"); +/* harmony import */ var codemirror_mode_xml_xml__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(codemirror_mode_xml_xml__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_codemirror2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-codemirror2 */ "./node_modules/react-codemirror2/index.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../components */ "./src/components/index.js"); +/* harmony import */ var _components_Form__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../components/Form */ "./src/components/Form/index.js"); +/* harmony import */ var _components_Oneof_Oneof__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../components/Oneof/Oneof */ "./src/components/Oneof/Oneof.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_colors__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../utils/colors */ "./src/utils/colors.js"); +/* harmony import */ var _colors__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./colors */ "./src/pages/CreateProject/Config/colors.js"); +/* harmony import */ var _Config_styl__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Config.styl */ "./src/pages/CreateProject/Config/Config.styl"); +/* harmony import */ var _Preview__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Preview */ "./src/pages/CreateProject/Config/Preview.js"); +/* harmony import */ var _Template__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Template */ "./src/pages/CreateProject/Config/Template.js"); +/* harmony import */ var _TemplatesList__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./TemplatesList */ "./src/pages/CreateProject/Config/TemplatesList.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + + + + + + // don't do this, kids + + + + +const formatXML = xml => { + let depth = 0; + + try { + return xml.replace(/<(\/)?.*?(\/)?>[\s\n]*/g, (tag, close1, close2) => { + if (!close1) { + const res = " ".repeat(depth) + tag.trim() + "\n"; + if (!close2) depth++; + return res; + } else { + depth--; + return " ".repeat(depth) + tag.trim() + "\n"; + } + }); + } catch (e) { + return xml; + } +}; + +const wizardClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_7__.cn)("wizard"); +const configClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_7__.cn)("configure"); + +const EmptyConfigPlaceholder = () => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("div", { + className: configClass.elem("empty-config"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("p", { + children: "\u60A8\u7684\u6807\u6CE8\u914D\u7F6E\u662F\u7A7A\u7684\uFF0C\u5B83\u662F\u5FC5\u987B\u7684\u6765\u6807\u6CE8\u60A8\u7684\u6570\u636E\u3002" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("p", { + children: ["\u4ECE\u6211\u4EEC\u7684\u9884\u5B9A\u4E49\u6A21\u677F\u5F00\u59CB\u6216\u5728\u4EE3\u7801\u9762\u677F\u4E0A\u521B\u5EFA\u60A8\u81EA\u5DF1\u7684\u914D\u7F6E\u3002 \u6807\u6CE8\u914D\u7F6E\u662F\u57FA\u4E8E XML \u7684\uFF0C\u60A8\u53EF\u4EE5", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("a", { + href: "https://labelstud.io/tags/", + target: "_blank", + children: "\u5728\u6211\u4EEC\u7684\u6587\u6863\u4E2D\u9605\u8BFB\u53EF\u7528\u7684\u6807\u7B7E" + }), "\u3002"] + })] +}); + +const Label = ({ + label, + template, + color +}) => { + const value = label.getAttribute("value"); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("li", { + className: configClass.elem("label").mod({ + choice: label.tagName === "Choice" + }), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("label", { + style: { + background: color + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("input", { + type: "color", + className: configClass.elem("label-color"), + value: _colors__WEBPACK_IMPORTED_MODULE_9__.colorNames[color] || color, + onChange: e => template.changeLabel(label, { + background: e.target.value + }) + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("span", { + children: value + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("button", { + type: "button", + className: configClass.elem("delete-label"), + onClick: () => template.removeLabel(label), + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("svg", { + width: "14", + height: "14", + viewBox: "0 0 14 14", + fill: "none", + stroke: "red", + strokeWidth: "2", + strokeLinecap: "square", + xmlns: "http://www.w3.org/2000/svg", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("path", { + d: "M2 12L12 2" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("path", { + d: "M12 12L2 2" + })] + }) + })] + }); +}; + +const ConfigureControl = ({ + control, + template +}) => { + const refLabels = react__WEBPACK_IMPORTED_MODULE_2__.useRef(); + const tagname = control.tagName; + if (tagname !== "Choices" && !tagname.endsWith("Labels")) return null; + const palette = (0,_utils_colors__WEBPACK_IMPORTED_MODULE_8__.Palette)(); + + const onAddLabels = () => { + if (!refLabels.current) return; + template.addLabels(control, refLabels.current.value); + refLabels.current.value = ""; + }; + + const onKeyPress = e => { + if (e.key === "Enter" && e.ctrlKey) { + e.preventDefault(); + onAddLabels(); + } + }; + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("div", { + className: configClass.elem("labels"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("form", { + className: configClass.elem("add-labels"), + action: "", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("h4", { + children: tagname === "Choices" ? "添加选择项" : "添加标签名" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("textarea", { + name: "labels", + id: "", + cols: "30", + rows: "5", + ref: refLabels, + onKeyPress: onKeyPress + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("input", { + type: "button", + value: "\u6DFB\u52A0", + onClick: onAddLabels + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("div", { + className: configClass.elem("current-labels"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("h3", { + children: [tagname === "Choices" ? "选择项" : "标签", " (", control.children.length, ")"] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("ul", { + children: Array.from(control.children).map(label => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(Label, { + label: label, + template: template, + color: label.getAttribute("background") || palette.next().value + }, label.getAttribute("value"))) + })] + })] + }); +}; + +const ConfigureSettings = ({ + template +}) => { + const { + settings + } = template; + if (!settings) return null; + const keys = Object.keys(settings); + const items = keys.map(key => { + const options = settings[key]; + const type = Array.isArray(options.type) ? Array : options.type; + const $object = template.objects[0]; + const $tag = options.control ? $object.$controls[0] : $object; + if (!$tag) return null; + if (options.when && !options.when($tag)) return; + let value = false; + if (options.value) value = options.value($tag);else if (typeof options.param === "string") value = $tag.getAttribute(options.param); + if (value === "true") value = true; + if (value === "false") value = false; + let onChange; + let size; + + switch (type) { + case Array: + onChange = e => { + if (typeof options.param === "function") { + options.param($tag, e.target.value); + } else { + $object.setAttribute(options.param, e.target.value); + } + + template.render(); + }; + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("li", { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("label", { + children: [options.title, " ", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("select", { + value: value, + onChange: onChange, + children: options.type.map(option => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("option", { + value: option, + children: option + }, option)) + })] + }) + }, key); + + case Boolean: + onChange = e => { + if (typeof options.param === "function") { + options.param($tag, e.target.checked); + } else { + $object.setAttribute(options.param, e.target.checked ? 'true' : 'false'); + } + + template.render(); + }; + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("li", { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("label", { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("input", { + type: "checkbox", + checked: value, + onChange: onChange + }), " ", options.title] + }) + }, key); + + case String: + case Number: + size = options.type === Number ? 5 : undefined; + + onChange = e => { + if (typeof options.param === "function") { + options.param($object, e.target.value); + } else { + $object.setAttribute(options.param, e.target.value); + } + + template.render(); + }; + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("li", { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("label", { + children: [options.title, " ", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("input", { + type: "text", + onInput: onChange, + value: value, + size: size + })] + }) + }, key); + } + }); // check for active settings + + if (!items.filter(Boolean).length) return null; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("ul", { + className: configClass.elem("settings"), + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("li", { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("h4", { + children: "\u914D\u7F6E\u8BBE\u7F6E" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("ul", { + className: configClass.elem("object-settings"), + children: items + })] + }) + }); +}; + +const ConfigureColumns = ({ + columns, + template +}) => { + const updateValue = obj => e => { + const attrName = e.target.value.replace(/^\$/, ""); + obj.setAttribute("value", "$" + attrName); + template.render(); + }; + + if (!template.objects.length) return null; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("div", { + className: configClass.elem("object"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("h4", { + children: "\u914D\u7F6E\u6570\u636E" + }), template.objects.length > 1 && (columns === null || columns === void 0 ? void 0 : columns.length) > 0 && columns.length < template.objects.length && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("p", { + className: configClass.elem("object-error"), + children: ["\u8FD9\u4E2A\u6A21\u677F\u9700\u8981\u66F4\u591A\u7684\u6570\u636E\uFF0C\u5F53\u524D\u60A8\u53EA\u6709", columns.length, "\u4E2A\u6570\u636E"] + }), (columns === null || columns === void 0 ? void 0 : columns.length) === 0 && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("p", { + className: configClass.elem("object-error"), + children: "\u4E3A\u4E86\u9009\u62E9\u54EA\u4E9B\u5B57\u6BB5\u8FDB\u884C\u6807\u6CE8\uFF0C\u60A8\u9700\u8981\u4E0A\u4F20\u6570\u636E\u3002\u6216\u8005\uFF0C\u60A8\u53EF\u4EE5\u4F7F\u7528\u4EE3\u7801\u6A21\u5F0F\u3002" + }), template.objects.map(obj => { + var _obj$getAttribute, _obj$getAttribute2; + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("p", { + children: ["\u4F7F\u7528 ", obj.tagName.toLowerCase(), template.objects > 1 && ` 用于 ${obj.getAttribute("name")}`, " 从 ", (columns === null || columns === void 0 ? void 0 : columns.length) > 0 && columns[0] !== _Template__WEBPACK_IMPORTED_MODULE_12__.DEFAULT_COLUMN && "字段 ", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("select", { + onChange: updateValue(obj), + value: (_obj$getAttribute = obj.getAttribute("value")) === null || _obj$getAttribute === void 0 ? void 0 : _obj$getAttribute.replace(/^\$/, ""), + children: [columns === null || columns === void 0 ? void 0 : columns.map(column => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("option", { + value: column, + children: column === _Template__WEBPACK_IMPORTED_MODULE_12__.DEFAULT_COLUMN ? "<导入的文件>" : `$${column}` + }, column)), !(columns !== null && columns !== void 0 && columns.length) && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("option", { + value: (_obj$getAttribute2 = obj.getAttribute("value")) === null || _obj$getAttribute2 === void 0 ? void 0 : _obj$getAttribute2.replace(/^\$/, ""), + children: "<导入的文件>" + })] + })] + }, obj.getAttribute("name")); + })] + }); +}; + +const Configurator = ({ + columns, + config, + project, + template, + setTemplate, + onBrowse, + onSaveClick, + onValidate, + disableSaveButton +}) => { + const [configure, setConfigure] = react__WEBPACK_IMPORTED_MODULE_2__.useState((0,_Template__WEBPACK_IMPORTED_MODULE_12__.isEmptyConfig)(config) ? "code" : "visual"); + const [visualLoaded, loadVisual] = react__WEBPACK_IMPORTED_MODULE_2__.useState(configure === "visual"); + const [waiting, setWaiting] = react__WEBPACK_IMPORTED_MODULE_2__.useState(false); + const [error, setError] = react__WEBPACK_IMPORTED_MODULE_2__.useState(); + const [configToCheck, setConfigToCheck] = react__WEBPACK_IMPORTED_MODULE_2__.useState(); + const [data, setData] = react__WEBPACK_IMPORTED_MODULE_2__.useState(); + const debounceTimer = react__WEBPACK_IMPORTED_MODULE_2__.useRef(); + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_14__.useAPI)(); + react__WEBPACK_IMPORTED_MODULE_2__.useEffect(() => { + // config may change during init, so wait for that, but for a very short time only + debounceTimer.current = window.setTimeout(() => setConfigToCheck(config), configToCheck ? 500 : 30); + return () => window.clearTimeout(debounceTimer.current); + }, [config]); + react__WEBPACK_IMPORTED_MODULE_2__.useEffect(async () => { + if (!configToCheck) return; + const validation = await api.callApi(`validateConfig`, { + params: { + pk: project.id + }, + body: { + label_config: configToCheck + }, + errorFilter: () => true + }); + + if (validation !== null && validation !== void 0 && validation.error) { + setError(validation.response); + return; + } + + setError(null); + onValidate === null || onValidate === void 0 ? void 0 : onValidate(validation); + const sample = await api.callApi("createSampleTask", { + params: { + pk: project.id + }, + body: { + label_config: configToCheck + }, + errorFilter: () => true + }); + + if (sample && !sample.error) { + setData(sample.sample_task); + } else { + // @todo validation can be done in this place, + // @todo but for now it's extremely slow in /sample-task endpoint + setError(sample === null || sample === void 0 ? void 0 : sample.response); + } + }, [configToCheck]); + react__WEBPACK_IMPORTED_MODULE_2__.useEffect(() => { + setError(null); + }, [template, config]); // code should be reloaded on every render because of uncontrolled codemirror + // visuals should be always rendered after first render + // so load it on the first access, then just show/hide + + const onSelect = value => { + setConfigure(value); + if (value === "visual") loadVisual(true); + }; + + const onSave = async () => { + setError(null); + setWaiting(true); + const res = await onSaveClick(); + setWaiting(false); + + if (res !== true) { + setError(res); + } + }; + + const extra = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("p", { + className: configClass.elem('tags-link'), + children: ["\u4F7F\u7528\u6807\u7B7E\u6765\u914D\u7F6E\u6807\u6CE8\u754C\u9762\u3002", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("br", {}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("a", { + href: "https://labelstud.io/tags/", + target: "_blank", + children: "\u67E5\u770B\u6240\u6709\u53EF\u7528\u6807\u7B7E" + }), "."] + }); + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("div", { + className: configClass, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("div", { + className: configClass.elem("container"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("header", { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("button", { + onClick: onBrowse, + children: "\u6D4F\u89C8\u6A21\u677F" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_components__WEBPACK_IMPORTED_MODULE_4__.ToggleItems, { + items: { + code: "代码", + visual: "可视化" + }, + active: configure, + onSelect: onSelect + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("div", { + className: configClass.elem('editor'), + children: [configure === "code" && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("div", { + className: configClass.elem("code"), + style: { + display: configure === "code" ? undefined : "none" + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(react_codemirror2__WEBPACK_IMPORTED_MODULE_3__.UnControlled, { + name: "code", + id: "edit_code", + value: formatXML(config), + detach: true, + options: { + mode: "xml", + theme: "default", + lineNumbers: true + }, + onChange: (editor, data, value) => setTemplate(value) + }) + }), visualLoaded && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)("div", { + className: configClass.elem("visual"), + style: { + display: configure === "visual" ? undefined : "none" + }, + children: [(0,_Template__WEBPACK_IMPORTED_MODULE_12__.isEmptyConfig)(config) && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(EmptyConfigPlaceholder, {}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(ConfigureColumns, { + columns: columns, + project: project, + template: template + }), template.controls.map(control => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(ConfigureControl, { + control: control, + template: template + }, control.getAttribute("name"))), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(ConfigureSettings, { + template: template + })] + })] + }), disableSaveButton !== true && onSaveClick && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_5__.Form.Actions, { + size: "small", + extra: configure === "code" && extra, + valid: true, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_components__WEBPACK_IMPORTED_MODULE_4__.Button, { + look: "primary", + size: "compact", + style: { + width: 120 + }, + onClick: onSave, + waiting: waiting, + children: "\u4FDD\u5B58" + }) + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_Preview__WEBPACK_IMPORTED_MODULE_11__.Preview, { + config: config, + data: data, + error: error + })] + }); +}; + +const ConfigPage = ({ + config: initialConfig = "", + columns: externalColumns, + project, + onUpdate, + onSaveClick, + onValidate, + disableSaveButton, + show = true +}) => { + const [config, _setConfig] = react__WEBPACK_IMPORTED_MODULE_2__.useState(""); + const [mode, setMode] = react__WEBPACK_IMPORTED_MODULE_2__.useState("list"); // view | list + + const [selectedGroup, setSelectedGroup] = react__WEBPACK_IMPORTED_MODULE_2__.useState(null); + const [selectedRecipe, setSelectedRecipe] = react__WEBPACK_IMPORTED_MODULE_2__.useState(null); + const [template, setCurrentTemplate] = react__WEBPACK_IMPORTED_MODULE_2__.useState(null); + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_14__.useAPI)(); + const setConfig = react__WEBPACK_IMPORTED_MODULE_2__.useCallback(config => { + _setConfig(config); + + onUpdate(config); + }, [_setConfig, onUpdate]); + const setTemplate = react__WEBPACK_IMPORTED_MODULE_2__.useCallback(config => { + const tpl = new _Template__WEBPACK_IMPORTED_MODULE_12__.Template({ + config + }); + tpl.onConfigUpdate = setConfig; + setConfig(config); + setCurrentTemplate(tpl); + }, [setConfig, setCurrentTemplate]); + const [columns, setColumns] = react__WEBPACK_IMPORTED_MODULE_2__.useState(); + react__WEBPACK_IMPORTED_MODULE_2__.useEffect(() => { + if (externalColumns !== null && externalColumns !== void 0 && externalColumns.length) setColumns(externalColumns); + }, [externalColumns]); + react__WEBPACK_IMPORTED_MODULE_2__.useEffect(async () => { + if (!project || columns) return; + const res = await api.callApi("dataSummary", { + params: { + pk: project.id + }, + // 404 is ok, and errors here don't matter + errorFilter: () => true + }); + + if (res !== null && res !== void 0 && res.common_data_columns) { + setColumns(res.common_data_columns); + } + }, [columns, project]); + react__WEBPACK_IMPORTED_MODULE_2__.useEffect(() => { + if (columns !== null && columns !== void 0 && columns.length && template) { + template.fixColumns(columns); + } + }, [columns, template]); + const onSelectRecipe = react__WEBPACK_IMPORTED_MODULE_2__.useCallback(recipe => { + if (!recipe) { + setSelectedRecipe(null); + setMode("list"); + return; + } + + setTemplate(recipe.config); + setSelectedRecipe(recipe); + setMode("view"); + }); + const onCustomTemplate = react__WEBPACK_IMPORTED_MODULE_2__.useCallback(() => { + setTemplate(_Template__WEBPACK_IMPORTED_MODULE_12__.EMPTY_CONFIG); + setMode("view"); + }); + react__WEBPACK_IMPORTED_MODULE_2__.useEffect(() => { + if (initialConfig) { + setTemplate(initialConfig); + setMode("view"); + } + }, []); + if (!show) return null; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("div", { + className: wizardClass, + "data-mode": "list", + id: "config-wizard", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)(_components_Oneof_Oneof__WEBPACK_IMPORTED_MODULE_6__.Oneof, { + value: mode, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_TemplatesList__WEBPACK_IMPORTED_MODULE_13__.TemplatesList, { + case: "list", + selectedGroup: selectedGroup, + selectedRecipe: selectedRecipe, + onSelectGroup: setSelectedGroup, + onSelectRecipe: onSelectRecipe, + onCustomTemplate: onCustomTemplate + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(Configurator, { + case: "view", + columns: columns, + config: config, + project: project, + selectedRecipe: selectedRecipe, + template: template, + setTemplate: setTemplate, + onBrowse: setMode.bind(null, "list"), + onValidate: onValidate, + disableSaveButton: disableSaveButton, + onSaveClick: onSaveClick + })] + }) + }); +}; + +/***/ }), + +/***/ "./src/pages/CreateProject/Config/Preview.js": +/*!***************************************************!*\ + !*** ./src/pages/CreateProject/Config/Preview.js ***! + \***************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Preview": () => (/* binding */ Preview) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../components */ "./src/components/index.js"); +/* harmony import */ var _providers_LibraryProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../providers/LibraryProvider */ "./src/providers/LibraryProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Config_styl__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Config.styl */ "./src/pages/CreateProject/Config/Config.styl"); +/* harmony import */ var _Template__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Template */ "./src/pages/CreateProject/Config/Template.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + +const configClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_3__.cn)("configure"); +const Preview = ({ + config, + data, + error +}) => { + var _error$validation_err, _error$validation_err2, _error$validation_err3, _error$validation_err4, _error$validation_err5, _error$validation_err6, _error$validation_err7, _error$validation_err8; + + const LabelStudio = (0,_providers_LibraryProvider__WEBPACK_IMPORTED_MODULE_2__.useLibrary)('lsf'); + const lsfRoot = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const lsf = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (!LabelStudio) return; + if (!lsfRoot.current) return; + if (error) return; + if (!data) return; + const LSF = window.LabelStudio; + + try { + var _lsf$current; + + (_lsf$current = lsf.current) === null || _lsf$current === void 0 ? void 0 : _lsf$current.destroy(); + lsf.current = new LSF(lsfRoot.current, { + config: config || _Template__WEBPACK_IMPORTED_MODULE_5__.EMPTY_CONFIG, + // empty string causes error in LSF + interfaces: ["side-column"], + task: { + annotations: [], + predictions: [], + id: 1, + data + }, + onLabelStudioLoad: function (LS) { + LS.settings.bottomSidePanel = true; + var c = LS.annotationStore.addAnnotation({ + userGenerate: true + }); + LS.annotationStore.selectAnnotation(c.id); + } + }); + } catch (e) { + console.error(e); + } + }, [config, data, LabelStudio, lsfRoot]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)("div", { + className: configClass.elem("preview"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("h3", { + children: "UI \u9884\u89C8" + }), error && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)("div", { + className: configClass.elem("preview-error"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)("h2", { + children: [error.detail, " ", error.id] + }), (_error$validation_err = error.validation_errors) === null || _error$validation_err === void 0 ? void 0 : (_error$validation_err2 = _error$validation_err.non_field_errors) === null || _error$validation_err2 === void 0 ? void 0 : (_error$validation_err3 = _error$validation_err2.map) === null || _error$validation_err3 === void 0 ? void 0 : _error$validation_err3.call(_error$validation_err2, err => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("p", { + children: err + }, err)), (_error$validation_err4 = error.validation_errors) === null || _error$validation_err4 === void 0 ? void 0 : (_error$validation_err5 = _error$validation_err4.label_config) === null || _error$validation_err5 === void 0 ? void 0 : (_error$validation_err6 = _error$validation_err5.map) === null || _error$validation_err6 === void 0 ? void 0 : _error$validation_err6.call(_error$validation_err5, err => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("p", { + children: err + }, err)), (_error$validation_err7 = error.validation_errors) === null || _error$validation_err7 === void 0 ? void 0 : (_error$validation_err8 = _error$validation_err7.map) === null || _error$validation_err8 === void 0 ? void 0 : _error$validation_err8.call(_error$validation_err7, err => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("p", { + children: err + }, err))] + }), !data && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Spinner, { + style: { + width: "100%", + height: "50vh" + } + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("div", { + id: "label-studio", + ref: lsfRoot + })] + }); +}; + +/***/ }), + +/***/ "./src/pages/CreateProject/Config/Template.js": +/*!****************************************************!*\ + !*** ./src/pages/CreateProject/Config/Template.js ***! + \****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "EMPTY_CONFIG": () => (/* binding */ EMPTY_CONFIG), +/* harmony export */ "DEFAULT_COLUMN": () => (/* binding */ DEFAULT_COLUMN), +/* harmony export */ "isEmptyConfig": () => (/* binding */ isEmptyConfig), +/* harmony export */ "Template": () => (/* binding */ Template) +/* harmony export */ }); +/* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tags */ "./src/pages/CreateProject/Config/tags.js"); +/* harmony import */ var _utils_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../utils/colors */ "./src/utils/colors.js"); +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + +const EMPTY_CONFIG = ""; +const DEFAULT_COLUMN = "$undefined$"; +const isEmptyConfig = config => ["", EMPTY_CONFIG].includes(config.replace(/\s+/g, '')); +class Template { + constructor(tpl) { + _defineProperty(this, "objects", []); + + _defineProperty(this, "controls", []); + + _defineProperty(this, "details", false); + + _defineProperty(this, "palette", (0,_utils_colors__WEBPACK_IMPORTED_MODULE_1__.Palette)()); + + this.tpl = tpl; + this.config = tpl.config; + const parser = new DOMParser(); + this.$root = parser.parseFromString(this.config, 'application/xml'); + this.serializer = new XMLSerializer(); + this.initRoot(); + } + + flatten(el) { + const tags = []; + + for (let tag of el.children) { + tags.push(tag); + if (tag.children.length) tags.push(...this.flatten(tag)); + } + + return tags; + } + + onConfigUpdate() {// should be overwritten + } + + render() { + const config = this.serializer.serializeToString(this.$root); + this.onConfigUpdate(config); + } + + initRoot() { + const tags = this.flatten(this.$root); + this.objects = tags.filter($tag => $tag.tagName in _tags__WEBPACK_IMPORTED_MODULE_0__.OBJECTS); + const names = this.objects.map($tag => $tag.getAttribute('name')); + this.controls = tags.filter($tag => names.includes($tag.getAttribute('toName'))); + + for (let $object of this.objects) { + const object = _tags__WEBPACK_IMPORTED_MODULE_0__.OBJECTS[$object.tagName]; + $object.$controls = this.controls.filter($tag => $tag.getAttribute('toName') === $object.getAttribute('name')); + $object.$controls.forEach($control => $control.$object = $object); + let settings = { ...object.settings + }; + $object.$controls.forEach($control => { + let control = _tags__WEBPACK_IMPORTED_MODULE_0__.CONTROLS[$control.tagName]; + + if (control) { + settings = { ...settings, + ...control.settings + }; + } + }); + this.settings = settings; + } + } // fix `value` of object tags according to current columns from data + + + fixColumns(columns) { + if (columns.length === 1 && columns[0] === DEFAULT_COLUMN) return; + const existing = this.objects.map(obj => obj.getAttribute("value").replace(/^\$/, '')); + let free = columns.filter(c => !existing.includes(c)); + + for (let obj of this.objects) { + if (!columns.includes(obj.getAttribute("value").replace(/^\$/, ''))) { + var _free$shift; + + obj.setAttribute("value", "$" + ((_free$shift = free.shift()) !== null && _free$shift !== void 0 ? _free$shift : columns[0])); + } + } + + this.render(); + } + + addLabels(control, labels) { + if (!labels) return; + + if (!Array.isArray(labels)) { + labels = labels.split("\n").map(s => s.trim()).filter(Boolean); + } + + if (!labels.length) return; + const existing = [...control.children].map(ch => ch.getAttribute("value")); + const isChoices = control.tagName === "Choices"; + labels.forEach(label => { + if (existing.includes(label)) return; + existing.push(label); + const $label = this.$root.createElement(isChoices ? "Choice" : "Label"); + $label.setAttribute("value", label); + if (!isChoices) $label.setAttribute("background", this.palette.next().value); + control.appendChild($label); + }); + this.render(); + } + + removeLabel($label) { + $label.parentNode.removeChild($label); + this.render(); + } + + changeLabel($label, attrs) { + for (let attr of Object.keys(attrs)) { + $label.setAttribute(attr, attrs[attr]); + } + + this.render(); + } + +} + +/***/ }), + +/***/ "./src/pages/CreateProject/Config/TemplatesList.js": +/*!*********************************************************!*\ + !*** ./src/pages/CreateProject/Config/TemplatesList.js ***! + \*********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "TemplatesList": () => (/* binding */ TemplatesList) +/* harmony export */ }); +/* harmony import */ var codemirror_lib_codemirror_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! codemirror/lib/codemirror.css */ "./node_modules/codemirror/lib/codemirror.css"); +/* harmony import */ var codemirror_mode_xml_xml__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! codemirror/mode/xml/xml */ "./node_modules/codemirror/mode/xml/xml.js"); +/* harmony import */ var codemirror_mode_xml_xml__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(codemirror_mode_xml_xml__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../components */ "./src/components/index.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Config_styl__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Config.styl */ "./src/pages/CreateProject/Config/Config.styl"); +/* harmony import */ var _assets_icons__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../assets/icons */ "./src/assets/icons/index.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + +const listClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_5__.cn)("templates-list"); + +const Arrow = () => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("svg", { + width: "8", + height: "12", + viewBox: "0 0 8 12", + fill: "none", + xmlns: "http://www.w3.org/2000/svg", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("path", { + opacity: "0.9", + d: "M2 10L6 6L2 2", + stroke: "currentColor", + strokeWidth: "2", + strokeLinecap: "square" + }) +}); + +const TemplatesInGroup = ({ + templates, + group, + onSelectRecipe +}) => { + const picked = templates.filter(recipe => recipe.group === group) // templates without `order` go to the end of the list + .sort((a, b) => { + var _a$order, _b$order; + + return ((_a$order = a.order) !== null && _a$order !== void 0 ? _a$order : Infinity) - ((_b$order = b.order) !== null && _b$order !== void 0 ? _b$order : Infinity); + }); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("ul", { + children: picked.map(recipe => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("li", { + onClick: () => onSelectRecipe(recipe), + className: listClass.elem("template"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("img", { + src: recipe.image + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("h3", { + children: recipe.title + })] + }, recipe.title)) + }); +}; + +const TemplatesList = ({ + selectedGroup, + selectedRecipe, + onCustomTemplate, + onSelectGroup, + onSelectRecipe +}) => { + const [groups, setGroups] = react__WEBPACK_IMPORTED_MODULE_2__.useState([]); + const [templates, setTemplates] = react__WEBPACK_IMPORTED_MODULE_2__.useState(); + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_4__.useAPI)(); + react__WEBPACK_IMPORTED_MODULE_2__.useEffect(async () => { + const res = await api.callApi('configTemplates'); + if (!res) return; + const { + templates, + groups + } = res; + setTemplates(templates); + setGroups(groups); + }, []); + const selected = selectedGroup || groups[0]; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("div", { + className: listClass, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("aside", { + className: listClass.elem("sidebar"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("ul", { + children: groups.map(group => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("li", { + onClick: () => onSelectGroup(group), + className: listClass.elem("group").mod({ + active: selected === group, + selected: (selectedRecipe === null || selectedRecipe === void 0 ? void 0 : selectedRecipe.group) === group + }), + children: [group, /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(Arrow, {})] + }, group)) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("button", { + type: "button", + onClick: onCustomTemplate, + className: listClass.elem("custom-template"), + children: "\u81EA\u5B9A\u4E49\u6A21\u677F" + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("main", { + children: [!templates && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components__WEBPACK_IMPORTED_MODULE_3__.Spinner, { + style: { + width: "100%", + height: 200 + } + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(TemplatesInGroup, { + templates: templates || [], + group: selected, + onSelectRecipe: onSelectRecipe + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("footer", { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_assets_icons__WEBPACK_IMPORTED_MODULE_7__.IconInfo, { + className: listClass.elem("info-icon"), + width: "20", + height: "20" + }), "\u60F3\u8981\u4E86\u89E3\u5982\u4F55\u8D21\u732E\u6A21\u677F\uFF0C\u8BF7\u67E5\u770B", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("a", { + href: "https://labelstud.io/guide", + target: "_blank", + children: "\u6587\u6863" + }), "\u3002"] + })] + }); +}; + +/***/ }), + +/***/ "./src/pages/CreateProject/Config/colors.js": +/*!**************************************************!*\ + !*** ./src/pages/CreateProject/Config/colors.js ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "colorNames": () => (/* binding */ colorNames) +/* harmony export */ }); +const colorNames = { + aliceblue: "#f0f8ff", + antiquewhite: "#faebd7", + aqua: "#00ffff", + aquamarine: "#7fffd4", + azure: "#f0ffff", + beige: "#f5f5dc", + bisque: "#ffe4c4", + black: "#000000", + blanchedalmond: "#ffebcd", + blue: "#0000ff", + blueviolet: "#8a2be2", + brown: "#a52a2a", + burlywood: "#deb887", + cadetblue: "#5f9ea0", + chartreuse: "#7fff00", + chocolate: "#d2691e", + coral: "#ff7f50", + cornflowerblue: "#6495ed", + cornsilk: "#fff8dc", + crimson: "#dc143c", + cyan: "#00ffff", + darkblue: "#00008b", + darkcyan: "#008b8b", + darkgoldenrod: "#b8860b", + darkgray: "#a9a9a9", + darkgreen: "#006400", + darkkhaki: "#bdb76b", + darkmagenta: "#8b008b", + darkolivegreen: "#556b2f", + darkorange: "#ff8c00", + darkorchid: "#9932cc", + darkred: "#8b0000", + darksalmon: "#e9967a", + darkseagreen: "#8fbc8f", + darkslateblue: "#483d8b", + darkslategray: "#2f4f4f", + darkturquoise: "#00ced1", + darkviolet: "#9400d3", + deeppink: "#ff1493", + deepskyblue: "#00bfff", + dimgray: "#696969", + dodgerblue: "#1e90ff", + firebrick: "#b22222", + floralwhite: "#fffaf0", + forestgreen: "#228b22", + fuchsia: "#ff00ff", + gainsboro: "#dcdcdc", + ghostwhite: "#f8f8ff", + gold: "#ffd700", + goldenrod: "#daa520", + gray: "#808080", + green: "#008000", + greenyellow: "#adff2f", + honeydew: "#f0fff0", + hotpink: "#ff69b4", + indianred: "#cd5c5c", + indigo: "#4b0082", + ivory: "#fffff0", + khaki: "#f0e68c", + lavender: "#e6e6fa", + lavenderblush: "#fff0f5", + lawngreen: "#7cfc00", + lemonchiffon: "#fffacd", + lightblue: "#add8e6", + lightcoral: "#f08080", + lightcyan: "#e0ffff", + lightgoldenrodyellow: "#fafad2", + lightgrey: "#d3d3d3", + lightgreen: "#90ee90", + lightpink: "#ffb6c1", + lightsalmon: "#ffa07a", + lightseagreen: "#20b2aa", + lightskyblue: "#87cefa", + lightslategray: "#778899", + lightsteelblue: "#b0c4de", + lightyellow: "#ffffe0", + lime: "#00ff00", + limegreen: "#32cd32", + linen: "#faf0e6", + magenta: "#ff00ff", + maroon: "#800000", + mediumaquamarine: "#66cdaa", + mediumblue: "#0000cd", + mediumorchid: "#ba55d3", + mediumpurple: "#9370d8", + mediumseagreen: "#3cb371", + mediumslateblue: "#7b68ee", + mediumspringgreen: "#00fa9a", + mediumturquoise: "#48d1cc", + mediumvioletred: "#c71585", + midnightblue: "#191970", + mintcream: "#f5fffa", + mistyrose: "#ffe4e1", + moccasin: "#ffe4b5", + navajowhite: "#ffdead", + navy: "#000080", + oldlace: "#fdf5e6", + olive: "#808000", + olivedrab: "#6b8e23", + orange: "#ffa500", + orangered: "#ff4500", + orchid: "#da70d6", + palegoldenrod: "#eee8aa", + palegreen: "#98fb98", + paleturquoise: "#afeeee", + palevioletred: "#d87093", + papayawhip: "#ffefd5", + peachpuff: "#ffdab9", + peru: "#cd853f", + pink: "#ffc0cb", + plum: "#dda0dd", + powderblue: "#b0e0e6", + purple: "#800080", + rebeccapurple: "#663399", + red: "#ff0000", + rosybrown: "#bc8f8f", + royalblue: "#4169e1", + saddlebrown: "#8b4513", + salmon: "#fa8072", + sandybrown: "#f4a460", + seagreen: "#2e8b57", + seashell: "#fff5ee", + sienna: "#a0522d", + silver: "#c0c0c0", + skyblue: "#87ceeb", + slateblue: "#6a5acd", + slategray: "#708090", + snow: "#fffafa", + springgreen: "#00ff7f", + steelblue: "#4682b4", + tan: "#d2b48c", + teal: "#008080", + thistle: "#d8bfd8", + tomato: "#ff6347", + turquoise: "#40e0d0", + violet: "#ee82ee", + wheat: "#f5deb3", + white: "#ffffff", + whitesmoke: "#f5f5f5", + yellow: "#ffff00", + yellowgreen: "#9acd32" +}; + +/***/ }), + +/***/ "./src/pages/CreateProject/Config/tags.js": +/*!************************************************!*\ + !*** ./src/pages/CreateProject/Config/tags.js ***! + \************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "OBJECTS": () => (/* binding */ OBJECTS), +/* harmony export */ "CONTROLS": () => (/* binding */ CONTROLS), +/* harmony export */ "TAGS": () => (/* binding */ TAGS) +/* harmony export */ }); +const OBJECTS = { + Image: { + type: 'Image', + settings: { + strokeWidth: { + title: 'Width of region borders', + type: Number, + param: ($obj, value) => $obj.$controls.forEach($control => $control.setAttribute('strokeWidth', value)), + value: $obj => { + var _$obj$$controls$0$get, _$obj$$controls$; + + return (_$obj$$controls$0$get = (_$obj$$controls$ = $obj.$controls[0]) === null || _$obj$$controls$ === void 0 ? void 0 : _$obj$$controls$.getAttribute('strokeWidth')) !== null && _$obj$$controls$0$get !== void 0 ? _$obj$$controls$0$get : 1; + } + }, + zoom: { + title: 'Allow image zoom (ctrl+wheel)', + type: Boolean, + param: 'zoom' + }, + zoomControl: { + title: 'Show controls to zoom in and out', + type: Boolean, + param: 'zoomControl' + }, + rotateControl: { + title: 'Show controls to rotate image', + type: Boolean, + param: 'rotateControl' + } + } + }, + Text: { + type: 'Text', + settings: { + granularity: { + title: 'Select text by words', + type: Boolean, + param: ($obj, value) => value ? $obj.setAttribute('granularity', 'word') : $obj.removeAttribute('granularity'), + value: $obj => $obj.getAttribute('granularity') === 'word', + when: $obj => $obj.$controls.filter(c => c.tagName.endsWith('Labels')).length > 0 + } + } + }, + HyperText: { + type: 'HyperText' + }, + Audio: { + type: 'Audio' + }, + AudioPlus: { + type: 'AudioPlus' + }, + TimeSeries: { + type: 'TimeSeries' + }, + Paragraphs: { + type: 'Paragraphs' + }, + Table: { + type: 'Table' + } +}; +const Labels = { + type: 'Labels', + settings: { + placeLabelsLeft: { + title: 'Display labels:', + type: ["bottom", "left", "right", "top"], + control: true, + param: ($control, value) => { + var _$container$firstChil, _$container$firstChil2, _$container$getAttrib; + + let $container = $control.parentNode; + let $labels = $control; + + if (((_$container$firstChil = $container.firstChild) === null || _$container$firstChil === void 0 ? void 0 : (_$container$firstChil2 = _$container$firstChil.tagName) === null || _$container$firstChil2 === void 0 ? void 0 : _$container$firstChil2.toUpperCase()) === "FILTER") { + $labels = $container; + $container = $labels.parentNode; + } + + const $obj = $control.$object; + const inline = ["top", "bottom"].includes(value); + const reversed = ["top", "left"].includes(value); + const direction = (inline ? "column" : "row") + (reversed ? "-reverse" : ""); + const alreadyApplied = (_$container$getAttrib = $container.getAttribute("style")) === null || _$container$getAttrib === void 0 ? void 0 : _$container$getAttrib.includes("flex"); + + if (!alreadyApplied) { + $container = $obj.ownerDocument.createElement('View'); + $labels.parentNode.insertBefore($container, $obj); + $container.appendChild($obj); + $container.appendChild($labels); + } + + $control.setAttribute('showInline', JSON.stringify(inline)); + $container.setAttribute('style', 'display:flex;align-items:start;gap:8px;flex-direction:' + direction); + }, + value: $control => { + var _$container$firstChil3, _$container$firstChil4; + + let $container = $control.parentNode; + + if (((_$container$firstChil3 = $container.firstChild) === null || _$container$firstChil3 === void 0 ? void 0 : (_$container$firstChil4 = _$container$firstChil3.tagName) === null || _$container$firstChil4 === void 0 ? void 0 : _$container$firstChil4.toUpperCase()) === "FILTER") { + $container = $container.parentNode; + } + + const style = $container.getAttribute("style"); + const direction = style === null || style === void 0 ? void 0 : style.match(/direction:(row|column)(-reverse)?/); + + if (!direction) { + const position = $control.compareDocumentPosition($control.$object); + return position & Node.DOCUMENT_POSITION_FOLLOWING ? "top" : "bottom"; + } + + if (direction[1] === "column") return direction[2] ? "top" : "bottom";else return direction[2] ? "left" : "right"; + } + }, + filter: { + title: 'Add filter for long list of labels', + type: Boolean, + control: true, + param: ($obj, value) => { + if (value) { + const $filter = $obj.ownerDocument.createElement('Filter'); + const $container = $obj.ownerDocument.createElement('View'); + $filter.setAttribute('toName', $obj.getAttribute('name')); + $filter.setAttribute('minlength', 0); + $filter.setAttribute('name', 'filter'); // @todo should be unique + + $obj.parentNode.insertBefore($container, $obj); + $container.appendChild($filter); + $container.appendChild($obj); + } else { + const $filter = $obj.previousElementSibling; + + if ($filter.tagName.toUpperCase() === "FILTER") { + const $container = $obj.parentNode; + $container.parentNode.insertBefore($obj, $container); + $container.parentNode.removeChild($container); + } + } + }, + value: $control => { + var _$control$previousEle; + + return ((_$control$previousEle = $control.previousElementSibling) === null || _$control$previousEle === void 0 ? void 0 : _$control$previousEle.tagName.toUpperCase()) === "FILTER"; + } + } + } +}; +const CONTROLS = { + Labels, + RectangleLabels: Labels +}; +const TAGS = { ...OBJECTS, + ...CONTROLS +}; + + +/***/ }), + +/***/ "./src/pages/CreateProject/CreateProject.js": +/*!**************************************************!*\ + !*** ./src/pages/CreateProject/CreateProject.js ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "CreateProject": () => (/* binding */ CreateProject) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! react-router */ "./node_modules/react-router/esm/react-router.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components */ "./src/components/index.js"); +/* harmony import */ var _components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../components/Modal/Modal */ "./src/components/Modal/Modal.js"); +/* harmony import */ var _components_Space_Space__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../components/Space/Space */ "./src/components/Space/Space.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _Config_Config__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Config/Config */ "./src/pages/CreateProject/Config/Config.js"); +/* harmony import */ var _CreateProject_styl__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./CreateProject.styl */ "./src/pages/CreateProject/CreateProject.styl"); +/* harmony import */ var _Import_Import__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Import/Import */ "./src/pages/CreateProject/Import/Import.js"); +/* harmony import */ var _Import_useImportPage__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Import/useImportPage */ "./src/pages/CreateProject/Import/useImportPage.js"); +/* harmony import */ var _utils_useDraftProject__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./utils/useDraftProject */ "./src/pages/CreateProject/utils/useDraftProject.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + + + + + + +const ProjectName = ({ + name, + setName, + onSaveName, + onSubmit, + error, + description, + setDescription, + show = true +}) => !show ? null : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)("form", { + className: (0,_utils_bem__WEBPACK_IMPORTED_MODULE_5__.cn)("project-name"), + onSubmit: e => { + e.preventDefault(); + onSubmit(); + }, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)("div", { + className: "field field--wide", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("label", { + htmlFor: "project_name", + children: "\u9879\u76EE\u540D\u79F0" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("input", { + name: "name", + id: "project_name", + value: name, + onChange: e => setName(e.target.value), + onBlur: onSaveName + }), error && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("span", { + className: "error", + children: error + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)("div", { + className: "field field--wide", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("label", { + htmlFor: "project_description", + children: "\u63CF\u8FF0" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("textarea", { + name: "description", + id: "project_description", + placeholder: "\u63CF\u8FF0\u4F60\u7684\u9879\u76EE\uFF08\u53EF\u9009\uFF09", + rows: "4", + value: description, + onChange: e => setDescription(e.target.value) + })] + })] +}); + +const CreateProject = ({ + onClose +}) => { + const [step, setStep] = react__WEBPACK_IMPORTED_MODULE_0__.useState("name"); // name | import | config + + const [waiting, setWaitingStatus] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false); + const project = (0,_utils_useDraftProject__WEBPACK_IMPORTED_MODULE_10__.useDraftProject)(); + const history = (0,react_router__WEBPACK_IMPORTED_MODULE_12__.useHistory)(); + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_4__.useAPI)(); + const [name, setName] = react__WEBPACK_IMPORTED_MODULE_0__.useState(""); + const [error, setError] = react__WEBPACK_IMPORTED_MODULE_0__.useState(); + const [description, setDescription] = react__WEBPACK_IMPORTED_MODULE_0__.useState(""); + const [config, setConfig] = react__WEBPACK_IMPORTED_MODULE_0__.useState(""); + react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { + setError(null); + }, [name]); + const { + columns, + uploading, + uploadDisabled, + finishUpload, + pageProps + } = (0,_Import_useImportPage__WEBPACK_IMPORTED_MODULE_9__.useImportPage)(project); + const rootClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_5__.cn)("create-project"); + const tabClass = rootClass.elem("tab"); + const steps = { + name: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("span", { + className: tabClass.mod({ + disabled: !!error + }), + children: "\u9879\u76EE\u540D\u79F0" + }), + import: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("span", { + className: tabClass.mod({ + disabled: uploadDisabled + }), + children: "\u6570\u636E\u5BFC\u5165" + }), + config: "标注配置" + }; // name intentionally skipped from deps: + // this should trigger only once when we got project loaded + + react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => project && !name && setName(project.title), [project]); + const projectBody = react__WEBPACK_IMPORTED_MODULE_0__.useMemo(() => ({ + title: name, + description, + label_config: config + }), [name, description, config]); + const onCreate = react__WEBPACK_IMPORTED_MODULE_0__.useCallback(async () => { + const imported = await finishUpload(); + if (!imported) return; + setWaitingStatus(true); + const response = await api.callApi('updateProject', { + params: { + pk: project.id + }, + body: projectBody + }); + setWaitingStatus(false); + + if (response !== null) { + history.push(`/projects/${response.id}/data`); + } + }, [project, projectBody, finishUpload]); + + const onSaveName = async () => { + var _err$validation_error; + + if (error) return; + const res = await api.callApi('updateProjectRaw', { + params: { + pk: project.id + }, + body: { + title: name + } + }); + if (res.ok) return; + const err = await res.json(); + setError((_err$validation_error = err.validation_errors) === null || _err$validation_error === void 0 ? void 0 : _err$validation_error.title); + }; + + const onDelete = react__WEBPACK_IMPORTED_MODULE_0__.useCallback(async () => { + setWaitingStatus(true); + if (project) await api.callApi('deleteProject', { + params: { + pk: project.id + } + }); + setWaitingStatus(false); + history.replace("/projects"); + onClose === null || onClose === void 0 ? void 0 : onClose(); + }, [project]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__.Modal, { + onHide: () => history.push("/projects"), + fullscreen: true, + visible: true, + bare: true, + closeOnClickOutside: false, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)("div", { + className: rootClass, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)(_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__.Modal.Header, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("h1", { + children: "\u521B\u5EFA\u9879\u76EE" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.ToggleItems, { + items: steps, + active: step, + onSelect: setStep + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_3__.Space, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + look: "danger", + size: "compact", + onClick: onDelete, + waiting: waiting, + children: "\u5220\u9664" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + look: "primary", + size: "compact", + onClick: onCreate, + waiting: waiting || uploading, + disabled: !project || uploadDisabled || error, + children: "\u4FDD\u5B58" + })] + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(ProjectName, { + name: name, + setName: setName, + error: error, + onSaveName: onSaveName, + onSubmit: onCreate, + description: description, + setDescription: setDescription, + show: step === "name" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_Import_Import__WEBPACK_IMPORTED_MODULE_8__.ImportPage, { + project: project, + show: step === "import", + ...pageProps + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_Config_Config__WEBPACK_IMPORTED_MODULE_6__.ConfigPage, { + project: project, + onUpdate: setConfig, + show: step === "config", + columns: columns, + disableSaveButton: true + })] + }) + }); +}; + +/***/ }), + +/***/ "./src/pages/CreateProject/Import/Import.js": +/*!**************************************************!*\ + !*** ./src/pages/CreateProject/Import/Import.js ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ImportPage": () => (/* binding */ ImportPage) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _components_Modal_Modal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../components/Modal/Modal */ "./src/components/Modal/Modal.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var _Import_styl__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Import.styl */ "./src/pages/CreateProject/Import/Import.styl"); +/* harmony import */ var _assets_icons__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../assets/icons */ "./src/assets/icons/index.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + +const importClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_2__.cn)("upload_page"); +const dropzoneClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_2__.cn)("dropzone"); + +function flatten(nested) { + return [].concat(...nested); +} + +function traverseFileTree(item, path) { + return new Promise(resolve => { + path = path || ""; + + if (item.isFile) { + // Avoid hidden files + if (item.name[0] === ".") return resolve([]); + resolve([item]); + } else if (item.isDirectory) { + // Get folder contents + const dirReader = item.createReader(); + const dirPath = path + item.name + "/"; + dirReader.readEntries(function (entries) { + Promise.all(entries.map(entry => traverseFileTree(entry, dirPath))).then(flatten).then(resolve); + }); + } + }); +} + +function getFiles(files) { + // @todo this can be not a files, but text or any other draggable stuff + return new Promise(resolve => { + if (!files.length) return resolve([]); + if (!files[0].webkitGetAsEntry) return resolve(files); // Use DataTransferItemList interface to access the file(s) + + const entries = Array.from(files).map(file => file.webkitGetAsEntry()); + Promise.all(entries.map(traverseFileTree)).then(flatten).then(fileEntries => fileEntries.map(fileEntry => new Promise(res => fileEntry.file(res)))).then(filePromises => Promise.all(filePromises)).then(resolve); + }); +} + +const Footer = () => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_1__.Modal.Footer, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_assets_icons__WEBPACK_IMPORTED_MODULE_5__.IconInfo, { + className: importClass.elem("info-icon"), + width: "20", + height: "20" + }), "\u67E5\u770B\u6587\u6863\uFF0C\u4E86\u89E3\u5982\u4F55", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("a", { + target: "_blank", + href: "https://labelstud.io/guide/predictions.html", + children: "\u5BFC\u5165\u9884\u6807\u6CE8\u6570\u636E" + }), "\u6216", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("a", { + target: "_blank", + href: "https://labelstud.io/guide/storage.html", + children: "\u4ECE\u6570\u636E\u5E93\u6216\u4E91\u5B58\u50A8\u4E2D\u540C\u6B65\u6570\u636E" + }), "\u3002"] + }); +}; + +const Upload = ({ + children, + sendFiles +}) => { + const [hovered, setHovered] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + + const onHover = e => { + e.preventDefault(); + setHovered(true); + }; + + const onLeave = setHovered.bind(null, false); + const dropzoneRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const onDrop = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(e => { + e.preventDefault(); + onLeave(); + getFiles(e.dataTransfer.items).then(files => sendFiles(files)); + }, [onLeave, sendFiles]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("div", { + id: "holder", + className: dropzoneClass.mod({ + hovered + }), + ref: dropzoneRef, + onDragStart: onHover, + onDragOver: onHover, + onDragLeave: onLeave, + onDrop: onDrop // {...getRootProps} + , + children: children + }); +}; + +const ErrorMessage = ({ + error +}) => { + var _error$validation_err; + + if (!error) return null; + let extra = (_error$validation_err = error.validation_errors) !== null && _error$validation_err !== void 0 ? _error$validation_err : error.extra; // support all possible responses + + if (extra && typeof extra === "object" && !Array.isArray(extra)) { + var _extra$non_field_erro; + + extra = (_extra$non_field_erro = extra.non_field_errors) !== null && _extra$non_field_erro !== void 0 ? _extra$non_field_erro : Object.values(extra); + } + + if (Array.isArray(extra)) extra = extra.join("; "); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("div", { + className: importClass.elem("error"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_assets_icons__WEBPACK_IMPORTED_MODULE_5__.IconError, { + style: { + marginRight: 8 + } + }), error.id && `[${error.id}] `, error.detail || error.message, extra && ` (${extra})`] + }); +}; + +const ImportPage = ({ + project, + show = true, + onWaiting, + onFileListUpdate, + highlightCsvHandling, + dontCommitToProject = false, + csvHandling, + setCsvHandling, + addColumns +}) => { + var _files$uploaded, _files$uploading; + + const [loading, setLoading] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + const [error, setError] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(); + const [ids, _setIds] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]); + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_6__.useAPI)(); + + const processFiles = (state, action) => { + if (action.sending) { + return { ...state, + uploading: [...action.sending, ...state.uploading] + }; + } + + if (action.sent) { + return { ...state, + uploading: state.uploading.filter(f => !action.sent.includes(f)) + }; + } + + if (action.uploaded) { + return { ...state, + uploaded: (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_3__.unique)([...state.uploaded, ...action.uploaded], (a, b) => a.id === b.id) + }; + } // if (action.ids) { + // const ids = unique([...state.ids, ...action.ids]); + // onFileListUpdate?.(ids); + // return {...state, ids }; + // } + + + return state; + }; + + const [files, dispatch] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useReducer)(processFiles, { + uploaded: [], + uploading: [] + }); + const showList = Boolean(((_files$uploaded = files.uploaded) === null || _files$uploaded === void 0 ? void 0 : _files$uploaded.length) || ((_files$uploading = files.uploading) === null || _files$uploading === void 0 ? void 0 : _files$uploading.length)); + + const setIds = ids => { + _setIds(ids); + + onFileListUpdate === null || onFileListUpdate === void 0 ? void 0 : onFileListUpdate(ids); + }; + + const loadFilesList = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async file_upload_ids => { + const query = {}; + + if (file_upload_ids) { + // should be stringified array "[1,2]" + query.ids = JSON.stringify(file_upload_ids); + } + + const files = await api.callApi("fileUploads", { + params: { + pk: project.id, + ...query + } + }); + dispatch({ + uploaded: files !== null && files !== void 0 ? files : [] + }); + + if (files !== null && files !== void 0 && files.length) { + setIds((0,_utils_helpers__WEBPACK_IMPORTED_MODULE_3__.unique)([...ids, ...files.map(f => f.id)])); + } + + return files; + }, [project]); + + const onStart = () => { + setLoading(true); + setError(null); + }; + + const onError = err => { + console.error(err); // @todo workaround for error about input size in a wrong html format + + if (typeof err === "string" && err.includes("RequestDataTooBig")) { + var _err$match; + + const message = "导入的文件太大"; + const extra = (_err$match = err.match(/"exception_value">(.*)<\/pre>/)) === null || _err$match === void 0 ? void 0 : _err$match[1]; + err = { + message, + extra + }; + } + + setError(err); + setLoading(false); + onWaiting === null || onWaiting === void 0 ? void 0 : onWaiting(false); + }; + + const onFinish = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(res => { + const { + could_be_tasks_list, + data_columns, + file_upload_ids + } = res; + const file_ids = [...ids, ...file_upload_ids]; + setIds(file_ids); + if (could_be_tasks_list && !csvHandling) setCsvHandling("choose"); + setLoading(true); + onWaiting === null || onWaiting === void 0 ? void 0 : onWaiting(false); + addColumns(data_columns); + return loadFilesList(file_ids).then(() => setLoading(false)); + }, [addColumns, loadFilesList, setIds, ids, setLoading]); + const importFiles = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async (files, body) => { + dispatch({ + sending: files + }); + const query = dontCommitToProject ? { + commit_to_project: "false" + } : {}; // @todo use json for dataset uploads by URL + + const contentType = body instanceof FormData ? 'multipart/form-data' // usual multipart for usual files + : 'application/x-www-form-urlencoded'; // chad urlencoded for URL uploads + + const res = await api.callApi("importFiles", { + params: { + pk: project.id, + ...query + }, + headers: { + 'Content-Type': contentType + }, + body, + errorFilter: () => true + }); + if (res && !res.error) onFinish === null || onFinish === void 0 ? void 0 : onFinish(res);else onError === null || onError === void 0 ? void 0 : onError(res === null || res === void 0 ? void 0 : res.response); + dispatch({ + sent: files + }); + }, [project, onFinish]); + const sendFiles = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(files => { + onStart(); + onWaiting === null || onWaiting === void 0 ? void 0 : onWaiting(true); + files = [...files]; // they can be array-like object + + const fd = new FormData(); + + for (let f of files) fd.append(f.name, f); + + return importFiles(files, fd); + }, [importFiles, onStart]); + const onUpload = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(e => { + sendFiles(e.target.files); + e.target.value = ""; + }, [sendFiles]); + const onLoadURL = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(e => { + var _urlRef$current; + + e.preventDefault(); + onStart(); + const url = (_urlRef$current = urlRef.current) === null || _urlRef$current === void 0 ? void 0 : _urlRef$current.value; + + if (!url) { + setLoading(false); + return; + } + + urlRef.current.value = ""; + onWaiting === null || onWaiting === void 0 ? void 0 : onWaiting(true); + const body = new URLSearchParams({ + url + }); + importFiles([{ + name: url + }], body); + }, [importFiles]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if ((project === null || project === void 0 ? void 0 : project.id) !== undefined) { + loadFilesList().then(files => { + if (csvHandling) return; // empirical guess on start if we have some possible tasks list/time series problem + + if (Array.isArray(files) && files.some(({ + file + }) => /\.[ct]sv$/.test(file))) { + setCsvHandling("choose"); + } + }); + } + }, [project, loadFilesList]); + const urlRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + if (!project) return null; + if (!show) return null; + const csvProps = { + name: "csv", + type: "radio", + onChange: e => setCsvHandling(e.target.value) + }; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("div", { + className: importClass, + children: [highlightCsvHandling && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("div", { + className: importClass.elem("csv-splash") + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("input", { + id: "file-input", + type: "file", + name: "file", + multiple: true, + onChange: onUpload, + style: { + display: "none" + } + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("header", { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("form", { + className: importClass.elem("url-form") + " inline", + method: "POST", + onSubmit: onLoadURL, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("input", { + placeholder: "\u6570\u636E\u96C6\u7684 URL", + name: "url", + ref: urlRef + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("button", { + type: "submit", + children: "\u6DFB\u52A0 URL" + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("span", { + children: "\u6216" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("button", { + onClick: () => document.getElementById('file-input').click(), + className: importClass.elem("upload-button"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_assets_icons__WEBPACK_IMPORTED_MODULE_5__.IconUpload, { + width: "16", + height: "16", + className: importClass.elem("upload-icon") + }), "\u4E0A\u4F20 ", files.uploaded.length ? "更多 " : "", "\u6587\u4EF6"] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("div", { + className: importClass.elem("csv-handling").mod({ + highlighted: highlightCsvHandling, + hidden: !csvHandling + }), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("span", { + children: "\u5C06 CSV/TSV \u4F5C\u4E3A" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("label", { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("input", { ...csvProps, + value: "tasks", + checked: csvHandling === "tasks" + }), " \u4EFB\u52A1\u5217\u8868"] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("label", { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("input", { ...csvProps, + value: "ts", + checked: csvHandling === "ts" + }), " \u65F6\u95F4\u5E8F\u5217"] + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("div", { + className: importClass.elem("status"), + children: files.uploaded.length ? `${files.uploaded.length} 个文件已上传` : "" + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(ErrorMessage, { + error: error + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("main", { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(Upload, { + sendFiles: sendFiles, + project: project, + children: [!showList && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("label", { + htmlFor: "file-input", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("div", { + className: dropzoneClass.elem("content"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("header", { + children: ["\u5C06\u6587\u4EF6\u62D6\u653E\u5230\u6B64\u5904", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("br", {}), "\u6216\u5355\u51FB\u6D4F\u89C8"] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_assets_icons__WEBPACK_IMPORTED_MODULE_5__.IconUpload, { + height: "64", + className: dropzoneClass.elem("icon") + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("dl", { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("dt", { + children: "\u6587\u672C" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("dd", { + children: "txt" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("dt", { + children: "\u97F3\u9891" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("dd", { + children: "wav, aiff, mp3, au, flac, m4a, ogg" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("dt", { + children: "\u56FE\u50CF" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("dd", { + children: "jpg, png, gif, bmp, svg, webp" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("dt", { + children: "HTML" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("dd", { + children: "html, htm, xml" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("dt", { + children: "\u65F6\u95F4\u5E8F\u5217" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("dd", { + children: "csv, tsv" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("dt", { + children: "\u5E38\u89C1\u683C\u5F0F" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("dd", { + children: "csv, tsv, txt, json" + })] + })] + }) + }), showList && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("table", { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("tbody", { + children: [files.uploading.map(file => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("tr", { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("td", { + children: file.name + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("td", { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("span", { + className: importClass.elem("file-status").mod({ + uploading: true + }) + }) + })] + }, file.name)), files.uploaded.map(file => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("tr", { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("td", { + children: file.file + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("td", { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("span", { + className: importClass.elem("file-status") + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("td", { + children: file.size + })] + }, file.file))] + }) + })] + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(Footer, {})] + }); +}; + +/***/ }), + +/***/ "./src/pages/CreateProject/Import/ImportModal.js": +/*!*******************************************************!*\ + !*** ./src/pages/CreateProject/Import/ImportModal.js ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Inner": () => (/* binding */ Inner), +/* harmony export */ "ImportModal": () => (/* binding */ ImportModal) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! react-router */ "./node_modules/react-router/esm/react-router.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../components */ "./src/components/index.js"); +/* harmony import */ var _components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../components/Modal/Modal */ "./src/components/Modal/Modal.js"); +/* harmony import */ var _components_Space_Space__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../components/Space/Space */ "./src/components/Space/Space.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../providers/ProjectProvider */ "./src/providers/ProjectProvider.tsx"); +/* harmony import */ var _providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../providers/RoutesProvider */ "./src/providers/RoutesProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_hooks__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../utils/hooks */ "./src/utils/hooks.js"); +/* harmony import */ var _Import__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Import */ "./src/pages/CreateProject/Import/Import.js"); +/* harmony import */ var _useImportPage__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./useImportPage */ "./src/pages/CreateProject/Import/useImportPage.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + + + + + +const Inner = () => { + const history = (0,react_router__WEBPACK_IMPORTED_MODULE_12__.useHistory)(); + const location = (0,_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_6__.useFixedLocation)(); + const modal = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const refresh = (0,_utils_hooks__WEBPACK_IMPORTED_MODULE_8__.useRefresh)(); + const { + project + } = (0,_providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_5__.useProject)(); + const [waiting, setWaitingStatus] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_4__.useAPI)(); + const { + uploading, + uploadDisabled, + finishUpload, + fileIds, + pageProps + } = (0,_useImportPage__WEBPACK_IMPORTED_MODULE_10__.useImportPage)(project); + const backToDM = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + const path = location.pathname.replace(ImportModal.path, ''); + const search = location.search; + const pathname = `${path}${search !== '?' ? search : ''}`; + return refresh(pathname); + }, [location, history]); + const onCancel = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + var _modal$current; + + setWaitingStatus(true); + await api.callApi('deleteFileUploads', { + params: { + pk: project.id + }, + body: { + file_upload_ids: fileIds + } + }); + setWaitingStatus(false); + modal === null || modal === void 0 ? void 0 : (_modal$current = modal.current) === null || _modal$current === void 0 ? void 0 : _modal$current.hide(); + backToDM(); + }, [modal, project, fileIds, backToDM]); + const onFinish = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + const imported = await finishUpload(); + if (!imported) return; + backToDM(); + }, [backToDM, finishUpload]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)(_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__.Modal, { + title: "Import data", + ref: modal, + onHide: () => backToDM(), + closeOnClickOutside: false, + fullscreen: true, + visible: true, + bare: true, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)(_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__.Modal.Header, { + divided: true, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_7__.Elem, { + block: "modal", + name: "title", + children: "\u5BFC\u5165\u6570\u636E" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_3__.Space, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + waiting: waiting, + onClick: onCancel, + children: "\u53D6\u6D88" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + look: "primary", + onClick: onFinish, + waiting: waiting || uploading, + disabled: uploadDisabled, + children: "\u5BFC\u5165" + })] + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_Import__WEBPACK_IMPORTED_MODULE_9__.ImportPage, { + project: project, + ...pageProps + })] + }); +}; +const ImportModal = () => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_5__.ProjectProvider, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(Inner, {}) + }); +}; +ImportModal.path = "/import"; +ImportModal.modal = true; + +/***/ }), + +/***/ "./src/pages/CreateProject/Import/useImportPage.js": +/*!*********************************************************!*\ + !*** ./src/pages/CreateProject/Import/useImportPage.js ***! + \*********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "useImportPage": () => (/* binding */ useImportPage) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../utils/helpers */ "./src/utils/helpers.js"); + + + +const DEFAULT_COLUMN = "$undefined$"; +const useImportPage = project => { + const [uploading, setUploadingStatus] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false); + const [fileIds, setFileIds] = react__WEBPACK_IMPORTED_MODULE_0__.useState([]); + const [_columns, _setColumns] = react__WEBPACK_IMPORTED_MODULE_0__.useState([]); + + const addColumns = cols => _setColumns(current => (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_2__.unique)(current.concat(cols))); // undefined - no csv added, all good, keep moving + // choose - csv added, block modal until user chooses a way to hangle csv + // tasks | ts — choice made, all good, this cannot be undone + + + const [csvHandling, setCsvHandling] = react__WEBPACK_IMPORTED_MODULE_0__.useState(); // undefined | choose | tasks | ts + + const uploadDisabled = csvHandling === "choose"; + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_1__.useAPI)(); // don't use columns from csv if we'll not use it as csv + + const columns = ["choose", "ts"].includes(csvHandling) ? [DEFAULT_COLUMN] : _columns; + + const finishUpload = async () => { + setUploadingStatus(true); + const imported = await api.callApi('reimportFiles', { + params: { + pk: project.id + }, + body: { + file_upload_ids: fileIds, + files_as_tasks_list: csvHandling === 'tasks' + } + }); + setUploadingStatus(false); + return imported; + }; + + const pageProps = { + onWaiting: setUploadingStatus, + // onDisableSubmit: onDisableSubmit, + highlightCsvHandling: uploadDisabled, + addColumns, + csvHandling, + setCsvHandling, + onFileListUpdate: setFileIds, + dontCommitToProject: true + }; + return { + columns, + uploading, + uploadDisabled, + finishUpload, + fileIds, + pageProps + }; +}; + +/***/ }), + +/***/ "./src/pages/CreateProject/utils/useDraftProject.js": +/*!**********************************************************!*\ + !*** ./src/pages/CreateProject/utils/useDraftProject.js ***! + \**********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "useDraftProject": () => (/* binding */ useDraftProject) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); + + +const useDraftProject = () => { + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_1__.useAPI)(); + const [project, setProject] = react__WEBPACK_IMPORTED_MODULE_0__.useState(); + const fetchDraftProject = react__WEBPACK_IMPORTED_MODULE_0__.useCallback(async () => { + const projects = await api.callApi('projects'); // always create the new one + + const lastIndex = (projects !== null && projects !== void 0 ? projects : []).length; + let projectNumber = lastIndex + 1; + let projectName = `新项目 #${projectNumber}`; // dirty hack to get proper non-duplicate name + + while (projects.find(({ + title + }) => title === projectName)) { + projectNumber++; + projectName = `新项目 #${projectNumber}`; + } + + const draft = await api.callApi('createProject', { + body: { + title: projectName + } + }); + if (draft) setProject(draft); + }, []); + react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { + fetchDraftProject(); + }, []); + return project; +}; + +/***/ }), + +/***/ "./src/pages/DataManager/DataManager.js": +/*!**********************************************!*\ + !*** ./src/pages/DataManager/DataManager.js ***! + \**********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DataManagerPage": () => (/* binding */ DataManagerPage) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! react-router */ "./node_modules/react-router/esm/react-router.js"); +/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/esm/react-router-dom.js"); +/* harmony import */ var _components_Button_Button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components/Button/Button */ "./src/components/Button/Button.js"); +/* harmony import */ var _components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../components/Modal/Modal */ "./src/components/Modal/Modal.js"); +/* harmony import */ var _components_Space_Space__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../components/Space/Space */ "./src/components/Space/Space.js"); +/* harmony import */ var _providers_LibraryProvider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../providers/LibraryProvider */ "./src/providers/LibraryProvider.js"); +/* harmony import */ var _providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../providers/ProjectProvider */ "./src/providers/ProjectProvider.tsx"); +/* harmony import */ var _providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../providers/RoutesProvider */ "./src/providers/RoutesProvider.js"); +/* harmony import */ var _services_breadrumbs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../services/breadrumbs */ "./src/services/breadrumbs.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _CreateProject_Import_ImportModal__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../CreateProject/Import/ImportModal */ "./src/pages/CreateProject/Import/ImportModal.js"); +/* harmony import */ var _ExportPage_ExportPage__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../ExportPage/ExportPage */ "./src/pages/ExportPage/ExportPage.js"); +/* harmony import */ var _api_config__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./api-config */ "./src/pages/DataManager/api-config.js"); +/* harmony import */ var _ExportToPlatform_ExportToPlatform__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../ExportToPlatform/ExportToPlatform */ "./src/pages/ExportToPlatform/ExportToPlatform.js"); +/* harmony import */ var _DataManager_styl__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./DataManager.styl */ "./src/pages/DataManager/DataManager.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + + + + + + + + + + +const initializeDataManager = async (root, props, params) => { + if (!window.LabelStudio) throw Error("Label Studio Frontend doesn't exist on the page"); + if (!root && root.dataset.dmInitialized) return; + root.dataset.dmInitialized = true; + const { ...settings + } = root.dataset; + const dmConfig = { + root, + projectId: params.id, + apiGateway: `${window.APP_SETTINGS.hostname}/api/dm`, + apiVersion: 2, + polling: !window.APP_SETTINGS, + showPreviews: false, + apiEndpoints: _api_config__WEBPACK_IMPORTED_MODULE_11__.APIConfig.endpoints, + interfaces: { + import: false, + export: false, + backButton: false, + labelingHeader: false + }, + ...props, + ...settings + }; + return new window.DataManager(dmConfig); +}; + +const buildLink = (path, params) => { + return (0,react_router__WEBPACK_IMPORTED_MODULE_15__.generatePath)(`/projects/:id${path}`, params); +}; + +const DataManagerPage = ({ ...props +}) => { + const root = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const params = (0,_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_6__.useParams)(); + const history = (0,react_router__WEBPACK_IMPORTED_MODULE_15__.useHistory)(); + const LabelStudio = (0,_providers_LibraryProvider__WEBPACK_IMPORTED_MODULE_4__.useLibrary)('lsf'); + const DataManager = (0,_providers_LibraryProvider__WEBPACK_IMPORTED_MODULE_4__.useLibrary)('dm'); + const setContextProps = (0,_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_6__.useContextProps)(); + const [crashed, setCrashed] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + const dataManagerRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const init = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + var _dataManagerRef$curre; + + if (!LabelStudio) return; + if (!DataManager) return; + if (!root.current) return; + if (dataManagerRef.current) return; + dataManagerRef.current = (_dataManagerRef$curre = dataManagerRef.current) !== null && _dataManagerRef$curre !== void 0 ? _dataManagerRef$curre : await initializeDataManager(root.current, props, params); + const { + current: dataManager + } = dataManagerRef; + dataManager.on("crash", () => setCrashed()); + dataManager.on("settingsClicked", () => { + history.push(buildLink("/settings/labeling", { + id: params.id + })); + }); + dataManager.on("importClicked", () => { + history.push(buildLink("/data/import", { + id: params.id + })); + }); + dataManager.on("exportClicked", () => { + history.push(buildLink("/data/export", { + id: params.id + })); + }); + setContextProps({ + dmRef: dataManager + }); + }, [LabelStudio, DataManager]); + const destroyDM = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + if (dataManagerRef.current) { + dataManagerRef.current.destroy(); + dataManagerRef.current = null; + } + }, [dataManagerRef]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + init(); + return () => destroyDM(); + }, [root, init]); + return crashed ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_8__.Block, { + name: "crash", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_8__.Elem, { + name: "info", + children: "\u9879\u76EE\u5DF2\u5220\u9664\u6216\u5C1A\u672A\u521B\u5EFA" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_components_Button_Button__WEBPACK_IMPORTED_MODULE_1__.Button, { + to: "/projects", + children: "\u8FD4\u56DE\u9879\u76EE\u5217\u8868" + })] + }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_8__.Block, { + ref: root, + name: "datamanager" + }); +}; +DataManagerPage.path = "/data"; +DataManagerPage.pages = { + ExportPage: _ExportPage_ExportPage__WEBPACK_IMPORTED_MODULE_10__.ExportPage, + ImportModal: _CreateProject_Import_ImportModal__WEBPACK_IMPORTED_MODULE_9__.ImportModal, + ExportToPlatform: _ExportToPlatform_ExportToPlatform__WEBPACK_IMPORTED_MODULE_12__.ExportToPlatform +}; + +DataManagerPage.context = ({ + dmRef +}) => { + var _dmRef$mode; + + const location = (0,_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_6__.useFixedLocation)(); + const { + project + } = (0,_providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_5__.useProject)(); + const [mode, setMode] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)((_dmRef$mode = dmRef === null || dmRef === void 0 ? void 0 : dmRef.mode) !== null && _dmRef$mode !== void 0 ? _dmRef$mode : "explorer"); + const links = { + '/settings': '设置', + '/data/import': "导入", + '/data/export': '导出' + }; + + const updateCrumbs = currentMode => { + const isExplorer = currentMode === 'explorer'; + const dmPath = location.pathname.replace(DataManagerPage.path, ''); + + if (isExplorer) { + (0,_services_breadrumbs__WEBPACK_IMPORTED_MODULE_7__.deleteAction)(dmPath); + (0,_services_breadrumbs__WEBPACK_IMPORTED_MODULE_7__.deleteCrumb)('dm-crumb'); + } else { + (0,_services_breadrumbs__WEBPACK_IMPORTED_MODULE_7__.addAction)(dmPath, e => { + var _dmRef$store, _dmRef$store$closeLab; + + e.preventDefault(); + e.stopPropagation(); + dmRef === null || dmRef === void 0 ? void 0 : (_dmRef$store = dmRef.store) === null || _dmRef$store === void 0 ? void 0 : (_dmRef$store$closeLab = _dmRef$store.closeLabeling) === null || _dmRef$store$closeLab === void 0 ? void 0 : _dmRef$store$closeLab.call(_dmRef$store); + }); + (0,_services_breadrumbs__WEBPACK_IMPORTED_MODULE_7__.addCrumb)({ + key: "dm-crumb", + title: "标注" + }); + } + }; + + const showLabelingInstruction = currentMode => { + const isLabelStream = currentMode === 'labelstream'; + const { + expert_instruction, + show_instruction + } = project; + + if (isLabelStream && show_instruction && expert_instruction) { + (0,_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__.modal)({ + title: "标注指引", + body: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)("div", { + dangerouslySetInnerHTML: { + __html: expert_instruction + } + }), + style: { + width: 680 + } + }); + } + }; + + const onDMModeChanged = currentMode => { + setMode(currentMode); + updateCrumbs(currentMode); + showLabelingInstruction(currentMode); + }; + + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (dmRef) { + dmRef.on('modeChanged', onDMModeChanged); + } + + return () => { + var _dmRef$off; + + dmRef === null || dmRef === void 0 ? void 0 : (_dmRef$off = dmRef.off) === null || _dmRef$off === void 0 ? void 0 : _dmRef$off.call(dmRef, 'modeChanged', onDMModeChanged); + }; + }, [dmRef, project]); + return project && project.id ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsxs)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_3__.Space, { + size: "small", + children: [project.expert_instruction && mode !== 'explorer' && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_components_Button_Button__WEBPACK_IMPORTED_MODULE_1__.Button, { + size: "compact", + onClick: () => { + (0,_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__.modal)({ + title: "指引", + body: () => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)("div", { + dangerouslySetInnerHTML: { + __html: project.expert_instruction + } + }) + }); + }, + children: "\u6307\u5F15" + }), Object.entries(links).map(([path, label]) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_14__.jsx)(_components_Button_Button__WEBPACK_IMPORTED_MODULE_1__.Button, { + tag: react_router_dom__WEBPACK_IMPORTED_MODULE_16__.NavLink, + size: "compact", + to: `/projects/${project.id}${path}`, + "data-external": true, + children: label + }, path))] + }) : null; +}; + +/***/ }), + +/***/ "./src/pages/DataManager/api-config.js": +/*!*********************************************!*\ + !*** ./src/pages/DataManager/api-config.js ***! + \*********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "APIConfig": () => (/* binding */ APIConfig) +/* harmony export */ }); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utils/helpers */ "./src/utils/helpers.js"); + +/** @type {import("../utils/api-proxy").APIProxyOptions} */ + +const APIConfig = { + gateway: "/api/dm", + endpoints: { + /** Project base info */ + project: "/project", + + /** Available columns/fields of the dataset */ + columns: "/columns", + + /** Tabs (materialized views) */ + tabs: "/views", + + /** Creates a new tab */ + createTab: "POST:/views", + + /** Update particular tab (PATCH) */ + updateTab: "PATCH:/views/:tabID", + + /** Delete particular tab (DELETE) */ + deleteTab: "DELETE:/views/:tabID", + + /** Per-task annotations (annotations, predictions) */ + annotations: "/views/:tabID/annotations", + + /** Single task (sample) */ + task: "/tasks/:taskID", + + /** List of tasks (samples) in the dataset */ + tasks: "/views/:tabID/tasks", + + /** Next task (labelstream, default sequential) */ + nextTask: "/tasks/next", + + /** Single annotation */ + annotation: "/../annotations/:id", + + /** Mark sample as skipped */ + skipTask: { + method: "post", + path: params => { + const pathBase = "/../tasks/:taskID/annotations"; + const isNewAnnotation = !(0,_utils_helpers__WEBPACK_IMPORTED_MODULE_0__.isDefined)(params.annotationID); + return isNewAnnotation ? pathBase : `${pathBase}/:annotationID`; + } + }, + + /** Submit annotation */ + submitAnnotation: "POST:/../tasks/:taskID/annotations", + + /** Update annotation */ + updateAnnotation: "PATCH:/../annotations/:annotationID", + + /** Delete annotation */ + deleteAnnotation: "DELETE:/../annotations/:annotationID", + + /** Override selected items list (checkboxes) */ + setSelectedItems: "POST:/views/:tabID/selected-items", + + /** Add item to the current selection */ + addSelectedItem: "PATCH:/views/:tabID/selected-items", + + /** List of available actions */ + actions: "/actions", + + /** Subtract item from the current selection */ + deleteSelectedItem: "DELETE:/views/:tabID/selected-items", + + /** Invoke a particular action */ + invokeAction: "POST:/actions" + } +}; + +/***/ }), + +/***/ "./src/pages/ExportPage/ExportPage.js": +/*!********************************************!*\ + !*** ./src/pages/ExportPage/ExportPage.js ***! + \********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ExportPage": () => (/* binding */ ExportPage) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! react-router */ "./node_modules/react-router/esm/react-router.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components */ "./src/components/index.js"); +/* harmony import */ var _components_Form__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../components/Form */ "./src/components/Form/index.js"); +/* harmony import */ var _components_Modal_Modal__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../components/Modal/Modal */ "./src/components/Modal/Modal.js"); +/* harmony import */ var _components_Space_Space__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../components/Space/Space */ "./src/components/Space/Space.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../providers/RoutesProvider */ "./src/providers/RoutesProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var _ExportPage_styl__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ExportPage.styl */ "./src/pages/ExportPage/ExportPage.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + + // const formats = { +// json: 'JSON', +// csv: 'CSV', +// }; + + + + +const buildLink = (path, params, type) => { + return (0,react_router__WEBPACK_IMPORTED_MODULE_11__.generatePath)(`/projects/:id${path}?type=${type}`, params); +}; + +const downloadFile = (blob, filename) => { + const link = document.createElement('a'); + link.href = URL.createObjectURL(blob); + link.download = filename; + link.click(); +}; + +const { + Block, + Elem +} = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_7__.BemWithSpecifiContext)(); + +const wait = () => new Promise(resolve => setTimeout(resolve, 5000)); + +const ExportPage = () => { + const history = (0,react_router__WEBPACK_IMPORTED_MODULE_11__.useHistory)(); + const location = (0,_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_6__.useFixedLocation)(); + const pageParams = (0,_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_6__.useParams)(); + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_5__.useAPI)(); + const [previousExports, setPreviousExports] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]); + const [downloading, setDownloading] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + const [downloadingMessage, setDownloadingMessage] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + const [availableFormats, setAvailableFormats] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]); + const [currentFormat, setCurrentFormat] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)('JSON'); + + const proceedExportToPlatform = async () => { + history.push(buildLink("/data/exportToPlatform", { + id: pageParams.id + }, currentFormat)); + }; + /** @type {import('react').RefObject
} */ + + + const form = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + + const proceedExport = async () => { + setDownloading(true); + const message = setTimeout(() => { + setDownloadingMessage(true); + }, 1000); + const params = form.current.assembleFormData({ + asJSON: true, + full: true, + booleansAsNumbers: true + }); + const response = await api.callApi('exportRaw', { + params: { + pk: pageParams.id, + ...params + } + }); + + if (response.ok) { + const blob = await response.blob(); + downloadFile(blob, response.headers.get('filename')); + } else { + api.handleError(response); + } + + setDownloading(false); + setDownloadingMessage(false); + clearTimeout(message); + }; + + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if ((0,_utils_helpers__WEBPACK_IMPORTED_MODULE_8__.isDefined)(pageParams.id)) { + api.callApi("previousExports", { + params: { + pk: pageParams.id + } + }).then(({ + export_files + }) => { + setPreviousExports(export_files.slice(0, 1)); + }); + api.callApi("exportFormats", { + params: { + pk: pageParams.id + } + }).then(formats => { + var _formats$; + + setAvailableFormats(formats); + setCurrentFormat((_formats$ = formats[0]) === null || _formats$ === void 0 ? void 0 : _formats$.name); + }); + } + }, [pageParams]); // const formatSelect = ( + // + // ); + // const aggregation = ( + // + // {/* TODO: We don't have api for different formats yet, so let's hide the select for now */} + // {/* {formatSelect} */} + // + // + // Majority vote + // + // + // No aggregation + // + // + // + // ); + // const exportHistory = ( + // + // ); + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_3__.Modal, { + onHide: () => { + const path = location.pathname.replace(ExportPage.path, ''); + const search = location.search; + history.replace(`${path}${search !== '?' ? search : ''}`); + }, + title: "\u5BFC\u51FA\u6570\u636E", + style: { + width: 720 + }, + closeOnClickOutside: false, + allowClose: !downloading // footer="在文档中了解支持的导出格式" + , + visible: true, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsxs)(Block, { + name: "export-page", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(FormatInfo, { + availableFormats: availableFormats, + selected: currentFormat, + onClick: format => setCurrentFormat(format.name) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Form, { + ref: form, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Input, { + type: "hidden", + name: "exportType", + value: currentFormat + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(Elem, { + name: "footer", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsxs)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_4__.Space, { + style: { + width: '100%' + }, + spread: true, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(Elem, { + name: "recent", + children: downloadingMessage && "正在导出..." + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsxs)(Elem, { + name: "actions", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_4__.Space, { + style: { + marginRight: '10px' + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(Elem, { + tag: _components__WEBPACK_IMPORTED_MODULE_1__.Button, + name: "finish", + onClick: proceedExportToPlatform, + children: "\u5BFC\u51FA\u5230\u5E73\u53F0" + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_4__.Space, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(Elem, { + tag: _components__WEBPACK_IMPORTED_MODULE_1__.Button, + name: "finish", + look: "primary", + onClick: proceedExport, + waiting: downloading, + children: "\u5BFC\u51FA" + }) + })] + })] + }) + })] + }) + }); +}; + +const FormatInfo = ({ + availableFormats, + selected, + onClick +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsxs)(Block, { + name: "formats", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(Elem, { + name: "info", + children: "\u4F60\u53EF\u4EE5\u5C06\u6570\u636E\u96C6\u5BFC\u51FA\u4E3A\u4EE5\u4E0B\u683C\u5F0F" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(Elem, { + name: "list", + children: availableFormats.map(format => { + var _format$tags, _format$tags$map; + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsxs)(Elem, { + name: "item", + mod: { + active: !format.disabled, + selected: format.name === selected + }, + onClick: !format.disabled ? () => onClick(format) : null, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsxs)(Elem, { + name: "name", + children: [format.title, /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_4__.Space, { + size: "small", + children: (_format$tags = format.tags) === null || _format$tags === void 0 ? void 0 : (_format$tags$map = _format$tags.map) === null || _format$tags$map === void 0 ? void 0 : _format$tags$map.call(_format$tags, (tag, index) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(Elem, { + name: "tag", + children: tag + }, index)) + })] + }), format.description && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(Elem, { + name: "description", + children: format.description + })] + }, format.name); + }) + })] + }); +}; + +ExportPage.path = "/export"; +ExportPage.modal = true; + +/***/ }), + +/***/ "./src/pages/ExportToPlatform/ExportToPlatform.js": +/*!********************************************************!*\ + !*** ./src/pages/ExportToPlatform/ExportToPlatform.js ***! + \********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ExportToPlatform": () => (/* binding */ ExportToPlatform) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! react-router */ "./node_modules/react-router/esm/react-router.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components */ "./src/components/index.js"); +/* harmony import */ var _components_Form__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../components/Form */ "./src/components/Form/index.js"); +/* harmony import */ var _components_Modal_Modal__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../components/Modal/Modal */ "./src/components/Modal/Modal.js"); +/* harmony import */ var _components_Space_Space__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../components/Space/Space */ "./src/components/Space/Space.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../providers/RoutesProvider */ "./src/providers/RoutesProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _ExportToPlatform_styl__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ExportToPlatform.styl */ "./src/pages/ExportToPlatform/ExportToPlatform.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + + + +const { + Block, + Elem +} = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_7__.BemWithSpecifiContext)(); +const DownloadStatus = Object.freeze({ + normal: 0, + success: 1, + error: 2 +}); + +const getColor = status => { + if (status === DownloadStatus.normal) { + return "#1d1d20"; + } else if (status === DownloadStatus.success) { + return "#1ace62"; + } else { + return "#c73131"; + } +}; + +const ExportToPlatform = () => { + const history = (0,react_router__WEBPACK_IMPORTED_MODULE_10__.useHistory)(); + const location = (0,_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_6__.useFixedLocation)(); + const pageParams = (0,_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_6__.useParams)(); + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_5__.useAPI)(); + const [downloading, setDownloading] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + const [downloadingMessage, setDownloadingMessage] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(""); + const [downloadStatus, setDownloadStatus] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(DownloadStatus.normal); + const [dataset, setDataset] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]); + /** @type {import('react').RefObject} */ + + const form = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + getUserToken(); + }, []); + + async function customRequest(method, path, params) { + const baseURL = window.APP_SETTINGS.hostname; + let url = `${baseURL}${path}`; + + if (method === "GET") { + const queryString = new URLSearchParams(params).toString(); + url = `${baseURL}${path}?${queryString}`; + } + + const data = method === "POST" ? params : undefined; + const accessToken = sessionStorage.getItem("bearerAccessToken"); + + try { + const response = await fetch(url, { + method: method, + headers: { + 'Content-Type': 'application/json', + "Authorization": `Bearer ${accessToken}` + }, + body: data ? JSON.stringify(data) : undefined + }); + + if (response.ok) { + const json = await response.json(); + + if (json && json.code === 200) { + return json.data; + } else { + var _json$msg; + + return Promise.reject(new Error((_json$msg = json === null || json === void 0 ? void 0 : json.msg) !== null && _json$msg !== void 0 ? _json$msg : "请求失败")); + } + } else { + return Promise.reject(new Error("请求失败")); + } + } catch (error) { + console.error('Error:', error); + return Promise.reject(error); + } + } + + const getUserToken = async () => { + try { + const res = await customRequest("POST", "/forward/getToken/", { + username: "admin", + key: "h1n2x3j4y5@" + }); + + if (res && res.access_token) { + sessionStorage.setItem("bearerAccessToken", res.access_token); + getDatasetList(); + } + } catch (error) { + console.log(error); + } + }; + + const getDatasetList = async () => { + try { + const res = await customRequest("GET", "/forward/getDateset/", { + page: 0, + size: 1000, + available_range: 0 + }); + + if (res && res.content) { + const content = res.content.map(v => ({ + label: v.name, + value: v.id + })); + setDataset(content); + } + } catch (error) { + console.log(error); + } + }; + + const proceedExport = async () => { + const params = form.current.assembleFormData({ + asJSON: true, + full: true, + booleansAsNumbers: true + }); + + if (!params.dataset_id) { + setDownloadStatus(DownloadStatus.error); + setDownloadingMessage("请选择数据集"); + return; + } + + if (!params.version) { + setDownloadStatus(DownloadStatus.error); + setDownloadingMessage("请输入数据集版本"); + return; + } + + setDownloading(true); + setDownloadStatus(DownloadStatus.normal); + setDownloadingMessage("正在导出..."); + + try { + const response = await api.callApi('token'); + const urlParams = new URLSearchParams(window.location.search); + const currentFormat = urlParams.get('type'); + + if (response && response.token) { + await customRequest("POST", "/forward/exportDateset/", { + token: response.token, + project_id: Number(pageParams.id), + export_type: currentFormat, + ...params + }); + setDownloadStatus(DownloadStatus.success); + setDownloadingMessage("导出成功"); + setTimeout(() => { + successToBack(); + }, 2000); + } else { + setDownloadStatus(DownloadStatus.error); + setDownloadingMessage("获取token失败"); + } + + setDownloading(false); + } catch (error) { + setDownloading(false); + setDownloadStatus(DownloadStatus.error); + setDownloadingMessage("导出失败"); + } + }; + + const handleClose = () => { + const path = location.pathname.replace(ExportToPlatform.path, '/export'); + history.replace(`${path}`); + }; + + const successToBack = () => { + const path = location.pathname.replace(ExportToPlatform.path, ''); + history.replace(`${path}`); + }; + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_3__.Modal, { + onHide: handleClose, + title: "\u5BFC\u51FA\u6570\u636E\u5230\u5E73\u53F0", + style: { + width: 720 + }, + closeOnClickOutside: false, + allowClose: !downloading // footer="Read more about supported export formats in the Documentation." + , + visible: true, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsxs)(Block, { + name: "export-to-platform", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsxs)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Form, { + ref: form, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Select, { + label: "\u9009\u62E9\u6570\u636E\u96C6", + name: "dataset_id", + defaultValue: null, + options: dataset, + placeholder: "\u8BF7\u9009\u62E9\u6570\u636E\u96C6", + className: "dataset-select" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Input, { + type: "text", + label: "\u6570\u636E\u96C6\u7248\u672C", + name: "version", + placeholder: "\u8BF7\u8F93\u5165\u6570\u636E\u96C6\u7248\u672C", + style: { + marginBottom: "20px" + } + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.TextArea, { + type: "text", + label: "\u7248\u672C\u63CF\u8FF0", + placeholder: "\u8BF7\u8F93\u5165\u7248\u672C\u63CF\u8FF0", + name: "desc" + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(Elem, { + name: "footer", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsxs)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_4__.Space, { + style: { + width: '100%' + }, + spread: true, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(Elem, { + name: "recent", + style: { + color: getColor(downloadStatus) + }, + children: downloadingMessage + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsxs)(Elem, { + name: "actions", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_4__.Space, { + style: { + marginRight: '10px' + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(Elem, { + tag: _components__WEBPACK_IMPORTED_MODULE_1__.Button, + name: "finish", + onClick: handleClose, + waiting: downloading, + children: "\u53D6\u6D88" + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_4__.Space, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(Elem, { + tag: _components__WEBPACK_IMPORTED_MODULE_1__.Button, + name: "finish", + look: "primary", + onClick: proceedExport, + waiting: downloading, + children: "\u786E\u5B9A" + }) + })] + })] + }) + })] + }) + }); +}; +ExportToPlatform.path = "/exportToPlatform"; +ExportToPlatform.modal = true; + +/***/ }), + +/***/ "./src/pages/PeoplePage/PeopleList.js": +/*!********************************************!*\ + !*** ./src/pages/PeoplePage/PeopleList.js ***! + \********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "PeopleList": () => (/* binding */ PeopleList) +/* harmony export */ }); +/* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/formatDistance/index.js"); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components */ "./src/components/index.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var _PeopleList_styl__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./PeopleList.styl */ "./src/pages/PeoplePage/PeopleList.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + +const PeopleList = ({ + onSelect, + selectedUser, + defaultSelected +}) => { + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_2__.useAPI)(); + const [usersList, setUsersList] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(); + const fetchUsers = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + const result = await api.callApi('memberships', { + params: { + pk: 1 + } + }); + setUsersList(result); + }, [api]); + const selectUser = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(user => { + if ((selectedUser === null || selectedUser === void 0 ? void 0 : selectedUser.id) === user.id) { + onSelect === null || onSelect === void 0 ? void 0 : onSelect(null); + } else { + onSelect === null || onSelect === void 0 ? void 0 : onSelect(user); + } + }, [selectedUser]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + fetchUsers(); + }, []); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if ((0,_utils_helpers__WEBPACK_IMPORTED_MODULE_4__.isDefined)(defaultSelected) && usersList) { + const selected = usersList.find(({ + user + }) => user.id === Number(defaultSelected)); + if (selected) selectUser(selected.user); + } + }, [usersList, defaultSelected]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_3__.Block, { + name: "people-list", + children: usersList ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_3__.Elem, { + name: "users", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_3__.Elem, { + name: "header", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_3__.Elem, { + name: "column", + mix: "avatar" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_3__.Elem, { + name: "column", + mix: "email", + children: "\u90AE\u7BB1" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_3__.Elem, { + name: "column", + mix: "name", + children: "\u59D3\u540D" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_3__.Elem, { + name: "column", + mix: "last-activity", + children: "\u6700\u8FD1\u6D3B\u52A8" + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_3__.Elem, { + name: "body", + children: usersList.map(({ + user + }) => { + const active = user.id === (selectedUser === null || selectedUser === void 0 ? void 0 : selectedUser.id); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_3__.Elem, { + name: "user", + mod: { + active + }, + onClick: () => selectUser(user), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_3__.Elem, { + name: "field", + mix: "avatar", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Userpic, { + user: user, + style: { + width: 28, + height: 28 + } + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_3__.Elem, { + name: "field", + mix: "email", + children: user.email + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_3__.Elem, { + name: "field", + mix: "name", + children: [user.first_name, " ", user.last_name] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_3__.Elem, { + name: "field", + mix: "last-activity", + children: (0,date_fns__WEBPACK_IMPORTED_MODULE_7__.default)(new Date(user.last_activity), new Date(), { + addSuffix: true + }) + })] + }, `user-${user.id}`); + }) + })] + }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_3__.Elem, { + name: "loading", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Spinner, { + size: 36 + }) + }) + }); +}; + +/***/ }), + +/***/ "./src/pages/PeoplePage/PeoplePage.js": +/*!********************************************!*\ + !*** ./src/pages/PeoplePage/PeoplePage.js ***! + \********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "PeoplePage": () => (/* binding */ PeoplePage) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _assets_icons__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../assets/icons */ "./src/assets/icons/index.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../components */ "./src/components/index.js"); +/* harmony import */ var _components_Description_Description__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../components/Description/Description */ "./src/components/Description/Description.js"); +/* harmony import */ var _components_Form__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../components/Form */ "./src/components/Form/index.js"); +/* harmony import */ var _components_Modal_Modal__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../components/Modal/Modal */ "./src/components/Modal/Modal.js"); +/* harmony import */ var _components_Space_Space__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../components/Space/Space */ "./src/components/Space/Space.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _providers_ConfigProvider__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../providers/ConfigProvider */ "./src/providers/ConfigProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var _PeopleInvitation_styl__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./PeopleInvitation.styl */ "./src/pages/PeoplePage/PeopleInvitation.styl"); +/* harmony import */ var _PeopleList__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./PeopleList */ "./src/pages/PeoplePage/PeopleList.js"); +/* harmony import */ var _PeoplePage_styl__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./PeoplePage.styl */ "./src/pages/PeoplePage/PeoplePage.styl"); +/* harmony import */ var _SelectedUser__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./SelectedUser */ "./src/pages/PeoplePage/SelectedUser.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + + + + + + + + + +const InvitationModal = ({ + link +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_9__.Block, { + name: "invite", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_4__.Input, { + value: link, + style: { + width: '100%' + }, + readOnly: true + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)(_components_Description_Description__WEBPACK_IMPORTED_MODULE_3__.Description, { + style: { + width: '70%', + marginTop: 16 + }, + children: ["\u9080\u8BF7\u60A8\u7684\u540C\u4E8B\u52A0\u5165Label Studio\u5B9E\u4F8B\uFF0C\u88AB\u9080\u8BF7\u7684\u4EBA\u5C06\u62E5\u6709\u5BF9\u60A8\u6240\u6709\u9879\u76EE\u7684\u5B8C\u5168\u8BBF\u95EE\u6743\u9650\u3002", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)("a", { + href: "https://labelstud.io/guide/signup.html", + children: "\u4E86\u89E3\u66F4\u591A" + }), "\u3002"] + })] + }); +}; + +const PeoplePage = () => { + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_7__.useAPI)(); + const inviteModal = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const config = (0,_providers_ConfigProvider__WEBPACK_IMPORTED_MODULE_8__.useConfig)(); + const [selectedUser, setSelectedUser] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + const [link, setLink] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(); + const selectUser = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(user => { + setSelectedUser(user); + localStorage.setItem('selectedUser', user === null || user === void 0 ? void 0 : user.id); + }, [setSelectedUser]); + const setInviteLink = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(link => { + const hostname = config.hostname || location.origin; + setLink(`${hostname}${link}`); + }, [config, setLink]); + const updateLink = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + api.callApi('resetInviteLink').then(({ + invite_url + }) => { + setInviteLink(invite_url); + }); + }, [setInviteLink]); + const inviteModalProps = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(link => ({ + title: "Invite people", + style: { + width: 640, + height: 472 + }, + body: () => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(InvitationModal, { + link: link + }), + footer: () => { + const [copied, setCopied] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + const copyLink = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + setCopied(true); + (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_10__.copyText)(link); + setTimeout(() => setCopied(false), 1500); + }, []); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_6__.Space, { + spread: true, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_6__.Space, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_components__WEBPACK_IMPORTED_MODULE_2__.Button, { + style: { + width: 170 + }, + onClick: () => updateLink(), + children: "\u91CD\u7F6E\u94FE\u63A5" + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_6__.Space, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_components__WEBPACK_IMPORTED_MODULE_2__.Button, { + primary: true, + style: { + width: 170 + }, + onClick: copyLink, + children: copied ? "Copied!" : "Copy link" + }) + })] + }); + }, + bareFooter: true + }), []); + const showInvitationModal = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + inviteModal.current = (0,_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_5__.modal)(inviteModalProps(link)); + }, [inviteModalProps, link]); + const defaultSelected = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + return localStorage.getItem('selectedUser'); + }, []); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + api.callApi("inviteLink").then(({ + invite_url + }) => { + setInviteLink(invite_url); + }); + }, []); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + var _inviteModal$current; + + (_inviteModal$current = inviteModal.current) === null || _inviteModal$current === void 0 ? void 0 : _inviteModal$current.update(inviteModalProps(link)); + }, [link]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_9__.Block, { + name: "people", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_9__.Elem, { + name: "controls", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_6__.Space, { + spread: true, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_6__.Space, {}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_6__.Space, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_components__WEBPACK_IMPORTED_MODULE_2__.Button, { + icon: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_assets_icons__WEBPACK_IMPORTED_MODULE_1__.LsPlus, {}), + primary: true, + onClick: showInvitationModal, + children: "\u6DFB\u52A0\u4EBA\u5458" + }) + })] + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_9__.Elem, { + name: "content", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_PeopleList__WEBPACK_IMPORTED_MODULE_12__.PeopleList, { + selectedUser: selectedUser, + defaultSelected: defaultSelected, + onSelect: user => selectUser(user) + }), selectedUser && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_15__.jsx)(_SelectedUser__WEBPACK_IMPORTED_MODULE_14__.SelectedUser, { + user: selectedUser, + onClose: () => selectUser(null) + })] + })] + }); +}; +PeoplePage.title = "People"; +PeoplePage.path = "/people"; + +/***/ }), + +/***/ "./src/pages/PeoplePage/SelectedUser.js": +/*!**********************************************!*\ + !*** ./src/pages/PeoplePage/SelectedUser.js ***! + \**********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SelectedUser": () => (/* binding */ SelectedUser) +/* harmony export */ }); +/* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/format/index.js"); +/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/esm/react-router-dom.js"); +/* harmony import */ var _assets_icons__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../assets/icons */ "./src/assets/icons/index.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components */ "./src/components/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _SelectedUser_styl__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./SelectedUser.styl */ "./src/pages/PeoplePage/SelectedUser.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + +const UserProjectsLinks = ({ + projects +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "links-list", + children: projects.map(project => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + tag: react_router_dom__WEBPACK_IMPORTED_MODULE_5__.NavLink, + name: "project-link", + to: `/projects/${project.id}`, + "data-external": true, + children: project.title + }, `project-${project.id}`)) + }); +}; + +const SelectedUser = ({ + user, + onClose +}) => { + const fullName = [user.first_name, user.last_name].filter(n => !!n).join(" ").trim(); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Block, { + name: "user-info", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "close", + tag: _components__WEBPACK_IMPORTED_MODULE_1__.Button, + type: "link", + onClick: onClose, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_assets_icons__WEBPACK_IMPORTED_MODULE_0__.LsCross, {}) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "header", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Userpic, { + user: user, + style: { + width: 64, + height: 64, + fontSize: 28 + } + }), fullName && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "full-name", + children: fullName + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + tag: "p", + name: "email", + children: user.email + })] + }), user.phone && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "section", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)("a", { + href: `tel:${user.phone}`, + children: user.phone + }) + }), !!user.created_projects.length && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "section", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "section-title", + children: "\u521B\u5EFA\u7684\u9879\u76EE" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(UserProjectsLinks, { + projects: user.created_projects + })] + }), !!user.contributed_to_projects.length && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "section", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + name: "section-title", + children: "\u53C2\u4E0E\u9879\u76EE" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(UserProjectsLinks, { + projects: user.contributed_to_projects + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_2__.Elem, { + tag: "p", + name: "last-active", + children: ["\u4E0A\u6B21\u6D3B\u52A8\u4E8E\uFF1A", (0,date_fns__WEBPACK_IMPORTED_MODULE_6__.default)(new Date(user.last_activity), 'yyyy-MM-dd HH:mm:ss')] + })] + }); +}; + +/***/ }), + +/***/ "./src/pages/Projects/Projects.js": +/*!****************************************!*\ + !*** ./src/pages/Projects/Projects.js ***! + \****************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ProjectsPage": () => (/* binding */ ProjectsPage) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router/esm/react-router.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components */ "./src/components/index.js"); +/* harmony import */ var _components_Oneof_Oneof__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../components/Oneof/Oneof */ "./src/components/Oneof/Oneof.js"); +/* harmony import */ var _components_Spinner_Spinner__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../components/Spinner/Spinner */ "./src/components/Spinner/Spinner.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../providers/RoutesProvider */ "./src/providers/RoutesProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _CreateProject_CreateProject__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../CreateProject/CreateProject */ "./src/pages/CreateProject/CreateProject.js"); +/* harmony import */ var _DataManager_DataManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../DataManager/DataManager */ "./src/pages/DataManager/DataManager.js"); +/* harmony import */ var _Settings__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Settings */ "./src/pages/Settings/index.js"); +/* harmony import */ var _Projects_styl__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Projects.styl */ "./src/pages/Projects/Projects.styl"); +/* harmony import */ var _ProjectsList__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ProjectsList */ "./src/pages/Projects/ProjectsList.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + + + + + + + +const ProjectsPage = () => { + const api = react__WEBPACK_IMPORTED_MODULE_0__.useContext(_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_4__.ApiContext); + const [projectsList, setProjectsList] = react__WEBPACK_IMPORTED_MODULE_0__.useState([]); + const [networkState, setNetworkState] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null); + const setContextProps = (0,_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_5__.useContextProps)(); + const [modal, setModal] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false); + const openModal = setModal.bind(null, true); + const closeModal = setModal.bind(null, false); + + const fetchProjects = async () => { + setNetworkState('loading'); + const projects = await api.callApi("projects"); + setProjectsList(projects !== null && projects !== void 0 ? projects : []); + setNetworkState('loaded'); + }; + + react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { + fetchProjects(); + }, []); + react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { + // there is a nice page with Create button when list is empty + // so don't show the context button in that case + setContextProps({ + openModal, + showButton: projectsList.length > 0 + }); + }, [projectsList.length]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_6__.Block, { + name: "projects-page", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)(_components_Oneof_Oneof__WEBPACK_IMPORTED_MODULE_2__.Oneof, { + value: networkState, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_6__.Elem, { + name: "loading", + case: "loading", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Spinner_Spinner__WEBPACK_IMPORTED_MODULE_3__.Spinner, { + size: 64 + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_6__.Elem, { + name: "content", + case: "loaded", + children: [projectsList.length ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_ProjectsList__WEBPACK_IMPORTED_MODULE_11__.ProjectsList, { + projects: projectsList + }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_ProjectsList__WEBPACK_IMPORTED_MODULE_11__.EmptyProjectsList, { + openModal: openModal + }), modal && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_CreateProject_CreateProject__WEBPACK_IMPORTED_MODULE_7__.CreateProject, { + onClose: closeModal + })] + })] + }) + }); +}; +ProjectsPage.title = "项目"; +ProjectsPage.path = "/projects"; +ProjectsPage.exact = true; + +ProjectsPage.routes = ({ + store +}) => [{ + title: () => { + var _store$project; + + return (_store$project = store.project) === null || _store$project === void 0 ? void 0 : _store$project.title; + }, + path: "/:id(\\d+)", + exact: true, + component: () => { + const params = (0,react_router__WEBPACK_IMPORTED_MODULE_13__.useParams)(); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(react_router__WEBPACK_IMPORTED_MODULE_13__.Redirect, { + to: `/projects/${params.id}/data` + }); + }, + pages: { + DataManagerPage: _DataManager_DataManager__WEBPACK_IMPORTED_MODULE_8__.DataManagerPage, + SettingsPage: _Settings__WEBPACK_IMPORTED_MODULE_9__.SettingsPage + } +}]; + +ProjectsPage.context = ({ + openModal, + showButton +}) => { + if (!showButton) return null; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + onClick: openModal, + look: "primary", + size: "compact", + children: "\u521B\u5EFA" + }); +}; + +/***/ }), + +/***/ "./src/pages/Projects/ProjectsList.js": +/*!********************************************!*\ + !*** ./src/pages/Projects/ProjectsList.js ***! + \********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ProjectsList": () => (/* binding */ ProjectsList), +/* harmony export */ "EmptyProjectsList": () => (/* binding */ EmptyProjectsList) +/* harmony export */ }); +/* harmony import */ var chroma_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! chroma-js */ "./node_modules/chroma-js/chroma.js"); +/* harmony import */ var chroma_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(chroma_js__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/format/index.js"); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react-router */ "./node_modules/react-router/esm/react-router.js"); +/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/esm/react-router-dom.js"); +/* harmony import */ var _assets_icons__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../assets/icons */ "./src/assets/icons/index.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../components */ "./src/components/index.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + + +const ProjectsList = ({ + projects +}) => { + const history = (0,react_router__WEBPACK_IMPORTED_MODULE_7__.useHistory)(); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "list", + children: projects.map(project => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(ProjectCard, { + project: project, + history: history + }, project.id)) + }); +}; +const EmptyProjectsList = ({ + openModal +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Block, { + name: "empty-projects-page", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "heidi", + tag: "img", + src: (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_5__.absoluteURL)("/static/images/opossum_looking.png") + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "header", + tag: "h1", + children: "Heidi \u5728\u8FD9\u91CC\u6CA1\u6709\u770B\u5230\u4EFB\u4F55\u9879\u76EE" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("p", { + children: "\u521B\u5EFA\u4E00\u4E2A\u9879\u76EE\u5E76\u5F00\u59CB\u6807\u8BB0\u6570\u636E" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "action", + tag: _components__WEBPACK_IMPORTED_MODULE_3__.Button, + onClick: openModal, + look: "primary", + children: "\u521B\u5EFA\u9879\u76EE" + })] + }); +}; + +const ProjectCard = ({ + project, + history +}) => { + var _project$title; + + const color = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(() => { + return project.color === '#FFFFFF' ? null : project.color; + }, [project]); + const projectColors = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(() => { + return color ? { + '--header-color': color, + '--background-color': chroma_js__WEBPACK_IMPORTED_MODULE_0___default()(color).alpha(0.2).css() + } : {}; + }, [color]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + tag: react_router_dom__WEBPACK_IMPORTED_MODULE_8__.NavLink, + name: "link", + to: `/projects/${project.id}/data`, + "data-external": true, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Block, { + name: "project-card", + mod: { + colored: !!color + }, + style: projectColors, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "header", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "title", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "title-text", + children: (_project$title = project.title) !== null && _project$title !== void 0 ? _project$title : "新项目" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "menu", + onClick: e => { + e.stopPropagation(); + e.preventDefault(); + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components__WEBPACK_IMPORTED_MODULE_3__.Dropdown.Trigger, { + content: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_components__WEBPACK_IMPORTED_MODULE_3__.Menu, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components__WEBPACK_IMPORTED_MODULE_3__.Menu.Item, { + href: `/projects/${project.id}/settings`, + children: "\u8BBE\u7F6E" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components__WEBPACK_IMPORTED_MODULE_3__.Menu.Item, { + href: `/projects/${project.id}/data?labeling=1`, + children: "\u6807\u6CE8" + })] + }), + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components__WEBPACK_IMPORTED_MODULE_3__.Button, { + size: "small", + type: "text", + icon: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_assets_icons__WEBPACK_IMPORTED_MODULE_2__.LsEllipsis, {}) + }) + }) + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "summary", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "annotation", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "total", + children: [project.num_tasks_with_annotations, " / ", project.task_number] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "detail", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "detail-item", + mod: { + type: "completed" + }, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + tag: _assets_icons__WEBPACK_IMPORTED_MODULE_2__.LsCheck, + name: "icon" + }), project.total_annotations_number] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "detail-item", + mod: { + type: "rejected" + }, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + tag: _assets_icons__WEBPACK_IMPORTED_MODULE_2__.LsMinus, + name: "icon" + }), project.skipped_annotations_number] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "detail-item", + mod: { + type: "predictions" + }, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + tag: _assets_icons__WEBPACK_IMPORTED_MODULE_2__.LsBulb, + name: "icon" + }), project.total_predictions_number] + })] + })] + }) + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "description", + children: project.description + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "info", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "created-date", + children: (0,date_fns__WEBPACK_IMPORTED_MODULE_9__.default)(new Date(project.created_at), "yyyy-MM-dd HH:mm") + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_4__.Elem, { + name: "created-by", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components__WEBPACK_IMPORTED_MODULE_3__.Userpic, { + src: "#", + user: project.created_by, + showUsername: true + }) + })] + })] + }) + }); +}; + +/***/ }), + +/***/ "./src/pages/Settings/DangerZone.js": +/*!******************************************!*\ + !*** ./src/pages/Settings/DangerZone.js ***! + \******************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DangerZone": () => (/* binding */ DangerZone) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! react-router */ "./node_modules/react-router/esm/react-router.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components */ "./src/components/index.js"); +/* harmony import */ var _components_Form__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../components/Form */ "./src/components/Form/index.js"); +/* harmony import */ var _components_Modal_Modal__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../components/Modal/Modal */ "./src/components/Modal/Modal.js"); +/* harmony import */ var _components_Space_Space__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../components/Space/Space */ "./src/components/Space/Space.js"); +/* harmony import */ var _components_Spinner_Spinner__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../components/Spinner/Spinner */ "./src/components/Spinner/Spinner.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../providers/ProjectProvider */ "./src/providers/ProjectProvider.tsx"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + + +const DangerZone = () => { + const { + project + } = (0,_providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_7__.useProject)(); + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_6__.useAPI)(); + const history = (0,react_router__WEBPACK_IMPORTED_MODULE_9__.useHistory)(); + const [processing, setProcessing] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + + const handleOnClick = type => () => { + (0,_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_3__.confirm)({ + title: "操作确认", + body: "您正在执行一项不可逆的操作,这个操作不能撤销。", + okText: "继续", + buttonLook: "destructive", + onOk: async () => { + setProcessing(type); + + if (type === 'annotations') {// console.log('delete annotations'); + } else if (type === 'tasks') {// console.log('delete tasks'); + } else if (type === 'predictions') {// console.log('delete predictions'); + } else if (type === 'tabs') { + await api.callApi('deleteTabs', { + body: { + project: project.id + } + }); + } else if (type === 'project') { + await api.callApi('deleteProject', { + params: { + pk: project.id + } + }); + history.replace('/projects'); + } + + setProcessing(null); + } + }); + }; + + const buttons = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => [{ + type: 'annotations', + disabled: true, + //&& !project.total_annotations_number, + label: `删除 ${project.total_annotations_number} 个标注` + }, { + type: 'tasks', + disabled: true, + //&& !project.task_number, + label: `删除 ${project.task_number} 个任务` + }, { + type: 'predictions', + disabled: true, + //&& !project.total_predictions_number, + label: `删除 ${project.total_predictions_number} 个预测` + }, { + type: 'tabs', + label: '删除所有标签页' + }, { + type: 'project', + label: '删除项目' + }], [project]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("div", { + style: { + width: 480 + }, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Label, { + text: "\u5220\u9664\u6807\u6CE8\u3001\u4EFB\u52A1\u6216\u9879\u76EE", + description: "\u8FD9\u4E9B\u64CD\u4F5C\u4F1A\u7ACB\u5373\u751F\u6548\uFF0C\u5E76\u4E14\u65E0\u6CD5\u56DE\u6EDA\u3002\u8BF7\u786E\u4FDD\u60A8\u7684\u6570\u636E\u5DF2\u7ECF\u5907\u4EFD\uFF0C\u5E76\u4E14\u5728\u7EE7\u7EED\u4E4B\u524D\u8BA4\u771F\u8003\u8651\u6BCF\u4E00\u4E2A\u9009\u9879\u7684\u542B\u4E49\u3002", + style: { + display: 'block', + width: 415 + } + }), project.id ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_4__.Space, { + direction: "vertical", + spread: true, + style: { + marginTop: 32 + }, + children: buttons.map(btn => { + const waiting = processing === btn.type; + const disabled = btn.disabled || processing && !waiting; + return btn.disabled !== true && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + look: "danger", + disabled: disabled, + waiting: waiting, + onClick: handleOnClick(btn.type), + children: btn.label + }, btn.type); + }) + }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("div", { + style: { + display: "flex", + justifyContent: "center", + marginTop: 32 + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components_Spinner_Spinner__WEBPACK_IMPORTED_MODULE_5__.Spinner, { + size: 32 + }) + })] + }); +}; +DangerZone.title = "危险区域"; +DangerZone.path = "/danger-zone"; + +/***/ }), + +/***/ "./src/pages/Settings/GeneralSettings.js": +/*!***********************************************!*\ + !*** ./src/pages/Settings/GeneralSettings.js ***! + \***********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "GeneralSettings": () => (/* binding */ GeneralSettings) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components */ "./src/components/index.js"); +/* harmony import */ var _components_Form__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../components/Form */ "./src/components/Form/index.js"); +/* harmony import */ var _components_Form_Elements_RadioGroup_RadioGroup__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../components/Form/Elements/RadioGroup/RadioGroup */ "./src/components/Form/Elements/RadioGroup/RadioGroup.js"); +/* harmony import */ var _providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../providers/ProjectProvider */ "./src/providers/ProjectProvider.tsx"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + +const GeneralSettings = () => { + const { + project, + fetchProject + } = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_4__.ProjectContext); + const updateProject = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + if (project.id) fetchProject(project.id, true); + }, [project]); + const colors = ['#FFFFFF', '#F52B4F', '#FA8C16', '#F6C549', '#9ACA4F', '#51AAFD', '#7F64FF', '#D55C9D']; + const samplings = [{ + value: "Sequential", + label: "顺序", + description: "按数据管理器的顺序来排列任务" + }, { + value: "Uniform", + label: "随机", + description: "以均匀随机方式选择任务" + }]; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("div", { + style: { + width: 480 + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Form, { + action: "updateProject", + formData: { ...project + }, + params: { + pk: project.id + }, + onSubmit: updateProject, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Form.Row, { + columnCount: 1, + rowGap: "32px", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Input, { + name: "title", + label: "\u9879\u76EE\u540D\u79F0", + labelProps: { + large: true + } + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.TextArea, { + name: "description", + label: "\u9879\u76EE\u63CF\u8FF0", + labelProps: { + large: true + }, + style: { + minHeight: 128 + } + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Form_Elements_RadioGroup_RadioGroup__WEBPACK_IMPORTED_MODULE_3__.RadioGroup, { + name: "color", + label: "\u989C\u8272", + size: "large", + labelProps: { + size: "large" + }, + children: colors.map(color => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Form_Elements_RadioGroup_RadioGroup__WEBPACK_IMPORTED_MODULE_3__.RadioGroup.Button, { + value: color, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_5__.Block, { + name: "color", + style: { + '--background': color + } + }) + }, color)) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Form_Elements_RadioGroup_RadioGroup__WEBPACK_IMPORTED_MODULE_3__.RadioGroup, { + label: "\u4EFB\u52A1\u91C7\u6837", + labelProps: { + size: "large" + }, + name: "sampling", + simple: true, + children: samplings.map(({ + value, + label, + description + }) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Form_Elements_RadioGroup_RadioGroup__WEBPACK_IMPORTED_MODULE_3__.RadioGroup.Button, { + value: `${value} sampling`, + label: `${label}采样`, + description: description + }, value)) + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Form.Actions, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Form.Indicator, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("span", { + case: "success", + children: "\u4FDD\u5B58!" + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + type: "submit", + look: "primary", + style: { + width: 120 + }, + children: "\u4FDD\u5B58" + })] + })] + }) + }); +}; +GeneralSettings.menuItem = "常用设置"; +GeneralSettings.path = "/"; +GeneralSettings.exact = true; + +/***/ }), + +/***/ "./src/pages/Settings/InstructionsSettings.js": +/*!****************************************************!*\ + !*** ./src/pages/Settings/InstructionsSettings.js ***! + \****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "InstructionsSettings": () => (/* binding */ InstructionsSettings) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components */ "./src/components/index.js"); +/* harmony import */ var _components_Form__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../components/Form */ "./src/components/Form/index.js"); +/* harmony import */ var _components_Menubar_Menubar__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../components/Menubar/Menubar */ "./src/components/Menubar/Menubar.js"); +/* harmony import */ var _providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../providers/ProjectProvider */ "./src/providers/ProjectProvider.tsx"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + +const InstructionsSettings = () => { + const { + project, + fetchProject + } = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_4__.ProjectContext); + const pageContext = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_components_Menubar_Menubar__WEBPACK_IMPORTED_MODULE_3__.MenubarContext); + const formRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + pageContext.setProps({ + formRef + }); + }, [formRef]); + const updateProject = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + fetchProject(project.id, true); + }, [project]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", { + style: { + width: 480 + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Form, { + ref: formRef, + action: "updateProject", + formData: { ...project + }, + params: { + pk: project.id + }, + onSubmit: updateProject, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Form.Row, { + columnCount: 1, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Label, { + text: "\u6807\u6CE8\u8BF4\u660E", + large: true + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", { + style: { + paddingLeft: 16 + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Toggle, { + label: "\u6807\u6CE8\u524D\u663E\u793A", + name: "show_instruction" + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", { + style: { + color: "rgba(0,0,0,0.4)", + paddingLeft: 16 + }, + children: "\u7F16\u5199\u6807\u6CE8\u8BF4\u660E\u4EE5\u5E2E\u52A9\u7528\u6237\u5B8C\u6210\u6807\u6CE8\u4EFB\u52A1\u3002" + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Form.Row, { + columnCount: 1, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.TextArea, { + name: "expert_instruction", + style: { + minHeight: 128 + } + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Form.Actions, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_2__.Form.Indicator, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("span", { + case: "success", + children: "\u4FDD\u5B58\u6210\u529F\uFF01" + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + type: "submit", + look: "primary", + style: { + width: 120 + }, + children: "\u4FDD\u5B58" + })] + })] + }) + }); +}; +InstructionsSettings.title = "标注说明"; +InstructionsSettings.path = "/instruction"; + +/***/ }), + +/***/ "./src/pages/Settings/LabelingSettings.js": +/*!************************************************!*\ + !*** ./src/pages/Settings/LabelingSettings.js ***! + \************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "LabelingSettings": () => (/* binding */ LabelingSettings) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react-router */ "./node_modules/react-router/esm/react-router.js"); +/* harmony import */ var _components_Modal_Modal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components/Modal/Modal */ "./src/components/Modal/Modal.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../providers/ProjectProvider */ "./src/providers/ProjectProvider.tsx"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var _CreateProject_Config_Config__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../CreateProject/Config/Config */ "./src/pages/CreateProject/Config/Config.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + +const LabelingSettings = () => { + const history = (0,react_router__WEBPACK_IMPORTED_MODULE_7__.useHistory)(); + const { + project, + fetchProject + } = (0,_providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_3__.useProject)(); + const [config, setConfig] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(""); + const [essentialDataChanged, setEssentialDataChanged] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_2__.useAPI)(); + const saveConfig = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + const res = await api.callApi("updateProjectRaw", { + params: { + pk: project.id + }, + body: { + label_config: config + } + }); + + if (res.ok) { + history.push(`/projects/${project.id}/data`); + return true; + } + + const error = await res.json(); + fetchProject(); + return error; + }, [project, config]); + const projectAlreadySetUp = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + if (project.label_config) { + const hasConfig = !(0,_utils_helpers__WEBPACK_IMPORTED_MODULE_4__.isEmptyString)(project.label_config); + const configIsEmpty = project.label_config.replace(/\s/g, '') === ''; + const hasTasks = project.task_number > 0; + console.log({ + hasConfig, + configIsEmpty, + hasTasks, + project + }); + return hasConfig && !configIsEmpty && hasTasks; + } + + return false; + }, [project]); + const onSave = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + if (essentialDataChanged && projectAlreadySetUp) { + (0,_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_1__.confirm)({ + title: "标注配置数据已更改", + body: "标注配置数据有影响数据展示的重大更改。保存配置可能会导致删除数据管理器中以前创建的所有标签页。", + buttonLook: "destructive", + onOk: () => saveConfig(), + okText: "保存" + }); + } else { + saveConfig(); + } + }, [essentialDataChanged, saveConfig]); + const onUpdate = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(config => { + setConfig(config); + fetchProject(); + }); + const onValidate = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(validation => { + setEssentialDataChanged(validation.config_essential_data_has_changed); + }, []); + if (!project.id) return null; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_CreateProject_Config_Config__WEBPACK_IMPORTED_MODULE_5__.ConfigPage, { + config: project.label_config, + project: project, + onUpdate: onUpdate, + onSaveClick: onSave, + onValidate: onValidate + }); +}; +LabelingSettings.title = "标识接口"; +LabelingSettings.path = "/labeling"; + +/***/ }), + +/***/ "./src/pages/Settings/MachineLearningSettings/MachineLearningList.js": +/*!***************************************************************************!*\ + !*** ./src/pages/Settings/MachineLearningSettings/MachineLearningList.js ***! + \***************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "MachineLearningList": () => (/* binding */ MachineLearningList) +/* harmony export */ }); +/* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/format/index.js"); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_icons_fa__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! react-icons/fa */ "./node_modules/react-icons/fa/index.esm.js"); +/* harmony import */ var truncate_middle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! truncate-middle */ "./node_modules/truncate-middle/index.js"); +/* harmony import */ var truncate_middle__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(truncate_middle__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../components */ "./src/components/index.js"); +/* harmony import */ var _components_DescriptionList_DescriptionList__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../components/DescriptionList/DescriptionList */ "./src/components/DescriptionList/DescriptionList.js"); +/* harmony import */ var _components_Modal_Modal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../components/Modal/Modal */ "./src/components/Modal/Modal.js"); +/* harmony import */ var _components_Oneof_Oneof__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../components/Oneof/Oneof */ "./src/components/Oneof/Oneof.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + + + +const MachineLearningList = ({ + backends, + fetchBackends, + onEdit +}) => { + const rootClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_7__.cn)('ml'); + const api = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_6__.ApiContext); + const onDeleteModel = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async backend => { + await api.callApi('deleteMLBackend', { + params: { + pk: backend.id + } + }); + await fetchBackends(); + }, [fetchBackends, api]); + const onStartTraining = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async backend => { + await api.callApi('trainMLBackend', { + params: { + pk: backend.id + } + }); + await fetchBackends(); + }, [fetchBackends, api]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("div", { + className: rootClass, + children: backends.map(backend => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(BackendCard, { + backend: backend, + onStartTrain: onStartTraining, + onDelete: onDeleteModel, + onEdit: onEdit + }, backend.id)) + }); +}; + +const BackendCard = ({ + backend, + onStartTrain, + onEdit, + onDelete +}) => { + const confirmDelete = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(backend => { + (0,_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_4__.confirm)({ + title: "删除机器学习后端", + body: "此操作不可撤销。您确定要这样做吗?", + buttonLook: "destructive", + + onOk() { + onDelete === null || onDelete === void 0 ? void 0 : onDelete(backend); + } + + }); + }, [backend, onDelete]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)(_components__WEBPACK_IMPORTED_MODULE_2__.Card, { + style: { + marginTop: 0 + }, + header: backend.title, + extra: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("div", { + className: (0,_utils_bem__WEBPACK_IMPORTED_MODULE_7__.cn)('ml').elem('info'), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(BackendState, { + backend: backend + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components__WEBPACK_IMPORTED_MODULE_2__.Dropdown.Trigger, { + align: "right", + content: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)(_components__WEBPACK_IMPORTED_MODULE_2__.Menu, { + size: "small", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components__WEBPACK_IMPORTED_MODULE_2__.Menu.Item, { + onClick: () => onEdit(backend), + children: "\u7F16\u8F91" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components__WEBPACK_IMPORTED_MODULE_2__.Menu.Item, { + onClick: () => confirmDelete(backend), + children: "\u5220\u9664" + })] + }), + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components__WEBPACK_IMPORTED_MODULE_2__.Button, { + type: "link", + icon: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(react_icons_fa__WEBPACK_IMPORTED_MODULE_9__.FaEllipsisV, {}) + }) + })] + }), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)(_components_DescriptionList_DescriptionList__WEBPACK_IMPORTED_MODULE_3__.DescriptionList, { + className: (0,_utils_bem__WEBPACK_IMPORTED_MODULE_7__.cn)('ml').elem('summary'), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components_DescriptionList_DescriptionList__WEBPACK_IMPORTED_MODULE_3__.DescriptionList.Item, { + term: "URL", + termStyle: { + whiteSpace: 'nowrap' + }, + children: truncate_middle__WEBPACK_IMPORTED_MODULE_1___default()(backend.url, 20, 10, '...') + }), backend.description && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components_DescriptionList_DescriptionList__WEBPACK_IMPORTED_MODULE_3__.DescriptionList.Item, { + term: "\u63CF\u8FF0", + children: backend.description + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components_DescriptionList_DescriptionList__WEBPACK_IMPORTED_MODULE_3__.DescriptionList.Item, { + term: "\u7248\u672C", + children: backend.version ? (0,date_fns__WEBPACK_IMPORTED_MODULE_10__.default)(new Date(backend.version), 'yyyy-MM-dd HH:mm:ss') : '未知' + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components__WEBPACK_IMPORTED_MODULE_2__.Button, { + disabled: backend.state !== "CO", + onClick: () => onStartTrain(backend), + children: "\u5F00\u59CB\u8BAD\u7EC3" + })] + }); +}; + +const BackendState = ({ + backend +}) => { + const { + state + } = backend; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("div", { + className: (0,_utils_bem__WEBPACK_IMPORTED_MODULE_7__.cn)('ml').elem('status'), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("span", { + className: (0,_utils_bem__WEBPACK_IMPORTED_MODULE_7__.cn)('ml').elem('indicator').mod({ + state + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)(_components_Oneof_Oneof__WEBPACK_IMPORTED_MODULE_5__.Oneof, { + value: state, + className: (0,_utils_bem__WEBPACK_IMPORTED_MODULE_7__.cn)('ml').elem('status-label'), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("span", { + case: "DI", + children: "\u65AD\u5F00\u8FDE\u63A5" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("span", { + case: "CO", + children: "\u5DF2\u8FDE\u63A5" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("span", { + case: "ER", + children: "\u9519\u8BEF" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("span", { + case: "TR", + children: "\u8BAD\u7EC3\u4E2D" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("span", { + case: "PR", + children: "\u9884\u6D4B\u4E2D" + })] + })] + }); +}; + +/***/ }), + +/***/ "./src/pages/Settings/MachineLearningSettings/MachineLearningSettings.js": +/*!*******************************************************************************!*\ + !*** ./src/pages/Settings/MachineLearningSettings/MachineLearningSettings.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "MachineLearningSettings": () => (/* binding */ MachineLearningSettings) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../components */ "./src/components/index.js"); +/* harmony import */ var _components_Description_Description__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../components/Description/Description */ "./src/components/Description/Description.js"); +/* harmony import */ var _components_Divider_Divider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../components/Divider/Divider */ "./src/components/Divider/Divider.js"); +/* harmony import */ var _components_Error_Error__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../components/Error/Error */ "./src/components/Error/Error.js"); +/* harmony import */ var _components_Error_InlineError__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../components/Error/InlineError */ "./src/components/Error/InlineError.js"); +/* harmony import */ var _components_Form__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../components/Form */ "./src/components/Form/index.js"); +/* harmony import */ var _components_Modal_Modal__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../components/Modal/Modal */ "./src/components/Modal/Modal.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../providers/ProjectProvider */ "./src/providers/ProjectProvider.tsx"); +/* harmony import */ var _MachineLearningList__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./MachineLearningList */ "./src/pages/Settings/MachineLearningSettings/MachineLearningList.js"); +/* harmony import */ var _MachineLearningSettings_styl__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./MachineLearningSettings.styl */ "./src/pages/Settings/MachineLearningSettings/MachineLearningSettings.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + + + + + + +const MachineLearningSettings = () => { + const api = (0,_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_8__.useAPI)(); + const { + project, + fetchProject, + updateProject + } = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_9__.ProjectContext); + const [mlError, setMLError] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(); + const [backends, setBackends] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]); + const [versions, setVersions] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]); + const resetMLVersion = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async e => { + e.preventDefault(); + e.stopPropagation(); + await updateProject({ + model_version: null + }); + }, [api, project]); + const fetchBackends = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + const models = await api.callApi('mlBackends', { + params: { + project: project.id + } + }); + if (models) setBackends(models); + }, [api, project, setBackends]); + const fetchMLVersions = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + const versions = await api.callApi("modelVersions", { + params: { + pk: project.id + } + }); + setVersions(versions); + }, [api, project.id]); + const showMLFormModal = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(backend => { + const action = backend ? "updateMLBackend" : "addMLBackend"; + const modalProps = { + title: `${backend ? '编辑' : '添加'}模型`, + style: { + width: 760 + }, + closeOnClickOutside: false, + body: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Form, { + action: action, + formData: { ...(backend !== null && backend !== void 0 ? backend : {}) + }, + params: { + pk: backend === null || backend === void 0 ? void 0 : backend.id + }, + onSubmit: async response => { + if (!response.error_message) { + await fetchBackends(); + modalRef.close(); + } + }, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Input, { + type: "hidden", + name: "project", + value: project.id + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Form.Row, { + columnCount: 2, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Input, { + name: "title", + label: "\u6807\u9898", + placeholder: "ML \u6A21\u578B" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Input, { + name: "url", + label: "URL", + required: true + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Form.Row, { + columnCount: 1, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.TextArea, { + name: "description", + label: "\u63CF\u8FF0", + style: { + minHeight: 120 + } + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Form.Actions, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + type: "submit", + look: "primary", + onClick: () => setMLError(null), + children: "\u9A8C\u8BC1\u5E76\u4FDD\u5B58" + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Form.ResponseParser, { + children: response => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.Fragment, { + children: response.error_message && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Error_Error__WEBPACK_IMPORTED_MODULE_4__.ErrorWrapper, { + error: { + response: { + detail: `保存或添加新的 ML 后端操作失败。`, + exc_info: response.error_message + } + } + }) + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Error_InlineError__WEBPACK_IMPORTED_MODULE_5__.InlineError, {})] + }) + }; + const modalRef = (0,_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_7__.modal)(modalProps); + }, [project, fetchBackends, mlError]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (project.id) { + fetchBackends(); + fetchMLVersions(); + } + }, [project]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.Fragment, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)(_components_Description_Description__WEBPACK_IMPORTED_MODULE_2__.Description, { + style: { + marginTop: 0, + maxWidth: 680 + }, + children: ["\u6DFB\u52A0\u4E00\u4E2A\u6216\u591A\u4E2A\u673A\u5668\u5B66\u4E60\u6A21\u578B\uFF0C\u4EE5\u4FBF\u4E3A\u60A8\u7684\u6570\u636E\u9884\u6D4B\u6807\u7B7E\u3002 \u8981\u5728\u4E0D\u8FDE\u63A5\u6A21\u578B\u7684\u60C5\u51B5\u4E0B\u5BFC\u5165\u9884\u6D4B\uFF0C", " ", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)("a", { + href: "https://labelstud.io/guide/predictions.html", + target: "_blank", + children: "\u8BF7\u53C2\u9605\u6587\u6863" + }), "\u3002"] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + onClick: () => showMLFormModal(), + children: "\u6DFB\u52A0\u6A21\u578B" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Divider_Divider__WEBPACK_IMPORTED_MODULE_3__.Divider, { + height: 32 + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Form, { + action: "updateProject", + formData: { ...project + }, + params: { + pk: project.id + }, + onSubmit: () => fetchProject(), + autosubmit: true, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Form.Row, { + columnCount: 1, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Label, { + text: "\u673A\u5668\u5B66\u4E60\u8F85\u52A9\u6807\u6CE8", + large: true + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)("div", { + style: { + paddingLeft: 16 + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Toggle, { + label: "\u5728\u4EFB\u4F55\u6807\u6CE8\u6216\u66F4\u65B0\u65F6\u542F\u52A8\u6A21\u578B\u8BAD\u7EC3", + name: "start_training_on_annotation_update" + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)("div", { + style: { + paddingLeft: 16 + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Toggle, { + label: "\u5728\u4EFB\u52A1\u52A0\u8F7D\u65F6\u81EA\u52A8\u68C0\u7D22\u9884\u6D4B\u7ED3\u679C", + name: "evaluate_predictions_automatically" + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)("div", { + style: { + paddingLeft: 16 + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Toggle, { + label: "\u5728\u6807\u7B7E\u6D41\u548C\u5FEB\u901F\u67E5\u770B\u4E2D\u663E\u793A\u9884\u6D4B\u7ED3\u679C\u7ED9\u6807\u6CE8\u8005", + name: "show_collab_predictions" + }) + })] + }), versions.length > 1 && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Form.Row, { + columnCount: 1, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Label, { + text: "\u6A21\u578B\u7248\u672C", + description: "\u6A21\u578B\u7248\u672C\u5141\u8BB8\u60A8\u6307\u5B9A\u8981\u663E\u793A\u7ED9\u6807\u6CE8\u8005\u7684\u9884\u6D4B", + style: { + marginTop: 16 + }, + large: true + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)("div", { + style: { + display: 'flex', + alignItems: 'center', + width: 400, + paddingLeft: 16 + }, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)("div", { + style: { + flex: 1, + paddingRight: 16 + }, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_6__.Select, { + name: "model_version", + defaultValue: null, + options: [...versions], + placeholder: "\u672A\u9009\u62E9\u6A21\u578B\u7248\u672C" + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + onClick: resetMLVersion, + children: "\u91CD\u7F6E" + })] + })] + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_MachineLearningList__WEBPACK_IMPORTED_MODULE_10__.MachineLearningList, { + onEdit: backend => showMLFormModal(backend), + fetchBackends: fetchBackends, + backends: backends + })] + }); +}; +MachineLearningSettings.title = "机器学习"; +MachineLearningSettings.path = "/ml"; + +/***/ }), + +/***/ "./src/pages/Settings/StorageSettings/StorageCard.js": +/*!***********************************************************!*\ + !*** ./src/pages/Settings/StorageSettings/StorageCard.js ***! + \***********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "StorageCard": () => (/* binding */ StorageCard) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_icons_fa__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react-icons/fa */ "./node_modules/react-icons/fa/index.esm.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../components */ "./src/components/index.js"); +/* harmony import */ var _components_Space_Space__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../components/Space/Space */ "./src/components/Space/Space.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _StorageSummary__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./StorageSummary */ "./src/pages/Settings/StorageSettings/StorageSummary.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + +const StorageCard = ({ + rootClass, + target, + storage, + onEditStorage, + onDeleteStorage, + storageTypes +}) => { + var _storageData$title; + + const [syncing, setSyncing] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + const api = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_3__.ApiContext); + const [storageData, setStorageData] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)({ ...storage + }); + const [synced, setSynced] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + const startSync = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + setSyncing(true); + setSynced(null); + const result = await api.callApi('syncStorage', { + params: { + target, + type: storageData.type, + pk: storageData.id + } + }); + + if (result) { + setStorageData(result); + setSynced(result.last_sync_count); + } + + setSyncing(false); + }, [storage]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + setStorageData(storage); + }, [storage]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_components__WEBPACK_IMPORTED_MODULE_1__.Card, { + header: (_storageData$title = storageData.title) !== null && _storageData$title !== void 0 ? _storageData$title : `无标题 ${storageData.type}`, + extra: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Dropdown.Trigger, { + align: "right", + content: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_components__WEBPACK_IMPORTED_MODULE_1__.Menu, { + size: "compact", + style: { + width: 110 + }, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Menu.Item, { + onClick: () => onEditStorage(storageData), + children: "\u7F16\u8F91" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Menu.Item, { + onClick: () => onDeleteStorage(storageData), + children: "\u5220\u9664" + })] + }), + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + type: "link", + style: { + width: 32, + height: 32, + marginRight: -10 + }, + icon: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(react_icons_fa__WEBPACK_IMPORTED_MODULE_6__.FaEllipsisV, {}) + }) + }), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_StorageSummary__WEBPACK_IMPORTED_MODULE_4__.StorageSummary, { + storage: storageData, + enableLastSync: target !== 'export', + className: rootClass.elem('summary'), + storageTypes: storageTypes + }), target !== 'export' && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", { + className: rootClass.elem('sync'), + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_components_Space_Space__WEBPACK_IMPORTED_MODULE_2__.Space, { + size: "small", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + waiting: syncing, + onClick: startSync, + children: "\u540C\u6B65\u5B58\u50A8" + }), synced !== null ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("div", { + className: rootClass.elem('sync-count'), + children: ["\u5DF2\u540C\u6B65 ", synced, " \u4E2A\u4EFB\u52A1"] + }) : null] + }) + })] + }); +}; + +/***/ }), + +/***/ "./src/pages/Settings/StorageSettings/StorageForm.js": +/*!***********************************************************!*\ + !*** ./src/pages/Settings/StorageSettings/StorageForm.js ***! + \***********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "StorageForm": () => (/* binding */ StorageForm) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../components */ "./src/components/index.js"); +/* harmony import */ var _components_Error_InlineError__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../components/Error/InlineError */ "./src/components/Error/InlineError.js"); +/* harmony import */ var _components_Form__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../components/Form */ "./src/components/Form/index.js"); +/* harmony import */ var _components_Oneof_Oneof__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../components/Oneof/Oneof */ "./src/components/Oneof/Oneof.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + +const StorageForm = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(({ + onSubmit, + target, + project, + rootClass, + storage, + storageTypes +}, ref) => { + var _ref, _storage$type, _storageTypes$, _storage$type2; + + /**@type {import('react').RefObject} */ + const api = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_5__.ApiContext); + const formRef = ref !== null && ref !== void 0 ? ref : (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + const [type, setType] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)((_ref = (_storage$type = storage === null || storage === void 0 ? void 0 : storage.type) !== null && _storage$type !== void 0 ? _storage$type : storageTypes === null || storageTypes === void 0 ? void 0 : (_storageTypes$ = storageTypes[0]) === null || _storageTypes$ === void 0 ? void 0 : _storageTypes$.name) !== null && _ref !== void 0 ? _ref : 's3'); + const [checking, setChecking] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + const [connectionValid, setConnectionValid] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + const [form, setForm] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + api.callApi('storageForms', { + params: { + target, + type + } + }).then(formFields => setForm(formFields)); + }, [type]); + const storageTypeSelect = { + columnCount: 1, + fields: [{ + skip: true, + type: "select", + name: "storage_type", + label: "存储类型", + disabled: !!storage, + options: storageTypes.map(({ + name, + title + }) => ({ + value: name, + label: title + })), + value: (_storage$type2 = storage === null || storage === void 0 ? void 0 : storage.type) !== null && _storage$type2 !== void 0 ? _storage$type2 : type, + onChange: e => { + setType(e.target.value); + } + }] + }; + const validateStorageConnection = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + setChecking(true); + setConnectionValid(null); + const form = formRef.current; + + if (form && form.validateFields()) { + const body = form.assembleFormData({ + asJSON: true + }); + const type = form.getField('storage_type').value; // we're using api provided by the form to be able to save + // current api context and render inline erorrs properly + + const response = await form.api.callApi('validateStorage', { + params: { + target, + type + }, + body + }); + if (response !== null) setConnectionValid(true);else setConnectionValid(false); + } + + setChecking(false); + }, [formRef, target, type]); + const action = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + return storage ? "updateStorage" : "createStorage"; + }, [storage]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_components_Form__WEBPACK_IMPORTED_MODULE_3__.Form.Builder, { + ref: formRef, + action: action, + params: { + target, + type, + project, + pk: storage === null || storage === void 0 ? void 0 : storage.id + }, + fields: [storageTypeSelect, ...form], + formData: { ...(storage !== null && storage !== void 0 ? storage : {}) + }, + skipEmpty: true, + onSubmit: onSubmit, + autoFill: "off", + autoComplete: "off", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_3__.Input, { + type: "hidden", + name: "project", + value: project + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_components_Form__WEBPACK_IMPORTED_MODULE_3__.Form.Actions, { + valid: connectionValid, + extra: connectionValid !== null && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_6__.Block, { + name: "form-indicator", + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_components_Oneof_Oneof__WEBPACK_IMPORTED_MODULE_4__.Oneof, { + value: connectionValid, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_6__.Elem, { + tag: "span", + mod: { + type: "success" + }, + name: "item", + case: true, + children: "\u8FDE\u63A5\u6210\u529F\uFF01" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_utils_bem__WEBPACK_IMPORTED_MODULE_6__.Elem, { + tag: "span", + mod: { + type: "fail" + }, + name: "item", + case: false, + children: "\u8FDE\u63A5\u5931\u8D25" + })] + }) + }), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_components_Form__WEBPACK_IMPORTED_MODULE_3__.Input, { + type: "hidden", + name: "project", + value: project + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_components__WEBPACK_IMPORTED_MODULE_1__.Button.Group, { + className: rootClass.elem('buttons'), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + type: "button", + waiting: checking, + onClick: validateStorageConnection, + children: "\u68C0\u67E5\u8FDE\u63A5" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + type: "submit", + look: "primary", + children: storage ? "保存" : "添加存储" + })] + })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_components_Error_InlineError__WEBPACK_IMPORTED_MODULE_2__.InlineError, {})] + }); +}); + +/***/ }), + +/***/ "./src/pages/Settings/StorageSettings/StorageSet.js": +/*!**********************************************************!*\ + !*** ./src/pages/Settings/StorageSettings/StorageSet.js ***! + \**********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "StorageSet": () => (/* binding */ StorageSet) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../components */ "./src/components/index.js"); +/* harmony import */ var _components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../components/Modal/Modal */ "./src/components/Modal/Modal.js"); +/* harmony import */ var _components_Spinner_Spinner__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../components/Spinner/Spinner */ "./src/components/Spinner/Spinner.js"); +/* harmony import */ var _providers_ApiProvider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../providers/ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../providers/ProjectProvider */ "./src/providers/ProjectProvider.tsx"); +/* harmony import */ var _StorageCard__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./StorageCard */ "./src/pages/Settings/StorageSettings/StorageCard.js"); +/* harmony import */ var _StorageForm__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./StorageForm */ "./src/pages/Settings/StorageSettings/StorageForm.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + + + +const StorageSet = ({ + title, + target, + rootClass, + buttonLabel +}) => { + const api = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_providers_ApiProvider__WEBPACK_IMPORTED_MODULE_4__.ApiContext); + const { + project + } = (0,_providers_ProjectProvider__WEBPACK_IMPORTED_MODULE_5__.useProject)(); + const [storages, setStorages] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]); + const [loading, setLoading] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + const [loaded, setLoaded] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + const [storageTypes, setStorageTypes] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + api.callApi('storageTypes', { + params: { + target + } + }).then(types => { + setStorageTypes(types); + }); + }, []); + const fetchStorages = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + if (!project.id) { + console.warn("Project ID not provided"); + return; + } + + setLoading(true); + const result = await api.callApi('listStorages', { + params: { + project: project.id, + target + } + }); + const storageTypes = await api.callApi('storageTypes', { + params: { + target + } + }); + setStorageTypes(storageTypes); + + if (result !== null) { + setStorages(result); + setLoaded(true); + } + + setLoading(false); + }, [project]); + const showStorageFormModal = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(storage => { + const action = storage ? "编辑" : "添加"; + const actionTarget = target === 'export' ? '目标' : '源'; + const title = `${action}${actionTarget}存储`; + const modalRef = (0,_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__.modal)({ + title, + closeOnClickOutside: false, + style: { + width: 760 + }, + body: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_StorageForm__WEBPACK_IMPORTED_MODULE_7__.StorageForm, { + target: target, + storage: storage, + project: project.id, + rootClass: rootClass, + storageTypes: storageTypes, + onSubmit: async () => { + await fetchStorages(); + modalRef.close(); + } + }), + footer: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.Fragment, { + children: ["\u5C06\u5DF2\u5B8C\u6210\u7684\u6807\u6CE8\u6570\u636E\u4FDD\u5B58\u5230 Amazon S3\u3001Google Cloud\u3001Microsoft Azure \u6216 Redis \u4E0A\u3002", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("br", {}), "\u4E86\u89E3\u66F4\u591A\u8BF7\u53C2\u8003", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("a", { + href: "https://labelstud.io/guide/storage.html", + children: "\u6587\u6863" + }), "\u3002"] + }) + }); + }, [project, fetchStorages, target, rootClass]); + const onEditStorage = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async storage => { + showStorageFormModal(storage); + }, [showStorageFormModal]); + const onDeleteStorage = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async storage => { + (0,_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__.confirm)({ + title: "删除存储", + body: "这个操作是不可恢复的,您确定要删除吗?", + buttonLook: "destructive", + onOk: async () => { + const response = await api.callApi('deleteStorage', { + params: { + type: storage.type, + pk: storage.id, + target + } + }); + if (response !== null) fetchStorages(); + } + }); + }, [fetchStorages]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + fetchStorages(); + }, [fetchStorages]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)(_components__WEBPACK_IMPORTED_MODULE_1__.Columns.Column, { + title: title, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("div", { + className: rootClass.elem("controls"), + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + onClick: () => showStorageFormModal(), + children: buttonLabel + }) + }), loading && !loaded ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("div", { + className: rootClass.elem("empty"), + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components_Spinner_Spinner__WEBPACK_IMPORTED_MODULE_3__.Spinner, { + size: 32 + }) + }) : storages.length === 0 ? null : storages.map(storage => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_StorageCard__WEBPACK_IMPORTED_MODULE_6__.StorageCard, { + storage: storage, + target: target, + rootClass: rootClass, + storageTypes: storageTypes, + onEditStorage: onEditStorage, + onDeleteStorage: onDeleteStorage + }, storage.id))] + }); +}; + +/***/ }), + +/***/ "./src/pages/Settings/StorageSettings/StorageSettings.js": +/*!***************************************************************!*\ + !*** ./src/pages/Settings/StorageSettings/StorageSettings.js ***! + \***************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "StorageSettings": () => (/* binding */ StorageSettings) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _components_Columns_Columns__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../components/Columns/Columns */ "./src/components/Columns/Columns.js"); +/* harmony import */ var _components_Description_Description__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../components/Description/Description */ "./src/components/Description/Description.js"); +/* harmony import */ var _utils_bem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../utils/bem */ "./src/utils/bem.tsx"); +/* harmony import */ var _StorageSet__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./StorageSet */ "./src/pages/Settings/StorageSettings/StorageSet.js"); +/* harmony import */ var _StorageSettings_styl__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./StorageSettings.styl */ "./src/pages/Settings/StorageSettings/StorageSettings.styl"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + +const StorageSettings = () => { + const rootClass = (0,_utils_bem__WEBPACK_IMPORTED_MODULE_3__.cn)("storage-settings"); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_utils_bem__WEBPACK_IMPORTED_MODULE_3__.Block, { + name: "storage-settings", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Description_Description__WEBPACK_IMPORTED_MODULE_2__.Description, { + style: { + marginTop: 0 + }, + children: "\u4F7F\u7528\u4E91\u5B58\u50A8\u6216\u6570\u636E\u5E93\u4E3A\u60A8\u7684\u6807\u6CE8\u4EFB\u52A1\u6216\u5DF2\u5B8C\u6210\u7684\u6807\u6CE8\u4F5C\u4E3A\u6570\u636E\u6E90\uFF0C\u6216\u8005\u4F5C\u4E3A\u6570\u636E\u7684\u76EE\u6807\u3002" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_components_Columns_Columns__WEBPACK_IMPORTED_MODULE_1__.Columns, { + count: 2, + gap: "40px", + size: "320px", + className: rootClass, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_StorageSet__WEBPACK_IMPORTED_MODULE_4__.StorageSet, { + title: "\u6E90\u4E91\u5B58\u50A8", + buttonLabel: "\u6DFB\u52A0\u6E90\u5B58\u50A8", + rootClass: rootClass + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_StorageSet__WEBPACK_IMPORTED_MODULE_4__.StorageSet, { + title: "\u76EE\u6807\u4E91\u5B58\u50A8", + target: "export", + buttonLabel: "\u6DFB\u52A0\u76EE\u6807\u5B58\u50A8", + rootClass: rootClass + })] + })] + }); +}; +StorageSettings.title = "云存储"; +StorageSettings.path = "/storage"; + +/***/ }), + +/***/ "./src/pages/Settings/StorageSettings/StorageSummary.js": +/*!**************************************************************!*\ + !*** ./src/pages/Settings/StorageSettings/StorageSummary.js ***! + \**************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "StorageSummary": () => (/* binding */ StorageSummary) +/* harmony export */ }); +/* harmony import */ var date_fns_esm__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! date-fns/esm */ "./node_modules/date-fns/esm/format/index.js"); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _components_DescriptionList_DescriptionList__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../components/DescriptionList/DescriptionList */ "./src/components/DescriptionList/DescriptionList.js"); +/* harmony import */ var _components_Oneof_Oneof__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../components/Oneof/Oneof */ "./src/components/Oneof/Oneof.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + +const StorageSummary = ({ + storage, + className, + enableLastSync = false, + storageTypes = [] +}) => { + var _storageTypes$find$ti, _storageTypes$find; + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("div", { + className: className, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)(_components_DescriptionList_DescriptionList__WEBPACK_IMPORTED_MODULE_1__.DescriptionList, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_components_DescriptionList_DescriptionList__WEBPACK_IMPORTED_MODULE_1__.DescriptionList.Item, { + term: "\u7C7B\u578B", + children: (_storageTypes$find$ti = (_storageTypes$find = storageTypes.find(s => s.name === storage.type)) === null || _storageTypes$find === void 0 ? void 0 : _storageTypes$find.title) !== null && _storageTypes$find$ti !== void 0 ? _storageTypes$find$ti : storage.type + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)(_components_Oneof_Oneof__WEBPACK_IMPORTED_MODULE_2__.Oneof, { + value: storage.type, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(SummaryS3, { + case: "s3", + storage: storage + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(GSCStorage, { + case: "gcs", + storage: storage + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(AzureStorage, { + case: "azure", + storage: storage + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(RedisStorage, { + case: "redis", + storage: storage + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(LocalStorage, { + case: "localfiles", + storage: storage + })] + }), enableLastSync && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_components_DescriptionList_DescriptionList__WEBPACK_IMPORTED_MODULE_1__.DescriptionList.Item, { + term: "\u6700\u540E\u4E00\u6B21\u540C\u6B65", + children: storage.last_sync ? (0,date_fns_esm__WEBPACK_IMPORTED_MODULE_4__.default)(new Date(storage.last_sync), 'yyyy-MM-dd HH:mm:ss') : "不同步" + })] + }) + }); +}; + +const SummaryS3 = ({ + storage +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_components_DescriptionList_DescriptionList__WEBPACK_IMPORTED_MODULE_1__.DescriptionList.Item, { + term: "Bucket", + children: storage.bucket + }); +}; + +const GSCStorage = ({ + storage +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_components_DescriptionList_DescriptionList__WEBPACK_IMPORTED_MODULE_1__.DescriptionList.Item, { + term: "Bucket", + children: storage.bucket + }); +}; + +const AzureStorage = ({ + storage +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_components_DescriptionList_DescriptionList__WEBPACK_IMPORTED_MODULE_1__.DescriptionList.Item, { + term: "\u5BB9\u5668", + children: storage.container + }); +}; + +const RedisStorage = ({ + storage +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.Fragment, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_components_DescriptionList_DescriptionList__WEBPACK_IMPORTED_MODULE_1__.DescriptionList.Item, { + term: "\u8DEF\u5F84", + children: storage.path + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)(_components_DescriptionList_DescriptionList__WEBPACK_IMPORTED_MODULE_1__.DescriptionList.Item, { + term: "\u4E3B\u673A", + children: [storage.host, storage.port ? `:${storage.post}` : ''] + })] + }); +}; + +const LocalStorage = ({ + storage +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_components_DescriptionList_DescriptionList__WEBPACK_IMPORTED_MODULE_1__.DescriptionList.Item, { + term: "\u8DEF\u5F84", + children: storage.path + }); +}; + +/***/ }), + +/***/ "./src/pages/Settings/index.js": +/*!*************************************!*\ + !*** ./src/pages/Settings/index.js ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "MenuLayout": () => (/* binding */ MenuLayout), +/* harmony export */ "SettingsPage": () => (/* binding */ SettingsPage) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _components_SidebarMenu_SidebarMenu__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components/SidebarMenu/SidebarMenu */ "./src/components/SidebarMenu/SidebarMenu.js"); +/* harmony import */ var _DangerZone__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./DangerZone */ "./src/pages/Settings/DangerZone.js"); +/* harmony import */ var _GeneralSettings__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./GeneralSettings */ "./src/pages/Settings/GeneralSettings.js"); +/* harmony import */ var _InstructionsSettings__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./InstructionsSettings */ "./src/pages/Settings/InstructionsSettings.js"); +/* harmony import */ var _LabelingSettings__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./LabelingSettings */ "./src/pages/Settings/LabelingSettings.js"); +/* harmony import */ var _MachineLearningSettings_MachineLearningSettings__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./MachineLearningSettings/MachineLearningSettings */ "./src/pages/Settings/MachineLearningSettings/MachineLearningSettings.js"); +/* harmony import */ var _StorageSettings_StorageSettings__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./StorageSettings/StorageSettings */ "./src/pages/Settings/StorageSettings/StorageSettings.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + +const MenuLayout = ({ + children, + ...routeProps +}) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(_components_SidebarMenu_SidebarMenu__WEBPACK_IMPORTED_MODULE_1__.SidebarMenu, { + menuItems: [_GeneralSettings__WEBPACK_IMPORTED_MODULE_3__.GeneralSettings, _LabelingSettings__WEBPACK_IMPORTED_MODULE_5__.LabelingSettings, _InstructionsSettings__WEBPACK_IMPORTED_MODULE_4__.InstructionsSettings, _MachineLearningSettings_MachineLearningSettings__WEBPACK_IMPORTED_MODULE_6__.MachineLearningSettings, _StorageSettings_StorageSettings__WEBPACK_IMPORTED_MODULE_7__.StorageSettings, _DangerZone__WEBPACK_IMPORTED_MODULE_2__.DangerZone], + path: routeProps.match.url, + children: children + }); +}; +const SettingsPage = { + title: "设置", + path: "/settings", + exact: true, + layout: MenuLayout, + component: _GeneralSettings__WEBPACK_IMPORTED_MODULE_3__.GeneralSettings, + pages: { + InstructionsSettings: _InstructionsSettings__WEBPACK_IMPORTED_MODULE_4__.InstructionsSettings, + LabelingSettings: _LabelingSettings__WEBPACK_IMPORTED_MODULE_5__.LabelingSettings, + MachineLearningSettings: _MachineLearningSettings_MachineLearningSettings__WEBPACK_IMPORTED_MODULE_6__.MachineLearningSettings, + StorageSettings: _StorageSettings_StorageSettings__WEBPACK_IMPORTED_MODULE_7__.StorageSettings, + DangerZone: _DangerZone__WEBPACK_IMPORTED_MODULE_2__.DangerZone + } +}; + +/***/ }), + +/***/ "./src/pages/index.js": +/*!****************************!*\ + !*** ./src/pages/index.js ***! + \****************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Pages": () => (/* binding */ Pages) +/* harmony export */ }); +/* harmony import */ var _PeoplePage_PeoplePage__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PeoplePage/PeoplePage */ "./src/pages/PeoplePage/PeoplePage.js"); +/* harmony import */ var _Projects_Projects__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Projects/Projects */ "./src/pages/Projects/Projects.js"); + + +const Pages = [_PeoplePage_PeoplePage__WEBPACK_IMPORTED_MODULE_0__.PeoplePage, _Projects_Projects__WEBPACK_IMPORTED_MODULE_1__.ProjectsPage]; + +/***/ }), + +/***/ "./src/providers/ApiProvider.js": +/*!**************************************!*\ + !*** ./src/providers/ApiProvider.js ***! + \**************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ApiContext": () => (/* binding */ ApiContext), +/* harmony export */ "ApiProvider": () => (/* binding */ ApiProvider), +/* harmony export */ "useAPI": () => (/* binding */ useAPI) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _components_Error_Error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../components/Error/Error */ "./src/components/Error/Error.js"); +/* harmony import */ var _components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../components/Modal/Modal */ "./src/components/Modal/Modal.js"); +/* harmony import */ var _config_ApiConfig__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../config/ApiConfig */ "./src/config/ApiConfig.js"); +/* harmony import */ var _utils_api_proxy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/api-proxy */ "./src/utils/api-proxy.js"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/helpers */ "./src/utils/helpers.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + +const API = new _utils_api_proxy__WEBPACK_IMPORTED_MODULE_4__.APIProxy(_config_ApiConfig__WEBPACK_IMPORTED_MODULE_3__.API_CONFIG); +const ApiContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(); +ApiContext.displayName = 'ApiContext'; + +const errorFormatter = result => { + var _response$detail, _response$detail2, _response$exc_info, _response$validation_; + + const { + response + } = result; + const isShutdown = String((_response$detail = response === null || response === void 0 ? void 0 : response.detail) !== null && _response$detail !== void 0 ? _response$detail : result === null || result === void 0 ? void 0 : result.error) === 'Failed to fetch'; + return { + isShutdown, + title: result.error ? "运行时错误" : "服务员错误", + message: (_response$detail2 = response === null || response === void 0 ? void 0 : response.detail) !== null && _response$detail2 !== void 0 ? _response$detail2 : result === null || result === void 0 ? void 0 : result.error, + stacktrace: (_response$exc_info = response === null || response === void 0 ? void 0 : response.exc_info) !== null && _response$exc_info !== void 0 ? _response$exc_info : null, + version: response === null || response === void 0 ? void 0 : response.version, + validation: Object.entries((_response$validation_ = response === null || response === void 0 ? void 0 : response.validation_errors) !== null && _response$validation_ !== void 0 ? _response$validation_ : {}) + }; +}; + +const handleError = async (response, showModal = true) => { + let result = response; + + if (result instanceof Response) { + result = await API.generateError(response); + } + + if (response.status === 401) { + location.href = (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_5__.absoluteURL)("/"); + return; + } + + if (showModal) { + const { + isShutdown, + ...formattedError + } = errorFormatter(result); + (0,_components_Modal_Modal__WEBPACK_IMPORTED_MODULE_2__.modal)({ + allowClose: true, + simple: true, + body: isShutdown ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Error_Error__WEBPACK_IMPORTED_MODULE_1__.ErrorWrapper, { + possum: false, + title: "无法连接", + message: "服务器无响应" + }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Error_Error__WEBPACK_IMPORTED_MODULE_1__.ErrorWrapper, { ...formattedError + }), + style: { + width: 680 + } + }); + } +}; + +const ApiProvider = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(({ + children +}, ref) => { + const [error, setError] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + const callApi = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async (method, { + params = {}, + errorFilter, + ...rest + } = {}) => { + setError(null); + const result = await API[method](params, rest); + + if (result.error) { + const shouldCatchError = (errorFilter === null || errorFilter === void 0 ? void 0 : errorFilter(result)) === false; + + if (!errorFilter || shouldCatchError) { + setError(result); + handleError(result, contextValue.showModal); + return null; + } + } + + return result; + }, []); + const contextValue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => ({ + api: API, + callApi, + handleError, + error, + showModal: true, + errorFormatter, + + isValidMethod(...args) { + return API.isValidMethod(...args); + } + + }), [error]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (ref) { + ref.current = contextValue; + } + }, [ref]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(ApiContext.Provider, { + value: contextValue, + children: children + }); +}); +const useAPI = () => { + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(ApiContext); +}; + +/***/ }), + +/***/ "./src/providers/AppStoreProvider.tsx": +/*!********************************************!*\ + !*** ./src/providers/AppStoreProvider.tsx ***! + \********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "AppStoreProvider": () => (/* binding */ AppStoreProvider), +/* harmony export */ "useAppStore": () => (/* binding */ useAppStore) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + +const AppStoreContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext({}); +AppStoreContext.displayName = 'AppStoreContext'; +const AppStoreProvider = ({ + children +}) => { + const [store, setStore] = react__WEBPACK_IMPORTED_MODULE_0__.useState({}); + const update = react__WEBPACK_IMPORTED_MODULE_0__.useCallback(newData => { + setStore({ ...store, + ...(newData !== null && newData !== void 0 ? newData : {}) + }); + }, [store]); + const contextValue = react__WEBPACK_IMPORTED_MODULE_0__.useMemo(() => ({ + store, + update + }), [store, update]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(AppStoreContext.Provider, { + value: contextValue, + children: children + }); +}; +const useAppStore = () => { + return react__WEBPACK_IMPORTED_MODULE_0__.useContext(AppStoreContext); +}; + +/***/ }), + +/***/ "./src/providers/ConfigProvider.js": +/*!*****************************************!*\ + !*** ./src/providers/ConfigProvider.js ***! + \*****************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ConfigContext": () => (/* binding */ ConfigContext), +/* harmony export */ "ConfigConsumer": () => (/* binding */ ConfigConsumer), +/* harmony export */ "ConfigProvider": () => (/* binding */ ConfigProvider), +/* harmony export */ "useConfig": () => (/* binding */ useConfig) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + +const ConfigContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(window.APP_SETTINGS); +ConfigContext.displayName = "ConfigContext"; +const ConfigConsumer = ConfigContext.Consumer; +const ConfigProvider = ({ + children +}) => { + var _window$APP_SETTINGS; + + const [config, setConfig] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)((_window$APP_SETTINGS = window.APP_SETTINGS) !== null && _window$APP_SETTINGS !== void 0 ? _window$APP_SETTINGS : {}); + + const update = newConfig => { + if (!newConfig) return; + setConfig(newConfig); + }; + + const contextValue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + return { ...config, + update + }; + }, [config]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(ConfigContext.Provider, { + value: contextValue, + children: children + }); +}; +const useConfig = () => { + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(ConfigContext); +}; + +/***/ }), + +/***/ "./src/providers/CurrentUser.js": +/*!**************************************!*\ + !*** ./src/providers/CurrentUser.js ***! + \**************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "CurrentUserProvider": () => (/* binding */ CurrentUserProvider), +/* harmony export */ "useCurrentUser": () => (/* binding */ useCurrentUser) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _ApiProvider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + +const CurrentUserContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(); +const CurrentUserProvider = ({ + children +}) => { + const api = (0,_ApiProvider__WEBPACK_IMPORTED_MODULE_1__.useAPI)(); + const [user, setUser] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(); + const fetch = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + api.callApi('me').then(user => { + setUser(user); + }); + }, [api.callApi]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + fetch(); + }, [fetch]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(CurrentUserContext.Provider, { + value: { + user, + fetch + }, + children: children + }); +}; +const useCurrentUser = () => { + var _useContext; + + return (_useContext = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(CurrentUserContext)) !== null && _useContext !== void 0 ? _useContext : {}; +}; + +/***/ }), + +/***/ "./src/providers/LibraryProvider.js": +/*!******************************************!*\ + !*** ./src/providers/LibraryProvider.js ***! + \******************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "LibraryContext": () => (/* binding */ LibraryContext), +/* harmony export */ "LibraryProvider": () => (/* binding */ LibraryProvider), +/* harmony export */ "useLibrary": () => (/* binding */ useLibrary) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + +const libraryQueue = new Map(); +const libRequest = new Map(); + +const requestLabelStudio = libraries => async library => { + var _libraryQueue$get; + + const { + scriptSrc, + cssSrc, + checkAvailability + } = libraries[library]; + const availableLibrary = checkAvailability(); + const queueSet = (_libraryQueue$get = libraryQueue.get(library)) !== null && _libraryQueue$get !== void 0 ? _libraryQueue$get : new Set(); + libraryQueue.set(library, queueSet); + if (availableLibrary) return availableLibrary; + const requestResolver = new Promise(resolve => { + queueSet.add(() => { + setTimeout(() => { + resolve(checkAvailability()); + }, 10); + }); + }); + + if (!libRequest.has(library)) { + libRequest.set(library, (async () => { + const assets = []; + + if (scriptSrc) { + assets.push(new Promise(resolve => { + const script = document.createElement('script'); + script.type = 'text/javascript'; + + script.onload = () => { + resolve(); + }; + + script.src = scriptSrc; + script.dataset.replaced = true; + document.head.appendChild(script); + })); + } + + if (cssSrc) { + assets.push(new Promise(resolve => { + const link = document.createElement('link'); + link.rel = "stylesheet"; + link.type = "text/css"; + + link.onload = () => { + resolve(); + }; + + link.href = cssSrc; + link.dataset.replaced = true; + document.head.appendChild(link); + })); + } + + await Promise.all(assets); + queueSet.forEach(resolver => resolver()); + })()); + } + + return requestResolver; +}; + +const LibraryContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)({}); +const LibraryProvider = ({ + libraries, + children +}) => { + const requestLibrary = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + return requestLabelStudio(libraries); + }, [libraries]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(LibraryContext.Provider, { + value: { + requestLibrary + }, + children: children + }); +}; +const useLibrary = libraryName => { + const ctx = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(LibraryContext); + const [library, setLibrary] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(); + const fetchLibrary = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { + const libLoaded = await ctx.requestLibrary(libraryName); + setLibrary(!!libLoaded); + }, [ctx, libraryName]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + fetchLibrary(); + }, [fetchLibrary]); + return library; +}; + +/***/ }), + +/***/ "./src/providers/MultiProvider.js": +/*!****************************************!*\ + !*** ./src/providers/MultiProvider.js ***! + \****************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "MultiProvider": () => (/* binding */ MultiProvider) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); + +const MultiProvider = props => { + var _props$providers; + + let content = props.children || null; + /* Error/Validation */ + + if (!props.providers) { + throw "MultiProvider: Missing providers prop"; + } + + if (!props.children) { + throw "MultiProvider: Missing children"; + } // Turn object into an array + // const numberOfProviders = props.providers.size; + + + const numberOfProviders = props.providers.length; + + if (!numberOfProviders) { + // Providers prop is empty, r + return content; + } + + [...((_props$providers = props.providers) !== null && _props$providers !== void 0 ? _props$providers : [])].reverse().forEach(provider => { + content = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.cloneElement(provider, null, content); + }); + return content; +}; + +/***/ }), + +/***/ "./src/providers/ProjectProvider.tsx": +/*!*******************************************!*\ + !*** ./src/providers/ProjectProvider.tsx ***! + \*******************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ProjectContext": () => (/* binding */ ProjectContext), +/* harmony export */ "ProjectProvider": () => (/* binding */ ProjectProvider), +/* harmony export */ "useProject": () => (/* binding */ useProject) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var shallow_equal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! shallow-equal */ "./node_modules/shallow-equal/dist/index.esm.js"); +/* harmony import */ var _ApiProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ApiProvider */ "./src/providers/ApiProvider.js"); +/* harmony import */ var _AppStoreProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./AppStoreProvider */ "./src/providers/AppStoreProvider.tsx"); +/* harmony import */ var _RoutesProvider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./RoutesProvider */ "./src/providers/RoutesProvider.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + +const ProjectContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)({}); +ProjectContext.displayName = 'ProjectContext'; +const projectCache = new Map(); +const ProjectProvider = ({ + children +}) => { + var _projectCache$get; + + const api = (0,_ApiProvider__WEBPACK_IMPORTED_MODULE_2__.useAPI)(); + const params = (0,_RoutesProvider__WEBPACK_IMPORTED_MODULE_4__.useParams)(); + const { + update: updateStore + } = (0,_AppStoreProvider__WEBPACK_IMPORTED_MODULE_3__.useAppStore)(); // @todo use null for missed project data + + const [projectData, setProjectData] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)((_projectCache$get = projectCache.get(+params.id)) !== null && _projectCache$get !== void 0 ? _projectCache$get : {}); + const fetchProject = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async (id, force = false) => { + const finalProjectId = +(id !== null && id !== void 0 ? id : params.id); + if (isNaN(finalProjectId)) return; + + if (!force && projectCache.has(finalProjectId)) { + setProjectData({ ...projectCache.get(finalProjectId) + }); + } + + const result = await api.callApi('project', { + params: { + pk: finalProjectId + }, + errorFilter: () => false + }); + const projectInfo = result; + + if ((0,shallow_equal__WEBPACK_IMPORTED_MODULE_1__.shallowEqualObjects)(projectData, projectInfo) === false) { + setProjectData(projectInfo); + updateStore({ + project: projectInfo + }); + projectCache.set(projectInfo.id, projectInfo); + } + + return projectInfo; + }, [params]); + const updateProject = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async fields => { + const result = await api.callApi('updateProject', { + params: { + pk: projectData.id + }, + body: fields + }); + + if (result.$meta) { + setProjectData(result); + updateStore({ + project: result + }); + } + + return result; + }, [projectData, setProjectData, updateStore]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (+params.id !== (projectData === null || projectData === void 0 ? void 0 : projectData.id)) { + setProjectData({}); + } + + fetchProject(); + }, [params]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + return () => projectCache.clear(); + }, []); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(ProjectContext.Provider, { + value: { + project: projectData, + fetchProject, + updateProject, + + invalidateCache() { + projectCache.clear(); + setProjectData({}); + } + + }, + children: children + }); +}; // without this extra typing VSCode doesn't see the type after import :( + +const useProject = () => { + var _useContext; + + return (_useContext = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(ProjectContext)) !== null && _useContext !== void 0 ? _useContext : {}; +}; + +/***/ }), + +/***/ "./src/providers/RoutesProvider.js": +/*!*****************************************!*\ + !*** ./src/providers/RoutesProvider.js ***! + \*****************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "RoutesContext": () => (/* binding */ RoutesContext), +/* harmony export */ "RoutesProvider": () => (/* binding */ RoutesProvider), +/* harmony export */ "useRoutesMap": () => (/* binding */ useRoutesMap), +/* harmony export */ "useFindRouteComponent": () => (/* binding */ useFindRouteComponent), +/* harmony export */ "useBreadcrumbs": () => (/* binding */ useBreadcrumbs), +/* harmony export */ "useCurrentPath": () => (/* binding */ useCurrentPath), +/* harmony export */ "useParams": () => (/* binding */ useParams), +/* harmony export */ "useContextComponent": () => (/* binding */ useContextComponent), +/* harmony export */ "useFixedLocation": () => (/* binding */ useFixedLocation), +/* harmony export */ "useContextProps": () => (/* binding */ useContextProps) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react-router */ "./node_modules/react-router/esm/react-router.js"); +/* harmony import */ var _pages__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../pages */ "./src/pages/index.js"); +/* harmony import */ var _services_breadrumbs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../services/breadrumbs */ "./src/services/breadrumbs.js"); +/* harmony import */ var _utils_routeHelpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/routeHelpers */ "./src/utils/routeHelpers.js"); +/* harmony import */ var _AppStoreProvider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./AppStoreProvider */ "./src/providers/AppStoreProvider.tsx"); +/* harmony import */ var _ConfigProvider__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ConfigProvider */ "./src/providers/ConfigProvider.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + +const RoutesContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(); + +const findMacthingComponents = (path, routesMap, parentPath = "") => { + const result = []; + const match = routesMap.find(route => { + const matchingPath = `${parentPath}${route.path}`; + const match = (0,react_router__WEBPACK_IMPORTED_MODULE_7__.matchPath)(path, { + path: matchingPath + }); + return match; + }); + + if (match) { + const routePath = `${parentPath}${match.path}`; + result.push({ ...match, + path: routePath + }); + + if (match.routes) { + result.push(...findMacthingComponents(path, match.routes, routePath)); + } + } + + return result; +}; + +const RoutesProvider = ({ + children +}) => { + const history = (0,react_router__WEBPACK_IMPORTED_MODULE_7__.useHistory)(); + const location = useFixedLocation(); + const config = (0,_ConfigProvider__WEBPACK_IMPORTED_MODULE_5__.useConfig)(); + const { + store + } = (0,_AppStoreProvider__WEBPACK_IMPORTED_MODULE_4__.useAppStore)(); + const breadcrumbs = (0,_services_breadrumbs__WEBPACK_IMPORTED_MODULE_2__.useBreadcrumbControls)(); + const [currentContext, setCurrentContext] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + const [currentContextProps, setCurrentContextProps] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + const routesMap = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + return (0,_utils_routeHelpers__WEBPACK_IMPORTED_MODULE_3__.pageSetToRoutes)(_pages__WEBPACK_IMPORTED_MODULE_1__.Pages, { + config, + store + }); + }, [location, config, store, history]); + const routesChain = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + return findMacthingComponents(location.pathname, routesMap); + }, [location, routesMap]); + const lastRoute = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + return routesChain.filter(r => !r.modal).slice(-1)[0]; + }, [routesChain]); + const [currentPath, setCurrentPath] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(lastRoute === null || lastRoute === void 0 ? void 0 : lastRoute.path); + const contextValue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => ({ + routesMap, + breadcrumbs, + currentContext, + setContextProps: setCurrentContextProps, + path: currentPath, + findComponent: path => findMacthingComponents(path, routesMap) + }), [breadcrumbs, routesMap, currentContext, currentPath, setCurrentContext]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + const ContextComponent = lastRoute === null || lastRoute === void 0 ? void 0 : lastRoute.context; + setCurrentContext({ + component: ContextComponent !== null && ContextComponent !== void 0 ? ContextComponent : null, + props: currentContextProps + }); + setCurrentPath(lastRoute === null || lastRoute === void 0 ? void 0 : lastRoute.path); + + try { + const crumbs = routesChain.map(route => { + var _ref, _route$component$disp, _route$component; + + const params = (0,react_router__WEBPACK_IMPORTED_MODULE_7__.matchPath)(location.pathname, { + path: route.path + }); + const path = (0,react_router__WEBPACK_IMPORTED_MODULE_7__.generatePath)(route.path, params.params); + const title = route.title instanceof Function ? route.title() : route.title; + const key = (_ref = (_route$component$disp = (_route$component = route.component) === null || _route$component === void 0 ? void 0 : _route$component.displayName) !== null && _route$component$disp !== void 0 ? _route$component$disp : route.key) !== null && _ref !== void 0 ? _ref : path; + return { + path, + title, + key + }; + }).filter(c => !!c.title); + (0,_services_breadrumbs__WEBPACK_IMPORTED_MODULE_2__.setBreadcrumbs)(crumbs); + } catch (err) { + console.log(err); + } + }, [location, routesMap, currentContextProps, routesChain, lastRoute]); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(RoutesContext.Provider, { + value: contextValue, + children: children + }); +}; +const useRoutesMap = () => { + var _useContext$routesMap, _useContext; + + return (_useContext$routesMap = (_useContext = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(RoutesContext)) === null || _useContext === void 0 ? void 0 : _useContext.routesMap) !== null && _useContext$routesMap !== void 0 ? _useContext$routesMap : []; +}; +const useFindRouteComponent = () => { + var _useContext$findCompo, _useContext2; + + return (_useContext$findCompo = (_useContext2 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(RoutesContext)) === null || _useContext2 === void 0 ? void 0 : _useContext2.findComponent) !== null && _useContext$findCompo !== void 0 ? _useContext$findCompo : () => null; +}; +const useBreadcrumbs = () => { + var _useContext$breadcrum, _useContext3; + + return (_useContext$breadcrum = (_useContext3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(RoutesContext)) === null || _useContext3 === void 0 ? void 0 : _useContext3.breadcrumbs) !== null && _useContext$breadcrum !== void 0 ? _useContext$breadcrum : []; +}; +const useCurrentPath = () => { + var _useContext4; + + return (_useContext4 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(RoutesContext)) === null || _useContext4 === void 0 ? void 0 : _useContext4.path; +}; +const useParams = () => { + const location = useFixedLocation(); + const currentPath = useCurrentPath(); + const match = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + var _urlParams$params; + + const parsedLocation = location.search.replace(/^\?/, '').split("&").map(pair => { + const [key, value] = pair.split('=').map(p => decodeURIComponent(p)); + return [key, value]; + }); + const search = Object.fromEntries(parsedLocation); + const urlParams = (0,react_router__WEBPACK_IMPORTED_MODULE_7__.matchPath)(location.pathname, currentPath !== null && currentPath !== void 0 ? currentPath : ""); + return { ...search, + ...((_urlParams$params = urlParams === null || urlParams === void 0 ? void 0 : urlParams.params) !== null && _urlParams$params !== void 0 ? _urlParams$params : {}) + }; + }, [location, currentPath]); + return match !== null && match !== void 0 ? match : {}; +}; +const useContextComponent = () => { + var _ctx$currentContext; + + const ctx = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(RoutesContext); + const { + component: ContextComponent, + props: contextProps + } = (_ctx$currentContext = ctx === null || ctx === void 0 ? void 0 : ctx.currentContext) !== null && _ctx$currentContext !== void 0 ? _ctx$currentContext : {}; + return { + ContextComponent, + contextProps + }; +}; +const useFixedLocation = () => { + const location = (0,react_router__WEBPACK_IMPORTED_MODULE_7__.useLocation)(); + const result = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + var _location$location; + + return (_location$location = location.location) !== null && _location$location !== void 0 ? _location$location : location; + }, [location]); + return result; +}; +const useContextProps = () => { + const setProps = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(RoutesContext).setContextProps; + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => setProps, [setProps]); +}; + +/***/ }), + +/***/ "./src/routes/ProjectRoutes.js": +/*!*************************************!*\ + !*** ./src/routes/ProjectRoutes.js ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ProjectRoutes": () => (/* binding */ ProjectRoutes) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../providers/RoutesProvider */ "./src/providers/RoutesProvider.js"); +/* harmony import */ var _utils_routeHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/routeHelpers */ "./src/utils/routeHelpers.js"); +/* harmony import */ var _RouteWithStaticFallback__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./RouteWithStaticFallback */ "./src/routes/RouteWithStaticFallback.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + +const ProjectRoutes = ({ + content +}) => { + const routes = (0,_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_1__.useRoutesMap)(); + const resolvedRoutes = (0,_utils_routeHelpers__WEBPACK_IMPORTED_MODULE_2__.resolveRoutes)(routes, { + content + }); + return resolvedRoutes ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_RouteWithStaticFallback__WEBPACK_IMPORTED_MODULE_3__.RouteWithStaticFallback, { + path: "/", + children: resolvedRoutes + }) : null; +}; + +/***/ }), + +/***/ "./src/routes/RouteWithStaticFallback.js": +/*!***********************************************!*\ + !*** ./src/routes/RouteWithStaticFallback.js ***! + \***********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "RouteWithStaticFallback": () => (/* binding */ RouteWithStaticFallback) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react-router */ "./node_modules/react-router/esm/react-router.js"); +/* harmony import */ var _app_StaticContent_StaticContent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../app/StaticContent/StaticContent */ "./src/app/StaticContent/StaticContent.js"); +/* harmony import */ var _components_Menubar_Menubar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../components/Menubar/Menubar */ "./src/components/Menubar/Menubar.js"); +/* harmony import */ var _config_Sentry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../config/Sentry */ "./src/config/Sentry.ts"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + + + + + + +const extractModalRoutes = children => { + const modalRoutes = []; + const regularRoutes = []; + + try { + react__WEBPACK_IMPORTED_MODULE_0__.Children.toArray(children).forEach(child => { + var _child$props; + + if (child !== null && child !== void 0 && (_child$props = child.props) !== null && _child$props !== void 0 && _child$props.modal) modalRoutes.push(child);else regularRoutes.push(child); + }); + } catch (err) { + console.log(err); + console.log({ + children + }); + } + + return [modalRoutes, regularRoutes]; +}; +/** + * Router wrapper that handles 404 pages + */ + + +const RouteWithStaticFallback = ({ + children, + render, + route, + component, + staticComponent, + ...props +}) => { + const menubar = react__WEBPACK_IMPORTED_MODULE_0__.useContext(_components_Menubar_Menubar__WEBPACK_IMPORTED_MODULE_2__.MenubarContext); + + const notFoundRenderer = children => { + let modalRoutes = []; + let regularRoutes = []; + + if (children.props && children.props.children) { + [modalRoutes, regularRoutes] = extractModalRoutes(children.props.children); + children = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.cloneElement(children, { + children: regularRoutes + }); + } else if (Array.isArray(children)) { + [modalRoutes, regularRoutes] = extractModalRoutes(children); + children = regularRoutes; + } + + const Static = () => { + if ((menubar === null || menubar === void 0 ? void 0 : menubar.contextIsSet(null)) === false) menubar === null || menubar === void 0 ? void 0 : menubar.setContext(null); + return staticComponent !== null && staticComponent !== void 0 ? staticComponent : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_app_StaticContent_StaticContent__WEBPACK_IMPORTED_MODULE_1__.StaticContent, { + id: "main-content" + }); + }; + + const exactRoutes = modalRoutes.reduce((res, route) => { + if (route.props.exact) { + res.exact.push(route); + } else { + res.modal.push(route); + } + + return res; + }, { + exact: [], + modal: [] + }); + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.Fragment, { + children: [exactRoutes.modal, /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)(react_router__WEBPACK_IMPORTED_MODULE_5__.Switch, { + children: [exactRoutes.exact, children, /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_config_Sentry__WEBPACK_IMPORTED_MODULE_3__.SentryRoute, { + exact: true, + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(Static, {}) + })] + })] + }); + }; + + const routeProps = {}; + + if (render) { + routeProps.render = props => notFoundRenderer(render(props)); + } else if (children instanceof Function) { + routeProps.children = props => notFoundRenderer(children(props)); + } else if (component) { + routeProps.component = props => notFoundRenderer(component(props)); + } else { + routeProps.children = notFoundRenderer(children); + } + + return route !== false ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_config_Sentry__WEBPACK_IMPORTED_MODULE_3__.SentryRoute, { ...props, + ...routeProps + }) : notFoundRenderer(children); +}; + +/***/ }), + +/***/ "./src/services/breadrumbs.js": +/*!************************************!*\ + !*** ./src/services/breadrumbs.js ***! + \************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "setBreadcrumbs": () => (/* binding */ setBreadcrumbs), +/* harmony export */ "addCrumb": () => (/* binding */ addCrumb), +/* harmony export */ "deleteCrumb": () => (/* binding */ deleteCrumb), +/* harmony export */ "addAction": () => (/* binding */ addAction), +/* harmony export */ "deleteAction": () => (/* binding */ deleteAction), +/* harmony export */ "useBreadcrumbControls": () => (/* binding */ useBreadcrumbControls) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_singleton_hook__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-singleton-hook */ "./node_modules/react-singleton-hook/es/index.js"); +/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/helpers */ "./src/utils/helpers.js"); + + + +const initialBreadcrumbs = []; + +const noop = () => { + if (true) { + console.warn("Breadcrumbs must be initialized first"); + } +}; + +let setBreadcrumbs = noop; +let addCrumb = noop; +let deleteCrumb = noop; +let addAction = noop; +let deleteAction = noop; +let localCrumbs = []; +const useBreadcrumbControls = (0,react_singleton_hook__WEBPACK_IMPORTED_MODULE_1__.singletonHook)(initialBreadcrumbs, () => { + const [breadcrumbs, setBreadcrumbsState] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(initialBreadcrumbs); + localCrumbs = breadcrumbs; + + setBreadcrumbs = newCrumbs => { + const crumbs = [...(newCrumbs !== null && newCrumbs !== void 0 ? newCrumbs : [])]; + setBreadcrumbsState(crumbs); + localCrumbs = crumbs; + }; + + addCrumb = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(crumb => { + if (!(0,_utils_helpers__WEBPACK_IMPORTED_MODULE_2__.isDefined)(crumb === null || crumb === void 0 ? void 0 : crumb.key)) throw Error("Crumb must have a key"); + const crumbs = [...localCrumbs, crumb]; + setBreadcrumbs(crumbs); + localCrumbs = crumbs; + }, [breadcrumbs]); + deleteCrumb = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(key => { + const crumbs = localCrumbs.filter(c => c.key !== key); + setBreadcrumbs(crumbs); + localCrumbs = crumbs; + }, [breadcrumbs]); + addAction = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)((key, onClick) => { + const crumbs = localCrumbs.map(crumb => { + if (crumb.key === key) { + return { ...crumb, + onClick: onClick + }; + } + + return crumb; + }); + setBreadcrumbs(crumbs); + localCrumbs = crumbs; + }, [breadcrumbs]); + deleteAction = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(key => { + const crumbs = localCrumbs.map(crumb => { + if (crumb.key === key) delete crumb.onClick; + return crumb; + }); + setBreadcrumbs(crumbs); + localCrumbs = crumbs; + }, [breadcrumbs]); + return breadcrumbs; +}); + +/***/ }), + +/***/ "./src/utils/api-proxy.js": +/*!********************************!*\ + !*** ./src/utils/api-proxy.js ***! + \********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "APIProxy": () => (/* binding */ APIProxy) +/* harmony export */ }); +/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./helpers */ "./src/utils/helpers.js"); +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * @typedef {string | { + * path: string, + * method: RequestMethod, + * convert: ResponseConverter, + * mock: (url: string, request: Request) => Dict + * body: Dict, + * headers: Headers, + * }} EndpointConfig + */ + +/** + * @typedef {Dict} Endpoints + */ + +/** + * @typedef {{ + * gateway: string | URL, + * endpoints: Dict, + * commonHeaders: Dict, + * mockDelay: number, + * mockDisabled: boolean, + * sharedParams: Dict, + * alwaysExpectJSON: boolean, + * }} APIProxyOptions + */ + +/** + * Proxy layer for any type of API's + */ + +class APIProxy { + /** @type {string} */ + + /** @type {Dict} */ + + /** @type {number} */ + + /** @type {boolean} */ + + /** @type {"same-origin"|"cors"} */ + + /** @type {Dict} */ + + /** + * Constructor + * @param {APIProxyOptions} options + */ + constructor(options) { + var _options$commonHeader, _options$mockDelay, _options$mockDisabled, _options$sharedParams, _options$alwaysExpect; + + _defineProperty(this, "gateway", null); + + _defineProperty(this, "commonHeaders", {}); + + _defineProperty(this, "mockDelay", 0); + + _defineProperty(this, "mockDisabled", false); + + _defineProperty(this, "requestMode", "same-origin"); + + _defineProperty(this, "sharedParams", {}); + + this.commonHeaders = (_options$commonHeader = options.commonHeaders) !== null && _options$commonHeader !== void 0 ? _options$commonHeader : {}; + this.gateway = this.resolveGateway(options.gateway); + this.requestMode = this.detectMode(); + this.mockDelay = (_options$mockDelay = options.mockDelay) !== null && _options$mockDelay !== void 0 ? _options$mockDelay : 0; + this.mockDisabled = (_options$mockDisabled = options.mockDisabled) !== null && _options$mockDisabled !== void 0 ? _options$mockDisabled : false; + this.sharedParams = (_options$sharedParams = options.sharedParams) !== null && _options$sharedParams !== void 0 ? _options$sharedParams : {}; + this.alwaysExpectJSON = (_options$alwaysExpect = options.alwaysExpectJSON) !== null && _options$alwaysExpect !== void 0 ? _options$alwaysExpect : true; + this.resolveMethods(options.endpoints); + } + /** + * Check if method exists + * @param {String} method + */ + + + isValidMethod(method) { + return this[method] instanceof Function; + } + /** + * Resolves gateway to a full URL + * @returns {string} + */ + + + resolveGateway(url) { + if (url instanceof URL) { + return url.toString(); + } + + try { + return new URL(url).toString(); + } catch (e) { + const gateway = new URL(window.location.href); + gateway.search = ""; + gateway.hash = ""; + + if (url[0] === "/") { + gateway.pathname = url.replace(/([/])$/, ""); + } else { + gateway.pathname = `${gateway.pathname}/${url}`.replace(/([/]+)/g, "/").replace(/([/])$/, ""); + } + + return gateway.toString(); + } + } + /** + * Detect RequestMode. + * @returns {"same-origin"|"cors"} + */ + + + detectMode() { + const currentOrigin = window.location.origin; + const gatewayOrigin = new URL(this.gateway).origin; + return currentOrigin === gatewayOrigin ? "same-origin" : "cors"; + } + /** + * Build methods list from endpoints + * @private + */ + + + resolveMethods(endpoints, parentPath) { + if (endpoints) { + const methods = new Map(Object.entries(endpoints)); + methods.forEach((settings, methodName) => { + const { + scope, + ...restSettings + } = this.getSettings(settings); + Object.defineProperty(this, methodName, { + value: this.createApiCallExecutor(restSettings, [parentPath]) + }); + Object.defineProperty(this, `${methodName}Raw`, { + value: this.createApiCallExecutor(restSettings, [parentPath], true) + }); + if (scope) this.resolveMethods(scope, [...(parentPath !== null && parentPath !== void 0 ? parentPath : []), restSettings.path]); + }); + } + } + /** + * Actual API call + * @param {EndpointConfig} settings + * @private + */ + + + createApiCallExecutor(methodSettings, parentPath, raw = false) { + return async (urlParams, { + headers, + body + } = {}) => { + let responseResult, responseMeta; + + try { + var _this$sharedParams, _methodSettings$metho, _this$commonHeaders, _methodSettings$heade; + + const finalParams = { ...(urlParams !== null && urlParams !== void 0 ? urlParams : {}), + ...((_this$sharedParams = this.sharedParams) !== null && _this$sharedParams !== void 0 ? _this$sharedParams : {}) + }; + const { + method, + url: apiCallURL + } = this.createUrl(methodSettings.path, finalParams, parentPath); + const requestMethod = method !== null && method !== void 0 ? method : ((_methodSettings$metho = methodSettings.method) !== null && _methodSettings$metho !== void 0 ? _methodSettings$metho : "get").toUpperCase(); + const initialheaders = Object.assign(this.getDefaultHeaders(requestMethod), (_this$commonHeaders = this.commonHeaders) !== null && _this$commonHeaders !== void 0 ? _this$commonHeaders : {}, (_methodSettings$heade = methodSettings.headers) !== null && _methodSettings$heade !== void 0 ? _methodSettings$heade : {}, headers !== null && headers !== void 0 ? headers : {}); + const requestHeaders = new Headers(initialheaders); + const requestParams = { + method: requestMethod, + headers: requestHeaders, + mode: this.requestMode, + credentials: this.requestMode === "cors" ? "omit" : "same-origin" + }; + + if (requestMethod !== "GET") { + const contentType = requestHeaders.get("Content-Type"); + const { + sharedParams + } = this; + let extendedBody = body !== null && body !== void 0 ? body : {}; + + if (extendedBody instanceof FormData) { + Object.entries(sharedParams !== null && sharedParams !== void 0 ? sharedParams : {}).forEach(([key, value]) => { + extendedBody.append(key, value); + }); + } else { + Object.assign(extendedBody, { ...(sharedParams !== null && sharedParams !== void 0 ? sharedParams : {}), + ...(body !== null && body !== void 0 ? body : {}) + }); + } + + if (extendedBody instanceof FormData) { + requestParams.body = extendedBody; + } else if (contentType === "multipart/form-data") { + requestParams.body = this.createRequestBody(extendedBody); + } else if (contentType === "application/json") { + requestParams.body = this.bodyToJSON(extendedBody); + } else { + requestParams.body = extendedBody; + } // @todo better check for files maybe? + + + if (contentType === "multipart/form-data") { + // fetch will set correct header with boundaries + requestHeaders.delete('Content-Type'); + } + } + /** @type {Response} */ + + + let rawResponse; + + if (methodSettings.mock && "development" === "development" && !this.mockDisabled) { + rawResponse = await this.mockRequest(apiCallURL, urlParams, requestParams, methodSettings); + } else { + rawResponse = await fetch(apiCallURL, requestParams); + } + + responseMeta = { + headers: new Map(Array.from(rawResponse.headers)), + status: rawResponse.status, + url: rawResponse.url + }; + if (raw) return rawResponse; + + if (rawResponse.ok) { + const responseText = await rawResponse.text(); + + try { + const responseData = rawResponse.status !== 204 ? JSON.parse(this.alwaysExpectJSON ? responseText : responseText || "{}") : { + ok: true + }; + + if (methodSettings.convert instanceof Function) { + return await methodSettings.convert(responseData); + } + + responseResult = responseData; + } catch (err) { + responseResult = this.generateException(err, responseText); + } + } else { + responseResult = this.generateError(rawResponse); + } + } catch (exception) { + responseResult = this.generateException(exception); + } + + Object.defineProperty(responseResult, '$meta', { + value: responseMeta, + configurable: false, + enumerable: false, + writable: false + }); + return responseResult; + }; + } + /** + * Retrieve method-specific settings + * @private + * @param {EndpointConfig} settings + * @returns {EndpointConfig} + */ + + + getSettings(settings) { + if (typeof settings === "string") { + settings = { + path: settings + }; + } + + return { + method: "GET", + mock: undefined, + convert: undefined, + scope: undefined, + ...settings + }; + } + + getDefaultHeaders(method) { + switch (method) { + case "POST": + case "PATCH": + case "DELETE": + { + return { + "Content-Type": "application/json" + }; + } + + default: + return {}; + } + } + /** + * Creates a URL from gateway + endpoint path + params + * @param {string} path + * @param {Dict} data + * @private + */ + + + createUrl(endpoint, data = {}, parentPath) { + const url = new URL(this.gateway); + const usedKeys = []; + const { + path: resolvedPath, + method: resolvedMethod + } = this.resolveEndpoint(endpoint, data); + const path = [].concat(...(parentPath !== null && parentPath !== void 0 ? parentPath : []), resolvedPath).filter(p => p !== undefined).join("/").replace(/([/]+)/g, "/"); + const processedPath = path.replace(/:([^/]+)/g, (...res) => { + const keyRaw = res[1]; + const [key, optional] = keyRaw.match(/([^?]+)(\??)/).slice(1, 3); + const result = data[key]; + usedKeys.push(key); + + if (result === undefined) { + if (optional === "?") return ""; + throw new Error(`Can't find key \`${key}\` in data`); + } + + return result; + }); + url.pathname += processedPath.replace(/\/+/g, "/").replace(/\/+$/g, ""); + + if (data && typeof data === "object") { + Object.entries(data).forEach(([key, value]) => { + if (!usedKeys.includes(key)) { + url.searchParams.set(key, value); + } + }); + } + + return { + url: url.toString(), + method: resolvedMethod + }; + } + /** + * Resolves an endpoint + * @param {string|Function} endpoint + * @param {Dict} data + */ + + + resolveEndpoint(endpoint, data) { + var _finalEndpoint$match; + + let finalEndpoint; + + if (endpoint instanceof Function) { + finalEndpoint = endpoint(data); + } else { + finalEndpoint = endpoint; + } + + const methodRegexp = /^(GET|POST|PATCH|DELETE|PUT|HEAD|OPTIONS):/; + const method = (_finalEndpoint$match = finalEndpoint.match(methodRegexp)) === null || _finalEndpoint$match === void 0 ? void 0 : _finalEndpoint$match[1]; + const path = finalEndpoint.replace(methodRegexp, ""); + return { + method, + path + }; + } + /** + * Create FormData object from raw JS object + * @private + * @param {Dict} body + */ + + + createRequestBody(body) { + if (body instanceof FormData) return body; + const formData = new FormData(); + Object.entries(body).forEach(([key, value]) => { + formData.append(key, value); + }); + return formData; + } + /** + * Converts body to JSON string + * @param {Object|FormData} body + */ + + + bodyToJSON(body) { + const object = (0,_helpers__WEBPACK_IMPORTED_MODULE_0__.formDataToJPO)(body); + return JSON.stringify(object); + } + /** + * Generates an error from a Response object + * @param {Response} fetchResponse + * @private + */ + + + async generateError(fetchResponse, exception) { + var _exception$message; + + const result = (async () => { + const text = await fetchResponse.text(); + + try { + return JSON.parse(text); + } catch (e) { + return text; + } + })(); + + return { + status: fetchResponse.status, + error: ((_exception$message = exception === null || exception === void 0 ? void 0 : exception.message) !== null && _exception$message !== void 0 ? _exception$message : fetchResponse.statusText) || "Server Error", + response: await result + }; + } + /** + * Generates an error from a caught exception + * @param {Error} exception + * @private + */ + + + generateException(exception, details) { + console.error(exception); + + const parsedDetails = () => { + try { + return JSON.parse(details); + } catch (e) { + return details; + } + }; + + return { + error: exception.message, + details: parsedDetails() + }; + } + /** + * Emulate server call + * @param {string} url + * @param {Request} params + * @param {EndpointConfig} settings + */ + + + mockRequest(url, params, request, settings) { + return new Promise(async resolve => { + let response = null; + let ok = true; + + try { + const fakeRequest = new Request(request); + + if (typeof request.body === "string") { + fakeRequest.body = JSON.parse(request.body); + } + + response = await settings.mock(url, params !== null && params !== void 0 ? params : {}, fakeRequest); + } catch (err) { + console.error(err); + ok = false; + } + + setTimeout(() => { + resolve({ + ok, + + json() { + return Promise.resolve(response); + } + + }); + }, this.mockDelay); + }); + } + +} + +/***/ }), + +/***/ "./src/utils/bem.tsx": +/*!***************************!*\ + !*** ./src/utils/bem.tsx ***! + \***************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "cn": () => (/* binding */ cn), +/* harmony export */ "BemWithSpecifiContext": () => (/* binding */ BemWithSpecifiContext), +/* harmony export */ "Block": () => (/* binding */ Block), +/* harmony export */ "Elem": () => (/* binding */ Elem) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); +var _process$env$CSS_PREF; + + + +const CSS_PREFIX = (_process$env$CSS_PREF = "ls-") !== null && _process$env$CSS_PREF !== void 0 ? _process$env$CSS_PREF : 'dm-'; + +const assembleClass = (block, elem, mix, mod) => { + const rootName = block; + const elemName = elem ? `${rootName}__${elem}` : null; + const stateName = Object.entries(mod !== null && mod !== void 0 ? mod : {}).reduce((res, [key, value]) => { + const stateClass = [elemName !== null && elemName !== void 0 ? elemName : rootName]; + if (value === null || value === undefined) return res; + + if (value !== false) { + stateClass.push(key); + if (value !== true) stateClass.push(value); + res.push(stateClass.join('_')); + } + + return res; + }, []); + const finalClass = []; + finalClass.push(elemName !== null && elemName !== void 0 ? elemName : rootName); + finalClass.push(...stateName); + + if (mix) { + const mixes = Array.isArray(mix) ? mix : [mix]; + const mixMap = [].concat(...mixes).filter(m => m !== undefined && m !== null && m !== "").map(m => { + if (typeof m === 'string') { + return m; + } else { + var _m$toClassName; + + return m === null || m === void 0 ? void 0 : (_m$toClassName = m.toClassName) === null || _m$toClassName === void 0 ? void 0 : _m$toClassName.call(m); + } + }).reduce((res, cls) => [...res, ...cls.split(/\s+/)], []); + finalClass.push(...mixMap); + } + + const attachNamespace = cls => { + if (new RegExp(CSS_PREFIX).test(cls)) return cls;else return `${CSS_PREFIX}${cls}`; + }; + + return finalClass.map(attachNamespace).join(" "); +}; + +const BlockContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(null); +const cn = (block, options = {}) => { + const { + elem, + mix, + mod + } = options !== null && options !== void 0 ? options : {}; + const blockName = block; + const classNameBuilder = { + block(name) { + return cn(name, { + elem, + mix, + mod + }); + }, + + elem(name) { + return cn(block, { + elem: name, + mix, + mod + }); + }, + + mod(newMod = {}) { + const stateOverride = Object.assign({}, mod !== null && mod !== void 0 ? mod : {}, newMod); + return cn(block !== null && block !== void 0 ? block : blockName, { + elem, + mix, + mod: stateOverride + }); + }, + + mix(...mix) { + return cn(block, { + elem, + mix, + mod + }); + }, + + select(root = document) { + return root.querySelector(this.toCSSSelector()); + }, + + selectAll(root = document) { + return root.querySelectorAll(this.toCSSSelector()); + }, + + closest(root) { + return root.closest(this.toCSSSelector()); + }, + + toString() { + return assembleClass(block, elem, mix, mod); + }, + + toClassName() { + return this.toString(); + }, + + toCSSSelector() { + return `.${this.toClassName().replace(/(\s+)/g, '.')}`; + } + + }; + Object.defineProperty(classNameBuilder, 'Block', { + value: Block + }); + Object.defineProperty(classNameBuilder, 'Elem', { + value: Elem + }); + Object.defineProperty(classNameBuilder, '__class', { + value: { + block, + elem, + mix, + mod + } + }); + return classNameBuilder; +}; +const BemWithSpecifiContext = context => { + const Context = context !== null && context !== void 0 ? context : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(null); + const Block = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(({ + tag = 'div', + name, + mod, + mix, + ...rest + }, ref) => { + const rootClass = cn(name); + const finalMix = [].concat(mix).filter(cn => !!cn); + const className = rootClass.mod(mod).mix(...finalMix, rest.className).toClassName(); + const finalProps = { ...rest, + ref, + className + }; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(Context.Provider, { + value: rootClass, + children: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(tag, finalProps) + }); + }); + Block.displayName = 'Block'; + const Elem = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(({ + tag = 'div', + component, + block, + name, + mod, + mix, + ...rest + }, ref) => { + const blockCtx = react__WEBPACK_IMPORTED_MODULE_0__.useContext(Context); + const finalMix = [].concat(mix).filter(cn => !!cn); + const className = (block ? cn(block) : blockCtx).elem(name).mod(mod).mix(...finalMix, rest.className).toClassName(); + const finalProps = { ...rest, + ref, + className + }; + if (typeof tag !== 'string') finalProps.block = blockCtx; + if (component) finalProps.tag = tag; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(component !== null && component !== void 0 ? component : tag, finalProps); + }); + Elem.displayName = 'Elem'; + return { + Block, + Elem, + Context + }; +}; +const { + Block, + Elem +} = BemWithSpecifiContext(BlockContext); + +/***/ }), + +/***/ "./src/utils/colors.js": +/*!*****************************!*\ + !*** ./src/utils/colors.js ***! + \*****************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "LABELS_PALETTE": () => (/* binding */ LABELS_PALETTE), +/* harmony export */ "Palette": () => (/* binding */ Palette) +/* harmony export */ }); +const LABELS_PALETTE = "FFA39E D4380D FFC069 AD8B00 D3F261 389E0D 5CDBD3 096DD9 ADC6FF 9254DE F759AB".split(" ").map(s => "#" + s); +function* Palette(colors = LABELS_PALETTE) { + let index = 0; + + while (true) { + yield colors[index]; + index = (index + 1) % colors.length; + } +} +window.Palette = Palette; + +/***/ }), + +/***/ "./src/utils/debounce.js": +/*!*******************************!*\ + !*** ./src/utils/debounce.js ***! + \*******************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "debounce": () => (/* binding */ debounce) +/* harmony export */ }); +/** + * Returns a function, that, as long as it continues to be invoked, + * will not be triggered. The function will be called after it + * stops being called for N milliseconds. If `immediate` is passed, + * trigger the function on the leading edge, instead of the trailing. + * + * @param {function} func + * @param {number} wait + * @param {boolean} immediate + */ +function debounce(func, wait, immediate) { + let timeout; + return function (...args) { + const later = () => { + timeout = null; + + if (!immediate) { + func.apply(this, args); + } + }; + + const callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) func.apply(this, args); + }; +} + +/***/ }), + +/***/ "./src/utils/dom.js": +/*!**************************!*\ + !*** ./src/utils/dom.js ***! + \**************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "alignElements": () => (/* binding */ alignElements) +/* harmony export */ }); +/** + * @param {HTMLElement} source + * @param {HTMLElement} target + */ +const positioner = (source, target) => { + const sourcePosition = source.getBoundingClientRect(); + const targetPosition = target.getBoundingClientRect(); + return { + source: sourcePosition, + target: targetPosition, + + get top() { + return sourcePosition.top - targetPosition.height; + }, + + get bottom() { + return sourcePosition.top + sourcePosition.height; + }, + + get horizontalCenter() { + return sourcePosition.left + sourcePosition.width / 2 - targetPosition.width / 2; + }, + + get horizontalLeft() { + return sourcePosition.left; + }, + + get horizontalRight() { + return sourcePosition.left + sourcePosition.width - targetPosition.width; + } + + }; +}; + +const alignElements = (elem, target, align = 'bottom-left', padding = 0) => { + let offsetLeft = 0; + let offsetTop = 0; + const pos = positioner(elem, target); + let resultAlign = align.split('-'); + + switch (align) { + case "top-center": + offsetTop = pos.top - padding; + offsetLeft = pos.horizontalCenter; + break; + + case "top-left": + offsetTop = pos.top - padding; + offsetLeft = pos.horizontalLeft; + break; + + case "top-right": + offsetTop = pos.top - padding; + offsetLeft = pos.horizontalRight; + break; + + case "bottom-center": + offsetTop = pos.bottom + padding; + offsetLeft = pos.horizontalCenter; + break; + + case "bottom-left": + offsetTop = pos.bottom + padding; + offsetLeft = pos.horizontalLeft; + break; + + case "bottom-right": + offsetTop = pos.bottom + padding; + offsetLeft = pos.horizontalRight; + break; + + default: + break; + } + + if (offsetTop < window.scrollX) { + offsetTop = pos.bottom + padding; + resultAlign[0] = 'bottom'; + } else if (offsetTop + pos.target.height > window.scrollX + window.innerHeight) { + offsetTop = pos.top - padding; + resultAlign[0] = 'top'; + } + + if (offsetLeft < 0) { + offsetLeft = pos.horizontalLeft; + resultAlign[1] = 'left'; + } else if (offsetLeft + pos.target.width > window.innerWidth) { + offsetLeft = pos.horizontalRight; + resultAlign[1] = 'right'; + } + + return { + top: offsetTop, + left: offsetLeft, + pos, + align: resultAlign.join('-') + }; +}; + +/***/ }), + +/***/ "./src/utils/helpers.js": +/*!******************************!*\ + !*** ./src/utils/helpers.js ***! + \******************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "formDataToJPO": () => (/* binding */ formDataToJPO), +/* harmony export */ "unique": () => (/* binding */ unique), +/* harmony export */ "isDefined": () => (/* binding */ isDefined), +/* harmony export */ "isEmptyString": () => (/* binding */ isEmptyString), +/* harmony export */ "objectClean": () => (/* binding */ objectClean), +/* harmony export */ "humanReadableNumber": () => (/* binding */ humanReadableNumber), +/* harmony export */ "absoluteURL": () => (/* binding */ absoluteURL), +/* harmony export */ "removePrefix": () => (/* binding */ removePrefix), +/* harmony export */ "copyText": () => (/* binding */ copyText), +/* harmony export */ "delay": () => (/* binding */ delay) +/* harmony export */ }); +const formDataToJPO = formData => { + if (formData instanceof FormData === false) return formData; + return Array.from(formData.entries()).reduce((res, [key, value]) => { + return { ...res, + [key]: value + }; + }, {}); +}; +const unique = (list, expression = (a, b) => a === b) => { + return list.reduce((res, item) => { + const index = res.findIndex(elem => expression(elem, item)); + if (index < 0) res.push(item); + return res; + }, []); +}; +const isDefined = value => { + return value !== null && value !== undefined; +}; +const isEmptyString = value => { + return typeof value === 'string' && value.trim() === ""; +}; +const objectClean = source => { + const cleanObject = Object.entries(source).filter(pair => { + return isDefined(pair[1]) && pair[1] !== ""; + }).map(([key, value]) => { + if (Object.prototype.toString.call(value) === '[object Object]') { + return [key, objectClean(value)]; + } else { + return [key, value]; + } + }); + return Object.fromEntries(cleanObject); +}; +const humanReadableNumber = n => { + let result = n; + + const normalizeNumber = n => n.toFixed(1).replace(/.(0+)$/, ''); + + if (n >= 1e3 && n < 1e6) { + result = `${normalizeNumber(n / 1e3)}K`; + } else if (n >= 1e6 && n < 1e9) { + result = `${normalizeNumber(n / 1e6)}M`; + } else if (n >= 1e9) { + result = `${normalizeNumber(n / 1e9)}B`; + } + + return result || null; +}; +const absoluteURL = (path = "") => { + if (path.match(/^https?/) || path.match(/^\/\//)) { + return path; + } else { + return [APP_SETTINGS.hostname.replace(/([/]+)$/, ''), path.replace(/^([/]+)/, '')].join("/"); + } +}; +const removePrefix = path => { + if (APP_SETTINGS.hostname) { + const hostname = APP_SETTINGS.hostname; + const prefix = new URL(hostname).pathname.replace(/([/]+)$/, ''); + return path.replace(new RegExp(`^${prefix}`), ''); + } + + return path || "/"; +}; +const copyText = text => { + const input = document.createElement('textarea'); + document.body.appendChild(input); + input.value = text; + input.focus(); + input.select(); + document.execCommand('copy'); + input.remove(); +}; +const delay = (time = 0) => { + return new Promise(resolve => setTimeout(resolve, time)); +}; + +/***/ }), + +/***/ "./src/utils/hooks.js": +/*!****************************!*\ + !*** ./src/utils/hooks.js ***! + \****************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "useSet": () => (/* binding */ useSet), +/* harmony export */ "useRefresh": () => (/* binding */ useRefresh) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-router */ "./node_modules/react-router/esm/react-router.js"); +/* harmony import */ var _providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../providers/RoutesProvider */ "./src/providers/RoutesProvider.js"); + + + +const useSet = (initialSet = new Set()) => { + const [set, setSet] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(initialSet); + const stableActions = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + const add = item => setSet(prevSet => { + return new Set([...Array.from(prevSet), item]); + }); + + const remove = item => setSet(prevSet => { + return new Set(Array.from(prevSet).filter(i => i !== item)); + }); + + const toggle = item => setSet(prevSet => { + return prevSet.has(item) ? new Set(Array.from(prevSet).filter(i => i !== item)) : new Set([...Array.from(prevSet), item]); + }); + + return { + add, + remove, + toggle, + reset: () => setSet(initialSet) + }; + }, [setSet]); + const utils = { + has: (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(item => set.has(item), [set]), + ...stableActions + }; + return [set, utils]; +}; +const useRefresh = () => { + const history = (0,react_router__WEBPACK_IMPORTED_MODULE_2__.useHistory)(); + const { + pathname + } = (0,_providers_RoutesProvider__WEBPACK_IMPORTED_MODULE_1__.useFixedLocation)(); + const refresh = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(redirectPath => { + history.replace("/"); + setTimeout(() => { + history.replace(redirectPath !== null && redirectPath !== void 0 ? redirectPath : pathname); + }, 10); + return pathname; + }, [pathname]); + return refresh; +}; + +/***/ }), + +/***/ "./src/utils/routeHelpers.js": +/*!***********************************!*\ + !*** ./src/utils/routeHelpers.js ***! + \***********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "RouteContext": () => (/* binding */ RouteContext), +/* harmony export */ "pageSetToRoutes": () => (/* binding */ pageSetToRoutes), +/* harmony export */ "resolveRoutes": () => (/* binding */ resolveRoutes) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +/* harmony import */ var _config_Sentry__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../config/Sentry */ "./src/config/Sentry.ts"); +/* harmony import */ var _routes_RouteWithStaticFallback__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../routes/RouteWithStaticFallback */ "./src/routes/RouteWithStaticFallback.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); + + + + +const RouteContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(); + +const resolveWithConfig = (routes, config) => { + return routes instanceof Function ? routes(config) : routes; +}; +/** + * Resolves a set of components in a set of routes usign component + * properties. + * + * Component can has: + * @param {String|Function} title Title of a page. Can be either a string or a function that accepts route props as an argument + * @param {String} path Path of the page. It is always relative to the parent + * @param {boolean} exact Exact match of the route + * @param {Array} routes A list of raw routes + * @param {Object} pages Object with component that define pages. If provided, the function will run recursively + * + * The function itself accepts only pages argument. + * @param {Object} pages Object with components that define pages + */ + + +const pageSetToRoutes = (pages, config) => { + const pageProcessor = ([name, page]) => { + var _route$component; + + const route = { + path: page.path + }; + route.exact = !!page.exact; + route.modal = !!page.modal; + if (page.title) route.title = page.title; + if (page.render) route.render = page.render; + + if (page instanceof react__WEBPACK_IMPORTED_MODULE_0__.Component || page instanceof Function) { + if (name && /Layout/.test(name)) route.layout = page;else route.component = page; + } else { + route.component = page.component; + route.layout = page.layout; + } + + if (page.pages) { + route.routes = pageSetToRoutes(resolveWithConfig(page.pages, config), config); + } else if (page.routes) { + route.routes = pageSetToRoutes(resolveWithConfig(page.routes, config), config); + } + + if ((_route$component = route.component) !== null && _route$component !== void 0 && _route$component.context) route.context = route.component.context; + return route; + }; + + try { + if (Array.isArray(pages)) { + return pages.map(page => pageProcessor([null, page])); + } else { + return Object.entries(pages).map(pageProcessor); + } + } catch (err) { + console.log(err); + return []; + } +}; +/** + * + * @param {Array} routes List of routes + * @param {*} props Props to pass to every component and layout + * @param {*} onRender Callback that runs on every route render + */ + +const resolveRoutes = (routes, props) => { + const resolver = (route, parentPath) => { + const { + component: Component, + layout: Layout, + path, + modal, + routes: _routes, + ...rest + } = route; + const fullPath = parentPath ? `${parentPath}${path}` : path; + + if (_routes) { + const resolvedNestedRoutes = processRoutes(_routes, fullPath); + + const RouteComponent = routeProps => { + const children = []; // If a component provided for the set of routes/pages, + // we render in one level higher to preserve nesting + + if (Component) { + children.push(processRoutes([{ + path, + modal, + ...rest, + component: Component + }], parentPath)); + } + + children.push(...resolvedNestedRoutes); + return Layout ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(Layout, { ...routeProps, + children: children + }) : children; + }; + + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_routes_RouteWithStaticFallback__WEBPACK_IMPORTED_MODULE_2__.RouteWithStaticFallback, { + path: fullPath, + render: RouteComponent + }, fullPath); + } else { + const routeProps = { + key: fullPath, + path: fullPath, + modal: !!Component.modal + }; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_config_Sentry__WEBPACK_IMPORTED_MODULE_1__.SentryRoute, { ...routeProps, + exact: true, + render: () => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(Component, { ...(props !== null && props !== void 0 ? props : {}) + }), + ...rest + }); + } + }; + + const processRoutes = (routes, fullPath) => { + return routes.map(route => resolver(route, fullPath)); + }; + + return processRoutes(routes); +}; + +/***/ }), + +/***/ "./src/utils/scripts.js": +/*!******************************!*\ + !*** ./src/utils/scripts.js ***! + \******************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "isScriptValid": () => (/* binding */ isScriptValid), +/* harmony export */ "clearScriptsCache": () => (/* binding */ clearScriptsCache), +/* harmony export */ "replaceScript": () => (/* binding */ replaceScript), +/* harmony export */ "reInsertScripts": () => (/* binding */ reInsertScripts) +/* harmony export */ }); +const loadedScripts = new Set(); +/** + * Check wether it's a real script tag or not + * @param {HTMLScriptElement} script + */ + +const isScriptTag = script => { + return [null, undefined, '', 'text/javascript'].includes(script.type); +}; +/** + * Create a blob url from inline script + * @param {String} scriptContent + */ + + +const createScriptLink = scriptContent => { + const blob = new Blob([scriptContent], { + type: "text/javascript" + }); + return URL.createObjectURL(blob).toString(); +}; + +const isScriptValid = (scriptTag, forceUpdate) => { + // Check wether the tag is a real script or not + if (!isScriptTag(scriptTag)) { + return false; + } // Skip loading already existing scripts + + + if (scriptTag.dataset.alwaysReload === undefined) { + if (forceUpdate !== true && loadedScripts.has(scriptTag.outerHTML)) { + return false; + } + } // Skip if the script is not attached to DOM + + + if (!scriptTag.parentNode) { + return false; + } + + return true; +}; +const clearScriptsCache = () => { + loadedScripts.clear(); +}; +/** + * @param {HTMLScriptElement} targetScript + * @param {HTMLScriptElement} sourceScript + */ + +const swapScripts = (targetScript, sourceScript) => { + return new Promise(resolve => { + var _sourceScript; + + /**@type {HTMLScriptElement} */ + const newScript = document.createElement('script'); + sourceScript = (_sourceScript = sourceScript) !== null && _sourceScript !== void 0 ? _sourceScript : targetScript; // Use existing src or create url from script content + // This is necessary for onload event to work properly + + const src = sourceScript.src || createScriptLink(sourceScript.text); // Remember the script to prevent loading it more than once + + loadedScripts.add(sourceScript.outerHTML); // We respect async attribute, so we only wait for script to load + // when it's explicitly no async attribute + + if (!sourceScript.async) { + const onScriptLoaded = ({ + type + }) => { + newScript.removeEventListener('load', onScriptLoaded); + newScript.removeEventListener('error', onScriptLoaded); + resolve(type === 'error' ? false : newScript); + }; + + newScript.addEventListener('load', onScriptLoaded); + newScript.addEventListener('error', onScriptLoaded); + } else { + resolve(); + } + + if (sourceScript.dataset.alwaysReload !== undefined) { + newScript.dataset.alwaysReload = ""; + } + + if (sourceScript.id) newScript.id = sourceScript.id; + if (sourceScript.className) newScript.className = sourceScript.className; + newScript.dataset.replaced = 'true'; + newScript.async = sourceScript.async; + newScript.defer = sourceScript.defer; + newScript.type = 'text/javascript'; + newScript.src = src; + targetScript.parentNode.insertBefore(newScript, targetScript); + targetScript.remove(); + }); +}; +/** + * @param {HTMLScriptElement} scriptTag + * @param {Function} onReplace + */ + + +const replaceScript = async (scriptTag, { + sourceScript, + forceUpdate = false +} = {}) => { + var _sourceScript2; + + sourceScript = (_sourceScript2 = sourceScript) !== null && _sourceScript2 !== void 0 ? _sourceScript2 : scriptTag; + if (!isScriptValid(scriptTag, forceUpdate)) return; + if (sourceScript !== scriptTag && !isScriptValid(sourceScript, forceUpdate)) return; + return swapScripts(scriptTag, sourceScript); +}; + +const scriptIterator = function* (scripts) { + while (scripts.length) { + const nextScript = scripts.shift(); + yield replaceScript(nextScript).then(result => { + return result; + }); + } +}; +/** + * Re-inserts script tags inside a given element + * Only scripts with src or with empty type, or with + * type text/javascript will be processed + * @param {HTMLElement} root + */ + + +const reInsertScripts = async root => { + const scripts = root.querySelectorAll('script'); + if (!scripts.length) return []; + const iterarot = scriptIterator(Array.from(scripts)); + const result = []; + + for await (const script of iterarot) { + result.push(script); + } + + return result; +}; + +/***/ }), + +/***/ "./src/utils/transition.js": +/*!*********************************!*\ + !*** ./src/utils/transition.js ***! + \*********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "aroundTransition": () => (/* binding */ aroundTransition) +/* harmony export */ }); +/** + * Performs a transition on an element + * @param {HTMLElement} element + * @param {Function} transition + * @param {{ + * init: (element: HTMLElement) => void, + * transition: (element: HTMLElement) => void, + * onStart: (element: HTMLElement) => void, + * beforeTransition: (element: HTMLElement) => void, + * afterTransition: (element: HTMLElement) => void + * }} param2 + */ +const aroundTransition = (element, { + init, + transition, + onStart, + beforeTransition, + afterTransition +} = {}) => { + return new Promise(async resolve => { + init === null || init === void 0 ? void 0 : init(element); + + const onTransitionStarted = () => { + onStart === null || onStart === void 0 ? void 0 : onStart(element); + }; + + const onTransitionEnded = async () => { + await (afterTransition === null || afterTransition === void 0 ? void 0 : afterTransition(element)); + element.removeEventListener('transitionstart', onTransitionStarted); + element.removeEventListener('transitionend', onTransitionEnded); + resolve(); + }; + + element.addEventListener('transitionstart', onTransitionStarted); + element.addEventListener('transitionend', onTransitionEnded); + await (beforeTransition === null || beforeTransition === void 0 ? void 0 : beforeTransition()); + setTimeout(() => transition(element), 30); + }); +}; + +/***/ }), + +/***/ "./node_modules/chroma-js/chroma.js": +/*!******************************************!*\ + !*** ./node_modules/chroma-js/chroma.js ***! + \******************************************/ +/***/ (function(module) { + +/** + * chroma.js - JavaScript library for color conversions + * + * Copyright (c) 2011-2019, Gregor Aisch + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The name Gregor Aisch may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ------------------------------------------------------- + * + * chroma.js includes colors from colorbrewer2.org, which are released under + * the following license: + * + * Copyright (c) 2002 Cynthia Brewer, Mark Harrower, + * and The Pennsylvania State University. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + * + * ------------------------------------------------------ + * + * Named colors are taken from X11 Color Names. + * http://www.w3.org/TR/css3-color/#svg-color + * + * @preserve + */ + +(function (global, factory) { + true ? module.exports = factory() : + 0; +}(this, (function () { 'use strict'; + + var limit = function (x, min, max) { + if ( min === void 0 ) min=0; + if ( max === void 0 ) max=1; + + return x < min ? min : x > max ? max : x; + }; + + var clip_rgb = function (rgb) { + rgb._clipped = false; + rgb._unclipped = rgb.slice(0); + for (var i=0; i<=3; i++) { + if (i < 3) { + if (rgb[i] < 0 || rgb[i] > 255) { rgb._clipped = true; } + rgb[i] = limit(rgb[i], 0, 255); + } else if (i === 3) { + rgb[i] = limit(rgb[i], 0, 1); + } + } + return rgb; + }; + + // ported from jQuery's $.type + var classToType = {}; + for (var i = 0, list = ['Boolean', 'Number', 'String', 'Function', 'Array', 'Date', 'RegExp', 'Undefined', 'Null']; i < list.length; i += 1) { + var name = list[i]; + + classToType[("[object " + name + "]")] = name.toLowerCase(); + } + var type = function(obj) { + return classToType[Object.prototype.toString.call(obj)] || "object"; + }; + + var unpack = function (args, keyOrder) { + if ( keyOrder === void 0 ) keyOrder=null; + + // if called with more than 3 arguments, we return the arguments + if (args.length >= 3) { return Array.prototype.slice.call(args); } + // with less than 3 args we check if first arg is object + // and use the keyOrder string to extract and sort properties + if (type(args[0]) == 'object' && keyOrder) { + return keyOrder.split('') + .filter(function (k) { return args[0][k] !== undefined; }) + .map(function (k) { return args[0][k]; }); + } + // otherwise we just return the first argument + // (which we suppose is an array of args) + return args[0]; + }; + + var last = function (args) { + if (args.length < 2) { return null; } + var l = args.length-1; + if (type(args[l]) == 'string') { return args[l].toLowerCase(); } + return null; + }; + + var PI = Math.PI; + + var utils = { + clip_rgb: clip_rgb, + limit: limit, + type: type, + unpack: unpack, + last: last, + PI: PI, + TWOPI: PI*2, + PITHIRD: PI/3, + DEG2RAD: PI / 180, + RAD2DEG: 180 / PI + }; + + var input = { + format: {}, + autodetect: [] + }; + + var last$1 = utils.last; + var clip_rgb$1 = utils.clip_rgb; + var type$1 = utils.type; + + + var Color = function Color() { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var me = this; + if (type$1(args[0]) === 'object' && + args[0].constructor && + args[0].constructor === this.constructor) { + // the argument is already a Color instance + return args[0]; + } + + // last argument could be the mode + var mode = last$1(args); + var autodetect = false; + + if (!mode) { + autodetect = true; + if (!input.sorted) { + input.autodetect = input.autodetect.sort(function (a,b) { return b.p - a.p; }); + input.sorted = true; + } + // auto-detect format + for (var i = 0, list = input.autodetect; i < list.length; i += 1) { + var chk = list[i]; + + mode = chk.test.apply(chk, args); + if (mode) { break; } + } + } + + if (input.format[mode]) { + var rgb = input.format[mode].apply(null, autodetect ? args : args.slice(0,-1)); + me._rgb = clip_rgb$1(rgb); + } else { + throw new Error('unknown format: '+args); + } + + // add alpha channel + if (me._rgb.length === 3) { me._rgb.push(1); } + }; + + Color.prototype.toString = function toString () { + if (type$1(this.hex) == 'function') { return this.hex(); } + return ("[" + (this._rgb.join(',')) + "]"); + }; + + var Color_1 = Color; + + var chroma = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return new (Function.prototype.bind.apply( chroma.Color, [ null ].concat( args) )); + }; + + chroma.Color = Color_1; + chroma.version = '2.1.1'; + + var chroma_1 = chroma; + + var unpack$1 = utils.unpack; + var max = Math.max; + + var rgb2cmyk = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var ref = unpack$1(args, 'rgb'); + var r = ref[0]; + var g = ref[1]; + var b = ref[2]; + r = r / 255; + g = g / 255; + b = b / 255; + var k = 1 - max(r,max(g,b)); + var f = k < 1 ? 1 / (1-k) : 0; + var c = (1-r-k) * f; + var m = (1-g-k) * f; + var y = (1-b-k) * f; + return [c,m,y,k]; + }; + + var rgb2cmyk_1 = rgb2cmyk; + + var unpack$2 = utils.unpack; + + var cmyk2rgb = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack$2(args, 'cmyk'); + var c = args[0]; + var m = args[1]; + var y = args[2]; + var k = args[3]; + var alpha = args.length > 4 ? args[4] : 1; + if (k === 1) { return [0,0,0,alpha]; } + return [ + c >= 1 ? 0 : 255 * (1-c) * (1-k), // r + m >= 1 ? 0 : 255 * (1-m) * (1-k), // g + y >= 1 ? 0 : 255 * (1-y) * (1-k), // b + alpha + ]; + }; + + var cmyk2rgb_1 = cmyk2rgb; + + var unpack$3 = utils.unpack; + var type$2 = utils.type; + + + + Color_1.prototype.cmyk = function() { + return rgb2cmyk_1(this._rgb); + }; + + chroma_1.cmyk = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['cmyk']) )); + }; + + input.format.cmyk = cmyk2rgb_1; + + input.autodetect.push({ + p: 2, + test: function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack$3(args, 'cmyk'); + if (type$2(args) === 'array' && args.length === 4) { + return 'cmyk'; + } + } + }); + + var unpack$4 = utils.unpack; + var last$2 = utils.last; + var rnd = function (a) { return Math.round(a*100)/100; }; + + /* + * supported arguments: + * - hsl2css(h,s,l) + * - hsl2css(h,s,l,a) + * - hsl2css([h,s,l], mode) + * - hsl2css([h,s,l,a], mode) + * - hsl2css({h,s,l,a}, mode) + */ + var hsl2css = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var hsla = unpack$4(args, 'hsla'); + var mode = last$2(args) || 'lsa'; + hsla[0] = rnd(hsla[0] || 0); + hsla[1] = rnd(hsla[1]*100) + '%'; + hsla[2] = rnd(hsla[2]*100) + '%'; + if (mode === 'hsla' || (hsla.length > 3 && hsla[3]<1)) { + hsla[3] = hsla.length > 3 ? hsla[3] : 1; + mode = 'hsla'; + } else { + hsla.length = 3; + } + return (mode + "(" + (hsla.join(',')) + ")"); + }; + + var hsl2css_1 = hsl2css; + + var unpack$5 = utils.unpack; + + /* + * supported arguments: + * - rgb2hsl(r,g,b) + * - rgb2hsl(r,g,b,a) + * - rgb2hsl([r,g,b]) + * - rgb2hsl([r,g,b,a]) + * - rgb2hsl({r,g,b,a}) + */ + var rgb2hsl = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack$5(args, 'rgba'); + var r = args[0]; + var g = args[1]; + var b = args[2]; + + r /= 255; + g /= 255; + b /= 255; + + var min = Math.min(r, g, b); + var max = Math.max(r, g, b); + + var l = (max + min) / 2; + var s, h; + + if (max === min){ + s = 0; + h = Number.NaN; + } else { + s = l < 0.5 ? (max - min) / (max + min) : (max - min) / (2 - max - min); + } + + if (r == max) { h = (g - b) / (max - min); } + else if (g == max) { h = 2 + (b - r) / (max - min); } + else if (b == max) { h = 4 + (r - g) / (max - min); } + + h *= 60; + if (h < 0) { h += 360; } + if (args.length>3 && args[3]!==undefined) { return [h,s,l,args[3]]; } + return [h,s,l]; + }; + + var rgb2hsl_1 = rgb2hsl; + + var unpack$6 = utils.unpack; + var last$3 = utils.last; + + + var round = Math.round; + + /* + * supported arguments: + * - rgb2css(r,g,b) + * - rgb2css(r,g,b,a) + * - rgb2css([r,g,b], mode) + * - rgb2css([r,g,b,a], mode) + * - rgb2css({r,g,b,a}, mode) + */ + var rgb2css = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var rgba = unpack$6(args, 'rgba'); + var mode = last$3(args) || 'rgb'; + if (mode.substr(0,3) == 'hsl') { + return hsl2css_1(rgb2hsl_1(rgba), mode); + } + rgba[0] = round(rgba[0]); + rgba[1] = round(rgba[1]); + rgba[2] = round(rgba[2]); + if (mode === 'rgba' || (rgba.length > 3 && rgba[3]<1)) { + rgba[3] = rgba.length > 3 ? rgba[3] : 1; + mode = 'rgba'; + } + return (mode + "(" + (rgba.slice(0,mode==='rgb'?3:4).join(',')) + ")"); + }; + + var rgb2css_1 = rgb2css; + + var unpack$7 = utils.unpack; + var round$1 = Math.round; + + var hsl2rgb = function () { + var assign; + + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + args = unpack$7(args, 'hsl'); + var h = args[0]; + var s = args[1]; + var l = args[2]; + var r,g,b; + if (s === 0) { + r = g = b = l*255; + } else { + var t3 = [0,0,0]; + var c = [0,0,0]; + var t2 = l < 0.5 ? l * (1+s) : l+s-l*s; + var t1 = 2 * l - t2; + var h_ = h / 360; + t3[0] = h_ + 1/3; + t3[1] = h_; + t3[2] = h_ - 1/3; + for (var i=0; i<3; i++) { + if (t3[i] < 0) { t3[i] += 1; } + if (t3[i] > 1) { t3[i] -= 1; } + if (6 * t3[i] < 1) + { c[i] = t1 + (t2 - t1) * 6 * t3[i]; } + else if (2 * t3[i] < 1) + { c[i] = t2; } + else if (3 * t3[i] < 2) + { c[i] = t1 + (t2 - t1) * ((2 / 3) - t3[i]) * 6; } + else + { c[i] = t1; } + } + (assign = [round$1(c[0]*255),round$1(c[1]*255),round$1(c[2]*255)], r = assign[0], g = assign[1], b = assign[2]); + } + if (args.length > 3) { + // keep alpha channel + return [r,g,b,args[3]]; + } + return [r,g,b,1]; + }; + + var hsl2rgb_1 = hsl2rgb; + + var RE_RGB = /^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/; + var RE_RGBA = /^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/; + var RE_RGB_PCT = /^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/; + var RE_RGBA_PCT = /^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/; + var RE_HSL = /^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/; + var RE_HSLA = /^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/; + + var round$2 = Math.round; + + var css2rgb = function (css) { + css = css.toLowerCase().trim(); + var m; + + if (input.format.named) { + try { + return input.format.named(css); + } catch (e) { + // eslint-disable-next-line + } + } + + // rgb(250,20,0) + if ((m = css.match(RE_RGB))) { + var rgb = m.slice(1,4); + for (var i=0; i<3; i++) { + rgb[i] = +rgb[i]; + } + rgb[3] = 1; // default alpha + return rgb; + } + + // rgba(250,20,0,0.4) + if ((m = css.match(RE_RGBA))) { + var rgb$1 = m.slice(1,5); + for (var i$1=0; i$1<4; i$1++) { + rgb$1[i$1] = +rgb$1[i$1]; + } + return rgb$1; + } + + // rgb(100%,0%,0%) + if ((m = css.match(RE_RGB_PCT))) { + var rgb$2 = m.slice(1,4); + for (var i$2=0; i$2<3; i$2++) { + rgb$2[i$2] = round$2(rgb$2[i$2] * 2.55); + } + rgb$2[3] = 1; // default alpha + return rgb$2; + } + + // rgba(100%,0%,0%,0.4) + if ((m = css.match(RE_RGBA_PCT))) { + var rgb$3 = m.slice(1,5); + for (var i$3=0; i$3<3; i$3++) { + rgb$3[i$3] = round$2(rgb$3[i$3] * 2.55); + } + rgb$3[3] = +rgb$3[3]; + return rgb$3; + } + + // hsl(0,100%,50%) + if ((m = css.match(RE_HSL))) { + var hsl = m.slice(1,4); + hsl[1] *= 0.01; + hsl[2] *= 0.01; + var rgb$4 = hsl2rgb_1(hsl); + rgb$4[3] = 1; + return rgb$4; + } + + // hsla(0,100%,50%,0.5) + if ((m = css.match(RE_HSLA))) { + var hsl$1 = m.slice(1,4); + hsl$1[1] *= 0.01; + hsl$1[2] *= 0.01; + var rgb$5 = hsl2rgb_1(hsl$1); + rgb$5[3] = +m[4]; // default alpha = 1 + return rgb$5; + } + }; + + css2rgb.test = function (s) { + return RE_RGB.test(s) || + RE_RGBA.test(s) || + RE_RGB_PCT.test(s) || + RE_RGBA_PCT.test(s) || + RE_HSL.test(s) || + RE_HSLA.test(s); + }; + + var css2rgb_1 = css2rgb; + + var type$3 = utils.type; + + + + + Color_1.prototype.css = function(mode) { + return rgb2css_1(this._rgb, mode); + }; + + chroma_1.css = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['css']) )); + }; + + input.format.css = css2rgb_1; + + input.autodetect.push({ + p: 5, + test: function (h) { + var rest = [], len = arguments.length - 1; + while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ]; + + if (!rest.length && type$3(h) === 'string' && css2rgb_1.test(h)) { + return 'css'; + } + } + }); + + var unpack$8 = utils.unpack; + + input.format.gl = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var rgb = unpack$8(args, 'rgba'); + rgb[0] *= 255; + rgb[1] *= 255; + rgb[2] *= 255; + return rgb; + }; + + chroma_1.gl = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['gl']) )); + }; + + Color_1.prototype.gl = function() { + var rgb = this._rgb; + return [rgb[0]/255, rgb[1]/255, rgb[2]/255, rgb[3]]; + }; + + var unpack$9 = utils.unpack; + + var rgb2hcg = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var ref = unpack$9(args, 'rgb'); + var r = ref[0]; + var g = ref[1]; + var b = ref[2]; + var min = Math.min(r, g, b); + var max = Math.max(r, g, b); + var delta = max - min; + var c = delta * 100 / 255; + var _g = min / (255 - delta) * 100; + var h; + if (delta === 0) { + h = Number.NaN; + } else { + if (r === max) { h = (g - b) / delta; } + if (g === max) { h = 2+(b - r) / delta; } + if (b === max) { h = 4+(r - g) / delta; } + h *= 60; + if (h < 0) { h += 360; } + } + return [h, c, _g]; + }; + + var rgb2hcg_1 = rgb2hcg; + + var unpack$a = utils.unpack; + var floor = Math.floor; + + /* + * this is basically just HSV with some minor tweaks + * + * hue.. [0..360] + * chroma .. [0..1] + * grayness .. [0..1] + */ + + var hcg2rgb = function () { + var assign, assign$1, assign$2, assign$3, assign$4, assign$5; + + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + args = unpack$a(args, 'hcg'); + var h = args[0]; + var c = args[1]; + var _g = args[2]; + var r,g,b; + _g = _g * 255; + var _c = c * 255; + if (c === 0) { + r = g = b = _g; + } else { + if (h === 360) { h = 0; } + if (h > 360) { h -= 360; } + if (h < 0) { h += 360; } + h /= 60; + var i = floor(h); + var f = h - i; + var p = _g * (1 - c); + var q = p + _c * (1 - f); + var t = p + _c * f; + var v = p + _c; + switch (i) { + case 0: (assign = [v, t, p], r = assign[0], g = assign[1], b = assign[2]); break + case 1: (assign$1 = [q, v, p], r = assign$1[0], g = assign$1[1], b = assign$1[2]); break + case 2: (assign$2 = [p, v, t], r = assign$2[0], g = assign$2[1], b = assign$2[2]); break + case 3: (assign$3 = [p, q, v], r = assign$3[0], g = assign$3[1], b = assign$3[2]); break + case 4: (assign$4 = [t, p, v], r = assign$4[0], g = assign$4[1], b = assign$4[2]); break + case 5: (assign$5 = [v, p, q], r = assign$5[0], g = assign$5[1], b = assign$5[2]); break + } + } + return [r, g, b, args.length > 3 ? args[3] : 1]; + }; + + var hcg2rgb_1 = hcg2rgb; + + var unpack$b = utils.unpack; + var type$4 = utils.type; + + + + + + + Color_1.prototype.hcg = function() { + return rgb2hcg_1(this._rgb); + }; + + chroma_1.hcg = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['hcg']) )); + }; + + input.format.hcg = hcg2rgb_1; + + input.autodetect.push({ + p: 1, + test: function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack$b(args, 'hcg'); + if (type$4(args) === 'array' && args.length === 3) { + return 'hcg'; + } + } + }); + + var unpack$c = utils.unpack; + var last$4 = utils.last; + var round$3 = Math.round; + + var rgb2hex = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var ref = unpack$c(args, 'rgba'); + var r = ref[0]; + var g = ref[1]; + var b = ref[2]; + var a = ref[3]; + var mode = last$4(args) || 'auto'; + if (a === undefined) { a = 1; } + if (mode === 'auto') { + mode = a < 1 ? 'rgba' : 'rgb'; + } + r = round$3(r); + g = round$3(g); + b = round$3(b); + var u = r << 16 | g << 8 | b; + var str = "000000" + u.toString(16); //#.toUpperCase(); + str = str.substr(str.length - 6); + var hxa = '0' + round$3(a * 255).toString(16); + hxa = hxa.substr(hxa.length - 2); + switch (mode.toLowerCase()) { + case 'rgba': return ("#" + str + hxa); + case 'argb': return ("#" + hxa + str); + default: return ("#" + str); + } + }; + + var rgb2hex_1 = rgb2hex; + + var RE_HEX = /^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/; + var RE_HEXA = /^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/; + + var hex2rgb = function (hex) { + if (hex.match(RE_HEX)) { + // remove optional leading # + if (hex.length === 4 || hex.length === 7) { + hex = hex.substr(1); + } + // expand short-notation to full six-digit + if (hex.length === 3) { + hex = hex.split(''); + hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2]; + } + var u = parseInt(hex, 16); + var r = u >> 16; + var g = u >> 8 & 0xFF; + var b = u & 0xFF; + return [r,g,b,1]; + } + + // match rgba hex format, eg #FF000077 + if (hex.match(RE_HEXA)) { + if (hex.length === 5 || hex.length === 9) { + // remove optional leading # + hex = hex.substr(1); + } + // expand short-notation to full eight-digit + if (hex.length === 4) { + hex = hex.split(''); + hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2]+hex[3]+hex[3]; + } + var u$1 = parseInt(hex, 16); + var r$1 = u$1 >> 24 & 0xFF; + var g$1 = u$1 >> 16 & 0xFF; + var b$1 = u$1 >> 8 & 0xFF; + var a = Math.round((u$1 & 0xFF) / 0xFF * 100) / 100; + return [r$1,g$1,b$1,a]; + } + + // we used to check for css colors here + // if _input.css? and rgb = _input.css hex + // return rgb + + throw new Error(("unknown hex color: " + hex)); + }; + + var hex2rgb_1 = hex2rgb; + + var type$5 = utils.type; + + + + + Color_1.prototype.hex = function(mode) { + return rgb2hex_1(this._rgb, mode); + }; + + chroma_1.hex = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['hex']) )); + }; + + input.format.hex = hex2rgb_1; + input.autodetect.push({ + p: 4, + test: function (h) { + var rest = [], len = arguments.length - 1; + while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ]; + + if (!rest.length && type$5(h) === 'string' && [3,4,5,6,7,8,9].indexOf(h.length) >= 0) { + return 'hex'; + } + } + }); + + var unpack$d = utils.unpack; + var TWOPI = utils.TWOPI; + var min = Math.min; + var sqrt = Math.sqrt; + var acos = Math.acos; + + var rgb2hsi = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + /* + borrowed from here: + http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/rgb2hsi.cpp + */ + var ref = unpack$d(args, 'rgb'); + var r = ref[0]; + var g = ref[1]; + var b = ref[2]; + r /= 255; + g /= 255; + b /= 255; + var h; + var min_ = min(r,g,b); + var i = (r+g+b) / 3; + var s = i > 0 ? 1 - min_/i : 0; + if (s === 0) { + h = NaN; + } else { + h = ((r-g)+(r-b)) / 2; + h /= sqrt((r-g)*(r-g) + (r-b)*(g-b)); + h = acos(h); + if (b > g) { + h = TWOPI - h; + } + h /= TWOPI; + } + return [h*360,s,i]; + }; + + var rgb2hsi_1 = rgb2hsi; + + var unpack$e = utils.unpack; + var limit$1 = utils.limit; + var TWOPI$1 = utils.TWOPI; + var PITHIRD = utils.PITHIRD; + var cos = Math.cos; + + /* + * hue [0..360] + * saturation [0..1] + * intensity [0..1] + */ + var hsi2rgb = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + /* + borrowed from here: + http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/hsi2rgb.cpp + */ + args = unpack$e(args, 'hsi'); + var h = args[0]; + var s = args[1]; + var i = args[2]; + var r,g,b; + + if (isNaN(h)) { h = 0; } + if (isNaN(s)) { s = 0; } + // normalize hue + if (h > 360) { h -= 360; } + if (h < 0) { h += 360; } + h /= 360; + if (h < 1/3) { + b = (1-s)/3; + r = (1+s*cos(TWOPI$1*h)/cos(PITHIRD-TWOPI$1*h))/3; + g = 1 - (b+r); + } else if (h < 2/3) { + h -= 1/3; + r = (1-s)/3; + g = (1+s*cos(TWOPI$1*h)/cos(PITHIRD-TWOPI$1*h))/3; + b = 1 - (r+g); + } else { + h -= 2/3; + g = (1-s)/3; + b = (1+s*cos(TWOPI$1*h)/cos(PITHIRD-TWOPI$1*h))/3; + r = 1 - (g+b); + } + r = limit$1(i*r*3); + g = limit$1(i*g*3); + b = limit$1(i*b*3); + return [r*255, g*255, b*255, args.length > 3 ? args[3] : 1]; + }; + + var hsi2rgb_1 = hsi2rgb; + + var unpack$f = utils.unpack; + var type$6 = utils.type; + + + + + + + Color_1.prototype.hsi = function() { + return rgb2hsi_1(this._rgb); + }; + + chroma_1.hsi = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['hsi']) )); + }; + + input.format.hsi = hsi2rgb_1; + + input.autodetect.push({ + p: 2, + test: function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack$f(args, 'hsi'); + if (type$6(args) === 'array' && args.length === 3) { + return 'hsi'; + } + } + }); + + var unpack$g = utils.unpack; + var type$7 = utils.type; + + + + + + + Color_1.prototype.hsl = function() { + return rgb2hsl_1(this._rgb); + }; + + chroma_1.hsl = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['hsl']) )); + }; + + input.format.hsl = hsl2rgb_1; + + input.autodetect.push({ + p: 2, + test: function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack$g(args, 'hsl'); + if (type$7(args) === 'array' && args.length === 3) { + return 'hsl'; + } + } + }); + + var unpack$h = utils.unpack; + var min$1 = Math.min; + var max$1 = Math.max; + + /* + * supported arguments: + * - rgb2hsv(r,g,b) + * - rgb2hsv([r,g,b]) + * - rgb2hsv({r,g,b}) + */ + var rgb2hsl$1 = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack$h(args, 'rgb'); + var r = args[0]; + var g = args[1]; + var b = args[2]; + var min_ = min$1(r, g, b); + var max_ = max$1(r, g, b); + var delta = max_ - min_; + var h,s,v; + v = max_ / 255.0; + if (max_ === 0) { + h = Number.NaN; + s = 0; + } else { + s = delta / max_; + if (r === max_) { h = (g - b) / delta; } + if (g === max_) { h = 2+(b - r) / delta; } + if (b === max_) { h = 4+(r - g) / delta; } + h *= 60; + if (h < 0) { h += 360; } + } + return [h, s, v] + }; + + var rgb2hsv = rgb2hsl$1; + + var unpack$i = utils.unpack; + var floor$1 = Math.floor; + + var hsv2rgb = function () { + var assign, assign$1, assign$2, assign$3, assign$4, assign$5; + + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + args = unpack$i(args, 'hsv'); + var h = args[0]; + var s = args[1]; + var v = args[2]; + var r,g,b; + v *= 255; + if (s === 0) { + r = g = b = v; + } else { + if (h === 360) { h = 0; } + if (h > 360) { h -= 360; } + if (h < 0) { h += 360; } + h /= 60; + + var i = floor$1(h); + var f = h - i; + var p = v * (1 - s); + var q = v * (1 - s * f); + var t = v * (1 - s * (1 - f)); + + switch (i) { + case 0: (assign = [v, t, p], r = assign[0], g = assign[1], b = assign[2]); break + case 1: (assign$1 = [q, v, p], r = assign$1[0], g = assign$1[1], b = assign$1[2]); break + case 2: (assign$2 = [p, v, t], r = assign$2[0], g = assign$2[1], b = assign$2[2]); break + case 3: (assign$3 = [p, q, v], r = assign$3[0], g = assign$3[1], b = assign$3[2]); break + case 4: (assign$4 = [t, p, v], r = assign$4[0], g = assign$4[1], b = assign$4[2]); break + case 5: (assign$5 = [v, p, q], r = assign$5[0], g = assign$5[1], b = assign$5[2]); break + } + } + return [r,g,b,args.length > 3?args[3]:1]; + }; + + var hsv2rgb_1 = hsv2rgb; + + var unpack$j = utils.unpack; + var type$8 = utils.type; + + + + + + + Color_1.prototype.hsv = function() { + return rgb2hsv(this._rgb); + }; + + chroma_1.hsv = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['hsv']) )); + }; + + input.format.hsv = hsv2rgb_1; + + input.autodetect.push({ + p: 2, + test: function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack$j(args, 'hsv'); + if (type$8(args) === 'array' && args.length === 3) { + return 'hsv'; + } + } + }); + + var labConstants = { + // Corresponds roughly to RGB brighter/darker + Kn: 18, + + // D65 standard referent + Xn: 0.950470, + Yn: 1, + Zn: 1.088830, + + t0: 0.137931034, // 4 / 29 + t1: 0.206896552, // 6 / 29 + t2: 0.12841855, // 3 * t1 * t1 + t3: 0.008856452, // t1 * t1 * t1 + }; + + var unpack$k = utils.unpack; + var pow = Math.pow; + + var rgb2lab = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var ref = unpack$k(args, 'rgb'); + var r = ref[0]; + var g = ref[1]; + var b = ref[2]; + var ref$1 = rgb2xyz(r,g,b); + var x = ref$1[0]; + var y = ref$1[1]; + var z = ref$1[2]; + var l = 116 * y - 16; + return [l < 0 ? 0 : l, 500 * (x - y), 200 * (y - z)]; + }; + + var rgb_xyz = function (r) { + if ((r /= 255) <= 0.04045) { return r / 12.92; } + return pow((r + 0.055) / 1.055, 2.4); + }; + + var xyz_lab = function (t) { + if (t > labConstants.t3) { return pow(t, 1 / 3); } + return t / labConstants.t2 + labConstants.t0; + }; + + var rgb2xyz = function (r,g,b) { + r = rgb_xyz(r); + g = rgb_xyz(g); + b = rgb_xyz(b); + var x = xyz_lab((0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / labConstants.Xn); + var y = xyz_lab((0.2126729 * r + 0.7151522 * g + 0.0721750 * b) / labConstants.Yn); + var z = xyz_lab((0.0193339 * r + 0.1191920 * g + 0.9503041 * b) / labConstants.Zn); + return [x,y,z]; + }; + + var rgb2lab_1 = rgb2lab; + + var unpack$l = utils.unpack; + var pow$1 = Math.pow; + + /* + * L* [0..100] + * a [-100..100] + * b [-100..100] + */ + var lab2rgb = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack$l(args, 'lab'); + var l = args[0]; + var a = args[1]; + var b = args[2]; + var x,y,z, r,g,b_; + + y = (l + 16) / 116; + x = isNaN(a) ? y : y + a / 500; + z = isNaN(b) ? y : y - b / 200; + + y = labConstants.Yn * lab_xyz(y); + x = labConstants.Xn * lab_xyz(x); + z = labConstants.Zn * lab_xyz(z); + + r = xyz_rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z); // D65 -> sRGB + g = xyz_rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z); + b_ = xyz_rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z); + + return [r,g,b_,args.length > 3 ? args[3] : 1]; + }; + + var xyz_rgb = function (r) { + return 255 * (r <= 0.00304 ? 12.92 * r : 1.055 * pow$1(r, 1 / 2.4) - 0.055) + }; + + var lab_xyz = function (t) { + return t > labConstants.t1 ? t * t * t : labConstants.t2 * (t - labConstants.t0) + }; + + var lab2rgb_1 = lab2rgb; + + var unpack$m = utils.unpack; + var type$9 = utils.type; + + + + + + + Color_1.prototype.lab = function() { + return rgb2lab_1(this._rgb); + }; + + chroma_1.lab = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['lab']) )); + }; + + input.format.lab = lab2rgb_1; + + input.autodetect.push({ + p: 2, + test: function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack$m(args, 'lab'); + if (type$9(args) === 'array' && args.length === 3) { + return 'lab'; + } + } + }); + + var unpack$n = utils.unpack; + var RAD2DEG = utils.RAD2DEG; + var sqrt$1 = Math.sqrt; + var atan2 = Math.atan2; + var round$4 = Math.round; + + var lab2lch = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var ref = unpack$n(args, 'lab'); + var l = ref[0]; + var a = ref[1]; + var b = ref[2]; + var c = sqrt$1(a * a + b * b); + var h = (atan2(b, a) * RAD2DEG + 360) % 360; + if (round$4(c*10000) === 0) { h = Number.NaN; } + return [l, c, h]; + }; + + var lab2lch_1 = lab2lch; + + var unpack$o = utils.unpack; + + + + var rgb2lch = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var ref = unpack$o(args, 'rgb'); + var r = ref[0]; + var g = ref[1]; + var b = ref[2]; + var ref$1 = rgb2lab_1(r,g,b); + var l = ref$1[0]; + var a = ref$1[1]; + var b_ = ref$1[2]; + return lab2lch_1(l,a,b_); + }; + + var rgb2lch_1 = rgb2lch; + + var unpack$p = utils.unpack; + var DEG2RAD = utils.DEG2RAD; + var sin = Math.sin; + var cos$1 = Math.cos; + + var lch2lab = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + /* + Convert from a qualitative parameter h and a quantitative parameter l to a 24-bit pixel. + These formulas were invented by David Dalrymple to obtain maximum contrast without going + out of gamut if the parameters are in the range 0-1. + + A saturation multiplier was added by Gregor Aisch + */ + var ref = unpack$p(args, 'lch'); + var l = ref[0]; + var c = ref[1]; + var h = ref[2]; + if (isNaN(h)) { h = 0; } + h = h * DEG2RAD; + return [l, cos$1(h) * c, sin(h) * c] + }; + + var lch2lab_1 = lch2lab; + + var unpack$q = utils.unpack; + + + + var lch2rgb = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack$q(args, 'lch'); + var l = args[0]; + var c = args[1]; + var h = args[2]; + var ref = lch2lab_1 (l,c,h); + var L = ref[0]; + var a = ref[1]; + var b_ = ref[2]; + var ref$1 = lab2rgb_1 (L,a,b_); + var r = ref$1[0]; + var g = ref$1[1]; + var b = ref$1[2]; + return [r, g, b, args.length > 3 ? args[3] : 1]; + }; + + var lch2rgb_1 = lch2rgb; + + var unpack$r = utils.unpack; + + + var hcl2rgb = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var hcl = unpack$r(args, 'hcl').reverse(); + return lch2rgb_1.apply(void 0, hcl); + }; + + var hcl2rgb_1 = hcl2rgb; + + var unpack$s = utils.unpack; + var type$a = utils.type; + + + + + + + Color_1.prototype.lch = function() { return rgb2lch_1(this._rgb); }; + Color_1.prototype.hcl = function() { return rgb2lch_1(this._rgb).reverse(); }; + + chroma_1.lch = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['lch']) )); + }; + chroma_1.hcl = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['hcl']) )); + }; + + input.format.lch = lch2rgb_1; + input.format.hcl = hcl2rgb_1; + + ['lch','hcl'].forEach(function (m) { return input.autodetect.push({ + p: 2, + test: function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack$s(args, m); + if (type$a(args) === 'array' && args.length === 3) { + return m; + } + } + }); }); + + /** + X11 color names + + http://www.w3.org/TR/css3-color/#svg-color + */ + + var w3cx11 = { + aliceblue: '#f0f8ff', + antiquewhite: '#faebd7', + aqua: '#00ffff', + aquamarine: '#7fffd4', + azure: '#f0ffff', + beige: '#f5f5dc', + bisque: '#ffe4c4', + black: '#000000', + blanchedalmond: '#ffebcd', + blue: '#0000ff', + blueviolet: '#8a2be2', + brown: '#a52a2a', + burlywood: '#deb887', + cadetblue: '#5f9ea0', + chartreuse: '#7fff00', + chocolate: '#d2691e', + coral: '#ff7f50', + cornflower: '#6495ed', + cornflowerblue: '#6495ed', + cornsilk: '#fff8dc', + crimson: '#dc143c', + cyan: '#00ffff', + darkblue: '#00008b', + darkcyan: '#008b8b', + darkgoldenrod: '#b8860b', + darkgray: '#a9a9a9', + darkgreen: '#006400', + darkgrey: '#a9a9a9', + darkkhaki: '#bdb76b', + darkmagenta: '#8b008b', + darkolivegreen: '#556b2f', + darkorange: '#ff8c00', + darkorchid: '#9932cc', + darkred: '#8b0000', + darksalmon: '#e9967a', + darkseagreen: '#8fbc8f', + darkslateblue: '#483d8b', + darkslategray: '#2f4f4f', + darkslategrey: '#2f4f4f', + darkturquoise: '#00ced1', + darkviolet: '#9400d3', + deeppink: '#ff1493', + deepskyblue: '#00bfff', + dimgray: '#696969', + dimgrey: '#696969', + dodgerblue: '#1e90ff', + firebrick: '#b22222', + floralwhite: '#fffaf0', + forestgreen: '#228b22', + fuchsia: '#ff00ff', + gainsboro: '#dcdcdc', + ghostwhite: '#f8f8ff', + gold: '#ffd700', + goldenrod: '#daa520', + gray: '#808080', + green: '#008000', + greenyellow: '#adff2f', + grey: '#808080', + honeydew: '#f0fff0', + hotpink: '#ff69b4', + indianred: '#cd5c5c', + indigo: '#4b0082', + ivory: '#fffff0', + khaki: '#f0e68c', + laserlemon: '#ffff54', + lavender: '#e6e6fa', + lavenderblush: '#fff0f5', + lawngreen: '#7cfc00', + lemonchiffon: '#fffacd', + lightblue: '#add8e6', + lightcoral: '#f08080', + lightcyan: '#e0ffff', + lightgoldenrod: '#fafad2', + lightgoldenrodyellow: '#fafad2', + lightgray: '#d3d3d3', + lightgreen: '#90ee90', + lightgrey: '#d3d3d3', + lightpink: '#ffb6c1', + lightsalmon: '#ffa07a', + lightseagreen: '#20b2aa', + lightskyblue: '#87cefa', + lightslategray: '#778899', + lightslategrey: '#778899', + lightsteelblue: '#b0c4de', + lightyellow: '#ffffe0', + lime: '#00ff00', + limegreen: '#32cd32', + linen: '#faf0e6', + magenta: '#ff00ff', + maroon: '#800000', + maroon2: '#7f0000', + maroon3: '#b03060', + mediumaquamarine: '#66cdaa', + mediumblue: '#0000cd', + mediumorchid: '#ba55d3', + mediumpurple: '#9370db', + mediumseagreen: '#3cb371', + mediumslateblue: '#7b68ee', + mediumspringgreen: '#00fa9a', + mediumturquoise: '#48d1cc', + mediumvioletred: '#c71585', + midnightblue: '#191970', + mintcream: '#f5fffa', + mistyrose: '#ffe4e1', + moccasin: '#ffe4b5', + navajowhite: '#ffdead', + navy: '#000080', + oldlace: '#fdf5e6', + olive: '#808000', + olivedrab: '#6b8e23', + orange: '#ffa500', + orangered: '#ff4500', + orchid: '#da70d6', + palegoldenrod: '#eee8aa', + palegreen: '#98fb98', + paleturquoise: '#afeeee', + palevioletred: '#db7093', + papayawhip: '#ffefd5', + peachpuff: '#ffdab9', + peru: '#cd853f', + pink: '#ffc0cb', + plum: '#dda0dd', + powderblue: '#b0e0e6', + purple: '#800080', + purple2: '#7f007f', + purple3: '#a020f0', + rebeccapurple: '#663399', + red: '#ff0000', + rosybrown: '#bc8f8f', + royalblue: '#4169e1', + saddlebrown: '#8b4513', + salmon: '#fa8072', + sandybrown: '#f4a460', + seagreen: '#2e8b57', + seashell: '#fff5ee', + sienna: '#a0522d', + silver: '#c0c0c0', + skyblue: '#87ceeb', + slateblue: '#6a5acd', + slategray: '#708090', + slategrey: '#708090', + snow: '#fffafa', + springgreen: '#00ff7f', + steelblue: '#4682b4', + tan: '#d2b48c', + teal: '#008080', + thistle: '#d8bfd8', + tomato: '#ff6347', + turquoise: '#40e0d0', + violet: '#ee82ee', + wheat: '#f5deb3', + white: '#ffffff', + whitesmoke: '#f5f5f5', + yellow: '#ffff00', + yellowgreen: '#9acd32' + }; + + var w3cx11_1 = w3cx11; + + var type$b = utils.type; + + + + + + Color_1.prototype.name = function() { + var hex = rgb2hex_1(this._rgb, 'rgb'); + for (var i = 0, list = Object.keys(w3cx11_1); i < list.length; i += 1) { + var n = list[i]; + + if (w3cx11_1[n] === hex) { return n.toLowerCase(); } + } + return hex; + }; + + input.format.named = function (name) { + name = name.toLowerCase(); + if (w3cx11_1[name]) { return hex2rgb_1(w3cx11_1[name]); } + throw new Error('unknown color name: '+name); + }; + + input.autodetect.push({ + p: 5, + test: function (h) { + var rest = [], len = arguments.length - 1; + while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ]; + + if (!rest.length && type$b(h) === 'string' && w3cx11_1[h.toLowerCase()]) { + return 'named'; + } + } + }); + + var unpack$t = utils.unpack; + + var rgb2num = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var ref = unpack$t(args, 'rgb'); + var r = ref[0]; + var g = ref[1]; + var b = ref[2]; + return (r << 16) + (g << 8) + b; + }; + + var rgb2num_1 = rgb2num; + + var type$c = utils.type; + + var num2rgb = function (num) { + if (type$c(num) == "number" && num >= 0 && num <= 0xFFFFFF) { + var r = num >> 16; + var g = (num >> 8) & 0xFF; + var b = num & 0xFF; + return [r,g,b,1]; + } + throw new Error("unknown num color: "+num); + }; + + var num2rgb_1 = num2rgb; + + var type$d = utils.type; + + + + Color_1.prototype.num = function() { + return rgb2num_1(this._rgb); + }; + + chroma_1.num = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['num']) )); + }; + + input.format.num = num2rgb_1; + + input.autodetect.push({ + p: 5, + test: function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + if (args.length === 1 && type$d(args[0]) === 'number' && args[0] >= 0 && args[0] <= 0xFFFFFF) { + return 'num'; + } + } + }); + + var unpack$u = utils.unpack; + var type$e = utils.type; + var round$5 = Math.round; + + Color_1.prototype.rgb = function(rnd) { + if ( rnd === void 0 ) rnd=true; + + if (rnd === false) { return this._rgb.slice(0,3); } + return this._rgb.slice(0,3).map(round$5); + }; + + Color_1.prototype.rgba = function(rnd) { + if ( rnd === void 0 ) rnd=true; + + return this._rgb.slice(0,4).map(function (v,i) { + return i<3 ? (rnd === false ? v : round$5(v)) : v; + }); + }; + + chroma_1.rgb = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['rgb']) )); + }; + + input.format.rgb = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var rgba = unpack$u(args, 'rgba'); + if (rgba[3] === undefined) { rgba[3] = 1; } + return rgba; + }; + + input.autodetect.push({ + p: 3, + test: function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack$u(args, 'rgba'); + if (type$e(args) === 'array' && (args.length === 3 || + args.length === 4 && type$e(args[3]) == 'number' && args[3] >= 0 && args[3] <= 1)) { + return 'rgb'; + } + } + }); + + /* + * Based on implementation by Neil Bartlett + * https://github.com/neilbartlett/color-temperature + */ + + var log = Math.log; + + var temperature2rgb = function (kelvin) { + var temp = kelvin / 100; + var r,g,b; + if (temp < 66) { + r = 255; + g = -155.25485562709179 - 0.44596950469579133 * (g = temp-2) + 104.49216199393888 * log(g); + b = temp < 20 ? 0 : -254.76935184120902 + 0.8274096064007395 * (b = temp-10) + 115.67994401066147 * log(b); + } else { + r = 351.97690566805693 + 0.114206453784165 * (r = temp-55) - 40.25366309332127 * log(r); + g = 325.4494125711974 + 0.07943456536662342 * (g = temp-50) - 28.0852963507957 * log(g); + b = 255; + } + return [r,g,b,1]; + }; + + var temperature2rgb_1 = temperature2rgb; + + /* + * Based on implementation by Neil Bartlett + * https://github.com/neilbartlett/color-temperature + **/ + + + var unpack$v = utils.unpack; + var round$6 = Math.round; + + var rgb2temperature = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var rgb = unpack$v(args, 'rgb'); + var r = rgb[0], b = rgb[2]; + var minTemp = 1000; + var maxTemp = 40000; + var eps = 0.4; + var temp; + while (maxTemp - minTemp > eps) { + temp = (maxTemp + minTemp) * 0.5; + var rgb$1 = temperature2rgb_1(temp); + if ((rgb$1[2] / rgb$1[0]) >= (b / r)) { + maxTemp = temp; + } else { + minTemp = temp; + } + } + return round$6(temp); + }; + + var rgb2temperature_1 = rgb2temperature; + + Color_1.prototype.temp = + Color_1.prototype.kelvin = + Color_1.prototype.temperature = function() { + return rgb2temperature_1(this._rgb); + }; + + chroma_1.temp = + chroma_1.kelvin = + chroma_1.temperature = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['temp']) )); + }; + + input.format.temp = + input.format.kelvin = + input.format.temperature = temperature2rgb_1; + + var type$f = utils.type; + + Color_1.prototype.alpha = function(a, mutate) { + if ( mutate === void 0 ) mutate=false; + + if (a !== undefined && type$f(a) === 'number') { + if (mutate) { + this._rgb[3] = a; + return this; + } + return new Color_1([this._rgb[0], this._rgb[1], this._rgb[2], a], 'rgb'); + } + return this._rgb[3]; + }; + + Color_1.prototype.clipped = function() { + return this._rgb._clipped || false; + }; + + Color_1.prototype.darken = function(amount) { + if ( amount === void 0 ) amount=1; + + var me = this; + var lab = me.lab(); + lab[0] -= labConstants.Kn * amount; + return new Color_1(lab, 'lab').alpha(me.alpha(), true); + }; + + Color_1.prototype.brighten = function(amount) { + if ( amount === void 0 ) amount=1; + + return this.darken(-amount); + }; + + Color_1.prototype.darker = Color_1.prototype.darken; + Color_1.prototype.brighter = Color_1.prototype.brighten; + + Color_1.prototype.get = function(mc) { + var ref = mc.split('.'); + var mode = ref[0]; + var channel = ref[1]; + var src = this[mode](); + if (channel) { + var i = mode.indexOf(channel); + if (i > -1) { return src[i]; } + throw new Error(("unknown channel " + channel + " in mode " + mode)); + } else { + return src; + } + }; + + var type$g = utils.type; + var pow$2 = Math.pow; + + var EPS = 1e-7; + var MAX_ITER = 20; + + Color_1.prototype.luminance = function(lum) { + if (lum !== undefined && type$g(lum) === 'number') { + if (lum === 0) { + // return pure black + return new Color_1([0,0,0,this._rgb[3]], 'rgb'); + } + if (lum === 1) { + // return pure white + return new Color_1([255,255,255,this._rgb[3]], 'rgb'); + } + // compute new color using... + var cur_lum = this.luminance(); + var mode = 'rgb'; + var max_iter = MAX_ITER; + + var test = function (low, high) { + var mid = low.interpolate(high, 0.5, mode); + var lm = mid.luminance(); + if (Math.abs(lum - lm) < EPS || !max_iter--) { + // close enough + return mid; + } + return lm > lum ? test(low, mid) : test(mid, high); + }; + + var rgb = (cur_lum > lum ? test(new Color_1([0,0,0]), this) : test(this, new Color_1([255,255,255]))).rgb(); + return new Color_1(rgb.concat( [this._rgb[3]])); + } + return rgb2luminance.apply(void 0, (this._rgb).slice(0,3)); + }; + + + var rgb2luminance = function (r,g,b) { + // relative luminance + // see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef + r = luminance_x(r); + g = luminance_x(g); + b = luminance_x(b); + return 0.2126 * r + 0.7152 * g + 0.0722 * b; + }; + + var luminance_x = function (x) { + x /= 255; + return x <= 0.03928 ? x/12.92 : pow$2((x+0.055)/1.055, 2.4); + }; + + var interpolator = {}; + + var type$h = utils.type; + + + var mix = function (col1, col2, f) { + if ( f === void 0 ) f=0.5; + var rest = [], len = arguments.length - 3; + while ( len-- > 0 ) rest[ len ] = arguments[ len + 3 ]; + + var mode = rest[0] || 'lrgb'; + if (!interpolator[mode] && !rest.length) { + // fall back to the first supported mode + mode = Object.keys(interpolator)[0]; + } + if (!interpolator[mode]) { + throw new Error(("interpolation mode " + mode + " is not defined")); + } + if (type$h(col1) !== 'object') { col1 = new Color_1(col1); } + if (type$h(col2) !== 'object') { col2 = new Color_1(col2); } + return interpolator[mode](col1, col2, f) + .alpha(col1.alpha() + f * (col2.alpha() - col1.alpha())); + }; + + Color_1.prototype.mix = + Color_1.prototype.interpolate = function(col2, f) { + if ( f === void 0 ) f=0.5; + var rest = [], len = arguments.length - 2; + while ( len-- > 0 ) rest[ len ] = arguments[ len + 2 ]; + + return mix.apply(void 0, [ this, col2, f ].concat( rest )); + }; + + Color_1.prototype.premultiply = function(mutate) { + if ( mutate === void 0 ) mutate=false; + + var rgb = this._rgb; + var a = rgb[3]; + if (mutate) { + this._rgb = [rgb[0]*a, rgb[1]*a, rgb[2]*a, a]; + return this; + } else { + return new Color_1([rgb[0]*a, rgb[1]*a, rgb[2]*a, a], 'rgb'); + } + }; + + Color_1.prototype.saturate = function(amount) { + if ( amount === void 0 ) amount=1; + + var me = this; + var lch = me.lch(); + lch[1] += labConstants.Kn * amount; + if (lch[1] < 0) { lch[1] = 0; } + return new Color_1(lch, 'lch').alpha(me.alpha(), true); + }; + + Color_1.prototype.desaturate = function(amount) { + if ( amount === void 0 ) amount=1; + + return this.saturate(-amount); + }; + + var type$i = utils.type; + + Color_1.prototype.set = function(mc, value, mutate) { + if ( mutate === void 0 ) mutate=false; + + var ref = mc.split('.'); + var mode = ref[0]; + var channel = ref[1]; + var src = this[mode](); + if (channel) { + var i = mode.indexOf(channel); + if (i > -1) { + if (type$i(value) == 'string') { + switch(value.charAt(0)) { + case '+': src[i] += +value; break; + case '-': src[i] += +value; break; + case '*': src[i] *= +(value.substr(1)); break; + case '/': src[i] /= +(value.substr(1)); break; + default: src[i] = +value; + } + } else if (type$i(value) === 'number') { + src[i] = value; + } else { + throw new Error("unsupported value for Color.set"); + } + var out = new Color_1(src, mode); + if (mutate) { + this._rgb = out._rgb; + return this; + } + return out; + } + throw new Error(("unknown channel " + channel + " in mode " + mode)); + } else { + return src; + } + }; + + var rgb$1 = function (col1, col2, f) { + var xyz0 = col1._rgb; + var xyz1 = col2._rgb; + return new Color_1( + xyz0[0] + f * (xyz1[0]-xyz0[0]), + xyz0[1] + f * (xyz1[1]-xyz0[1]), + xyz0[2] + f * (xyz1[2]-xyz0[2]), + 'rgb' + ) + }; + + // register interpolator + interpolator.rgb = rgb$1; + + var sqrt$2 = Math.sqrt; + var pow$3 = Math.pow; + + var lrgb = function (col1, col2, f) { + var ref = col1._rgb; + var x1 = ref[0]; + var y1 = ref[1]; + var z1 = ref[2]; + var ref$1 = col2._rgb; + var x2 = ref$1[0]; + var y2 = ref$1[1]; + var z2 = ref$1[2]; + return new Color_1( + sqrt$2(pow$3(x1,2) * (1-f) + pow$3(x2,2) * f), + sqrt$2(pow$3(y1,2) * (1-f) + pow$3(y2,2) * f), + sqrt$2(pow$3(z1,2) * (1-f) + pow$3(z2,2) * f), + 'rgb' + ) + }; + + // register interpolator + interpolator.lrgb = lrgb; + + var lab$1 = function (col1, col2, f) { + var xyz0 = col1.lab(); + var xyz1 = col2.lab(); + return new Color_1( + xyz0[0] + f * (xyz1[0]-xyz0[0]), + xyz0[1] + f * (xyz1[1]-xyz0[1]), + xyz0[2] + f * (xyz1[2]-xyz0[2]), + 'lab' + ) + }; + + // register interpolator + interpolator.lab = lab$1; + + var _hsx = function (col1, col2, f, m) { + var assign, assign$1; + + var xyz0, xyz1; + if (m === 'hsl') { + xyz0 = col1.hsl(); + xyz1 = col2.hsl(); + } else if (m === 'hsv') { + xyz0 = col1.hsv(); + xyz1 = col2.hsv(); + } else if (m === 'hcg') { + xyz0 = col1.hcg(); + xyz1 = col2.hcg(); + } else if (m === 'hsi') { + xyz0 = col1.hsi(); + xyz1 = col2.hsi(); + } else if (m === 'lch' || m === 'hcl') { + m = 'hcl'; + xyz0 = col1.hcl(); + xyz1 = col2.hcl(); + } + + var hue0, hue1, sat0, sat1, lbv0, lbv1; + if (m.substr(0, 1) === 'h') { + (assign = xyz0, hue0 = assign[0], sat0 = assign[1], lbv0 = assign[2]); + (assign$1 = xyz1, hue1 = assign$1[0], sat1 = assign$1[1], lbv1 = assign$1[2]); + } + + var sat, hue, lbv, dh; + + if (!isNaN(hue0) && !isNaN(hue1)) { + // both colors have hue + if (hue1 > hue0 && hue1 - hue0 > 180) { + dh = hue1-(hue0+360); + } else if (hue1 < hue0 && hue0 - hue1 > 180) { + dh = hue1+360-hue0; + } else{ + dh = hue1 - hue0; + } + hue = hue0 + f * dh; + } else if (!isNaN(hue0)) { + hue = hue0; + if ((lbv1 == 1 || lbv1 == 0) && m != 'hsv') { sat = sat0; } + } else if (!isNaN(hue1)) { + hue = hue1; + if ((lbv0 == 1 || lbv0 == 0) && m != 'hsv') { sat = sat1; } + } else { + hue = Number.NaN; + } + + if (sat === undefined) { sat = sat0 + f * (sat1 - sat0); } + lbv = lbv0 + f * (lbv1-lbv0); + return new Color_1([hue, sat, lbv], m); + }; + + var lch$1 = function (col1, col2, f) { + return _hsx(col1, col2, f, 'lch'); + }; + + // register interpolator + interpolator.lch = lch$1; + interpolator.hcl = lch$1; + + var num$1 = function (col1, col2, f) { + var c1 = col1.num(); + var c2 = col2.num(); + return new Color_1(c1 + f * (c2-c1), 'num') + }; + + // register interpolator + interpolator.num = num$1; + + var hcg$1 = function (col1, col2, f) { + return _hsx(col1, col2, f, 'hcg'); + }; + + // register interpolator + interpolator.hcg = hcg$1; + + var hsi$1 = function (col1, col2, f) { + return _hsx(col1, col2, f, 'hsi'); + }; + + // register interpolator + interpolator.hsi = hsi$1; + + var hsl$1 = function (col1, col2, f) { + return _hsx(col1, col2, f, 'hsl'); + }; + + // register interpolator + interpolator.hsl = hsl$1; + + var hsv$1 = function (col1, col2, f) { + return _hsx(col1, col2, f, 'hsv'); + }; + + // register interpolator + interpolator.hsv = hsv$1; + + var clip_rgb$2 = utils.clip_rgb; + var pow$4 = Math.pow; + var sqrt$3 = Math.sqrt; + var PI$1 = Math.PI; + var cos$2 = Math.cos; + var sin$1 = Math.sin; + var atan2$1 = Math.atan2; + + var average = function (colors, mode, weights) { + if ( mode === void 0 ) mode='lrgb'; + if ( weights === void 0 ) weights=null; + + var l = colors.length; + if (!weights) { weights = Array.from(new Array(l)).map(function () { return 1; }); } + // normalize weights + var k = l / weights.reduce(function(a, b) { return a + b; }); + weights.forEach(function (w,i) { weights[i] *= k; }); + // convert colors to Color objects + colors = colors.map(function (c) { return new Color_1(c); }); + if (mode === 'lrgb') { + return _average_lrgb(colors, weights) + } + var first = colors.shift(); + var xyz = first.get(mode); + var cnt = []; + var dx = 0; + var dy = 0; + // initial color + for (var i=0; i= 360) { A$1 -= 360; } + xyz[i$1] = A$1; + } else { + xyz[i$1] = xyz[i$1]/cnt[i$1]; + } + } + alpha /= l; + return (new Color_1(xyz, mode)).alpha(alpha > 0.99999 ? 1 : alpha, true); + }; + + + var _average_lrgb = function (colors, weights) { + var l = colors.length; + var xyz = [0,0,0,0]; + for (var i=0; i < colors.length; i++) { + var col = colors[i]; + var f = weights[i] / l; + var rgb = col._rgb; + xyz[0] += pow$4(rgb[0],2) * f; + xyz[1] += pow$4(rgb[1],2) * f; + xyz[2] += pow$4(rgb[2],2) * f; + xyz[3] += rgb[3] * f; + } + xyz[0] = sqrt$3(xyz[0]); + xyz[1] = sqrt$3(xyz[1]); + xyz[2] = sqrt$3(xyz[2]); + if (xyz[3] > 0.9999999) { xyz[3] = 1; } + return new Color_1(clip_rgb$2(xyz)); + }; + + // minimal multi-purpose interface + + // @requires utils color analyze + + + var type$j = utils.type; + + var pow$5 = Math.pow; + + var scale = function(colors) { + + // constructor + var _mode = 'rgb'; + var _nacol = chroma_1('#ccc'); + var _spread = 0; + // const _fixed = false; + var _domain = [0, 1]; + var _pos = []; + var _padding = [0,0]; + var _classes = false; + var _colors = []; + var _out = false; + var _min = 0; + var _max = 1; + var _correctLightness = false; + var _colorCache = {}; + var _useCache = true; + var _gamma = 1; + + // private methods + + var setColors = function(colors) { + colors = colors || ['#fff', '#000']; + if (colors && type$j(colors) === 'string' && chroma_1.brewer && + chroma_1.brewer[colors.toLowerCase()]) { + colors = chroma_1.brewer[colors.toLowerCase()]; + } + if (type$j(colors) === 'array') { + // handle single color + if (colors.length === 1) { + colors = [colors[0], colors[0]]; + } + // make a copy of the colors + colors = colors.slice(0); + // convert to chroma classes + for (var c=0; c= _classes[i]) { + i++; + } + return i-1; + } + return 0; + }; + + var tMapLightness = function (t) { return t; }; + var tMapDomain = function (t) { return t; }; + + // const classifyValue = function(value) { + // let val = value; + // if (_classes.length > 2) { + // const n = _classes.length-1; + // const i = getClass(value); + // const minc = _classes[0] + ((_classes[1]-_classes[0]) * (0 + (_spread * 0.5))); // center of 1st class + // const maxc = _classes[n-1] + ((_classes[n]-_classes[n-1]) * (1 - (_spread * 0.5))); // center of last class + // val = _min + ((((_classes[i] + ((_classes[i+1] - _classes[i]) * 0.5)) - minc) / (maxc-minc)) * (_max - _min)); + // } + // return val; + // }; + + var getColor = function(val, bypassMap) { + var col, t; + if (bypassMap == null) { bypassMap = false; } + if (isNaN(val) || (val === null)) { return _nacol; } + if (!bypassMap) { + if (_classes && (_classes.length > 2)) { + // find the class + var c = getClass(val); + t = c / (_classes.length-2); + } else if (_max !== _min) { + // just interpolate between min/max + t = (val - _min) / (_max - _min); + } else { + t = 1; + } + } else { + t = val; + } + + // domain map + t = tMapDomain(t); + + if (!bypassMap) { + t = tMapLightness(t); // lightness correction + } + + if (_gamma !== 1) { t = pow$5(t, _gamma); } + + t = _padding[0] + (t * (1 - _padding[0] - _padding[1])); + + t = Math.min(1, Math.max(0, t)); + + var k = Math.floor(t * 10000); + + if (_useCache && _colorCache[k]) { + col = _colorCache[k]; + } else { + if (type$j(_colors) === 'array') { + //for i in [0.._pos.length-1] + for (var i=0; i<_pos.length; i++) { + var p = _pos[i]; + if (t <= p) { + col = _colors[i]; + break; + } + if ((t >= p) && (i === (_pos.length-1))) { + col = _colors[i]; + break; + } + if (t > p && t < _pos[i+1]) { + t = (t-p)/(_pos[i+1]-p); + col = chroma_1.interpolate(_colors[i], _colors[i+1], t, _mode); + break; + } + } + } else if (type$j(_colors) === 'function') { + col = _colors(t); + } + if (_useCache) { _colorCache[k] = col; } + } + return col; + }; + + var resetCache = function () { return _colorCache = {}; }; + + setColors(colors); + + // public interface + + var f = function(v) { + var c = chroma_1(getColor(v)); + if (_out && c[_out]) { return c[_out](); } else { return c; } + }; + + f.classes = function(classes) { + if (classes != null) { + if (type$j(classes) === 'array') { + _classes = classes; + _domain = [classes[0], classes[classes.length-1]]; + } else { + var d = chroma_1.analyze(_domain); + if (classes === 0) { + _classes = [d.min, d.max]; + } else { + _classes = chroma_1.limits(d, 'e', classes); + } + } + return f; + } + return _classes; + }; + + + f.domain = function(domain) { + if (!arguments.length) { + return _domain; + } + _min = domain[0]; + _max = domain[domain.length-1]; + _pos = []; + var k = _colors.length; + if ((domain.length === k) && (_min !== _max)) { + // update positions + for (var i = 0, list = Array.from(domain); i < list.length; i += 1) { + var d = list[i]; + + _pos.push((d-_min) / (_max-_min)); + } + } else { + for (var c=0; c 2) { + // set domain map + var tOut = domain.map(function (d,i) { return i/(domain.length-1); }); + var tBreaks = domain.map(function (d) { return (d - _min) / (_max - _min); }); + if (!tBreaks.every(function (val, i) { return tOut[i] === val; })) { + tMapDomain = function (t) { + if (t <= 0 || t >= 1) { return t; } + var i = 0; + while (t >= tBreaks[i+1]) { i++; } + var f = (t - tBreaks[i]) / (tBreaks[i+1] - tBreaks[i]); + var out = tOut[i] + f * (tOut[i+1] - tOut[i]); + return out; + }; + } + + } + } + _domain = [_min, _max]; + return f; + }; + + f.mode = function(_m) { + if (!arguments.length) { + return _mode; + } + _mode = _m; + resetCache(); + return f; + }; + + f.range = function(colors, _pos) { + setColors(colors, _pos); + return f; + }; + + f.out = function(_o) { + _out = _o; + return f; + }; + + f.spread = function(val) { + if (!arguments.length) { + return _spread; + } + _spread = val; + return f; + }; + + f.correctLightness = function(v) { + if (v == null) { v = true; } + _correctLightness = v; + resetCache(); + if (_correctLightness) { + tMapLightness = function(t) { + var L0 = getColor(0, true).lab()[0]; + var L1 = getColor(1, true).lab()[0]; + var pol = L0 > L1; + var L_actual = getColor(t, true).lab()[0]; + var L_ideal = L0 + ((L1 - L0) * t); + var L_diff = L_actual - L_ideal; + var t0 = 0; + var t1 = 1; + var max_iter = 20; + while ((Math.abs(L_diff) > 1e-2) && (max_iter-- > 0)) { + (function() { + if (pol) { L_diff *= -1; } + if (L_diff < 0) { + t0 = t; + t += (t1 - t) * 0.5; + } else { + t1 = t; + t += (t0 - t) * 0.5; + } + L_actual = getColor(t, true).lab()[0]; + return L_diff = L_actual - L_ideal; + })(); + } + return t; + }; + } else { + tMapLightness = function (t) { return t; }; + } + return f; + }; + + f.padding = function(p) { + if (p != null) { + if (type$j(p) === 'number') { + p = [p,p]; + } + _padding = p; + return f; + } else { + return _padding; + } + }; + + f.colors = function(numColors, out) { + // If no arguments are given, return the original colors that were provided + if (arguments.length < 2) { out = 'hex'; } + var result = []; + + if (arguments.length === 0) { + result = _colors.slice(0); + + } else if (numColors === 1) { + result = [f(0.5)]; + + } else if (numColors > 1) { + var dm = _domain[0]; + var dd = _domain[1] - dm; + result = __range__(0, numColors, false).map(function (i) { return f( dm + ((i/(numColors-1)) * dd) ); }); + + } else { // returns all colors based on the defined classes + colors = []; + var samples = []; + if (_classes && (_classes.length > 2)) { + for (var i = 1, end = _classes.length, asc = 1 <= end; asc ? i < end : i > end; asc ? i++ : i--) { + samples.push((_classes[i-1]+_classes[i])*0.5); + } + } else { + samples = _domain; + } + result = samples.map(function (v) { return f(v); }); + } + + if (chroma_1[out]) { + result = result.map(function (c) { return c[out](); }); + } + return result; + }; + + f.cache = function(c) { + if (c != null) { + _useCache = c; + return f; + } else { + return _useCache; + } + }; + + f.gamma = function(g) { + if (g != null) { + _gamma = g; + return f; + } else { + return _gamma; + } + }; + + f.nodata = function(d) { + if (d != null) { + _nacol = chroma_1(d); + return f; + } else { + return _nacol; + } + }; + + return f; + }; + + function __range__(left, right, inclusive) { + var range = []; + var ascending = left < right; + var end = !inclusive ? right : ascending ? right + 1 : right - 1; + for (var i = left; ascending ? i < end : i > end; ascending ? i++ : i--) { + range.push(i); + } + return range; + } + + // + // interpolates between a set of colors uzing a bezier spline + // + + // @requires utils lab + + + + + var bezier = function(colors) { + var assign, assign$1, assign$2; + + var I, lab0, lab1, lab2; + colors = colors.map(function (c) { return new Color_1(c); }); + if (colors.length === 2) { + // linear interpolation + (assign = colors.map(function (c) { return c.lab(); }), lab0 = assign[0], lab1 = assign[1]); + I = function(t) { + var lab = ([0, 1, 2].map(function (i) { return lab0[i] + (t * (lab1[i] - lab0[i])); })); + return new Color_1(lab, 'lab'); + }; + } else if (colors.length === 3) { + // quadratic bezier interpolation + (assign$1 = colors.map(function (c) { return c.lab(); }), lab0 = assign$1[0], lab1 = assign$1[1], lab2 = assign$1[2]); + I = function(t) { + var lab = ([0, 1, 2].map(function (i) { return ((1-t)*(1-t) * lab0[i]) + (2 * (1-t) * t * lab1[i]) + (t * t * lab2[i]); })); + return new Color_1(lab, 'lab'); + }; + } else if (colors.length === 4) { + // cubic bezier interpolation + var lab3; + (assign$2 = colors.map(function (c) { return c.lab(); }), lab0 = assign$2[0], lab1 = assign$2[1], lab2 = assign$2[2], lab3 = assign$2[3]); + I = function(t) { + var lab = ([0, 1, 2].map(function (i) { return ((1-t)*(1-t)*(1-t) * lab0[i]) + (3 * (1-t) * (1-t) * t * lab1[i]) + (3 * (1-t) * t * t * lab2[i]) + (t*t*t * lab3[i]); })); + return new Color_1(lab, 'lab'); + }; + } else if (colors.length === 5) { + var I0 = bezier(colors.slice(0, 3)); + var I1 = bezier(colors.slice(2, 5)); + I = function(t) { + if (t < 0.5) { + return I0(t*2); + } else { + return I1((t-0.5)*2); + } + }; + } + return I; + }; + + var bezier_1 = function (colors) { + var f = bezier(colors); + f.scale = function () { return scale(f); }; + return f; + }; + + /* + * interpolates between a set of colors uzing a bezier spline + * blend mode formulas taken from http://www.venture-ware.com/kevin/coding/lets-learn-math-photoshop-blend-modes/ + */ + + + + + var blend = function (bottom, top, mode) { + if (!blend[mode]) { + throw new Error('unknown blend mode ' + mode); + } + return blend[mode](bottom, top); + }; + + var blend_f = function (f) { return function (bottom,top) { + var c0 = chroma_1(top).rgb(); + var c1 = chroma_1(bottom).rgb(); + return chroma_1.rgb(f(c0, c1)); + }; }; + + var each = function (f) { return function (c0, c1) { + var out = []; + out[0] = f(c0[0], c1[0]); + out[1] = f(c0[1], c1[1]); + out[2] = f(c0[2], c1[2]); + return out; + }; }; + + var normal = function (a) { return a; }; + var multiply = function (a,b) { return a * b / 255; }; + var darken$1 = function (a,b) { return a > b ? b : a; }; + var lighten = function (a,b) { return a > b ? a : b; }; + var screen = function (a,b) { return 255 * (1 - (1-a/255) * (1-b/255)); }; + var overlay = function (a,b) { return b < 128 ? 2 * a * b / 255 : 255 * (1 - 2 * (1 - a / 255 ) * ( 1 - b / 255 )); }; + var burn = function (a,b) { return 255 * (1 - (1 - b / 255) / (a/255)); }; + var dodge = function (a,b) { + if (a === 255) { return 255; } + a = 255 * (b / 255) / (1 - a / 255); + return a > 255 ? 255 : a + }; + + // # add = (a,b) -> + // # if (a + b > 255) then 255 else a + b + + blend.normal = blend_f(each(normal)); + blend.multiply = blend_f(each(multiply)); + blend.screen = blend_f(each(screen)); + blend.overlay = blend_f(each(overlay)); + blend.darken = blend_f(each(darken$1)); + blend.lighten = blend_f(each(lighten)); + blend.dodge = blend_f(each(dodge)); + blend.burn = blend_f(each(burn)); + // blend.add = blend_f(each(add)); + + var blend_1 = blend; + + // cubehelix interpolation + // based on D.A. Green "A colour scheme for the display of astronomical intensity images" + // http://astron-soc.in/bulletin/11June/289392011.pdf + + var type$k = utils.type; + var clip_rgb$3 = utils.clip_rgb; + var TWOPI$2 = utils.TWOPI; + var pow$6 = Math.pow; + var sin$2 = Math.sin; + var cos$3 = Math.cos; + + + var cubehelix = function(start, rotations, hue, gamma, lightness) { + if ( start === void 0 ) start=300; + if ( rotations === void 0 ) rotations=-1.5; + if ( hue === void 0 ) hue=1; + if ( gamma === void 0 ) gamma=1; + if ( lightness === void 0 ) lightness=[0,1]; + + var dh = 0, dl; + if (type$k(lightness) === 'array') { + dl = lightness[1] - lightness[0]; + } else { + dl = 0; + lightness = [lightness, lightness]; + } + + var f = function(fract) { + var a = TWOPI$2 * (((start+120)/360) + (rotations * fract)); + var l = pow$6(lightness[0] + (dl * fract), gamma); + var h = dh !== 0 ? hue[0] + (fract * dh) : hue; + var amp = (h * l * (1-l)) / 2; + var cos_a = cos$3(a); + var sin_a = sin$2(a); + var r = l + (amp * ((-0.14861 * cos_a) + (1.78277* sin_a))); + var g = l + (amp * ((-0.29227 * cos_a) - (0.90649* sin_a))); + var b = l + (amp * (+1.97294 * cos_a)); + return chroma_1(clip_rgb$3([r*255,g*255,b*255,1])); + }; + + f.start = function(s) { + if ((s == null)) { return start; } + start = s; + return f; + }; + + f.rotations = function(r) { + if ((r == null)) { return rotations; } + rotations = r; + return f; + }; + + f.gamma = function(g) { + if ((g == null)) { return gamma; } + gamma = g; + return f; + }; + + f.hue = function(h) { + if ((h == null)) { return hue; } + hue = h; + if (type$k(hue) === 'array') { + dh = hue[1] - hue[0]; + if (dh === 0) { hue = hue[1]; } + } else { + dh = 0; + } + return f; + }; + + f.lightness = function(h) { + if ((h == null)) { return lightness; } + if (type$k(h) === 'array') { + lightness = h; + dl = h[1] - h[0]; + } else { + lightness = [h,h]; + dl = 0; + } + return f; + }; + + f.scale = function () { return chroma_1.scale(f); }; + + f.hue(hue); + + return f; + }; + + var digits = '0123456789abcdef'; + + var floor$2 = Math.floor; + var random = Math.random; + + var random_1 = function () { + var code = '#'; + for (var i=0; i<6; i++) { + code += digits.charAt(floor$2(random() * 16)); + } + return new Color_1(code, 'hex'); + }; + + var log$1 = Math.log; + var pow$7 = Math.pow; + var floor$3 = Math.floor; + var abs = Math.abs; + + + var analyze = function (data, key) { + if ( key === void 0 ) key=null; + + var r = { + min: Number.MAX_VALUE, + max: Number.MAX_VALUE*-1, + sum: 0, + values: [], + count: 0 + }; + if (type(data) === 'object') { + data = Object.values(data); + } + data.forEach(function (val) { + if (key && type(val) === 'object') { val = val[key]; } + if (val !== undefined && val !== null && !isNaN(val)) { + r.values.push(val); + r.sum += val; + if (val < r.min) { r.min = val; } + if (val > r.max) { r.max = val; } + r.count += 1; + } + }); + + r.domain = [r.min, r.max]; + + r.limits = function (mode, num) { return limits(r, mode, num); }; + + return r; + }; + + + var limits = function (data, mode, num) { + if ( mode === void 0 ) mode='equal'; + if ( num === void 0 ) num=7; + + if (type(data) == 'array') { + data = analyze(data); + } + var min = data.min; + var max = data.max; + var values = data.values.sort(function (a,b) { return a-b; }); + + if (num === 1) { return [min,max]; } + + var limits = []; + + if (mode.substr(0,1) === 'c') { // continuous + limits.push(min); + limits.push(max); + } + + if (mode.substr(0,1) === 'e') { // equal interval + limits.push(min); + for (var i=1; i 0'); + } + var min_log = Math.LOG10E * log$1(min); + var max_log = Math.LOG10E * log$1(max); + limits.push(min); + for (var i$1=1; i$1 pb + var pr = p - pb; + limits.push((values[pb]*(1-pr)) + (values[pb+1]*pr)); + } + } + limits.push(max); + + } + + else if (mode.substr(0,1) === 'k') { // k-means clustering + /* + implementation based on + http://code.google.com/p/figue/source/browse/trunk/figue.js#336 + simplified for 1-d input values + */ + var cluster; + var n = values.length; + var assignments = new Array(n); + var clusterSizes = new Array(num); + var repeat = true; + var nb_iters = 0; + var centroids = null; + + // get seed values + centroids = []; + centroids.push(min); + for (var i$3=1; i$3 200) { + repeat = false; + } + } + + // finished k-means clustering + // the next part is borrowed from gabrielflor.it + var kClusters = {}; + for (var j$5=0; j$5 l2 ? (l1 + 0.05) / (l2 + 0.05) : (l2 + 0.05) / (l1 + 0.05); + }; + + var sqrt$4 = Math.sqrt; + var atan2$2 = Math.atan2; + var abs$1 = Math.abs; + var cos$4 = Math.cos; + var PI$2 = Math.PI; + + var deltaE = function(a, b, L, C) { + if ( L === void 0 ) L=1; + if ( C === void 0 ) C=1; + + // Delta E (CMC) + // see http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CMC.html + a = new Color_1(a); + b = new Color_1(b); + var ref = Array.from(a.lab()); + var L1 = ref[0]; + var a1 = ref[1]; + var b1 = ref[2]; + var ref$1 = Array.from(b.lab()); + var L2 = ref$1[0]; + var a2 = ref$1[1]; + var b2 = ref$1[2]; + var c1 = sqrt$4((a1 * a1) + (b1 * b1)); + var c2 = sqrt$4((a2 * a2) + (b2 * b2)); + var sl = L1 < 16.0 ? 0.511 : (0.040975 * L1) / (1.0 + (0.01765 * L1)); + var sc = ((0.0638 * c1) / (1.0 + (0.0131 * c1))) + 0.638; + var h1 = c1 < 0.000001 ? 0.0 : (atan2$2(b1, a1) * 180.0) / PI$2; + while (h1 < 0) { h1 += 360; } + while (h1 >= 360) { h1 -= 360; } + var t = (h1 >= 164.0) && (h1 <= 345.0) ? (0.56 + abs$1(0.2 * cos$4((PI$2 * (h1 + 168.0)) / 180.0))) : (0.36 + abs$1(0.4 * cos$4((PI$2 * (h1 + 35.0)) / 180.0))); + var c4 = c1 * c1 * c1 * c1; + var f = sqrt$4(c4 / (c4 + 1900.0)); + var sh = sc * (((f * t) + 1.0) - f); + var delL = L1 - L2; + var delC = c1 - c2; + var delA = a1 - a2; + var delB = b1 - b2; + var dH2 = ((delA * delA) + (delB * delB)) - (delC * delC); + var v1 = delL / (L * sl); + var v2 = delC / (C * sc); + var v3 = sh; + return sqrt$4((v1 * v1) + (v2 * v2) + (dH2 / (v3 * v3))); + }; + + // simple Euclidean distance + var distance = function(a, b, mode) { + if ( mode === void 0 ) mode='lab'; + + // Delta E (CIE 1976) + // see http://www.brucelindbloom.com/index.html?Equations.html + a = new Color_1(a); + b = new Color_1(b); + var l1 = a.get(mode); + var l2 = b.get(mode); + var sum_sq = 0; + for (var i in l1) { + var d = (l1[i] || 0) - (l2[i] || 0); + sum_sq += d*d; + } + return Math.sqrt(sum_sq); + }; + + var valid = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + try { + new (Function.prototype.bind.apply( Color_1, [ null ].concat( args) )); + return true; + } catch (e) { + return false; + } + }; + + // some pre-defined color scales: + + + + + var scales = { + cool: function cool() { return scale([chroma_1.hsl(180,1,.9), chroma_1.hsl(250,.7,.4)]) }, + hot: function hot() { return scale(['#000','#f00','#ff0','#fff'], [0,.25,.75,1]).mode('rgb') } + }; + + /** + ColorBrewer colors for chroma.js + + Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The + Pennsylvania State University. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software distributed + under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + CONDITIONS OF ANY KIND, either express or implied. See the License for the + specific language governing permissions and limitations under the License. + */ + + var colorbrewer = { + // sequential + OrRd: ['#fff7ec', '#fee8c8', '#fdd49e', '#fdbb84', '#fc8d59', '#ef6548', '#d7301f', '#b30000', '#7f0000'], + PuBu: ['#fff7fb', '#ece7f2', '#d0d1e6', '#a6bddb', '#74a9cf', '#3690c0', '#0570b0', '#045a8d', '#023858'], + BuPu: ['#f7fcfd', '#e0ecf4', '#bfd3e6', '#9ebcda', '#8c96c6', '#8c6bb1', '#88419d', '#810f7c', '#4d004b'], + Oranges: ['#fff5eb', '#fee6ce', '#fdd0a2', '#fdae6b', '#fd8d3c', '#f16913', '#d94801', '#a63603', '#7f2704'], + BuGn: ['#f7fcfd', '#e5f5f9', '#ccece6', '#99d8c9', '#66c2a4', '#41ae76', '#238b45', '#006d2c', '#00441b'], + YlOrBr: ['#ffffe5', '#fff7bc', '#fee391', '#fec44f', '#fe9929', '#ec7014', '#cc4c02', '#993404', '#662506'], + YlGn: ['#ffffe5', '#f7fcb9', '#d9f0a3', '#addd8e', '#78c679', '#41ab5d', '#238443', '#006837', '#004529'], + Reds: ['#fff5f0', '#fee0d2', '#fcbba1', '#fc9272', '#fb6a4a', '#ef3b2c', '#cb181d', '#a50f15', '#67000d'], + RdPu: ['#fff7f3', '#fde0dd', '#fcc5c0', '#fa9fb5', '#f768a1', '#dd3497', '#ae017e', '#7a0177', '#49006a'], + Greens: ['#f7fcf5', '#e5f5e0', '#c7e9c0', '#a1d99b', '#74c476', '#41ab5d', '#238b45', '#006d2c', '#00441b'], + YlGnBu: ['#ffffd9', '#edf8b1', '#c7e9b4', '#7fcdbb', '#41b6c4', '#1d91c0', '#225ea8', '#253494', '#081d58'], + Purples: ['#fcfbfd', '#efedf5', '#dadaeb', '#bcbddc', '#9e9ac8', '#807dba', '#6a51a3', '#54278f', '#3f007d'], + GnBu: ['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081'], + Greys: ['#ffffff', '#f0f0f0', '#d9d9d9', '#bdbdbd', '#969696', '#737373', '#525252', '#252525', '#000000'], + YlOrRd: ['#ffffcc', '#ffeda0', '#fed976', '#feb24c', '#fd8d3c', '#fc4e2a', '#e31a1c', '#bd0026', '#800026'], + PuRd: ['#f7f4f9', '#e7e1ef', '#d4b9da', '#c994c7', '#df65b0', '#e7298a', '#ce1256', '#980043', '#67001f'], + Blues: ['#f7fbff', '#deebf7', '#c6dbef', '#9ecae1', '#6baed6', '#4292c6', '#2171b5', '#08519c', '#08306b'], + PuBuGn: ['#fff7fb', '#ece2f0', '#d0d1e6', '#a6bddb', '#67a9cf', '#3690c0', '#02818a', '#016c59', '#014636'], + Viridis: ['#440154', '#482777', '#3f4a8a', '#31678e', '#26838f', '#1f9d8a', '#6cce5a', '#b6de2b', '#fee825'], + + // diverging + + Spectral: ['#9e0142', '#d53e4f', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#e6f598', '#abdda4', '#66c2a5', '#3288bd', '#5e4fa2'], + RdYlGn: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#d9ef8b', '#a6d96a', '#66bd63', '#1a9850', '#006837'], + RdBu: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#f7f7f7', '#d1e5f0', '#92c5de', '#4393c3', '#2166ac', '#053061'], + PiYG: ['#8e0152', '#c51b7d', '#de77ae', '#f1b6da', '#fde0ef', '#f7f7f7', '#e6f5d0', '#b8e186', '#7fbc41', '#4d9221', '#276419'], + PRGn: ['#40004b', '#762a83', '#9970ab', '#c2a5cf', '#e7d4e8', '#f7f7f7', '#d9f0d3', '#a6dba0', '#5aae61', '#1b7837', '#00441b'], + RdYlBu: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee090', '#ffffbf', '#e0f3f8', '#abd9e9', '#74add1', '#4575b4', '#313695'], + BrBG: ['#543005', '#8c510a', '#bf812d', '#dfc27d', '#f6e8c3', '#f5f5f5', '#c7eae5', '#80cdc1', '#35978f', '#01665e', '#003c30'], + RdGy: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#ffffff', '#e0e0e0', '#bababa', '#878787', '#4d4d4d', '#1a1a1a'], + PuOr: ['#7f3b08', '#b35806', '#e08214', '#fdb863', '#fee0b6', '#f7f7f7', '#d8daeb', '#b2abd2', '#8073ac', '#542788', '#2d004b'], + + // qualitative + + Set2: ['#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3', '#a6d854', '#ffd92f', '#e5c494', '#b3b3b3'], + Accent: ['#7fc97f', '#beaed4', '#fdc086', '#ffff99', '#386cb0', '#f0027f', '#bf5b17', '#666666'], + Set1: ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33', '#a65628', '#f781bf', '#999999'], + Set3: ['#8dd3c7', '#ffffb3', '#bebada', '#fb8072', '#80b1d3', '#fdb462', '#b3de69', '#fccde5', '#d9d9d9', '#bc80bd', '#ccebc5', '#ffed6f'], + Dark2: ['#1b9e77', '#d95f02', '#7570b3', '#e7298a', '#66a61e', '#e6ab02', '#a6761d', '#666666'], + Paired: ['#a6cee3', '#1f78b4', '#b2df8a', '#33a02c', '#fb9a99', '#e31a1c', '#fdbf6f', '#ff7f00', '#cab2d6', '#6a3d9a', '#ffff99', '#b15928'], + Pastel2: ['#b3e2cd', '#fdcdac', '#cbd5e8', '#f4cae4', '#e6f5c9', '#fff2ae', '#f1e2cc', '#cccccc'], + Pastel1: ['#fbb4ae', '#b3cde3', '#ccebc5', '#decbe4', '#fed9a6', '#ffffcc', '#e5d8bd', '#fddaec', '#f2f2f2'], + }; + + // add lowercase aliases for case-insensitive matches + for (var i$1 = 0, list$1 = Object.keys(colorbrewer); i$1 < list$1.length; i$1 += 1) { + var key = list$1[i$1]; + + colorbrewer[key.toLowerCase()] = colorbrewer[key]; + } + + var colorbrewer_1 = colorbrewer; + + // feel free to comment out anything to rollup + // a smaller chroma.js built + + // io --> convert colors + + + + + + + + + + + + + + + + // operators --> modify existing Colors + + + + + + + + + + + // interpolators + + + + + + + + + + + // generators -- > create new colors + chroma_1.average = average; + chroma_1.bezier = bezier_1; + chroma_1.blend = blend_1; + chroma_1.cubehelix = cubehelix; + chroma_1.mix = chroma_1.interpolate = mix; + chroma_1.random = random_1; + chroma_1.scale = scale; + + // other utility methods + chroma_1.analyze = analyze_1.analyze; + chroma_1.contrast = contrast; + chroma_1.deltaE = deltaE; + chroma_1.distance = distance; + chroma_1.limits = analyze_1.limits; + chroma_1.valid = valid; + + // scale + chroma_1.scales = scales; + + // colors + chroma_1.colors = w3cx11_1; + chroma_1.brewer = colorbrewer_1; + + var chroma_js = chroma_1; + + return chroma_js; + +}))); + + +/***/ }), + +/***/ "./node_modules/codemirror/lib/codemirror.js": +/*!***************************************************!*\ + !*** ./node_modules/codemirror/lib/codemirror.js ***! + \***************************************************/ +/***/ (function(module) { + +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +// This is CodeMirror (https://codemirror.net), a code editor +// implemented in JavaScript on top of the browser's DOM. +// +// You can find some technical background for some of the code below +// at http://marijnhaverbeke.nl/blog/#cm-internals . + +(function (global, factory) { + true ? module.exports = factory() : + 0; +}(this, (function () { 'use strict'; + + // Kludges for bugs and behavior differences that can't be feature + // detected are enabled based on userAgent etc sniffing. + var userAgent = navigator.userAgent; + var platform = navigator.platform; + + var gecko = /gecko\/\d/i.test(userAgent); + var ie_upto10 = /MSIE \d/.test(userAgent); + var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent); + var edge = /Edge\/(\d+)/.exec(userAgent); + var ie = ie_upto10 || ie_11up || edge; + var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]); + var webkit = !edge && /WebKit\//.test(userAgent); + var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent); + var chrome = !edge && /Chrome\//.test(userAgent); + var presto = /Opera\//.test(userAgent); + var safari = /Apple Computer/.test(navigator.vendor); + var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent); + var phantom = /PhantomJS/.test(userAgent); + + var ios = safari && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2); + var android = /Android/.test(userAgent); + // This is woefully incomplete. Suggestions for alternative methods welcome. + var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent); + var mac = ios || /Mac/.test(platform); + var chromeOS = /\bCrOS\b/.test(userAgent); + var windows = /win/i.test(platform); + + var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/); + if (presto_version) { presto_version = Number(presto_version[1]); } + if (presto_version && presto_version >= 15) { presto = false; webkit = true; } + // Some browsers use the wrong event properties to signal cmd/ctrl on OS X + var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11)); + var captureRightClick = gecko || (ie && ie_version >= 9); + + function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") } + + var rmClass = function(node, cls) { + var current = node.className; + var match = classTest(cls).exec(current); + if (match) { + var after = current.slice(match.index + match[0].length); + node.className = current.slice(0, match.index) + (after ? match[1] + after : ""); + } + }; + + function removeChildren(e) { + for (var count = e.childNodes.length; count > 0; --count) + { e.removeChild(e.firstChild); } + return e + } + + function removeChildrenAndAdd(parent, e) { + return removeChildren(parent).appendChild(e) + } + + function elt(tag, content, className, style) { + var e = document.createElement(tag); + if (className) { e.className = className; } + if (style) { e.style.cssText = style; } + if (typeof content == "string") { e.appendChild(document.createTextNode(content)); } + else if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]); } } + return e + } + // wrapper for elt, which removes the elt from the accessibility tree + function eltP(tag, content, className, style) { + var e = elt(tag, content, className, style); + e.setAttribute("role", "presentation"); + return e + } + + var range; + if (document.createRange) { range = function(node, start, end, endNode) { + var r = document.createRange(); + r.setEnd(endNode || node, end); + r.setStart(node, start); + return r + }; } + else { range = function(node, start, end) { + var r = document.body.createTextRange(); + try { r.moveToElementText(node.parentNode); } + catch(e) { return r } + r.collapse(true); + r.moveEnd("character", end); + r.moveStart("character", start); + return r + }; } + + function contains(parent, child) { + if (child.nodeType == 3) // Android browser always returns false when child is a textnode + { child = child.parentNode; } + if (parent.contains) + { return parent.contains(child) } + do { + if (child.nodeType == 11) { child = child.host; } + if (child == parent) { return true } + } while (child = child.parentNode) + } + + function activeElt() { + // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement. + // IE < 10 will throw when accessed while the page is loading or in an iframe. + // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable. + var activeElement; + try { + activeElement = document.activeElement; + } catch(e) { + activeElement = document.body || null; + } + while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement) + { activeElement = activeElement.shadowRoot.activeElement; } + return activeElement + } + + function addClass(node, cls) { + var current = node.className; + if (!classTest(cls).test(current)) { node.className += (current ? " " : "") + cls; } + } + function joinClasses(a, b) { + var as = a.split(" "); + for (var i = 0; i < as.length; i++) + { if (as[i] && !classTest(as[i]).test(b)) { b += " " + as[i]; } } + return b + } + + var selectInput = function(node) { node.select(); }; + if (ios) // Mobile Safari apparently has a bug where select() is broken. + { selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; }; } + else if (ie) // Suppress mysterious IE10 errors + { selectInput = function(node) { try { node.select(); } catch(_e) {} }; } + + function bind(f) { + var args = Array.prototype.slice.call(arguments, 1); + return function(){return f.apply(null, args)} + } + + function copyObj(obj, target, overwrite) { + if (!target) { target = {}; } + for (var prop in obj) + { if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop))) + { target[prop] = obj[prop]; } } + return target + } + + // Counts the column offset in a string, taking tabs into account. + // Used mostly to find indentation. + function countColumn(string, end, tabSize, startIndex, startValue) { + if (end == null) { + end = string.search(/[^\s\u00a0]/); + if (end == -1) { end = string.length; } + } + for (var i = startIndex || 0, n = startValue || 0;;) { + var nextTab = string.indexOf("\t", i); + if (nextTab < 0 || nextTab >= end) + { return n + (end - i) } + n += nextTab - i; + n += tabSize - (n % tabSize); + i = nextTab + 1; + } + } + + var Delayed = function() { + this.id = null; + this.f = null; + this.time = 0; + this.handler = bind(this.onTimeout, this); + }; + Delayed.prototype.onTimeout = function (self) { + self.id = 0; + if (self.time <= +new Date) { + self.f(); + } else { + setTimeout(self.handler, self.time - +new Date); + } + }; + Delayed.prototype.set = function (ms, f) { + this.f = f; + var time = +new Date + ms; + if (!this.id || time < this.time) { + clearTimeout(this.id); + this.id = setTimeout(this.handler, ms); + this.time = time; + } + }; + + function indexOf(array, elt) { + for (var i = 0; i < array.length; ++i) + { if (array[i] == elt) { return i } } + return -1 + } + + // Number of pixels added to scroller and sizer to hide scrollbar + var scrollerGap = 50; + + // Returned or thrown by various protocols to signal 'I'm not + // handling this'. + var Pass = {toString: function(){return "CodeMirror.Pass"}}; + + // Reused option objects for setSelection & friends + var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"}; + + // The inverse of countColumn -- find the offset that corresponds to + // a particular column. + function findColumn(string, goal, tabSize) { + for (var pos = 0, col = 0;;) { + var nextTab = string.indexOf("\t", pos); + if (nextTab == -1) { nextTab = string.length; } + var skipped = nextTab - pos; + if (nextTab == string.length || col + skipped >= goal) + { return pos + Math.min(skipped, goal - col) } + col += nextTab - pos; + col += tabSize - (col % tabSize); + pos = nextTab + 1; + if (col >= goal) { return pos } + } + } + + var spaceStrs = [""]; + function spaceStr(n) { + while (spaceStrs.length <= n) + { spaceStrs.push(lst(spaceStrs) + " "); } + return spaceStrs[n] + } + + function lst(arr) { return arr[arr.length-1] } + + function map(array, f) { + var out = []; + for (var i = 0; i < array.length; i++) { out[i] = f(array[i], i); } + return out + } + + function insertSorted(array, value, score) { + var pos = 0, priority = score(value); + while (pos < array.length && score(array[pos]) <= priority) { pos++; } + array.splice(pos, 0, value); + } + + function nothing() {} + + function createObj(base, props) { + var inst; + if (Object.create) { + inst = Object.create(base); + } else { + nothing.prototype = base; + inst = new nothing(); + } + if (props) { copyObj(props, inst); } + return inst + } + + var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/; + function isWordCharBasic(ch) { + return /\w/.test(ch) || ch > "\x80" && + (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)) + } + function isWordChar(ch, helper) { + if (!helper) { return isWordCharBasic(ch) } + if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) { return true } + return helper.test(ch) + } + + function isEmpty(obj) { + for (var n in obj) { if (obj.hasOwnProperty(n) && obj[n]) { return false } } + return true + } + + // Extending unicode characters. A series of a non-extending char + + // any number of extending chars is treated as a single unit as far + // as editing and measuring is concerned. This is not fully correct, + // since some scripts/fonts/browsers also treat other configurations + // of code points as a group. + var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/; + function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) } + + // Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range. + function skipExtendingChars(str, pos, dir) { + while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) { pos += dir; } + return pos + } + + // Returns the value from the range [`from`; `to`] that satisfies + // `pred` and is closest to `from`. Assumes that at least `to` + // satisfies `pred`. Supports `from` being greater than `to`. + function findFirst(pred, from, to) { + // At any point we are certain `to` satisfies `pred`, don't know + // whether `from` does. + var dir = from > to ? -1 : 1; + for (;;) { + if (from == to) { return from } + var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF); + if (mid == from) { return pred(mid) ? from : to } + if (pred(mid)) { to = mid; } + else { from = mid + dir; } + } + } + + // BIDI HELPERS + + function iterateBidiSections(order, from, to, f) { + if (!order) { return f(from, to, "ltr", 0) } + var found = false; + for (var i = 0; i < order.length; ++i) { + var part = order[i]; + if (part.from < to && part.to > from || from == to && part.to == from) { + f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr", i); + found = true; + } + } + if (!found) { f(from, to, "ltr"); } + } + + var bidiOther = null; + function getBidiPartAt(order, ch, sticky) { + var found; + bidiOther = null; + for (var i = 0; i < order.length; ++i) { + var cur = order[i]; + if (cur.from < ch && cur.to > ch) { return i } + if (cur.to == ch) { + if (cur.from != cur.to && sticky == "before") { found = i; } + else { bidiOther = i; } + } + if (cur.from == ch) { + if (cur.from != cur.to && sticky != "before") { found = i; } + else { bidiOther = i; } + } + } + return found != null ? found : bidiOther + } + + // Bidirectional ordering algorithm + // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm + // that this (partially) implements. + + // One-char codes used for character types: + // L (L): Left-to-Right + // R (R): Right-to-Left + // r (AL): Right-to-Left Arabic + // 1 (EN): European Number + // + (ES): European Number Separator + // % (ET): European Number Terminator + // n (AN): Arabic Number + // , (CS): Common Number Separator + // m (NSM): Non-Spacing Mark + // b (BN): Boundary Neutral + // s (B): Paragraph Separator + // t (S): Segment Separator + // w (WS): Whitespace + // N (ON): Other Neutrals + + // Returns null if characters are ordered as they appear + // (left-to-right), or an array of sections ({from, to, level} + // objects) in the order in which they occur visually. + var bidiOrdering = (function() { + // Character types for codepoints 0 to 0xff + var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN"; + // Character types for codepoints 0x600 to 0x6f9 + var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111"; + function charType(code) { + if (code <= 0xf7) { return lowTypes.charAt(code) } + else if (0x590 <= code && code <= 0x5f4) { return "R" } + else if (0x600 <= code && code <= 0x6f9) { return arabicTypes.charAt(code - 0x600) } + else if (0x6ee <= code && code <= 0x8ac) { return "r" } + else if (0x2000 <= code && code <= 0x200b) { return "w" } + else if (code == 0x200c) { return "b" } + else { return "L" } + } + + var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/; + var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/; + + function BidiSpan(level, from, to) { + this.level = level; + this.from = from; this.to = to; + } + + return function(str, direction) { + var outerType = direction == "ltr" ? "L" : "R"; + + if (str.length == 0 || direction == "ltr" && !bidiRE.test(str)) { return false } + var len = str.length, types = []; + for (var i = 0; i < len; ++i) + { types.push(charType(str.charCodeAt(i))); } + + // W1. Examine each non-spacing mark (NSM) in the level run, and + // change the type of the NSM to the type of the previous + // character. If the NSM is at the start of the level run, it will + // get the type of sor. + for (var i$1 = 0, prev = outerType; i$1 < len; ++i$1) { + var type = types[i$1]; + if (type == "m") { types[i$1] = prev; } + else { prev = type; } + } + + // W2. Search backwards from each instance of a European number + // until the first strong type (R, L, AL, or sor) is found. If an + // AL is found, change the type of the European number to Arabic + // number. + // W3. Change all ALs to R. + for (var i$2 = 0, cur = outerType; i$2 < len; ++i$2) { + var type$1 = types[i$2]; + if (type$1 == "1" && cur == "r") { types[i$2] = "n"; } + else if (isStrong.test(type$1)) { cur = type$1; if (type$1 == "r") { types[i$2] = "R"; } } + } + + // W4. A single European separator between two European numbers + // changes to a European number. A single common separator between + // two numbers of the same type changes to that type. + for (var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3) { + var type$2 = types[i$3]; + if (type$2 == "+" && prev$1 == "1" && types[i$3+1] == "1") { types[i$3] = "1"; } + else if (type$2 == "," && prev$1 == types[i$3+1] && + (prev$1 == "1" || prev$1 == "n")) { types[i$3] = prev$1; } + prev$1 = type$2; + } + + // W5. A sequence of European terminators adjacent to European + // numbers changes to all European numbers. + // W6. Otherwise, separators and terminators change to Other + // Neutral. + for (var i$4 = 0; i$4 < len; ++i$4) { + var type$3 = types[i$4]; + if (type$3 == ",") { types[i$4] = "N"; } + else if (type$3 == "%") { + var end = (void 0); + for (end = i$4 + 1; end < len && types[end] == "%"; ++end) {} + var replace = (i$4 && types[i$4-1] == "!") || (end < len && types[end] == "1") ? "1" : "N"; + for (var j = i$4; j < end; ++j) { types[j] = replace; } + i$4 = end - 1; + } + } + + // W7. Search backwards from each instance of a European number + // until the first strong type (R, L, or sor) is found. If an L is + // found, then change the type of the European number to L. + for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) { + var type$4 = types[i$5]; + if (cur$1 == "L" && type$4 == "1") { types[i$5] = "L"; } + else if (isStrong.test(type$4)) { cur$1 = type$4; } + } + + // N1. A sequence of neutrals takes the direction of the + // surrounding strong text if the text on both sides has the same + // direction. European and Arabic numbers act as if they were R in + // terms of their influence on neutrals. Start-of-level-run (sor) + // and end-of-level-run (eor) are used at level run boundaries. + // N2. Any remaining neutrals take the embedding direction. + for (var i$6 = 0; i$6 < len; ++i$6) { + if (isNeutral.test(types[i$6])) { + var end$1 = (void 0); + for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {} + var before = (i$6 ? types[i$6-1] : outerType) == "L"; + var after = (end$1 < len ? types[end$1] : outerType) == "L"; + var replace$1 = before == after ? (before ? "L" : "R") : outerType; + for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1; } + i$6 = end$1 - 1; + } + } + + // Here we depart from the documented algorithm, in order to avoid + // building up an actual levels array. Since there are only three + // levels (0, 1, 2) in an implementation that doesn't take + // explicit embedding into account, we can build up the order on + // the fly, without following the level-based algorithm. + var order = [], m; + for (var i$7 = 0; i$7 < len;) { + if (countsAsLeft.test(types[i$7])) { + var start = i$7; + for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {} + order.push(new BidiSpan(0, start, i$7)); + } else { + var pos = i$7, at = order.length, isRTL = direction == "rtl" ? 1 : 0; + for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {} + for (var j$2 = pos; j$2 < i$7;) { + if (countsAsNum.test(types[j$2])) { + if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); at += isRTL; } + var nstart = j$2; + for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {} + order.splice(at, 0, new BidiSpan(2, nstart, j$2)); + at += isRTL; + pos = j$2; + } else { ++j$2; } + } + if (pos < i$7) { order.splice(at, 0, new BidiSpan(1, pos, i$7)); } + } + } + if (direction == "ltr") { + if (order[0].level == 1 && (m = str.match(/^\s+/))) { + order[0].from = m[0].length; + order.unshift(new BidiSpan(0, 0, m[0].length)); + } + if (lst(order).level == 1 && (m = str.match(/\s+$/))) { + lst(order).to -= m[0].length; + order.push(new BidiSpan(0, len - m[0].length, len)); + } + } + + return direction == "rtl" ? order.reverse() : order + } + })(); + + // Get the bidi ordering for the given line (and cache it). Returns + // false for lines that are fully left-to-right, and an array of + // BidiSpan objects otherwise. + function getOrder(line, direction) { + var order = line.order; + if (order == null) { order = line.order = bidiOrdering(line.text, direction); } + return order + } + + // EVENT HANDLING + + // Lightweight event framework. on/off also work on DOM nodes, + // registering native DOM handlers. + + var noHandlers = []; + + var on = function(emitter, type, f) { + if (emitter.addEventListener) { + emitter.addEventListener(type, f, false); + } else if (emitter.attachEvent) { + emitter.attachEvent("on" + type, f); + } else { + var map = emitter._handlers || (emitter._handlers = {}); + map[type] = (map[type] || noHandlers).concat(f); + } + }; + + function getHandlers(emitter, type) { + return emitter._handlers && emitter._handlers[type] || noHandlers + } + + function off(emitter, type, f) { + if (emitter.removeEventListener) { + emitter.removeEventListener(type, f, false); + } else if (emitter.detachEvent) { + emitter.detachEvent("on" + type, f); + } else { + var map = emitter._handlers, arr = map && map[type]; + if (arr) { + var index = indexOf(arr, f); + if (index > -1) + { map[type] = arr.slice(0, index).concat(arr.slice(index + 1)); } + } + } + } + + function signal(emitter, type /*, values...*/) { + var handlers = getHandlers(emitter, type); + if (!handlers.length) { return } + var args = Array.prototype.slice.call(arguments, 2); + for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args); } + } + + // The DOM events that CodeMirror handles can be overridden by + // registering a (non-DOM) handler on the editor for the event name, + // and preventDefault-ing the event in that handler. + function signalDOMEvent(cm, e, override) { + if (typeof e == "string") + { e = {type: e, preventDefault: function() { this.defaultPrevented = true; }}; } + signal(cm, override || e.type, cm, e); + return e_defaultPrevented(e) || e.codemirrorIgnore + } + + function signalCursorActivity(cm) { + var arr = cm._handlers && cm._handlers.cursorActivity; + if (!arr) { return } + var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []); + for (var i = 0; i < arr.length; ++i) { if (indexOf(set, arr[i]) == -1) + { set.push(arr[i]); } } + } + + function hasHandler(emitter, type) { + return getHandlers(emitter, type).length > 0 + } + + // Add on and off methods to a constructor's prototype, to make + // registering events on such objects more convenient. + function eventMixin(ctor) { + ctor.prototype.on = function(type, f) {on(this, type, f);}; + ctor.prototype.off = function(type, f) {off(this, type, f);}; + } + + // Due to the fact that we still support jurassic IE versions, some + // compatibility wrappers are needed. + + function e_preventDefault(e) { + if (e.preventDefault) { e.preventDefault(); } + else { e.returnValue = false; } + } + function e_stopPropagation(e) { + if (e.stopPropagation) { e.stopPropagation(); } + else { e.cancelBubble = true; } + } + function e_defaultPrevented(e) { + return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false + } + function e_stop(e) {e_preventDefault(e); e_stopPropagation(e);} + + function e_target(e) {return e.target || e.srcElement} + function e_button(e) { + var b = e.which; + if (b == null) { + if (e.button & 1) { b = 1; } + else if (e.button & 2) { b = 3; } + else if (e.button & 4) { b = 2; } + } + if (mac && e.ctrlKey && b == 1) { b = 3; } + return b + } + + // Detect drag-and-drop + var dragAndDrop = function() { + // There is *some* kind of drag-and-drop support in IE6-8, but I + // couldn't get it to work yet. + if (ie && ie_version < 9) { return false } + var div = elt('div'); + return "draggable" in div || "dragDrop" in div + }(); + + var zwspSupported; + function zeroWidthElement(measure) { + if (zwspSupported == null) { + var test = elt("span", "\u200b"); + removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")])); + if (measure.firstChild.offsetHeight != 0) + { zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8); } + } + var node = zwspSupported ? elt("span", "\u200b") : + elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px"); + node.setAttribute("cm-text", ""); + return node + } + + // Feature-detect IE's crummy client rect reporting for bidi text + var badBidiRects; + function hasBadBidiRects(measure) { + if (badBidiRects != null) { return badBidiRects } + var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA")); + var r0 = range(txt, 0, 1).getBoundingClientRect(); + var r1 = range(txt, 1, 2).getBoundingClientRect(); + removeChildren(measure); + if (!r0 || r0.left == r0.right) { return false } // Safari returns null in some cases (#2780) + return badBidiRects = (r1.right - r0.right < 3) + } + + // See if "".split is the broken IE version, if so, provide an + // alternative way to split lines. + var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? function (string) { + var pos = 0, result = [], l = string.length; + while (pos <= l) { + var nl = string.indexOf("\n", pos); + if (nl == -1) { nl = string.length; } + var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl); + var rt = line.indexOf("\r"); + if (rt != -1) { + result.push(line.slice(0, rt)); + pos += rt + 1; + } else { + result.push(line); + pos = nl + 1; + } + } + return result + } : function (string) { return string.split(/\r\n?|\n/); }; + + var hasSelection = window.getSelection ? function (te) { + try { return te.selectionStart != te.selectionEnd } + catch(e) { return false } + } : function (te) { + var range; + try {range = te.ownerDocument.selection.createRange();} + catch(e) {} + if (!range || range.parentElement() != te) { return false } + return range.compareEndPoints("StartToEnd", range) != 0 + }; + + var hasCopyEvent = (function () { + var e = elt("div"); + if ("oncopy" in e) { return true } + e.setAttribute("oncopy", "return;"); + return typeof e.oncopy == "function" + })(); + + var badZoomedRects = null; + function hasBadZoomedRects(measure) { + if (badZoomedRects != null) { return badZoomedRects } + var node = removeChildrenAndAdd(measure, elt("span", "x")); + var normal = node.getBoundingClientRect(); + var fromRange = range(node, 0, 1).getBoundingClientRect(); + return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1 + } + + // Known modes, by name and by MIME + var modes = {}, mimeModes = {}; + + // Extra arguments are stored as the mode's dependencies, which is + // used by (legacy) mechanisms like loadmode.js to automatically + // load a mode. (Preferred mechanism is the require/define calls.) + function defineMode(name, mode) { + if (arguments.length > 2) + { mode.dependencies = Array.prototype.slice.call(arguments, 2); } + modes[name] = mode; + } + + function defineMIME(mime, spec) { + mimeModes[mime] = spec; + } + + // Given a MIME type, a {name, ...options} config object, or a name + // string, return a mode config object. + function resolveMode(spec) { + if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) { + spec = mimeModes[spec]; + } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) { + var found = mimeModes[spec.name]; + if (typeof found == "string") { found = {name: found}; } + spec = createObj(found, spec); + spec.name = found.name; + } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) { + return resolveMode("application/xml") + } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) { + return resolveMode("application/json") + } + if (typeof spec == "string") { return {name: spec} } + else { return spec || {name: "null"} } + } + + // Given a mode spec (anything that resolveMode accepts), find and + // initialize an actual mode object. + function getMode(options, spec) { + spec = resolveMode(spec); + var mfactory = modes[spec.name]; + if (!mfactory) { return getMode(options, "text/plain") } + var modeObj = mfactory(options, spec); + if (modeExtensions.hasOwnProperty(spec.name)) { + var exts = modeExtensions[spec.name]; + for (var prop in exts) { + if (!exts.hasOwnProperty(prop)) { continue } + if (modeObj.hasOwnProperty(prop)) { modeObj["_" + prop] = modeObj[prop]; } + modeObj[prop] = exts[prop]; + } + } + modeObj.name = spec.name; + if (spec.helperType) { modeObj.helperType = spec.helperType; } + if (spec.modeProps) { for (var prop$1 in spec.modeProps) + { modeObj[prop$1] = spec.modeProps[prop$1]; } } + + return modeObj + } + + // This can be used to attach properties to mode objects from + // outside the actual mode definition. + var modeExtensions = {}; + function extendMode(mode, properties) { + var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {}); + copyObj(properties, exts); + } + + function copyState(mode, state) { + if (state === true) { return state } + if (mode.copyState) { return mode.copyState(state) } + var nstate = {}; + for (var n in state) { + var val = state[n]; + if (val instanceof Array) { val = val.concat([]); } + nstate[n] = val; + } + return nstate + } + + // Given a mode and a state (for that mode), find the inner mode and + // state at the position that the state refers to. + function innerMode(mode, state) { + var info; + while (mode.innerMode) { + info = mode.innerMode(state); + if (!info || info.mode == mode) { break } + state = info.state; + mode = info.mode; + } + return info || {mode: mode, state: state} + } + + function startState(mode, a1, a2) { + return mode.startState ? mode.startState(a1, a2) : true + } + + // STRING STREAM + + // Fed to the mode parsers, provides helper functions to make + // parsers more succinct. + + var StringStream = function(string, tabSize, lineOracle) { + this.pos = this.start = 0; + this.string = string; + this.tabSize = tabSize || 8; + this.lastColumnPos = this.lastColumnValue = 0; + this.lineStart = 0; + this.lineOracle = lineOracle; + }; + + StringStream.prototype.eol = function () {return this.pos >= this.string.length}; + StringStream.prototype.sol = function () {return this.pos == this.lineStart}; + StringStream.prototype.peek = function () {return this.string.charAt(this.pos) || undefined}; + StringStream.prototype.next = function () { + if (this.pos < this.string.length) + { return this.string.charAt(this.pos++) } + }; + StringStream.prototype.eat = function (match) { + var ch = this.string.charAt(this.pos); + var ok; + if (typeof match == "string") { ok = ch == match; } + else { ok = ch && (match.test ? match.test(ch) : match(ch)); } + if (ok) {++this.pos; return ch} + }; + StringStream.prototype.eatWhile = function (match) { + var start = this.pos; + while (this.eat(match)){} + return this.pos > start + }; + StringStream.prototype.eatSpace = function () { + var start = this.pos; + while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this.pos; } + return this.pos > start + }; + StringStream.prototype.skipToEnd = function () {this.pos = this.string.length;}; + StringStream.prototype.skipTo = function (ch) { + var found = this.string.indexOf(ch, this.pos); + if (found > -1) {this.pos = found; return true} + }; + StringStream.prototype.backUp = function (n) {this.pos -= n;}; + StringStream.prototype.column = function () { + if (this.lastColumnPos < this.start) { + this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue); + this.lastColumnPos = this.start; + } + return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0) + }; + StringStream.prototype.indentation = function () { + return countColumn(this.string, null, this.tabSize) - + (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0) + }; + StringStream.prototype.match = function (pattern, consume, caseInsensitive) { + if (typeof pattern == "string") { + var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; }; + var substr = this.string.substr(this.pos, pattern.length); + if (cased(substr) == cased(pattern)) { + if (consume !== false) { this.pos += pattern.length; } + return true + } + } else { + var match = this.string.slice(this.pos).match(pattern); + if (match && match.index > 0) { return null } + if (match && consume !== false) { this.pos += match[0].length; } + return match + } + }; + StringStream.prototype.current = function (){return this.string.slice(this.start, this.pos)}; + StringStream.prototype.hideFirstChars = function (n, inner) { + this.lineStart += n; + try { return inner() } + finally { this.lineStart -= n; } + }; + StringStream.prototype.lookAhead = function (n) { + var oracle = this.lineOracle; + return oracle && oracle.lookAhead(n) + }; + StringStream.prototype.baseToken = function () { + var oracle = this.lineOracle; + return oracle && oracle.baseToken(this.pos) + }; + + // Find the line object corresponding to the given line number. + function getLine(doc, n) { + n -= doc.first; + if (n < 0 || n >= doc.size) { throw new Error("There is no line " + (n + doc.first) + " in the document.") } + var chunk = doc; + while (!chunk.lines) { + for (var i = 0;; ++i) { + var child = chunk.children[i], sz = child.chunkSize(); + if (n < sz) { chunk = child; break } + n -= sz; + } + } + return chunk.lines[n] + } + + // Get the part of a document between two positions, as an array of + // strings. + function getBetween(doc, start, end) { + var out = [], n = start.line; + doc.iter(start.line, end.line + 1, function (line) { + var text = line.text; + if (n == end.line) { text = text.slice(0, end.ch); } + if (n == start.line) { text = text.slice(start.ch); } + out.push(text); + ++n; + }); + return out + } + // Get the lines between from and to, as array of strings. + function getLines(doc, from, to) { + var out = []; + doc.iter(from, to, function (line) { out.push(line.text); }); // iter aborts when callback returns truthy value + return out + } + + // Update the height of a line, propagating the height change + // upwards to parent nodes. + function updateLineHeight(line, height) { + var diff = height - line.height; + if (diff) { for (var n = line; n; n = n.parent) { n.height += diff; } } + } + + // Given a line object, find its line number by walking up through + // its parent links. + function lineNo(line) { + if (line.parent == null) { return null } + var cur = line.parent, no = indexOf(cur.lines, line); + for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) { + for (var i = 0;; ++i) { + if (chunk.children[i] == cur) { break } + no += chunk.children[i].chunkSize(); + } + } + return no + cur.first + } + + // Find the line at the given vertical position, using the height + // information in the document tree. + function lineAtHeight(chunk, h) { + var n = chunk.first; + outer: do { + for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) { + var child = chunk.children[i$1], ch = child.height; + if (h < ch) { chunk = child; continue outer } + h -= ch; + n += child.chunkSize(); + } + return n + } while (!chunk.lines) + var i = 0; + for (; i < chunk.lines.length; ++i) { + var line = chunk.lines[i], lh = line.height; + if (h < lh) { break } + h -= lh; + } + return n + i + } + + function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size} + + function lineNumberFor(options, i) { + return String(options.lineNumberFormatter(i + options.firstLineNumber)) + } + + // A Pos instance represents a position within the text. + function Pos(line, ch, sticky) { + if ( sticky === void 0 ) sticky = null; + + if (!(this instanceof Pos)) { return new Pos(line, ch, sticky) } + this.line = line; + this.ch = ch; + this.sticky = sticky; + } + + // Compare two positions, return 0 if they are the same, a negative + // number when a is less, and a positive number otherwise. + function cmp(a, b) { return a.line - b.line || a.ch - b.ch } + + function equalCursorPos(a, b) { return a.sticky == b.sticky && cmp(a, b) == 0 } + + function copyPos(x) {return Pos(x.line, x.ch)} + function maxPos(a, b) { return cmp(a, b) < 0 ? b : a } + function minPos(a, b) { return cmp(a, b) < 0 ? a : b } + + // Most of the external API clips given positions to make sure they + // actually exist within the document. + function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1))} + function clipPos(doc, pos) { + if (pos.line < doc.first) { return Pos(doc.first, 0) } + var last = doc.first + doc.size - 1; + if (pos.line > last) { return Pos(last, getLine(doc, last).text.length) } + return clipToLen(pos, getLine(doc, pos.line).text.length) + } + function clipToLen(pos, linelen) { + var ch = pos.ch; + if (ch == null || ch > linelen) { return Pos(pos.line, linelen) } + else if (ch < 0) { return Pos(pos.line, 0) } + else { return pos } + } + function clipPosArray(doc, array) { + var out = []; + for (var i = 0; i < array.length; i++) { out[i] = clipPos(doc, array[i]); } + return out + } + + var SavedContext = function(state, lookAhead) { + this.state = state; + this.lookAhead = lookAhead; + }; + + var Context = function(doc, state, line, lookAhead) { + this.state = state; + this.doc = doc; + this.line = line; + this.maxLookAhead = lookAhead || 0; + this.baseTokens = null; + this.baseTokenPos = 1; + }; + + Context.prototype.lookAhead = function (n) { + var line = this.doc.getLine(this.line + n); + if (line != null && n > this.maxLookAhead) { this.maxLookAhead = n; } + return line + }; + + Context.prototype.baseToken = function (n) { + if (!this.baseTokens) { return null } + while (this.baseTokens[this.baseTokenPos] <= n) + { this.baseTokenPos += 2; } + var type = this.baseTokens[this.baseTokenPos + 1]; + return {type: type && type.replace(/( |^)overlay .*/, ""), + size: this.baseTokens[this.baseTokenPos] - n} + }; + + Context.prototype.nextLine = function () { + this.line++; + if (this.maxLookAhead > 0) { this.maxLookAhead--; } + }; + + Context.fromSaved = function (doc, saved, line) { + if (saved instanceof SavedContext) + { return new Context(doc, copyState(doc.mode, saved.state), line, saved.lookAhead) } + else + { return new Context(doc, copyState(doc.mode, saved), line) } + }; + + Context.prototype.save = function (copy) { + var state = copy !== false ? copyState(this.doc.mode, this.state) : this.state; + return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state + }; + + + // Compute a style array (an array starting with a mode generation + // -- for invalidation -- followed by pairs of end positions and + // style strings), which is used to highlight the tokens on the + // line. + function highlightLine(cm, line, context, forceToEnd) { + // A styles array always starts with a number identifying the + // mode/overlays that it is based on (for easy invalidation). + var st = [cm.state.modeGen], lineClasses = {}; + // Compute the base array of styles + runMode(cm, line.text, cm.doc.mode, context, function (end, style) { return st.push(end, style); }, + lineClasses, forceToEnd); + var state = context.state; + + // Run overlays, adjust style array. + var loop = function ( o ) { + context.baseTokens = st; + var overlay = cm.state.overlays[o], i = 1, at = 0; + context.state = true; + runMode(cm, line.text, overlay.mode, context, function (end, style) { + var start = i; + // Ensure there's a token end at the current position, and that i points at it + while (at < end) { + var i_end = st[i]; + if (i_end > end) + { st.splice(i, 1, end, st[i+1], i_end); } + i += 2; + at = Math.min(end, i_end); + } + if (!style) { return } + if (overlay.opaque) { + st.splice(start, i - start, end, "overlay " + style); + i = start + 2; + } else { + for (; start < i; start += 2) { + var cur = st[start+1]; + st[start+1] = (cur ? cur + " " : "") + "overlay " + style; + } + } + }, lineClasses); + context.state = state; + context.baseTokens = null; + context.baseTokenPos = 1; + }; + + for (var o = 0; o < cm.state.overlays.length; ++o) loop( o ); + + return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null} + } + + function getLineStyles(cm, line, updateFrontier) { + if (!line.styles || line.styles[0] != cm.state.modeGen) { + var context = getContextBefore(cm, lineNo(line)); + var resetState = line.text.length > cm.options.maxHighlightLength && copyState(cm.doc.mode, context.state); + var result = highlightLine(cm, line, context); + if (resetState) { context.state = resetState; } + line.stateAfter = context.save(!resetState); + line.styles = result.styles; + if (result.classes) { line.styleClasses = result.classes; } + else if (line.styleClasses) { line.styleClasses = null; } + if (updateFrontier === cm.doc.highlightFrontier) + { cm.doc.modeFrontier = Math.max(cm.doc.modeFrontier, ++cm.doc.highlightFrontier); } + } + return line.styles + } + + function getContextBefore(cm, n, precise) { + var doc = cm.doc, display = cm.display; + if (!doc.mode.startState) { return new Context(doc, true, n) } + var start = findStartLine(cm, n, precise); + var saved = start > doc.first && getLine(doc, start - 1).stateAfter; + var context = saved ? Context.fromSaved(doc, saved, start) : new Context(doc, startState(doc.mode), start); + + doc.iter(start, n, function (line) { + processLine(cm, line.text, context); + var pos = context.line; + line.stateAfter = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo ? context.save() : null; + context.nextLine(); + }); + if (precise) { doc.modeFrontier = context.line; } + return context + } + + // Lightweight form of highlight -- proceed over this line and + // update state, but don't save a style array. Used for lines that + // aren't currently visible. + function processLine(cm, text, context, startAt) { + var mode = cm.doc.mode; + var stream = new StringStream(text, cm.options.tabSize, context); + stream.start = stream.pos = startAt || 0; + if (text == "") { callBlankLine(mode, context.state); } + while (!stream.eol()) { + readToken(mode, stream, context.state); + stream.start = stream.pos; + } + } + + function callBlankLine(mode, state) { + if (mode.blankLine) { return mode.blankLine(state) } + if (!mode.innerMode) { return } + var inner = innerMode(mode, state); + if (inner.mode.blankLine) { return inner.mode.blankLine(inner.state) } + } + + function readToken(mode, stream, state, inner) { + for (var i = 0; i < 10; i++) { + if (inner) { inner[0] = innerMode(mode, state).mode; } + var style = mode.token(stream, state); + if (stream.pos > stream.start) { return style } + } + throw new Error("Mode " + mode.name + " failed to advance stream.") + } + + var Token = function(stream, type, state) { + this.start = stream.start; this.end = stream.pos; + this.string = stream.current(); + this.type = type || null; + this.state = state; + }; + + // Utility for getTokenAt and getLineTokens + function takeToken(cm, pos, precise, asArray) { + var doc = cm.doc, mode = doc.mode, style; + pos = clipPos(doc, pos); + var line = getLine(doc, pos.line), context = getContextBefore(cm, pos.line, precise); + var stream = new StringStream(line.text, cm.options.tabSize, context), tokens; + if (asArray) { tokens = []; } + while ((asArray || stream.pos < pos.ch) && !stream.eol()) { + stream.start = stream.pos; + style = readToken(mode, stream, context.state); + if (asArray) { tokens.push(new Token(stream, style, copyState(doc.mode, context.state))); } + } + return asArray ? tokens : new Token(stream, style, context.state) + } + + function extractLineClasses(type, output) { + if (type) { for (;;) { + var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/); + if (!lineClass) { break } + type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length); + var prop = lineClass[1] ? "bgClass" : "textClass"; + if (output[prop] == null) + { output[prop] = lineClass[2]; } + else if (!(new RegExp("(?:^|\\s)" + lineClass[2] + "(?:$|\\s)")).test(output[prop])) + { output[prop] += " " + lineClass[2]; } + } } + return type + } + + // Run the given mode's parser over a line, calling f for each token. + function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) { + var flattenSpans = mode.flattenSpans; + if (flattenSpans == null) { flattenSpans = cm.options.flattenSpans; } + var curStart = 0, curStyle = null; + var stream = new StringStream(text, cm.options.tabSize, context), style; + var inner = cm.options.addModeClass && [null]; + if (text == "") { extractLineClasses(callBlankLine(mode, context.state), lineClasses); } + while (!stream.eol()) { + if (stream.pos > cm.options.maxHighlightLength) { + flattenSpans = false; + if (forceToEnd) { processLine(cm, text, context, stream.pos); } + stream.pos = text.length; + style = null; + } else { + style = extractLineClasses(readToken(mode, stream, context.state, inner), lineClasses); + } + if (inner) { + var mName = inner[0].name; + if (mName) { style = "m-" + (style ? mName + " " + style : mName); } + } + if (!flattenSpans || curStyle != style) { + while (curStart < stream.start) { + curStart = Math.min(stream.start, curStart + 5000); + f(curStart, curStyle); + } + curStyle = style; + } + stream.start = stream.pos; + } + while (curStart < stream.pos) { + // Webkit seems to refuse to render text nodes longer than 57444 + // characters, and returns inaccurate measurements in nodes + // starting around 5000 chars. + var pos = Math.min(stream.pos, curStart + 5000); + f(pos, curStyle); + curStart = pos; + } + } + + // Finds the line to start with when starting a parse. Tries to + // find a line with a stateAfter, so that it can start with a + // valid state. If that fails, it returns the line with the + // smallest indentation, which tends to need the least context to + // parse correctly. + function findStartLine(cm, n, precise) { + var minindent, minline, doc = cm.doc; + var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100); + for (var search = n; search > lim; --search) { + if (search <= doc.first) { return doc.first } + var line = getLine(doc, search - 1), after = line.stateAfter; + if (after && (!precise || search + (after instanceof SavedContext ? after.lookAhead : 0) <= doc.modeFrontier)) + { return search } + var indented = countColumn(line.text, null, cm.options.tabSize); + if (minline == null || minindent > indented) { + minline = search - 1; + minindent = indented; + } + } + return minline + } + + function retreatFrontier(doc, n) { + doc.modeFrontier = Math.min(doc.modeFrontier, n); + if (doc.highlightFrontier < n - 10) { return } + var start = doc.first; + for (var line = n - 1; line > start; line--) { + var saved = getLine(doc, line).stateAfter; + // change is on 3 + // state on line 1 looked ahead 2 -- so saw 3 + // test 1 + 2 < 3 should cover this + if (saved && (!(saved instanceof SavedContext) || line + saved.lookAhead < n)) { + start = line + 1; + break + } + } + doc.highlightFrontier = Math.min(doc.highlightFrontier, start); + } + + // Optimize some code when these features are not used. + var sawReadOnlySpans = false, sawCollapsedSpans = false; + + function seeReadOnlySpans() { + sawReadOnlySpans = true; + } + + function seeCollapsedSpans() { + sawCollapsedSpans = true; + } + + // TEXTMARKER SPANS + + function MarkedSpan(marker, from, to) { + this.marker = marker; + this.from = from; this.to = to; + } + + // Search an array of spans for a span matching the given marker. + function getMarkedSpanFor(spans, marker) { + if (spans) { for (var i = 0; i < spans.length; ++i) { + var span = spans[i]; + if (span.marker == marker) { return span } + } } + } + // Remove a span from an array, returning undefined if no spans are + // left (we don't store arrays for lines without spans). + function removeMarkedSpan(spans, span) { + var r; + for (var i = 0; i < spans.length; ++i) + { if (spans[i] != span) { (r || (r = [])).push(spans[i]); } } + return r + } + // Add a span to a line. + function addMarkedSpan(line, span) { + line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]; + span.marker.attachLine(line); + } + + // Used for the algorithm that adjusts markers for a change in the + // document. These functions cut an array of spans at a given + // character position, returning an array of remaining chunks (or + // undefined if nothing remains). + function markedSpansBefore(old, startCh, isInsert) { + var nw; + if (old) { for (var i = 0; i < old.length; ++i) { + var span = old[i], marker = span.marker; + var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh); + if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) { + var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh) + ;(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to)); + } + } } + return nw + } + function markedSpansAfter(old, endCh, isInsert) { + var nw; + if (old) { for (var i = 0; i < old.length; ++i) { + var span = old[i], marker = span.marker; + var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh); + if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) { + var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh) + ;(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh, + span.to == null ? null : span.to - endCh)); + } + } } + return nw + } + + // Given a change object, compute the new set of marker spans that + // cover the line in which the change took place. Removes spans + // entirely within the change, reconnects spans belonging to the + // same marker that appear on both sides of the change, and cuts off + // spans partially within the change. Returns an array of span + // arrays with one element for each line in (after) the change. + function stretchSpansOverChange(doc, change) { + if (change.full) { return null } + var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans; + var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans; + if (!oldFirst && !oldLast) { return null } + + var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0; + // Get the spans that 'stick out' on both sides + var first = markedSpansBefore(oldFirst, startCh, isInsert); + var last = markedSpansAfter(oldLast, endCh, isInsert); + + // Next, merge those two ends + var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0); + if (first) { + // Fix up .to properties of first + for (var i = 0; i < first.length; ++i) { + var span = first[i]; + if (span.to == null) { + var found = getMarkedSpanFor(last, span.marker); + if (!found) { span.to = startCh; } + else if (sameLine) { span.to = found.to == null ? null : found.to + offset; } + } + } + } + if (last) { + // Fix up .from in last (or move them into first in case of sameLine) + for (var i$1 = 0; i$1 < last.length; ++i$1) { + var span$1 = last[i$1]; + if (span$1.to != null) { span$1.to += offset; } + if (span$1.from == null) { + var found$1 = getMarkedSpanFor(first, span$1.marker); + if (!found$1) { + span$1.from = offset; + if (sameLine) { (first || (first = [])).push(span$1); } + } + } else { + span$1.from += offset; + if (sameLine) { (first || (first = [])).push(span$1); } + } + } + } + // Make sure we didn't create any zero-length spans + if (first) { first = clearEmptySpans(first); } + if (last && last != first) { last = clearEmptySpans(last); } + + var newMarkers = [first]; + if (!sameLine) { + // Fill gap with whole-line-spans + var gap = change.text.length - 2, gapMarkers; + if (gap > 0 && first) + { for (var i$2 = 0; i$2 < first.length; ++i$2) + { if (first[i$2].to == null) + { (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2].marker, null, null)); } } } + for (var i$3 = 0; i$3 < gap; ++i$3) + { newMarkers.push(gapMarkers); } + newMarkers.push(last); + } + return newMarkers + } + + // Remove spans that are empty and don't have a clearWhenEmpty + // option of false. + function clearEmptySpans(spans) { + for (var i = 0; i < spans.length; ++i) { + var span = spans[i]; + if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false) + { spans.splice(i--, 1); } + } + if (!spans.length) { return null } + return spans + } + + // Used to 'clip' out readOnly ranges when making a change. + function removeReadOnlyRanges(doc, from, to) { + var markers = null; + doc.iter(from.line, to.line + 1, function (line) { + if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) { + var mark = line.markedSpans[i].marker; + if (mark.readOnly && (!markers || indexOf(markers, mark) == -1)) + { (markers || (markers = [])).push(mark); } + } } + }); + if (!markers) { return null } + var parts = [{from: from, to: to}]; + for (var i = 0; i < markers.length; ++i) { + var mk = markers[i], m = mk.find(0); + for (var j = 0; j < parts.length; ++j) { + var p = parts[j]; + if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) { continue } + var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to); + if (dfrom < 0 || !mk.inclusiveLeft && !dfrom) + { newParts.push({from: p.from, to: m.from}); } + if (dto > 0 || !mk.inclusiveRight && !dto) + { newParts.push({from: m.to, to: p.to}); } + parts.splice.apply(parts, newParts); + j += newParts.length - 3; + } + } + return parts + } + + // Connect or disconnect spans from a line. + function detachMarkedSpans(line) { + var spans = line.markedSpans; + if (!spans) { return } + for (var i = 0; i < spans.length; ++i) + { spans[i].marker.detachLine(line); } + line.markedSpans = null; + } + function attachMarkedSpans(line, spans) { + if (!spans) { return } + for (var i = 0; i < spans.length; ++i) + { spans[i].marker.attachLine(line); } + line.markedSpans = spans; + } + + // Helpers used when computing which overlapping collapsed span + // counts as the larger one. + function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0 } + function extraRight(marker) { return marker.inclusiveRight ? 1 : 0 } + + // Returns a number indicating which of two overlapping collapsed + // spans is larger (and thus includes the other). Falls back to + // comparing ids when the spans cover exactly the same range. + function compareCollapsedMarkers(a, b) { + var lenDiff = a.lines.length - b.lines.length; + if (lenDiff != 0) { return lenDiff } + var aPos = a.find(), bPos = b.find(); + var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b); + if (fromCmp) { return -fromCmp } + var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b); + if (toCmp) { return toCmp } + return b.id - a.id + } + + // Find out whether a line ends or starts in a collapsed span. If + // so, return the marker for that span. + function collapsedSpanAtSide(line, start) { + var sps = sawCollapsedSpans && line.markedSpans, found; + if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) { + sp = sps[i]; + if (sp.marker.collapsed && (start ? sp.from : sp.to) == null && + (!found || compareCollapsedMarkers(found, sp.marker) < 0)) + { found = sp.marker; } + } } + return found + } + function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true) } + function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false) } + + function collapsedSpanAround(line, ch) { + var sps = sawCollapsedSpans && line.markedSpans, found; + if (sps) { for (var i = 0; i < sps.length; ++i) { + var sp = sps[i]; + if (sp.marker.collapsed && (sp.from == null || sp.from < ch) && (sp.to == null || sp.to > ch) && + (!found || compareCollapsedMarkers(found, sp.marker) < 0)) { found = sp.marker; } + } } + return found + } + + // Test whether there exists a collapsed span that partially + // overlaps (covers the start or end, but not both) of a new span. + // Such overlap is not allowed. + function conflictingCollapsedRange(doc, lineNo, from, to, marker) { + var line = getLine(doc, lineNo); + var sps = sawCollapsedSpans && line.markedSpans; + if (sps) { for (var i = 0; i < sps.length; ++i) { + var sp = sps[i]; + if (!sp.marker.collapsed) { continue } + var found = sp.marker.find(0); + var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker); + var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker); + if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) { continue } + if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) || + fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0)) + { return true } + } } + } + + // A visual line is a line as drawn on the screen. Folding, for + // example, can cause multiple logical lines to appear on the same + // visual line. This finds the start of the visual line that the + // given line is part of (usually that is the line itself). + function visualLine(line) { + var merged; + while (merged = collapsedSpanAtStart(line)) + { line = merged.find(-1, true).line; } + return line + } + + function visualLineEnd(line) { + var merged; + while (merged = collapsedSpanAtEnd(line)) + { line = merged.find(1, true).line; } + return line + } + + // Returns an array of logical lines that continue the visual line + // started by the argument, or undefined if there are no such lines. + function visualLineContinued(line) { + var merged, lines; + while (merged = collapsedSpanAtEnd(line)) { + line = merged.find(1, true).line + ;(lines || (lines = [])).push(line); + } + return lines + } + + // Get the line number of the start of the visual line that the + // given line number is part of. + function visualLineNo(doc, lineN) { + var line = getLine(doc, lineN), vis = visualLine(line); + if (line == vis) { return lineN } + return lineNo(vis) + } + + // Get the line number of the start of the next visual line after + // the given line. + function visualLineEndNo(doc, lineN) { + if (lineN > doc.lastLine()) { return lineN } + var line = getLine(doc, lineN), merged; + if (!lineIsHidden(doc, line)) { return lineN } + while (merged = collapsedSpanAtEnd(line)) + { line = merged.find(1, true).line; } + return lineNo(line) + 1 + } + + // Compute whether a line is hidden. Lines count as hidden when they + // are part of a visual line that starts with another line, or when + // they are entirely covered by collapsed, non-widget span. + function lineIsHidden(doc, line) { + var sps = sawCollapsedSpans && line.markedSpans; + if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) { + sp = sps[i]; + if (!sp.marker.collapsed) { continue } + if (sp.from == null) { return true } + if (sp.marker.widgetNode) { continue } + if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp)) + { return true } + } } + } + function lineIsHiddenInner(doc, line, span) { + if (span.to == null) { + var end = span.marker.find(1, true); + return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker)) + } + if (span.marker.inclusiveRight && span.to == line.text.length) + { return true } + for (var sp = (void 0), i = 0; i < line.markedSpans.length; ++i) { + sp = line.markedSpans[i]; + if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to && + (sp.to == null || sp.to != span.from) && + (sp.marker.inclusiveLeft || span.marker.inclusiveRight) && + lineIsHiddenInner(doc, line, sp)) { return true } + } + } + + // Find the height above the given line. + function heightAtLine(lineObj) { + lineObj = visualLine(lineObj); + + var h = 0, chunk = lineObj.parent; + for (var i = 0; i < chunk.lines.length; ++i) { + var line = chunk.lines[i]; + if (line == lineObj) { break } + else { h += line.height; } + } + for (var p = chunk.parent; p; chunk = p, p = chunk.parent) { + for (var i$1 = 0; i$1 < p.children.length; ++i$1) { + var cur = p.children[i$1]; + if (cur == chunk) { break } + else { h += cur.height; } + } + } + return h + } + + // Compute the character length of a line, taking into account + // collapsed ranges (see markText) that might hide parts, and join + // other lines onto it. + function lineLength(line) { + if (line.height == 0) { return 0 } + var len = line.text.length, merged, cur = line; + while (merged = collapsedSpanAtStart(cur)) { + var found = merged.find(0, true); + cur = found.from.line; + len += found.from.ch - found.to.ch; + } + cur = line; + while (merged = collapsedSpanAtEnd(cur)) { + var found$1 = merged.find(0, true); + len -= cur.text.length - found$1.from.ch; + cur = found$1.to.line; + len += cur.text.length - found$1.to.ch; + } + return len + } + + // Find the longest line in the document. + function findMaxLine(cm) { + var d = cm.display, doc = cm.doc; + d.maxLine = getLine(doc, doc.first); + d.maxLineLength = lineLength(d.maxLine); + d.maxLineChanged = true; + doc.iter(function (line) { + var len = lineLength(line); + if (len > d.maxLineLength) { + d.maxLineLength = len; + d.maxLine = line; + } + }); + } + + // LINE DATA STRUCTURE + + // Line objects. These hold state related to a line, including + // highlighting info (the styles array). + var Line = function(text, markedSpans, estimateHeight) { + this.text = text; + attachMarkedSpans(this, markedSpans); + this.height = estimateHeight ? estimateHeight(this) : 1; + }; + + Line.prototype.lineNo = function () { return lineNo(this) }; + eventMixin(Line); + + // Change the content (text, markers) of a line. Automatically + // invalidates cached information and tries to re-estimate the + // line's height. + function updateLine(line, text, markedSpans, estimateHeight) { + line.text = text; + if (line.stateAfter) { line.stateAfter = null; } + if (line.styles) { line.styles = null; } + if (line.order != null) { line.order = null; } + detachMarkedSpans(line); + attachMarkedSpans(line, markedSpans); + var estHeight = estimateHeight ? estimateHeight(line) : 1; + if (estHeight != line.height) { updateLineHeight(line, estHeight); } + } + + // Detach a line from the document tree and its markers. + function cleanUpLine(line) { + line.parent = null; + detachMarkedSpans(line); + } + + // Convert a style as returned by a mode (either null, or a string + // containing one or more styles) to a CSS style. This is cached, + // and also looks for line-wide styles. + var styleToClassCache = {}, styleToClassCacheWithMode = {}; + function interpretTokenStyle(style, options) { + if (!style || /^\s*$/.test(style)) { return null } + var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache; + return cache[style] || + (cache[style] = style.replace(/\S+/g, "cm-$&")) + } + + // Render the DOM representation of the text of a line. Also builds + // up a 'line map', which points at the DOM nodes that represent + // specific stretches of text, and is used by the measuring code. + // The returned object contains the DOM node, this map, and + // information about line-wide styles that were set by the mode. + function buildLineContent(cm, lineView) { + // The padding-right forces the element to have a 'border', which + // is needed on Webkit to be able to get line-level bounding + // rectangles for it (in measureChar). + var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null); + var builder = {pre: eltP("pre", [content], "CodeMirror-line"), content: content, + col: 0, pos: 0, cm: cm, + trailingSpace: false, + splitSpaces: cm.getOption("lineWrapping")}; + lineView.measure = {}; + + // Iterate over the logical lines that make up this visual line. + for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) { + var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0); + builder.pos = 0; + builder.addToken = buildToken; + // Optionally wire in some hacks into the token-rendering + // algorithm, to deal with browser quirks. + if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction))) + { builder.addToken = buildTokenBadBidi(builder.addToken, order); } + builder.map = []; + var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line); + insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate)); + if (line.styleClasses) { + if (line.styleClasses.bgClass) + { builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); } + if (line.styleClasses.textClass) + { builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); } + } + + // Ensure at least a single node is present, for measuring. + if (builder.map.length == 0) + { builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); } + + // Store the map and a cache object for the current logical line + if (i == 0) { + lineView.measure.map = builder.map; + lineView.measure.cache = {}; + } else { + (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map) + ;(lineView.measure.caches || (lineView.measure.caches = [])).push({}); + } + } + + // See issue #2901 + if (webkit) { + var last = builder.content.lastChild; + if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab"))) + { builder.content.className = "cm-tab-wrap-hack"; } + } + + signal(cm, "renderLine", cm, lineView.line, builder.pre); + if (builder.pre.className) + { builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); } + + return builder + } + + function defaultSpecialCharPlaceholder(ch) { + var token = elt("span", "\u2022", "cm-invalidchar"); + token.title = "\\u" + ch.charCodeAt(0).toString(16); + token.setAttribute("aria-label", token.title); + return token + } + + // Build up the DOM representation for a single token, and add it to + // the line map. Takes care to render special characters separately. + function buildToken(builder, text, style, startStyle, endStyle, css, attributes) { + if (!text) { return } + var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text; + var special = builder.cm.state.specialChars, mustWrap = false; + var content; + if (!special.test(text)) { + builder.col += text.length; + content = document.createTextNode(displayText); + builder.map.push(builder.pos, builder.pos + text.length, content); + if (ie && ie_version < 9) { mustWrap = true; } + builder.pos += text.length; + } else { + content = document.createDocumentFragment(); + var pos = 0; + while (true) { + special.lastIndex = pos; + var m = special.exec(text); + var skipped = m ? m.index - pos : text.length - pos; + if (skipped) { + var txt = document.createTextNode(displayText.slice(pos, pos + skipped)); + if (ie && ie_version < 9) { content.appendChild(elt("span", [txt])); } + else { content.appendChild(txt); } + builder.map.push(builder.pos, builder.pos + skipped, txt); + builder.col += skipped; + builder.pos += skipped; + } + if (!m) { break } + pos += skipped + 1; + var txt$1 = (void 0); + if (m[0] == "\t") { + var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize; + txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab")); + txt$1.setAttribute("role", "presentation"); + txt$1.setAttribute("cm-text", "\t"); + builder.col += tabWidth; + } else if (m[0] == "\r" || m[0] == "\n") { + txt$1 = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar")); + txt$1.setAttribute("cm-text", m[0]); + builder.col += 1; + } else { + txt$1 = builder.cm.options.specialCharPlaceholder(m[0]); + txt$1.setAttribute("cm-text", m[0]); + if (ie && ie_version < 9) { content.appendChild(elt("span", [txt$1])); } + else { content.appendChild(txt$1); } + builder.col += 1; + } + builder.map.push(builder.pos, builder.pos + 1, txt$1); + builder.pos++; + } + } + builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32; + if (style || startStyle || endStyle || mustWrap || css || attributes) { + var fullStyle = style || ""; + if (startStyle) { fullStyle += startStyle; } + if (endStyle) { fullStyle += endStyle; } + var token = elt("span", [content], fullStyle, css); + if (attributes) { + for (var attr in attributes) { if (attributes.hasOwnProperty(attr) && attr != "style" && attr != "class") + { token.setAttribute(attr, attributes[attr]); } } + } + return builder.content.appendChild(token) + } + builder.content.appendChild(content); + } + + // Change some spaces to NBSP to prevent the browser from collapsing + // trailing spaces at the end of a line when rendering text (issue #1362). + function splitSpaces(text, trailingBefore) { + if (text.length > 1 && !/ /.test(text)) { return text } + var spaceBefore = trailingBefore, result = ""; + for (var i = 0; i < text.length; i++) { + var ch = text.charAt(i); + if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32)) + { ch = "\u00a0"; } + result += ch; + spaceBefore = ch == " "; + } + return result + } + + // Work around nonsense dimensions being reported for stretches of + // right-to-left text. + function buildTokenBadBidi(inner, order) { + return function (builder, text, style, startStyle, endStyle, css, attributes) { + style = style ? style + " cm-force-border" : "cm-force-border"; + var start = builder.pos, end = start + text.length; + for (;;) { + // Find the part that overlaps with the start of this text + var part = (void 0); + for (var i = 0; i < order.length; i++) { + part = order[i]; + if (part.to > start && part.from <= start) { break } + } + if (part.to >= end) { return inner(builder, text, style, startStyle, endStyle, css, attributes) } + inner(builder, text.slice(0, part.to - start), style, startStyle, null, css, attributes); + startStyle = null; + text = text.slice(part.to - start); + start = part.to; + } + } + } + + function buildCollapsedSpan(builder, size, marker, ignoreWidget) { + var widget = !ignoreWidget && marker.widgetNode; + if (widget) { builder.map.push(builder.pos, builder.pos + size, widget); } + if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) { + if (!widget) + { widget = builder.content.appendChild(document.createElement("span")); } + widget.setAttribute("cm-marker", marker.id); + } + if (widget) { + builder.cm.display.input.setUneditable(widget); + builder.content.appendChild(widget); + } + builder.pos += size; + builder.trailingSpace = false; + } + + // Outputs a number of spans to make up a line, taking highlighting + // and marked text into account. + function insertLineContent(line, builder, styles) { + var spans = line.markedSpans, allText = line.text, at = 0; + if (!spans) { + for (var i$1 = 1; i$1 < styles.length; i$1+=2) + { builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)); } + return + } + + var len = allText.length, pos = 0, i = 1, text = "", style, css; + var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, collapsed, attributes; + for (;;) { + if (nextChange == pos) { // Update current marker set + spanStyle = spanEndStyle = spanStartStyle = css = ""; + attributes = null; + collapsed = null; nextChange = Infinity; + var foundBookmarks = [], endStyles = (void 0); + for (var j = 0; j < spans.length; ++j) { + var sp = spans[j], m = sp.marker; + if (m.type == "bookmark" && sp.from == pos && m.widgetNode) { + foundBookmarks.push(m); + } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) { + if (sp.to != null && sp.to != pos && nextChange > sp.to) { + nextChange = sp.to; + spanEndStyle = ""; + } + if (m.className) { spanStyle += " " + m.className; } + if (m.css) { css = (css ? css + ";" : "") + m.css; } + if (m.startStyle && sp.from == pos) { spanStartStyle += " " + m.startStyle; } + if (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push(m.endStyle, sp.to); } + // support for the old title property + // https://github.com/codemirror/CodeMirror/pull/5673 + if (m.title) { (attributes || (attributes = {})).title = m.title; } + if (m.attributes) { + for (var attr in m.attributes) + { (attributes || (attributes = {}))[attr] = m.attributes[attr]; } + } + if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0)) + { collapsed = sp; } + } else if (sp.from > pos && nextChange > sp.from) { + nextChange = sp.from; + } + } + if (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2) + { if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += " " + endStyles[j$1]; } } } + + if (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2) + { buildCollapsedSpan(builder, 0, foundBookmarks[j$2]); } } + if (collapsed && (collapsed.from || 0) == pos) { + buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos, + collapsed.marker, collapsed.from == null); + if (collapsed.to == null) { return } + if (collapsed.to == pos) { collapsed = false; } + } + } + if (pos >= len) { break } + + var upto = Math.min(len, nextChange); + while (true) { + if (text) { + var end = pos + text.length; + if (!collapsed) { + var tokenText = end > upto ? text.slice(0, upto - pos) : text; + builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle, + spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", css, attributes); + } + if (end >= upto) {text = text.slice(upto - pos); pos = upto; break} + pos = end; + spanStartStyle = ""; + } + text = allText.slice(at, at = styles[i++]); + style = interpretTokenStyle(styles[i++], builder.cm.options); + } + } + } + + + // These objects are used to represent the visible (currently drawn) + // part of the document. A LineView may correspond to multiple + // logical lines, if those are connected by collapsed ranges. + function LineView(doc, line, lineN) { + // The starting line + this.line = line; + // Continuing lines, if any + this.rest = visualLineContinued(line); + // Number of logical lines in this visual line + this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1; + this.node = this.text = null; + this.hidden = lineIsHidden(doc, line); + } + + // Create a range of LineView objects for the given lines. + function buildViewArray(cm, from, to) { + var array = [], nextPos; + for (var pos = from; pos < to; pos = nextPos) { + var view = new LineView(cm.doc, getLine(cm.doc, pos), pos); + nextPos = pos + view.size; + array.push(view); + } + return array + } + + var operationGroup = null; + + function pushOperation(op) { + if (operationGroup) { + operationGroup.ops.push(op); + } else { + op.ownsGroup = operationGroup = { + ops: [op], + delayedCallbacks: [] + }; + } + } + + function fireCallbacksForOps(group) { + // Calls delayed callbacks and cursorActivity handlers until no + // new ones appear + var callbacks = group.delayedCallbacks, i = 0; + do { + for (; i < callbacks.length; i++) + { callbacks[i].call(null); } + for (var j = 0; j < group.ops.length; j++) { + var op = group.ops[j]; + if (op.cursorActivityHandlers) + { while (op.cursorActivityCalled < op.cursorActivityHandlers.length) + { op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm); } } + } + } while (i < callbacks.length) + } + + function finishOperation(op, endCb) { + var group = op.ownsGroup; + if (!group) { return } + + try { fireCallbacksForOps(group); } + finally { + operationGroup = null; + endCb(group); + } + } + + var orphanDelayedCallbacks = null; + + // Often, we want to signal events at a point where we are in the + // middle of some work, but don't want the handler to start calling + // other methods on the editor, which might be in an inconsistent + // state or simply not expect any other events to happen. + // signalLater looks whether there are any handlers, and schedules + // them to be executed when the last operation ends, or, if no + // operation is active, when a timeout fires. + function signalLater(emitter, type /*, values...*/) { + var arr = getHandlers(emitter, type); + if (!arr.length) { return } + var args = Array.prototype.slice.call(arguments, 2), list; + if (operationGroup) { + list = operationGroup.delayedCallbacks; + } else if (orphanDelayedCallbacks) { + list = orphanDelayedCallbacks; + } else { + list = orphanDelayedCallbacks = []; + setTimeout(fireOrphanDelayed, 0); + } + var loop = function ( i ) { + list.push(function () { return arr[i].apply(null, args); }); + }; + + for (var i = 0; i < arr.length; ++i) + loop( i ); + } + + function fireOrphanDelayed() { + var delayed = orphanDelayedCallbacks; + orphanDelayedCallbacks = null; + for (var i = 0; i < delayed.length; ++i) { delayed[i](); } + } + + // When an aspect of a line changes, a string is added to + // lineView.changes. This updates the relevant part of the line's + // DOM structure. + function updateLineForChanges(cm, lineView, lineN, dims) { + for (var j = 0; j < lineView.changes.length; j++) { + var type = lineView.changes[j]; + if (type == "text") { updateLineText(cm, lineView); } + else if (type == "gutter") { updateLineGutter(cm, lineView, lineN, dims); } + else if (type == "class") { updateLineClasses(cm, lineView); } + else if (type == "widget") { updateLineWidgets(cm, lineView, dims); } + } + lineView.changes = null; + } + + // Lines with gutter elements, widgets or a background class need to + // be wrapped, and have the extra elements added to the wrapper div + function ensureLineWrapped(lineView) { + if (lineView.node == lineView.text) { + lineView.node = elt("div", null, null, "position: relative"); + if (lineView.text.parentNode) + { lineView.text.parentNode.replaceChild(lineView.node, lineView.text); } + lineView.node.appendChild(lineView.text); + if (ie && ie_version < 8) { lineView.node.style.zIndex = 2; } + } + return lineView.node + } + + function updateLineBackground(cm, lineView) { + var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass; + if (cls) { cls += " CodeMirror-linebackground"; } + if (lineView.background) { + if (cls) { lineView.background.className = cls; } + else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; } + } else if (cls) { + var wrap = ensureLineWrapped(lineView); + lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild); + cm.display.input.setUneditable(lineView.background); + } + } + + // Wrapper around buildLineContent which will reuse the structure + // in display.externalMeasured when possible. + function getLineContent(cm, lineView) { + var ext = cm.display.externalMeasured; + if (ext && ext.line == lineView.line) { + cm.display.externalMeasured = null; + lineView.measure = ext.measure; + return ext.built + } + return buildLineContent(cm, lineView) + } + + // Redraw the line's text. Interacts with the background and text + // classes because the mode may output tokens that influence these + // classes. + function updateLineText(cm, lineView) { + var cls = lineView.text.className; + var built = getLineContent(cm, lineView); + if (lineView.text == lineView.node) { lineView.node = built.pre; } + lineView.text.parentNode.replaceChild(built.pre, lineView.text); + lineView.text = built.pre; + if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) { + lineView.bgClass = built.bgClass; + lineView.textClass = built.textClass; + updateLineClasses(cm, lineView); + } else if (cls) { + lineView.text.className = cls; + } + } + + function updateLineClasses(cm, lineView) { + updateLineBackground(cm, lineView); + if (lineView.line.wrapClass) + { ensureLineWrapped(lineView).className = lineView.line.wrapClass; } + else if (lineView.node != lineView.text) + { lineView.node.className = ""; } + var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass; + lineView.text.className = textClass || ""; + } + + function updateLineGutter(cm, lineView, lineN, dims) { + if (lineView.gutter) { + lineView.node.removeChild(lineView.gutter); + lineView.gutter = null; + } + if (lineView.gutterBackground) { + lineView.node.removeChild(lineView.gutterBackground); + lineView.gutterBackground = null; + } + if (lineView.line.gutterClass) { + var wrap = ensureLineWrapped(lineView); + lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass, + ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + (dims.gutterTotalWidth) + "px")); + cm.display.input.setUneditable(lineView.gutterBackground); + wrap.insertBefore(lineView.gutterBackground, lineView.text); + } + var markers = lineView.line.gutterMarkers; + if (cm.options.lineNumbers || markers) { + var wrap$1 = ensureLineWrapped(lineView); + var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px")); + cm.display.input.setUneditable(gutterWrap); + wrap$1.insertBefore(gutterWrap, lineView.text); + if (lineView.line.gutterClass) + { gutterWrap.className += " " + lineView.line.gutterClass; } + if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"])) + { lineView.lineNumber = gutterWrap.appendChild( + elt("div", lineNumberFor(cm.options, lineN), + "CodeMirror-linenumber CodeMirror-gutter-elt", + ("left: " + (dims.gutterLeft["CodeMirror-linenumbers"]) + "px; width: " + (cm.display.lineNumInnerWidth) + "px"))); } + if (markers) { for (var k = 0; k < cm.display.gutterSpecs.length; ++k) { + var id = cm.display.gutterSpecs[k].className, found = markers.hasOwnProperty(id) && markers[id]; + if (found) + { gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", + ("left: " + (dims.gutterLeft[id]) + "px; width: " + (dims.gutterWidth[id]) + "px"))); } + } } + } + } + + function updateLineWidgets(cm, lineView, dims) { + if (lineView.alignable) { lineView.alignable = null; } + var isWidget = classTest("CodeMirror-linewidget"); + for (var node = lineView.node.firstChild, next = (void 0); node; node = next) { + next = node.nextSibling; + if (isWidget.test(node.className)) { lineView.node.removeChild(node); } + } + insertLineWidgets(cm, lineView, dims); + } + + // Build a line's DOM representation from scratch + function buildLineElement(cm, lineView, lineN, dims) { + var built = getLineContent(cm, lineView); + lineView.text = lineView.node = built.pre; + if (built.bgClass) { lineView.bgClass = built.bgClass; } + if (built.textClass) { lineView.textClass = built.textClass; } + + updateLineClasses(cm, lineView); + updateLineGutter(cm, lineView, lineN, dims); + insertLineWidgets(cm, lineView, dims); + return lineView.node + } + + // A lineView may contain multiple logical lines (when merged by + // collapsed spans). The widgets for all of them need to be drawn. + function insertLineWidgets(cm, lineView, dims) { + insertLineWidgetsFor(cm, lineView.line, lineView, dims, true); + if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++) + { insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false); } } + } + + function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) { + if (!line.widgets) { return } + var wrap = ensureLineWrapped(lineView); + for (var i = 0, ws = line.widgets; i < ws.length; ++i) { + var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget" + (widget.className ? " " + widget.className : "")); + if (!widget.handleMouseEvents) { node.setAttribute("cm-ignore-events", "true"); } + positionLineWidget(widget, node, lineView, dims); + cm.display.input.setUneditable(node); + if (allowAbove && widget.above) + { wrap.insertBefore(node, lineView.gutter || lineView.text); } + else + { wrap.appendChild(node); } + signalLater(widget, "redraw"); + } + } + + function positionLineWidget(widget, node, lineView, dims) { + if (widget.noHScroll) { + (lineView.alignable || (lineView.alignable = [])).push(node); + var width = dims.wrapperWidth; + node.style.left = dims.fixedPos + "px"; + if (!widget.coverGutter) { + width -= dims.gutterTotalWidth; + node.style.paddingLeft = dims.gutterTotalWidth + "px"; + } + node.style.width = width + "px"; + } + if (widget.coverGutter) { + node.style.zIndex = 5; + node.style.position = "relative"; + if (!widget.noHScroll) { node.style.marginLeft = -dims.gutterTotalWidth + "px"; } + } + } + + function widgetHeight(widget) { + if (widget.height != null) { return widget.height } + var cm = widget.doc.cm; + if (!cm) { return 0 } + if (!contains(document.body, widget.node)) { + var parentStyle = "position: relative;"; + if (widget.coverGutter) + { parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;"; } + if (widget.noHScroll) + { parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;"; } + removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle)); + } + return widget.height = widget.node.parentNode.offsetHeight + } + + // Return true when the given mouse event happened in a widget + function eventInWidget(display, e) { + for (var n = e_target(e); n != display.wrapper; n = n.parentNode) { + if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") || + (n.parentNode == display.sizer && n != display.mover)) + { return true } + } + } + + // POSITION MEASUREMENT + + function paddingTop(display) {return display.lineSpace.offsetTop} + function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight} + function paddingH(display) { + if (display.cachedPaddingH) { return display.cachedPaddingH } + var e = removeChildrenAndAdd(display.measure, elt("pre", "x", "CodeMirror-line-like")); + var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle; + var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)}; + if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data; } + return data + } + + function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth } + function displayWidth(cm) { + return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth + } + function displayHeight(cm) { + return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight + } + + // Ensure the lineView.wrapping.heights array is populated. This is + // an array of bottom offsets for the lines that make up a drawn + // line. When lineWrapping is on, there might be more than one + // height. + function ensureLineHeights(cm, lineView, rect) { + var wrapping = cm.options.lineWrapping; + var curWidth = wrapping && displayWidth(cm); + if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) { + var heights = lineView.measure.heights = []; + if (wrapping) { + lineView.measure.width = curWidth; + var rects = lineView.text.firstChild.getClientRects(); + for (var i = 0; i < rects.length - 1; i++) { + var cur = rects[i], next = rects[i + 1]; + if (Math.abs(cur.bottom - next.bottom) > 2) + { heights.push((cur.bottom + next.top) / 2 - rect.top); } + } + } + heights.push(rect.bottom - rect.top); + } + } + + // Find a line map (mapping character offsets to text nodes) and a + // measurement cache for the given line number. (A line view might + // contain multiple lines when collapsed ranges are present.) + function mapFromLineView(lineView, line, lineN) { + if (lineView.line == line) + { return {map: lineView.measure.map, cache: lineView.measure.cache} } + for (var i = 0; i < lineView.rest.length; i++) + { if (lineView.rest[i] == line) + { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } } + for (var i$1 = 0; i$1 < lineView.rest.length; i$1++) + { if (lineNo(lineView.rest[i$1]) > lineN) + { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } } + } + + // Render a line into the hidden node display.externalMeasured. Used + // when measurement is needed for a line that's not in the viewport. + function updateExternalMeasurement(cm, line) { + line = visualLine(line); + var lineN = lineNo(line); + var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN); + view.lineN = lineN; + var built = view.built = buildLineContent(cm, view); + view.text = built.pre; + removeChildrenAndAdd(cm.display.lineMeasure, built.pre); + return view + } + + // Get a {top, bottom, left, right} box (in line-local coordinates) + // for a given character. + function measureChar(cm, line, ch, bias) { + return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias) + } + + // Find a line view that corresponds to the given line number. + function findViewForLine(cm, lineN) { + if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo) + { return cm.display.view[findViewIndex(cm, lineN)] } + var ext = cm.display.externalMeasured; + if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size) + { return ext } + } + + // Measurement can be split in two steps, the set-up work that + // applies to the whole line, and the measurement of the actual + // character. Functions like coordsChar, that need to do a lot of + // measurements in a row, can thus ensure that the set-up work is + // only done once. + function prepareMeasureForLine(cm, line) { + var lineN = lineNo(line); + var view = findViewForLine(cm, lineN); + if (view && !view.text) { + view = null; + } else if (view && view.changes) { + updateLineForChanges(cm, view, lineN, getDimensions(cm)); + cm.curOp.forceUpdate = true; + } + if (!view) + { view = updateExternalMeasurement(cm, line); } + + var info = mapFromLineView(view, line, lineN); + return { + line: line, view: view, rect: null, + map: info.map, cache: info.cache, before: info.before, + hasHeights: false + } + } + + // Given a prepared measurement object, measures the position of an + // actual character (or fetches it from the cache). + function measureCharPrepared(cm, prepared, ch, bias, varHeight) { + if (prepared.before) { ch = -1; } + var key = ch + (bias || ""), found; + if (prepared.cache.hasOwnProperty(key)) { + found = prepared.cache[key]; + } else { + if (!prepared.rect) + { prepared.rect = prepared.view.text.getBoundingClientRect(); } + if (!prepared.hasHeights) { + ensureLineHeights(cm, prepared.view, prepared.rect); + prepared.hasHeights = true; + } + found = measureCharInner(cm, prepared, ch, bias); + if (!found.bogus) { prepared.cache[key] = found; } + } + return {left: found.left, right: found.right, + top: varHeight ? found.rtop : found.top, + bottom: varHeight ? found.rbottom : found.bottom} + } + + var nullRect = {left: 0, right: 0, top: 0, bottom: 0}; + + function nodeAndOffsetInLineMap(map, ch, bias) { + var node, start, end, collapse, mStart, mEnd; + // First, search the line map for the text node corresponding to, + // or closest to, the target character. + for (var i = 0; i < map.length; i += 3) { + mStart = map[i]; + mEnd = map[i + 1]; + if (ch < mStart) { + start = 0; end = 1; + collapse = "left"; + } else if (ch < mEnd) { + start = ch - mStart; + end = start + 1; + } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) { + end = mEnd - mStart; + start = end - 1; + if (ch >= mEnd) { collapse = "right"; } + } + if (start != null) { + node = map[i + 2]; + if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right")) + { collapse = bias; } + if (bias == "left" && start == 0) + { while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) { + node = map[(i -= 3) + 2]; + collapse = "left"; + } } + if (bias == "right" && start == mEnd - mStart) + { while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) { + node = map[(i += 3) + 2]; + collapse = "right"; + } } + break + } + } + return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd} + } + + function getUsefulRect(rects, bias) { + var rect = nullRect; + if (bias == "left") { for (var i = 0; i < rects.length; i++) { + if ((rect = rects[i]).left != rect.right) { break } + } } else { for (var i$1 = rects.length - 1; i$1 >= 0; i$1--) { + if ((rect = rects[i$1]).left != rect.right) { break } + } } + return rect + } + + function measureCharInner(cm, prepared, ch, bias) { + var place = nodeAndOffsetInLineMap(prepared.map, ch, bias); + var node = place.node, start = place.start, end = place.end, collapse = place.collapse; + + var rect; + if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates. + for (var i$1 = 0; i$1 < 4; i$1++) { // Retry a maximum of 4 times when nonsense rectangles are returned + while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) { --start; } + while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) { ++end; } + if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) + { rect = node.parentNode.getBoundingClientRect(); } + else + { rect = getUsefulRect(range(node, start, end).getClientRects(), bias); } + if (rect.left || rect.right || start == 0) { break } + end = start; + start = start - 1; + collapse = "right"; + } + if (ie && ie_version < 11) { rect = maybeUpdateRectForZooming(cm.display.measure, rect); } + } else { // If it is a widget, simply get the box for the whole widget. + if (start > 0) { collapse = bias = "right"; } + var rects; + if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1) + { rect = rects[bias == "right" ? rects.length - 1 : 0]; } + else + { rect = node.getBoundingClientRect(); } + } + if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) { + var rSpan = node.parentNode.getClientRects()[0]; + if (rSpan) + { rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom}; } + else + { rect = nullRect; } + } + + var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top; + var mid = (rtop + rbot) / 2; + var heights = prepared.view.measure.heights; + var i = 0; + for (; i < heights.length - 1; i++) + { if (mid < heights[i]) { break } } + var top = i ? heights[i - 1] : 0, bot = heights[i]; + var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left, + right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left, + top: top, bottom: bot}; + if (!rect.left && !rect.right) { result.bogus = true; } + if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; } + + return result + } + + // Work around problem with bounding client rects on ranges being + // returned incorrectly when zoomed on IE10 and below. + function maybeUpdateRectForZooming(measure, rect) { + if (!window.screen || screen.logicalXDPI == null || + screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure)) + { return rect } + var scaleX = screen.logicalXDPI / screen.deviceXDPI; + var scaleY = screen.logicalYDPI / screen.deviceYDPI; + return {left: rect.left * scaleX, right: rect.right * scaleX, + top: rect.top * scaleY, bottom: rect.bottom * scaleY} + } + + function clearLineMeasurementCacheFor(lineView) { + if (lineView.measure) { + lineView.measure.cache = {}; + lineView.measure.heights = null; + if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++) + { lineView.measure.caches[i] = {}; } } + } + } + + function clearLineMeasurementCache(cm) { + cm.display.externalMeasure = null; + removeChildren(cm.display.lineMeasure); + for (var i = 0; i < cm.display.view.length; i++) + { clearLineMeasurementCacheFor(cm.display.view[i]); } + } + + function clearCaches(cm) { + clearLineMeasurementCache(cm); + cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null; + if (!cm.options.lineWrapping) { cm.display.maxLineChanged = true; } + cm.display.lineNumChars = null; + } + + function pageScrollX() { + // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206 + // which causes page_Offset and bounding client rects to use + // different reference viewports and invalidate our calculations. + if (chrome && android) { return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) } + return window.pageXOffset || (document.documentElement || document.body).scrollLeft + } + function pageScrollY() { + if (chrome && android) { return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) } + return window.pageYOffset || (document.documentElement || document.body).scrollTop + } + + function widgetTopHeight(lineObj) { + var height = 0; + if (lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above) + { height += widgetHeight(lineObj.widgets[i]); } } } + return height + } + + // Converts a {top, bottom, left, right} box from line-local + // coordinates into another coordinate system. Context may be one of + // "line", "div" (display.lineDiv), "local"./null (editor), "window", + // or "page". + function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) { + if (!includeWidgets) { + var height = widgetTopHeight(lineObj); + rect.top += height; rect.bottom += height; + } + if (context == "line") { return rect } + if (!context) { context = "local"; } + var yOff = heightAtLine(lineObj); + if (context == "local") { yOff += paddingTop(cm.display); } + else { yOff -= cm.display.viewOffset; } + if (context == "page" || context == "window") { + var lOff = cm.display.lineSpace.getBoundingClientRect(); + yOff += lOff.top + (context == "window" ? 0 : pageScrollY()); + var xOff = lOff.left + (context == "window" ? 0 : pageScrollX()); + rect.left += xOff; rect.right += xOff; + } + rect.top += yOff; rect.bottom += yOff; + return rect + } + + // Coverts a box from "div" coords to another coordinate system. + // Context may be "window", "page", "div", or "local"./null. + function fromCoordSystem(cm, coords, context) { + if (context == "div") { return coords } + var left = coords.left, top = coords.top; + // First move into "page" coordinate system + if (context == "page") { + left -= pageScrollX(); + top -= pageScrollY(); + } else if (context == "local" || !context) { + var localBox = cm.display.sizer.getBoundingClientRect(); + left += localBox.left; + top += localBox.top; + } + + var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect(); + return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top} + } + + function charCoords(cm, pos, context, lineObj, bias) { + if (!lineObj) { lineObj = getLine(cm.doc, pos.line); } + return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context) + } + + // Returns a box for a given cursor position, which may have an + // 'other' property containing the position of the secondary cursor + // on a bidi boundary. + // A cursor Pos(line, char, "before") is on the same visual line as `char - 1` + // and after `char - 1` in writing order of `char - 1` + // A cursor Pos(line, char, "after") is on the same visual line as `char` + // and before `char` in writing order of `char` + // Examples (upper-case letters are RTL, lower-case are LTR): + // Pos(0, 1, ...) + // before after + // ab a|b a|b + // aB a|B aB| + // Ab |Ab A|b + // AB B|A B|A + // Every position after the last character on a line is considered to stick + // to the last character on the line. + function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) { + lineObj = lineObj || getLine(cm.doc, pos.line); + if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); } + function get(ch, right) { + var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight); + if (right) { m.left = m.right; } else { m.right = m.left; } + return intoCoordSystem(cm, lineObj, m, context) + } + var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky; + if (ch >= lineObj.text.length) { + ch = lineObj.text.length; + sticky = "before"; + } else if (ch <= 0) { + ch = 0; + sticky = "after"; + } + if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before") } + + function getBidi(ch, partPos, invert) { + var part = order[partPos], right = part.level == 1; + return get(invert ? ch - 1 : ch, right != invert) + } + var partPos = getBidiPartAt(order, ch, sticky); + var other = bidiOther; + var val = getBidi(ch, partPos, sticky == "before"); + if (other != null) { val.other = getBidi(ch, other, sticky != "before"); } + return val + } + + // Used to cheaply estimate the coordinates for a position. Used for + // intermediate scroll updates. + function estimateCoords(cm, pos) { + var left = 0; + pos = clipPos(cm.doc, pos); + if (!cm.options.lineWrapping) { left = charWidth(cm.display) * pos.ch; } + var lineObj = getLine(cm.doc, pos.line); + var top = heightAtLine(lineObj) + paddingTop(cm.display); + return {left: left, right: left, top: top, bottom: top + lineObj.height} + } + + // Positions returned by coordsChar contain some extra information. + // xRel is the relative x position of the input coordinates compared + // to the found position (so xRel > 0 means the coordinates are to + // the right of the character position, for example). When outside + // is true, that means the coordinates lie outside the line's + // vertical range. + function PosWithInfo(line, ch, sticky, outside, xRel) { + var pos = Pos(line, ch, sticky); + pos.xRel = xRel; + if (outside) { pos.outside = outside; } + return pos + } + + // Compute the character position closest to the given coordinates. + // Input must be lineSpace-local ("div" coordinate system). + function coordsChar(cm, x, y) { + var doc = cm.doc; + y += cm.display.viewOffset; + if (y < 0) { return PosWithInfo(doc.first, 0, null, -1, -1) } + var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1; + if (lineN > last) + { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, 1, 1) } + if (x < 0) { x = 0; } + + var lineObj = getLine(doc, lineN); + for (;;) { + var found = coordsCharInner(cm, lineObj, lineN, x, y); + var collapsed = collapsedSpanAround(lineObj, found.ch + (found.xRel > 0 || found.outside > 0 ? 1 : 0)); + if (!collapsed) { return found } + var rangeEnd = collapsed.find(1); + if (rangeEnd.line == lineN) { return rangeEnd } + lineObj = getLine(doc, lineN = rangeEnd.line); + } + } + + function wrappedLineExtent(cm, lineObj, preparedMeasure, y) { + y -= widgetTopHeight(lineObj); + var end = lineObj.text.length; + var begin = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch - 1).bottom <= y; }, end, 0); + end = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch).top > y; }, begin, end); + return {begin: begin, end: end} + } + + function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) { + if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); } + var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line").top; + return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop) + } + + // Returns true if the given side of a box is after the given + // coordinates, in top-to-bottom, left-to-right order. + function boxIsAfter(box, x, y, left) { + return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x + } + + function coordsCharInner(cm, lineObj, lineNo, x, y) { + // Move y into line-local coordinate space + y -= heightAtLine(lineObj); + var preparedMeasure = prepareMeasureForLine(cm, lineObj); + // When directly calling `measureCharPrepared`, we have to adjust + // for the widgets at this line. + var widgetHeight = widgetTopHeight(lineObj); + var begin = 0, end = lineObj.text.length, ltr = true; + + var order = getOrder(lineObj, cm.doc.direction); + // If the line isn't plain left-to-right text, first figure out + // which bidi section the coordinates fall into. + if (order) { + var part = (cm.options.lineWrapping ? coordsBidiPartWrapped : coordsBidiPart) + (cm, lineObj, lineNo, preparedMeasure, order, x, y); + ltr = part.level != 1; + // The awkward -1 offsets are needed because findFirst (called + // on these below) will treat its first bound as inclusive, + // second as exclusive, but we want to actually address the + // characters in the part's range + begin = ltr ? part.from : part.to - 1; + end = ltr ? part.to : part.from - 1; + } + + // A binary search to find the first character whose bounding box + // starts after the coordinates. If we run across any whose box wrap + // the coordinates, store that. + var chAround = null, boxAround = null; + var ch = findFirst(function (ch) { + var box = measureCharPrepared(cm, preparedMeasure, ch); + box.top += widgetHeight; box.bottom += widgetHeight; + if (!boxIsAfter(box, x, y, false)) { return false } + if (box.top <= y && box.left <= x) { + chAround = ch; + boxAround = box; + } + return true + }, begin, end); + + var baseX, sticky, outside = false; + // If a box around the coordinates was found, use that + if (boxAround) { + // Distinguish coordinates nearer to the left or right side of the box + var atLeft = x - boxAround.left < boxAround.right - x, atStart = atLeft == ltr; + ch = chAround + (atStart ? 0 : 1); + sticky = atStart ? "after" : "before"; + baseX = atLeft ? boxAround.left : boxAround.right; + } else { + // (Adjust for extended bound, if necessary.) + if (!ltr && (ch == end || ch == begin)) { ch++; } + // To determine which side to associate with, get the box to the + // left of the character and compare it's vertical position to the + // coordinates + sticky = ch == 0 ? "after" : ch == lineObj.text.length ? "before" : + (measureCharPrepared(cm, preparedMeasure, ch - (ltr ? 1 : 0)).bottom + widgetHeight <= y) == ltr ? + "after" : "before"; + // Now get accurate coordinates for this place, in order to get a + // base X position + var coords = cursorCoords(cm, Pos(lineNo, ch, sticky), "line", lineObj, preparedMeasure); + baseX = coords.left; + outside = y < coords.top ? -1 : y >= coords.bottom ? 1 : 0; + } + + ch = skipExtendingChars(lineObj.text, ch, 1); + return PosWithInfo(lineNo, ch, sticky, outside, x - baseX) + } + + function coordsBidiPart(cm, lineObj, lineNo, preparedMeasure, order, x, y) { + // Bidi parts are sorted left-to-right, and in a non-line-wrapping + // situation, we can take this ordering to correspond to the visual + // ordering. This finds the first part whose end is after the given + // coordinates. + var index = findFirst(function (i) { + var part = order[i], ltr = part.level != 1; + return boxIsAfter(cursorCoords(cm, Pos(lineNo, ltr ? part.to : part.from, ltr ? "before" : "after"), + "line", lineObj, preparedMeasure), x, y, true) + }, 0, order.length - 1); + var part = order[index]; + // If this isn't the first part, the part's start is also after + // the coordinates, and the coordinates aren't on the same line as + // that start, move one part back. + if (index > 0) { + var ltr = part.level != 1; + var start = cursorCoords(cm, Pos(lineNo, ltr ? part.from : part.to, ltr ? "after" : "before"), + "line", lineObj, preparedMeasure); + if (boxIsAfter(start, x, y, true) && start.top > y) + { part = order[index - 1]; } + } + return part + } + + function coordsBidiPartWrapped(cm, lineObj, _lineNo, preparedMeasure, order, x, y) { + // In a wrapped line, rtl text on wrapping boundaries can do things + // that don't correspond to the ordering in our `order` array at + // all, so a binary search doesn't work, and we want to return a + // part that only spans one line so that the binary search in + // coordsCharInner is safe. As such, we first find the extent of the + // wrapped line, and then do a flat search in which we discard any + // spans that aren't on the line. + var ref = wrappedLineExtent(cm, lineObj, preparedMeasure, y); + var begin = ref.begin; + var end = ref.end; + if (/\s/.test(lineObj.text.charAt(end - 1))) { end--; } + var part = null, closestDist = null; + for (var i = 0; i < order.length; i++) { + var p = order[i]; + if (p.from >= end || p.to <= begin) { continue } + var ltr = p.level != 1; + var endX = measureCharPrepared(cm, preparedMeasure, ltr ? Math.min(end, p.to) - 1 : Math.max(begin, p.from)).right; + // Weigh against spans ending before this, so that they are only + // picked if nothing ends after + var dist = endX < x ? x - endX + 1e9 : endX - x; + if (!part || closestDist > dist) { + part = p; + closestDist = dist; + } + } + if (!part) { part = order[order.length - 1]; } + // Clip the part to the wrapped line. + if (part.from < begin) { part = {from: begin, to: part.to, level: part.level}; } + if (part.to > end) { part = {from: part.from, to: end, level: part.level}; } + return part + } + + var measureText; + // Compute the default text height. + function textHeight(display) { + if (display.cachedTextHeight != null) { return display.cachedTextHeight } + if (measureText == null) { + measureText = elt("pre", null, "CodeMirror-line-like"); + // Measure a bunch of lines, for browsers that compute + // fractional heights. + for (var i = 0; i < 49; ++i) { + measureText.appendChild(document.createTextNode("x")); + measureText.appendChild(elt("br")); + } + measureText.appendChild(document.createTextNode("x")); + } + removeChildrenAndAdd(display.measure, measureText); + var height = measureText.offsetHeight / 50; + if (height > 3) { display.cachedTextHeight = height; } + removeChildren(display.measure); + return height || 1 + } + + // Compute the default character width. + function charWidth(display) { + if (display.cachedCharWidth != null) { return display.cachedCharWidth } + var anchor = elt("span", "xxxxxxxxxx"); + var pre = elt("pre", [anchor], "CodeMirror-line-like"); + removeChildrenAndAdd(display.measure, pre); + var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10; + if (width > 2) { display.cachedCharWidth = width; } + return width || 10 + } + + // Do a bulk-read of the DOM positions and sizes needed to draw the + // view, so that we don't interleave reading and writing to the DOM. + function getDimensions(cm) { + var d = cm.display, left = {}, width = {}; + var gutterLeft = d.gutters.clientLeft; + for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) { + var id = cm.display.gutterSpecs[i].className; + left[id] = n.offsetLeft + n.clientLeft + gutterLeft; + width[id] = n.clientWidth; + } + return {fixedPos: compensateForHScroll(d), + gutterTotalWidth: d.gutters.offsetWidth, + gutterLeft: left, + gutterWidth: width, + wrapperWidth: d.wrapper.clientWidth} + } + + // Computes display.scroller.scrollLeft + display.gutters.offsetWidth, + // but using getBoundingClientRect to get a sub-pixel-accurate + // result. + function compensateForHScroll(display) { + return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left + } + + // Returns a function that estimates the height of a line, to use as + // first approximation until the line becomes visible (and is thus + // properly measurable). + function estimateHeight(cm) { + var th = textHeight(cm.display), wrapping = cm.options.lineWrapping; + var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3); + return function (line) { + if (lineIsHidden(cm.doc, line)) { return 0 } + + var widgetsHeight = 0; + if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) { + if (line.widgets[i].height) { widgetsHeight += line.widgets[i].height; } + } } + + if (wrapping) + { return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th } + else + { return widgetsHeight + th } + } + } + + function estimateLineHeights(cm) { + var doc = cm.doc, est = estimateHeight(cm); + doc.iter(function (line) { + var estHeight = est(line); + if (estHeight != line.height) { updateLineHeight(line, estHeight); } + }); + } + + // Given a mouse event, find the corresponding position. If liberal + // is false, it checks whether a gutter or scrollbar was clicked, + // and returns null if it was. forRect is used by rectangular + // selections, and tries to estimate a character position even for + // coordinates beyond the right of the text. + function posFromMouse(cm, e, liberal, forRect) { + var display = cm.display; + if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") { return null } + + var x, y, space = display.lineSpace.getBoundingClientRect(); + // Fails unpredictably on IE[67] when mouse is dragged around quickly. + try { x = e.clientX - space.left; y = e.clientY - space.top; } + catch (e$1) { return null } + var coords = coordsChar(cm, x, y), line; + if (forRect && coords.xRel > 0 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { + var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; + coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)); + } + return coords + } + + // Find the view element corresponding to a given line. Return null + // when the line isn't visible. + function findViewIndex(cm, n) { + if (n >= cm.display.viewTo) { return null } + n -= cm.display.viewFrom; + if (n < 0) { return null } + var view = cm.display.view; + for (var i = 0; i < view.length; i++) { + n -= view[i].size; + if (n < 0) { return i } + } + } + + // Updates the display.view data structure for a given change to the + // document. From and to are in pre-change coordinates. Lendiff is + // the amount of lines added or subtracted by the change. This is + // used for changes that span multiple lines, or change the way + // lines are divided into visual lines. regLineChange (below) + // registers single-line changes. + function regChange(cm, from, to, lendiff) { + if (from == null) { from = cm.doc.first; } + if (to == null) { to = cm.doc.first + cm.doc.size; } + if (!lendiff) { lendiff = 0; } + + var display = cm.display; + if (lendiff && to < display.viewTo && + (display.updateLineNumbers == null || display.updateLineNumbers > from)) + { display.updateLineNumbers = from; } + + cm.curOp.viewChanged = true; + + if (from >= display.viewTo) { // Change after + if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo) + { resetView(cm); } + } else if (to <= display.viewFrom) { // Change before + if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) { + resetView(cm); + } else { + display.viewFrom += lendiff; + display.viewTo += lendiff; + } + } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap + resetView(cm); + } else if (from <= display.viewFrom) { // Top overlap + var cut = viewCuttingPoint(cm, to, to + lendiff, 1); + if (cut) { + display.view = display.view.slice(cut.index); + display.viewFrom = cut.lineN; + display.viewTo += lendiff; + } else { + resetView(cm); + } + } else if (to >= display.viewTo) { // Bottom overlap + var cut$1 = viewCuttingPoint(cm, from, from, -1); + if (cut$1) { + display.view = display.view.slice(0, cut$1.index); + display.viewTo = cut$1.lineN; + } else { + resetView(cm); + } + } else { // Gap in the middle + var cutTop = viewCuttingPoint(cm, from, from, -1); + var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1); + if (cutTop && cutBot) { + display.view = display.view.slice(0, cutTop.index) + .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN)) + .concat(display.view.slice(cutBot.index)); + display.viewTo += lendiff; + } else { + resetView(cm); + } + } + + var ext = display.externalMeasured; + if (ext) { + if (to < ext.lineN) + { ext.lineN += lendiff; } + else if (from < ext.lineN + ext.size) + { display.externalMeasured = null; } + } + } + + // Register a change to a single line. Type must be one of "text", + // "gutter", "class", "widget" + function regLineChange(cm, line, type) { + cm.curOp.viewChanged = true; + var display = cm.display, ext = cm.display.externalMeasured; + if (ext && line >= ext.lineN && line < ext.lineN + ext.size) + { display.externalMeasured = null; } + + if (line < display.viewFrom || line >= display.viewTo) { return } + var lineView = display.view[findViewIndex(cm, line)]; + if (lineView.node == null) { return } + var arr = lineView.changes || (lineView.changes = []); + if (indexOf(arr, type) == -1) { arr.push(type); } + } + + // Clear the view. + function resetView(cm) { + cm.display.viewFrom = cm.display.viewTo = cm.doc.first; + cm.display.view = []; + cm.display.viewOffset = 0; + } + + function viewCuttingPoint(cm, oldN, newN, dir) { + var index = findViewIndex(cm, oldN), diff, view = cm.display.view; + if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size) + { return {index: index, lineN: newN} } + var n = cm.display.viewFrom; + for (var i = 0; i < index; i++) + { n += view[i].size; } + if (n != oldN) { + if (dir > 0) { + if (index == view.length - 1) { return null } + diff = (n + view[index].size) - oldN; + index++; + } else { + diff = n - oldN; + } + oldN += diff; newN += diff; + } + while (visualLineNo(cm.doc, newN) != newN) { + if (index == (dir < 0 ? 0 : view.length - 1)) { return null } + newN += dir * view[index - (dir < 0 ? 1 : 0)].size; + index += dir; + } + return {index: index, lineN: newN} + } + + // Force the view to cover a given range, adding empty view element + // or clipping off existing ones as needed. + function adjustView(cm, from, to) { + var display = cm.display, view = display.view; + if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) { + display.view = buildViewArray(cm, from, to); + display.viewFrom = from; + } else { + if (display.viewFrom > from) + { display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); } + else if (display.viewFrom < from) + { display.view = display.view.slice(findViewIndex(cm, from)); } + display.viewFrom = from; + if (display.viewTo < to) + { display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); } + else if (display.viewTo > to) + { display.view = display.view.slice(0, findViewIndex(cm, to)); } + } + display.viewTo = to; + } + + // Count the number of lines in the view whose DOM representation is + // out of date (or nonexistent). + function countDirtyView(cm) { + var view = cm.display.view, dirty = 0; + for (var i = 0; i < view.length; i++) { + var lineView = view[i]; + if (!lineView.hidden && (!lineView.node || lineView.changes)) { ++dirty; } + } + return dirty + } + + function updateSelection(cm) { + cm.display.input.showSelection(cm.display.input.prepareSelection()); + } + + function prepareSelection(cm, primary) { + if ( primary === void 0 ) primary = true; + + var doc = cm.doc, result = {}; + var curFragment = result.cursors = document.createDocumentFragment(); + var selFragment = result.selection = document.createDocumentFragment(); + + for (var i = 0; i < doc.sel.ranges.length; i++) { + if (!primary && i == doc.sel.primIndex) { continue } + var range = doc.sel.ranges[i]; + if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) { continue } + var collapsed = range.empty(); + if (collapsed || cm.options.showCursorWhenSelecting) + { drawSelectionCursor(cm, range.head, curFragment); } + if (!collapsed) + { drawSelectionRange(cm, range, selFragment); } + } + return result + } + + // Draws a cursor for the given range + function drawSelectionCursor(cm, head, output) { + var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine); + + var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor")); + cursor.style.left = pos.left + "px"; + cursor.style.top = pos.top + "px"; + cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"; + + if (pos.other) { + // Secondary cursor, shown when on a 'jump' in bi-directional text + var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor")); + otherCursor.style.display = ""; + otherCursor.style.left = pos.other.left + "px"; + otherCursor.style.top = pos.other.top + "px"; + otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px"; + } + } + + function cmpCoords(a, b) { return a.top - b.top || a.left - b.left } + + // Draws the given range as a highlighted selection + function drawSelectionRange(cm, range, output) { + var display = cm.display, doc = cm.doc; + var fragment = document.createDocumentFragment(); + var padding = paddingH(cm.display), leftSide = padding.left; + var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right; + var docLTR = doc.direction == "ltr"; + + function add(left, top, width, bottom) { + if (top < 0) { top = 0; } + top = Math.round(top); + bottom = Math.round(bottom); + fragment.appendChild(elt("div", null, "CodeMirror-selected", ("position: absolute; left: " + left + "px;\n top: " + top + "px; width: " + (width == null ? rightSide - left : width) + "px;\n height: " + (bottom - top) + "px"))); + } + + function drawForLine(line, fromArg, toArg) { + var lineObj = getLine(doc, line); + var lineLen = lineObj.text.length; + var start, end; + function coords(ch, bias) { + return charCoords(cm, Pos(line, ch), "div", lineObj, bias) + } + + function wrapX(pos, dir, side) { + var extent = wrappedLineExtentChar(cm, lineObj, null, pos); + var prop = (dir == "ltr") == (side == "after") ? "left" : "right"; + var ch = side == "after" ? extent.begin : extent.end - (/\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1); + return coords(ch, prop)[prop] + } + + var order = getOrder(lineObj, doc.direction); + iterateBidiSections(order, fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir, i) { + var ltr = dir == "ltr"; + var fromPos = coords(from, ltr ? "left" : "right"); + var toPos = coords(to - 1, ltr ? "right" : "left"); + + var openStart = fromArg == null && from == 0, openEnd = toArg == null && to == lineLen; + var first = i == 0, last = !order || i == order.length - 1; + if (toPos.top - fromPos.top <= 3) { // Single line + var openLeft = (docLTR ? openStart : openEnd) && first; + var openRight = (docLTR ? openEnd : openStart) && last; + var left = openLeft ? leftSide : (ltr ? fromPos : toPos).left; + var right = openRight ? rightSide : (ltr ? toPos : fromPos).right; + add(left, fromPos.top, right - left, fromPos.bottom); + } else { // Multiple lines + var topLeft, topRight, botLeft, botRight; + if (ltr) { + topLeft = docLTR && openStart && first ? leftSide : fromPos.left; + topRight = docLTR ? rightSide : wrapX(from, dir, "before"); + botLeft = docLTR ? leftSide : wrapX(to, dir, "after"); + botRight = docLTR && openEnd && last ? rightSide : toPos.right; + } else { + topLeft = !docLTR ? leftSide : wrapX(from, dir, "before"); + topRight = !docLTR && openStart && first ? rightSide : fromPos.right; + botLeft = !docLTR && openEnd && last ? leftSide : toPos.left; + botRight = !docLTR ? rightSide : wrapX(to, dir, "after"); + } + add(topLeft, fromPos.top, topRight - topLeft, fromPos.bottom); + if (fromPos.bottom < toPos.top) { add(leftSide, fromPos.bottom, null, toPos.top); } + add(botLeft, toPos.top, botRight - botLeft, toPos.bottom); + } + + if (!start || cmpCoords(fromPos, start) < 0) { start = fromPos; } + if (cmpCoords(toPos, start) < 0) { start = toPos; } + if (!end || cmpCoords(fromPos, end) < 0) { end = fromPos; } + if (cmpCoords(toPos, end) < 0) { end = toPos; } + }); + return {start: start, end: end} + } + + var sFrom = range.from(), sTo = range.to(); + if (sFrom.line == sTo.line) { + drawForLine(sFrom.line, sFrom.ch, sTo.ch); + } else { + var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line); + var singleVLine = visualLine(fromLine) == visualLine(toLine); + var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end; + var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start; + if (singleVLine) { + if (leftEnd.top < rightStart.top - 2) { + add(leftEnd.right, leftEnd.top, null, leftEnd.bottom); + add(leftSide, rightStart.top, rightStart.left, rightStart.bottom); + } else { + add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom); + } + } + if (leftEnd.bottom < rightStart.top) + { add(leftSide, leftEnd.bottom, null, rightStart.top); } + } + + output.appendChild(fragment); + } + + // Cursor-blinking + function restartBlink(cm) { + if (!cm.state.focused) { return } + var display = cm.display; + clearInterval(display.blinker); + var on = true; + display.cursorDiv.style.visibility = ""; + if (cm.options.cursorBlinkRate > 0) + { display.blinker = setInterval(function () { + if (!cm.hasFocus()) { onBlur(cm); } + display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; + }, cm.options.cursorBlinkRate); } + else if (cm.options.cursorBlinkRate < 0) + { display.cursorDiv.style.visibility = "hidden"; } + } + + function ensureFocus(cm) { + if (!cm.hasFocus()) { + cm.display.input.focus(); + if (!cm.state.focused) { onFocus(cm); } + } + } + + function delayBlurEvent(cm) { + cm.state.delayingBlurEvent = true; + setTimeout(function () { if (cm.state.delayingBlurEvent) { + cm.state.delayingBlurEvent = false; + if (cm.state.focused) { onBlur(cm); } + } }, 100); + } + + function onFocus(cm, e) { + if (cm.state.delayingBlurEvent && !cm.state.draggingText) { cm.state.delayingBlurEvent = false; } + + if (cm.options.readOnly == "nocursor") { return } + if (!cm.state.focused) { + signal(cm, "focus", cm, e); + cm.state.focused = true; + addClass(cm.display.wrapper, "CodeMirror-focused"); + // This test prevents this from firing when a context + // menu is closed (since the input reset would kill the + // select-all detection hack) + if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) { + cm.display.input.reset(); + if (webkit) { setTimeout(function () { return cm.display.input.reset(true); }, 20); } // Issue #1730 + } + cm.display.input.receivedFocus(); + } + restartBlink(cm); + } + function onBlur(cm, e) { + if (cm.state.delayingBlurEvent) { return } + + if (cm.state.focused) { + signal(cm, "blur", cm, e); + cm.state.focused = false; + rmClass(cm.display.wrapper, "CodeMirror-focused"); + } + clearInterval(cm.display.blinker); + setTimeout(function () { if (!cm.state.focused) { cm.display.shift = false; } }, 150); + } + + // Read the actual heights of the rendered lines, and update their + // stored heights to match. + function updateHeightsInViewport(cm) { + var display = cm.display; + var prevBottom = display.lineDiv.offsetTop; + for (var i = 0; i < display.view.length; i++) { + var cur = display.view[i], wrapping = cm.options.lineWrapping; + var height = (void 0), width = 0; + if (cur.hidden) { continue } + if (ie && ie_version < 8) { + var bot = cur.node.offsetTop + cur.node.offsetHeight; + height = bot - prevBottom; + prevBottom = bot; + } else { + var box = cur.node.getBoundingClientRect(); + height = box.bottom - box.top; + // Check that lines don't extend past the right of the current + // editor width + if (!wrapping && cur.text.firstChild) + { width = cur.text.firstChild.getBoundingClientRect().right - box.left - 1; } + } + var diff = cur.line.height - height; + if (diff > .005 || diff < -.005) { + updateLineHeight(cur.line, height); + updateWidgetHeight(cur.line); + if (cur.rest) { for (var j = 0; j < cur.rest.length; j++) + { updateWidgetHeight(cur.rest[j]); } } + } + if (width > cm.display.sizerWidth) { + var chWidth = Math.ceil(width / charWidth(cm.display)); + if (chWidth > cm.display.maxLineLength) { + cm.display.maxLineLength = chWidth; + cm.display.maxLine = cur.line; + cm.display.maxLineChanged = true; + } + } + } + } + + // Read and store the height of line widgets associated with the + // given line. + function updateWidgetHeight(line) { + if (line.widgets) { for (var i = 0; i < line.widgets.length; ++i) { + var w = line.widgets[i], parent = w.node.parentNode; + if (parent) { w.height = parent.offsetHeight; } + } } + } + + // Compute the lines that are visible in a given viewport (defaults + // the the current scroll position). viewport may contain top, + // height, and ensure (see op.scrollToPos) properties. + function visibleLines(display, doc, viewport) { + var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop; + top = Math.floor(top - paddingTop(display)); + var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight; + + var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom); + // Ensure is a {from: {line, ch}, to: {line, ch}} object, and + // forces those lines into the viewport (if possible). + if (viewport && viewport.ensure) { + var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line; + if (ensureFrom < from) { + from = ensureFrom; + to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight); + } else if (Math.min(ensureTo, doc.lastLine()) >= to) { + from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight); + to = ensureTo; + } + } + return {from: from, to: Math.max(to, from + 1)} + } + + // SCROLLING THINGS INTO VIEW + + // If an editor sits on the top or bottom of the window, partially + // scrolled out of view, this ensures that the cursor is visible. + function maybeScrollWindow(cm, rect) { + if (signalDOMEvent(cm, "scrollCursorIntoView")) { return } + + var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; + if (rect.top + box.top < 0) { doScroll = true; } + else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false; } + if (doScroll != null && !phantom) { + var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;")); + cm.display.lineSpace.appendChild(scrollNode); + scrollNode.scrollIntoView(doScroll); + cm.display.lineSpace.removeChild(scrollNode); + } + } + + // Scroll a given position into view (immediately), verifying that + // it actually became visible (as line heights are accurately + // measured, the position of something may 'drift' during drawing). + function scrollPosIntoView(cm, pos, end, margin) { + if (margin == null) { margin = 0; } + var rect; + if (!cm.options.lineWrapping && pos == end) { + // Set pos and end to the cursor positions around the character pos sticks to + // If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch + // If pos == Pos(_, 0, "before"), pos and end are unchanged + pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos; + end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos; + } + for (var limit = 0; limit < 5; limit++) { + var changed = false; + var coords = cursorCoords(cm, pos); + var endCoords = !end || end == pos ? coords : cursorCoords(cm, end); + rect = {left: Math.min(coords.left, endCoords.left), + top: Math.min(coords.top, endCoords.top) - margin, + right: Math.max(coords.left, endCoords.left), + bottom: Math.max(coords.bottom, endCoords.bottom) + margin}; + var scrollPos = calculateScrollPos(cm, rect); + var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft; + if (scrollPos.scrollTop != null) { + updateScrollTop(cm, scrollPos.scrollTop); + if (Math.abs(cm.doc.scrollTop - startTop) > 1) { changed = true; } + } + if (scrollPos.scrollLeft != null) { + setScrollLeft(cm, scrollPos.scrollLeft); + if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) { changed = true; } + } + if (!changed) { break } + } + return rect + } + + // Scroll a given set of coordinates into view (immediately). + function scrollIntoView(cm, rect) { + var scrollPos = calculateScrollPos(cm, rect); + if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop); } + if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); } + } + + // Calculate a new scroll position needed to scroll the given + // rectangle into view. Returns an object with scrollTop and + // scrollLeft properties. When these are undefined, the + // vertical/horizontal position does not need to be adjusted. + function calculateScrollPos(cm, rect) { + var display = cm.display, snapMargin = textHeight(cm.display); + if (rect.top < 0) { rect.top = 0; } + var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop; + var screen = displayHeight(cm), result = {}; + if (rect.bottom - rect.top > screen) { rect.bottom = rect.top + screen; } + var docBottom = cm.doc.height + paddingVert(display); + var atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin; + if (rect.top < screentop) { + result.scrollTop = atTop ? 0 : rect.top; + } else if (rect.bottom > screentop + screen) { + var newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen); + if (newTop != screentop) { result.scrollTop = newTop; } + } + + var gutterSpace = cm.options.fixedGutter ? 0 : display.gutters.offsetWidth; + var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft - gutterSpace; + var screenw = displayWidth(cm) - display.gutters.offsetWidth; + var tooWide = rect.right - rect.left > screenw; + if (tooWide) { rect.right = rect.left + screenw; } + if (rect.left < 10) + { result.scrollLeft = 0; } + else if (rect.left < screenleft) + { result.scrollLeft = Math.max(0, rect.left + gutterSpace - (tooWide ? 0 : 10)); } + else if (rect.right > screenw + screenleft - 3) + { result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; } + return result + } + + // Store a relative adjustment to the scroll position in the current + // operation (to be applied when the operation finishes). + function addToScrollTop(cm, top) { + if (top == null) { return } + resolveScrollToPos(cm); + cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top; + } + + // Make sure that at the end of the operation the current cursor is + // shown. + function ensureCursorVisible(cm) { + resolveScrollToPos(cm); + var cur = cm.getCursor(); + cm.curOp.scrollToPos = {from: cur, to: cur, margin: cm.options.cursorScrollMargin}; + } + + function scrollToCoords(cm, x, y) { + if (x != null || y != null) { resolveScrollToPos(cm); } + if (x != null) { cm.curOp.scrollLeft = x; } + if (y != null) { cm.curOp.scrollTop = y; } + } + + function scrollToRange(cm, range) { + resolveScrollToPos(cm); + cm.curOp.scrollToPos = range; + } + + // When an operation has its scrollToPos property set, and another + // scroll action is applied before the end of the operation, this + // 'simulates' scrolling that position into view in a cheap way, so + // that the effect of intermediate scroll commands is not ignored. + function resolveScrollToPos(cm) { + var range = cm.curOp.scrollToPos; + if (range) { + cm.curOp.scrollToPos = null; + var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to); + scrollToCoordsRange(cm, from, to, range.margin); + } + } + + function scrollToCoordsRange(cm, from, to, margin) { + var sPos = calculateScrollPos(cm, { + left: Math.min(from.left, to.left), + top: Math.min(from.top, to.top) - margin, + right: Math.max(from.right, to.right), + bottom: Math.max(from.bottom, to.bottom) + margin + }); + scrollToCoords(cm, sPos.scrollLeft, sPos.scrollTop); + } + + // Sync the scrollable area and scrollbars, ensure the viewport + // covers the visible area. + function updateScrollTop(cm, val) { + if (Math.abs(cm.doc.scrollTop - val) < 2) { return } + if (!gecko) { updateDisplaySimple(cm, {top: val}); } + setScrollTop(cm, val, true); + if (gecko) { updateDisplaySimple(cm); } + startWorker(cm, 100); + } + + function setScrollTop(cm, val, forceScroll) { + val = Math.max(0, Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val)); + if (cm.display.scroller.scrollTop == val && !forceScroll) { return } + cm.doc.scrollTop = val; + cm.display.scrollbars.setScrollTop(val); + if (cm.display.scroller.scrollTop != val) { cm.display.scroller.scrollTop = val; } + } + + // Sync scroller and scrollbar, ensure the gutter elements are + // aligned. + function setScrollLeft(cm, val, isScroller, forceScroll) { + val = Math.max(0, Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth)); + if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) { return } + cm.doc.scrollLeft = val; + alignHorizontally(cm); + if (cm.display.scroller.scrollLeft != val) { cm.display.scroller.scrollLeft = val; } + cm.display.scrollbars.setScrollLeft(val); + } + + // SCROLLBARS + + // Prepare DOM reads needed to update the scrollbars. Done in one + // shot to minimize update/measure roundtrips. + function measureForScrollbars(cm) { + var d = cm.display, gutterW = d.gutters.offsetWidth; + var docH = Math.round(cm.doc.height + paddingVert(cm.display)); + return { + clientHeight: d.scroller.clientHeight, + viewHeight: d.wrapper.clientHeight, + scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth, + viewWidth: d.wrapper.clientWidth, + barLeft: cm.options.fixedGutter ? gutterW : 0, + docHeight: docH, + scrollHeight: docH + scrollGap(cm) + d.barHeight, + nativeBarWidth: d.nativeBarWidth, + gutterWidth: gutterW + } + } + + var NativeScrollbars = function(place, scroll, cm) { + this.cm = cm; + var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar"); + var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar"); + vert.tabIndex = horiz.tabIndex = -1; + place(vert); place(horiz); + + on(vert, "scroll", function () { + if (vert.clientHeight) { scroll(vert.scrollTop, "vertical"); } + }); + on(horiz, "scroll", function () { + if (horiz.clientWidth) { scroll(horiz.scrollLeft, "horizontal"); } + }); + + this.checkedZeroWidth = false; + // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8). + if (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = "18px"; } + }; + + NativeScrollbars.prototype.update = function (measure) { + var needsH = measure.scrollWidth > measure.clientWidth + 1; + var needsV = measure.scrollHeight > measure.clientHeight + 1; + var sWidth = measure.nativeBarWidth; + + if (needsV) { + this.vert.style.display = "block"; + this.vert.style.bottom = needsH ? sWidth + "px" : "0"; + var totalHeight = measure.viewHeight - (needsH ? sWidth : 0); + // A bug in IE8 can cause this value to be negative, so guard it. + this.vert.firstChild.style.height = + Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px"; + } else { + this.vert.style.display = ""; + this.vert.firstChild.style.height = "0"; + } + + if (needsH) { + this.horiz.style.display = "block"; + this.horiz.style.right = needsV ? sWidth + "px" : "0"; + this.horiz.style.left = measure.barLeft + "px"; + var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0); + this.horiz.firstChild.style.width = + Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + "px"; + } else { + this.horiz.style.display = ""; + this.horiz.firstChild.style.width = "0"; + } + + if (!this.checkedZeroWidth && measure.clientHeight > 0) { + if (sWidth == 0) { this.zeroWidthHack(); } + this.checkedZeroWidth = true; + } + + return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0} + }; + + NativeScrollbars.prototype.setScrollLeft = function (pos) { + if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos; } + if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz"); } + }; + + NativeScrollbars.prototype.setScrollTop = function (pos) { + if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos; } + if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert, "vert"); } + }; + + NativeScrollbars.prototype.zeroWidthHack = function () { + var w = mac && !mac_geMountainLion ? "12px" : "18px"; + this.horiz.style.height = this.vert.style.width = w; + this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none"; + this.disableHoriz = new Delayed; + this.disableVert = new Delayed; + }; + + NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay, type) { + bar.style.pointerEvents = "auto"; + function maybeDisable() { + // To find out whether the scrollbar is still visible, we + // check whether the element under the pixel in the bottom + // right corner of the scrollbar box is the scrollbar box + // itself (when the bar is still visible) or its filler child + // (when the bar is hidden). If it is still visible, we keep + // it enabled, if it's hidden, we disable pointer events. + var box = bar.getBoundingClientRect(); + var elt = type == "vert" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2) + : document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1); + if (elt != bar) { bar.style.pointerEvents = "none"; } + else { delay.set(1000, maybeDisable); } + } + delay.set(1000, maybeDisable); + }; + + NativeScrollbars.prototype.clear = function () { + var parent = this.horiz.parentNode; + parent.removeChild(this.horiz); + parent.removeChild(this.vert); + }; + + var NullScrollbars = function () {}; + + NullScrollbars.prototype.update = function () { return {bottom: 0, right: 0} }; + NullScrollbars.prototype.setScrollLeft = function () {}; + NullScrollbars.prototype.setScrollTop = function () {}; + NullScrollbars.prototype.clear = function () {}; + + function updateScrollbars(cm, measure) { + if (!measure) { measure = measureForScrollbars(cm); } + var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight; + updateScrollbarsInner(cm, measure); + for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) { + if (startWidth != cm.display.barWidth && cm.options.lineWrapping) + { updateHeightsInViewport(cm); } + updateScrollbarsInner(cm, measureForScrollbars(cm)); + startWidth = cm.display.barWidth; startHeight = cm.display.barHeight; + } + } + + // Re-synchronize the fake scrollbars with the actual size of the + // content. + function updateScrollbarsInner(cm, measure) { + var d = cm.display; + var sizes = d.scrollbars.update(measure); + + d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px"; + d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px"; + d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"; + + if (sizes.right && sizes.bottom) { + d.scrollbarFiller.style.display = "block"; + d.scrollbarFiller.style.height = sizes.bottom + "px"; + d.scrollbarFiller.style.width = sizes.right + "px"; + } else { d.scrollbarFiller.style.display = ""; } + if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) { + d.gutterFiller.style.display = "block"; + d.gutterFiller.style.height = sizes.bottom + "px"; + d.gutterFiller.style.width = measure.gutterWidth + "px"; + } else { d.gutterFiller.style.display = ""; } + } + + var scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars}; + + function initScrollbars(cm) { + if (cm.display.scrollbars) { + cm.display.scrollbars.clear(); + if (cm.display.scrollbars.addClass) + { rmClass(cm.display.wrapper, cm.display.scrollbars.addClass); } + } + + cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function (node) { + cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller); + // Prevent clicks in the scrollbars from killing focus + on(node, "mousedown", function () { + if (cm.state.focused) { setTimeout(function () { return cm.display.input.focus(); }, 0); } + }); + node.setAttribute("cm-not-content", "true"); + }, function (pos, axis) { + if (axis == "horizontal") { setScrollLeft(cm, pos); } + else { updateScrollTop(cm, pos); } + }, cm); + if (cm.display.scrollbars.addClass) + { addClass(cm.display.wrapper, cm.display.scrollbars.addClass); } + } + + // Operations are used to wrap a series of changes to the editor + // state in such a way that each change won't have to update the + // cursor and display (which would be awkward, slow, and + // error-prone). Instead, display updates are batched and then all + // combined and executed at once. + + var nextOpId = 0; + // Start a new operation. + function startOperation(cm) { + cm.curOp = { + cm: cm, + viewChanged: false, // Flag that indicates that lines might need to be redrawn + startHeight: cm.doc.height, // Used to detect need to update scrollbar + forceUpdate: false, // Used to force a redraw + updateInput: 0, // Whether to reset the input textarea + typing: false, // Whether this reset should be careful to leave existing text (for compositing) + changeObjs: null, // Accumulated changes, for firing change events + cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on + cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already + selectionChanged: false, // Whether the selection needs to be redrawn + updateMaxLine: false, // Set when the widest line needs to be determined anew + scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet + scrollToPos: null, // Used to scroll to a specific position + focus: false, + id: ++nextOpId // Unique ID + }; + pushOperation(cm.curOp); + } + + // Finish an operation, updating the display and signalling delayed events + function endOperation(cm) { + var op = cm.curOp; + if (op) { finishOperation(op, function (group) { + for (var i = 0; i < group.ops.length; i++) + { group.ops[i].cm.curOp = null; } + endOperations(group); + }); } + } + + // The DOM updates done when an operation finishes are batched so + // that the minimum number of relayouts are required. + function endOperations(group) { + var ops = group.ops; + for (var i = 0; i < ops.length; i++) // Read DOM + { endOperation_R1(ops[i]); } + for (var i$1 = 0; i$1 < ops.length; i$1++) // Write DOM (maybe) + { endOperation_W1(ops[i$1]); } + for (var i$2 = 0; i$2 < ops.length; i$2++) // Read DOM + { endOperation_R2(ops[i$2]); } + for (var i$3 = 0; i$3 < ops.length; i$3++) // Write DOM (maybe) + { endOperation_W2(ops[i$3]); } + for (var i$4 = 0; i$4 < ops.length; i$4++) // Read DOM + { endOperation_finish(ops[i$4]); } + } + + function endOperation_R1(op) { + var cm = op.cm, display = cm.display; + maybeClipScrollbars(cm); + if (op.updateMaxLine) { findMaxLine(cm); } + + op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null || + op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom || + op.scrollToPos.to.line >= display.viewTo) || + display.maxLineChanged && cm.options.lineWrapping; + op.update = op.mustUpdate && + new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate); + } + + function endOperation_W1(op) { + op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update); + } + + function endOperation_R2(op) { + var cm = op.cm, display = cm.display; + if (op.updatedDisplay) { updateHeightsInViewport(cm); } + + op.barMeasure = measureForScrollbars(cm); + + // If the max line changed since it was last measured, measure it, + // and ensure the document's width matches it. + // updateDisplay_W2 will use these properties to do the actual resizing + if (display.maxLineChanged && !cm.options.lineWrapping) { + op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3; + cm.display.sizerWidth = op.adjustWidthTo; + op.barMeasure.scrollWidth = + Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth); + op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm)); + } + + if (op.updatedDisplay || op.selectionChanged) + { op.preparedSelection = display.input.prepareSelection(); } + } + + function endOperation_W2(op) { + var cm = op.cm; + + if (op.adjustWidthTo != null) { + cm.display.sizer.style.minWidth = op.adjustWidthTo + "px"; + if (op.maxScrollLeft < cm.doc.scrollLeft) + { setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true); } + cm.display.maxLineChanged = false; + } + + var takeFocus = op.focus && op.focus == activeElt(); + if (op.preparedSelection) + { cm.display.input.showSelection(op.preparedSelection, takeFocus); } + if (op.updatedDisplay || op.startHeight != cm.doc.height) + { updateScrollbars(cm, op.barMeasure); } + if (op.updatedDisplay) + { setDocumentHeight(cm, op.barMeasure); } + + if (op.selectionChanged) { restartBlink(cm); } + + if (cm.state.focused && op.updateInput) + { cm.display.input.reset(op.typing); } + if (takeFocus) { ensureFocus(op.cm); } + } + + function endOperation_finish(op) { + var cm = op.cm, display = cm.display, doc = cm.doc; + + if (op.updatedDisplay) { postUpdateDisplay(cm, op.update); } + + // Abort mouse wheel delta measurement, when scrolling explicitly + if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos)) + { display.wheelStartX = display.wheelStartY = null; } + + // Propagate the scroll position to the actual DOM scroller + if (op.scrollTop != null) { setScrollTop(cm, op.scrollTop, op.forceScroll); } + + if (op.scrollLeft != null) { setScrollLeft(cm, op.scrollLeft, true, true); } + // If we need to scroll a specific position into view, do so. + if (op.scrollToPos) { + var rect = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from), + clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin); + maybeScrollWindow(cm, rect); + } + + // Fire events for markers that are hidden/unidden by editing or + // undoing + var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers; + if (hidden) { for (var i = 0; i < hidden.length; ++i) + { if (!hidden[i].lines.length) { signal(hidden[i], "hide"); } } } + if (unhidden) { for (var i$1 = 0; i$1 < unhidden.length; ++i$1) + { if (unhidden[i$1].lines.length) { signal(unhidden[i$1], "unhide"); } } } + + if (display.wrapper.offsetHeight) + { doc.scrollTop = cm.display.scroller.scrollTop; } + + // Fire change events, and delayed event handlers + if (op.changeObjs) + { signal(cm, "changes", cm, op.changeObjs); } + if (op.update) + { op.update.finish(); } + } + + // Run the given function in an operation + function runInOp(cm, f) { + if (cm.curOp) { return f() } + startOperation(cm); + try { return f() } + finally { endOperation(cm); } + } + // Wraps a function in an operation. Returns the wrapped function. + function operation(cm, f) { + return function() { + if (cm.curOp) { return f.apply(cm, arguments) } + startOperation(cm); + try { return f.apply(cm, arguments) } + finally { endOperation(cm); } + } + } + // Used to add methods to editor and doc instances, wrapping them in + // operations. + function methodOp(f) { + return function() { + if (this.curOp) { return f.apply(this, arguments) } + startOperation(this); + try { return f.apply(this, arguments) } + finally { endOperation(this); } + } + } + function docMethodOp(f) { + return function() { + var cm = this.cm; + if (!cm || cm.curOp) { return f.apply(this, arguments) } + startOperation(cm); + try { return f.apply(this, arguments) } + finally { endOperation(cm); } + } + } + + // HIGHLIGHT WORKER + + function startWorker(cm, time) { + if (cm.doc.highlightFrontier < cm.display.viewTo) + { cm.state.highlight.set(time, bind(highlightWorker, cm)); } + } + + function highlightWorker(cm) { + var doc = cm.doc; + if (doc.highlightFrontier >= cm.display.viewTo) { return } + var end = +new Date + cm.options.workTime; + var context = getContextBefore(cm, doc.highlightFrontier); + var changedLines = []; + + doc.iter(context.line, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) { + if (context.line >= cm.display.viewFrom) { // Visible + var oldStyles = line.styles; + var resetState = line.text.length > cm.options.maxHighlightLength ? copyState(doc.mode, context.state) : null; + var highlighted = highlightLine(cm, line, context, true); + if (resetState) { context.state = resetState; } + line.styles = highlighted.styles; + var oldCls = line.styleClasses, newCls = highlighted.classes; + if (newCls) { line.styleClasses = newCls; } + else if (oldCls) { line.styleClasses = null; } + var ischange = !oldStyles || oldStyles.length != line.styles.length || + oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass); + for (var i = 0; !ischange && i < oldStyles.length; ++i) { ischange = oldStyles[i] != line.styles[i]; } + if (ischange) { changedLines.push(context.line); } + line.stateAfter = context.save(); + context.nextLine(); + } else { + if (line.text.length <= cm.options.maxHighlightLength) + { processLine(cm, line.text, context); } + line.stateAfter = context.line % 5 == 0 ? context.save() : null; + context.nextLine(); + } + if (+new Date > end) { + startWorker(cm, cm.options.workDelay); + return true + } + }); + doc.highlightFrontier = context.line; + doc.modeFrontier = Math.max(doc.modeFrontier, context.line); + if (changedLines.length) { runInOp(cm, function () { + for (var i = 0; i < changedLines.length; i++) + { regLineChange(cm, changedLines[i], "text"); } + }); } + } + + // DISPLAY DRAWING + + var DisplayUpdate = function(cm, viewport, force) { + var display = cm.display; + + this.viewport = viewport; + // Store some values that we'll need later (but don't want to force a relayout for) + this.visible = visibleLines(display, cm.doc, viewport); + this.editorIsHidden = !display.wrapper.offsetWidth; + this.wrapperHeight = display.wrapper.clientHeight; + this.wrapperWidth = display.wrapper.clientWidth; + this.oldDisplayWidth = displayWidth(cm); + this.force = force; + this.dims = getDimensions(cm); + this.events = []; + }; + + DisplayUpdate.prototype.signal = function (emitter, type) { + if (hasHandler(emitter, type)) + { this.events.push(arguments); } + }; + DisplayUpdate.prototype.finish = function () { + for (var i = 0; i < this.events.length; i++) + { signal.apply(null, this.events[i]); } + }; + + function maybeClipScrollbars(cm) { + var display = cm.display; + if (!display.scrollbarsClipped && display.scroller.offsetWidth) { + display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth; + display.heightForcer.style.height = scrollGap(cm) + "px"; + display.sizer.style.marginBottom = -display.nativeBarWidth + "px"; + display.sizer.style.borderRightWidth = scrollGap(cm) + "px"; + display.scrollbarsClipped = true; + } + } + + function selectionSnapshot(cm) { + if (cm.hasFocus()) { return null } + var active = activeElt(); + if (!active || !contains(cm.display.lineDiv, active)) { return null } + var result = {activeElt: active}; + if (window.getSelection) { + var sel = window.getSelection(); + if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) { + result.anchorNode = sel.anchorNode; + result.anchorOffset = sel.anchorOffset; + result.focusNode = sel.focusNode; + result.focusOffset = sel.focusOffset; + } + } + return result + } + + function restoreSelection(snapshot) { + if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return } + snapshot.activeElt.focus(); + if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) && + snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) { + var sel = window.getSelection(), range = document.createRange(); + range.setEnd(snapshot.anchorNode, snapshot.anchorOffset); + range.collapse(false); + sel.removeAllRanges(); + sel.addRange(range); + sel.extend(snapshot.focusNode, snapshot.focusOffset); + } + } + + // Does the actual updating of the line display. Bails out + // (returning false) when there is nothing to be done and forced is + // false. + function updateDisplayIfNeeded(cm, update) { + var display = cm.display, doc = cm.doc; + + if (update.editorIsHidden) { + resetView(cm); + return false + } + + // Bail out if the visible area is already rendered and nothing changed. + if (!update.force && + update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo && + (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) && + display.renderedView == display.view && countDirtyView(cm) == 0) + { return false } + + if (maybeUpdateLineNumberWidth(cm)) { + resetView(cm); + update.dims = getDimensions(cm); + } + + // Compute a suitable new viewport (from & to) + var end = doc.first + doc.size; + var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first); + var to = Math.min(end, update.visible.to + cm.options.viewportMargin); + if (display.viewFrom < from && from - display.viewFrom < 20) { from = Math.max(doc.first, display.viewFrom); } + if (display.viewTo > to && display.viewTo - to < 20) { to = Math.min(end, display.viewTo); } + if (sawCollapsedSpans) { + from = visualLineNo(cm.doc, from); + to = visualLineEndNo(cm.doc, to); + } + + var different = from != display.viewFrom || to != display.viewTo || + display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth; + adjustView(cm, from, to); + + display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom)); + // Position the mover div to align with the current scroll position + cm.display.mover.style.top = display.viewOffset + "px"; + + var toUpdate = countDirtyView(cm); + if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view && + (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo)) + { return false } + + // For big changes, we hide the enclosing element during the + // update, since that speeds up the operations on most browsers. + var selSnapshot = selectionSnapshot(cm); + if (toUpdate > 4) { display.lineDiv.style.display = "none"; } + patchDisplay(cm, display.updateLineNumbers, update.dims); + if (toUpdate > 4) { display.lineDiv.style.display = ""; } + display.renderedView = display.view; + // There might have been a widget with a focused element that got + // hidden or updated, if so re-focus it. + restoreSelection(selSnapshot); + + // Prevent selection and cursors from interfering with the scroll + // width and height. + removeChildren(display.cursorDiv); + removeChildren(display.selectionDiv); + display.gutters.style.height = display.sizer.style.minHeight = 0; + + if (different) { + display.lastWrapHeight = update.wrapperHeight; + display.lastWrapWidth = update.wrapperWidth; + startWorker(cm, 400); + } + + display.updateLineNumbers = null; + + return true + } + + function postUpdateDisplay(cm, update) { + var viewport = update.viewport; + + for (var first = true;; first = false) { + if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) { + // Clip forced viewport to actual scrollable area. + if (viewport && viewport.top != null) + { viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)}; } + // Updated line heights might result in the drawn area not + // actually covering the viewport. Keep looping until it does. + update.visible = visibleLines(cm.display, cm.doc, viewport); + if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo) + { break } + } else if (first) { + update.visible = visibleLines(cm.display, cm.doc, viewport); + } + if (!updateDisplayIfNeeded(cm, update)) { break } + updateHeightsInViewport(cm); + var barMeasure = measureForScrollbars(cm); + updateSelection(cm); + updateScrollbars(cm, barMeasure); + setDocumentHeight(cm, barMeasure); + update.force = false; + } + + update.signal(cm, "update", cm); + if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) { + update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo); + cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo; + } + } + + function updateDisplaySimple(cm, viewport) { + var update = new DisplayUpdate(cm, viewport); + if (updateDisplayIfNeeded(cm, update)) { + updateHeightsInViewport(cm); + postUpdateDisplay(cm, update); + var barMeasure = measureForScrollbars(cm); + updateSelection(cm); + updateScrollbars(cm, barMeasure); + setDocumentHeight(cm, barMeasure); + update.finish(); + } + } + + // Sync the actual display DOM structure with display.view, removing + // nodes for lines that are no longer in view, and creating the ones + // that are not there yet, and updating the ones that are out of + // date. + function patchDisplay(cm, updateNumbersFrom, dims) { + var display = cm.display, lineNumbers = cm.options.lineNumbers; + var container = display.lineDiv, cur = container.firstChild; + + function rm(node) { + var next = node.nextSibling; + // Works around a throw-scroll bug in OS X Webkit + if (webkit && mac && cm.display.currentWheelTarget == node) + { node.style.display = "none"; } + else + { node.parentNode.removeChild(node); } + return next + } + + var view = display.view, lineN = display.viewFrom; + // Loop over the elements in the view, syncing cur (the DOM nodes + // in display.lineDiv) with the view as we go. + for (var i = 0; i < view.length; i++) { + var lineView = view[i]; + if (lineView.hidden) ; else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet + var node = buildLineElement(cm, lineView, lineN, dims); + container.insertBefore(node, cur); + } else { // Already drawn + while (cur != lineView.node) { cur = rm(cur); } + var updateNumber = lineNumbers && updateNumbersFrom != null && + updateNumbersFrom <= lineN && lineView.lineNumber; + if (lineView.changes) { + if (indexOf(lineView.changes, "gutter") > -1) { updateNumber = false; } + updateLineForChanges(cm, lineView, lineN, dims); + } + if (updateNumber) { + removeChildren(lineView.lineNumber); + lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN))); + } + cur = lineView.node.nextSibling; + } + lineN += lineView.size; + } + while (cur) { cur = rm(cur); } + } + + function updateGutterSpace(display) { + var width = display.gutters.offsetWidth; + display.sizer.style.marginLeft = width + "px"; + } + + function setDocumentHeight(cm, measure) { + cm.display.sizer.style.minHeight = measure.docHeight + "px"; + cm.display.heightForcer.style.top = measure.docHeight + "px"; + cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px"; + } + + // Re-align line numbers and gutter marks to compensate for + // horizontal scrolling. + function alignHorizontally(cm) { + var display = cm.display, view = display.view; + if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) { return } + var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft; + var gutterW = display.gutters.offsetWidth, left = comp + "px"; + for (var i = 0; i < view.length; i++) { if (!view[i].hidden) { + if (cm.options.fixedGutter) { + if (view[i].gutter) + { view[i].gutter.style.left = left; } + if (view[i].gutterBackground) + { view[i].gutterBackground.style.left = left; } + } + var align = view[i].alignable; + if (align) { for (var j = 0; j < align.length; j++) + { align[j].style.left = left; } } + } } + if (cm.options.fixedGutter) + { display.gutters.style.left = (comp + gutterW) + "px"; } + } + + // Used to ensure that the line number gutter is still the right + // size for the current document size. Returns true when an update + // is needed. + function maybeUpdateLineNumberWidth(cm) { + if (!cm.options.lineNumbers) { return false } + var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display; + if (last.length != display.lineNumChars) { + var test = display.measure.appendChild(elt("div", [elt("div", last)], + "CodeMirror-linenumber CodeMirror-gutter-elt")); + var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW; + display.lineGutter.style.width = ""; + display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1; + display.lineNumWidth = display.lineNumInnerWidth + padding; + display.lineNumChars = display.lineNumInnerWidth ? last.length : -1; + display.lineGutter.style.width = display.lineNumWidth + "px"; + updateGutterSpace(cm.display); + return true + } + return false + } + + function getGutters(gutters, lineNumbers) { + var result = [], sawLineNumbers = false; + for (var i = 0; i < gutters.length; i++) { + var name = gutters[i], style = null; + if (typeof name != "string") { style = name.style; name = name.className; } + if (name == "CodeMirror-linenumbers") { + if (!lineNumbers) { continue } + else { sawLineNumbers = true; } + } + result.push({className: name, style: style}); + } + if (lineNumbers && !sawLineNumbers) { result.push({className: "CodeMirror-linenumbers", style: null}); } + return result + } + + // Rebuild the gutter elements, ensure the margin to the left of the + // code matches their width. + function renderGutters(display) { + var gutters = display.gutters, specs = display.gutterSpecs; + removeChildren(gutters); + display.lineGutter = null; + for (var i = 0; i < specs.length; ++i) { + var ref = specs[i]; + var className = ref.className; + var style = ref.style; + var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + className)); + if (style) { gElt.style.cssText = style; } + if (className == "CodeMirror-linenumbers") { + display.lineGutter = gElt; + gElt.style.width = (display.lineNumWidth || 1) + "px"; + } + } + gutters.style.display = specs.length ? "" : "none"; + updateGutterSpace(display); + } + + function updateGutters(cm) { + renderGutters(cm.display); + regChange(cm); + alignHorizontally(cm); + } + + // The display handles the DOM integration, both for input reading + // and content drawing. It holds references to DOM nodes and + // display-related state. + + function Display(place, doc, input, options) { + var d = this; + this.input = input; + + // Covers bottom-right square when both scrollbars are present. + d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler"); + d.scrollbarFiller.setAttribute("cm-not-content", "true"); + // Covers bottom of gutter when coverGutterNextToScrollbar is on + // and h scrollbar is present. + d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler"); + d.gutterFiller.setAttribute("cm-not-content", "true"); + // Will contain the actual code, positioned to cover the viewport. + d.lineDiv = eltP("div", null, "CodeMirror-code"); + // Elements are added to these to represent selection and cursors. + d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1"); + d.cursorDiv = elt("div", null, "CodeMirror-cursors"); + // A visibility: hidden element used to find the size of things. + d.measure = elt("div", null, "CodeMirror-measure"); + // When lines outside of the viewport are measured, they are drawn in this. + d.lineMeasure = elt("div", null, "CodeMirror-measure"); + // Wraps everything that needs to exist inside the vertically-padded coordinate system + d.lineSpace = eltP("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv], + null, "position: relative; outline: none"); + var lines = eltP("div", [d.lineSpace], "CodeMirror-lines"); + // Moved around its parent to cover visible view. + d.mover = elt("div", [lines], null, "position: relative"); + // Set to the height of the document, allowing scrolling. + d.sizer = elt("div", [d.mover], "CodeMirror-sizer"); + d.sizerWidth = null; + // Behavior of elts with overflow: auto and padding is + // inconsistent across browsers. This is used to ensure the + // scrollable area is big enough. + d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;"); + // Will contain the gutters, if any. + d.gutters = elt("div", null, "CodeMirror-gutters"); + d.lineGutter = null; + // Actual scrollable element. + d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll"); + d.scroller.setAttribute("tabIndex", "-1"); + // The element in which the editor lives. + d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror"); + + // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported) + if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; } + if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true; } + + if (place) { + if (place.appendChild) { place.appendChild(d.wrapper); } + else { place(d.wrapper); } + } + + // Current rendered range (may be bigger than the view window). + d.viewFrom = d.viewTo = doc.first; + d.reportedViewFrom = d.reportedViewTo = doc.first; + // Information about the rendered lines. + d.view = []; + d.renderedView = null; + // Holds info about a single rendered line when it was rendered + // for measurement, while not in view. + d.externalMeasured = null; + // Empty space (in pixels) above the view + d.viewOffset = 0; + d.lastWrapHeight = d.lastWrapWidth = 0; + d.updateLineNumbers = null; + + d.nativeBarWidth = d.barHeight = d.barWidth = 0; + d.scrollbarsClipped = false; + + // Used to only resize the line number gutter when necessary (when + // the amount of lines crosses a boundary that makes its width change) + d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null; + // Set to true when a non-horizontal-scrolling line widget is + // added. As an optimization, line widget aligning is skipped when + // this is false. + d.alignWidgets = false; + + d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; + + // Tracks the maximum line length so that the horizontal scrollbar + // can be kept static when scrolling. + d.maxLine = null; + d.maxLineLength = 0; + d.maxLineChanged = false; + + // Used for measuring wheel scrolling granularity + d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null; + + // True when shift is held down. + d.shift = false; + + // Used to track whether anything happened since the context menu + // was opened. + d.selForContextMenu = null; + + d.activeTouch = null; + + d.gutterSpecs = getGutters(options.gutters, options.lineNumbers); + renderGutters(d); + + input.init(d); + } + + // Since the delta values reported on mouse wheel events are + // unstandardized between browsers and even browser versions, and + // generally horribly unpredictable, this code starts by measuring + // the scroll effect that the first few mouse wheel events have, + // and, from that, detects the way it can convert deltas to pixel + // offsets afterwards. + // + // The reason we want to know the amount a wheel event will scroll + // is that it gives us a chance to update the display before the + // actual scrolling happens, reducing flickering. + + var wheelSamples = 0, wheelPixelsPerUnit = null; + // Fill in a browser-detected starting value on browsers where we + // know one. These don't have to be accurate -- the result of them + // being wrong would just be a slight flicker on the first wheel + // scroll (if it is large enough). + if (ie) { wheelPixelsPerUnit = -.53; } + else if (gecko) { wheelPixelsPerUnit = 15; } + else if (chrome) { wheelPixelsPerUnit = -.7; } + else if (safari) { wheelPixelsPerUnit = -1/3; } + + function wheelEventDelta(e) { + var dx = e.wheelDeltaX, dy = e.wheelDeltaY; + if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) { dx = e.detail; } + if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) { dy = e.detail; } + else if (dy == null) { dy = e.wheelDelta; } + return {x: dx, y: dy} + } + function wheelEventPixels(e) { + var delta = wheelEventDelta(e); + delta.x *= wheelPixelsPerUnit; + delta.y *= wheelPixelsPerUnit; + return delta + } + + function onScrollWheel(cm, e) { + var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y; + + var display = cm.display, scroll = display.scroller; + // Quit if there's nothing to scroll here + var canScrollX = scroll.scrollWidth > scroll.clientWidth; + var canScrollY = scroll.scrollHeight > scroll.clientHeight; + if (!(dx && canScrollX || dy && canScrollY)) { return } + + // Webkit browsers on OS X abort momentum scrolls when the target + // of the scroll event is removed from the scrollable element. + // This hack (see related code in patchDisplay) makes sure the + // element is kept around. + if (dy && mac && webkit) { + outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) { + for (var i = 0; i < view.length; i++) { + if (view[i].node == cur) { + cm.display.currentWheelTarget = cur; + break outer + } + } + } + } + + // On some browsers, horizontal scrolling will cause redraws to + // happen before the gutter has been realigned, causing it to + // wriggle around in a most unseemly way. When we have an + // estimated pixels/delta value, we just handle horizontal + // scrolling entirely here. It'll be slightly off from native, but + // better than glitching out. + if (dx && !gecko && !presto && wheelPixelsPerUnit != null) { + if (dy && canScrollY) + { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * wheelPixelsPerUnit)); } + setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * wheelPixelsPerUnit)); + // Only prevent default scrolling if vertical scrolling is + // actually possible. Otherwise, it causes vertical scroll + // jitter on OSX trackpads when deltaX is small and deltaY + // is large (issue #3579) + if (!dy || (dy && canScrollY)) + { e_preventDefault(e); } + display.wheelStartX = null; // Abort measurement, if in progress + return + } + + // 'Project' the visible viewport to cover the area that is being + // scrolled into view (if we know enough to estimate it). + if (dy && wheelPixelsPerUnit != null) { + var pixels = dy * wheelPixelsPerUnit; + var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight; + if (pixels < 0) { top = Math.max(0, top + pixels - 50); } + else { bot = Math.min(cm.doc.height, bot + pixels + 50); } + updateDisplaySimple(cm, {top: top, bottom: bot}); + } + + if (wheelSamples < 20) { + if (display.wheelStartX == null) { + display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop; + display.wheelDX = dx; display.wheelDY = dy; + setTimeout(function () { + if (display.wheelStartX == null) { return } + var movedX = scroll.scrollLeft - display.wheelStartX; + var movedY = scroll.scrollTop - display.wheelStartY; + var sample = (movedY && display.wheelDY && movedY / display.wheelDY) || + (movedX && display.wheelDX && movedX / display.wheelDX); + display.wheelStartX = display.wheelStartY = null; + if (!sample) { return } + wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1); + ++wheelSamples; + }, 200); + } else { + display.wheelDX += dx; display.wheelDY += dy; + } + } + } + + // Selection objects are immutable. A new one is created every time + // the selection changes. A selection is one or more non-overlapping + // (and non-touching) ranges, sorted, and an integer that indicates + // which one is the primary selection (the one that's scrolled into + // view, that getCursor returns, etc). + var Selection = function(ranges, primIndex) { + this.ranges = ranges; + this.primIndex = primIndex; + }; + + Selection.prototype.primary = function () { return this.ranges[this.primIndex] }; + + Selection.prototype.equals = function (other) { + if (other == this) { return true } + if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false } + for (var i = 0; i < this.ranges.length; i++) { + var here = this.ranges[i], there = other.ranges[i]; + if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) { return false } + } + return true + }; + + Selection.prototype.deepCopy = function () { + var out = []; + for (var i = 0; i < this.ranges.length; i++) + { out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head)); } + return new Selection(out, this.primIndex) + }; + + Selection.prototype.somethingSelected = function () { + for (var i = 0; i < this.ranges.length; i++) + { if (!this.ranges[i].empty()) { return true } } + return false + }; + + Selection.prototype.contains = function (pos, end) { + if (!end) { end = pos; } + for (var i = 0; i < this.ranges.length; i++) { + var range = this.ranges[i]; + if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0) + { return i } + } + return -1 + }; + + var Range = function(anchor, head) { + this.anchor = anchor; this.head = head; + }; + + Range.prototype.from = function () { return minPos(this.anchor, this.head) }; + Range.prototype.to = function () { return maxPos(this.anchor, this.head) }; + Range.prototype.empty = function () { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch }; + + // Take an unsorted, potentially overlapping set of ranges, and + // build a selection out of it. 'Consumes' ranges array (modifying + // it). + function normalizeSelection(cm, ranges, primIndex) { + var mayTouch = cm && cm.options.selectionsMayTouch; + var prim = ranges[primIndex]; + ranges.sort(function (a, b) { return cmp(a.from(), b.from()); }); + primIndex = indexOf(ranges, prim); + for (var i = 1; i < ranges.length; i++) { + var cur = ranges[i], prev = ranges[i - 1]; + var diff = cmp(prev.to(), cur.from()); + if (mayTouch && !cur.empty() ? diff > 0 : diff >= 0) { + var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to()); + var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head; + if (i <= primIndex) { --primIndex; } + ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to)); + } + } + return new Selection(ranges, primIndex) + } + + function simpleSelection(anchor, head) { + return new Selection([new Range(anchor, head || anchor)], 0) + } + + // Compute the position of the end of a change (its 'to' property + // refers to the pre-change end). + function changeEnd(change) { + if (!change.text) { return change.to } + return Pos(change.from.line + change.text.length - 1, + lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0)) + } + + // Adjust a position to refer to the post-change position of the + // same text, or the end of the change if the change covers it. + function adjustForChange(pos, change) { + if (cmp(pos, change.from) < 0) { return pos } + if (cmp(pos, change.to) <= 0) { return changeEnd(change) } + + var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch; + if (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch; } + return Pos(line, ch) + } + + function computeSelAfterChange(doc, change) { + var out = []; + for (var i = 0; i < doc.sel.ranges.length; i++) { + var range = doc.sel.ranges[i]; + out.push(new Range(adjustForChange(range.anchor, change), + adjustForChange(range.head, change))); + } + return normalizeSelection(doc.cm, out, doc.sel.primIndex) + } + + function offsetPos(pos, old, nw) { + if (pos.line == old.line) + { return Pos(nw.line, pos.ch - old.ch + nw.ch) } + else + { return Pos(nw.line + (pos.line - old.line), pos.ch) } + } + + // Used by replaceSelections to allow moving the selection to the + // start or around the replaced test. Hint may be "start" or "around". + function computeReplacedSel(doc, changes, hint) { + var out = []; + var oldPrev = Pos(doc.first, 0), newPrev = oldPrev; + for (var i = 0; i < changes.length; i++) { + var change = changes[i]; + var from = offsetPos(change.from, oldPrev, newPrev); + var to = offsetPos(changeEnd(change), oldPrev, newPrev); + oldPrev = change.to; + newPrev = to; + if (hint == "around") { + var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0; + out[i] = new Range(inv ? to : from, inv ? from : to); + } else { + out[i] = new Range(from, from); + } + } + return new Selection(out, doc.sel.primIndex) + } + + // Used to get the editor into a consistent state again when options change. + + function loadMode(cm) { + cm.doc.mode = getMode(cm.options, cm.doc.modeOption); + resetModeState(cm); + } + + function resetModeState(cm) { + cm.doc.iter(function (line) { + if (line.stateAfter) { line.stateAfter = null; } + if (line.styles) { line.styles = null; } + }); + cm.doc.modeFrontier = cm.doc.highlightFrontier = cm.doc.first; + startWorker(cm, 100); + cm.state.modeGen++; + if (cm.curOp) { regChange(cm); } + } + + // DOCUMENT DATA STRUCTURE + + // By default, updates that start and end at the beginning of a line + // are treated specially, in order to make the association of line + // widgets and marker elements with the text behave more intuitive. + function isWholeLineUpdate(doc, change) { + return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" && + (!doc.cm || doc.cm.options.wholeLineUpdateBefore) + } + + // Perform a change on the document data structure. + function updateDoc(doc, change, markedSpans, estimateHeight) { + function spansFor(n) {return markedSpans ? markedSpans[n] : null} + function update(line, text, spans) { + updateLine(line, text, spans, estimateHeight); + signalLater(line, "change", line, change); + } + function linesFor(start, end) { + var result = []; + for (var i = start; i < end; ++i) + { result.push(new Line(text[i], spansFor(i), estimateHeight)); } + return result + } + + var from = change.from, to = change.to, text = change.text; + var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line); + var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line; + + // Adjust the line structure + if (change.full) { + doc.insert(0, linesFor(0, text.length)); + doc.remove(text.length, doc.size - text.length); + } else if (isWholeLineUpdate(doc, change)) { + // This is a whole-line replace. Treated specially to make + // sure line objects move the way they are supposed to. + var added = linesFor(0, text.length - 1); + update(lastLine, lastLine.text, lastSpans); + if (nlines) { doc.remove(from.line, nlines); } + if (added.length) { doc.insert(from.line, added); } + } else if (firstLine == lastLine) { + if (text.length == 1) { + update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans); + } else { + var added$1 = linesFor(1, text.length - 1); + added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight)); + update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); + doc.insert(from.line + 1, added$1); + } + } else if (text.length == 1) { + update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0)); + doc.remove(from.line + 1, nlines); + } else { + update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); + update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans); + var added$2 = linesFor(1, text.length - 1); + if (nlines > 1) { doc.remove(from.line + 1, nlines - 1); } + doc.insert(from.line + 1, added$2); + } + + signalLater(doc, "change", doc, change); + } + + // Call f for all linked documents. + function linkedDocs(doc, f, sharedHistOnly) { + function propagate(doc, skip, sharedHist) { + if (doc.linked) { for (var i = 0; i < doc.linked.length; ++i) { + var rel = doc.linked[i]; + if (rel.doc == skip) { continue } + var shared = sharedHist && rel.sharedHist; + if (sharedHistOnly && !shared) { continue } + f(rel.doc, shared); + propagate(rel.doc, doc, shared); + } } + } + propagate(doc, null, true); + } + + // Attach a document to an editor. + function attachDoc(cm, doc) { + if (doc.cm) { throw new Error("This document is already in use.") } + cm.doc = doc; + doc.cm = cm; + estimateLineHeights(cm); + loadMode(cm); + setDirectionClass(cm); + if (!cm.options.lineWrapping) { findMaxLine(cm); } + cm.options.mode = doc.modeOption; + regChange(cm); + } + + function setDirectionClass(cm) { + (cm.doc.direction == "rtl" ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl"); + } + + function directionChanged(cm) { + runInOp(cm, function () { + setDirectionClass(cm); + regChange(cm); + }); + } + + function History(prev) { + // Arrays of change events and selections. Doing something adds an + // event to done and clears undo. Undoing moves events from done + // to undone, redoing moves them in the other direction. + this.done = []; this.undone = []; + this.undoDepth = prev ? prev.undoDepth : Infinity; + // Used to track when changes can be merged into a single undo + // event + this.lastModTime = this.lastSelTime = 0; + this.lastOp = this.lastSelOp = null; + this.lastOrigin = this.lastSelOrigin = null; + // Used by the isClean() method + this.generation = this.maxGeneration = prev ? prev.maxGeneration : 1; + } + + // Create a history change event from an updateDoc-style change + // object. + function historyChangeFromChange(doc, change) { + var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)}; + attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); + linkedDocs(doc, function (doc) { return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); }, true); + return histChange + } + + // Pop all selection events off the end of a history array. Stop at + // a change event. + function clearSelectionEvents(array) { + while (array.length) { + var last = lst(array); + if (last.ranges) { array.pop(); } + else { break } + } + } + + // Find the top change event in the history. Pop off selection + // events that are in the way. + function lastChangeEvent(hist, force) { + if (force) { + clearSelectionEvents(hist.done); + return lst(hist.done) + } else if (hist.done.length && !lst(hist.done).ranges) { + return lst(hist.done) + } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) { + hist.done.pop(); + return lst(hist.done) + } + } + + // Register a change in the history. Merges changes that are within + // a single operation, or are close together with an origin that + // allows merging (starting with "+") into a single event. + function addChangeToHistory(doc, change, selAfter, opId) { + var hist = doc.history; + hist.undone.length = 0; + var time = +new Date, cur; + var last; + + if ((hist.lastOp == opId || + hist.lastOrigin == change.origin && change.origin && + ((change.origin.charAt(0) == "+" && hist.lastModTime > time - (doc.cm ? doc.cm.options.historyEventDelay : 500)) || + change.origin.charAt(0) == "*")) && + (cur = lastChangeEvent(hist, hist.lastOp == opId))) { + // Merge this change into the last event + last = lst(cur.changes); + if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) { + // Optimized case for simple insertion -- don't want to add + // new changesets for every character typed + last.to = changeEnd(change); + } else { + // Add new sub-event + cur.changes.push(historyChangeFromChange(doc, change)); + } + } else { + // Can not be merged, start a new event. + var before = lst(hist.done); + if (!before || !before.ranges) + { pushSelectionToHistory(doc.sel, hist.done); } + cur = {changes: [historyChangeFromChange(doc, change)], + generation: hist.generation}; + hist.done.push(cur); + while (hist.done.length > hist.undoDepth) { + hist.done.shift(); + if (!hist.done[0].ranges) { hist.done.shift(); } + } + } + hist.done.push(selAfter); + hist.generation = ++hist.maxGeneration; + hist.lastModTime = hist.lastSelTime = time; + hist.lastOp = hist.lastSelOp = opId; + hist.lastOrigin = hist.lastSelOrigin = change.origin; + + if (!last) { signal(doc, "historyAdded"); } + } + + function selectionEventCanBeMerged(doc, origin, prev, sel) { + var ch = origin.charAt(0); + return ch == "*" || + ch == "+" && + prev.ranges.length == sel.ranges.length && + prev.somethingSelected() == sel.somethingSelected() && + new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500) + } + + // Called whenever the selection changes, sets the new selection as + // the pending selection in the history, and pushes the old pending + // selection into the 'done' array when it was significantly + // different (in number of selected ranges, emptiness, or time). + function addSelectionToHistory(doc, sel, opId, options) { + var hist = doc.history, origin = options && options.origin; + + // A new event is started when the previous origin does not match + // the current, or the origins don't allow matching. Origins + // starting with * are always merged, those starting with + are + // merged when similar and close together in time. + if (opId == hist.lastSelOp || + (origin && hist.lastSelOrigin == origin && + (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || + selectionEventCanBeMerged(doc, origin, lst(hist.done), sel)))) + { hist.done[hist.done.length - 1] = sel; } + else + { pushSelectionToHistory(sel, hist.done); } + + hist.lastSelTime = +new Date; + hist.lastSelOrigin = origin; + hist.lastSelOp = opId; + if (options && options.clearRedo !== false) + { clearSelectionEvents(hist.undone); } + } + + function pushSelectionToHistory(sel, dest) { + var top = lst(dest); + if (!(top && top.ranges && top.equals(sel))) + { dest.push(sel); } + } + + // Used to store marked span information in the history. + function attachLocalSpans(doc, change, from, to) { + var existing = change["spans_" + doc.id], n = 0; + doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) { + if (line.markedSpans) + { (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans; } + ++n; + }); + } + + // When un/re-doing restores text containing marked spans, those + // that have been explicitly cleared should not be restored. + function removeClearedSpans(spans) { + if (!spans) { return null } + var out; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].marker.explicitlyCleared) { if (!out) { out = spans.slice(0, i); } } + else if (out) { out.push(spans[i]); } + } + return !out ? spans : out.length ? out : null + } + + // Retrieve and filter the old marked spans stored in a change event. + function getOldSpans(doc, change) { + var found = change["spans_" + doc.id]; + if (!found) { return null } + var nw = []; + for (var i = 0; i < change.text.length; ++i) + { nw.push(removeClearedSpans(found[i])); } + return nw + } + + // Used for un/re-doing changes from the history. Combines the + // result of computing the existing spans with the set of spans that + // existed in the history (so that deleting around a span and then + // undoing brings back the span). + function mergeOldSpans(doc, change) { + var old = getOldSpans(doc, change); + var stretched = stretchSpansOverChange(doc, change); + if (!old) { return stretched } + if (!stretched) { return old } + + for (var i = 0; i < old.length; ++i) { + var oldCur = old[i], stretchCur = stretched[i]; + if (oldCur && stretchCur) { + spans: for (var j = 0; j < stretchCur.length; ++j) { + var span = stretchCur[j]; + for (var k = 0; k < oldCur.length; ++k) + { if (oldCur[k].marker == span.marker) { continue spans } } + oldCur.push(span); + } + } else if (stretchCur) { + old[i] = stretchCur; + } + } + return old + } + + // Used both to provide a JSON-safe object in .getHistory, and, when + // detaching a document, to split the history in two + function copyHistoryArray(events, newGroup, instantiateSel) { + var copy = []; + for (var i = 0; i < events.length; ++i) { + var event = events[i]; + if (event.ranges) { + copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event); + continue + } + var changes = event.changes, newChanges = []; + copy.push({changes: newChanges}); + for (var j = 0; j < changes.length; ++j) { + var change = changes[j], m = (void 0); + newChanges.push({from: change.from, to: change.to, text: change.text}); + if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\d+)$/)) { + if (indexOf(newGroup, Number(m[1])) > -1) { + lst(newChanges)[prop] = change[prop]; + delete change[prop]; + } + } } } + } + } + return copy + } + + // The 'scroll' parameter given to many of these indicated whether + // the new cursor position should be scrolled into view after + // modifying the selection. + + // If shift is held or the extend flag is set, extends a range to + // include a given position (and optionally a second position). + // Otherwise, simply returns the range between the given positions. + // Used for cursor motion and such. + function extendRange(range, head, other, extend) { + if (extend) { + var anchor = range.anchor; + if (other) { + var posBefore = cmp(head, anchor) < 0; + if (posBefore != (cmp(other, anchor) < 0)) { + anchor = head; + head = other; + } else if (posBefore != (cmp(head, other) < 0)) { + head = other; + } + } + return new Range(anchor, head) + } else { + return new Range(other || head, head) + } + } + + // Extend the primary selection range, discard the rest. + function extendSelection(doc, head, other, options, extend) { + if (extend == null) { extend = doc.cm && (doc.cm.display.shift || doc.extend); } + setSelection(doc, new Selection([extendRange(doc.sel.primary(), head, other, extend)], 0), options); + } + + // Extend all selections (pos is an array of selections with length + // equal the number of selections) + function extendSelections(doc, heads, options) { + var out = []; + var extend = doc.cm && (doc.cm.display.shift || doc.extend); + for (var i = 0; i < doc.sel.ranges.length; i++) + { out[i] = extendRange(doc.sel.ranges[i], heads[i], null, extend); } + var newSel = normalizeSelection(doc.cm, out, doc.sel.primIndex); + setSelection(doc, newSel, options); + } + + // Updates a single range in the selection. + function replaceOneSelection(doc, i, range, options) { + var ranges = doc.sel.ranges.slice(0); + ranges[i] = range; + setSelection(doc, normalizeSelection(doc.cm, ranges, doc.sel.primIndex), options); + } + + // Reset the selection to a single range. + function setSimpleSelection(doc, anchor, head, options) { + setSelection(doc, simpleSelection(anchor, head), options); + } + + // Give beforeSelectionChange handlers a change to influence a + // selection update. + function filterSelectionChange(doc, sel, options) { + var obj = { + ranges: sel.ranges, + update: function(ranges) { + this.ranges = []; + for (var i = 0; i < ranges.length; i++) + { this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor), + clipPos(doc, ranges[i].head)); } + }, + origin: options && options.origin + }; + signal(doc, "beforeSelectionChange", doc, obj); + if (doc.cm) { signal(doc.cm, "beforeSelectionChange", doc.cm, obj); } + if (obj.ranges != sel.ranges) { return normalizeSelection(doc.cm, obj.ranges, obj.ranges.length - 1) } + else { return sel } + } + + function setSelectionReplaceHistory(doc, sel, options) { + var done = doc.history.done, last = lst(done); + if (last && last.ranges) { + done[done.length - 1] = sel; + setSelectionNoUndo(doc, sel, options); + } else { + setSelection(doc, sel, options); + } + } + + // Set a new selection. + function setSelection(doc, sel, options) { + setSelectionNoUndo(doc, sel, options); + addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options); + } + + function setSelectionNoUndo(doc, sel, options) { + if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) + { sel = filterSelectionChange(doc, sel, options); } + + var bias = options && options.bias || + (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1); + setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true)); + + if (!(options && options.scroll === false) && doc.cm && doc.cm.getOption("readOnly") != "nocursor") + { ensureCursorVisible(doc.cm); } + } + + function setSelectionInner(doc, sel) { + if (sel.equals(doc.sel)) { return } + + doc.sel = sel; + + if (doc.cm) { + doc.cm.curOp.updateInput = 1; + doc.cm.curOp.selectionChanged = true; + signalCursorActivity(doc.cm); + } + signalLater(doc, "cursorActivity", doc); + } + + // Verify that the selection does not partially select any atomic + // marked ranges. + function reCheckSelection(doc) { + setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false)); + } + + // Return a selection that does not partially select any atomic + // ranges. + function skipAtomicInSelection(doc, sel, bias, mayClear) { + var out; + for (var i = 0; i < sel.ranges.length; i++) { + var range = sel.ranges[i]; + var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i]; + var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear); + var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear); + if (out || newAnchor != range.anchor || newHead != range.head) { + if (!out) { out = sel.ranges.slice(0, i); } + out[i] = new Range(newAnchor, newHead); + } + } + return out ? normalizeSelection(doc.cm, out, sel.primIndex) : sel + } + + function skipAtomicInner(doc, pos, oldPos, dir, mayClear) { + var line = getLine(doc, pos.line); + if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) { + var sp = line.markedSpans[i], m = sp.marker; + + // Determine if we should prevent the cursor being placed to the left/right of an atomic marker + // Historically this was determined using the inclusiveLeft/Right option, but the new way to control it + // is with selectLeft/Right + var preventCursorLeft = ("selectLeft" in m) ? !m.selectLeft : m.inclusiveLeft; + var preventCursorRight = ("selectRight" in m) ? !m.selectRight : m.inclusiveRight; + + if ((sp.from == null || (preventCursorLeft ? sp.from <= pos.ch : sp.from < pos.ch)) && + (sp.to == null || (preventCursorRight ? sp.to >= pos.ch : sp.to > pos.ch))) { + if (mayClear) { + signal(m, "beforeCursorEnter"); + if (m.explicitlyCleared) { + if (!line.markedSpans) { break } + else {--i; continue} + } + } + if (!m.atomic) { continue } + + if (oldPos) { + var near = m.find(dir < 0 ? 1 : -1), diff = (void 0); + if (dir < 0 ? preventCursorRight : preventCursorLeft) + { near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null); } + if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0)) + { return skipAtomicInner(doc, near, pos, dir, mayClear) } + } + + var far = m.find(dir < 0 ? -1 : 1); + if (dir < 0 ? preventCursorLeft : preventCursorRight) + { far = movePos(doc, far, dir, far.line == pos.line ? line : null); } + return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null + } + } } + return pos + } + + // Ensure a given position is not inside an atomic range. + function skipAtomic(doc, pos, oldPos, bias, mayClear) { + var dir = bias || 1; + var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) || + (!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) || + skipAtomicInner(doc, pos, oldPos, -dir, mayClear) || + (!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true)); + if (!found) { + doc.cantEdit = true; + return Pos(doc.first, 0) + } + return found + } + + function movePos(doc, pos, dir, line) { + if (dir < 0 && pos.ch == 0) { + if (pos.line > doc.first) { return clipPos(doc, Pos(pos.line - 1)) } + else { return null } + } else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) { + if (pos.line < doc.first + doc.size - 1) { return Pos(pos.line + 1, 0) } + else { return null } + } else { + return new Pos(pos.line, pos.ch + dir) + } + } + + function selectAll(cm) { + cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll); + } + + // UPDATING + + // Allow "beforeChange" event handlers to influence a change + function filterChange(doc, change, update) { + var obj = { + canceled: false, + from: change.from, + to: change.to, + text: change.text, + origin: change.origin, + cancel: function () { return obj.canceled = true; } + }; + if (update) { obj.update = function (from, to, text, origin) { + if (from) { obj.from = clipPos(doc, from); } + if (to) { obj.to = clipPos(doc, to); } + if (text) { obj.text = text; } + if (origin !== undefined) { obj.origin = origin; } + }; } + signal(doc, "beforeChange", doc, obj); + if (doc.cm) { signal(doc.cm, "beforeChange", doc.cm, obj); } + + if (obj.canceled) { + if (doc.cm) { doc.cm.curOp.updateInput = 2; } + return null + } + return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin} + } + + // Apply a change to a document, and add it to the document's + // history, and propagating it to all linked documents. + function makeChange(doc, change, ignoreReadOnly) { + if (doc.cm) { + if (!doc.cm.curOp) { return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly) } + if (doc.cm.state.suppressEdits) { return } + } + + if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) { + change = filterChange(doc, change, true); + if (!change) { return } + } + + // Possibly split or suppress the update based on the presence + // of read-only spans in its range. + var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to); + if (split) { + for (var i = split.length - 1; i >= 0; --i) + { makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin}); } + } else { + makeChangeInner(doc, change); + } + } + + function makeChangeInner(doc, change) { + if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) { return } + var selAfter = computeSelAfterChange(doc, change); + addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN); + + makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change)); + var rebased = []; + + linkedDocs(doc, function (doc, sharedHist) { + if (!sharedHist && indexOf(rebased, doc.history) == -1) { + rebaseHist(doc.history, change); + rebased.push(doc.history); + } + makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change)); + }); + } + + // Revert a change stored in a document's history. + function makeChangeFromHistory(doc, type, allowSelectionOnly) { + var suppress = doc.cm && doc.cm.state.suppressEdits; + if (suppress && !allowSelectionOnly) { return } + + var hist = doc.history, event, selAfter = doc.sel; + var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done; + + // Verify that there is a useable event (so that ctrl-z won't + // needlessly clear selection events) + var i = 0; + for (; i < source.length; i++) { + event = source[i]; + if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges) + { break } + } + if (i == source.length) { return } + hist.lastOrigin = hist.lastSelOrigin = null; + + for (;;) { + event = source.pop(); + if (event.ranges) { + pushSelectionToHistory(event, dest); + if (allowSelectionOnly && !event.equals(doc.sel)) { + setSelection(doc, event, {clearRedo: false}); + return + } + selAfter = event; + } else if (suppress) { + source.push(event); + return + } else { break } + } + + // Build up a reverse change object to add to the opposite history + // stack (redo when undoing, and vice versa). + var antiChanges = []; + pushSelectionToHistory(selAfter, dest); + dest.push({changes: antiChanges, generation: hist.generation}); + hist.generation = event.generation || ++hist.maxGeneration; + + var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange"); + + var loop = function ( i ) { + var change = event.changes[i]; + change.origin = type; + if (filter && !filterChange(doc, change, false)) { + source.length = 0; + return {} + } + + antiChanges.push(historyChangeFromChange(doc, change)); + + var after = i ? computeSelAfterChange(doc, change) : lst(source); + makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change)); + if (!i && doc.cm) { doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}); } + var rebased = []; + + // Propagate to the linked documents + linkedDocs(doc, function (doc, sharedHist) { + if (!sharedHist && indexOf(rebased, doc.history) == -1) { + rebaseHist(doc.history, change); + rebased.push(doc.history); + } + makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change)); + }); + }; + + for (var i$1 = event.changes.length - 1; i$1 >= 0; --i$1) { + var returned = loop( i$1 ); + + if ( returned ) return returned.v; + } + } + + // Sub-views need their line numbers shifted when text is added + // above or below them in the parent document. + function shiftDoc(doc, distance) { + if (distance == 0) { return } + doc.first += distance; + doc.sel = new Selection(map(doc.sel.ranges, function (range) { return new Range( + Pos(range.anchor.line + distance, range.anchor.ch), + Pos(range.head.line + distance, range.head.ch) + ); }), doc.sel.primIndex); + if (doc.cm) { + regChange(doc.cm, doc.first, doc.first - distance, distance); + for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++) + { regLineChange(doc.cm, l, "gutter"); } + } + } + + // More lower-level change function, handling only a single document + // (not linked ones). + function makeChangeSingleDoc(doc, change, selAfter, spans) { + if (doc.cm && !doc.cm.curOp) + { return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans) } + + if (change.to.line < doc.first) { + shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line)); + return + } + if (change.from.line > doc.lastLine()) { return } + + // Clip the change to the size of this doc + if (change.from.line < doc.first) { + var shift = change.text.length - 1 - (doc.first - change.from.line); + shiftDoc(doc, shift); + change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch), + text: [lst(change.text)], origin: change.origin}; + } + var last = doc.lastLine(); + if (change.to.line > last) { + change = {from: change.from, to: Pos(last, getLine(doc, last).text.length), + text: [change.text[0]], origin: change.origin}; + } + + change.removed = getBetween(doc, change.from, change.to); + + if (!selAfter) { selAfter = computeSelAfterChange(doc, change); } + if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans); } + else { updateDoc(doc, change, spans); } + setSelectionNoUndo(doc, selAfter, sel_dontScroll); + + if (doc.cantEdit && skipAtomic(doc, Pos(doc.firstLine(), 0))) + { doc.cantEdit = false; } + } + + // Handle the interaction of a change to a document with the editor + // that this document is part of. + function makeChangeSingleDocInEditor(cm, change, spans) { + var doc = cm.doc, display = cm.display, from = change.from, to = change.to; + + var recomputeMaxLength = false, checkWidthStart = from.line; + if (!cm.options.lineWrapping) { + checkWidthStart = lineNo(visualLine(getLine(doc, from.line))); + doc.iter(checkWidthStart, to.line + 1, function (line) { + if (line == display.maxLine) { + recomputeMaxLength = true; + return true + } + }); + } + + if (doc.sel.contains(change.from, change.to) > -1) + { signalCursorActivity(cm); } + + updateDoc(doc, change, spans, estimateHeight(cm)); + + if (!cm.options.lineWrapping) { + doc.iter(checkWidthStart, from.line + change.text.length, function (line) { + var len = lineLength(line); + if (len > display.maxLineLength) { + display.maxLine = line; + display.maxLineLength = len; + display.maxLineChanged = true; + recomputeMaxLength = false; + } + }); + if (recomputeMaxLength) { cm.curOp.updateMaxLine = true; } + } + + retreatFrontier(doc, from.line); + startWorker(cm, 400); + + var lendiff = change.text.length - (to.line - from.line) - 1; + // Remember that these lines changed, for updating the display + if (change.full) + { regChange(cm); } + else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change)) + { regLineChange(cm, from.line, "text"); } + else + { regChange(cm, from.line, to.line + 1, lendiff); } + + var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change"); + if (changeHandler || changesHandler) { + var obj = { + from: from, to: to, + text: change.text, + removed: change.removed, + origin: change.origin + }; + if (changeHandler) { signalLater(cm, "change", cm, obj); } + if (changesHandler) { (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); } + } + cm.display.selForContextMenu = null; + } + + function replaceRange(doc, code, from, to, origin) { + var assign; + + if (!to) { to = from; } + if (cmp(to, from) < 0) { (assign = [to, from], from = assign[0], to = assign[1]); } + if (typeof code == "string") { code = doc.splitLines(code); } + makeChange(doc, {from: from, to: to, text: code, origin: origin}); + } + + // Rebasing/resetting history to deal with externally-sourced changes + + function rebaseHistSelSingle(pos, from, to, diff) { + if (to < pos.line) { + pos.line += diff; + } else if (from < pos.line) { + pos.line = from; + pos.ch = 0; + } + } + + // Tries to rebase an array of history events given a change in the + // document. If the change touches the same lines as the event, the + // event, and everything 'behind' it, is discarded. If the change is + // before the event, the event's positions are updated. Uses a + // copy-on-write scheme for the positions, to avoid having to + // reallocate them all on every rebase, but also avoid problems with + // shared position objects being unsafely updated. + function rebaseHistArray(array, from, to, diff) { + for (var i = 0; i < array.length; ++i) { + var sub = array[i], ok = true; + if (sub.ranges) { + if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; } + for (var j = 0; j < sub.ranges.length; j++) { + rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff); + rebaseHistSelSingle(sub.ranges[j].head, from, to, diff); + } + continue + } + for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) { + var cur = sub.changes[j$1]; + if (to < cur.from.line) { + cur.from = Pos(cur.from.line + diff, cur.from.ch); + cur.to = Pos(cur.to.line + diff, cur.to.ch); + } else if (from <= cur.to.line) { + ok = false; + break + } + } + if (!ok) { + array.splice(0, i + 1); + i = 0; + } + } + } + + function rebaseHist(hist, change) { + var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1; + rebaseHistArray(hist.done, from, to, diff); + rebaseHistArray(hist.undone, from, to, diff); + } + + // Utility for applying a change to a line by handle or number, + // returning the number and optionally registering the line as + // changed. + function changeLine(doc, handle, changeType, op) { + var no = handle, line = handle; + if (typeof handle == "number") { line = getLine(doc, clipLine(doc, handle)); } + else { no = lineNo(handle); } + if (no == null) { return null } + if (op(line, no) && doc.cm) { regLineChange(doc.cm, no, changeType); } + return line + } + + // The document is represented as a BTree consisting of leaves, with + // chunk of lines in them, and branches, with up to ten leaves or + // other branch nodes below them. The top node is always a branch + // node, and is the document object itself (meaning it has + // additional methods and properties). + // + // All nodes have parent links. The tree is used both to go from + // line numbers to line objects, and to go from objects to numbers. + // It also indexes by height, and is used to convert between height + // and line object, and to find the total height of the document. + // + // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html + + function LeafChunk(lines) { + this.lines = lines; + this.parent = null; + var height = 0; + for (var i = 0; i < lines.length; ++i) { + lines[i].parent = this; + height += lines[i].height; + } + this.height = height; + } + + LeafChunk.prototype = { + chunkSize: function() { return this.lines.length }, + + // Remove the n lines at offset 'at'. + removeInner: function(at, n) { + for (var i = at, e = at + n; i < e; ++i) { + var line = this.lines[i]; + this.height -= line.height; + cleanUpLine(line); + signalLater(line, "delete"); + } + this.lines.splice(at, n); + }, + + // Helper used to collapse a small branch into a single leaf. + collapse: function(lines) { + lines.push.apply(lines, this.lines); + }, + + // Insert the given array of lines at offset 'at', count them as + // having the given height. + insertInner: function(at, lines, height) { + this.height += height; + this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at)); + for (var i = 0; i < lines.length; ++i) { lines[i].parent = this; } + }, + + // Used to iterate over a part of the tree. + iterN: function(at, n, op) { + for (var e = at + n; at < e; ++at) + { if (op(this.lines[at])) { return true } } + } + }; + + function BranchChunk(children) { + this.children = children; + var size = 0, height = 0; + for (var i = 0; i < children.length; ++i) { + var ch = children[i]; + size += ch.chunkSize(); height += ch.height; + ch.parent = this; + } + this.size = size; + this.height = height; + this.parent = null; + } + + BranchChunk.prototype = { + chunkSize: function() { return this.size }, + + removeInner: function(at, n) { + this.size -= n; + for (var i = 0; i < this.children.length; ++i) { + var child = this.children[i], sz = child.chunkSize(); + if (at < sz) { + var rm = Math.min(n, sz - at), oldHeight = child.height; + child.removeInner(at, rm); + this.height -= oldHeight - child.height; + if (sz == rm) { this.children.splice(i--, 1); child.parent = null; } + if ((n -= rm) == 0) { break } + at = 0; + } else { at -= sz; } + } + // If the result is smaller than 25 lines, ensure that it is a + // single leaf node. + if (this.size - n < 25 && + (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) { + var lines = []; + this.collapse(lines); + this.children = [new LeafChunk(lines)]; + this.children[0].parent = this; + } + }, + + collapse: function(lines) { + for (var i = 0; i < this.children.length; ++i) { this.children[i].collapse(lines); } + }, + + insertInner: function(at, lines, height) { + this.size += lines.length; + this.height += height; + for (var i = 0; i < this.children.length; ++i) { + var child = this.children[i], sz = child.chunkSize(); + if (at <= sz) { + child.insertInner(at, lines, height); + if (child.lines && child.lines.length > 50) { + // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced. + // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest. + var remaining = child.lines.length % 25 + 25; + for (var pos = remaining; pos < child.lines.length;) { + var leaf = new LeafChunk(child.lines.slice(pos, pos += 25)); + child.height -= leaf.height; + this.children.splice(++i, 0, leaf); + leaf.parent = this; + } + child.lines = child.lines.slice(0, remaining); + this.maybeSpill(); + } + break + } + at -= sz; + } + }, + + // When a node has grown, check whether it should be split. + maybeSpill: function() { + if (this.children.length <= 10) { return } + var me = this; + do { + var spilled = me.children.splice(me.children.length - 5, 5); + var sibling = new BranchChunk(spilled); + if (!me.parent) { // Become the parent node + var copy = new BranchChunk(me.children); + copy.parent = me; + me.children = [copy, sibling]; + me = copy; + } else { + me.size -= sibling.size; + me.height -= sibling.height; + var myIndex = indexOf(me.parent.children, me); + me.parent.children.splice(myIndex + 1, 0, sibling); + } + sibling.parent = me.parent; + } while (me.children.length > 10) + me.parent.maybeSpill(); + }, + + iterN: function(at, n, op) { + for (var i = 0; i < this.children.length; ++i) { + var child = this.children[i], sz = child.chunkSize(); + if (at < sz) { + var used = Math.min(n, sz - at); + if (child.iterN(at, used, op)) { return true } + if ((n -= used) == 0) { break } + at = 0; + } else { at -= sz; } + } + } + }; + + // Line widgets are block elements displayed above or below a line. + + var LineWidget = function(doc, node, options) { + if (options) { for (var opt in options) { if (options.hasOwnProperty(opt)) + { this[opt] = options[opt]; } } } + this.doc = doc; + this.node = node; + }; + + LineWidget.prototype.clear = function () { + var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line); + if (no == null || !ws) { return } + for (var i = 0; i < ws.length; ++i) { if (ws[i] == this) { ws.splice(i--, 1); } } + if (!ws.length) { line.widgets = null; } + var height = widgetHeight(this); + updateLineHeight(line, Math.max(0, line.height - height)); + if (cm) { + runInOp(cm, function () { + adjustScrollWhenAboveVisible(cm, line, -height); + regLineChange(cm, no, "widget"); + }); + signalLater(cm, "lineWidgetCleared", cm, this, no); + } + }; + + LineWidget.prototype.changed = function () { + var this$1 = this; + + var oldH = this.height, cm = this.doc.cm, line = this.line; + this.height = null; + var diff = widgetHeight(this) - oldH; + if (!diff) { return } + if (!lineIsHidden(this.doc, line)) { updateLineHeight(line, line.height + diff); } + if (cm) { + runInOp(cm, function () { + cm.curOp.forceUpdate = true; + adjustScrollWhenAboveVisible(cm, line, diff); + signalLater(cm, "lineWidgetChanged", cm, this$1, lineNo(line)); + }); + } + }; + eventMixin(LineWidget); + + function adjustScrollWhenAboveVisible(cm, line, diff) { + if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop)) + { addToScrollTop(cm, diff); } + } + + function addLineWidget(doc, handle, node, options) { + var widget = new LineWidget(doc, node, options); + var cm = doc.cm; + if (cm && widget.noHScroll) { cm.display.alignWidgets = true; } + changeLine(doc, handle, "widget", function (line) { + var widgets = line.widgets || (line.widgets = []); + if (widget.insertAt == null) { widgets.push(widget); } + else { widgets.splice(Math.min(widgets.length, Math.max(0, widget.insertAt)), 0, widget); } + widget.line = line; + if (cm && !lineIsHidden(doc, line)) { + var aboveVisible = heightAtLine(line) < doc.scrollTop; + updateLineHeight(line, line.height + widgetHeight(widget)); + if (aboveVisible) { addToScrollTop(cm, widget.height); } + cm.curOp.forceUpdate = true; + } + return true + }); + if (cm) { signalLater(cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle)); } + return widget + } + + // TEXTMARKERS + + // Created with markText and setBookmark methods. A TextMarker is a + // handle that can be used to clear or find a marked position in the + // document. Line objects hold arrays (markedSpans) containing + // {from, to, marker} object pointing to such marker objects, and + // indicating that such a marker is present on that line. Multiple + // lines may point to the same marker when it spans across lines. + // The spans will have null for their from/to properties when the + // marker continues beyond the start/end of the line. Markers have + // links back to the lines they currently touch. + + // Collapsed markers have unique ids, in order to be able to order + // them, which is needed for uniquely determining an outer marker + // when they overlap (they may nest, but not partially overlap). + var nextMarkerId = 0; + + var TextMarker = function(doc, type) { + this.lines = []; + this.type = type; + this.doc = doc; + this.id = ++nextMarkerId; + }; + + // Clear the marker. + TextMarker.prototype.clear = function () { + if (this.explicitlyCleared) { return } + var cm = this.doc.cm, withOp = cm && !cm.curOp; + if (withOp) { startOperation(cm); } + if (hasHandler(this, "clear")) { + var found = this.find(); + if (found) { signalLater(this, "clear", found.from, found.to); } + } + var min = null, max = null; + for (var i = 0; i < this.lines.length; ++i) { + var line = this.lines[i]; + var span = getMarkedSpanFor(line.markedSpans, this); + if (cm && !this.collapsed) { regLineChange(cm, lineNo(line), "text"); } + else if (cm) { + if (span.to != null) { max = lineNo(line); } + if (span.from != null) { min = lineNo(line); } + } + line.markedSpans = removeMarkedSpan(line.markedSpans, span); + if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm) + { updateLineHeight(line, textHeight(cm.display)); } + } + if (cm && this.collapsed && !cm.options.lineWrapping) { for (var i$1 = 0; i$1 < this.lines.length; ++i$1) { + var visual = visualLine(this.lines[i$1]), len = lineLength(visual); + if (len > cm.display.maxLineLength) { + cm.display.maxLine = visual; + cm.display.maxLineLength = len; + cm.display.maxLineChanged = true; + } + } } + + if (min != null && cm && this.collapsed) { regChange(cm, min, max + 1); } + this.lines.length = 0; + this.explicitlyCleared = true; + if (this.atomic && this.doc.cantEdit) { + this.doc.cantEdit = false; + if (cm) { reCheckSelection(cm.doc); } + } + if (cm) { signalLater(cm, "markerCleared", cm, this, min, max); } + if (withOp) { endOperation(cm); } + if (this.parent) { this.parent.clear(); } + }; + + // Find the position of the marker in the document. Returns a {from, + // to} object by default. Side can be passed to get a specific side + // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the + // Pos objects returned contain a line object, rather than a line + // number (used to prevent looking up the same line twice). + TextMarker.prototype.find = function (side, lineObj) { + if (side == null && this.type == "bookmark") { side = 1; } + var from, to; + for (var i = 0; i < this.lines.length; ++i) { + var line = this.lines[i]; + var span = getMarkedSpanFor(line.markedSpans, this); + if (span.from != null) { + from = Pos(lineObj ? line : lineNo(line), span.from); + if (side == -1) { return from } + } + if (span.to != null) { + to = Pos(lineObj ? line : lineNo(line), span.to); + if (side == 1) { return to } + } + } + return from && {from: from, to: to} + }; + + // Signals that the marker's widget changed, and surrounding layout + // should be recomputed. + TextMarker.prototype.changed = function () { + var this$1 = this; + + var pos = this.find(-1, true), widget = this, cm = this.doc.cm; + if (!pos || !cm) { return } + runInOp(cm, function () { + var line = pos.line, lineN = lineNo(pos.line); + var view = findViewForLine(cm, lineN); + if (view) { + clearLineMeasurementCacheFor(view); + cm.curOp.selectionChanged = cm.curOp.forceUpdate = true; + } + cm.curOp.updateMaxLine = true; + if (!lineIsHidden(widget.doc, line) && widget.height != null) { + var oldHeight = widget.height; + widget.height = null; + var dHeight = widgetHeight(widget) - oldHeight; + if (dHeight) + { updateLineHeight(line, line.height + dHeight); } + } + signalLater(cm, "markerChanged", cm, this$1); + }); + }; + + TextMarker.prototype.attachLine = function (line) { + if (!this.lines.length && this.doc.cm) { + var op = this.doc.cm.curOp; + if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1) + { (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this); } + } + this.lines.push(line); + }; + + TextMarker.prototype.detachLine = function (line) { + this.lines.splice(indexOf(this.lines, line), 1); + if (!this.lines.length && this.doc.cm) { + var op = this.doc.cm.curOp + ;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this); + } + }; + eventMixin(TextMarker); + + // Create a marker, wire it up to the right lines, and + function markText(doc, from, to, options, type) { + // Shared markers (across linked documents) are handled separately + // (markTextShared will call out to this again, once per + // document). + if (options && options.shared) { return markTextShared(doc, from, to, options, type) } + // Ensure we are in an operation. + if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, markText)(doc, from, to, options, type) } + + var marker = new TextMarker(doc, type), diff = cmp(from, to); + if (options) { copyObj(options, marker, false); } + // Don't connect empty markers unless clearWhenEmpty is false + if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false) + { return marker } + if (marker.replacedWith) { + // Showing up as a widget implies collapsed (widget replaces text) + marker.collapsed = true; + marker.widgetNode = eltP("span", [marker.replacedWith], "CodeMirror-widget"); + if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true"); } + if (options.insertLeft) { marker.widgetNode.insertLeft = true; } + } + if (marker.collapsed) { + if (conflictingCollapsedRange(doc, from.line, from, to, marker) || + from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker)) + { throw new Error("Inserting collapsed marker partially overlapping an existing one") } + seeCollapsedSpans(); + } + + if (marker.addToHistory) + { addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN); } + + var curLine = from.line, cm = doc.cm, updateMaxLine; + doc.iter(curLine, to.line + 1, function (line) { + if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine) + { updateMaxLine = true; } + if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0); } + addMarkedSpan(line, new MarkedSpan(marker, + curLine == from.line ? from.ch : null, + curLine == to.line ? to.ch : null)); + ++curLine; + }); + // lineIsHidden depends on the presence of the spans, so needs a second pass + if (marker.collapsed) { doc.iter(from.line, to.line + 1, function (line) { + if (lineIsHidden(doc, line)) { updateLineHeight(line, 0); } + }); } + + if (marker.clearOnEnter) { on(marker, "beforeCursorEnter", function () { return marker.clear(); }); } + + if (marker.readOnly) { + seeReadOnlySpans(); + if (doc.history.done.length || doc.history.undone.length) + { doc.clearHistory(); } + } + if (marker.collapsed) { + marker.id = ++nextMarkerId; + marker.atomic = true; + } + if (cm) { + // Sync editor state + if (updateMaxLine) { cm.curOp.updateMaxLine = true; } + if (marker.collapsed) + { regChange(cm, from.line, to.line + 1); } + else if (marker.className || marker.startStyle || marker.endStyle || marker.css || + marker.attributes || marker.title) + { for (var i = from.line; i <= to.line; i++) { regLineChange(cm, i, "text"); } } + if (marker.atomic) { reCheckSelection(cm.doc); } + signalLater(cm, "markerAdded", cm, marker); + } + return marker + } + + // SHARED TEXTMARKERS + + // A shared marker spans multiple linked documents. It is + // implemented as a meta-marker-object controlling multiple normal + // markers. + var SharedTextMarker = function(markers, primary) { + this.markers = markers; + this.primary = primary; + for (var i = 0; i < markers.length; ++i) + { markers[i].parent = this; } + }; + + SharedTextMarker.prototype.clear = function () { + if (this.explicitlyCleared) { return } + this.explicitlyCleared = true; + for (var i = 0; i < this.markers.length; ++i) + { this.markers[i].clear(); } + signalLater(this, "clear"); + }; + + SharedTextMarker.prototype.find = function (side, lineObj) { + return this.primary.find(side, lineObj) + }; + eventMixin(SharedTextMarker); + + function markTextShared(doc, from, to, options, type) { + options = copyObj(options); + options.shared = false; + var markers = [markText(doc, from, to, options, type)], primary = markers[0]; + var widget = options.widgetNode; + linkedDocs(doc, function (doc) { + if (widget) { options.widgetNode = widget.cloneNode(true); } + markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type)); + for (var i = 0; i < doc.linked.length; ++i) + { if (doc.linked[i].isParent) { return } } + primary = lst(markers); + }); + return new SharedTextMarker(markers, primary) + } + + function findSharedMarkers(doc) { + return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function (m) { return m.parent; }) + } + + function copySharedMarkers(doc, markers) { + for (var i = 0; i < markers.length; i++) { + var marker = markers[i], pos = marker.find(); + var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to); + if (cmp(mFrom, mTo)) { + var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type); + marker.markers.push(subMark); + subMark.parent = marker; + } + } + } + + function detachSharedMarkers(markers) { + var loop = function ( i ) { + var marker = markers[i], linked = [marker.primary.doc]; + linkedDocs(marker.primary.doc, function (d) { return linked.push(d); }); + for (var j = 0; j < marker.markers.length; j++) { + var subMarker = marker.markers[j]; + if (indexOf(linked, subMarker.doc) == -1) { + subMarker.parent = null; + marker.markers.splice(j--, 1); + } + } + }; + + for (var i = 0; i < markers.length; i++) loop( i ); + } + + var nextDocId = 0; + var Doc = function(text, mode, firstLine, lineSep, direction) { + if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep, direction) } + if (firstLine == null) { firstLine = 0; } + + BranchChunk.call(this, [new LeafChunk([new Line("", null)])]); + this.first = firstLine; + this.scrollTop = this.scrollLeft = 0; + this.cantEdit = false; + this.cleanGeneration = 1; + this.modeFrontier = this.highlightFrontier = firstLine; + var start = Pos(firstLine, 0); + this.sel = simpleSelection(start); + this.history = new History(null); + this.id = ++nextDocId; + this.modeOption = mode; + this.lineSep = lineSep; + this.direction = (direction == "rtl") ? "rtl" : "ltr"; + this.extend = false; + + if (typeof text == "string") { text = this.splitLines(text); } + updateDoc(this, {from: start, to: start, text: text}); + setSelection(this, simpleSelection(start), sel_dontScroll); + }; + + Doc.prototype = createObj(BranchChunk.prototype, { + constructor: Doc, + // Iterate over the document. Supports two forms -- with only one + // argument, it calls that for each line in the document. With + // three, it iterates over the range given by the first two (with + // the second being non-inclusive). + iter: function(from, to, op) { + if (op) { this.iterN(from - this.first, to - from, op); } + else { this.iterN(this.first, this.first + this.size, from); } + }, + + // Non-public interface for adding and removing lines. + insert: function(at, lines) { + var height = 0; + for (var i = 0; i < lines.length; ++i) { height += lines[i].height; } + this.insertInner(at - this.first, lines, height); + }, + remove: function(at, n) { this.removeInner(at - this.first, n); }, + + // From here, the methods are part of the public interface. Most + // are also available from CodeMirror (editor) instances. + + getValue: function(lineSep) { + var lines = getLines(this, this.first, this.first + this.size); + if (lineSep === false) { return lines } + return lines.join(lineSep || this.lineSeparator()) + }, + setValue: docMethodOp(function(code) { + var top = Pos(this.first, 0), last = this.first + this.size - 1; + makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length), + text: this.splitLines(code), origin: "setValue", full: true}, true); + if (this.cm) { scrollToCoords(this.cm, 0, 0); } + setSelection(this, simpleSelection(top), sel_dontScroll); + }), + replaceRange: function(code, from, to, origin) { + from = clipPos(this, from); + to = to ? clipPos(this, to) : from; + replaceRange(this, code, from, to, origin); + }, + getRange: function(from, to, lineSep) { + var lines = getBetween(this, clipPos(this, from), clipPos(this, to)); + if (lineSep === false) { return lines } + return lines.join(lineSep || this.lineSeparator()) + }, + + getLine: function(line) {var l = this.getLineHandle(line); return l && l.text}, + + getLineHandle: function(line) {if (isLine(this, line)) { return getLine(this, line) }}, + getLineNumber: function(line) {return lineNo(line)}, + + getLineHandleVisualStart: function(line) { + if (typeof line == "number") { line = getLine(this, line); } + return visualLine(line) + }, + + lineCount: function() {return this.size}, + firstLine: function() {return this.first}, + lastLine: function() {return this.first + this.size - 1}, + + clipPos: function(pos) {return clipPos(this, pos)}, + + getCursor: function(start) { + var range = this.sel.primary(), pos; + if (start == null || start == "head") { pos = range.head; } + else if (start == "anchor") { pos = range.anchor; } + else if (start == "end" || start == "to" || start === false) { pos = range.to(); } + else { pos = range.from(); } + return pos + }, + listSelections: function() { return this.sel.ranges }, + somethingSelected: function() {return this.sel.somethingSelected()}, + + setCursor: docMethodOp(function(line, ch, options) { + setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options); + }), + setSelection: docMethodOp(function(anchor, head, options) { + setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options); + }), + extendSelection: docMethodOp(function(head, other, options) { + extendSelection(this, clipPos(this, head), other && clipPos(this, other), options); + }), + extendSelections: docMethodOp(function(heads, options) { + extendSelections(this, clipPosArray(this, heads), options); + }), + extendSelectionsBy: docMethodOp(function(f, options) { + var heads = map(this.sel.ranges, f); + extendSelections(this, clipPosArray(this, heads), options); + }), + setSelections: docMethodOp(function(ranges, primary, options) { + if (!ranges.length) { return } + var out = []; + for (var i = 0; i < ranges.length; i++) + { out[i] = new Range(clipPos(this, ranges[i].anchor), + clipPos(this, ranges[i].head)); } + if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex); } + setSelection(this, normalizeSelection(this.cm, out, primary), options); + }), + addSelection: docMethodOp(function(anchor, head, options) { + var ranges = this.sel.ranges.slice(0); + ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor))); + setSelection(this, normalizeSelection(this.cm, ranges, ranges.length - 1), options); + }), + + getSelection: function(lineSep) { + var ranges = this.sel.ranges, lines; + for (var i = 0; i < ranges.length; i++) { + var sel = getBetween(this, ranges[i].from(), ranges[i].to()); + lines = lines ? lines.concat(sel) : sel; + } + if (lineSep === false) { return lines } + else { return lines.join(lineSep || this.lineSeparator()) } + }, + getSelections: function(lineSep) { + var parts = [], ranges = this.sel.ranges; + for (var i = 0; i < ranges.length; i++) { + var sel = getBetween(this, ranges[i].from(), ranges[i].to()); + if (lineSep !== false) { sel = sel.join(lineSep || this.lineSeparator()); } + parts[i] = sel; + } + return parts + }, + replaceSelection: function(code, collapse, origin) { + var dup = []; + for (var i = 0; i < this.sel.ranges.length; i++) + { dup[i] = code; } + this.replaceSelections(dup, collapse, origin || "+input"); + }, + replaceSelections: docMethodOp(function(code, collapse, origin) { + var changes = [], sel = this.sel; + for (var i = 0; i < sel.ranges.length; i++) { + var range = sel.ranges[i]; + changes[i] = {from: range.from(), to: range.to(), text: this.splitLines(code[i]), origin: origin}; + } + var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse); + for (var i$1 = changes.length - 1; i$1 >= 0; i$1--) + { makeChange(this, changes[i$1]); } + if (newSel) { setSelectionReplaceHistory(this, newSel); } + else if (this.cm) { ensureCursorVisible(this.cm); } + }), + undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}), + redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}), + undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}), + redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}), + + setExtending: function(val) {this.extend = val;}, + getExtending: function() {return this.extend}, + + historySize: function() { + var hist = this.history, done = 0, undone = 0; + for (var i = 0; i < hist.done.length; i++) { if (!hist.done[i].ranges) { ++done; } } + for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone; } } + return {undo: done, redo: undone} + }, + clearHistory: function() { + var this$1 = this; + + this.history = new History(this.history); + linkedDocs(this, function (doc) { return doc.history = this$1.history; }, true); + }, + + markClean: function() { + this.cleanGeneration = this.changeGeneration(true); + }, + changeGeneration: function(forceSplit) { + if (forceSplit) + { this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null; } + return this.history.generation + }, + isClean: function (gen) { + return this.history.generation == (gen || this.cleanGeneration) + }, + + getHistory: function() { + return {done: copyHistoryArray(this.history.done), + undone: copyHistoryArray(this.history.undone)} + }, + setHistory: function(histData) { + var hist = this.history = new History(this.history); + hist.done = copyHistoryArray(histData.done.slice(0), null, true); + hist.undone = copyHistoryArray(histData.undone.slice(0), null, true); + }, + + setGutterMarker: docMethodOp(function(line, gutterID, value) { + return changeLine(this, line, "gutter", function (line) { + var markers = line.gutterMarkers || (line.gutterMarkers = {}); + markers[gutterID] = value; + if (!value && isEmpty(markers)) { line.gutterMarkers = null; } + return true + }) + }), + + clearGutter: docMethodOp(function(gutterID) { + var this$1 = this; + + this.iter(function (line) { + if (line.gutterMarkers && line.gutterMarkers[gutterID]) { + changeLine(this$1, line, "gutter", function () { + line.gutterMarkers[gutterID] = null; + if (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null; } + return true + }); + } + }); + }), + + lineInfo: function(line) { + var n; + if (typeof line == "number") { + if (!isLine(this, line)) { return null } + n = line; + line = getLine(this, line); + if (!line) { return null } + } else { + n = lineNo(line); + if (n == null) { return null } + } + return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers, + textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass, + widgets: line.widgets} + }, + + addLineClass: docMethodOp(function(handle, where, cls) { + return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) { + var prop = where == "text" ? "textClass" + : where == "background" ? "bgClass" + : where == "gutter" ? "gutterClass" : "wrapClass"; + if (!line[prop]) { line[prop] = cls; } + else if (classTest(cls).test(line[prop])) { return false } + else { line[prop] += " " + cls; } + return true + }) + }), + removeLineClass: docMethodOp(function(handle, where, cls) { + return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) { + var prop = where == "text" ? "textClass" + : where == "background" ? "bgClass" + : where == "gutter" ? "gutterClass" : "wrapClass"; + var cur = line[prop]; + if (!cur) { return false } + else if (cls == null) { line[prop] = null; } + else { + var found = cur.match(classTest(cls)); + if (!found) { return false } + var end = found.index + found[0].length; + line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null; + } + return true + }) + }), + + addLineWidget: docMethodOp(function(handle, node, options) { + return addLineWidget(this, handle, node, options) + }), + removeLineWidget: function(widget) { widget.clear(); }, + + markText: function(from, to, options) { + return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range") + }, + setBookmark: function(pos, options) { + var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options), + insertLeft: options && options.insertLeft, + clearWhenEmpty: false, shared: options && options.shared, + handleMouseEvents: options && options.handleMouseEvents}; + pos = clipPos(this, pos); + return markText(this, pos, pos, realOpts, "bookmark") + }, + findMarksAt: function(pos) { + pos = clipPos(this, pos); + var markers = [], spans = getLine(this, pos.line).markedSpans; + if (spans) { for (var i = 0; i < spans.length; ++i) { + var span = spans[i]; + if ((span.from == null || span.from <= pos.ch) && + (span.to == null || span.to >= pos.ch)) + { markers.push(span.marker.parent || span.marker); } + } } + return markers + }, + findMarks: function(from, to, filter) { + from = clipPos(this, from); to = clipPos(this, to); + var found = [], lineNo = from.line; + this.iter(from.line, to.line + 1, function (line) { + var spans = line.markedSpans; + if (spans) { for (var i = 0; i < spans.length; i++) { + var span = spans[i]; + if (!(span.to != null && lineNo == from.line && from.ch >= span.to || + span.from == null && lineNo != from.line || + span.from != null && lineNo == to.line && span.from >= to.ch) && + (!filter || filter(span.marker))) + { found.push(span.marker.parent || span.marker); } + } } + ++lineNo; + }); + return found + }, + getAllMarks: function() { + var markers = []; + this.iter(function (line) { + var sps = line.markedSpans; + if (sps) { for (var i = 0; i < sps.length; ++i) + { if (sps[i].from != null) { markers.push(sps[i].marker); } } } + }); + return markers + }, + + posFromIndex: function(off) { + var ch, lineNo = this.first, sepSize = this.lineSeparator().length; + this.iter(function (line) { + var sz = line.text.length + sepSize; + if (sz > off) { ch = off; return true } + off -= sz; + ++lineNo; + }); + return clipPos(this, Pos(lineNo, ch)) + }, + indexFromPos: function (coords) { + coords = clipPos(this, coords); + var index = coords.ch; + if (coords.line < this.first || coords.ch < 0) { return 0 } + var sepSize = this.lineSeparator().length; + this.iter(this.first, coords.line, function (line) { // iter aborts when callback returns a truthy value + index += line.text.length + sepSize; + }); + return index + }, + + copy: function(copyHistory) { + var doc = new Doc(getLines(this, this.first, this.first + this.size), + this.modeOption, this.first, this.lineSep, this.direction); + doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft; + doc.sel = this.sel; + doc.extend = false; + if (copyHistory) { + doc.history.undoDepth = this.history.undoDepth; + doc.setHistory(this.getHistory()); + } + return doc + }, + + linkedDoc: function(options) { + if (!options) { options = {}; } + var from = this.first, to = this.first + this.size; + if (options.from != null && options.from > from) { from = options.from; } + if (options.to != null && options.to < to) { to = options.to; } + var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep, this.direction); + if (options.sharedHist) { copy.history = this.history + ; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist}); + copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}]; + copySharedMarkers(copy, findSharedMarkers(this)); + return copy + }, + unlinkDoc: function(other) { + if (other instanceof CodeMirror) { other = other.doc; } + if (this.linked) { for (var i = 0; i < this.linked.length; ++i) { + var link = this.linked[i]; + if (link.doc != other) { continue } + this.linked.splice(i, 1); + other.unlinkDoc(this); + detachSharedMarkers(findSharedMarkers(this)); + break + } } + // If the histories were shared, split them again + if (other.history == this.history) { + var splitIds = [other.id]; + linkedDocs(other, function (doc) { return splitIds.push(doc.id); }, true); + other.history = new History(null); + other.history.done = copyHistoryArray(this.history.done, splitIds); + other.history.undone = copyHistoryArray(this.history.undone, splitIds); + } + }, + iterLinkedDocs: function(f) {linkedDocs(this, f);}, + + getMode: function() {return this.mode}, + getEditor: function() {return this.cm}, + + splitLines: function(str) { + if (this.lineSep) { return str.split(this.lineSep) } + return splitLinesAuto(str) + }, + lineSeparator: function() { return this.lineSep || "\n" }, + + setDirection: docMethodOp(function (dir) { + if (dir != "rtl") { dir = "ltr"; } + if (dir == this.direction) { return } + this.direction = dir; + this.iter(function (line) { return line.order = null; }); + if (this.cm) { directionChanged(this.cm); } + }) + }); + + // Public alias. + Doc.prototype.eachLine = Doc.prototype.iter; + + // Kludge to work around strange IE behavior where it'll sometimes + // re-fire a series of drag-related events right after the drop (#1551) + var lastDrop = 0; + + function onDrop(e) { + var cm = this; + clearDragCursor(cm); + if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) + { return } + e_preventDefault(e); + if (ie) { lastDrop = +new Date; } + var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files; + if (!pos || cm.isReadOnly()) { return } + // Might be a file drop, in which case we simply extract the text + // and insert it. + if (files && files.length && window.FileReader && window.File) { + var n = files.length, text = Array(n), read = 0; + var markAsReadAndPasteIfAllFilesAreRead = function () { + if (++read == n) { + operation(cm, function () { + pos = clipPos(cm.doc, pos); + var change = {from: pos, to: pos, + text: cm.doc.splitLines( + text.filter(function (t) { return t != null; }).join(cm.doc.lineSeparator())), + origin: "paste"}; + makeChange(cm.doc, change); + setSelectionReplaceHistory(cm.doc, simpleSelection(clipPos(cm.doc, pos), clipPos(cm.doc, changeEnd(change)))); + })(); + } + }; + var readTextFromFile = function (file, i) { + if (cm.options.allowDropFileTypes && + indexOf(cm.options.allowDropFileTypes, file.type) == -1) { + markAsReadAndPasteIfAllFilesAreRead(); + return + } + var reader = new FileReader; + reader.onerror = function () { return markAsReadAndPasteIfAllFilesAreRead(); }; + reader.onload = function () { + var content = reader.result; + if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { + markAsReadAndPasteIfAllFilesAreRead(); + return + } + text[i] = content; + markAsReadAndPasteIfAllFilesAreRead(); + }; + reader.readAsText(file); + }; + for (var i = 0; i < files.length; i++) { readTextFromFile(files[i], i); } + } else { // Normal drop + // Don't do a replace if the drop happened inside of the selected text. + if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) { + cm.state.draggingText(e); + // Ensure the editor is re-focused + setTimeout(function () { return cm.display.input.focus(); }, 20); + return + } + try { + var text$1 = e.dataTransfer.getData("Text"); + if (text$1) { + var selected; + if (cm.state.draggingText && !cm.state.draggingText.copy) + { selected = cm.listSelections(); } + setSelectionNoUndo(cm.doc, simpleSelection(pos, pos)); + if (selected) { for (var i$1 = 0; i$1 < selected.length; ++i$1) + { replaceRange(cm.doc, "", selected[i$1].anchor, selected[i$1].head, "drag"); } } + cm.replaceSelection(text$1, "around", "paste"); + cm.display.input.focus(); + } + } + catch(e$1){} + } + } + + function onDragStart(cm, e) { + if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return } + if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return } + + e.dataTransfer.setData("Text", cm.getSelection()); + e.dataTransfer.effectAllowed = "copyMove"; + + // Use dummy image instead of default browsers image. + // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there. + if (e.dataTransfer.setDragImage && !safari) { + var img = elt("img", null, null, "position: fixed; left: 0; top: 0;"); + img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; + if (presto) { + img.width = img.height = 1; + cm.display.wrapper.appendChild(img); + // Force a relayout, or Opera won't use our image for some obscure reason + img._top = img.offsetTop; + } + e.dataTransfer.setDragImage(img, 0, 0); + if (presto) { img.parentNode.removeChild(img); } + } + } + + function onDragOver(cm, e) { + var pos = posFromMouse(cm, e); + if (!pos) { return } + var frag = document.createDocumentFragment(); + drawSelectionCursor(cm, pos, frag); + if (!cm.display.dragCursor) { + cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors"); + cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv); + } + removeChildrenAndAdd(cm.display.dragCursor, frag); + } + + function clearDragCursor(cm) { + if (cm.display.dragCursor) { + cm.display.lineSpace.removeChild(cm.display.dragCursor); + cm.display.dragCursor = null; + } + } + + // These must be handled carefully, because naively registering a + // handler for each editor will cause the editors to never be + // garbage collected. + + function forEachCodeMirror(f) { + if (!document.getElementsByClassName) { return } + var byClass = document.getElementsByClassName("CodeMirror"), editors = []; + for (var i = 0; i < byClass.length; i++) { + var cm = byClass[i].CodeMirror; + if (cm) { editors.push(cm); } + } + if (editors.length) { editors[0].operation(function () { + for (var i = 0; i < editors.length; i++) { f(editors[i]); } + }); } + } + + var globalsRegistered = false; + function ensureGlobalHandlers() { + if (globalsRegistered) { return } + registerGlobalHandlers(); + globalsRegistered = true; + } + function registerGlobalHandlers() { + // When the window resizes, we need to refresh active editors. + var resizeTimer; + on(window, "resize", function () { + if (resizeTimer == null) { resizeTimer = setTimeout(function () { + resizeTimer = null; + forEachCodeMirror(onResize); + }, 100); } + }); + // When the window loses focus, we want to show the editor as blurred + on(window, "blur", function () { return forEachCodeMirror(onBlur); }); + } + // Called when the window resizes + function onResize(cm) { + var d = cm.display; + // Might be a text scaling operation, clear size caches. + d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; + d.scrollbarsClipped = false; + cm.setSize(); + } + + var keyNames = { + 3: "Pause", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", + 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", + 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", + 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", + 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 145: "ScrollLock", + 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", + 221: "]", 222: "'", 224: "Mod", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete", + 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert" + }; + + // Number keys + for (var i = 0; i < 10; i++) { keyNames[i + 48] = keyNames[i + 96] = String(i); } + // Alphabetic keys + for (var i$1 = 65; i$1 <= 90; i$1++) { keyNames[i$1] = String.fromCharCode(i$1); } + // Function keys + for (var i$2 = 1; i$2 <= 12; i$2++) { keyNames[i$2 + 111] = keyNames[i$2 + 63235] = "F" + i$2; } + + var keyMap = {}; + + keyMap.basic = { + "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown", + "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown", + "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore", + "Tab": "defaultTab", "Shift-Tab": "indentAuto", + "Enter": "newlineAndIndent", "Insert": "toggleOverwrite", + "Esc": "singleSelection" + }; + // Note that the save and find-related commands aren't defined by + // default. User code or addons can define them. Unknown commands + // are simply ignored. + keyMap.pcDefault = { + "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo", + "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown", + "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd", + "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find", + "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll", + "Ctrl-[": "indentLess", "Ctrl-]": "indentMore", + "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection", + "fallthrough": "basic" + }; + // Very basic readline/emacs-style bindings, which are standard on Mac. + keyMap.emacsy = { + "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown", + "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", + "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", + "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars", + "Ctrl-O": "openLine" + }; + keyMap.macDefault = { + "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo", + "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft", + "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore", + "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find", + "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll", + "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight", + "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd", + "fallthrough": ["basic", "emacsy"] + }; + keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault; + + // KEYMAP DISPATCH + + function normalizeKeyName(name) { + var parts = name.split(/-(?!$)/); + name = parts[parts.length - 1]; + var alt, ctrl, shift, cmd; + for (var i = 0; i < parts.length - 1; i++) { + var mod = parts[i]; + if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true; } + else if (/^a(lt)?$/i.test(mod)) { alt = true; } + else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true; } + else if (/^s(hift)?$/i.test(mod)) { shift = true; } + else { throw new Error("Unrecognized modifier name: " + mod) } + } + if (alt) { name = "Alt-" + name; } + if (ctrl) { name = "Ctrl-" + name; } + if (cmd) { name = "Cmd-" + name; } + if (shift) { name = "Shift-" + name; } + return name + } + + // This is a kludge to keep keymaps mostly working as raw objects + // (backwards compatibility) while at the same time support features + // like normalization and multi-stroke key bindings. It compiles a + // new normalized keymap, and then updates the old object to reflect + // this. + function normalizeKeyMap(keymap) { + var copy = {}; + for (var keyname in keymap) { if (keymap.hasOwnProperty(keyname)) { + var value = keymap[keyname]; + if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) { continue } + if (value == "...") { delete keymap[keyname]; continue } + + var keys = map(keyname.split(" "), normalizeKeyName); + for (var i = 0; i < keys.length; i++) { + var val = (void 0), name = (void 0); + if (i == keys.length - 1) { + name = keys.join(" "); + val = value; + } else { + name = keys.slice(0, i + 1).join(" "); + val = "..."; + } + var prev = copy[name]; + if (!prev) { copy[name] = val; } + else if (prev != val) { throw new Error("Inconsistent bindings for " + name) } + } + delete keymap[keyname]; + } } + for (var prop in copy) { keymap[prop] = copy[prop]; } + return keymap + } + + function lookupKey(key, map, handle, context) { + map = getKeyMap(map); + var found = map.call ? map.call(key, context) : map[key]; + if (found === false) { return "nothing" } + if (found === "...") { return "multi" } + if (found != null && handle(found)) { return "handled" } + + if (map.fallthrough) { + if (Object.prototype.toString.call(map.fallthrough) != "[object Array]") + { return lookupKey(key, map.fallthrough, handle, context) } + for (var i = 0; i < map.fallthrough.length; i++) { + var result = lookupKey(key, map.fallthrough[i], handle, context); + if (result) { return result } + } + } + } + + // Modifier key presses don't count as 'real' key presses for the + // purpose of keymap fallthrough. + function isModifierKey(value) { + var name = typeof value == "string" ? value : keyNames[value.keyCode]; + return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod" + } + + function addModifierNames(name, event, noShift) { + var base = name; + if (event.altKey && base != "Alt") { name = "Alt-" + name; } + if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") { name = "Ctrl-" + name; } + if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Mod") { name = "Cmd-" + name; } + if (!noShift && event.shiftKey && base != "Shift") { name = "Shift-" + name; } + return name + } + + // Look up the name of a key as indicated by an event object. + function keyName(event, noShift) { + if (presto && event.keyCode == 34 && event["char"]) { return false } + var name = keyNames[event.keyCode]; + if (name == null || event.altGraphKey) { return false } + // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause, + // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+) + if (event.keyCode == 3 && event.code) { name = event.code; } + return addModifierNames(name, event, noShift) + } + + function getKeyMap(val) { + return typeof val == "string" ? keyMap[val] : val + } + + // Helper for deleting text near the selection(s), used to implement + // backspace, delete, and similar functionality. + function deleteNearSelection(cm, compute) { + var ranges = cm.doc.sel.ranges, kill = []; + // Build up a set of ranges to kill first, merging overlapping + // ranges. + for (var i = 0; i < ranges.length; i++) { + var toKill = compute(ranges[i]); + while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) { + var replaced = kill.pop(); + if (cmp(replaced.from, toKill.from) < 0) { + toKill.from = replaced.from; + break + } + } + kill.push(toKill); + } + // Next, remove those actual ranges. + runInOp(cm, function () { + for (var i = kill.length - 1; i >= 0; i--) + { replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); } + ensureCursorVisible(cm); + }); + } + + function moveCharLogically(line, ch, dir) { + var target = skipExtendingChars(line.text, ch + dir, dir); + return target < 0 || target > line.text.length ? null : target + } + + function moveLogically(line, start, dir) { + var ch = moveCharLogically(line, start.ch, dir); + return ch == null ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before") + } + + function endOfLine(visually, cm, lineObj, lineNo, dir) { + if (visually) { + if (cm.doc.direction == "rtl") { dir = -dir; } + var order = getOrder(lineObj, cm.doc.direction); + if (order) { + var part = dir < 0 ? lst(order) : order[0]; + var moveInStorageOrder = (dir < 0) == (part.level == 1); + var sticky = moveInStorageOrder ? "after" : "before"; + var ch; + // With a wrapped rtl chunk (possibly spanning multiple bidi parts), + // it could be that the last bidi part is not on the last visual line, + // since visual lines contain content order-consecutive chunks. + // Thus, in rtl, we are looking for the first (content-order) character + // in the rtl chunk that is on the last line (that is, the same line + // as the last (content-order) character). + if (part.level > 0 || cm.doc.direction == "rtl") { + var prep = prepareMeasureForLine(cm, lineObj); + ch = dir < 0 ? lineObj.text.length - 1 : 0; + var targetTop = measureCharPrepared(cm, prep, ch).top; + ch = findFirst(function (ch) { return measureCharPrepared(cm, prep, ch).top == targetTop; }, (dir < 0) == (part.level == 1) ? part.from : part.to - 1, ch); + if (sticky == "before") { ch = moveCharLogically(lineObj, ch, 1); } + } else { ch = dir < 0 ? part.to : part.from; } + return new Pos(lineNo, ch, sticky) + } + } + return new Pos(lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after") + } + + function moveVisually(cm, line, start, dir) { + var bidi = getOrder(line, cm.doc.direction); + if (!bidi) { return moveLogically(line, start, dir) } + if (start.ch >= line.text.length) { + start.ch = line.text.length; + start.sticky = "before"; + } else if (start.ch <= 0) { + start.ch = 0; + start.sticky = "after"; + } + var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos]; + if (cm.doc.direction == "ltr" && part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) { + // Case 1: We move within an ltr part in an ltr editor. Even with wrapped lines, + // nothing interesting happens. + return moveLogically(line, start, dir) + } + + var mv = function (pos, dir) { return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir); }; + var prep; + var getWrappedLineExtent = function (ch) { + if (!cm.options.lineWrapping) { return {begin: 0, end: line.text.length} } + prep = prep || prepareMeasureForLine(cm, line); + return wrappedLineExtentChar(cm, line, prep, ch) + }; + var wrappedLineExtent = getWrappedLineExtent(start.sticky == "before" ? mv(start, -1) : start.ch); + + if (cm.doc.direction == "rtl" || part.level == 1) { + var moveInStorageOrder = (part.level == 1) == (dir < 0); + var ch = mv(start, moveInStorageOrder ? 1 : -1); + if (ch != null && (!moveInStorageOrder ? ch >= part.from && ch >= wrappedLineExtent.begin : ch <= part.to && ch <= wrappedLineExtent.end)) { + // Case 2: We move within an rtl part or in an rtl editor on the same visual line + var sticky = moveInStorageOrder ? "before" : "after"; + return new Pos(start.line, ch, sticky) + } + } + + // Case 3: Could not move within this bidi part in this visual line, so leave + // the current bidi part + + var searchInVisualLine = function (partPos, dir, wrappedLineExtent) { + var getRes = function (ch, moveInStorageOrder) { return moveInStorageOrder + ? new Pos(start.line, mv(ch, 1), "before") + : new Pos(start.line, ch, "after"); }; + + for (; partPos >= 0 && partPos < bidi.length; partPos += dir) { + var part = bidi[partPos]; + var moveInStorageOrder = (dir > 0) == (part.level != 1); + var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1); + if (part.from <= ch && ch < part.to) { return getRes(ch, moveInStorageOrder) } + ch = moveInStorageOrder ? part.from : mv(part.to, -1); + if (wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end) { return getRes(ch, moveInStorageOrder) } + } + }; + + // Case 3a: Look for other bidi parts on the same visual line + var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent); + if (res) { return res } + + // Case 3b: Look for other bidi parts on the next visual line + var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1); + if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) { + res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh)); + if (res) { return res } + } + + // Case 4: Nowhere to move + return null + } + + // Commands are parameter-less actions that can be performed on an + // editor, mostly used for keybindings. + var commands = { + selectAll: selectAll, + singleSelection: function (cm) { return cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); }, + killLine: function (cm) { return deleteNearSelection(cm, function (range) { + if (range.empty()) { + var len = getLine(cm.doc, range.head.line).text.length; + if (range.head.ch == len && range.head.line < cm.lastLine()) + { return {from: range.head, to: Pos(range.head.line + 1, 0)} } + else + { return {from: range.head, to: Pos(range.head.line, len)} } + } else { + return {from: range.from(), to: range.to()} + } + }); }, + deleteLine: function (cm) { return deleteNearSelection(cm, function (range) { return ({ + from: Pos(range.from().line, 0), + to: clipPos(cm.doc, Pos(range.to().line + 1, 0)) + }); }); }, + delLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { return ({ + from: Pos(range.from().line, 0), to: range.from() + }); }); }, + delWrappedLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { + var top = cm.charCoords(range.head, "div").top + 5; + var leftPos = cm.coordsChar({left: 0, top: top}, "div"); + return {from: leftPos, to: range.from()} + }); }, + delWrappedLineRight: function (cm) { return deleteNearSelection(cm, function (range) { + var top = cm.charCoords(range.head, "div").top + 5; + var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div"); + return {from: range.from(), to: rightPos } + }); }, + undo: function (cm) { return cm.undo(); }, + redo: function (cm) { return cm.redo(); }, + undoSelection: function (cm) { return cm.undoSelection(); }, + redoSelection: function (cm) { return cm.redoSelection(); }, + goDocStart: function (cm) { return cm.extendSelection(Pos(cm.firstLine(), 0)); }, + goDocEnd: function (cm) { return cm.extendSelection(Pos(cm.lastLine())); }, + goLineStart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStart(cm, range.head.line); }, + {origin: "+move", bias: 1} + ); }, + goLineStartSmart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStartSmart(cm, range.head); }, + {origin: "+move", bias: 1} + ); }, + goLineEnd: function (cm) { return cm.extendSelectionsBy(function (range) { return lineEnd(cm, range.head.line); }, + {origin: "+move", bias: -1} + ); }, + goLineRight: function (cm) { return cm.extendSelectionsBy(function (range) { + var top = cm.cursorCoords(range.head, "div").top + 5; + return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div") + }, sel_move); }, + goLineLeft: function (cm) { return cm.extendSelectionsBy(function (range) { + var top = cm.cursorCoords(range.head, "div").top + 5; + return cm.coordsChar({left: 0, top: top}, "div") + }, sel_move); }, + goLineLeftSmart: function (cm) { return cm.extendSelectionsBy(function (range) { + var top = cm.cursorCoords(range.head, "div").top + 5; + var pos = cm.coordsChar({left: 0, top: top}, "div"); + if (pos.ch < cm.getLine(pos.line).search(/\S/)) { return lineStartSmart(cm, range.head) } + return pos + }, sel_move); }, + goLineUp: function (cm) { return cm.moveV(-1, "line"); }, + goLineDown: function (cm) { return cm.moveV(1, "line"); }, + goPageUp: function (cm) { return cm.moveV(-1, "page"); }, + goPageDown: function (cm) { return cm.moveV(1, "page"); }, + goCharLeft: function (cm) { return cm.moveH(-1, "char"); }, + goCharRight: function (cm) { return cm.moveH(1, "char"); }, + goColumnLeft: function (cm) { return cm.moveH(-1, "column"); }, + goColumnRight: function (cm) { return cm.moveH(1, "column"); }, + goWordLeft: function (cm) { return cm.moveH(-1, "word"); }, + goGroupRight: function (cm) { return cm.moveH(1, "group"); }, + goGroupLeft: function (cm) { return cm.moveH(-1, "group"); }, + goWordRight: function (cm) { return cm.moveH(1, "word"); }, + delCharBefore: function (cm) { return cm.deleteH(-1, "codepoint"); }, + delCharAfter: function (cm) { return cm.deleteH(1, "char"); }, + delWordBefore: function (cm) { return cm.deleteH(-1, "word"); }, + delWordAfter: function (cm) { return cm.deleteH(1, "word"); }, + delGroupBefore: function (cm) { return cm.deleteH(-1, "group"); }, + delGroupAfter: function (cm) { return cm.deleteH(1, "group"); }, + indentAuto: function (cm) { return cm.indentSelection("smart"); }, + indentMore: function (cm) { return cm.indentSelection("add"); }, + indentLess: function (cm) { return cm.indentSelection("subtract"); }, + insertTab: function (cm) { return cm.replaceSelection("\t"); }, + insertSoftTab: function (cm) { + var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize; + for (var i = 0; i < ranges.length; i++) { + var pos = ranges[i].from(); + var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize); + spaces.push(spaceStr(tabSize - col % tabSize)); + } + cm.replaceSelections(spaces); + }, + defaultTab: function (cm) { + if (cm.somethingSelected()) { cm.indentSelection("add"); } + else { cm.execCommand("insertTab"); } + }, + // Swap the two chars left and right of each selection's head. + // Move cursor behind the two swapped characters afterwards. + // + // Doesn't consider line feeds a character. + // Doesn't scan more than one line above to find a character. + // Doesn't do anything on an empty line. + // Doesn't do anything with non-empty selections. + transposeChars: function (cm) { return runInOp(cm, function () { + var ranges = cm.listSelections(), newSel = []; + for (var i = 0; i < ranges.length; i++) { + if (!ranges[i].empty()) { continue } + var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text; + if (line) { + if (cur.ch == line.length) { cur = new Pos(cur.line, cur.ch - 1); } + if (cur.ch > 0) { + cur = new Pos(cur.line, cur.ch + 1); + cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2), + Pos(cur.line, cur.ch - 2), cur, "+transpose"); + } else if (cur.line > cm.doc.first) { + var prev = getLine(cm.doc, cur.line - 1).text; + if (prev) { + cur = new Pos(cur.line, 1); + cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() + + prev.charAt(prev.length - 1), + Pos(cur.line - 1, prev.length - 1), cur, "+transpose"); + } + } + } + newSel.push(new Range(cur, cur)); + } + cm.setSelections(newSel); + }); }, + newlineAndIndent: function (cm) { return runInOp(cm, function () { + var sels = cm.listSelections(); + for (var i = sels.length - 1; i >= 0; i--) + { cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input"); } + sels = cm.listSelections(); + for (var i$1 = 0; i$1 < sels.length; i$1++) + { cm.indentLine(sels[i$1].from().line, null, true); } + ensureCursorVisible(cm); + }); }, + openLine: function (cm) { return cm.replaceSelection("\n", "start"); }, + toggleOverwrite: function (cm) { return cm.toggleOverwrite(); } + }; + + + function lineStart(cm, lineN) { + var line = getLine(cm.doc, lineN); + var visual = visualLine(line); + if (visual != line) { lineN = lineNo(visual); } + return endOfLine(true, cm, visual, lineN, 1) + } + function lineEnd(cm, lineN) { + var line = getLine(cm.doc, lineN); + var visual = visualLineEnd(line); + if (visual != line) { lineN = lineNo(visual); } + return endOfLine(true, cm, line, lineN, -1) + } + function lineStartSmart(cm, pos) { + var start = lineStart(cm, pos.line); + var line = getLine(cm.doc, start.line); + var order = getOrder(line, cm.doc.direction); + if (!order || order[0].level == 0) { + var firstNonWS = Math.max(start.ch, line.text.search(/\S/)); + var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch; + return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky) + } + return start + } + + // Run a handler that was bound to a key. + function doHandleBinding(cm, bound, dropShift) { + if (typeof bound == "string") { + bound = commands[bound]; + if (!bound) { return false } + } + // Ensure previous input has been read, so that the handler sees a + // consistent view of the document + cm.display.input.ensurePolled(); + var prevShift = cm.display.shift, done = false; + try { + if (cm.isReadOnly()) { cm.state.suppressEdits = true; } + if (dropShift) { cm.display.shift = false; } + done = bound(cm) != Pass; + } finally { + cm.display.shift = prevShift; + cm.state.suppressEdits = false; + } + return done + } + + function lookupKeyForEditor(cm, name, handle) { + for (var i = 0; i < cm.state.keyMaps.length; i++) { + var result = lookupKey(name, cm.state.keyMaps[i], handle, cm); + if (result) { return result } + } + return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm)) + || lookupKey(name, cm.options.keyMap, handle, cm) + } + + // Note that, despite the name, this function is also used to check + // for bound mouse clicks. + + var stopSeq = new Delayed; + + function dispatchKey(cm, name, e, handle) { + var seq = cm.state.keySeq; + if (seq) { + if (isModifierKey(name)) { return "handled" } + if (/\'$/.test(name)) + { cm.state.keySeq = null; } + else + { stopSeq.set(50, function () { + if (cm.state.keySeq == seq) { + cm.state.keySeq = null; + cm.display.input.reset(); + } + }); } + if (dispatchKeyInner(cm, seq + " " + name, e, handle)) { return true } + } + return dispatchKeyInner(cm, name, e, handle) + } + + function dispatchKeyInner(cm, name, e, handle) { + var result = lookupKeyForEditor(cm, name, handle); + + if (result == "multi") + { cm.state.keySeq = name; } + if (result == "handled") + { signalLater(cm, "keyHandled", cm, name, e); } + + if (result == "handled" || result == "multi") { + e_preventDefault(e); + restartBlink(cm); + } + + return !!result + } + + // Handle a key from the keydown event. + function handleKeyBinding(cm, e) { + var name = keyName(e, true); + if (!name) { return false } + + if (e.shiftKey && !cm.state.keySeq) { + // First try to resolve full name (including 'Shift-'). Failing + // that, see if there is a cursor-motion command (starting with + // 'go') bound to the keyname without 'Shift-'. + return dispatchKey(cm, "Shift-" + name, e, function (b) { return doHandleBinding(cm, b, true); }) + || dispatchKey(cm, name, e, function (b) { + if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion) + { return doHandleBinding(cm, b) } + }) + } else { + return dispatchKey(cm, name, e, function (b) { return doHandleBinding(cm, b); }) + } + } + + // Handle a key from the keypress event + function handleCharBinding(cm, e, ch) { + return dispatchKey(cm, "'" + ch + "'", e, function (b) { return doHandleBinding(cm, b, true); }) + } + + var lastStoppedKey = null; + function onKeyDown(e) { + var cm = this; + if (e.target && e.target != cm.display.input.getField()) { return } + cm.curOp.focus = activeElt(); + if (signalDOMEvent(cm, e)) { return } + // IE does strange things with escape. + if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; } + var code = e.keyCode; + cm.display.shift = code == 16 || e.shiftKey; + var handled = handleKeyBinding(cm, e); + if (presto) { + lastStoppedKey = handled ? code : null; + // Opera has no cut event... we try to at least catch the key combo + if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey)) + { cm.replaceSelection("", null, "cut"); } + } + if (gecko && !mac && !handled && code == 46 && e.shiftKey && !e.ctrlKey && document.execCommand) + { document.execCommand("cut"); } + + // Turn mouse into crosshair when Alt is held on Mac. + if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className)) + { showCrossHair(cm); } + } + + function showCrossHair(cm) { + var lineDiv = cm.display.lineDiv; + addClass(lineDiv, "CodeMirror-crosshair"); + + function up(e) { + if (e.keyCode == 18 || !e.altKey) { + rmClass(lineDiv, "CodeMirror-crosshair"); + off(document, "keyup", up); + off(document, "mouseover", up); + } + } + on(document, "keyup", up); + on(document, "mouseover", up); + } + + function onKeyUp(e) { + if (e.keyCode == 16) { this.doc.sel.shift = false; } + signalDOMEvent(this, e); + } + + function onKeyPress(e) { + var cm = this; + if (e.target && e.target != cm.display.input.getField()) { return } + if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) { return } + var keyCode = e.keyCode, charCode = e.charCode; + if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return} + if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) { return } + var ch = String.fromCharCode(charCode == null ? keyCode : charCode); + // Some browsers fire keypress events for backspace + if (ch == "\x08") { return } + if (handleCharBinding(cm, e, ch)) { return } + cm.display.input.onKeyPress(e); + } + + var DOUBLECLICK_DELAY = 400; + + var PastClick = function(time, pos, button) { + this.time = time; + this.pos = pos; + this.button = button; + }; + + PastClick.prototype.compare = function (time, pos, button) { + return this.time + DOUBLECLICK_DELAY > time && + cmp(pos, this.pos) == 0 && button == this.button + }; + + var lastClick, lastDoubleClick; + function clickRepeat(pos, button) { + var now = +new Date; + if (lastDoubleClick && lastDoubleClick.compare(now, pos, button)) { + lastClick = lastDoubleClick = null; + return "triple" + } else if (lastClick && lastClick.compare(now, pos, button)) { + lastDoubleClick = new PastClick(now, pos, button); + lastClick = null; + return "double" + } else { + lastClick = new PastClick(now, pos, button); + lastDoubleClick = null; + return "single" + } + } + + // A mouse down can be a single click, double click, triple click, + // start of selection drag, start of text drag, new cursor + // (ctrl-click), rectangle drag (alt-drag), or xwin + // middle-click-paste. Or it might be a click on something we should + // not interfere with, such as a scrollbar or widget. + function onMouseDown(e) { + var cm = this, display = cm.display; + if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return } + display.input.ensurePolled(); + display.shift = e.shiftKey; + + if (eventInWidget(display, e)) { + if (!webkit) { + // Briefly turn off draggability, to allow widgets to do + // normal dragging things. + display.scroller.draggable = false; + setTimeout(function () { return display.scroller.draggable = true; }, 100); + } + return + } + if (clickInGutter(cm, e)) { return } + var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single"; + window.focus(); + + // #3261: make sure, that we're not starting a second selection + if (button == 1 && cm.state.selectingText) + { cm.state.selectingText(e); } + + if (pos && handleMappedButton(cm, button, pos, repeat, e)) { return } + + if (button == 1) { + if (pos) { leftButtonDown(cm, pos, repeat, e); } + else if (e_target(e) == display.scroller) { e_preventDefault(e); } + } else if (button == 2) { + if (pos) { extendSelection(cm.doc, pos); } + setTimeout(function () { return display.input.focus(); }, 20); + } else if (button == 3) { + if (captureRightClick) { cm.display.input.onContextMenu(e); } + else { delayBlurEvent(cm); } + } + } + + function handleMappedButton(cm, button, pos, repeat, event) { + var name = "Click"; + if (repeat == "double") { name = "Double" + name; } + else if (repeat == "triple") { name = "Triple" + name; } + name = (button == 1 ? "Left" : button == 2 ? "Middle" : "Right") + name; + + return dispatchKey(cm, addModifierNames(name, event), event, function (bound) { + if (typeof bound == "string") { bound = commands[bound]; } + if (!bound) { return false } + var done = false; + try { + if (cm.isReadOnly()) { cm.state.suppressEdits = true; } + done = bound(cm, pos) != Pass; + } finally { + cm.state.suppressEdits = false; + } + return done + }) + } + + function configureMouse(cm, repeat, event) { + var option = cm.getOption("configureMouse"); + var value = option ? option(cm, repeat, event) : {}; + if (value.unit == null) { + var rect = chromeOS ? event.shiftKey && event.metaKey : event.altKey; + value.unit = rect ? "rectangle" : repeat == "single" ? "char" : repeat == "double" ? "word" : "line"; + } + if (value.extend == null || cm.doc.extend) { value.extend = cm.doc.extend || event.shiftKey; } + if (value.addNew == null) { value.addNew = mac ? event.metaKey : event.ctrlKey; } + if (value.moveOnDrag == null) { value.moveOnDrag = !(mac ? event.altKey : event.ctrlKey); } + return value + } + + function leftButtonDown(cm, pos, repeat, event) { + if (ie) { setTimeout(bind(ensureFocus, cm), 0); } + else { cm.curOp.focus = activeElt(); } + + var behavior = configureMouse(cm, repeat, event); + + var sel = cm.doc.sel, contained; + if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() && + repeat == "single" && (contained = sel.contains(pos)) > -1 && + (cmp((contained = sel.ranges[contained]).from(), pos) < 0 || pos.xRel > 0) && + (cmp(contained.to(), pos) > 0 || pos.xRel < 0)) + { leftButtonStartDrag(cm, event, pos, behavior); } + else + { leftButtonSelect(cm, event, pos, behavior); } + } + + // Start a text drag. When it ends, see if any dragging actually + // happen, and treat as a click if it didn't. + function leftButtonStartDrag(cm, event, pos, behavior) { + var display = cm.display, moved = false; + var dragEnd = operation(cm, function (e) { + if (webkit) { display.scroller.draggable = false; } + cm.state.draggingText = false; + if (cm.state.delayingBlurEvent) { + if (cm.hasFocus()) { cm.state.delayingBlurEvent = false; } + else { delayBlurEvent(cm); } + } + off(display.wrapper.ownerDocument, "mouseup", dragEnd); + off(display.wrapper.ownerDocument, "mousemove", mouseMove); + off(display.scroller, "dragstart", dragStart); + off(display.scroller, "drop", dragEnd); + if (!moved) { + e_preventDefault(e); + if (!behavior.addNew) + { extendSelection(cm.doc, pos, null, null, behavior.extend); } + // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081) + if ((webkit && !safari) || ie && ie_version == 9) + { setTimeout(function () {display.wrapper.ownerDocument.body.focus({preventScroll: true}); display.input.focus();}, 20); } + else + { display.input.focus(); } + } + }); + var mouseMove = function(e2) { + moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clientY - e2.clientY) >= 10; + }; + var dragStart = function () { return moved = true; }; + // Let the drag handler handle this. + if (webkit) { display.scroller.draggable = true; } + cm.state.draggingText = dragEnd; + dragEnd.copy = !behavior.moveOnDrag; + on(display.wrapper.ownerDocument, "mouseup", dragEnd); + on(display.wrapper.ownerDocument, "mousemove", mouseMove); + on(display.scroller, "dragstart", dragStart); + on(display.scroller, "drop", dragEnd); + + cm.state.delayingBlurEvent = true; + setTimeout(function () { return display.input.focus(); }, 20); + // IE's approach to draggable + if (display.scroller.dragDrop) { display.scroller.dragDrop(); } + } + + function rangeForUnit(cm, pos, unit) { + if (unit == "char") { return new Range(pos, pos) } + if (unit == "word") { return cm.findWordAt(pos) } + if (unit == "line") { return new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))) } + var result = unit(cm, pos); + return new Range(result.from, result.to) + } + + // Normal selection, as opposed to text dragging. + function leftButtonSelect(cm, event, start, behavior) { + if (ie) { delayBlurEvent(cm); } + var display = cm.display, doc = cm.doc; + e_preventDefault(event); + + var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges; + if (behavior.addNew && !behavior.extend) { + ourIndex = doc.sel.contains(start); + if (ourIndex > -1) + { ourRange = ranges[ourIndex]; } + else + { ourRange = new Range(start, start); } + } else { + ourRange = doc.sel.primary(); + ourIndex = doc.sel.primIndex; + } + + if (behavior.unit == "rectangle") { + if (!behavior.addNew) { ourRange = new Range(start, start); } + start = posFromMouse(cm, event, true, true); + ourIndex = -1; + } else { + var range = rangeForUnit(cm, start, behavior.unit); + if (behavior.extend) + { ourRange = extendRange(ourRange, range.anchor, range.head, behavior.extend); } + else + { ourRange = range; } + } + + if (!behavior.addNew) { + ourIndex = 0; + setSelection(doc, new Selection([ourRange], 0), sel_mouse); + startSel = doc.sel; + } else if (ourIndex == -1) { + ourIndex = ranges.length; + setSelection(doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex), + {scroll: false, origin: "*mouse"}); + } else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) { + setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0), + {scroll: false, origin: "*mouse"}); + startSel = doc.sel; + } else { + replaceOneSelection(doc, ourIndex, ourRange, sel_mouse); + } + + var lastPos = start; + function extendTo(pos) { + if (cmp(lastPos, pos) == 0) { return } + lastPos = pos; + + if (behavior.unit == "rectangle") { + var ranges = [], tabSize = cm.options.tabSize; + var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize); + var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize); + var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol); + for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line)); + line <= end; line++) { + var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize); + if (left == right) + { ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); } + else if (text.length > leftPos) + { ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); } + } + if (!ranges.length) { ranges.push(new Range(start, start)); } + setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), + {origin: "*mouse", scroll: false}); + cm.scrollIntoView(pos); + } else { + var oldRange = ourRange; + var range = rangeForUnit(cm, pos, behavior.unit); + var anchor = oldRange.anchor, head; + if (cmp(range.anchor, anchor) > 0) { + head = range.head; + anchor = minPos(oldRange.from(), range.anchor); + } else { + head = range.anchor; + anchor = maxPos(oldRange.to(), range.head); + } + var ranges$1 = startSel.ranges.slice(0); + ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head)); + setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse); + } + } + + var editorSize = display.wrapper.getBoundingClientRect(); + // Used to ensure timeout re-tries don't fire when another extend + // happened in the meantime (clearTimeout isn't reliable -- at + // least on Chrome, the timeouts still happen even when cleared, + // if the clear happens after their scheduled firing time). + var counter = 0; + + function extend(e) { + var curCount = ++counter; + var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle"); + if (!cur) { return } + if (cmp(cur, lastPos) != 0) { + cm.curOp.focus = activeElt(); + extendTo(cur); + var visible = visibleLines(display, doc); + if (cur.line >= visible.to || cur.line < visible.from) + { setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); } + } else { + var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0; + if (outside) { setTimeout(operation(cm, function () { + if (counter != curCount) { return } + display.scroller.scrollTop += outside; + extend(e); + }), 50); } + } + } + + function done(e) { + cm.state.selectingText = false; + counter = Infinity; + // If e is null or undefined we interpret this as someone trying + // to explicitly cancel the selection rather than the user + // letting go of the mouse button. + if (e) { + e_preventDefault(e); + display.input.focus(); + } + off(display.wrapper.ownerDocument, "mousemove", move); + off(display.wrapper.ownerDocument, "mouseup", up); + doc.history.lastSelOrigin = null; + } + + var move = operation(cm, function (e) { + if (e.buttons === 0 || !e_button(e)) { done(e); } + else { extend(e); } + }); + var up = operation(cm, done); + cm.state.selectingText = up; + on(display.wrapper.ownerDocument, "mousemove", move); + on(display.wrapper.ownerDocument, "mouseup", up); + } + + // Used when mouse-selecting to adjust the anchor to the proper side + // of a bidi jump depending on the visual position of the head. + function bidiSimplify(cm, range) { + var anchor = range.anchor; + var head = range.head; + var anchorLine = getLine(cm.doc, anchor.line); + if (cmp(anchor, head) == 0 && anchor.sticky == head.sticky) { return range } + var order = getOrder(anchorLine); + if (!order) { return range } + var index = getBidiPartAt(order, anchor.ch, anchor.sticky), part = order[index]; + if (part.from != anchor.ch && part.to != anchor.ch) { return range } + var boundary = index + ((part.from == anchor.ch) == (part.level != 1) ? 0 : 1); + if (boundary == 0 || boundary == order.length) { return range } + + // Compute the relative visual position of the head compared to the + // anchor (<0 is to the left, >0 to the right) + var leftSide; + if (head.line != anchor.line) { + leftSide = (head.line - anchor.line) * (cm.doc.direction == "ltr" ? 1 : -1) > 0; + } else { + var headIndex = getBidiPartAt(order, head.ch, head.sticky); + var dir = headIndex - index || (head.ch - anchor.ch) * (part.level == 1 ? -1 : 1); + if (headIndex == boundary - 1 || headIndex == boundary) + { leftSide = dir < 0; } + else + { leftSide = dir > 0; } + } + + var usePart = order[boundary + (leftSide ? -1 : 0)]; + var from = leftSide == (usePart.level == 1); + var ch = from ? usePart.from : usePart.to, sticky = from ? "after" : "before"; + return anchor.ch == ch && anchor.sticky == sticky ? range : new Range(new Pos(anchor.line, ch, sticky), head) + } + + + // Determines whether an event happened in the gutter, and fires the + // handlers for the corresponding event. + function gutterEvent(cm, e, type, prevent) { + var mX, mY; + if (e.touches) { + mX = e.touches[0].clientX; + mY = e.touches[0].clientY; + } else { + try { mX = e.clientX; mY = e.clientY; } + catch(e$1) { return false } + } + if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false } + if (prevent) { e_preventDefault(e); } + + var display = cm.display; + var lineBox = display.lineDiv.getBoundingClientRect(); + + if (mY > lineBox.bottom || !hasHandler(cm, type)) { return e_defaultPrevented(e) } + mY -= lineBox.top - display.viewOffset; + + for (var i = 0; i < cm.display.gutterSpecs.length; ++i) { + var g = display.gutters.childNodes[i]; + if (g && g.getBoundingClientRect().right >= mX) { + var line = lineAtHeight(cm.doc, mY); + var gutter = cm.display.gutterSpecs[i]; + signal(cm, type, cm, line, gutter.className, e); + return e_defaultPrevented(e) + } + } + } + + function clickInGutter(cm, e) { + return gutterEvent(cm, e, "gutterClick", true) + } + + // CONTEXT MENU HANDLING + + // To make the context menu work, we need to briefly unhide the + // textarea (making it as unobtrusive as possible) to let the + // right-click take effect on it. + function onContextMenu(cm, e) { + if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) { return } + if (signalDOMEvent(cm, e, "contextmenu")) { return } + if (!captureRightClick) { cm.display.input.onContextMenu(e); } + } + + function contextMenuInGutter(cm, e) { + if (!hasHandler(cm, "gutterContextMenu")) { return false } + return gutterEvent(cm, e, "gutterContextMenu", false) + } + + function themeChanged(cm) { + cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + + cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-"); + clearCaches(cm); + } + + var Init = {toString: function(){return "CodeMirror.Init"}}; + + var defaults = {}; + var optionHandlers = {}; + + function defineOptions(CodeMirror) { + var optionHandlers = CodeMirror.optionHandlers; + + function option(name, deflt, handle, notOnInit) { + CodeMirror.defaults[name] = deflt; + if (handle) { optionHandlers[name] = + notOnInit ? function (cm, val, old) {if (old != Init) { handle(cm, val, old); }} : handle; } + } + + CodeMirror.defineOption = option; + + // Passed to option handlers when there is no old value. + CodeMirror.Init = Init; + + // These two are, on init, called from the constructor because they + // have to be initialized before the editor can start at all. + option("value", "", function (cm, val) { return cm.setValue(val); }, true); + option("mode", null, function (cm, val) { + cm.doc.modeOption = val; + loadMode(cm); + }, true); + + option("indentUnit", 2, loadMode, true); + option("indentWithTabs", false); + option("smartIndent", true); + option("tabSize", 4, function (cm) { + resetModeState(cm); + clearCaches(cm); + regChange(cm); + }, true); + + option("lineSeparator", null, function (cm, val) { + cm.doc.lineSep = val; + if (!val) { return } + var newBreaks = [], lineNo = cm.doc.first; + cm.doc.iter(function (line) { + for (var pos = 0;;) { + var found = line.text.indexOf(val, pos); + if (found == -1) { break } + pos = found + val.length; + newBreaks.push(Pos(lineNo, found)); + } + lineNo++; + }); + for (var i = newBreaks.length - 1; i >= 0; i--) + { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); } + }); + option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) { + cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g"); + if (old != Init) { cm.refresh(); } + }); + option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true); + option("electricChars", true); + option("inputStyle", mobile ? "contenteditable" : "textarea", function () { + throw new Error("inputStyle can not (yet) be changed in a running editor") // FIXME + }, true); + option("spellcheck", false, function (cm, val) { return cm.getInputField().spellcheck = val; }, true); + option("autocorrect", false, function (cm, val) { return cm.getInputField().autocorrect = val; }, true); + option("autocapitalize", false, function (cm, val) { return cm.getInputField().autocapitalize = val; }, true); + option("rtlMoveVisually", !windows); + option("wholeLineUpdateBefore", true); + + option("theme", "default", function (cm) { + themeChanged(cm); + updateGutters(cm); + }, true); + option("keyMap", "default", function (cm, val, old) { + var next = getKeyMap(val); + var prev = old != Init && getKeyMap(old); + if (prev && prev.detach) { prev.detach(cm, next); } + if (next.attach) { next.attach(cm, prev || null); } + }); + option("extraKeys", null); + option("configureMouse", null); + + option("lineWrapping", false, wrappingChanged, true); + option("gutters", [], function (cm, val) { + cm.display.gutterSpecs = getGutters(val, cm.options.lineNumbers); + updateGutters(cm); + }, true); + option("fixedGutter", true, function (cm, val) { + cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0"; + cm.refresh(); + }, true); + option("coverGutterNextToScrollbar", false, function (cm) { return updateScrollbars(cm); }, true); + option("scrollbarStyle", "native", function (cm) { + initScrollbars(cm); + updateScrollbars(cm); + cm.display.scrollbars.setScrollTop(cm.doc.scrollTop); + cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft); + }, true); + option("lineNumbers", false, function (cm, val) { + cm.display.gutterSpecs = getGutters(cm.options.gutters, val); + updateGutters(cm); + }, true); + option("firstLineNumber", 1, updateGutters, true); + option("lineNumberFormatter", function (integer) { return integer; }, updateGutters, true); + option("showCursorWhenSelecting", false, updateSelection, true); + + option("resetSelectionOnContextMenu", true); + option("lineWiseCopyCut", true); + option("pasteLinesPerSelection", true); + option("selectionsMayTouch", false); + + option("readOnly", false, function (cm, val) { + if (val == "nocursor") { + onBlur(cm); + cm.display.input.blur(); + } + cm.display.input.readOnlyChanged(val); + }); + + option("screenReaderLabel", null, function (cm, val) { + val = (val === '') ? null : val; + cm.display.input.screenReaderLabelChanged(val); + }); + + option("disableInput", false, function (cm, val) {if (!val) { cm.display.input.reset(); }}, true); + option("dragDrop", true, dragDropChanged); + option("allowDropFileTypes", null); + + option("cursorBlinkRate", 530); + option("cursorScrollMargin", 0); + option("cursorHeight", 1, updateSelection, true); + option("singleCursorHeightPerLine", true, updateSelection, true); + option("workTime", 100); + option("workDelay", 100); + option("flattenSpans", true, resetModeState, true); + option("addModeClass", false, resetModeState, true); + option("pollInterval", 100); + option("undoDepth", 200, function (cm, val) { return cm.doc.history.undoDepth = val; }); + option("historyEventDelay", 1250); + option("viewportMargin", 10, function (cm) { return cm.refresh(); }, true); + option("maxHighlightLength", 10000, resetModeState, true); + option("moveInputWithCursor", true, function (cm, val) { + if (!val) { cm.display.input.resetPosition(); } + }); + + option("tabindex", null, function (cm, val) { return cm.display.input.getField().tabIndex = val || ""; }); + option("autofocus", null); + option("direction", "ltr", function (cm, val) { return cm.doc.setDirection(val); }, true); + option("phrases", null); + } + + function dragDropChanged(cm, value, old) { + var wasOn = old && old != Init; + if (!value != !wasOn) { + var funcs = cm.display.dragFunctions; + var toggle = value ? on : off; + toggle(cm.display.scroller, "dragstart", funcs.start); + toggle(cm.display.scroller, "dragenter", funcs.enter); + toggle(cm.display.scroller, "dragover", funcs.over); + toggle(cm.display.scroller, "dragleave", funcs.leave); + toggle(cm.display.scroller, "drop", funcs.drop); + } + } + + function wrappingChanged(cm) { + if (cm.options.lineWrapping) { + addClass(cm.display.wrapper, "CodeMirror-wrap"); + cm.display.sizer.style.minWidth = ""; + cm.display.sizerWidth = null; + } else { + rmClass(cm.display.wrapper, "CodeMirror-wrap"); + findMaxLine(cm); + } + estimateLineHeights(cm); + regChange(cm); + clearCaches(cm); + setTimeout(function () { return updateScrollbars(cm); }, 100); + } + + // A CodeMirror instance represents an editor. This is the object + // that user code is usually dealing with. + + function CodeMirror(place, options) { + var this$1 = this; + + if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options) } + + this.options = options = options ? copyObj(options) : {}; + // Determine effective options based on given values and defaults. + copyObj(defaults, options, false); + + var doc = options.value; + if (typeof doc == "string") { doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction); } + else if (options.mode) { doc.modeOption = options.mode; } + this.doc = doc; + + var input = new CodeMirror.inputStyles[options.inputStyle](this); + var display = this.display = new Display(place, doc, input, options); + display.wrapper.CodeMirror = this; + themeChanged(this); + if (options.lineWrapping) + { this.display.wrapper.className += " CodeMirror-wrap"; } + initScrollbars(this); + + this.state = { + keyMaps: [], // stores maps added by addKeyMap + overlays: [], // highlighting overlays, as added by addOverlay + modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info + overwrite: false, + delayingBlurEvent: false, + focused: false, + suppressEdits: false, // used to disable editing during key handlers when in readOnly mode + pasteIncoming: -1, cutIncoming: -1, // help recognize paste/cut edits in input.poll + selectingText: false, + draggingText: false, + highlight: new Delayed(), // stores highlight worker timeout + keySeq: null, // Unfinished key sequence + specialChars: null + }; + + if (options.autofocus && !mobile) { display.input.focus(); } + + // Override magic textarea content restore that IE sometimes does + // on our hidden textarea on reload + if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20); } + + registerEventHandlers(this); + ensureGlobalHandlers(); + + startOperation(this); + this.curOp.forceUpdate = true; + attachDoc(this, doc); + + if ((options.autofocus && !mobile) || this.hasFocus()) + { setTimeout(function () { + if (this$1.hasFocus() && !this$1.state.focused) { onFocus(this$1); } + }, 20); } + else + { onBlur(this); } + + for (var opt in optionHandlers) { if (optionHandlers.hasOwnProperty(opt)) + { optionHandlers[opt](this, options[opt], Init); } } + maybeUpdateLineNumberWidth(this); + if (options.finishInit) { options.finishInit(this); } + for (var i = 0; i < initHooks.length; ++i) { initHooks[i](this); } + endOperation(this); + // Suppress optimizelegibility in Webkit, since it breaks text + // measuring on line wrapping boundaries. + if (webkit && options.lineWrapping && + getComputedStyle(display.lineDiv).textRendering == "optimizelegibility") + { display.lineDiv.style.textRendering = "auto"; } + } + + // The default configuration options. + CodeMirror.defaults = defaults; + // Functions to run when options are changed. + CodeMirror.optionHandlers = optionHandlers; + + // Attach the necessary event handlers when initializing the editor + function registerEventHandlers(cm) { + var d = cm.display; + on(d.scroller, "mousedown", operation(cm, onMouseDown)); + // Older IE's will not fire a second mousedown for a double click + if (ie && ie_version < 11) + { on(d.scroller, "dblclick", operation(cm, function (e) { + if (signalDOMEvent(cm, e)) { return } + var pos = posFromMouse(cm, e); + if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) { return } + e_preventDefault(e); + var word = cm.findWordAt(pos); + extendSelection(cm.doc, word.anchor, word.head); + })); } + else + { on(d.scroller, "dblclick", function (e) { return signalDOMEvent(cm, e) || e_preventDefault(e); }); } + // Some browsers fire contextmenu *after* opening the menu, at + // which point we can't mess with it anymore. Context menu is + // handled in onMouseDown for these browsers. + on(d.scroller, "contextmenu", function (e) { return onContextMenu(cm, e); }); + on(d.input.getField(), "contextmenu", function (e) { + if (!d.scroller.contains(e.target)) { onContextMenu(cm, e); } + }); + + // Used to suppress mouse event handling when a touch happens + var touchFinished, prevTouch = {end: 0}; + function finishTouch() { + if (d.activeTouch) { + touchFinished = setTimeout(function () { return d.activeTouch = null; }, 1000); + prevTouch = d.activeTouch; + prevTouch.end = +new Date; + } + } + function isMouseLikeTouchEvent(e) { + if (e.touches.length != 1) { return false } + var touch = e.touches[0]; + return touch.radiusX <= 1 && touch.radiusY <= 1 + } + function farAway(touch, other) { + if (other.left == null) { return true } + var dx = other.left - touch.left, dy = other.top - touch.top; + return dx * dx + dy * dy > 20 * 20 + } + on(d.scroller, "touchstart", function (e) { + if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e) && !clickInGutter(cm, e)) { + d.input.ensurePolled(); + clearTimeout(touchFinished); + var now = +new Date; + d.activeTouch = {start: now, moved: false, + prev: now - prevTouch.end <= 300 ? prevTouch : null}; + if (e.touches.length == 1) { + d.activeTouch.left = e.touches[0].pageX; + d.activeTouch.top = e.touches[0].pageY; + } + } + }); + on(d.scroller, "touchmove", function () { + if (d.activeTouch) { d.activeTouch.moved = true; } + }); + on(d.scroller, "touchend", function (e) { + var touch = d.activeTouch; + if (touch && !eventInWidget(d, e) && touch.left != null && + !touch.moved && new Date - touch.start < 300) { + var pos = cm.coordsChar(d.activeTouch, "page"), range; + if (!touch.prev || farAway(touch, touch.prev)) // Single tap + { range = new Range(pos, pos); } + else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap + { range = cm.findWordAt(pos); } + else // Triple tap + { range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))); } + cm.setSelection(range.anchor, range.head); + cm.focus(); + e_preventDefault(e); + } + finishTouch(); + }); + on(d.scroller, "touchcancel", finishTouch); + + // Sync scrolling between fake scrollbars and real scrollable + // area, ensure viewport is updated when scrolling. + on(d.scroller, "scroll", function () { + if (d.scroller.clientHeight) { + updateScrollTop(cm, d.scroller.scrollTop); + setScrollLeft(cm, d.scroller.scrollLeft, true); + signal(cm, "scroll", cm); + } + }); + + // Listen to wheel events in order to try and update the viewport on time. + on(d.scroller, "mousewheel", function (e) { return onScrollWheel(cm, e); }); + on(d.scroller, "DOMMouseScroll", function (e) { return onScrollWheel(cm, e); }); + + // Prevent wrapper from ever scrolling + on(d.wrapper, "scroll", function () { return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; }); + + d.dragFunctions = { + enter: function (e) {if (!signalDOMEvent(cm, e)) { e_stop(e); }}, + over: function (e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }}, + start: function (e) { return onDragStart(cm, e); }, + drop: operation(cm, onDrop), + leave: function (e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); }} + }; + + var inp = d.input.getField(); + on(inp, "keyup", function (e) { return onKeyUp.call(cm, e); }); + on(inp, "keydown", operation(cm, onKeyDown)); + on(inp, "keypress", operation(cm, onKeyPress)); + on(inp, "focus", function (e) { return onFocus(cm, e); }); + on(inp, "blur", function (e) { return onBlur(cm, e); }); + } + + var initHooks = []; + CodeMirror.defineInitHook = function (f) { return initHooks.push(f); }; + + // Indent the given line. The how parameter can be "smart", + // "add"/null, "subtract", or "prev". When aggressive is false + // (typically set to true for forced single-line indents), empty + // lines are not indented, and places where the mode returns Pass + // are left alone. + function indentLine(cm, n, how, aggressive) { + var doc = cm.doc, state; + if (how == null) { how = "add"; } + if (how == "smart") { + // Fall back to "prev" when the mode doesn't have an indentation + // method. + if (!doc.mode.indent) { how = "prev"; } + else { state = getContextBefore(cm, n).state; } + } + + var tabSize = cm.options.tabSize; + var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize); + if (line.stateAfter) { line.stateAfter = null; } + var curSpaceString = line.text.match(/^\s*/)[0], indentation; + if (!aggressive && !/\S/.test(line.text)) { + indentation = 0; + how = "not"; + } else if (how == "smart") { + indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text); + if (indentation == Pass || indentation > 150) { + if (!aggressive) { return } + how = "prev"; + } + } + if (how == "prev") { + if (n > doc.first) { indentation = countColumn(getLine(doc, n-1).text, null, tabSize); } + else { indentation = 0; } + } else if (how == "add") { + indentation = curSpace + cm.options.indentUnit; + } else if (how == "subtract") { + indentation = curSpace - cm.options.indentUnit; + } else if (typeof how == "number") { + indentation = curSpace + how; + } + indentation = Math.max(0, indentation); + + var indentString = "", pos = 0; + if (cm.options.indentWithTabs) + { for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";} } + if (pos < indentation) { indentString += spaceStr(indentation - pos); } + + if (indentString != curSpaceString) { + replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input"); + line.stateAfter = null; + return true + } else { + // Ensure that, if the cursor was in the whitespace at the start + // of the line, it is moved to the end of that space. + for (var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++) { + var range = doc.sel.ranges[i$1]; + if (range.head.line == n && range.head.ch < curSpaceString.length) { + var pos$1 = Pos(n, curSpaceString.length); + replaceOneSelection(doc, i$1, new Range(pos$1, pos$1)); + break + } + } + } + } + + // This will be set to a {lineWise: bool, text: [string]} object, so + // that, when pasting, we know what kind of selections the copied + // text was made out of. + var lastCopied = null; + + function setLastCopied(newLastCopied) { + lastCopied = newLastCopied; + } + + function applyTextInput(cm, inserted, deleted, sel, origin) { + var doc = cm.doc; + cm.display.shift = false; + if (!sel) { sel = doc.sel; } + + var recent = +new Date - 200; + var paste = origin == "paste" || cm.state.pasteIncoming > recent; + var textLines = splitLinesAuto(inserted), multiPaste = null; + // When pasting N lines into N selections, insert one line per selection + if (paste && sel.ranges.length > 1) { + if (lastCopied && lastCopied.text.join("\n") == inserted) { + if (sel.ranges.length % lastCopied.text.length == 0) { + multiPaste = []; + for (var i = 0; i < lastCopied.text.length; i++) + { multiPaste.push(doc.splitLines(lastCopied.text[i])); } + } + } else if (textLines.length == sel.ranges.length && cm.options.pasteLinesPerSelection) { + multiPaste = map(textLines, function (l) { return [l]; }); + } + } + + var updateInput = cm.curOp.updateInput; + // Normal behavior is to insert the new text into every selection + for (var i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--) { + var range = sel.ranges[i$1]; + var from = range.from(), to = range.to(); + if (range.empty()) { + if (deleted && deleted > 0) // Handle deletion + { from = Pos(from.line, from.ch - deleted); } + else if (cm.state.overwrite && !paste) // Handle overwrite + { to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); } + else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == textLines.join("\n")) + { from = to = Pos(from.line, 0); } + } + var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines, + origin: origin || (paste ? "paste" : cm.state.cutIncoming > recent ? "cut" : "+input")}; + makeChange(cm.doc, changeEvent); + signalLater(cm, "inputRead", cm, changeEvent); + } + if (inserted && !paste) + { triggerElectric(cm, inserted); } + + ensureCursorVisible(cm); + if (cm.curOp.updateInput < 2) { cm.curOp.updateInput = updateInput; } + cm.curOp.typing = true; + cm.state.pasteIncoming = cm.state.cutIncoming = -1; + } + + function handlePaste(e, cm) { + var pasted = e.clipboardData && e.clipboardData.getData("Text"); + if (pasted) { + e.preventDefault(); + if (!cm.isReadOnly() && !cm.options.disableInput) + { runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, "paste"); }); } + return true + } + } + + function triggerElectric(cm, inserted) { + // When an 'electric' character is inserted, immediately trigger a reindent + if (!cm.options.electricChars || !cm.options.smartIndent) { return } + var sel = cm.doc.sel; + + for (var i = sel.ranges.length - 1; i >= 0; i--) { + var range = sel.ranges[i]; + if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) { continue } + var mode = cm.getModeAt(range.head); + var indented = false; + if (mode.electricChars) { + for (var j = 0; j < mode.electricChars.length; j++) + { if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) { + indented = indentLine(cm, range.head.line, "smart"); + break + } } + } else if (mode.electricInput) { + if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch))) + { indented = indentLine(cm, range.head.line, "smart"); } + } + if (indented) { signalLater(cm, "electricInput", cm, range.head.line); } + } + } + + function copyableRanges(cm) { + var text = [], ranges = []; + for (var i = 0; i < cm.doc.sel.ranges.length; i++) { + var line = cm.doc.sel.ranges[i].head.line; + var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)}; + ranges.push(lineRange); + text.push(cm.getRange(lineRange.anchor, lineRange.head)); + } + return {text: text, ranges: ranges} + } + + function disableBrowserMagic(field, spellcheck, autocorrect, autocapitalize) { + field.setAttribute("autocorrect", autocorrect ? "" : "off"); + field.setAttribute("autocapitalize", autocapitalize ? "" : "off"); + field.setAttribute("spellcheck", !!spellcheck); + } + + function hiddenTextarea() { + var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"); + var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"); + // The textarea is kept positioned near the cursor to prevent the + // fact that it'll be scrolled into view on input from scrolling + // our fake cursor out of view. On webkit, when wrap=off, paste is + // very slow. So make the area wide instead. + if (webkit) { te.style.width = "1000px"; } + else { te.setAttribute("wrap", "off"); } + // If border: 0; -- iOS fails to open keyboard (issue #1287) + if (ios) { te.style.border = "1px solid black"; } + disableBrowserMagic(te); + return div + } + + // The publicly visible API. Note that methodOp(f) means + // 'wrap f in an operation, performed on its `this` parameter'. + + // This is not the complete set of editor methods. Most of the + // methods defined on the Doc type are also injected into + // CodeMirror.prototype, for backwards compatibility and + // convenience. + + function addEditorMethods(CodeMirror) { + var optionHandlers = CodeMirror.optionHandlers; + + var helpers = CodeMirror.helpers = {}; + + CodeMirror.prototype = { + constructor: CodeMirror, + focus: function(){window.focus(); this.display.input.focus();}, + + setOption: function(option, value) { + var options = this.options, old = options[option]; + if (options[option] == value && option != "mode") { return } + options[option] = value; + if (optionHandlers.hasOwnProperty(option)) + { operation(this, optionHandlers[option])(this, value, old); } + signal(this, "optionChange", this, option); + }, + + getOption: function(option) {return this.options[option]}, + getDoc: function() {return this.doc}, + + addKeyMap: function(map, bottom) { + this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map)); + }, + removeKeyMap: function(map) { + var maps = this.state.keyMaps; + for (var i = 0; i < maps.length; ++i) + { if (maps[i] == map || maps[i].name == map) { + maps.splice(i, 1); + return true + } } + }, + + addOverlay: methodOp(function(spec, options) { + var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec); + if (mode.startState) { throw new Error("Overlays may not be stateful.") } + insertSorted(this.state.overlays, + {mode: mode, modeSpec: spec, opaque: options && options.opaque, + priority: (options && options.priority) || 0}, + function (overlay) { return overlay.priority; }); + this.state.modeGen++; + regChange(this); + }), + removeOverlay: methodOp(function(spec) { + var overlays = this.state.overlays; + for (var i = 0; i < overlays.length; ++i) { + var cur = overlays[i].modeSpec; + if (cur == spec || typeof spec == "string" && cur.name == spec) { + overlays.splice(i, 1); + this.state.modeGen++; + regChange(this); + return + } + } + }), + + indentLine: methodOp(function(n, dir, aggressive) { + if (typeof dir != "string" && typeof dir != "number") { + if (dir == null) { dir = this.options.smartIndent ? "smart" : "prev"; } + else { dir = dir ? "add" : "subtract"; } + } + if (isLine(this.doc, n)) { indentLine(this, n, dir, aggressive); } + }), + indentSelection: methodOp(function(how) { + var ranges = this.doc.sel.ranges, end = -1; + for (var i = 0; i < ranges.length; i++) { + var range = ranges[i]; + if (!range.empty()) { + var from = range.from(), to = range.to(); + var start = Math.max(end, from.line); + end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1; + for (var j = start; j < end; ++j) + { indentLine(this, j, how); } + var newRanges = this.doc.sel.ranges; + if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0) + { replaceOneSelection(this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll); } + } else if (range.head.line > end) { + indentLine(this, range.head.line, how, true); + end = range.head.line; + if (i == this.doc.sel.primIndex) { ensureCursorVisible(this); } + } + } + }), + + // Fetch the parser token for a given character. Useful for hacks + // that want to inspect the mode state (say, for completion). + getTokenAt: function(pos, precise) { + return takeToken(this, pos, precise) + }, + + getLineTokens: function(line, precise) { + return takeToken(this, Pos(line), precise, true) + }, + + getTokenTypeAt: function(pos) { + pos = clipPos(this.doc, pos); + var styles = getLineStyles(this, getLine(this.doc, pos.line)); + var before = 0, after = (styles.length - 1) / 2, ch = pos.ch; + var type; + if (ch == 0) { type = styles[2]; } + else { for (;;) { + var mid = (before + after) >> 1; + if ((mid ? styles[mid * 2 - 1] : 0) >= ch) { after = mid; } + else if (styles[mid * 2 + 1] < ch) { before = mid + 1; } + else { type = styles[mid * 2 + 2]; break } + } } + var cut = type ? type.indexOf("overlay ") : -1; + return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1) + }, + + getModeAt: function(pos) { + var mode = this.doc.mode; + if (!mode.innerMode) { return mode } + return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode + }, + + getHelper: function(pos, type) { + return this.getHelpers(pos, type)[0] + }, + + getHelpers: function(pos, type) { + var found = []; + if (!helpers.hasOwnProperty(type)) { return found } + var help = helpers[type], mode = this.getModeAt(pos); + if (typeof mode[type] == "string") { + if (help[mode[type]]) { found.push(help[mode[type]]); } + } else if (mode[type]) { + for (var i = 0; i < mode[type].length; i++) { + var val = help[mode[type][i]]; + if (val) { found.push(val); } + } + } else if (mode.helperType && help[mode.helperType]) { + found.push(help[mode.helperType]); + } else if (help[mode.name]) { + found.push(help[mode.name]); + } + for (var i$1 = 0; i$1 < help._global.length; i$1++) { + var cur = help._global[i$1]; + if (cur.pred(mode, this) && indexOf(found, cur.val) == -1) + { found.push(cur.val); } + } + return found + }, + + getStateAfter: function(line, precise) { + var doc = this.doc; + line = clipLine(doc, line == null ? doc.first + doc.size - 1: line); + return getContextBefore(this, line + 1, precise).state + }, + + cursorCoords: function(start, mode) { + var pos, range = this.doc.sel.primary(); + if (start == null) { pos = range.head; } + else if (typeof start == "object") { pos = clipPos(this.doc, start); } + else { pos = start ? range.from() : range.to(); } + return cursorCoords(this, pos, mode || "page") + }, + + charCoords: function(pos, mode) { + return charCoords(this, clipPos(this.doc, pos), mode || "page") + }, + + coordsChar: function(coords, mode) { + coords = fromCoordSystem(this, coords, mode || "page"); + return coordsChar(this, coords.left, coords.top) + }, + + lineAtHeight: function(height, mode) { + height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top; + return lineAtHeight(this.doc, height + this.display.viewOffset) + }, + heightAtLine: function(line, mode, includeWidgets) { + var end = false, lineObj; + if (typeof line == "number") { + var last = this.doc.first + this.doc.size - 1; + if (line < this.doc.first) { line = this.doc.first; } + else if (line > last) { line = last; end = true; } + lineObj = getLine(this.doc, line); + } else { + lineObj = line; + } + return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page", includeWidgets || end).top + + (end ? this.doc.height - heightAtLine(lineObj) : 0) + }, + + defaultTextHeight: function() { return textHeight(this.display) }, + defaultCharWidth: function() { return charWidth(this.display) }, + + getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}}, + + addWidget: function(pos, node, scroll, vert, horiz) { + var display = this.display; + pos = cursorCoords(this, clipPos(this.doc, pos)); + var top = pos.bottom, left = pos.left; + node.style.position = "absolute"; + node.setAttribute("cm-ignore-events", "true"); + this.display.input.setUneditable(node); + display.sizer.appendChild(node); + if (vert == "over") { + top = pos.top; + } else if (vert == "above" || vert == "near") { + var vspace = Math.max(display.wrapper.clientHeight, this.doc.height), + hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth); + // Default to positioning above (if specified and possible); otherwise default to positioning below + if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight) + { top = pos.top - node.offsetHeight; } + else if (pos.bottom + node.offsetHeight <= vspace) + { top = pos.bottom; } + if (left + node.offsetWidth > hspace) + { left = hspace - node.offsetWidth; } + } + node.style.top = top + "px"; + node.style.left = node.style.right = ""; + if (horiz == "right") { + left = display.sizer.clientWidth - node.offsetWidth; + node.style.right = "0px"; + } else { + if (horiz == "left") { left = 0; } + else if (horiz == "middle") { left = (display.sizer.clientWidth - node.offsetWidth) / 2; } + node.style.left = left + "px"; + } + if (scroll) + { scrollIntoView(this, {left: left, top: top, right: left + node.offsetWidth, bottom: top + node.offsetHeight}); } + }, + + triggerOnKeyDown: methodOp(onKeyDown), + triggerOnKeyPress: methodOp(onKeyPress), + triggerOnKeyUp: onKeyUp, + triggerOnMouseDown: methodOp(onMouseDown), + + execCommand: function(cmd) { + if (commands.hasOwnProperty(cmd)) + { return commands[cmd].call(null, this) } + }, + + triggerElectric: methodOp(function(text) { triggerElectric(this, text); }), + + findPosH: function(from, amount, unit, visually) { + var dir = 1; + if (amount < 0) { dir = -1; amount = -amount; } + var cur = clipPos(this.doc, from); + for (var i = 0; i < amount; ++i) { + cur = findPosH(this.doc, cur, dir, unit, visually); + if (cur.hitSide) { break } + } + return cur + }, + + moveH: methodOp(function(dir, unit) { + var this$1 = this; + + this.extendSelectionsBy(function (range) { + if (this$1.display.shift || this$1.doc.extend || range.empty()) + { return findPosH(this$1.doc, range.head, dir, unit, this$1.options.rtlMoveVisually) } + else + { return dir < 0 ? range.from() : range.to() } + }, sel_move); + }), + + deleteH: methodOp(function(dir, unit) { + var sel = this.doc.sel, doc = this.doc; + if (sel.somethingSelected()) + { doc.replaceSelection("", null, "+delete"); } + else + { deleteNearSelection(this, function (range) { + var other = findPosH(doc, range.head, dir, unit, false); + return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other} + }); } + }), + + findPosV: function(from, amount, unit, goalColumn) { + var dir = 1, x = goalColumn; + if (amount < 0) { dir = -1; amount = -amount; } + var cur = clipPos(this.doc, from); + for (var i = 0; i < amount; ++i) { + var coords = cursorCoords(this, cur, "div"); + if (x == null) { x = coords.left; } + else { coords.left = x; } + cur = findPosV(this, coords, dir, unit); + if (cur.hitSide) { break } + } + return cur + }, + + moveV: methodOp(function(dir, unit) { + var this$1 = this; + + var doc = this.doc, goals = []; + var collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected(); + doc.extendSelectionsBy(function (range) { + if (collapse) + { return dir < 0 ? range.from() : range.to() } + var headPos = cursorCoords(this$1, range.head, "div"); + if (range.goalColumn != null) { headPos.left = range.goalColumn; } + goals.push(headPos.left); + var pos = findPosV(this$1, headPos, dir, unit); + if (unit == "page" && range == doc.sel.primary()) + { addToScrollTop(this$1, charCoords(this$1, pos, "div").top - headPos.top); } + return pos + }, sel_move); + if (goals.length) { for (var i = 0; i < doc.sel.ranges.length; i++) + { doc.sel.ranges[i].goalColumn = goals[i]; } } + }), + + // Find the word at the given position (as returned by coordsChar). + findWordAt: function(pos) { + var doc = this.doc, line = getLine(doc, pos.line).text; + var start = pos.ch, end = pos.ch; + if (line) { + var helper = this.getHelper(pos, "wordChars"); + if ((pos.sticky == "before" || end == line.length) && start) { --start; } else { ++end; } + var startChar = line.charAt(start); + var check = isWordChar(startChar, helper) + ? function (ch) { return isWordChar(ch, helper); } + : /\s/.test(startChar) ? function (ch) { return /\s/.test(ch); } + : function (ch) { return (!/\s/.test(ch) && !isWordChar(ch)); }; + while (start > 0 && check(line.charAt(start - 1))) { --start; } + while (end < line.length && check(line.charAt(end))) { ++end; } + } + return new Range(Pos(pos.line, start), Pos(pos.line, end)) + }, + + toggleOverwrite: function(value) { + if (value != null && value == this.state.overwrite) { return } + if (this.state.overwrite = !this.state.overwrite) + { addClass(this.display.cursorDiv, "CodeMirror-overwrite"); } + else + { rmClass(this.display.cursorDiv, "CodeMirror-overwrite"); } + + signal(this, "overwriteToggle", this, this.state.overwrite); + }, + hasFocus: function() { return this.display.input.getField() == activeElt() }, + isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) }, + + scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }), + getScrollInfo: function() { + var scroller = this.display.scroller; + return {left: scroller.scrollLeft, top: scroller.scrollTop, + height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight, + width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth, + clientHeight: displayHeight(this), clientWidth: displayWidth(this)} + }, + + scrollIntoView: methodOp(function(range, margin) { + if (range == null) { + range = {from: this.doc.sel.primary().head, to: null}; + if (margin == null) { margin = this.options.cursorScrollMargin; } + } else if (typeof range == "number") { + range = {from: Pos(range, 0), to: null}; + } else if (range.from == null) { + range = {from: range, to: null}; + } + if (!range.to) { range.to = range.from; } + range.margin = margin || 0; + + if (range.from.line != null) { + scrollToRange(this, range); + } else { + scrollToCoordsRange(this, range.from, range.to, range.margin); + } + }), + + setSize: methodOp(function(width, height) { + var this$1 = this; + + var interpret = function (val) { return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; }; + if (width != null) { this.display.wrapper.style.width = interpret(width); } + if (height != null) { this.display.wrapper.style.height = interpret(height); } + if (this.options.lineWrapping) { clearLineMeasurementCache(this); } + var lineNo = this.display.viewFrom; + this.doc.iter(lineNo, this.display.viewTo, function (line) { + if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) + { if (line.widgets[i].noHScroll) { regLineChange(this$1, lineNo, "widget"); break } } } + ++lineNo; + }); + this.curOp.forceUpdate = true; + signal(this, "refresh", this); + }), + + operation: function(f){return runInOp(this, f)}, + startOperation: function(){return startOperation(this)}, + endOperation: function(){return endOperation(this)}, + + refresh: methodOp(function() { + var oldHeight = this.display.cachedTextHeight; + regChange(this); + this.curOp.forceUpdate = true; + clearCaches(this); + scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop); + updateGutterSpace(this.display); + if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5 || this.options.lineWrapping) + { estimateLineHeights(this); } + signal(this, "refresh", this); + }), + + swapDoc: methodOp(function(doc) { + var old = this.doc; + old.cm = null; + // Cancel the current text selection if any (#5821) + if (this.state.selectingText) { this.state.selectingText(); } + attachDoc(this, doc); + clearCaches(this); + this.display.input.reset(); + scrollToCoords(this, doc.scrollLeft, doc.scrollTop); + this.curOp.forceScroll = true; + signalLater(this, "swapDoc", this, old); + return old + }), + + phrase: function(phraseText) { + var phrases = this.options.phrases; + return phrases && Object.prototype.hasOwnProperty.call(phrases, phraseText) ? phrases[phraseText] : phraseText + }, + + getInputField: function(){return this.display.input.getField()}, + getWrapperElement: function(){return this.display.wrapper}, + getScrollerElement: function(){return this.display.scroller}, + getGutterElement: function(){return this.display.gutters} + }; + eventMixin(CodeMirror); + + CodeMirror.registerHelper = function(type, name, value) { + if (!helpers.hasOwnProperty(type)) { helpers[type] = CodeMirror[type] = {_global: []}; } + helpers[type][name] = value; + }; + CodeMirror.registerGlobalHelper = function(type, name, predicate, value) { + CodeMirror.registerHelper(type, name, value); + helpers[type]._global.push({pred: predicate, val: value}); + }; + } + + // Used for horizontal relative motion. Dir is -1 or 1 (left or + // right), unit can be "codepoint", "char", "column" (like char, but + // doesn't cross line boundaries), "word" (across next word), or + // "group" (to the start of next group of word or + // non-word-non-whitespace chars). The visually param controls + // whether, in right-to-left text, direction 1 means to move towards + // the next index in the string, or towards the character to the right + // of the current position. The resulting position will have a + // hitSide=true property if it reached the end of the document. + function findPosH(doc, pos, dir, unit, visually) { + var oldPos = pos; + var origDir = dir; + var lineObj = getLine(doc, pos.line); + var lineDir = visually && doc.direction == "rtl" ? -dir : dir; + function findNextLine() { + var l = pos.line + lineDir; + if (l < doc.first || l >= doc.first + doc.size) { return false } + pos = new Pos(l, pos.ch, pos.sticky); + return lineObj = getLine(doc, l) + } + function moveOnce(boundToLine) { + var next; + if (unit == "codepoint") { + var ch = lineObj.text.charCodeAt(pos.ch + (dir > 0 ? 0 : -1)); + if (isNaN(ch)) { + next = null; + } else { + var astral = dir > 0 ? ch >= 0xD800 && ch < 0xDC00 : ch >= 0xDC00 && ch < 0xDFFF; + next = new Pos(pos.line, Math.max(0, Math.min(lineObj.text.length, pos.ch + dir * (astral ? 2 : 1))), -dir); + } + } else if (visually) { + next = moveVisually(doc.cm, lineObj, pos, dir); + } else { + next = moveLogically(lineObj, pos, dir); + } + if (next == null) { + if (!boundToLine && findNextLine()) + { pos = endOfLine(visually, doc.cm, lineObj, pos.line, lineDir); } + else + { return false } + } else { + pos = next; + } + return true + } + + if (unit == "char" || unit == "codepoint") { + moveOnce(); + } else if (unit == "column") { + moveOnce(true); + } else if (unit == "word" || unit == "group") { + var sawType = null, group = unit == "group"; + var helper = doc.cm && doc.cm.getHelper(pos, "wordChars"); + for (var first = true;; first = false) { + if (dir < 0 && !moveOnce(!first)) { break } + var cur = lineObj.text.charAt(pos.ch) || "\n"; + var type = isWordChar(cur, helper) ? "w" + : group && cur == "\n" ? "n" + : !group || /\s/.test(cur) ? null + : "p"; + if (group && !first && !type) { type = "s"; } + if (sawType && sawType != type) { + if (dir < 0) {dir = 1; moveOnce(); pos.sticky = "after";} + break + } + + if (type) { sawType = type; } + if (dir > 0 && !moveOnce(!first)) { break } + } + } + var result = skipAtomic(doc, pos, oldPos, origDir, true); + if (equalCursorPos(oldPos, result)) { result.hitSide = true; } + return result + } + + // For relative vertical movement. Dir may be -1 or 1. Unit can be + // "page" or "line". The resulting position will have a hitSide=true + // property if it reached the end of the document. + function findPosV(cm, pos, dir, unit) { + var doc = cm.doc, x = pos.left, y; + if (unit == "page") { + var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight); + var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3); + y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount; + + } else if (unit == "line") { + y = dir > 0 ? pos.bottom + 3 : pos.top - 3; + } + var target; + for (;;) { + target = coordsChar(cm, x, y); + if (!target.outside) { break } + if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break } + y += dir * 5; + } + return target + } + + // CONTENTEDITABLE INPUT STYLE + + var ContentEditableInput = function(cm) { + this.cm = cm; + this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null; + this.polling = new Delayed(); + this.composing = null; + this.gracePeriod = false; + this.readDOMTimeout = null; + }; + + ContentEditableInput.prototype.init = function (display) { + var this$1 = this; + + var input = this, cm = input.cm; + var div = input.div = display.lineDiv; + disableBrowserMagic(div, cm.options.spellcheck, cm.options.autocorrect, cm.options.autocapitalize); + + function belongsToInput(e) { + for (var t = e.target; t; t = t.parentNode) { + if (t == div) { return true } + if (/\bCodeMirror-(?:line)?widget\b/.test(t.className)) { break } + } + return false + } + + on(div, "paste", function (e) { + if (!belongsToInput(e) || signalDOMEvent(cm, e) || handlePaste(e, cm)) { return } + // IE doesn't fire input events, so we schedule a read for the pasted content in this way + if (ie_version <= 11) { setTimeout(operation(cm, function () { return this$1.updateFromDOM(); }), 20); } + }); + + on(div, "compositionstart", function (e) { + this$1.composing = {data: e.data, done: false}; + }); + on(div, "compositionupdate", function (e) { + if (!this$1.composing) { this$1.composing = {data: e.data, done: false}; } + }); + on(div, "compositionend", function (e) { + if (this$1.composing) { + if (e.data != this$1.composing.data) { this$1.readFromDOMSoon(); } + this$1.composing.done = true; + } + }); + + on(div, "touchstart", function () { return input.forceCompositionEnd(); }); + + on(div, "input", function () { + if (!this$1.composing) { this$1.readFromDOMSoon(); } + }); + + function onCopyCut(e) { + if (!belongsToInput(e) || signalDOMEvent(cm, e)) { return } + if (cm.somethingSelected()) { + setLastCopied({lineWise: false, text: cm.getSelections()}); + if (e.type == "cut") { cm.replaceSelection("", null, "cut"); } + } else if (!cm.options.lineWiseCopyCut) { + return + } else { + var ranges = copyableRanges(cm); + setLastCopied({lineWise: true, text: ranges.text}); + if (e.type == "cut") { + cm.operation(function () { + cm.setSelections(ranges.ranges, 0, sel_dontScroll); + cm.replaceSelection("", null, "cut"); + }); + } + } + if (e.clipboardData) { + e.clipboardData.clearData(); + var content = lastCopied.text.join("\n"); + // iOS exposes the clipboard API, but seems to discard content inserted into it + e.clipboardData.setData("Text", content); + if (e.clipboardData.getData("Text") == content) { + e.preventDefault(); + return + } + } + // Old-fashioned briefly-focus-a-textarea hack + var kludge = hiddenTextarea(), te = kludge.firstChild; + cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild); + te.value = lastCopied.text.join("\n"); + var hadFocus = document.activeElement; + selectInput(te); + setTimeout(function () { + cm.display.lineSpace.removeChild(kludge); + hadFocus.focus(); + if (hadFocus == div) { input.showPrimarySelection(); } + }, 50); + } + on(div, "copy", onCopyCut); + on(div, "cut", onCopyCut); + }; + + ContentEditableInput.prototype.screenReaderLabelChanged = function (label) { + // Label for screenreaders, accessibility + if(label) { + this.div.setAttribute('aria-label', label); + } else { + this.div.removeAttribute('aria-label'); + } + }; + + ContentEditableInput.prototype.prepareSelection = function () { + var result = prepareSelection(this.cm, false); + result.focus = document.activeElement == this.div; + return result + }; + + ContentEditableInput.prototype.showSelection = function (info, takeFocus) { + if (!info || !this.cm.display.view.length) { return } + if (info.focus || takeFocus) { this.showPrimarySelection(); } + this.showMultipleSelections(info); + }; + + ContentEditableInput.prototype.getSelection = function () { + return this.cm.display.wrapper.ownerDocument.getSelection() + }; + + ContentEditableInput.prototype.showPrimarySelection = function () { + var sel = this.getSelection(), cm = this.cm, prim = cm.doc.sel.primary(); + var from = prim.from(), to = prim.to(); + + if (cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom) { + sel.removeAllRanges(); + return + } + + var curAnchor = domToPos(cm, sel.anchorNode, sel.anchorOffset); + var curFocus = domToPos(cm, sel.focusNode, sel.focusOffset); + if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad && + cmp(minPos(curAnchor, curFocus), from) == 0 && + cmp(maxPos(curAnchor, curFocus), to) == 0) + { return } + + var view = cm.display.view; + var start = (from.line >= cm.display.viewFrom && posToDOM(cm, from)) || + {node: view[0].measure.map[2], offset: 0}; + var end = to.line < cm.display.viewTo && posToDOM(cm, to); + if (!end) { + var measure = view[view.length - 1].measure; + var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map; + end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]}; + } + + if (!start || !end) { + sel.removeAllRanges(); + return + } + + var old = sel.rangeCount && sel.getRangeAt(0), rng; + try { rng = range(start.node, start.offset, end.offset, end.node); } + catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible + if (rng) { + if (!gecko && cm.state.focused) { + sel.collapse(start.node, start.offset); + if (!rng.collapsed) { + sel.removeAllRanges(); + sel.addRange(rng); + } + } else { + sel.removeAllRanges(); + sel.addRange(rng); + } + if (old && sel.anchorNode == null) { sel.addRange(old); } + else if (gecko) { this.startGracePeriod(); } + } + this.rememberSelection(); + }; + + ContentEditableInput.prototype.startGracePeriod = function () { + var this$1 = this; + + clearTimeout(this.gracePeriod); + this.gracePeriod = setTimeout(function () { + this$1.gracePeriod = false; + if (this$1.selectionChanged()) + { this$1.cm.operation(function () { return this$1.cm.curOp.selectionChanged = true; }); } + }, 20); + }; + + ContentEditableInput.prototype.showMultipleSelections = function (info) { + removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors); + removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection); + }; + + ContentEditableInput.prototype.rememberSelection = function () { + var sel = this.getSelection(); + this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset; + this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset; + }; + + ContentEditableInput.prototype.selectionInEditor = function () { + var sel = this.getSelection(); + if (!sel.rangeCount) { return false } + var node = sel.getRangeAt(0).commonAncestorContainer; + return contains(this.div, node) + }; + + ContentEditableInput.prototype.focus = function () { + if (this.cm.options.readOnly != "nocursor") { + if (!this.selectionInEditor() || document.activeElement != this.div) + { this.showSelection(this.prepareSelection(), true); } + this.div.focus(); + } + }; + ContentEditableInput.prototype.blur = function () { this.div.blur(); }; + ContentEditableInput.prototype.getField = function () { return this.div }; + + ContentEditableInput.prototype.supportsTouch = function () { return true }; + + ContentEditableInput.prototype.receivedFocus = function () { + var input = this; + if (this.selectionInEditor()) + { this.pollSelection(); } + else + { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }); } + + function poll() { + if (input.cm.state.focused) { + input.pollSelection(); + input.polling.set(input.cm.options.pollInterval, poll); + } + } + this.polling.set(this.cm.options.pollInterval, poll); + }; + + ContentEditableInput.prototype.selectionChanged = function () { + var sel = this.getSelection(); + return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset || + sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset + }; + + ContentEditableInput.prototype.pollSelection = function () { + if (this.readDOMTimeout != null || this.gracePeriod || !this.selectionChanged()) { return } + var sel = this.getSelection(), cm = this.cm; + // On Android Chrome (version 56, at least), backspacing into an + // uneditable block element will put the cursor in that element, + // and then, because it's not editable, hide the virtual keyboard. + // Because Android doesn't allow us to actually detect backspace + // presses in a sane way, this code checks for when that happens + // and simulates a backspace press in this case. + if (android && chrome && this.cm.display.gutterSpecs.length && isInGutter(sel.anchorNode)) { + this.cm.triggerOnKeyDown({type: "keydown", keyCode: 8, preventDefault: Math.abs}); + this.blur(); + this.focus(); + return + } + if (this.composing) { return } + this.rememberSelection(); + var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset); + var head = domToPos(cm, sel.focusNode, sel.focusOffset); + if (anchor && head) { runInOp(cm, function () { + setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll); + if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true; } + }); } + }; + + ContentEditableInput.prototype.pollContent = function () { + if (this.readDOMTimeout != null) { + clearTimeout(this.readDOMTimeout); + this.readDOMTimeout = null; + } + + var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary(); + var from = sel.from(), to = sel.to(); + if (from.ch == 0 && from.line > cm.firstLine()) + { from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length); } + if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine()) + { to = Pos(to.line + 1, 0); } + if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false } + + var fromIndex, fromLine, fromNode; + if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) { + fromLine = lineNo(display.view[0].line); + fromNode = display.view[0].node; + } else { + fromLine = lineNo(display.view[fromIndex].line); + fromNode = display.view[fromIndex - 1].node.nextSibling; + } + var toIndex = findViewIndex(cm, to.line); + var toLine, toNode; + if (toIndex == display.view.length - 1) { + toLine = display.viewTo - 1; + toNode = display.lineDiv.lastChild; + } else { + toLine = lineNo(display.view[toIndex + 1].line) - 1; + toNode = display.view[toIndex + 1].node.previousSibling; + } + + if (!fromNode) { return false } + var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine)); + var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length)); + while (newText.length > 1 && oldText.length > 1) { + if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; } + else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; } + else { break } + } + + var cutFront = 0, cutEnd = 0; + var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length); + while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront)) + { ++cutFront; } + var newBot = lst(newText), oldBot = lst(oldText); + var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0), + oldBot.length - (oldText.length == 1 ? cutFront : 0)); + while (cutEnd < maxCutEnd && + newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) + { ++cutEnd; } + // Try to move start of change to start of selection if ambiguous + if (newText.length == 1 && oldText.length == 1 && fromLine == from.line) { + while (cutFront && cutFront > from.ch && + newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) { + cutFront--; + cutEnd++; + } + } + + newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, ""); + newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, ""); + + var chFrom = Pos(fromLine, cutFront); + var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0); + if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) { + replaceRange(cm.doc, newText, chFrom, chTo, "+input"); + return true + } + }; + + ContentEditableInput.prototype.ensurePolled = function () { + this.forceCompositionEnd(); + }; + ContentEditableInput.prototype.reset = function () { + this.forceCompositionEnd(); + }; + ContentEditableInput.prototype.forceCompositionEnd = function () { + if (!this.composing) { return } + clearTimeout(this.readDOMTimeout); + this.composing = null; + this.updateFromDOM(); + this.div.blur(); + this.div.focus(); + }; + ContentEditableInput.prototype.readFromDOMSoon = function () { + var this$1 = this; + + if (this.readDOMTimeout != null) { return } + this.readDOMTimeout = setTimeout(function () { + this$1.readDOMTimeout = null; + if (this$1.composing) { + if (this$1.composing.done) { this$1.composing = null; } + else { return } + } + this$1.updateFromDOM(); + }, 80); + }; + + ContentEditableInput.prototype.updateFromDOM = function () { + var this$1 = this; + + if (this.cm.isReadOnly() || !this.pollContent()) + { runInOp(this.cm, function () { return regChange(this$1.cm); }); } + }; + + ContentEditableInput.prototype.setUneditable = function (node) { + node.contentEditable = "false"; + }; + + ContentEditableInput.prototype.onKeyPress = function (e) { + if (e.charCode == 0 || this.composing) { return } + e.preventDefault(); + if (!this.cm.isReadOnly()) + { operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0); } + }; + + ContentEditableInput.prototype.readOnlyChanged = function (val) { + this.div.contentEditable = String(val != "nocursor"); + }; + + ContentEditableInput.prototype.onContextMenu = function () {}; + ContentEditableInput.prototype.resetPosition = function () {}; + + ContentEditableInput.prototype.needsContentAttribute = true; + + function posToDOM(cm, pos) { + var view = findViewForLine(cm, pos.line); + if (!view || view.hidden) { return null } + var line = getLine(cm.doc, pos.line); + var info = mapFromLineView(view, line, pos.line); + + var order = getOrder(line, cm.doc.direction), side = "left"; + if (order) { + var partPos = getBidiPartAt(order, pos.ch); + side = partPos % 2 ? "right" : "left"; + } + var result = nodeAndOffsetInLineMap(info.map, pos.ch, side); + result.offset = result.collapse == "right" ? result.end : result.start; + return result + } + + function isInGutter(node) { + for (var scan = node; scan; scan = scan.parentNode) + { if (/CodeMirror-gutter-wrapper/.test(scan.className)) { return true } } + return false + } + + function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos } + + function domTextBetween(cm, from, to, fromLine, toLine) { + var text = "", closing = false, lineSep = cm.doc.lineSeparator(), extraLinebreak = false; + function recognizeMarker(id) { return function (marker) { return marker.id == id; } } + function close() { + if (closing) { + text += lineSep; + if (extraLinebreak) { text += lineSep; } + closing = extraLinebreak = false; + } + } + function addText(str) { + if (str) { + close(); + text += str; + } + } + function walk(node) { + if (node.nodeType == 1) { + var cmText = node.getAttribute("cm-text"); + if (cmText) { + addText(cmText); + return + } + var markerID = node.getAttribute("cm-marker"), range; + if (markerID) { + var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID)); + if (found.length && (range = found[0].find(0))) + { addText(getBetween(cm.doc, range.from, range.to).join(lineSep)); } + return + } + if (node.getAttribute("contenteditable") == "false") { return } + var isBlock = /^(pre|div|p|li|table|br)$/i.test(node.nodeName); + if (!/^br$/i.test(node.nodeName) && node.textContent.length == 0) { return } + + if (isBlock) { close(); } + for (var i = 0; i < node.childNodes.length; i++) + { walk(node.childNodes[i]); } + + if (/^(pre|p)$/i.test(node.nodeName)) { extraLinebreak = true; } + if (isBlock) { closing = true; } + } else if (node.nodeType == 3) { + addText(node.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " ")); + } + } + for (;;) { + walk(from); + if (from == to) { break } + from = from.nextSibling; + extraLinebreak = false; + } + return text + } + + function domToPos(cm, node, offset) { + var lineNode; + if (node == cm.display.lineDiv) { + lineNode = cm.display.lineDiv.childNodes[offset]; + if (!lineNode) { return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true) } + node = null; offset = 0; + } else { + for (lineNode = node;; lineNode = lineNode.parentNode) { + if (!lineNode || lineNode == cm.display.lineDiv) { return null } + if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) { break } + } + } + for (var i = 0; i < cm.display.view.length; i++) { + var lineView = cm.display.view[i]; + if (lineView.node == lineNode) + { return locateNodeInLineView(lineView, node, offset) } + } + } + + function locateNodeInLineView(lineView, node, offset) { + var wrapper = lineView.text.firstChild, bad = false; + if (!node || !contains(wrapper, node)) { return badPos(Pos(lineNo(lineView.line), 0), true) } + if (node == wrapper) { + bad = true; + node = wrapper.childNodes[offset]; + offset = 0; + if (!node) { + var line = lineView.rest ? lst(lineView.rest) : lineView.line; + return badPos(Pos(lineNo(line), line.text.length), bad) + } + } + + var textNode = node.nodeType == 3 ? node : null, topNode = node; + if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) { + textNode = node.firstChild; + if (offset) { offset = textNode.nodeValue.length; } + } + while (topNode.parentNode != wrapper) { topNode = topNode.parentNode; } + var measure = lineView.measure, maps = measure.maps; + + function find(textNode, topNode, offset) { + for (var i = -1; i < (maps ? maps.length : 0); i++) { + var map = i < 0 ? measure.map : maps[i]; + for (var j = 0; j < map.length; j += 3) { + var curNode = map[j + 2]; + if (curNode == textNode || curNode == topNode) { + var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]); + var ch = map[j] + offset; + if (offset < 0 || curNode != textNode) { ch = map[j + (offset ? 1 : 0)]; } + return Pos(line, ch) + } + } + } + } + var found = find(textNode, topNode, offset); + if (found) { return badPos(found, bad) } + + // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems + for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) { + found = find(after, after.firstChild, 0); + if (found) + { return badPos(Pos(found.line, found.ch - dist), bad) } + else + { dist += after.textContent.length; } + } + for (var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling) { + found = find(before, before.firstChild, -1); + if (found) + { return badPos(Pos(found.line, found.ch + dist$1), bad) } + else + { dist$1 += before.textContent.length; } + } + } + + // TEXTAREA INPUT STYLE + + var TextareaInput = function(cm) { + this.cm = cm; + // See input.poll and input.reset + this.prevInput = ""; + + // Flag that indicates whether we expect input to appear real soon + // now (after some event like 'keypress' or 'input') and are + // polling intensively. + this.pollingFast = false; + // Self-resetting timeout for the poller + this.polling = new Delayed(); + // Used to work around IE issue with selection being forgotten when focus moves away from textarea + this.hasSelection = false; + this.composing = null; + }; + + TextareaInput.prototype.init = function (display) { + var this$1 = this; + + var input = this, cm = this.cm; + this.createField(display); + var te = this.textarea; + + display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild); + + // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore) + if (ios) { te.style.width = "0px"; } + + on(te, "input", function () { + if (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null; } + input.poll(); + }); + + on(te, "paste", function (e) { + if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return } + + cm.state.pasteIncoming = +new Date; + input.fastPoll(); + }); + + function prepareCopyCut(e) { + if (signalDOMEvent(cm, e)) { return } + if (cm.somethingSelected()) { + setLastCopied({lineWise: false, text: cm.getSelections()}); + } else if (!cm.options.lineWiseCopyCut) { + return + } else { + var ranges = copyableRanges(cm); + setLastCopied({lineWise: true, text: ranges.text}); + if (e.type == "cut") { + cm.setSelections(ranges.ranges, null, sel_dontScroll); + } else { + input.prevInput = ""; + te.value = ranges.text.join("\n"); + selectInput(te); + } + } + if (e.type == "cut") { cm.state.cutIncoming = +new Date; } + } + on(te, "cut", prepareCopyCut); + on(te, "copy", prepareCopyCut); + + on(display.scroller, "paste", function (e) { + if (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return } + if (!te.dispatchEvent) { + cm.state.pasteIncoming = +new Date; + input.focus(); + return + } + + // Pass the `paste` event to the textarea so it's handled by its event listener. + var event = new Event("paste"); + event.clipboardData = e.clipboardData; + te.dispatchEvent(event); + }); + + // Prevent normal selection in the editor (we handle our own) + on(display.lineSpace, "selectstart", function (e) { + if (!eventInWidget(display, e)) { e_preventDefault(e); } + }); + + on(te, "compositionstart", function () { + var start = cm.getCursor("from"); + if (input.composing) { input.composing.range.clear(); } + input.composing = { + start: start, + range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"}) + }; + }); + on(te, "compositionend", function () { + if (input.composing) { + input.poll(); + input.composing.range.clear(); + input.composing = null; + } + }); + }; + + TextareaInput.prototype.createField = function (_display) { + // Wraps and hides input textarea + this.wrapper = hiddenTextarea(); + // The semihidden textarea that is focused when the editor is + // focused, and receives input. + this.textarea = this.wrapper.firstChild; + }; + + TextareaInput.prototype.screenReaderLabelChanged = function (label) { + // Label for screenreaders, accessibility + if(label) { + this.textarea.setAttribute('aria-label', label); + } else { + this.textarea.removeAttribute('aria-label'); + } + }; + + TextareaInput.prototype.prepareSelection = function () { + // Redraw the selection and/or cursor + var cm = this.cm, display = cm.display, doc = cm.doc; + var result = prepareSelection(cm); + + // Move the hidden textarea near the cursor to prevent scrolling artifacts + if (cm.options.moveInputWithCursor) { + var headPos = cursorCoords(cm, doc.sel.primary().head, "div"); + var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect(); + result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10, + headPos.top + lineOff.top - wrapOff.top)); + result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10, + headPos.left + lineOff.left - wrapOff.left)); + } + + return result + }; + + TextareaInput.prototype.showSelection = function (drawn) { + var cm = this.cm, display = cm.display; + removeChildrenAndAdd(display.cursorDiv, drawn.cursors); + removeChildrenAndAdd(display.selectionDiv, drawn.selection); + if (drawn.teTop != null) { + this.wrapper.style.top = drawn.teTop + "px"; + this.wrapper.style.left = drawn.teLeft + "px"; + } + }; + + // Reset the input to correspond to the selection (or to be empty, + // when not typing and nothing is selected) + TextareaInput.prototype.reset = function (typing) { + if (this.contextMenuPending || this.composing) { return } + var cm = this.cm; + if (cm.somethingSelected()) { + this.prevInput = ""; + var content = cm.getSelection(); + this.textarea.value = content; + if (cm.state.focused) { selectInput(this.textarea); } + if (ie && ie_version >= 9) { this.hasSelection = content; } + } else if (!typing) { + this.prevInput = this.textarea.value = ""; + if (ie && ie_version >= 9) { this.hasSelection = null; } + } + }; + + TextareaInput.prototype.getField = function () { return this.textarea }; + + TextareaInput.prototype.supportsTouch = function () { return false }; + + TextareaInput.prototype.focus = function () { + if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) { + try { this.textarea.focus(); } + catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM + } + }; + + TextareaInput.prototype.blur = function () { this.textarea.blur(); }; + + TextareaInput.prototype.resetPosition = function () { + this.wrapper.style.top = this.wrapper.style.left = 0; + }; + + TextareaInput.prototype.receivedFocus = function () { this.slowPoll(); }; + + // Poll for input changes, using the normal rate of polling. This + // runs as long as the editor is focused. + TextareaInput.prototype.slowPoll = function () { + var this$1 = this; + + if (this.pollingFast) { return } + this.polling.set(this.cm.options.pollInterval, function () { + this$1.poll(); + if (this$1.cm.state.focused) { this$1.slowPoll(); } + }); + }; + + // When an event has just come in that is likely to add or change + // something in the input textarea, we poll faster, to ensure that + // the change appears on the screen quickly. + TextareaInput.prototype.fastPoll = function () { + var missed = false, input = this; + input.pollingFast = true; + function p() { + var changed = input.poll(); + if (!changed && !missed) {missed = true; input.polling.set(60, p);} + else {input.pollingFast = false; input.slowPoll();} + } + input.polling.set(20, p); + }; + + // Read input from the textarea, and update the document to match. + // When something is selected, it is present in the textarea, and + // selected (unless it is huge, in which case a placeholder is + // used). When nothing is selected, the cursor sits after previously + // seen text (can be empty), which is stored in prevInput (we must + // not reset the textarea when typing, because that breaks IME). + TextareaInput.prototype.poll = function () { + var this$1 = this; + + var cm = this.cm, input = this.textarea, prevInput = this.prevInput; + // Since this is called a *lot*, try to bail out as cheaply as + // possible when it is clear that nothing happened. hasSelection + // will be the case when there is a lot of text in the textarea, + // in which case reading its value would be expensive. + if (this.contextMenuPending || !cm.state.focused || + (hasSelection(input) && !prevInput && !this.composing) || + cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq) + { return false } + + var text = input.value; + // If nothing changed, bail. + if (text == prevInput && !cm.somethingSelected()) { return false } + // Work around nonsensical selection resetting in IE9/10, and + // inexplicable appearance of private area unicode characters on + // some key combos in Mac (#2689). + if (ie && ie_version >= 9 && this.hasSelection === text || + mac && /[\uf700-\uf7ff]/.test(text)) { + cm.display.input.reset(); + return false + } + + if (cm.doc.sel == cm.display.selForContextMenu) { + var first = text.charCodeAt(0); + if (first == 0x200b && !prevInput) { prevInput = "\u200b"; } + if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo") } + } + // Find the part of the input that is actually new + var same = 0, l = Math.min(prevInput.length, text.length); + while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) { ++same; } + + runInOp(cm, function () { + applyTextInput(cm, text.slice(same), prevInput.length - same, + null, this$1.composing ? "*compose" : null); + + // Don't leave long text in the textarea, since it makes further polling slow + if (text.length > 1000 || text.indexOf("\n") > -1) { input.value = this$1.prevInput = ""; } + else { this$1.prevInput = text; } + + if (this$1.composing) { + this$1.composing.range.clear(); + this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"), + {className: "CodeMirror-composing"}); + } + }); + return true + }; + + TextareaInput.prototype.ensurePolled = function () { + if (this.pollingFast && this.poll()) { this.pollingFast = false; } + }; + + TextareaInput.prototype.onKeyPress = function () { + if (ie && ie_version >= 9) { this.hasSelection = null; } + this.fastPoll(); + }; + + TextareaInput.prototype.onContextMenu = function (e) { + var input = this, cm = input.cm, display = cm.display, te = input.textarea; + if (input.contextMenuPending) { input.contextMenuPending(); } + var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop; + if (!pos || presto) { return } // Opera is difficult. + + // Reset the current text selection only if the click is done outside of the selection + // and 'resetSelectionOnContextMenu' option is true. + var reset = cm.options.resetSelectionOnContextMenu; + if (reset && cm.doc.sel.contains(pos) == -1) + { operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); } + + var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText; + var wrapperBox = input.wrapper.offsetParent.getBoundingClientRect(); + input.wrapper.style.cssText = "position: static"; + te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"; + var oldScrollY; + if (webkit) { oldScrollY = window.scrollY; } // Work around Chrome issue (#2712) + display.input.focus(); + if (webkit) { window.scrollTo(null, oldScrollY); } + display.input.reset(); + // Adds "Select all" to context menu in FF + if (!cm.somethingSelected()) { te.value = input.prevInput = " "; } + input.contextMenuPending = rehide; + display.selForContextMenu = cm.doc.sel; + clearTimeout(display.detectingSelectAll); + + // Select-all will be greyed out if there's nothing to select, so + // this adds a zero-width space so that we can later check whether + // it got selected. + function prepareSelectAllHack() { + if (te.selectionStart != null) { + var selected = cm.somethingSelected(); + var extval = "\u200b" + (selected ? te.value : ""); + te.value = "\u21da"; // Used to catch context-menu undo + te.value = extval; + input.prevInput = selected ? "" : "\u200b"; + te.selectionStart = 1; te.selectionEnd = extval.length; + // Re-set this, in case some other handler touched the + // selection in the meantime. + display.selForContextMenu = cm.doc.sel; + } + } + function rehide() { + if (input.contextMenuPending != rehide) { return } + input.contextMenuPending = false; + input.wrapper.style.cssText = oldWrapperCSS; + te.style.cssText = oldCSS; + if (ie && ie_version < 9) { display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos); } + + // Try to detect the user choosing select-all + if (te.selectionStart != null) { + if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack(); } + var i = 0, poll = function () { + if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 && + te.selectionEnd > 0 && input.prevInput == "\u200b") { + operation(cm, selectAll)(cm); + } else if (i++ < 10) { + display.detectingSelectAll = setTimeout(poll, 500); + } else { + display.selForContextMenu = null; + display.input.reset(); + } + }; + display.detectingSelectAll = setTimeout(poll, 200); + } + } + + if (ie && ie_version >= 9) { prepareSelectAllHack(); } + if (captureRightClick) { + e_stop(e); + var mouseup = function () { + off(window, "mouseup", mouseup); + setTimeout(rehide, 20); + }; + on(window, "mouseup", mouseup); + } else { + setTimeout(rehide, 50); + } + }; + + TextareaInput.prototype.readOnlyChanged = function (val) { + if (!val) { this.reset(); } + this.textarea.disabled = val == "nocursor"; + this.textarea.readOnly = !!val; + }; + + TextareaInput.prototype.setUneditable = function () {}; + + TextareaInput.prototype.needsContentAttribute = false; + + function fromTextArea(textarea, options) { + options = options ? copyObj(options) : {}; + options.value = textarea.value; + if (!options.tabindex && textarea.tabIndex) + { options.tabindex = textarea.tabIndex; } + if (!options.placeholder && textarea.placeholder) + { options.placeholder = textarea.placeholder; } + // Set autofocus to true if this textarea is focused, or if it has + // autofocus and no other element is focused. + if (options.autofocus == null) { + var hasFocus = activeElt(); + options.autofocus = hasFocus == textarea || + textarea.getAttribute("autofocus") != null && hasFocus == document.body; + } + + function save() {textarea.value = cm.getValue();} + + var realSubmit; + if (textarea.form) { + on(textarea.form, "submit", save); + // Deplorable hack to make the submit method do the right thing. + if (!options.leaveSubmitMethodAlone) { + var form = textarea.form; + realSubmit = form.submit; + try { + var wrappedSubmit = form.submit = function () { + save(); + form.submit = realSubmit; + form.submit(); + form.submit = wrappedSubmit; + }; + } catch(e) {} + } + } + + options.finishInit = function (cm) { + cm.save = save; + cm.getTextArea = function () { return textarea; }; + cm.toTextArea = function () { + cm.toTextArea = isNaN; // Prevent this from being ran twice + save(); + textarea.parentNode.removeChild(cm.getWrapperElement()); + textarea.style.display = ""; + if (textarea.form) { + off(textarea.form, "submit", save); + if (!options.leaveSubmitMethodAlone && typeof textarea.form.submit == "function") + { textarea.form.submit = realSubmit; } + } + }; + }; + + textarea.style.display = "none"; + var cm = CodeMirror(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); }, + options); + return cm + } + + function addLegacyProps(CodeMirror) { + CodeMirror.off = off; + CodeMirror.on = on; + CodeMirror.wheelEventPixels = wheelEventPixels; + CodeMirror.Doc = Doc; + CodeMirror.splitLines = splitLinesAuto; + CodeMirror.countColumn = countColumn; + CodeMirror.findColumn = findColumn; + CodeMirror.isWordChar = isWordCharBasic; + CodeMirror.Pass = Pass; + CodeMirror.signal = signal; + CodeMirror.Line = Line; + CodeMirror.changeEnd = changeEnd; + CodeMirror.scrollbarModel = scrollbarModel; + CodeMirror.Pos = Pos; + CodeMirror.cmpPos = cmp; + CodeMirror.modes = modes; + CodeMirror.mimeModes = mimeModes; + CodeMirror.resolveMode = resolveMode; + CodeMirror.getMode = getMode; + CodeMirror.modeExtensions = modeExtensions; + CodeMirror.extendMode = extendMode; + CodeMirror.copyState = copyState; + CodeMirror.startState = startState; + CodeMirror.innerMode = innerMode; + CodeMirror.commands = commands; + CodeMirror.keyMap = keyMap; + CodeMirror.keyName = keyName; + CodeMirror.isModifierKey = isModifierKey; + CodeMirror.lookupKey = lookupKey; + CodeMirror.normalizeKeyMap = normalizeKeyMap; + CodeMirror.StringStream = StringStream; + CodeMirror.SharedTextMarker = SharedTextMarker; + CodeMirror.TextMarker = TextMarker; + CodeMirror.LineWidget = LineWidget; + CodeMirror.e_preventDefault = e_preventDefault; + CodeMirror.e_stopPropagation = e_stopPropagation; + CodeMirror.e_stop = e_stop; + CodeMirror.addClass = addClass; + CodeMirror.contains = contains; + CodeMirror.rmClass = rmClass; + CodeMirror.keyNames = keyNames; + } + + // EDITOR CONSTRUCTOR + + defineOptions(CodeMirror); + + addEditorMethods(CodeMirror); + + // Set up methods on CodeMirror's prototype to redirect to the editor's document. + var dontDelegate = "iter insert remove copy getEditor constructor".split(" "); + for (var prop in Doc.prototype) { if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0) + { CodeMirror.prototype[prop] = (function(method) { + return function() {return method.apply(this.doc, arguments)} + })(Doc.prototype[prop]); } } + + eventMixin(Doc); + CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput}; + + // Extra arguments are stored as the mode's dependencies, which is + // used by (legacy) mechanisms like loadmode.js to automatically + // load a mode. (Preferred mechanism is the require/define calls.) + CodeMirror.defineMode = function(name/*, mode, …*/) { + if (!CodeMirror.defaults.mode && name != "null") { CodeMirror.defaults.mode = name; } + defineMode.apply(this, arguments); + }; + + CodeMirror.defineMIME = defineMIME; + + // Minimal default mode. + CodeMirror.defineMode("null", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); }); + CodeMirror.defineMIME("text/plain", "null"); + + // EXTENSIONS + + CodeMirror.defineExtension = function (name, func) { + CodeMirror.prototype[name] = func; + }; + CodeMirror.defineDocExtension = function (name, func) { + Doc.prototype[name] = func; + }; + + CodeMirror.fromTextArea = fromTextArea; + + addLegacyProps(CodeMirror); + + CodeMirror.version = "5.59.4"; + + return CodeMirror; + +}))); + + +/***/ }), + +/***/ "./node_modules/codemirror/mode/xml/xml.js": +/*!*************************************************!*\ + !*** ./node_modules/codemirror/mode/xml/xml.js ***! + \*************************************************/ +/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { + +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function(mod) { + if (true) // CommonJS + mod(__webpack_require__(/*! ../../lib/codemirror */ "./node_modules/codemirror/lib/codemirror.js")); + else {} +})(function(CodeMirror) { +"use strict"; + +var htmlConfig = { + autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true, + 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true, + 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true, + 'track': true, 'wbr': true, 'menuitem': true}, + implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true, + 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true, + 'th': true, 'tr': true}, + contextGrabbers: { + 'dd': {'dd': true, 'dt': true}, + 'dt': {'dd': true, 'dt': true}, + 'li': {'li': true}, + 'option': {'option': true, 'optgroup': true}, + 'optgroup': {'optgroup': true}, + 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true, + 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true, + 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true, + 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true, + 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true}, + 'rp': {'rp': true, 'rt': true}, + 'rt': {'rp': true, 'rt': true}, + 'tbody': {'tbody': true, 'tfoot': true}, + 'td': {'td': true, 'th': true}, + 'tfoot': {'tbody': true}, + 'th': {'td': true, 'th': true}, + 'thead': {'tbody': true, 'tfoot': true}, + 'tr': {'tr': true} + }, + doNotIndent: {"pre": true}, + allowUnquoted: true, + allowMissing: true, + caseFold: true +} + +var xmlConfig = { + autoSelfClosers: {}, + implicitlyClosed: {}, + contextGrabbers: {}, + doNotIndent: {}, + allowUnquoted: false, + allowMissing: false, + allowMissingTagName: false, + caseFold: false +} + +CodeMirror.defineMode("xml", function(editorConf, config_) { + var indentUnit = editorConf.indentUnit + var config = {} + var defaults = config_.htmlMode ? htmlConfig : xmlConfig + for (var prop in defaults) config[prop] = defaults[prop] + for (var prop in config_) config[prop] = config_[prop] + + // Return variables for tokenizers + var type, setStyle; + + function inText(stream, state) { + function chain(parser) { + state.tokenize = parser; + return parser(stream, state); + } + + var ch = stream.next(); + if (ch == "<") { + if (stream.eat("!")) { + if (stream.eat("[")) { + if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>")); + else return null; + } else if (stream.match("--")) { + return chain(inBlock("comment", "-->")); + } else if (stream.match("DOCTYPE", true, true)) { + stream.eatWhile(/[\w\._\-]/); + return chain(doctype(1)); + } else { + return null; + } + } else if (stream.eat("?")) { + stream.eatWhile(/[\w\._\-]/); + state.tokenize = inBlock("meta", "?>"); + return "meta"; + } else { + type = stream.eat("/") ? "closeTag" : "openTag"; + state.tokenize = inTag; + return "tag bracket"; + } + } else if (ch == "&") { + var ok; + if (stream.eat("#")) { + if (stream.eat("x")) { + ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";"); + } else { + ok = stream.eatWhile(/[\d]/) && stream.eat(";"); + } + } else { + ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";"); + } + return ok ? "atom" : "error"; + } else { + stream.eatWhile(/[^&<]/); + return null; + } + } + inText.isInText = true; + + function inTag(stream, state) { + var ch = stream.next(); + if (ch == ">" || (ch == "/" && stream.eat(">"))) { + state.tokenize = inText; + type = ch == ">" ? "endTag" : "selfcloseTag"; + return "tag bracket"; + } else if (ch == "=") { + type = "equals"; + return null; + } else if (ch == "<") { + state.tokenize = inText; + state.state = baseState; + state.tagName = state.tagStart = null; + var next = state.tokenize(stream, state); + return next ? next + " tag error" : "tag error"; + } else if (/[\'\"]/.test(ch)) { + state.tokenize = inAttribute(ch); + state.stringStartCol = stream.column(); + return state.tokenize(stream, state); + } else { + stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/); + return "word"; + } + } + + function inAttribute(quote) { + var closure = function(stream, state) { + while (!stream.eol()) { + if (stream.next() == quote) { + state.tokenize = inTag; + break; + } + } + return "string"; + }; + closure.isInAttribute = true; + return closure; + } + + function inBlock(style, terminator) { + return function(stream, state) { + while (!stream.eol()) { + if (stream.match(terminator)) { + state.tokenize = inText; + break; + } + stream.next(); + } + return style; + } + } + + function doctype(depth) { + return function(stream, state) { + var ch; + while ((ch = stream.next()) != null) { + if (ch == "<") { + state.tokenize = doctype(depth + 1); + return state.tokenize(stream, state); + } else if (ch == ">") { + if (depth == 1) { + state.tokenize = inText; + break; + } else { + state.tokenize = doctype(depth - 1); + return state.tokenize(stream, state); + } + } + } + return "meta"; + }; + } + + function Context(state, tagName, startOfLine) { + this.prev = state.context; + this.tagName = tagName || ""; + this.indent = state.indented; + this.startOfLine = startOfLine; + if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent)) + this.noIndent = true; + } + function popContext(state) { + if (state.context) state.context = state.context.prev; + } + function maybePopContext(state, nextTagName) { + var parentTagName; + while (true) { + if (!state.context) { + return; + } + parentTagName = state.context.tagName; + if (!config.contextGrabbers.hasOwnProperty(parentTagName) || + !config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) { + return; + } + popContext(state); + } + } + + function baseState(type, stream, state) { + if (type == "openTag") { + state.tagStart = stream.column(); + return tagNameState; + } else if (type == "closeTag") { + return closeTagNameState; + } else { + return baseState; + } + } + function tagNameState(type, stream, state) { + if (type == "word") { + state.tagName = stream.current(); + setStyle = "tag"; + return attrState; + } else if (config.allowMissingTagName && type == "endTag") { + setStyle = "tag bracket"; + return attrState(type, stream, state); + } else { + setStyle = "error"; + return tagNameState; + } + } + function closeTagNameState(type, stream, state) { + if (type == "word") { + var tagName = stream.current(); + if (state.context && state.context.tagName != tagName && + config.implicitlyClosed.hasOwnProperty(state.context.tagName)) + popContext(state); + if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) { + setStyle = "tag"; + return closeState; + } else { + setStyle = "tag error"; + return closeStateErr; + } + } else if (config.allowMissingTagName && type == "endTag") { + setStyle = "tag bracket"; + return closeState(type, stream, state); + } else { + setStyle = "error"; + return closeStateErr; + } + } + + function closeState(type, _stream, state) { + if (type != "endTag") { + setStyle = "error"; + return closeState; + } + popContext(state); + return baseState; + } + function closeStateErr(type, stream, state) { + setStyle = "error"; + return closeState(type, stream, state); + } + + function attrState(type, _stream, state) { + if (type == "word") { + setStyle = "attribute"; + return attrEqState; + } else if (type == "endTag" || type == "selfcloseTag") { + var tagName = state.tagName, tagStart = state.tagStart; + state.tagName = state.tagStart = null; + if (type == "selfcloseTag" || + config.autoSelfClosers.hasOwnProperty(tagName)) { + maybePopContext(state, tagName); + } else { + maybePopContext(state, tagName); + state.context = new Context(state, tagName, tagStart == state.indented); + } + return baseState; + } + setStyle = "error"; + return attrState; + } + function attrEqState(type, stream, state) { + if (type == "equals") return attrValueState; + if (!config.allowMissing) setStyle = "error"; + return attrState(type, stream, state); + } + function attrValueState(type, stream, state) { + if (type == "string") return attrContinuedState; + if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;} + setStyle = "error"; + return attrState(type, stream, state); + } + function attrContinuedState(type, stream, state) { + if (type == "string") return attrContinuedState; + return attrState(type, stream, state); + } + + return { + startState: function(baseIndent) { + var state = {tokenize: inText, + state: baseState, + indented: baseIndent || 0, + tagName: null, tagStart: null, + context: null} + if (baseIndent != null) state.baseIndent = baseIndent + return state + }, + + token: function(stream, state) { + if (!state.tagName && stream.sol()) + state.indented = stream.indentation(); + + if (stream.eatSpace()) return null; + type = null; + var style = state.tokenize(stream, state); + if ((style || type) && style != "comment") { + setStyle = null; + state.state = state.state(type || style, stream, state); + if (setStyle) + style = setStyle == "error" ? style + " error" : setStyle; + } + return style; + }, + + indent: function(state, textAfter, fullLine) { + var context = state.context; + // Indent multi-line strings (e.g. css). + if (state.tokenize.isInAttribute) { + if (state.tagStart == state.indented) + return state.stringStartCol + 1; + else + return state.indented + indentUnit; + } + if (context && context.noIndent) return CodeMirror.Pass; + if (state.tokenize != inTag && state.tokenize != inText) + return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0; + // Indent the starts of attribute names. + if (state.tagName) { + if (config.multilineTagIndentPastTag !== false) + return state.tagStart + state.tagName.length + 2; + else + return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1); + } + if (config.alignCDATA && /$/, + blockCommentStart: "", + + configuration: config.htmlMode ? "html" : "xml", + helperType: config.htmlMode ? "html" : "xml", + + skipAttribute: function(state) { + if (state.state == attrValueState) + state.state = attrState + }, + + xmlCurrentTag: function(state) { + return state.tagName ? {name: state.tagName, close: state.type == "closeTag"} : null + }, + + xmlCurrentContext: function(state) { + var context = [] + for (var cx = state.context; cx; cx = cx.prev) + context.push(cx.tagName) + return context.reverse() + } + }; +}); + +CodeMirror.defineMIME("text/xml", "xml"); +CodeMirror.defineMIME("application/xml", "xml"); +if (!CodeMirror.mimeModes.hasOwnProperty("text/html")) + CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true}); + +}); + + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/addLeadingZeros/index.js": +/*!*****************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/addLeadingZeros/index.js ***! + \*****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ addLeadingZeros) +/* harmony export */ }); +function addLeadingZeros(number, targetLength) { + var sign = number < 0 ? '-' : ''; + var output = Math.abs(number).toString(); + + while (output.length < targetLength) { + output = '0' + output; + } + + return sign + output; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/assign/index.js": +/*!********************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/assign/index.js ***! + \********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ assign) +/* harmony export */ }); +function assign(target, dirtyObject) { + if (target == null) { + throw new TypeError('assign requires that input parameter not be null or undefined'); + } + + dirtyObject = dirtyObject || {}; + + for (var property in dirtyObject) { + if (dirtyObject.hasOwnProperty(property)) { + target[property] = dirtyObject[property]; + } + } + + return target; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/cloneObject/index.js": +/*!*************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/cloneObject/index.js ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ cloneObject) +/* harmony export */ }); +/* harmony import */ var _assign_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../assign/index.js */ "./node_modules/date-fns/esm/_lib/assign/index.js"); + +function cloneObject(dirtyObject) { + return (0,_assign_index_js__WEBPACK_IMPORTED_MODULE_0__.default)({}, dirtyObject); +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/format/formatters/index.js": +/*!*******************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/format/formatters/index.js ***! + \*******************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _lightFormatters_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lightFormatters/index.js */ "./node_modules/date-fns/esm/_lib/format/lightFormatters/index.js"); +/* harmony import */ var _lib_getUTCDayOfYear_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../_lib/getUTCDayOfYear/index.js */ "./node_modules/date-fns/esm/_lib/getUTCDayOfYear/index.js"); +/* harmony import */ var _lib_getUTCISOWeek_index_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../_lib/getUTCISOWeek/index.js */ "./node_modules/date-fns/esm/_lib/getUTCISOWeek/index.js"); +/* harmony import */ var _lib_getUTCISOWeekYear_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../_lib/getUTCISOWeekYear/index.js */ "./node_modules/date-fns/esm/_lib/getUTCISOWeekYear/index.js"); +/* harmony import */ var _lib_getUTCWeek_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../_lib/getUTCWeek/index.js */ "./node_modules/date-fns/esm/_lib/getUTCWeek/index.js"); +/* harmony import */ var _lib_getUTCWeekYear_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../_lib/getUTCWeekYear/index.js */ "./node_modules/date-fns/esm/_lib/getUTCWeekYear/index.js"); +/* harmony import */ var _addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../addLeadingZeros/index.js */ "./node_modules/date-fns/esm/_lib/addLeadingZeros/index.js"); + + + + + + + +var dayPeriodEnum = { + am: 'am', + pm: 'pm', + midnight: 'midnight', + noon: 'noon', + morning: 'morning', + afternoon: 'afternoon', + evening: 'evening', + night: 'night' + /* + * | | Unit | | Unit | + * |-----|--------------------------------|-----|--------------------------------| + * | a | AM, PM | A* | Milliseconds in day | + * | b | AM, PM, noon, midnight | B | Flexible day period | + * | c | Stand-alone local day of week | C* | Localized hour w/ day period | + * | d | Day of month | D | Day of year | + * | e | Local day of week | E | Day of week | + * | f | | F* | Day of week in month | + * | g* | Modified Julian day | G | Era | + * | h | Hour [1-12] | H | Hour [0-23] | + * | i! | ISO day of week | I! | ISO week of year | + * | j* | Localized hour w/ day period | J* | Localized hour w/o day period | + * | k | Hour [1-24] | K | Hour [0-11] | + * | l* | (deprecated) | L | Stand-alone month | + * | m | Minute | M | Month | + * | n | | N | | + * | o! | Ordinal number modifier | O | Timezone (GMT) | + * | p! | Long localized time | P! | Long localized date | + * | q | Stand-alone quarter | Q | Quarter | + * | r* | Related Gregorian year | R! | ISO week-numbering year | + * | s | Second | S | Fraction of second | + * | t! | Seconds timestamp | T! | Milliseconds timestamp | + * | u | Extended year | U* | Cyclic year | + * | v* | Timezone (generic non-locat.) | V* | Timezone (location) | + * | w | Local week of year | W* | Week of month | + * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) | + * | y | Year (abs) | Y | Local week-numbering year | + * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) | + * + * Letters marked by * are not implemented but reserved by Unicode standard. + * + * Letters marked by ! are non-standard, but implemented by date-fns: + * - `o` modifies the previous token to turn it into an ordinal (see `format` docs) + * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days, + * i.e. 7 for Sunday, 1 for Monday, etc. + * - `I` is ISO week of year, as opposed to `w` which is local week of year. + * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year. + * `R` is supposed to be used in conjunction with `I` and `i` + * for universal ISO week-numbering date, whereas + * `Y` is supposed to be used in conjunction with `w` and `e` + * for week-numbering date specific to the locale. + * - `P` is long localized date format + * - `p` is long localized time format + */ + +}; +var formatters = { + // Era + G: function (date, token, localize) { + var era = date.getUTCFullYear() > 0 ? 1 : 0; + + switch (token) { + // AD, BC + case 'G': + case 'GG': + case 'GGG': + return localize.era(era, { + width: 'abbreviated' + }); + // A, B + + case 'GGGGG': + return localize.era(era, { + width: 'narrow' + }); + // Anno Domini, Before Christ + + case 'GGGG': + default: + return localize.era(era, { + width: 'wide' + }); + } + }, + // Year + y: function (date, token, localize) { + // Ordinal number + if (token === 'yo') { + var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript) + + var year = signedYear > 0 ? signedYear : 1 - signedYear; + return localize.ordinalNumber(year, { + unit: 'year' + }); + } + + return _lightFormatters_index_js__WEBPACK_IMPORTED_MODULE_0__.default.y(date, token); + }, + // Local week-numbering year + Y: function (date, token, localize, options) { + var signedWeekYear = (0,_lib_getUTCWeekYear_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(date, options); // Returns 1 for 1 BC (which is year 0 in JavaScript) + + var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; // Two digit year + + if (token === 'YY') { + var twoDigitYear = weekYear % 100; + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(twoDigitYear, 2); + } // Ordinal number + + + if (token === 'Yo') { + return localize.ordinalNumber(weekYear, { + unit: 'year' + }); + } // Padding + + + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(weekYear, token.length); + }, + // ISO week-numbering year + R: function (date, token) { + var isoWeekYear = (0,_lib_getUTCISOWeekYear_index_js__WEBPACK_IMPORTED_MODULE_3__.default)(date); // Padding + + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(isoWeekYear, token.length); + }, + // Extended year. This is a single number designating the year of this calendar system. + // The main difference between `y` and `u` localizers are B.C. years: + // | Year | `y` | `u` | + // |------|-----|-----| + // | AC 1 | 1 | 1 | + // | BC 1 | 1 | 0 | + // | BC 2 | 2 | -1 | + // Also `yy` always returns the last two digits of a year, + // while `uu` pads single digit years to 2 characters and returns other years unchanged. + u: function (date, token) { + var year = date.getUTCFullYear(); + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(year, token.length); + }, + // Quarter + Q: function (date, token, localize) { + var quarter = Math.ceil((date.getUTCMonth() + 1) / 3); + + switch (token) { + // 1, 2, 3, 4 + case 'Q': + return String(quarter); + // 01, 02, 03, 04 + + case 'QQ': + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(quarter, 2); + // 1st, 2nd, 3rd, 4th + + case 'Qo': + return localize.ordinalNumber(quarter, { + unit: 'quarter' + }); + // Q1, Q2, Q3, Q4 + + case 'QQQ': + return localize.quarter(quarter, { + width: 'abbreviated', + context: 'formatting' + }); + // 1, 2, 3, 4 (narrow quarter; could be not numerical) + + case 'QQQQQ': + return localize.quarter(quarter, { + width: 'narrow', + context: 'formatting' + }); + // 1st quarter, 2nd quarter, ... + + case 'QQQQ': + default: + return localize.quarter(quarter, { + width: 'wide', + context: 'formatting' + }); + } + }, + // Stand-alone quarter + q: function (date, token, localize) { + var quarter = Math.ceil((date.getUTCMonth() + 1) / 3); + + switch (token) { + // 1, 2, 3, 4 + case 'q': + return String(quarter); + // 01, 02, 03, 04 + + case 'qq': + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(quarter, 2); + // 1st, 2nd, 3rd, 4th + + case 'qo': + return localize.ordinalNumber(quarter, { + unit: 'quarter' + }); + // Q1, Q2, Q3, Q4 + + case 'qqq': + return localize.quarter(quarter, { + width: 'abbreviated', + context: 'standalone' + }); + // 1, 2, 3, 4 (narrow quarter; could be not numerical) + + case 'qqqqq': + return localize.quarter(quarter, { + width: 'narrow', + context: 'standalone' + }); + // 1st quarter, 2nd quarter, ... + + case 'qqqq': + default: + return localize.quarter(quarter, { + width: 'wide', + context: 'standalone' + }); + } + }, + // Month + M: function (date, token, localize) { + var month = date.getUTCMonth(); + + switch (token) { + case 'M': + case 'MM': + return _lightFormatters_index_js__WEBPACK_IMPORTED_MODULE_0__.default.M(date, token); + // 1st, 2nd, ..., 12th + + case 'Mo': + return localize.ordinalNumber(month + 1, { + unit: 'month' + }); + // Jan, Feb, ..., Dec + + case 'MMM': + return localize.month(month, { + width: 'abbreviated', + context: 'formatting' + }); + // J, F, ..., D + + case 'MMMMM': + return localize.month(month, { + width: 'narrow', + context: 'formatting' + }); + // January, February, ..., December + + case 'MMMM': + default: + return localize.month(month, { + width: 'wide', + context: 'formatting' + }); + } + }, + // Stand-alone month + L: function (date, token, localize) { + var month = date.getUTCMonth(); + + switch (token) { + // 1, 2, ..., 12 + case 'L': + return String(month + 1); + // 01, 02, ..., 12 + + case 'LL': + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(month + 1, 2); + // 1st, 2nd, ..., 12th + + case 'Lo': + return localize.ordinalNumber(month + 1, { + unit: 'month' + }); + // Jan, Feb, ..., Dec + + case 'LLL': + return localize.month(month, { + width: 'abbreviated', + context: 'standalone' + }); + // J, F, ..., D + + case 'LLLLL': + return localize.month(month, { + width: 'narrow', + context: 'standalone' + }); + // January, February, ..., December + + case 'LLLL': + default: + return localize.month(month, { + width: 'wide', + context: 'standalone' + }); + } + }, + // Local week of year + w: function (date, token, localize, options) { + var week = (0,_lib_getUTCWeek_index_js__WEBPACK_IMPORTED_MODULE_4__.default)(date, options); + + if (token === 'wo') { + return localize.ordinalNumber(week, { + unit: 'week' + }); + } + + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(week, token.length); + }, + // ISO week of year + I: function (date, token, localize) { + var isoWeek = (0,_lib_getUTCISOWeek_index_js__WEBPACK_IMPORTED_MODULE_5__.default)(date); + + if (token === 'Io') { + return localize.ordinalNumber(isoWeek, { + unit: 'week' + }); + } + + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(isoWeek, token.length); + }, + // Day of the month + d: function (date, token, localize) { + if (token === 'do') { + return localize.ordinalNumber(date.getUTCDate(), { + unit: 'date' + }); + } + + return _lightFormatters_index_js__WEBPACK_IMPORTED_MODULE_0__.default.d(date, token); + }, + // Day of year + D: function (date, token, localize) { + var dayOfYear = (0,_lib_getUTCDayOfYear_index_js__WEBPACK_IMPORTED_MODULE_6__.default)(date); + + if (token === 'Do') { + return localize.ordinalNumber(dayOfYear, { + unit: 'dayOfYear' + }); + } + + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(dayOfYear, token.length); + }, + // Day of week + E: function (date, token, localize) { + var dayOfWeek = date.getUTCDay(); + + switch (token) { + // Tue + case 'E': + case 'EE': + case 'EEE': + return localize.day(dayOfWeek, { + width: 'abbreviated', + context: 'formatting' + }); + // T + + case 'EEEEE': + return localize.day(dayOfWeek, { + width: 'narrow', + context: 'formatting' + }); + // Tu + + case 'EEEEEE': + return localize.day(dayOfWeek, { + width: 'short', + context: 'formatting' + }); + // Tuesday + + case 'EEEE': + default: + return localize.day(dayOfWeek, { + width: 'wide', + context: 'formatting' + }); + } + }, + // Local day of week + e: function (date, token, localize, options) { + var dayOfWeek = date.getUTCDay(); + var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; + + switch (token) { + // Numerical value (Nth day of week with current locale or weekStartsOn) + case 'e': + return String(localDayOfWeek); + // Padded numerical value + + case 'ee': + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(localDayOfWeek, 2); + // 1st, 2nd, ..., 7th + + case 'eo': + return localize.ordinalNumber(localDayOfWeek, { + unit: 'day' + }); + + case 'eee': + return localize.day(dayOfWeek, { + width: 'abbreviated', + context: 'formatting' + }); + // T + + case 'eeeee': + return localize.day(dayOfWeek, { + width: 'narrow', + context: 'formatting' + }); + // Tu + + case 'eeeeee': + return localize.day(dayOfWeek, { + width: 'short', + context: 'formatting' + }); + // Tuesday + + case 'eeee': + default: + return localize.day(dayOfWeek, { + width: 'wide', + context: 'formatting' + }); + } + }, + // Stand-alone local day of week + c: function (date, token, localize, options) { + var dayOfWeek = date.getUTCDay(); + var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; + + switch (token) { + // Numerical value (same as in `e`) + case 'c': + return String(localDayOfWeek); + // Padded numerical value + + case 'cc': + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(localDayOfWeek, token.length); + // 1st, 2nd, ..., 7th + + case 'co': + return localize.ordinalNumber(localDayOfWeek, { + unit: 'day' + }); + + case 'ccc': + return localize.day(dayOfWeek, { + width: 'abbreviated', + context: 'standalone' + }); + // T + + case 'ccccc': + return localize.day(dayOfWeek, { + width: 'narrow', + context: 'standalone' + }); + // Tu + + case 'cccccc': + return localize.day(dayOfWeek, { + width: 'short', + context: 'standalone' + }); + // Tuesday + + case 'cccc': + default: + return localize.day(dayOfWeek, { + width: 'wide', + context: 'standalone' + }); + } + }, + // ISO day of week + i: function (date, token, localize) { + var dayOfWeek = date.getUTCDay(); + var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; + + switch (token) { + // 2 + case 'i': + return String(isoDayOfWeek); + // 02 + + case 'ii': + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(isoDayOfWeek, token.length); + // 2nd + + case 'io': + return localize.ordinalNumber(isoDayOfWeek, { + unit: 'day' + }); + // Tue + + case 'iii': + return localize.day(dayOfWeek, { + width: 'abbreviated', + context: 'formatting' + }); + // T + + case 'iiiii': + return localize.day(dayOfWeek, { + width: 'narrow', + context: 'formatting' + }); + // Tu + + case 'iiiiii': + return localize.day(dayOfWeek, { + width: 'short', + context: 'formatting' + }); + // Tuesday + + case 'iiii': + default: + return localize.day(dayOfWeek, { + width: 'wide', + context: 'formatting' + }); + } + }, + // AM or PM + a: function (date, token, localize) { + var hours = date.getUTCHours(); + var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am'; + + switch (token) { + case 'a': + case 'aa': + return localize.dayPeriod(dayPeriodEnumValue, { + width: 'abbreviated', + context: 'formatting' + }); + + case 'aaa': + return localize.dayPeriod(dayPeriodEnumValue, { + width: 'abbreviated', + context: 'formatting' + }).toLowerCase(); + + case 'aaaaa': + return localize.dayPeriod(dayPeriodEnumValue, { + width: 'narrow', + context: 'formatting' + }); + + case 'aaaa': + default: + return localize.dayPeriod(dayPeriodEnumValue, { + width: 'wide', + context: 'formatting' + }); + } + }, + // AM, PM, midnight, noon + b: function (date, token, localize) { + var hours = date.getUTCHours(); + var dayPeriodEnumValue; + + if (hours === 12) { + dayPeriodEnumValue = dayPeriodEnum.noon; + } else if (hours === 0) { + dayPeriodEnumValue = dayPeriodEnum.midnight; + } else { + dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am'; + } + + switch (token) { + case 'b': + case 'bb': + return localize.dayPeriod(dayPeriodEnumValue, { + width: 'abbreviated', + context: 'formatting' + }); + + case 'bbb': + return localize.dayPeriod(dayPeriodEnumValue, { + width: 'abbreviated', + context: 'formatting' + }).toLowerCase(); + + case 'bbbbb': + return localize.dayPeriod(dayPeriodEnumValue, { + width: 'narrow', + context: 'formatting' + }); + + case 'bbbb': + default: + return localize.dayPeriod(dayPeriodEnumValue, { + width: 'wide', + context: 'formatting' + }); + } + }, + // in the morning, in the afternoon, in the evening, at night + B: function (date, token, localize) { + var hours = date.getUTCHours(); + var dayPeriodEnumValue; + + if (hours >= 17) { + dayPeriodEnumValue = dayPeriodEnum.evening; + } else if (hours >= 12) { + dayPeriodEnumValue = dayPeriodEnum.afternoon; + } else if (hours >= 4) { + dayPeriodEnumValue = dayPeriodEnum.morning; + } else { + dayPeriodEnumValue = dayPeriodEnum.night; + } + + switch (token) { + case 'B': + case 'BB': + case 'BBB': + return localize.dayPeriod(dayPeriodEnumValue, { + width: 'abbreviated', + context: 'formatting' + }); + + case 'BBBBB': + return localize.dayPeriod(dayPeriodEnumValue, { + width: 'narrow', + context: 'formatting' + }); + + case 'BBBB': + default: + return localize.dayPeriod(dayPeriodEnumValue, { + width: 'wide', + context: 'formatting' + }); + } + }, + // Hour [1-12] + h: function (date, token, localize) { + if (token === 'ho') { + var hours = date.getUTCHours() % 12; + if (hours === 0) hours = 12; + return localize.ordinalNumber(hours, { + unit: 'hour' + }); + } + + return _lightFormatters_index_js__WEBPACK_IMPORTED_MODULE_0__.default.h(date, token); + }, + // Hour [0-23] + H: function (date, token, localize) { + if (token === 'Ho') { + return localize.ordinalNumber(date.getUTCHours(), { + unit: 'hour' + }); + } + + return _lightFormatters_index_js__WEBPACK_IMPORTED_MODULE_0__.default.H(date, token); + }, + // Hour [0-11] + K: function (date, token, localize) { + var hours = date.getUTCHours() % 12; + + if (token === 'Ko') { + return localize.ordinalNumber(hours, { + unit: 'hour' + }); + } + + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(hours, token.length); + }, + // Hour [1-24] + k: function (date, token, localize) { + var hours = date.getUTCHours(); + if (hours === 0) hours = 24; + + if (token === 'ko') { + return localize.ordinalNumber(hours, { + unit: 'hour' + }); + } + + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(hours, token.length); + }, + // Minute + m: function (date, token, localize) { + if (token === 'mo') { + return localize.ordinalNumber(date.getUTCMinutes(), { + unit: 'minute' + }); + } + + return _lightFormatters_index_js__WEBPACK_IMPORTED_MODULE_0__.default.m(date, token); + }, + // Second + s: function (date, token, localize) { + if (token === 'so') { + return localize.ordinalNumber(date.getUTCSeconds(), { + unit: 'second' + }); + } + + return _lightFormatters_index_js__WEBPACK_IMPORTED_MODULE_0__.default.s(date, token); + }, + // Fraction of second + S: function (date, token) { + return _lightFormatters_index_js__WEBPACK_IMPORTED_MODULE_0__.default.S(date, token); + }, + // Timezone (ISO-8601. If offset is 0, output is always `'Z'`) + X: function (date, token, _localize, options) { + var originalDate = options._originalDate || date; + var timezoneOffset = originalDate.getTimezoneOffset(); + + if (timezoneOffset === 0) { + return 'Z'; + } + + switch (token) { + // Hours and optional minutes + case 'X': + return formatTimezoneWithOptionalMinutes(timezoneOffset); + // Hours, minutes and optional seconds without `:` delimiter + // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets + // so this token always has the same output as `XX` + + case 'XXXX': + case 'XX': + // Hours and minutes without `:` delimiter + return formatTimezone(timezoneOffset); + // Hours, minutes and optional seconds with `:` delimiter + // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets + // so this token always has the same output as `XXX` + + case 'XXXXX': + case 'XXX': // Hours and minutes with `:` delimiter + + default: + return formatTimezone(timezoneOffset, ':'); + } + }, + // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) + x: function (date, token, _localize, options) { + var originalDate = options._originalDate || date; + var timezoneOffset = originalDate.getTimezoneOffset(); + + switch (token) { + // Hours and optional minutes + case 'x': + return formatTimezoneWithOptionalMinutes(timezoneOffset); + // Hours, minutes and optional seconds without `:` delimiter + // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets + // so this token always has the same output as `xx` + + case 'xxxx': + case 'xx': + // Hours and minutes without `:` delimiter + return formatTimezone(timezoneOffset); + // Hours, minutes and optional seconds with `:` delimiter + // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets + // so this token always has the same output as `xxx` + + case 'xxxxx': + case 'xxx': // Hours and minutes with `:` delimiter + + default: + return formatTimezone(timezoneOffset, ':'); + } + }, + // Timezone (GMT) + O: function (date, token, _localize, options) { + var originalDate = options._originalDate || date; + var timezoneOffset = originalDate.getTimezoneOffset(); + + switch (token) { + // Short + case 'O': + case 'OO': + case 'OOO': + return 'GMT' + formatTimezoneShort(timezoneOffset, ':'); + // Long + + case 'OOOO': + default: + return 'GMT' + formatTimezone(timezoneOffset, ':'); + } + }, + // Timezone (specific non-location) + z: function (date, token, _localize, options) { + var originalDate = options._originalDate || date; + var timezoneOffset = originalDate.getTimezoneOffset(); + + switch (token) { + // Short + case 'z': + case 'zz': + case 'zzz': + return 'GMT' + formatTimezoneShort(timezoneOffset, ':'); + // Long + + case 'zzzz': + default: + return 'GMT' + formatTimezone(timezoneOffset, ':'); + } + }, + // Seconds timestamp + t: function (date, token, _localize, options) { + var originalDate = options._originalDate || date; + var timestamp = Math.floor(originalDate.getTime() / 1000); + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(timestamp, token.length); + }, + // Milliseconds timestamp + T: function (date, token, _localize, options) { + var originalDate = options._originalDate || date; + var timestamp = originalDate.getTime(); + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(timestamp, token.length); + } +}; + +function formatTimezoneShort(offset, dirtyDelimiter) { + var sign = offset > 0 ? '-' : '+'; + var absOffset = Math.abs(offset); + var hours = Math.floor(absOffset / 60); + var minutes = absOffset % 60; + + if (minutes === 0) { + return sign + String(hours); + } + + var delimiter = dirtyDelimiter || ''; + return sign + String(hours) + delimiter + (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(minutes, 2); +} + +function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) { + if (offset % 60 === 0) { + var sign = offset > 0 ? '-' : '+'; + return sign + (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(Math.abs(offset) / 60, 2); + } + + return formatTimezone(offset, dirtyDelimiter); +} + +function formatTimezone(offset, dirtyDelimiter) { + var delimiter = dirtyDelimiter || ''; + var sign = offset > 0 ? '-' : '+'; + var absOffset = Math.abs(offset); + var hours = (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(Math.floor(absOffset / 60), 2); + var minutes = (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(absOffset % 60, 2); + return sign + hours + delimiter + minutes; +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (formatters); + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/format/lightFormatters/index.js": +/*!************************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/format/lightFormatters/index.js ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../addLeadingZeros/index.js */ "./node_modules/date-fns/esm/_lib/addLeadingZeros/index.js"); + +/* + * | | Unit | | Unit | + * |-----|--------------------------------|-----|--------------------------------| + * | a | AM, PM | A* | | + * | d | Day of month | D | | + * | h | Hour [1-12] | H | Hour [0-23] | + * | m | Minute | M | Month | + * | s | Second | S | Fraction of second | + * | y | Year (abs) | Y | | + * + * Letters marked by * are not implemented but reserved by Unicode standard. + */ + +var formatters = { + // Year + y: function (date, token) { + // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens + // | Year | y | yy | yyy | yyyy | yyyyy | + // |----------|-------|----|-------|-------|-------| + // | AD 1 | 1 | 01 | 001 | 0001 | 00001 | + // | AD 12 | 12 | 12 | 012 | 0012 | 00012 | + // | AD 123 | 123 | 23 | 123 | 0123 | 00123 | + // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 | + // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 | + var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript) + + var year = signedYear > 0 ? signedYear : 1 - signedYear; + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(token === 'yy' ? year % 100 : year, token.length); + }, + // Month + M: function (date, token) { + var month = date.getUTCMonth(); + return token === 'M' ? String(month + 1) : (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(month + 1, 2); + }, + // Day of the month + d: function (date, token) { + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(date.getUTCDate(), token.length); + }, + // AM or PM + a: function (date, token) { + var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am'; + + switch (token) { + case 'a': + case 'aa': + return dayPeriodEnumValue.toUpperCase(); + + case 'aaa': + return dayPeriodEnumValue; + + case 'aaaaa': + return dayPeriodEnumValue[0]; + + case 'aaaa': + default: + return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.'; + } + }, + // Hour [1-12] + h: function (date, token) { + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(date.getUTCHours() % 12 || 12, token.length); + }, + // Hour [0-23] + H: function (date, token) { + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(date.getUTCHours(), token.length); + }, + // Minute + m: function (date, token) { + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(date.getUTCMinutes(), token.length); + }, + // Second + s: function (date, token) { + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(date.getUTCSeconds(), token.length); + }, + // Fraction of second + S: function (date, token) { + var numberOfDigits = token.length; + var milliseconds = date.getUTCMilliseconds(); + var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3)); + return (0,_addLeadingZeros_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(fractionalSeconds, token.length); + } +}; +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (formatters); + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/format/longFormatters/index.js": +/*!***********************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/format/longFormatters/index.js ***! + \***********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +function dateLongFormatter(pattern, formatLong) { + switch (pattern) { + case 'P': + return formatLong.date({ + width: 'short' + }); + + case 'PP': + return formatLong.date({ + width: 'medium' + }); + + case 'PPP': + return formatLong.date({ + width: 'long' + }); + + case 'PPPP': + default: + return formatLong.date({ + width: 'full' + }); + } +} + +function timeLongFormatter(pattern, formatLong) { + switch (pattern) { + case 'p': + return formatLong.time({ + width: 'short' + }); + + case 'pp': + return formatLong.time({ + width: 'medium' + }); + + case 'ppp': + return formatLong.time({ + width: 'long' + }); + + case 'pppp': + default: + return formatLong.time({ + width: 'full' + }); + } +} + +function dateTimeLongFormatter(pattern, formatLong) { + var matchResult = pattern.match(/(P+)(p+)?/); + var datePattern = matchResult[1]; + var timePattern = matchResult[2]; + + if (!timePattern) { + return dateLongFormatter(pattern, formatLong); + } + + var dateTimeFormat; + + switch (datePattern) { + case 'P': + dateTimeFormat = formatLong.dateTime({ + width: 'short' + }); + break; + + case 'PP': + dateTimeFormat = formatLong.dateTime({ + width: 'medium' + }); + break; + + case 'PPP': + dateTimeFormat = formatLong.dateTime({ + width: 'long' + }); + break; + + case 'PPPP': + default: + dateTimeFormat = formatLong.dateTime({ + width: 'full' + }); + break; + } + + return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong)); +} + +var longFormatters = { + p: timeLongFormatter, + P: dateTimeLongFormatter +}; +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (longFormatters); + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/getTimezoneOffsetInMilliseconds/index.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/getTimezoneOffsetInMilliseconds/index.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ getTimezoneOffsetInMilliseconds) +/* harmony export */ }); +var MILLISECONDS_IN_MINUTE = 60000; + +function getDateMillisecondsPart(date) { + return date.getTime() % MILLISECONDS_IN_MINUTE; +} +/** + * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds. + * They usually appear for dates that denote time before the timezones were introduced + * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891 + * and GMT+01:00:00 after that date) + * + * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above, + * which would lead to incorrect calculations. + * + * This function returns the timezone offset in milliseconds that takes seconds in account. + */ + + +function getTimezoneOffsetInMilliseconds(dirtyDate) { + var date = new Date(dirtyDate.getTime()); + var baseTimezoneOffset = Math.ceil(date.getTimezoneOffset()); + date.setSeconds(0, 0); + var hasNegativeUTCOffset = baseTimezoneOffset > 0; + var millisecondsPartOfTimezoneOffset = hasNegativeUTCOffset ? (MILLISECONDS_IN_MINUTE + getDateMillisecondsPart(date)) % MILLISECONDS_IN_MINUTE : getDateMillisecondsPart(date); + return baseTimezoneOffset * MILLISECONDS_IN_MINUTE + millisecondsPartOfTimezoneOffset; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/getUTCDayOfYear/index.js": +/*!*****************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/getUTCDayOfYear/index.js ***! + \*****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ getUTCDayOfYear) +/* harmony export */ }); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + +var MILLISECONDS_IN_DAY = 86400000; // This function will be a part of public API when UTC function will be implemented. +// See issue: https://github.com/date-fns/date-fns/issues/376 + +function getUTCDayOfYear(dirtyDate) { + (0,_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(1, arguments); + var date = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDate); + var timestamp = date.getTime(); + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); + var startOfYearTimestamp = date.getTime(); + var difference = timestamp - startOfYearTimestamp; + return Math.floor(difference / MILLISECONDS_IN_DAY) + 1; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/getUTCISOWeek/index.js": +/*!***************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/getUTCISOWeek/index.js ***! + \***************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ getUTCISOWeek) +/* harmony export */ }); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _startOfUTCISOWeek_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../startOfUTCISOWeek/index.js */ "./node_modules/date-fns/esm/_lib/startOfUTCISOWeek/index.js"); +/* harmony import */ var _startOfUTCISOWeekYear_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../startOfUTCISOWeekYear/index.js */ "./node_modules/date-fns/esm/_lib/startOfUTCISOWeekYear/index.js"); +/* harmony import */ var _requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + + + +var MILLISECONDS_IN_WEEK = 604800000; // This function will be a part of public API when UTC function will be implemented. +// See issue: https://github.com/date-fns/date-fns/issues/376 + +function getUTCISOWeek(dirtyDate) { + (0,_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(1, arguments); + var date = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDate); + var diff = (0,_startOfUTCISOWeek_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(date).getTime() - (0,_startOfUTCISOWeekYear_index_js__WEBPACK_IMPORTED_MODULE_3__.default)(date).getTime(); // Round the number of days to the nearest integer + // because the number of milliseconds in a week is not constant + // (e.g. it's different in the week of the daylight saving time clock shift) + + return Math.round(diff / MILLISECONDS_IN_WEEK) + 1; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/getUTCISOWeekYear/index.js": +/*!*******************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/getUTCISOWeekYear/index.js ***! + \*******************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ getUTCISOWeekYear) +/* harmony export */ }); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _startOfUTCISOWeek_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../startOfUTCISOWeek/index.js */ "./node_modules/date-fns/esm/_lib/startOfUTCISOWeek/index.js"); +/* harmony import */ var _requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + + // This function will be a part of public API when UTC function will be implemented. +// See issue: https://github.com/date-fns/date-fns/issues/376 + +function getUTCISOWeekYear(dirtyDate) { + (0,_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(1, arguments); + var date = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDate); + var year = date.getUTCFullYear(); + var fourthOfJanuaryOfNextYear = new Date(0); + fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4); + fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0); + var startOfNextYear = (0,_startOfUTCISOWeek_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(fourthOfJanuaryOfNextYear); + var fourthOfJanuaryOfThisYear = new Date(0); + fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4); + fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0); + var startOfThisYear = (0,_startOfUTCISOWeek_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(fourthOfJanuaryOfThisYear); + + if (date.getTime() >= startOfNextYear.getTime()) { + return year + 1; + } else if (date.getTime() >= startOfThisYear.getTime()) { + return year; + } else { + return year - 1; + } +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/getUTCWeek/index.js": +/*!************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/getUTCWeek/index.js ***! + \************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ getUTCWeek) +/* harmony export */ }); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _startOfUTCWeek_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../startOfUTCWeek/index.js */ "./node_modules/date-fns/esm/_lib/startOfUTCWeek/index.js"); +/* harmony import */ var _startOfUTCWeekYear_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../startOfUTCWeekYear/index.js */ "./node_modules/date-fns/esm/_lib/startOfUTCWeekYear/index.js"); +/* harmony import */ var _requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + + + +var MILLISECONDS_IN_WEEK = 604800000; // This function will be a part of public API when UTC function will be implemented. +// See issue: https://github.com/date-fns/date-fns/issues/376 + +function getUTCWeek(dirtyDate, options) { + (0,_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(1, arguments); + var date = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDate); + var diff = (0,_startOfUTCWeek_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(date, options).getTime() - (0,_startOfUTCWeekYear_index_js__WEBPACK_IMPORTED_MODULE_3__.default)(date, options).getTime(); // Round the number of days to the nearest integer + // because the number of milliseconds in a week is not constant + // (e.g. it's different in the week of the daylight saving time clock shift) + + return Math.round(diff / MILLISECONDS_IN_WEEK) + 1; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/getUTCWeekYear/index.js": +/*!****************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/getUTCWeekYear/index.js ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ getUTCWeekYear) +/* harmony export */ }); +/* harmony import */ var _toInteger_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../toInteger/index.js */ "./node_modules/date-fns/esm/_lib/toInteger/index.js"); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _startOfUTCWeek_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../startOfUTCWeek/index.js */ "./node_modules/date-fns/esm/_lib/startOfUTCWeek/index.js"); +/* harmony import */ var _requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + + + // This function will be a part of public API when UTC function will be implemented. +// See issue: https://github.com/date-fns/date-fns/issues/376 + +function getUTCWeekYear(dirtyDate, dirtyOptions) { + (0,_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(1, arguments); + var date = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDate, dirtyOptions); + var year = date.getUTCFullYear(); + var options = dirtyOptions || {}; + var locale = options.locale; + var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate; + var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : (0,_toInteger_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(localeFirstWeekContainsDate); + var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : (0,_toInteger_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN + + if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) { + throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively'); + } + + var firstWeekOfNextYear = new Date(0); + firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate); + firstWeekOfNextYear.setUTCHours(0, 0, 0, 0); + var startOfNextYear = (0,_startOfUTCWeek_index_js__WEBPACK_IMPORTED_MODULE_3__.default)(firstWeekOfNextYear, dirtyOptions); + var firstWeekOfThisYear = new Date(0); + firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate); + firstWeekOfThisYear.setUTCHours(0, 0, 0, 0); + var startOfThisYear = (0,_startOfUTCWeek_index_js__WEBPACK_IMPORTED_MODULE_3__.default)(firstWeekOfThisYear, dirtyOptions); + + if (date.getTime() >= startOfNextYear.getTime()) { + return year + 1; + } else if (date.getTime() >= startOfThisYear.getTime()) { + return year; + } else { + return year - 1; + } +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/protectedTokens/index.js": +/*!*****************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/protectedTokens/index.js ***! + \*****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "isProtectedDayOfYearToken": () => (/* binding */ isProtectedDayOfYearToken), +/* harmony export */ "isProtectedWeekYearToken": () => (/* binding */ isProtectedWeekYearToken), +/* harmony export */ "throwProtectedError": () => (/* binding */ throwProtectedError) +/* harmony export */ }); +var protectedDayOfYearTokens = ['D', 'DD']; +var protectedWeekYearTokens = ['YY', 'YYYY']; +function isProtectedDayOfYearToken(token) { + return protectedDayOfYearTokens.indexOf(token) !== -1; +} +function isProtectedWeekYearToken(token) { + return protectedWeekYearTokens.indexOf(token) !== -1; +} +function throwProtectedError(token, format, input) { + if (token === 'YYYY') { + throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr")); + } else if (token === 'YY') { + throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr")); + } else if (token === 'D') { + throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr")); + } else if (token === 'DD') { + throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr")); + } +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js": +/*!**************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/requiredArgs/index.js ***! + \**************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ requiredArgs) +/* harmony export */ }); +function requiredArgs(required, args) { + if (args.length < required) { + throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present'); + } +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/startOfUTCISOWeek/index.js": +/*!*******************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/startOfUTCISOWeek/index.js ***! + \*******************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ startOfUTCISOWeek) +/* harmony export */ }); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + // This function will be a part of public API when UTC function will be implemented. +// See issue: https://github.com/date-fns/date-fns/issues/376 + +function startOfUTCISOWeek(dirtyDate) { + (0,_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(1, arguments); + var weekStartsOn = 1; + var date = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDate); + var day = date.getUTCDay(); + var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; + date.setUTCDate(date.getUTCDate() - diff); + date.setUTCHours(0, 0, 0, 0); + return date; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/startOfUTCISOWeekYear/index.js": +/*!***********************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/startOfUTCISOWeekYear/index.js ***! + \***********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ startOfUTCISOWeekYear) +/* harmony export */ }); +/* harmony import */ var _getUTCISOWeekYear_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../getUTCISOWeekYear/index.js */ "./node_modules/date-fns/esm/_lib/getUTCISOWeekYear/index.js"); +/* harmony import */ var _startOfUTCISOWeek_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../startOfUTCISOWeek/index.js */ "./node_modules/date-fns/esm/_lib/startOfUTCISOWeek/index.js"); +/* harmony import */ var _requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + + // This function will be a part of public API when UTC function will be implemented. +// See issue: https://github.com/date-fns/date-fns/issues/376 + +function startOfUTCISOWeekYear(dirtyDate) { + (0,_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(1, arguments); + var year = (0,_getUTCISOWeekYear_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDate); + var fourthOfJanuary = new Date(0); + fourthOfJanuary.setUTCFullYear(year, 0, 4); + fourthOfJanuary.setUTCHours(0, 0, 0, 0); + var date = (0,_startOfUTCISOWeek_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(fourthOfJanuary); + return date; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/startOfUTCWeek/index.js": +/*!****************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/startOfUTCWeek/index.js ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ startOfUTCWeek) +/* harmony export */ }); +/* harmony import */ var _toInteger_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../toInteger/index.js */ "./node_modules/date-fns/esm/_lib/toInteger/index.js"); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + + // This function will be a part of public API when UTC function will be implemented. +// See issue: https://github.com/date-fns/date-fns/issues/376 + +function startOfUTCWeek(dirtyDate, dirtyOptions) { + (0,_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(1, arguments); + var options = dirtyOptions || {}; + var locale = options.locale; + var localeWeekStartsOn = locale && locale.options && locale.options.weekStartsOn; + var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : (0,_toInteger_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(localeWeekStartsOn); + var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : (0,_toInteger_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN + + if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { + throw new RangeError('weekStartsOn must be between 0 and 6 inclusively'); + } + + var date = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(dirtyDate); + var day = date.getUTCDay(); + var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; + date.setUTCDate(date.getUTCDate() - diff); + date.setUTCHours(0, 0, 0, 0); + return date; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/startOfUTCWeekYear/index.js": +/*!********************************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/startOfUTCWeekYear/index.js ***! + \********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ startOfUTCWeekYear) +/* harmony export */ }); +/* harmony import */ var _toInteger_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../toInteger/index.js */ "./node_modules/date-fns/esm/_lib/toInteger/index.js"); +/* harmony import */ var _getUTCWeekYear_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../getUTCWeekYear/index.js */ "./node_modules/date-fns/esm/_lib/getUTCWeekYear/index.js"); +/* harmony import */ var _startOfUTCWeek_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../startOfUTCWeek/index.js */ "./node_modules/date-fns/esm/_lib/startOfUTCWeek/index.js"); +/* harmony import */ var _requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + + + // This function will be a part of public API when UTC function will be implemented. +// See issue: https://github.com/date-fns/date-fns/issues/376 + +function startOfUTCWeekYear(dirtyDate, dirtyOptions) { + (0,_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(1, arguments); + var options = dirtyOptions || {}; + var locale = options.locale; + var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate; + var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : (0,_toInteger_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(localeFirstWeekContainsDate); + var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : (0,_toInteger_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(options.firstWeekContainsDate); + var year = (0,_getUTCWeekYear_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(dirtyDate, dirtyOptions); + var firstWeek = new Date(0); + firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate); + firstWeek.setUTCHours(0, 0, 0, 0); + var date = (0,_startOfUTCWeek_index_js__WEBPACK_IMPORTED_MODULE_3__.default)(firstWeek, dirtyOptions); + return date; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/_lib/toInteger/index.js": +/*!***********************************************************!*\ + !*** ./node_modules/date-fns/esm/_lib/toInteger/index.js ***! + \***********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ toInteger) +/* harmony export */ }); +function toInteger(dirtyNumber) { + if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) { + return NaN; + } + + var number = Number(dirtyNumber); + + if (isNaN(number)) { + return number; + } + + return number < 0 ? Math.ceil(number) : Math.floor(number); +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/addMilliseconds/index.js": +/*!************************************************************!*\ + !*** ./node_modules/date-fns/esm/addMilliseconds/index.js ***! + \************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ addMilliseconds) +/* harmony export */ }); +/* harmony import */ var _lib_toInteger_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../_lib/toInteger/index.js */ "./node_modules/date-fns/esm/_lib/toInteger/index.js"); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../_lib/requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + + +/** + * @name addMilliseconds + * @category Millisecond Helpers + * @summary Add the specified number of milliseconds to the given date. + * + * @description + * Add the specified number of milliseconds to the given date. + * + * ### v2.0.0 breaking changes: + * + * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes). + * + * @param {Date|Number} date - the date to be changed + * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`. + * @returns {Date} the new date with the milliseconds added + * @throws {TypeError} 2 arguments required + * + * @example + * // Add 750 milliseconds to 10 July 2014 12:45:30.000: + * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750) + * //=> Thu Jul 10 2014 12:45:30.750 + */ + +function addMilliseconds(dirtyDate, dirtyAmount) { + (0,_lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(2, arguments); + var timestamp = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDate).getTime(); + var amount = (0,_lib_toInteger_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(dirtyAmount); + return new Date(timestamp + amount); +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/compareAsc/index.js": +/*!*******************************************************!*\ + !*** ./node_modules/date-fns/esm/compareAsc/index.js ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ compareAsc) +/* harmony export */ }); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../_lib/requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + +/** + * @name compareAsc + * @category Common Helpers + * @summary Compare the two dates and return -1, 0 or 1. + * + * @description + * Compare the two dates and return 1 if the first date is after the second, + * -1 if the first date is before the second or 0 if dates are equal. + * + * ### v2.0.0 breaking changes: + * + * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes). + * + * @param {Date|Number} dateLeft - the first date to compare + * @param {Date|Number} dateRight - the second date to compare + * @returns {Number} the result of the comparison + * @throws {TypeError} 2 arguments required + * + * @example + * // Compare 11 February 1987 and 10 July 1989: + * const result = compareAsc(new Date(1987, 1, 11), new Date(1989, 6, 10)) + * //=> -1 + * + * @example + * // Sort the array of dates: + * const result = [ + * new Date(1995, 6, 2), + * new Date(1987, 1, 11), + * new Date(1989, 6, 10) + * ].sort(compareAsc) + * //=> [ + * // Wed Feb 11 1987 00:00:00, + * // Mon Jul 10 1989 00:00:00, + * // Sun Jul 02 1995 00:00:00 + * // ] + */ + +function compareAsc(dirtyDateLeft, dirtyDateRight) { + (0,_lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(2, arguments); + var dateLeft = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDateLeft); + var dateRight = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDateRight); + var diff = dateLeft.getTime() - dateRight.getTime(); + + if (diff < 0) { + return -1; + } else if (diff > 0) { + return 1; // Return 0 if diff is 0; return NaN if diff is NaN + } else { + return diff; + } +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/differenceInCalendarMonths/index.js": +/*!***********************************************************************!*\ + !*** ./node_modules/date-fns/esm/differenceInCalendarMonths/index.js ***! + \***********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ differenceInCalendarMonths) +/* harmony export */ }); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../_lib/requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + +/** + * @name differenceInCalendarMonths + * @category Month Helpers + * @summary Get the number of calendar months between the given dates. + * + * @description + * Get the number of calendar months between the given dates. + * + * ### v2.0.0 breaking changes: + * + * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes). + * + * @param {Date|Number} dateLeft - the later date + * @param {Date|Number} dateRight - the earlier date + * @returns {Number} the number of calendar months + * @throws {TypeError} 2 arguments required + * + * @example + * // How many calendar months are between 31 January 2014 and 1 September 2014? + * var result = differenceInCalendarMonths( + * new Date(2014, 8, 1), + * new Date(2014, 0, 31) + * ) + * //=> 8 + */ + +function differenceInCalendarMonths(dirtyDateLeft, dirtyDateRight) { + (0,_lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(2, arguments); + var dateLeft = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDateLeft); + var dateRight = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDateRight); + var yearDiff = dateLeft.getFullYear() - dateRight.getFullYear(); + var monthDiff = dateLeft.getMonth() - dateRight.getMonth(); + return yearDiff * 12 + monthDiff; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/differenceInMilliseconds/index.js": +/*!*********************************************************************!*\ + !*** ./node_modules/date-fns/esm/differenceInMilliseconds/index.js ***! + \*********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ differenceInMilliseconds) +/* harmony export */ }); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../_lib/requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + +/** + * @name differenceInMilliseconds + * @category Millisecond Helpers + * @summary Get the number of milliseconds between the given dates. + * + * @description + * Get the number of milliseconds between the given dates. + * + * ### v2.0.0 breaking changes: + * + * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes). + * + * @param {Date|Number} dateLeft - the later date + * @param {Date|Number} dateRight - the earlier date + * @returns {Number} the number of milliseconds + * @throws {TypeError} 2 arguments required + * + * @example + * // How many milliseconds are between + * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700? + * var result = differenceInMilliseconds( + * new Date(2014, 6, 2, 12, 30, 21, 700), + * new Date(2014, 6, 2, 12, 30, 20, 600) + * ) + * //=> 1100 + */ + +function differenceInMilliseconds(dirtyDateLeft, dirtyDateRight) { + (0,_lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(2, arguments); + var dateLeft = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDateLeft); + var dateRight = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDateRight); + return dateLeft.getTime() - dateRight.getTime(); +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/differenceInMonths/index.js": +/*!***************************************************************!*\ + !*** ./node_modules/date-fns/esm/differenceInMonths/index.js ***! + \***************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ differenceInMonths) +/* harmony export */ }); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _differenceInCalendarMonths_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../differenceInCalendarMonths/index.js */ "./node_modules/date-fns/esm/differenceInCalendarMonths/index.js"); +/* harmony import */ var _compareAsc_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../compareAsc/index.js */ "./node_modules/date-fns/esm/compareAsc/index.js"); +/* harmony import */ var _lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../_lib/requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); +/* harmony import */ var _isLastDayOfMonth_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../isLastDayOfMonth/index.js */ "./node_modules/date-fns/esm/isLastDayOfMonth/index.js"); + + + + + +/** + * @name differenceInMonths + * @category Month Helpers + * @summary Get the number of full months between the given dates. + * + * @description + * Get the number of full months between the given dates. + * + * ### v2.0.0 breaking changes: + * + * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes). + * + * @param {Date|Number} dateLeft - the later date + * @param {Date|Number} dateRight - the earlier date + * @returns {Number} the number of full months + * @throws {TypeError} 2 arguments required + * + * @example + * // How many full months are between 31 January 2014 and 1 September 2014? + * var result = differenceInMonths(new Date(2014, 8, 1), new Date(2014, 0, 31)) + * //=> 7 + */ + +function differenceInMonths(dirtyDateLeft, dirtyDateRight) { + (0,_lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(2, arguments); + var dateLeft = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDateLeft); + var dateRight = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDateRight); + var sign = (0,_compareAsc_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(dateLeft, dateRight); + var difference = Math.abs((0,_differenceInCalendarMonths_index_js__WEBPACK_IMPORTED_MODULE_3__.default)(dateLeft, dateRight)); // This will check if the date is end of Feb and assign a higher end of month date + // to compare it with Jan + + if (dateLeft.getMonth() === 1 && dateLeft.getDate() > 27) { + dateLeft.setDate(30); + } + + dateLeft.setMonth(dateLeft.getMonth() - sign * difference); // Math.abs(diff in full months - diff in calendar months) === 1 if last calendar month is not full + // If so, result must be decreased by 1 in absolute value + + var isLastMonthNotFull = (0,_compareAsc_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(dateLeft, dateRight) === -sign; // Check for cases of one full calendar month + + if ((0,_isLastDayOfMonth_index_js__WEBPACK_IMPORTED_MODULE_4__.default)((0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDateLeft)) && difference === 1 && (0,_compareAsc_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(dirtyDateLeft, dateRight) === 1) { + isLastMonthNotFull = false; + } + + var result = sign * (difference - isLastMonthNotFull); // Prevent negative zero + + return result === 0 ? 0 : result; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/differenceInSeconds/index.js": +/*!****************************************************************!*\ + !*** ./node_modules/date-fns/esm/differenceInSeconds/index.js ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ differenceInSeconds) +/* harmony export */ }); +/* harmony import */ var _differenceInMilliseconds_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../differenceInMilliseconds/index.js */ "./node_modules/date-fns/esm/differenceInMilliseconds/index.js"); +/* harmony import */ var _lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../_lib/requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + +/** + * @name differenceInSeconds + * @category Second Helpers + * @summary Get the number of seconds between the given dates. + * + * @description + * Get the number of seconds between the given dates. + * + * ### v2.0.0 breaking changes: + * + * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes). + * + * @param {Date|Number} dateLeft - the later date + * @param {Date|Number} dateRight - the earlier date + * @returns {Number} the number of seconds + * @throws {TypeError} 2 arguments required + * + * @example + * // How many seconds are between + * // 2 July 2014 12:30:07.999 and 2 July 2014 12:30:20.000? + * var result = differenceInSeconds( + * new Date(2014, 6, 2, 12, 30, 20, 0), + * new Date(2014, 6, 2, 12, 30, 7, 999) + * ) + * //=> 12 + */ + +function differenceInSeconds(dirtyDateLeft, dirtyDateRight) { + (0,_lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(2, arguments); + var diff = (0,_differenceInMilliseconds_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDateLeft, dirtyDateRight) / 1000; + return diff > 0 ? Math.floor(diff) : Math.ceil(diff); +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/endOfDay/index.js": +/*!*****************************************************!*\ + !*** ./node_modules/date-fns/esm/endOfDay/index.js ***! + \*****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ endOfDay) +/* harmony export */ }); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../_lib/requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + +/** + * @name endOfDay + * @category Day Helpers + * @summary Return the end of a day for the given date. + * + * @description + * Return the end of a day for the given date. + * The result will be in the local timezone. + * + * ### v2.0.0 breaking changes: + * + * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes). + * + * @param {Date|Number} date - the original date + * @returns {Date} the end of a day + * @throws {TypeError} 1 argument required + * + * @example + * // The end of a day for 2 September 2014 11:55:00: + * const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 02 2014 23:59:59.999 + */ + +function endOfDay(dirtyDate) { + (0,_lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(1, arguments); + var date = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDate); + date.setHours(23, 59, 59, 999); + return date; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/endOfMonth/index.js": +/*!*******************************************************!*\ + !*** ./node_modules/date-fns/esm/endOfMonth/index.js ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ endOfMonth) +/* harmony export */ }); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../_lib/requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + +/** + * @name endOfMonth + * @category Month Helpers + * @summary Return the end of a month for the given date. + * + * @description + * Return the end of a month for the given date. + * The result will be in the local timezone. + * + * ### v2.0.0 breaking changes: + * + * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes). + * + * @param {Date|Number} date - the original date + * @returns {Date} the end of a month + * @throws {TypeError} 1 argument required + * + * @example + * // The end of a month for 2 September 2014 11:55:00: + * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 30 2014 23:59:59.999 + */ + +function endOfMonth(dirtyDate) { + (0,_lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(1, arguments); + var date = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDate); + var month = date.getMonth(); + date.setFullYear(date.getFullYear(), month + 1, 0); + date.setHours(23, 59, 59, 999); + return date; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/format/index.js": +/*!***************************************************!*\ + !*** ./node_modules/date-fns/esm/format/index.js ***! + \***************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ format) +/* harmony export */ }); +/* harmony import */ var _isValid_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../isValid/index.js */ "./node_modules/date-fns/esm/isValid/index.js"); +/* harmony import */ var _locale_en_US_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../locale/en-US/index.js */ "./node_modules/date-fns/esm/locale/en-US/index.js"); +/* harmony import */ var _subMilliseconds_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../subMilliseconds/index.js */ "./node_modules/date-fns/esm/subMilliseconds/index.js"); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _lib_format_formatters_index_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../_lib/format/formatters/index.js */ "./node_modules/date-fns/esm/_lib/format/formatters/index.js"); +/* harmony import */ var _lib_format_longFormatters_index_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../_lib/format/longFormatters/index.js */ "./node_modules/date-fns/esm/_lib/format/longFormatters/index.js"); +/* harmony import */ var _lib_getTimezoneOffsetInMilliseconds_index_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../_lib/getTimezoneOffsetInMilliseconds/index.js */ "./node_modules/date-fns/esm/_lib/getTimezoneOffsetInMilliseconds/index.js"); +/* harmony import */ var _lib_protectedTokens_index_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../_lib/protectedTokens/index.js */ "./node_modules/date-fns/esm/_lib/protectedTokens/index.js"); +/* harmony import */ var _lib_toInteger_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../_lib/toInteger/index.js */ "./node_modules/date-fns/esm/_lib/toInteger/index.js"); +/* harmony import */ var _lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../_lib/requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + + + + + + + + + // This RegExp consists of three parts separated by `|`: +// - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token +// (one of the certain letters followed by `o`) +// - (\w)\1* matches any sequences of the same letter +// - '' matches two quote characters in a row +// - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('), +// except a single quote symbol, which ends the sequence. +// Two quote characters do not end the sequence. +// If there is no matching single quote +// then the sequence will continue until the end of the string. +// - . matches any single character unmatched by previous parts of the RegExps + +var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; // This RegExp catches symbols escaped by quotes, and also +// sequences of symbols P, p, and the combinations like `PPPPPPPppppp` + +var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; +var escapedStringRegExp = /^'([^]*?)'?$/; +var doubleQuoteRegExp = /''/g; +var unescapedLatinCharacterRegExp = /[a-zA-Z]/; +/** + * @name format + * @category Common Helpers + * @summary Format the date. + * + * @description + * Return the formatted date string in the given format. The result may vary by locale. + * + * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries. + * > See: https://git.io/fxCyr + * + * The characters wrapped between two single quotes characters (') are escaped. + * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote. + * (see the last example) + * + * Format of the string is based on Unicode Technical Standard #35: + * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table + * with a few additions (see note 7 below the table). + * + * Accepted patterns: + * | Unit | Pattern | Result examples | Notes | + * |---------------------------------|---------|-----------------------------------|-------| + * | Era | G..GGG | AD, BC | | + * | | GGGG | Anno Domini, Before Christ | 2 | + * | | GGGGG | A, B | | + * | Calendar year | y | 44, 1, 1900, 2017 | 5 | + * | | yo | 44th, 1st, 0th, 17th | 5,7 | + * | | yy | 44, 01, 00, 17 | 5 | + * | | yyy | 044, 001, 1900, 2017 | 5 | + * | | yyyy | 0044, 0001, 1900, 2017 | 5 | + * | | yyyyy | ... | 3,5 | + * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 | + * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 | + * | | YY | 44, 01, 00, 17 | 5,8 | + * | | YYY | 044, 001, 1900, 2017 | 5 | + * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 | + * | | YYYYY | ... | 3,5 | + * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 | + * | | RR | -43, 00, 01, 1900, 2017 | 5,7 | + * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 | + * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 | + * | | RRRRR | ... | 3,5,7 | + * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 | + * | | uu | -43, 01, 1900, 2017 | 5 | + * | | uuu | -043, 001, 1900, 2017 | 5 | + * | | uuuu | -0043, 0001, 1900, 2017 | 5 | + * | | uuuuu | ... | 3,5 | + * | Quarter (formatting) | Q | 1, 2, 3, 4 | | + * | | Qo | 1st, 2nd, 3rd, 4th | 7 | + * | | QQ | 01, 02, 03, 04 | | + * | | QQQ | Q1, Q2, Q3, Q4 | | + * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 | + * | | QQQQQ | 1, 2, 3, 4 | 4 | + * | Quarter (stand-alone) | q | 1, 2, 3, 4 | | + * | | qo | 1st, 2nd, 3rd, 4th | 7 | + * | | qq | 01, 02, 03, 04 | | + * | | qqq | Q1, Q2, Q3, Q4 | | + * | | qqqq | 1st quarter, 2nd quarter, ... | 2 | + * | | qqqqq | 1, 2, 3, 4 | 4 | + * | Month (formatting) | M | 1, 2, ..., 12 | | + * | | Mo | 1st, 2nd, ..., 12th | 7 | + * | | MM | 01, 02, ..., 12 | | + * | | MMM | Jan, Feb, ..., Dec | | + * | | MMMM | January, February, ..., December | 2 | + * | | MMMMM | J, F, ..., D | | + * | Month (stand-alone) | L | 1, 2, ..., 12 | | + * | | Lo | 1st, 2nd, ..., 12th | 7 | + * | | LL | 01, 02, ..., 12 | | + * | | LLL | Jan, Feb, ..., Dec | | + * | | LLLL | January, February, ..., December | 2 | + * | | LLLLL | J, F, ..., D | | + * | Local week of year | w | 1, 2, ..., 53 | | + * | | wo | 1st, 2nd, ..., 53th | 7 | + * | | ww | 01, 02, ..., 53 | | + * | ISO week of year | I | 1, 2, ..., 53 | 7 | + * | | Io | 1st, 2nd, ..., 53th | 7 | + * | | II | 01, 02, ..., 53 | 7 | + * | Day of month | d | 1, 2, ..., 31 | | + * | | do | 1st, 2nd, ..., 31st | 7 | + * | | dd | 01, 02, ..., 31 | | + * | Day of year | D | 1, 2, ..., 365, 366 | 9 | + * | | Do | 1st, 2nd, ..., 365th, 366th | 7 | + * | | DD | 01, 02, ..., 365, 366 | 9 | + * | | DDD | 001, 002, ..., 365, 366 | | + * | | DDDD | ... | 3 | + * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | | + * | | EEEE | Monday, Tuesday, ..., Sunday | 2 | + * | | EEEEE | M, T, W, T, F, S, S | | + * | | EEEEEE | Mo, Tu, We, Th, Fr, Su, Sa | | + * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 | + * | | io | 1st, 2nd, ..., 7th | 7 | + * | | ii | 01, 02, ..., 07 | 7 | + * | | iii | Mon, Tue, Wed, ..., Sun | 7 | + * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 | + * | | iiiii | M, T, W, T, F, S, S | 7 | + * | | iiiiii | Mo, Tu, We, Th, Fr, Su, Sa | 7 | + * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | | + * | | eo | 2nd, 3rd, ..., 1st | 7 | + * | | ee | 02, 03, ..., 01 | | + * | | eee | Mon, Tue, Wed, ..., Sun | | + * | | eeee | Monday, Tuesday, ..., Sunday | 2 | + * | | eeeee | M, T, W, T, F, S, S | | + * | | eeeeee | Mo, Tu, We, Th, Fr, Su, Sa | | + * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | | + * | | co | 2nd, 3rd, ..., 1st | 7 | + * | | cc | 02, 03, ..., 01 | | + * | | ccc | Mon, Tue, Wed, ..., Sun | | + * | | cccc | Monday, Tuesday, ..., Sunday | 2 | + * | | ccccc | M, T, W, T, F, S, S | | + * | | cccccc | Mo, Tu, We, Th, Fr, Su, Sa | | + * | AM, PM | a..aa | AM, PM | | + * | | aaa | am, pm | | + * | | aaaa | a.m., p.m. | 2 | + * | | aaaaa | a, p | | + * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | | + * | | bbb | am, pm, noon, midnight | | + * | | bbbb | a.m., p.m., noon, midnight | 2 | + * | | bbbbb | a, p, n, mi | | + * | Flexible day period | B..BBB | at night, in the morning, ... | | + * | | BBBB | at night, in the morning, ... | 2 | + * | | BBBBB | at night, in the morning, ... | | + * | Hour [1-12] | h | 1, 2, ..., 11, 12 | | + * | | ho | 1st, 2nd, ..., 11th, 12th | 7 | + * | | hh | 01, 02, ..., 11, 12 | | + * | Hour [0-23] | H | 0, 1, 2, ..., 23 | | + * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 | + * | | HH | 00, 01, 02, ..., 23 | | + * | Hour [0-11] | K | 1, 2, ..., 11, 0 | | + * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 | + * | | KK | 01, 02, ..., 11, 00 | | + * | Hour [1-24] | k | 24, 1, 2, ..., 23 | | + * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 | + * | | kk | 24, 01, 02, ..., 23 | | + * | Minute | m | 0, 1, ..., 59 | | + * | | mo | 0th, 1st, ..., 59th | 7 | + * | | mm | 00, 01, ..., 59 | | + * | Second | s | 0, 1, ..., 59 | | + * | | so | 0th, 1st, ..., 59th | 7 | + * | | ss | 00, 01, ..., 59 | | + * | Fraction of second | S | 0, 1, ..., 9 | | + * | | SS | 00, 01, ..., 99 | | + * | | SSS | 000, 0001, ..., 999 | | + * | | SSSS | ... | 3 | + * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | | + * | | XX | -0800, +0530, Z | | + * | | XXX | -08:00, +05:30, Z | | + * | | XXXX | -0800, +0530, Z, +123456 | 2 | + * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | | + * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | | + * | | xx | -0800, +0530, +0000 | | + * | | xxx | -08:00, +05:30, +00:00 | 2 | + * | | xxxx | -0800, +0530, +0000, +123456 | | + * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | | + * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | | + * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 | + * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 | + * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 | + * | Seconds timestamp | t | 512969520 | 7 | + * | | tt | ... | 3,7 | + * | Milliseconds timestamp | T | 512969520900 | 7 | + * | | TT | ... | 3,7 | + * | Long localized date | P | 04/29/1453 | 7 | + * | | PP | Apr 29, 1453 | 7 | + * | | PPP | April 29th, 1453 | 7 | + * | | PPPP | Friday, April 29th, 1453 | 2,7 | + * | Long localized time | p | 12:00 AM | 7 | + * | | pp | 12:00:00 AM | 7 | + * | | ppp | 12:00:00 AM GMT+2 | 7 | + * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 | + * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 | + * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 | + * | | PPPppp | April 29th, 1453 at ... | 7 | + * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 | + * Notes: + * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale + * are the same as "stand-alone" units, but are different in some languages. + * "Formatting" units are declined according to the rules of the language + * in the context of a date. "Stand-alone" units are always nominative singular: + * + * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'` + * + * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'` + * + * 2. Any sequence of the identical letters is a pattern, unless it is escaped by + * the single quote characters (see below). + * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`) + * the output will be the same as default pattern for this unit, usually + * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units + * are marked with "2" in the last column of the table. + * + * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'` + * + * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'` + * + * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'` + * + * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'` + * + * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'` + * + * 3. Some patterns could be unlimited length (such as `yyyyyyyy`). + * The output will be padded with zeros to match the length of the pattern. + * + * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'` + * + * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales. + * These tokens represent the shortest form of the quarter. + * + * 5. The main difference between `y` and `u` patterns are B.C. years: + * + * | Year | `y` | `u` | + * |------|-----|-----| + * | AC 1 | 1 | 1 | + * | BC 1 | 1 | 0 | + * | BC 2 | 2 | -1 | + * + * Also `yy` always returns the last two digits of a year, + * while `uu` pads single digit years to 2 characters and returns other years unchanged: + * + * | Year | `yy` | `uu` | + * |------|------|------| + * | 1 | 01 | 01 | + * | 14 | 14 | 14 | + * | 376 | 76 | 376 | + * | 1453 | 53 | 1453 | + * + * The same difference is true for local and ISO week-numbering years (`Y` and `R`), + * except local week-numbering years are dependent on `options.weekStartsOn` + * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear} + * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}). + * + * 6. Specific non-location timezones are currently unavailable in `date-fns`, + * so right now these tokens fall back to GMT timezones. + * + * 7. These patterns are not in the Unicode Technical Standard #35: + * - `i`: ISO day of week + * - `I`: ISO week of year + * - `R`: ISO week-numbering year + * - `t`: seconds timestamp + * - `T`: milliseconds timestamp + * - `o`: ordinal number modifier + * - `P`: long localized date + * - `p`: long localized time + * + * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years. + * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://git.io/fxCyr + * + * 9. `D` and `DD` tokens represent days of the year but they are ofthen confused with days of the month. + * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://git.io/fxCyr + * + * ### v2.0.0 breaking changes: + * + * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes). + * + * - The second argument is now required for the sake of explicitness. + * + * ```javascript + * // Before v2.0.0 + * format(new Date(2016, 0, 1)) + * + * // v2.0.0 onward + * format(new Date(2016, 0, 1), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx") + * ``` + * + * - New format string API for `format` function + * which is based on [Unicode Technical Standard #35](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table). + * See [this post](https://blog.date-fns.org/post/unicode-tokens-in-date-fns-v2-sreatyki91jg) for more details. + * + * - Characters are now escaped using single quote symbols (`'`) instead of square brackets. + * + * @param {Date|Number} date - the original date + * @param {String} format - the string of tokens + * @param {Object} [options] - an object with options. + * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale} + * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) + * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is + * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`; + * see: https://git.io/fxCyr + * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`; + * see: https://git.io/fxCyr + * @returns {String} the formatted date string + * @throws {TypeError} 2 arguments required + * @throws {RangeError} `date` must not be Invalid Date + * @throws {RangeError} `options.locale` must contain `localize` property + * @throws {RangeError} `options.locale` must contain `formatLong` property + * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6 + * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7 + * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://git.io/fxCyr + * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://git.io/fxCyr + * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://git.io/fxCyr + * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://git.io/fxCyr + * @throws {RangeError} format string contains an unescaped latin alphabet character + * + * @example + * // Represent 11 February 2014 in middle-endian format: + * var result = format(new Date(2014, 1, 11), 'MM/dd/yyyy') + * //=> '02/11/2014' + * + * @example + * // Represent 2 July 2014 in Esperanto: + * import { eoLocale } from 'date-fns/locale/eo' + * var result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", { + * locale: eoLocale + * }) + * //=> '2-a de julio 2014' + * + * @example + * // Escape string by single quote characters: + * var result = format(new Date(2014, 6, 2, 15), "h 'o''clock'") + * //=> "3 o'clock" + */ + +function format(dirtyDate, dirtyFormatStr, dirtyOptions) { + (0,_lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(2, arguments); + var formatStr = String(dirtyFormatStr); + var options = dirtyOptions || {}; + var locale = options.locale || _locale_en_US_index_js__WEBPACK_IMPORTED_MODULE_1__.default; + var localeFirstWeekContainsDate = locale.options && locale.options.firstWeekContainsDate; + var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : (0,_lib_toInteger_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(localeFirstWeekContainsDate); + var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : (0,_lib_toInteger_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN + + if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) { + throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively'); + } + + var localeWeekStartsOn = locale.options && locale.options.weekStartsOn; + var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : (0,_lib_toInteger_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(localeWeekStartsOn); + var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : (0,_lib_toInteger_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN + + if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { + throw new RangeError('weekStartsOn must be between 0 and 6 inclusively'); + } + + if (!locale.localize) { + throw new RangeError('locale must contain localize property'); + } + + if (!locale.formatLong) { + throw new RangeError('locale must contain formatLong property'); + } + + var originalDate = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_3__.default)(dirtyDate); + + if (!(0,_isValid_index_js__WEBPACK_IMPORTED_MODULE_4__.default)(originalDate)) { + throw new RangeError('Invalid time value'); + } // Convert the date in system timezone to the same date in UTC+00:00 timezone. + // This ensures that when UTC functions will be implemented, locales will be compatible with them. + // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376 + + + var timezoneOffset = (0,_lib_getTimezoneOffsetInMilliseconds_index_js__WEBPACK_IMPORTED_MODULE_5__.default)(originalDate); + var utcDate = (0,_subMilliseconds_index_js__WEBPACK_IMPORTED_MODULE_6__.default)(originalDate, timezoneOffset); + var formatterOptions = { + firstWeekContainsDate: firstWeekContainsDate, + weekStartsOn: weekStartsOn, + locale: locale, + _originalDate: originalDate + }; + var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) { + var firstCharacter = substring[0]; + + if (firstCharacter === 'p' || firstCharacter === 'P') { + var longFormatter = _lib_format_longFormatters_index_js__WEBPACK_IMPORTED_MODULE_7__.default[firstCharacter]; + return longFormatter(substring, locale.formatLong, formatterOptions); + } + + return substring; + }).join('').match(formattingTokensRegExp).map(function (substring) { + // Replace two single quote characters with one single quote character + if (substring === "''") { + return "'"; + } + + var firstCharacter = substring[0]; + + if (firstCharacter === "'") { + return cleanEscapedString(substring); + } + + var formatter = _lib_format_formatters_index_js__WEBPACK_IMPORTED_MODULE_8__.default[firstCharacter]; + + if (formatter) { + if (!options.useAdditionalWeekYearTokens && (0,_lib_protectedTokens_index_js__WEBPACK_IMPORTED_MODULE_9__.isProtectedWeekYearToken)(substring)) { + (0,_lib_protectedTokens_index_js__WEBPACK_IMPORTED_MODULE_9__.throwProtectedError)(substring, dirtyFormatStr, dirtyDate); + } + + if (!options.useAdditionalDayOfYearTokens && (0,_lib_protectedTokens_index_js__WEBPACK_IMPORTED_MODULE_9__.isProtectedDayOfYearToken)(substring)) { + (0,_lib_protectedTokens_index_js__WEBPACK_IMPORTED_MODULE_9__.throwProtectedError)(substring, dirtyFormatStr, dirtyDate); + } + + return formatter(utcDate, substring, locale.localize, formatterOptions); + } + + if (firstCharacter.match(unescapedLatinCharacterRegExp)) { + throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`'); + } + + return substring; + }).join(''); + return result; +} + +function cleanEscapedString(input) { + return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, "'"); +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/formatDistance/index.js": +/*!***********************************************************!*\ + !*** ./node_modules/date-fns/esm/formatDistance/index.js ***! + \***********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ formatDistance) +/* harmony export */ }); +/* harmony import */ var _compareAsc_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../compareAsc/index.js */ "./node_modules/date-fns/esm/compareAsc/index.js"); +/* harmony import */ var _differenceInMonths_index_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../differenceInMonths/index.js */ "./node_modules/date-fns/esm/differenceInMonths/index.js"); +/* harmony import */ var _differenceInSeconds_index_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../differenceInSeconds/index.js */ "./node_modules/date-fns/esm/differenceInSeconds/index.js"); +/* harmony import */ var _locale_en_US_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../locale/en-US/index.js */ "./node_modules/date-fns/esm/locale/en-US/index.js"); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _lib_cloneObject_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../_lib/cloneObject/index.js */ "./node_modules/date-fns/esm/_lib/cloneObject/index.js"); +/* harmony import */ var _lib_getTimezoneOffsetInMilliseconds_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../_lib/getTimezoneOffsetInMilliseconds/index.js */ "./node_modules/date-fns/esm/_lib/getTimezoneOffsetInMilliseconds/index.js"); +/* harmony import */ var _lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../_lib/requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + + + + + + + +var MINUTES_IN_DAY = 1440; +var MINUTES_IN_ALMOST_TWO_DAYS = 2520; +var MINUTES_IN_MONTH = 43200; +var MINUTES_IN_TWO_MONTHS = 86400; +/** + * @name formatDistance + * @category Common Helpers + * @summary Return the distance between the given dates in words. + * + * @description + * Return the distance between the given dates in words. + * + * | Distance between dates | Result | + * |-------------------------------------------------------------------|---------------------| + * | 0 ... 30 secs | less than a minute | + * | 30 secs ... 1 min 30 secs | 1 minute | + * | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes | + * | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour | + * | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours | + * | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day | + * | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days | + * | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month | + * | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months | + * | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months | + * | 1 yr ... 1 yr 3 months | about 1 year | + * | 1 yr 3 months ... 1 yr 9 month s | over 1 year | + * | 1 yr 9 months ... 2 yrs | almost 2 years | + * | N yrs ... N yrs 3 months | about N years | + * | N yrs 3 months ... N yrs 9 months | over N years | + * | N yrs 9 months ... N+1 yrs | almost N+1 years | + * + * With `options.includeSeconds == true`: + * | Distance between dates | Result | + * |------------------------|----------------------| + * | 0 secs ... 5 secs | less than 5 seconds | + * | 5 secs ... 10 secs | less than 10 seconds | + * | 10 secs ... 20 secs | less than 20 seconds | + * | 20 secs ... 40 secs | half a minute | + * | 40 secs ... 60 secs | less than a minute | + * | 60 secs ... 90 secs | 1 minute | + * + * ### v2.0.0 breaking changes: + * + * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes). + * + * - The function was renamed from `distanceInWords ` to `formatDistance` + * to make its name consistent with `format` and `formatRelative`. + * + * - The order of arguments is swapped to make the function + * consistent with `differenceIn...` functions. + * + * ```javascript + * // Before v2.0.0 + * + * distanceInWords( + * new Date(1986, 3, 4, 10, 32, 0), + * new Date(1986, 3, 4, 11, 32, 0), + * { addSuffix: true } + * ) //=> 'in about 1 hour' + * + * // v2.0.0 onward + * + * formatDistance( + * new Date(1986, 3, 4, 11, 32, 0), + * new Date(1986, 3, 4, 10, 32, 0), + * { addSuffix: true } + * ) //=> 'in about 1 hour' + * ``` + * + * @param {Date|Number} date - the date + * @param {Date|Number} baseDate - the date to compare with + * @param {Object} [options] - an object with options. + * @param {Boolean} [options.includeSeconds=false] - distances less than a minute are more detailed + * @param {Boolean} [options.addSuffix=false] - result indicates if the second date is earlier or later than the first + * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale} + * @returns {String} the distance in words + * @throws {TypeError} 2 arguments required + * @throws {RangeError} `date` must not be Invalid Date + * @throws {RangeError} `baseDate` must not be Invalid Date + * @throws {RangeError} `options.locale` must contain `formatDistance` property + * + * @example + * // What is the distance between 2 July 2014 and 1 January 2015? + * var result = formatDistance(new Date(2014, 6, 2), new Date(2015, 0, 1)) + * //=> '6 months' + * + * @example + * // What is the distance between 1 January 2015 00:00:15 + * // and 1 January 2015 00:00:00, including seconds? + * var result = formatDistance( + * new Date(2015, 0, 1, 0, 0, 15), + * new Date(2015, 0, 1, 0, 0, 0), + * { includeSeconds: true } + * ) + * //=> 'less than 20 seconds' + * + * @example + * // What is the distance from 1 January 2016 + * // to 1 January 2015, with a suffix? + * var result = formatDistance(new Date(2015, 0, 1), new Date(2016, 0, 1), { + * addSuffix: true + * }) + * //=> 'about 1 year ago' + * + * @example + * // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto? + * import { eoLocale } from 'date-fns/locale/eo' + * var result = formatDistance(new Date(2016, 7, 1), new Date(2015, 0, 1), { + * locale: eoLocale + * }) + * //=> 'pli ol 1 jaro' + */ + +function formatDistance(dirtyDate, dirtyBaseDate, dirtyOptions) { + (0,_lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(2, arguments); + var options = dirtyOptions || {}; + var locale = options.locale || _locale_en_US_index_js__WEBPACK_IMPORTED_MODULE_1__.default; + + if (!locale.formatDistance) { + throw new RangeError('locale must contain formatDistance property'); + } + + var comparison = (0,_compareAsc_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(dirtyDate, dirtyBaseDate); + + if (isNaN(comparison)) { + throw new RangeError('Invalid time value'); + } + + var localizeOptions = (0,_lib_cloneObject_index_js__WEBPACK_IMPORTED_MODULE_3__.default)(options); + localizeOptions.addSuffix = Boolean(options.addSuffix); + localizeOptions.comparison = comparison; + var dateLeft; + var dateRight; + + if (comparison > 0) { + dateLeft = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_4__.default)(dirtyBaseDate); + dateRight = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_4__.default)(dirtyDate); + } else { + dateLeft = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_4__.default)(dirtyDate); + dateRight = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_4__.default)(dirtyBaseDate); + } + + var seconds = (0,_differenceInSeconds_index_js__WEBPACK_IMPORTED_MODULE_5__.default)(dateRight, dateLeft); + var offsetInSeconds = ((0,_lib_getTimezoneOffsetInMilliseconds_index_js__WEBPACK_IMPORTED_MODULE_6__.default)(dateRight) - (0,_lib_getTimezoneOffsetInMilliseconds_index_js__WEBPACK_IMPORTED_MODULE_6__.default)(dateLeft)) / 1000; + var minutes = Math.round((seconds - offsetInSeconds) / 60); + var months; // 0 up to 2 mins + + if (minutes < 2) { + if (options.includeSeconds) { + if (seconds < 5) { + return locale.formatDistance('lessThanXSeconds', 5, localizeOptions); + } else if (seconds < 10) { + return locale.formatDistance('lessThanXSeconds', 10, localizeOptions); + } else if (seconds < 20) { + return locale.formatDistance('lessThanXSeconds', 20, localizeOptions); + } else if (seconds < 40) { + return locale.formatDistance('halfAMinute', null, localizeOptions); + } else if (seconds < 60) { + return locale.formatDistance('lessThanXMinutes', 1, localizeOptions); + } else { + return locale.formatDistance('xMinutes', 1, localizeOptions); + } + } else { + if (minutes === 0) { + return locale.formatDistance('lessThanXMinutes', 1, localizeOptions); + } else { + return locale.formatDistance('xMinutes', minutes, localizeOptions); + } + } // 2 mins up to 0.75 hrs + + } else if (minutes < 45) { + return locale.formatDistance('xMinutes', minutes, localizeOptions); // 0.75 hrs up to 1.5 hrs + } else if (minutes < 90) { + return locale.formatDistance('aboutXHours', 1, localizeOptions); // 1.5 hrs up to 24 hrs + } else if (minutes < MINUTES_IN_DAY) { + var hours = Math.round(minutes / 60); + return locale.formatDistance('aboutXHours', hours, localizeOptions); // 1 day up to 1.75 days + } else if (minutes < MINUTES_IN_ALMOST_TWO_DAYS) { + return locale.formatDistance('xDays', 1, localizeOptions); // 1.75 days up to 30 days + } else if (minutes < MINUTES_IN_MONTH) { + var days = Math.round(minutes / MINUTES_IN_DAY); + return locale.formatDistance('xDays', days, localizeOptions); // 1 month up to 2 months + } else if (minutes < MINUTES_IN_TWO_MONTHS) { + months = Math.round(minutes / MINUTES_IN_MONTH); + return locale.formatDistance('aboutXMonths', months, localizeOptions); + } + + months = (0,_differenceInMonths_index_js__WEBPACK_IMPORTED_MODULE_7__.default)(dateRight, dateLeft); // 2 months up to 12 months + + if (months < 12) { + var nearestMonth = Math.round(minutes / MINUTES_IN_MONTH); + return locale.formatDistance('xMonths', nearestMonth, localizeOptions); // 1 year up to max Date + } else { + var monthsSinceStartOfYear = months % 12; + var years = Math.floor(months / 12); // N years up to 1 years 3 months + + if (monthsSinceStartOfYear < 3) { + return locale.formatDistance('aboutXYears', years, localizeOptions); // N years 3 months up to N years 9 months + } else if (monthsSinceStartOfYear < 9) { + return locale.formatDistance('overXYears', years, localizeOptions); // N years 9 months up to N year 12 months + } else { + return locale.formatDistance('almostXYears', years + 1, localizeOptions); + } + } +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/isLastDayOfMonth/index.js": +/*!*************************************************************!*\ + !*** ./node_modules/date-fns/esm/isLastDayOfMonth/index.js ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ isLastDayOfMonth) +/* harmony export */ }); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _endOfDay_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../endOfDay/index.js */ "./node_modules/date-fns/esm/endOfDay/index.js"); +/* harmony import */ var _endOfMonth_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../endOfMonth/index.js */ "./node_modules/date-fns/esm/endOfMonth/index.js"); +/* harmony import */ var _lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../_lib/requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + + + +/** + * @name isLastDayOfMonth + * @category Month Helpers + * @summary Is the given date the last day of a month? + * + * @description + * Is the given date the last day of a month? + * + * ### v2.0.0 breaking changes: + * + * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes). + * + * @param {Date|Number} date - the date to check + * @returns {Boolean} the date is the last day of a month + * @throws {TypeError} 1 argument required + * + * @example + * // Is 28 February 2014 the last day of a month? + * var result = isLastDayOfMonth(new Date(2014, 1, 28)) + * //=> true + */ + +function isLastDayOfMonth(dirtyDate) { + (0,_lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(1, arguments); + var date = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDate); + return (0,_endOfDay_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(date).getTime() === (0,_endOfMonth_index_js__WEBPACK_IMPORTED_MODULE_3__.default)(date).getTime(); +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/isValid/index.js": +/*!****************************************************!*\ + !*** ./node_modules/date-fns/esm/isValid/index.js ***! + \****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ isValid) +/* harmony export */ }); +/* harmony import */ var _toDate_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../toDate/index.js */ "./node_modules/date-fns/esm/toDate/index.js"); +/* harmony import */ var _lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../_lib/requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + +/** + * @name isValid + * @category Common Helpers + * @summary Is the given date valid? + * + * @description + * Returns false if argument is Invalid Date and true otherwise. + * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate} + * Invalid Date is a Date, whose time value is NaN. + * + * Time value of Date: http://es5.github.io/#x15.9.1.1 + * + * ### v2.0.0 breaking changes: + * + * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes). + * + * - Now `isValid` doesn't throw an exception + * if the first argument is not an instance of Date. + * Instead, argument is converted beforehand using `toDate`. + * + * Examples: + * + * | `isValid` argument | Before v2.0.0 | v2.0.0 onward | + * |---------------------------|---------------|---------------| + * | `new Date()` | `true` | `true` | + * | `new Date('2016-01-01')` | `true` | `true` | + * | `new Date('')` | `false` | `false` | + * | `new Date(1488370835081)` | `true` | `true` | + * | `new Date(NaN)` | `false` | `false` | + * | `'2016-01-01'` | `TypeError` | `false` | + * | `''` | `TypeError` | `false` | + * | `1488370835081` | `TypeError` | `true` | + * | `NaN` | `TypeError` | `false` | + * + * We introduce this change to make *date-fns* consistent with ECMAScript behavior + * that try to coerce arguments to the expected type + * (which is also the case with other *date-fns* functions). + * + * @param {*} date - the date to check + * @returns {Boolean} the date is valid + * @throws {TypeError} 1 argument required + * + * @example + * // For the valid date: + * var result = isValid(new Date(2014, 1, 31)) + * //=> true + * + * @example + * // For the value, convertable into a date: + * var result = isValid(1393804800000) + * //=> true + * + * @example + * // For the invalid date: + * var result = isValid(new Date('')) + * //=> false + */ + +function isValid(dirtyDate) { + (0,_lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(1, arguments); + var date = (0,_toDate_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyDate); + return !isNaN(date); +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/locale/_lib/buildFormatLongFn/index.js": +/*!**************************************************************************!*\ + !*** ./node_modules/date-fns/esm/locale/_lib/buildFormatLongFn/index.js ***! + \**************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ buildFormatLongFn) +/* harmony export */ }); +function buildFormatLongFn(args) { + return function (dirtyOptions) { + var options = dirtyOptions || {}; + var width = options.width ? String(options.width) : args.defaultWidth; + var format = args.formats[width] || args.formats[args.defaultWidth]; + return format; + }; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/locale/_lib/buildLocalizeFn/index.js": +/*!************************************************************************!*\ + !*** ./node_modules/date-fns/esm/locale/_lib/buildLocalizeFn/index.js ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ buildLocalizeFn) +/* harmony export */ }); +function buildLocalizeFn(args) { + return function (dirtyIndex, dirtyOptions) { + var options = dirtyOptions || {}; + var context = options.context ? String(options.context) : 'standalone'; + var valuesArray; + + if (context === 'formatting' && args.formattingValues) { + var defaultWidth = args.defaultFormattingWidth || args.defaultWidth; + var width = options.width ? String(options.width) : defaultWidth; + valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; + } else { + var _defaultWidth = args.defaultWidth; + + var _width = options.width ? String(options.width) : args.defaultWidth; + + valuesArray = args.values[_width] || args.values[_defaultWidth]; + } + + var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex; + return valuesArray[index]; + }; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/locale/_lib/buildMatchFn/index.js": +/*!*********************************************************************!*\ + !*** ./node_modules/date-fns/esm/locale/_lib/buildMatchFn/index.js ***! + \*********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ buildMatchFn) +/* harmony export */ }); +function buildMatchFn(args) { + return function (dirtyString, dirtyOptions) { + var string = String(dirtyString); + var options = dirtyOptions || {}; + var width = options.width; + var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth]; + var matchResult = string.match(matchPattern); + + if (!matchResult) { + return null; + } + + var matchedString = matchResult[0]; + var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth]; + var value; + + if (Object.prototype.toString.call(parsePatterns) === '[object Array]') { + value = findIndex(parsePatterns, function (pattern) { + return pattern.test(matchedString); + }); + } else { + value = findKey(parsePatterns, function (pattern) { + return pattern.test(matchedString); + }); + } + + value = args.valueCallback ? args.valueCallback(value) : value; + value = options.valueCallback ? options.valueCallback(value) : value; + return { + value: value, + rest: string.slice(matchedString.length) + }; + }; +} + +function findKey(object, predicate) { + for (var key in object) { + if (object.hasOwnProperty(key) && predicate(object[key])) { + return key; + } + } +} + +function findIndex(array, predicate) { + for (var key = 0; key < array.length; key++) { + if (predicate(array[key])) { + return key; + } + } +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/locale/_lib/buildMatchPatternFn/index.js": +/*!****************************************************************************!*\ + !*** ./node_modules/date-fns/esm/locale/_lib/buildMatchPatternFn/index.js ***! + \****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ buildMatchPatternFn) +/* harmony export */ }); +function buildMatchPatternFn(args) { + return function (dirtyString, dirtyOptions) { + var string = String(dirtyString); + var options = dirtyOptions || {}; + var matchResult = string.match(args.matchPattern); + + if (!matchResult) { + return null; + } + + var matchedString = matchResult[0]; + var parseResult = string.match(args.parsePattern); + + if (!parseResult) { + return null; + } + + var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0]; + value = options.valueCallback ? options.valueCallback(value) : value; + return { + value: value, + rest: string.slice(matchedString.length) + }; + }; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/locale/en-US/_lib/formatDistance/index.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/date-fns/esm/locale/en-US/_lib/formatDistance/index.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ formatDistance) +/* harmony export */ }); +var formatDistanceLocale = { + lessThanXSeconds: { + one: 'less than a second', + other: 'less than {{count}} seconds' + }, + xSeconds: { + one: '1 second', + other: '{{count}} seconds' + }, + halfAMinute: 'half a minute', + lessThanXMinutes: { + one: 'less than a minute', + other: 'less than {{count}} minutes' + }, + xMinutes: { + one: '1 minute', + other: '{{count}} minutes' + }, + aboutXHours: { + one: 'about 1 hour', + other: 'about {{count}} hours' + }, + xHours: { + one: '1 hour', + other: '{{count}} hours' + }, + xDays: { + one: '1 day', + other: '{{count}} days' + }, + aboutXWeeks: { + one: 'about 1 week', + other: 'about {{count}} weeks' + }, + xWeeks: { + one: '1 week', + other: '{{count}} weeks' + }, + aboutXMonths: { + one: 'about 1 month', + other: 'about {{count}} months' + }, + xMonths: { + one: '1 month', + other: '{{count}} months' + }, + aboutXYears: { + one: 'about 1 year', + other: 'about {{count}} years' + }, + xYears: { + one: '1 year', + other: '{{count}} years' + }, + overXYears: { + one: 'over 1 year', + other: 'over {{count}} years' + }, + almostXYears: { + one: 'almost 1 year', + other: 'almost {{count}} years' + } +}; +function formatDistance(token, count, options) { + options = options || {}; + var result; + + if (typeof formatDistanceLocale[token] === 'string') { + result = formatDistanceLocale[token]; + } else if (count === 1) { + result = formatDistanceLocale[token].one; + } else { + result = formatDistanceLocale[token].other.replace('{{count}}', count); + } + + if (options.addSuffix) { + if (options.comparison > 0) { + return 'in ' + result; + } else { + return result + ' ago'; + } + } + + return result; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/locale/en-US/_lib/formatLong/index.js": +/*!*************************************************************************!*\ + !*** ./node_modules/date-fns/esm/locale/en-US/_lib/formatLong/index.js ***! + \*************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _lib_buildFormatLongFn_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../_lib/buildFormatLongFn/index.js */ "./node_modules/date-fns/esm/locale/_lib/buildFormatLongFn/index.js"); + +var dateFormats = { + full: 'EEEE, MMMM do, y', + long: 'MMMM do, y', + medium: 'MMM d, y', + short: 'MM/dd/yyyy' +}; +var timeFormats = { + full: 'h:mm:ss a zzzz', + long: 'h:mm:ss a z', + medium: 'h:mm:ss a', + short: 'h:mm a' +}; +var dateTimeFormats = { + full: "{{date}} 'at' {{time}}", + long: "{{date}} 'at' {{time}}", + medium: '{{date}}, {{time}}', + short: '{{date}}, {{time}}' +}; +var formatLong = { + date: (0,_lib_buildFormatLongFn_index_js__WEBPACK_IMPORTED_MODULE_0__.default)({ + formats: dateFormats, + defaultWidth: 'full' + }), + time: (0,_lib_buildFormatLongFn_index_js__WEBPACK_IMPORTED_MODULE_0__.default)({ + formats: timeFormats, + defaultWidth: 'full' + }), + dateTime: (0,_lib_buildFormatLongFn_index_js__WEBPACK_IMPORTED_MODULE_0__.default)({ + formats: dateTimeFormats, + defaultWidth: 'full' + }) +}; +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (formatLong); + +/***/ }), + +/***/ "./node_modules/date-fns/esm/locale/en-US/_lib/formatRelative/index.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/date-fns/esm/locale/en-US/_lib/formatRelative/index.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ formatRelative) +/* harmony export */ }); +var formatRelativeLocale = { + lastWeek: "'last' eeee 'at' p", + yesterday: "'yesterday at' p", + today: "'today at' p", + tomorrow: "'tomorrow at' p", + nextWeek: "eeee 'at' p", + other: 'P' +}; +function formatRelative(token, _date, _baseDate, _options) { + return formatRelativeLocale[token]; +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/locale/en-US/_lib/localize/index.js": +/*!***********************************************************************!*\ + !*** ./node_modules/date-fns/esm/locale/en-US/_lib/localize/index.js ***! + \***********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _lib_buildLocalizeFn_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../_lib/buildLocalizeFn/index.js */ "./node_modules/date-fns/esm/locale/_lib/buildLocalizeFn/index.js"); + +var eraValues = { + narrow: ['B', 'A'], + abbreviated: ['BC', 'AD'], + wide: ['Before Christ', 'Anno Domini'] +}; +var quarterValues = { + narrow: ['1', '2', '3', '4'], + abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'], + wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter'] // Note: in English, the names of days of the week and months are capitalized. + // If you are making a new locale based on this one, check if the same is true for the language you're working on. + // Generally, formatted dates should look like they are in the middle of a sentence, + // e.g. in Spanish language the weekdays and months should be in the lowercase. + +}; +var monthValues = { + narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'], + abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] +}; +var dayValues = { + narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'], + short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], + abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] +}; +var dayPeriodValues = { + narrow: { + am: 'a', + pm: 'p', + midnight: 'mi', + noon: 'n', + morning: 'morning', + afternoon: 'afternoon', + evening: 'evening', + night: 'night' + }, + abbreviated: { + am: 'AM', + pm: 'PM', + midnight: 'midnight', + noon: 'noon', + morning: 'morning', + afternoon: 'afternoon', + evening: 'evening', + night: 'night' + }, + wide: { + am: 'a.m.', + pm: 'p.m.', + midnight: 'midnight', + noon: 'noon', + morning: 'morning', + afternoon: 'afternoon', + evening: 'evening', + night: 'night' + } +}; +var formattingDayPeriodValues = { + narrow: { + am: 'a', + pm: 'p', + midnight: 'mi', + noon: 'n', + morning: 'in the morning', + afternoon: 'in the afternoon', + evening: 'in the evening', + night: 'at night' + }, + abbreviated: { + am: 'AM', + pm: 'PM', + midnight: 'midnight', + noon: 'noon', + morning: 'in the morning', + afternoon: 'in the afternoon', + evening: 'in the evening', + night: 'at night' + }, + wide: { + am: 'a.m.', + pm: 'p.m.', + midnight: 'midnight', + noon: 'noon', + morning: 'in the morning', + afternoon: 'in the afternoon', + evening: 'in the evening', + night: 'at night' + } +}; + +function ordinalNumber(dirtyNumber, _dirtyOptions) { + var number = Number(dirtyNumber); // If ordinal numbers depend on context, for example, + // if they are different for different grammatical genders, + // use `options.unit`: + // + // var options = dirtyOptions || {} + // var unit = String(options.unit) + // + // where `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear', + // 'day', 'hour', 'minute', 'second' + + var rem100 = number % 100; + + if (rem100 > 20 || rem100 < 10) { + switch (rem100 % 10) { + case 1: + return number + 'st'; + + case 2: + return number + 'nd'; + + case 3: + return number + 'rd'; + } + } + + return number + 'th'; +} + +var localize = { + ordinalNumber: ordinalNumber, + era: (0,_lib_buildLocalizeFn_index_js__WEBPACK_IMPORTED_MODULE_0__.default)({ + values: eraValues, + defaultWidth: 'wide' + }), + quarter: (0,_lib_buildLocalizeFn_index_js__WEBPACK_IMPORTED_MODULE_0__.default)({ + values: quarterValues, + defaultWidth: 'wide', + argumentCallback: function (quarter) { + return Number(quarter) - 1; + } + }), + month: (0,_lib_buildLocalizeFn_index_js__WEBPACK_IMPORTED_MODULE_0__.default)({ + values: monthValues, + defaultWidth: 'wide' + }), + day: (0,_lib_buildLocalizeFn_index_js__WEBPACK_IMPORTED_MODULE_0__.default)({ + values: dayValues, + defaultWidth: 'wide' + }), + dayPeriod: (0,_lib_buildLocalizeFn_index_js__WEBPACK_IMPORTED_MODULE_0__.default)({ + values: dayPeriodValues, + defaultWidth: 'wide', + formattingValues: formattingDayPeriodValues, + defaultFormattingWidth: 'wide' + }) +}; +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (localize); + +/***/ }), + +/***/ "./node_modules/date-fns/esm/locale/en-US/_lib/match/index.js": +/*!********************************************************************!*\ + !*** ./node_modules/date-fns/esm/locale/en-US/_lib/match/index.js ***! + \********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _lib_buildMatchPatternFn_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../_lib/buildMatchPatternFn/index.js */ "./node_modules/date-fns/esm/locale/_lib/buildMatchPatternFn/index.js"); +/* harmony import */ var _lib_buildMatchFn_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../_lib/buildMatchFn/index.js */ "./node_modules/date-fns/esm/locale/_lib/buildMatchFn/index.js"); + + +var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; +var parseOrdinalNumberPattern = /\d+/i; +var matchEraPatterns = { + narrow: /^(b|a)/i, + abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, + wide: /^(before christ|before common era|anno domini|common era)/i +}; +var parseEraPatterns = { + any: [/^b/i, /^(a|c)/i] +}; +var matchQuarterPatterns = { + narrow: /^[1234]/i, + abbreviated: /^q[1234]/i, + wide: /^[1234](th|st|nd|rd)? quarter/i +}; +var parseQuarterPatterns = { + any: [/1/i, /2/i, /3/i, /4/i] +}; +var matchMonthPatterns = { + narrow: /^[jfmasond]/i, + abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, + wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i +}; +var parseMonthPatterns = { + narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i], + any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i] +}; +var matchDayPatterns = { + narrow: /^[smtwf]/i, + short: /^(su|mo|tu|we|th|fr|sa)/i, + abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, + wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i +}; +var parseDayPatterns = { + narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], + any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] +}; +var matchDayPeriodPatterns = { + narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, + any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i +}; +var parseDayPeriodPatterns = { + any: { + am: /^a/i, + pm: /^p/i, + midnight: /^mi/i, + noon: /^no/i, + morning: /morning/i, + afternoon: /afternoon/i, + evening: /evening/i, + night: /night/i + } +}; +var match = { + ordinalNumber: (0,_lib_buildMatchPatternFn_index_js__WEBPACK_IMPORTED_MODULE_0__.default)({ + matchPattern: matchOrdinalNumberPattern, + parsePattern: parseOrdinalNumberPattern, + valueCallback: function (value) { + return parseInt(value, 10); + } + }), + era: (0,_lib_buildMatchFn_index_js__WEBPACK_IMPORTED_MODULE_1__.default)({ + matchPatterns: matchEraPatterns, + defaultMatchWidth: 'wide', + parsePatterns: parseEraPatterns, + defaultParseWidth: 'any' + }), + quarter: (0,_lib_buildMatchFn_index_js__WEBPACK_IMPORTED_MODULE_1__.default)({ + matchPatterns: matchQuarterPatterns, + defaultMatchWidth: 'wide', + parsePatterns: parseQuarterPatterns, + defaultParseWidth: 'any', + valueCallback: function (index) { + return index + 1; + } + }), + month: (0,_lib_buildMatchFn_index_js__WEBPACK_IMPORTED_MODULE_1__.default)({ + matchPatterns: matchMonthPatterns, + defaultMatchWidth: 'wide', + parsePatterns: parseMonthPatterns, + defaultParseWidth: 'any' + }), + day: (0,_lib_buildMatchFn_index_js__WEBPACK_IMPORTED_MODULE_1__.default)({ + matchPatterns: matchDayPatterns, + defaultMatchWidth: 'wide', + parsePatterns: parseDayPatterns, + defaultParseWidth: 'any' + }), + dayPeriod: (0,_lib_buildMatchFn_index_js__WEBPACK_IMPORTED_MODULE_1__.default)({ + matchPatterns: matchDayPeriodPatterns, + defaultMatchWidth: 'any', + parsePatterns: parseDayPeriodPatterns, + defaultParseWidth: 'any' + }) +}; +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (match); + +/***/ }), + +/***/ "./node_modules/date-fns/esm/locale/en-US/index.js": +/*!*********************************************************!*\ + !*** ./node_modules/date-fns/esm/locale/en-US/index.js ***! + \*********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _lib_formatDistance_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_lib/formatDistance/index.js */ "./node_modules/date-fns/esm/locale/en-US/_lib/formatDistance/index.js"); +/* harmony import */ var _lib_formatLong_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_lib/formatLong/index.js */ "./node_modules/date-fns/esm/locale/en-US/_lib/formatLong/index.js"); +/* harmony import */ var _lib_formatRelative_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./_lib/formatRelative/index.js */ "./node_modules/date-fns/esm/locale/en-US/_lib/formatRelative/index.js"); +/* harmony import */ var _lib_localize_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./_lib/localize/index.js */ "./node_modules/date-fns/esm/locale/en-US/_lib/localize/index.js"); +/* harmony import */ var _lib_match_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./_lib/match/index.js */ "./node_modules/date-fns/esm/locale/en-US/_lib/match/index.js"); + + + + + +/** + * @type {Locale} + * @category Locales + * @summary English locale (United States). + * @language English + * @iso-639-2 eng + * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp} + * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss} + */ + +var locale = { + code: 'en-US', + formatDistance: _lib_formatDistance_index_js__WEBPACK_IMPORTED_MODULE_0__.default, + formatLong: _lib_formatLong_index_js__WEBPACK_IMPORTED_MODULE_1__.default, + formatRelative: _lib_formatRelative_index_js__WEBPACK_IMPORTED_MODULE_2__.default, + localize: _lib_localize_index_js__WEBPACK_IMPORTED_MODULE_3__.default, + match: _lib_match_index_js__WEBPACK_IMPORTED_MODULE_4__.default, + options: { + weekStartsOn: 0 + /* Sunday */ + , + firstWeekContainsDate: 1 + } +}; +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (locale); + +/***/ }), + +/***/ "./node_modules/date-fns/esm/subMilliseconds/index.js": +/*!************************************************************!*\ + !*** ./node_modules/date-fns/esm/subMilliseconds/index.js ***! + \************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ subMilliseconds) +/* harmony export */ }); +/* harmony import */ var _lib_toInteger_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../_lib/toInteger/index.js */ "./node_modules/date-fns/esm/_lib/toInteger/index.js"); +/* harmony import */ var _addMilliseconds_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../addMilliseconds/index.js */ "./node_modules/date-fns/esm/addMilliseconds/index.js"); +/* harmony import */ var _lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../_lib/requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + + + +/** + * @name subMilliseconds + * @category Millisecond Helpers + * @summary Subtract the specified number of milliseconds from the given date. + * + * @description + * Subtract the specified number of milliseconds from the given date. + * + * ### v2.0.0 breaking changes: + * + * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes). + * + * @param {Date|Number} date - the date to be changed + * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`. + * @returns {Date} the new date with the milliseconds subtracted + * @throws {TypeError} 2 arguments required + * + * @example + * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000: + * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750) + * //=> Thu Jul 10 2014 12:45:29.250 + */ + +function subMilliseconds(dirtyDate, dirtyAmount) { + (0,_lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(2, arguments); + var amount = (0,_lib_toInteger_index_js__WEBPACK_IMPORTED_MODULE_1__.default)(dirtyAmount); + return (0,_addMilliseconds_index_js__WEBPACK_IMPORTED_MODULE_2__.default)(dirtyDate, -amount); +} + +/***/ }), + +/***/ "./node_modules/date-fns/esm/toDate/index.js": +/*!***************************************************!*\ + !*** ./node_modules/date-fns/esm/toDate/index.js ***! + \***************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ toDate) +/* harmony export */ }); +/* harmony import */ var _lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../_lib/requiredArgs/index.js */ "./node_modules/date-fns/esm/_lib/requiredArgs/index.js"); + +/** + * @name toDate + * @category Common Helpers + * @summary Convert the given argument to an instance of Date. + * + * @description + * Convert the given argument to an instance of Date. + * + * If the argument is an instance of Date, the function returns its clone. + * + * If the argument is a number, it is treated as a timestamp. + * + * If the argument is none of the above, the function returns Invalid Date. + * + * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`. + * + * @param {Date|Number} argument - the value to convert + * @returns {Date} the parsed date in the local time zone + * @throws {TypeError} 1 argument required + * + * @example + * // Clone the date: + * const result = toDate(new Date(2014, 1, 11, 11, 30, 30)) + * //=> Tue Feb 11 2014 11:30:30 + * + * @example + * // Convert the timestamp to date: + * const result = toDate(1392098430000) + * //=> Tue Feb 11 2014 11:30:30 + */ + +function toDate(argument) { + (0,_lib_requiredArgs_index_js__WEBPACK_IMPORTED_MODULE_0__.default)(1, arguments); + var argStr = Object.prototype.toString.call(argument); // Clone the date + + if (argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]') { + // Prevent the date to lose the milliseconds when passed to new Date() in IE10 + return new Date(argument.getTime()); + } else if (typeof argument === 'number' || argStr === '[object Number]') { + return new Date(argument); + } else { + if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') { + // eslint-disable-next-line no-console + console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"); // eslint-disable-next-line no-console + + console.warn(new Error().stack); + } + + return new Date(NaN); + } +} + +/***/ }), + +/***/ "./node_modules/domhandler/lib/node.js": +/*!*********************************************!*\ + !*** ./node_modules/domhandler/lib/node.js ***! + \*********************************************/ +/***/ (function(__unused_webpack_module, exports) { + +"use strict"; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.cloneNode = exports.Element = exports.Document = exports.NodeWithChildren = exports.ProcessingInstruction = exports.Comment = exports.Text = exports.DataNode = exports.Node = void 0; +var nodeTypes = new Map([ + ["tag" /* Tag */, 1], + ["script" /* Script */, 1], + ["style" /* Style */, 1], + ["directive" /* Directive */, 1], + ["text" /* Text */, 3], + ["cdata" /* CDATA */, 4], + ["comment" /* Comment */, 8], + ["root" /* Root */, 9], +]); +/** + * This object will be used as the prototype for Nodes when creating a + * DOM-Level-1-compliant structure. + */ +var Node = /** @class */ (function () { + /** + * + * @param type The type of the node. + */ + function Node(type) { + this.type = type; + /** Parent of the node */ + this.parent = null; + /** Previous sibling */ + this.prev = null; + /** Next sibling */ + this.next = null; + /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */ + this.startIndex = null; + /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */ + this.endIndex = null; + } + Object.defineProperty(Node.prototype, "nodeType", { + // Read-only aliases + get: function () { + var _a; + return (_a = nodeTypes.get(this.type)) !== null && _a !== void 0 ? _a : 1; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Node.prototype, "parentNode", { + // Read-write aliases for properties + get: function () { + return this.parent; + }, + set: function (parent) { + this.parent = parent; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Node.prototype, "previousSibling", { + get: function () { + return this.prev; + }, + set: function (prev) { + this.prev = prev; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Node.prototype, "nextSibling", { + get: function () { + return this.next; + }, + set: function (next) { + this.next = next; + }, + enumerable: false, + configurable: true + }); + /** + * Clone this node, and optionally its children. + * + * @param recursive Clone child nodes as well. + * @returns A clone of the node. + */ + Node.prototype.cloneNode = function (recursive) { + if (recursive === void 0) { recursive = false; } + return cloneNode(this, recursive); + }; + return Node; +}()); +exports.Node = Node; +var DataNode = /** @class */ (function (_super) { + __extends(DataNode, _super); + /** + * @param type The type of the node + * @param data The content of the data node + */ + function DataNode(type, data) { + var _this = _super.call(this, type) || this; + _this.data = data; + return _this; + } + Object.defineProperty(DataNode.prototype, "nodeValue", { + get: function () { + return this.data; + }, + set: function (data) { + this.data = data; + }, + enumerable: false, + configurable: true + }); + return DataNode; +}(Node)); +exports.DataNode = DataNode; +var Text = /** @class */ (function (_super) { + __extends(Text, _super); + function Text(data) { + return _super.call(this, "text" /* Text */, data) || this; + } + return Text; +}(DataNode)); +exports.Text = Text; +var Comment = /** @class */ (function (_super) { + __extends(Comment, _super); + function Comment(data) { + return _super.call(this, "comment" /* Comment */, data) || this; + } + return Comment; +}(DataNode)); +exports.Comment = Comment; +var ProcessingInstruction = /** @class */ (function (_super) { + __extends(ProcessingInstruction, _super); + function ProcessingInstruction(name, data) { + var _this = _super.call(this, "directive" /* Directive */, data) || this; + _this.name = name; + return _this; + } + return ProcessingInstruction; +}(DataNode)); +exports.ProcessingInstruction = ProcessingInstruction; +/** + * A `Node` that can have children. + */ +var NodeWithChildren = /** @class */ (function (_super) { + __extends(NodeWithChildren, _super); + /** + * @param type Type of the node. + * @param children Children of the node. Only certain node types can have children. + */ + function NodeWithChildren(type, children) { + var _this = _super.call(this, type) || this; + _this.children = children; + return _this; + } + Object.defineProperty(NodeWithChildren.prototype, "firstChild", { + // Aliases + get: function () { + var _a; + return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(NodeWithChildren.prototype, "lastChild", { + get: function () { + return this.children.length > 0 + ? this.children[this.children.length - 1] + : null; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(NodeWithChildren.prototype, "childNodes", { + get: function () { + return this.children; + }, + set: function (children) { + this.children = children; + }, + enumerable: false, + configurable: true + }); + return NodeWithChildren; +}(Node)); +exports.NodeWithChildren = NodeWithChildren; +var Document = /** @class */ (function (_super) { + __extends(Document, _super); + function Document(children) { + return _super.call(this, "root" /* Root */, children) || this; + } + return Document; +}(NodeWithChildren)); +exports.Document = Document; +var Element = /** @class */ (function (_super) { + __extends(Element, _super); + /** + * @param name Name of the tag, eg. `div`, `span`. + * @param attribs Object mapping attribute names to attribute values. + * @param children Children of the node. + */ + function Element(name, attribs, children) { + if (children === void 0) { children = []; } + var _this = _super.call(this, name === "script" + ? "script" /* Script */ + : name === "style" + ? "style" /* Style */ + : "tag" /* Tag */, children) || this; + _this.name = name; + _this.attribs = attribs; + _this.attribs = attribs; + return _this; + } + Object.defineProperty(Element.prototype, "tagName", { + // DOM Level 1 aliases + get: function () { + return this.name; + }, + set: function (name) { + this.name = name; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Element.prototype, "attributes", { + get: function () { + var _this = this; + return Object.keys(this.attribs).map(function (name) { + var _a, _b; + return ({ + name: name, + value: _this.attribs[name], + namespace: (_a = _this["x-attribsNamespace"]) === null || _a === void 0 ? void 0 : _a[name], + prefix: (_b = _this["x-attribsPrefix"]) === null || _b === void 0 ? void 0 : _b[name], + }); + }); + }, + enumerable: false, + configurable: true + }); + return Element; +}(NodeWithChildren)); +exports.Element = Element; +/** + * Clone a node, and optionally its children. + * + * @param recursive Clone child nodes as well. + * @returns A clone of the node. + */ +function cloneNode(node, recursive) { + if (recursive === void 0) { recursive = false; } + var result; + switch (node.type) { + case "text" /* Text */: + result = new Text(node.data); + break; + case "directive" /* Directive */: { + var instr = node; + result = new ProcessingInstruction(instr.name, instr.data); + if (instr["x-name"] != null) { + result["x-name"] = instr["x-name"]; + result["x-publicId"] = instr["x-publicId"]; + result["x-systemId"] = instr["x-systemId"]; + } + break; + } + case "comment" /* Comment */: + result = new Comment(node.data); + break; + case "tag" /* Tag */: + case "script" /* Script */: + case "style" /* Style */: { + var elem = node; + var children = recursive ? cloneChildren(elem.children) : []; + var clone_1 = new Element(elem.name, __assign({}, elem.attribs), children); + children.forEach(function (child) { return (child.parent = clone_1); }); + if (elem["x-attribsNamespace"]) { + clone_1["x-attribsNamespace"] = __assign({}, elem["x-attribsNamespace"]); + } + if (elem["x-attribsPrefix"]) { + clone_1["x-attribsPrefix"] = __assign({}, elem["x-attribsPrefix"]); + } + result = clone_1; + break; + } + case "cdata" /* CDATA */: { + var cdata = node; + var children = recursive ? cloneChildren(cdata.children) : []; + var clone_2 = new NodeWithChildren(node.type, children); + children.forEach(function (child) { return (child.parent = clone_2); }); + result = clone_2; + break; + } + case "root" /* Root */: { + var doc = node; + var children = recursive ? cloneChildren(doc.children) : []; + var clone_3 = new Document(children); + children.forEach(function (child) { return (child.parent = clone_3); }); + if (doc["x-mode"]) { + clone_3["x-mode"] = doc["x-mode"]; + } + result = clone_3; + break; + } + case "doctype" /* Doctype */: { + // This type isn't used yet. + throw new Error("Not implemented yet: ElementType.Doctype case"); + } + } + result.startIndex = node.startIndex; + result.endIndex = node.endIndex; + return result; +} +exports.cloneNode = cloneNode; +function cloneChildren(childs) { + var children = childs.map(function (child) { return cloneNode(child, true); }); + for (var i = 1; i < children.length; i++) { + children[i].prev = children[i - 1]; + children[i - 1].next = children[i]; + } + return children; +} + + +/***/ }), + +/***/ "./node_modules/history/esm/history.js": +/*!*********************************************!*\ + !*** ./node_modules/history/esm/history.js ***! + \*********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "createBrowserHistory": () => (/* binding */ createBrowserHistory), +/* harmony export */ "createHashHistory": () => (/* binding */ createHashHistory), +/* harmony export */ "createMemoryHistory": () => (/* binding */ createMemoryHistory), +/* harmony export */ "createLocation": () => (/* binding */ createLocation), +/* harmony export */ "locationsAreEqual": () => (/* binding */ locationsAreEqual), +/* harmony export */ "parsePath": () => (/* binding */ parsePath), +/* harmony export */ "createPath": () => (/* binding */ createPath) +/* harmony export */ }); +/* harmony import */ var _babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/extends */ "./node_modules/@babel/runtime/helpers/esm/extends.js"); +/* harmony import */ var resolve_pathname__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! resolve-pathname */ "./node_modules/resolve-pathname/esm/resolve-pathname.js"); +/* harmony import */ var value_equal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! value-equal */ "./node_modules/value-equal/esm/value-equal.js"); +/* harmony import */ var tiny_warning__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! tiny-warning */ "./node_modules/tiny-warning/dist/tiny-warning.esm.js"); +/* harmony import */ var tiny_invariant__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! tiny-invariant */ "./node_modules/tiny-invariant/dist/tiny-invariant.esm.js"); + + + + + + +function addLeadingSlash(path) { + return path.charAt(0) === '/' ? path : '/' + path; +} +function stripLeadingSlash(path) { + return path.charAt(0) === '/' ? path.substr(1) : path; +} +function hasBasename(path, prefix) { + return path.toLowerCase().indexOf(prefix.toLowerCase()) === 0 && '/?#'.indexOf(path.charAt(prefix.length)) !== -1; +} +function stripBasename(path, prefix) { + return hasBasename(path, prefix) ? path.substr(prefix.length) : path; +} +function stripTrailingSlash(path) { + return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path; +} +function parsePath(path) { + var pathname = path || '/'; + var search = ''; + var hash = ''; + var hashIndex = pathname.indexOf('#'); + + if (hashIndex !== -1) { + hash = pathname.substr(hashIndex); + pathname = pathname.substr(0, hashIndex); + } + + var searchIndex = pathname.indexOf('?'); + + if (searchIndex !== -1) { + search = pathname.substr(searchIndex); + pathname = pathname.substr(0, searchIndex); + } + + return { + pathname: pathname, + search: search === '?' ? '' : search, + hash: hash === '#' ? '' : hash + }; +} +function createPath(location) { + var pathname = location.pathname, + search = location.search, + hash = location.hash; + var path = pathname || '/'; + if (search && search !== '?') path += search.charAt(0) === '?' ? search : "?" + search; + if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : "#" + hash; + return path; +} + +function createLocation(path, state, key, currentLocation) { + var location; + + if (typeof path === 'string') { + // Two-arg form: push(path, state) + location = parsePath(path); + location.state = state; + } else { + // One-arg form: push(location) + location = (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__.default)({}, path); + if (location.pathname === undefined) location.pathname = ''; + + if (location.search) { + if (location.search.charAt(0) !== '?') location.search = '?' + location.search; + } else { + location.search = ''; + } + + if (location.hash) { + if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash; + } else { + location.hash = ''; + } + + if (state !== undefined && location.state === undefined) location.state = state; + } + + try { + location.pathname = decodeURI(location.pathname); + } catch (e) { + if (e instanceof URIError) { + throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.'); + } else { + throw e; + } + } + + if (key) location.key = key; + + if (currentLocation) { + // Resolve incomplete/relative pathname relative to current location. + if (!location.pathname) { + location.pathname = currentLocation.pathname; + } else if (location.pathname.charAt(0) !== '/') { + location.pathname = (0,resolve_pathname__WEBPACK_IMPORTED_MODULE_1__.default)(location.pathname, currentLocation.pathname); + } + } else { + // When there is no prior location and pathname is empty, set it to / + if (!location.pathname) { + location.pathname = '/'; + } + } + + return location; +} +function locationsAreEqual(a, b) { + return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && (0,value_equal__WEBPACK_IMPORTED_MODULE_2__.default)(a.state, b.state); +} + +function createTransitionManager() { + var prompt = null; + + function setPrompt(nextPrompt) { + true ? (0,tiny_warning__WEBPACK_IMPORTED_MODULE_3__.default)(prompt == null, 'A history supports only one prompt at a time') : 0; + prompt = nextPrompt; + return function () { + if (prompt === nextPrompt) prompt = null; + }; + } + + function confirmTransitionTo(location, action, getUserConfirmation, callback) { + // TODO: If another transition starts while we're still confirming + // the previous one, we may end up in a weird state. Figure out the + // best way to handle this. + if (prompt != null) { + var result = typeof prompt === 'function' ? prompt(location, action) : prompt; + + if (typeof result === 'string') { + if (typeof getUserConfirmation === 'function') { + getUserConfirmation(result, callback); + } else { + true ? (0,tiny_warning__WEBPACK_IMPORTED_MODULE_3__.default)(false, 'A history needs a getUserConfirmation function in order to use a prompt message') : 0; + callback(true); + } + } else { + // Return false from a transition hook to cancel the transition. + callback(result !== false); + } + } else { + callback(true); + } + } + + var listeners = []; + + function appendListener(fn) { + var isActive = true; + + function listener() { + if (isActive) fn.apply(void 0, arguments); + } + + listeners.push(listener); + return function () { + isActive = false; + listeners = listeners.filter(function (item) { + return item !== listener; + }); + }; + } + + function notifyListeners() { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + listeners.forEach(function (listener) { + return listener.apply(void 0, args); + }); + } + + return { + setPrompt: setPrompt, + confirmTransitionTo: confirmTransitionTo, + appendListener: appendListener, + notifyListeners: notifyListeners + }; +} + +var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); +function getConfirmation(message, callback) { + callback(window.confirm(message)); // eslint-disable-line no-alert +} +/** + * Returns true if the HTML5 history API is supported. Taken from Modernizr. + * + * https://github.com/Modernizr/Modernizr/blob/master/LICENSE + * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js + * changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586 + */ + +function supportsHistory() { + var ua = window.navigator.userAgent; + if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) return false; + return window.history && 'pushState' in window.history; +} +/** + * Returns true if browser fires popstate on hash change. + * IE10 and IE11 do not. + */ + +function supportsPopStateOnHashChange() { + return window.navigator.userAgent.indexOf('Trident') === -1; +} +/** + * Returns false if using go(n) with hash history causes a full page reload. + */ + +function supportsGoWithoutReloadUsingHash() { + return window.navigator.userAgent.indexOf('Firefox') === -1; +} +/** + * Returns true if a given popstate event is an extraneous WebKit event. + * Accounts for the fact that Chrome on iOS fires real popstate events + * containing undefined state when pressing the back button. + */ + +function isExtraneousPopstateEvent(event) { + return event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1; +} + +var PopStateEvent = 'popstate'; +var HashChangeEvent = 'hashchange'; + +function getHistoryState() { + try { + return window.history.state || {}; + } catch (e) { + // IE 11 sometimes throws when accessing window.history.state + // See https://github.com/ReactTraining/history/pull/289 + return {}; + } +} +/** + * Creates a history object that uses the HTML5 history API including + * pushState, replaceState, and the popstate event. + */ + + +function createBrowserHistory(props) { + if (props === void 0) { + props = {}; + } + + !canUseDOM ? true ? (0,tiny_invariant__WEBPACK_IMPORTED_MODULE_4__.default)(false, 'Browser history needs a DOM') : 0 : void 0; + var globalHistory = window.history; + var canUseHistory = supportsHistory(); + var needsHashChangeListener = !supportsPopStateOnHashChange(); + var _props = props, + _props$forceRefresh = _props.forceRefresh, + forceRefresh = _props$forceRefresh === void 0 ? false : _props$forceRefresh, + _props$getUserConfirm = _props.getUserConfirmation, + getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm, + _props$keyLength = _props.keyLength, + keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength; + var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : ''; + + function getDOMLocation(historyState) { + var _ref = historyState || {}, + key = _ref.key, + state = _ref.state; + + var _window$location = window.location, + pathname = _window$location.pathname, + search = _window$location.search, + hash = _window$location.hash; + var path = pathname + search + hash; + true ? (0,tiny_warning__WEBPACK_IMPORTED_MODULE_3__.default)(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".') : 0; + if (basename) path = stripBasename(path, basename); + return createLocation(path, state, key); + } + + function createKey() { + return Math.random().toString(36).substr(2, keyLength); + } + + var transitionManager = createTransitionManager(); + + function setState(nextState) { + (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__.default)(history, nextState); + + history.length = globalHistory.length; + transitionManager.notifyListeners(history.location, history.action); + } + + function handlePopState(event) { + // Ignore extraneous popstate events in WebKit. + if (isExtraneousPopstateEvent(event)) return; + handlePop(getDOMLocation(event.state)); + } + + function handleHashChange() { + handlePop(getDOMLocation(getHistoryState())); + } + + var forceNextPop = false; + + function handlePop(location) { + if (forceNextPop) { + forceNextPop = false; + setState(); + } else { + var action = 'POP'; + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (ok) { + setState({ + action: action, + location: location + }); + } else { + revertPop(location); + } + }); + } + } + + function revertPop(fromLocation) { + var toLocation = history.location; // TODO: We could probably make this more reliable by + // keeping a list of keys we've seen in sessionStorage. + // Instead, we just default to 0 for keys we don't know. + + var toIndex = allKeys.indexOf(toLocation.key); + if (toIndex === -1) toIndex = 0; + var fromIndex = allKeys.indexOf(fromLocation.key); + if (fromIndex === -1) fromIndex = 0; + var delta = toIndex - fromIndex; + + if (delta) { + forceNextPop = true; + go(delta); + } + } + + var initialLocation = getDOMLocation(getHistoryState()); + var allKeys = [initialLocation.key]; // Public interface + + function createHref(location) { + return basename + createPath(location); + } + + function push(path, state) { + true ? (0,tiny_warning__WEBPACK_IMPORTED_MODULE_3__.default)(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : 0; + var action = 'PUSH'; + var location = createLocation(path, state, createKey(), history.location); + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + var href = createHref(location); + var key = location.key, + state = location.state; + + if (canUseHistory) { + globalHistory.pushState({ + key: key, + state: state + }, null, href); + + if (forceRefresh) { + window.location.href = href; + } else { + var prevIndex = allKeys.indexOf(history.location.key); + var nextKeys = allKeys.slice(0, prevIndex + 1); + nextKeys.push(location.key); + allKeys = nextKeys; + setState({ + action: action, + location: location + }); + } + } else { + true ? (0,tiny_warning__WEBPACK_IMPORTED_MODULE_3__.default)(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history') : 0; + window.location.href = href; + } + }); + } + + function replace(path, state) { + true ? (0,tiny_warning__WEBPACK_IMPORTED_MODULE_3__.default)(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : 0; + var action = 'REPLACE'; + var location = createLocation(path, state, createKey(), history.location); + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + var href = createHref(location); + var key = location.key, + state = location.state; + + if (canUseHistory) { + globalHistory.replaceState({ + key: key, + state: state + }, null, href); + + if (forceRefresh) { + window.location.replace(href); + } else { + var prevIndex = allKeys.indexOf(history.location.key); + if (prevIndex !== -1) allKeys[prevIndex] = location.key; + setState({ + action: action, + location: location + }); + } + } else { + true ? (0,tiny_warning__WEBPACK_IMPORTED_MODULE_3__.default)(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history') : 0; + window.location.replace(href); + } + }); + } + + function go(n) { + globalHistory.go(n); + } + + function goBack() { + go(-1); + } + + function goForward() { + go(1); + } + + var listenerCount = 0; + + function checkDOMListeners(delta) { + listenerCount += delta; + + if (listenerCount === 1 && delta === 1) { + window.addEventListener(PopStateEvent, handlePopState); + if (needsHashChangeListener) window.addEventListener(HashChangeEvent, handleHashChange); + } else if (listenerCount === 0) { + window.removeEventListener(PopStateEvent, handlePopState); + if (needsHashChangeListener) window.removeEventListener(HashChangeEvent, handleHashChange); + } + } + + var isBlocked = false; + + function block(prompt) { + if (prompt === void 0) { + prompt = false; + } + + var unblock = transitionManager.setPrompt(prompt); + + if (!isBlocked) { + checkDOMListeners(1); + isBlocked = true; + } + + return function () { + if (isBlocked) { + isBlocked = false; + checkDOMListeners(-1); + } + + return unblock(); + }; + } + + function listen(listener) { + var unlisten = transitionManager.appendListener(listener); + checkDOMListeners(1); + return function () { + checkDOMListeners(-1); + unlisten(); + }; + } + + var history = { + length: globalHistory.length, + action: 'POP', + location: initialLocation, + createHref: createHref, + push: push, + replace: replace, + go: go, + goBack: goBack, + goForward: goForward, + block: block, + listen: listen + }; + return history; +} + +var HashChangeEvent$1 = 'hashchange'; +var HashPathCoders = { + hashbang: { + encodePath: function encodePath(path) { + return path.charAt(0) === '!' ? path : '!/' + stripLeadingSlash(path); + }, + decodePath: function decodePath(path) { + return path.charAt(0) === '!' ? path.substr(1) : path; + } + }, + noslash: { + encodePath: stripLeadingSlash, + decodePath: addLeadingSlash + }, + slash: { + encodePath: addLeadingSlash, + decodePath: addLeadingSlash + } +}; + +function stripHash(url) { + var hashIndex = url.indexOf('#'); + return hashIndex === -1 ? url : url.slice(0, hashIndex); +} + +function getHashPath() { + // We can't use window.location.hash here because it's not + // consistent across browsers - Firefox will pre-decode it! + var href = window.location.href; + var hashIndex = href.indexOf('#'); + return hashIndex === -1 ? '' : href.substring(hashIndex + 1); +} + +function pushHashPath(path) { + window.location.hash = path; +} + +function replaceHashPath(path) { + window.location.replace(stripHash(window.location.href) + '#' + path); +} + +function createHashHistory(props) { + if (props === void 0) { + props = {}; + } + + !canUseDOM ? true ? (0,tiny_invariant__WEBPACK_IMPORTED_MODULE_4__.default)(false, 'Hash history needs a DOM') : 0 : void 0; + var globalHistory = window.history; + var canGoWithoutReload = supportsGoWithoutReloadUsingHash(); + var _props = props, + _props$getUserConfirm = _props.getUserConfirmation, + getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm, + _props$hashType = _props.hashType, + hashType = _props$hashType === void 0 ? 'slash' : _props$hashType; + var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : ''; + var _HashPathCoders$hashT = HashPathCoders[hashType], + encodePath = _HashPathCoders$hashT.encodePath, + decodePath = _HashPathCoders$hashT.decodePath; + + function getDOMLocation() { + var path = decodePath(getHashPath()); + true ? (0,tiny_warning__WEBPACK_IMPORTED_MODULE_3__.default)(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".') : 0; + if (basename) path = stripBasename(path, basename); + return createLocation(path); + } + + var transitionManager = createTransitionManager(); + + function setState(nextState) { + (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__.default)(history, nextState); + + history.length = globalHistory.length; + transitionManager.notifyListeners(history.location, history.action); + } + + var forceNextPop = false; + var ignorePath = null; + + function locationsAreEqual$$1(a, b) { + return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash; + } + + function handleHashChange() { + var path = getHashPath(); + var encodedPath = encodePath(path); + + if (path !== encodedPath) { + // Ensure we always have a properly-encoded hash. + replaceHashPath(encodedPath); + } else { + var location = getDOMLocation(); + var prevLocation = history.location; + if (!forceNextPop && locationsAreEqual$$1(prevLocation, location)) return; // A hashchange doesn't always == location change. + + if (ignorePath === createPath(location)) return; // Ignore this change; we already setState in push/replace. + + ignorePath = null; + handlePop(location); + } + } + + function handlePop(location) { + if (forceNextPop) { + forceNextPop = false; + setState(); + } else { + var action = 'POP'; + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (ok) { + setState({ + action: action, + location: location + }); + } else { + revertPop(location); + } + }); + } + } + + function revertPop(fromLocation) { + var toLocation = history.location; // TODO: We could probably make this more reliable by + // keeping a list of paths we've seen in sessionStorage. + // Instead, we just default to 0 for paths we don't know. + + var toIndex = allPaths.lastIndexOf(createPath(toLocation)); + if (toIndex === -1) toIndex = 0; + var fromIndex = allPaths.lastIndexOf(createPath(fromLocation)); + if (fromIndex === -1) fromIndex = 0; + var delta = toIndex - fromIndex; + + if (delta) { + forceNextPop = true; + go(delta); + } + } // Ensure the hash is encoded properly before doing anything else. + + + var path = getHashPath(); + var encodedPath = encodePath(path); + if (path !== encodedPath) replaceHashPath(encodedPath); + var initialLocation = getDOMLocation(); + var allPaths = [createPath(initialLocation)]; // Public interface + + function createHref(location) { + var baseTag = document.querySelector('base'); + var href = ''; + + if (baseTag && baseTag.getAttribute('href')) { + href = stripHash(window.location.href); + } + + return href + '#' + encodePath(basename + createPath(location)); + } + + function push(path, state) { + true ? (0,tiny_warning__WEBPACK_IMPORTED_MODULE_3__.default)(state === undefined, 'Hash history cannot push state; it is ignored') : 0; + var action = 'PUSH'; + var location = createLocation(path, undefined, undefined, history.location); + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + var path = createPath(location); + var encodedPath = encodePath(basename + path); + var hashChanged = getHashPath() !== encodedPath; + + if (hashChanged) { + // We cannot tell if a hashchange was caused by a PUSH, so we'd + // rather setState here and ignore the hashchange. The caveat here + // is that other hash histories in the page will consider it a POP. + ignorePath = path; + pushHashPath(encodedPath); + var prevIndex = allPaths.lastIndexOf(createPath(history.location)); + var nextPaths = allPaths.slice(0, prevIndex + 1); + nextPaths.push(path); + allPaths = nextPaths; + setState({ + action: action, + location: location + }); + } else { + true ? (0,tiny_warning__WEBPACK_IMPORTED_MODULE_3__.default)(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack') : 0; + setState(); + } + }); + } + + function replace(path, state) { + true ? (0,tiny_warning__WEBPACK_IMPORTED_MODULE_3__.default)(state === undefined, 'Hash history cannot replace state; it is ignored') : 0; + var action = 'REPLACE'; + var location = createLocation(path, undefined, undefined, history.location); + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + var path = createPath(location); + var encodedPath = encodePath(basename + path); + var hashChanged = getHashPath() !== encodedPath; + + if (hashChanged) { + // We cannot tell if a hashchange was caused by a REPLACE, so we'd + // rather setState here and ignore the hashchange. The caveat here + // is that other hash histories in the page will consider it a POP. + ignorePath = path; + replaceHashPath(encodedPath); + } + + var prevIndex = allPaths.indexOf(createPath(history.location)); + if (prevIndex !== -1) allPaths[prevIndex] = path; + setState({ + action: action, + location: location + }); + }); + } + + function go(n) { + true ? (0,tiny_warning__WEBPACK_IMPORTED_MODULE_3__.default)(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser') : 0; + globalHistory.go(n); + } + + function goBack() { + go(-1); + } + + function goForward() { + go(1); + } + + var listenerCount = 0; + + function checkDOMListeners(delta) { + listenerCount += delta; + + if (listenerCount === 1 && delta === 1) { + window.addEventListener(HashChangeEvent$1, handleHashChange); + } else if (listenerCount === 0) { + window.removeEventListener(HashChangeEvent$1, handleHashChange); + } + } + + var isBlocked = false; + + function block(prompt) { + if (prompt === void 0) { + prompt = false; + } + + var unblock = transitionManager.setPrompt(prompt); + + if (!isBlocked) { + checkDOMListeners(1); + isBlocked = true; + } + + return function () { + if (isBlocked) { + isBlocked = false; + checkDOMListeners(-1); + } + + return unblock(); + }; + } + + function listen(listener) { + var unlisten = transitionManager.appendListener(listener); + checkDOMListeners(1); + return function () { + checkDOMListeners(-1); + unlisten(); + }; + } + + var history = { + length: globalHistory.length, + action: 'POP', + location: initialLocation, + createHref: createHref, + push: push, + replace: replace, + go: go, + goBack: goBack, + goForward: goForward, + block: block, + listen: listen + }; + return history; +} + +function clamp(n, lowerBound, upperBound) { + return Math.min(Math.max(n, lowerBound), upperBound); +} +/** + * Creates a history object that stores locations in memory. + */ + + +function createMemoryHistory(props) { + if (props === void 0) { + props = {}; + } + + var _props = props, + getUserConfirmation = _props.getUserConfirmation, + _props$initialEntries = _props.initialEntries, + initialEntries = _props$initialEntries === void 0 ? ['/'] : _props$initialEntries, + _props$initialIndex = _props.initialIndex, + initialIndex = _props$initialIndex === void 0 ? 0 : _props$initialIndex, + _props$keyLength = _props.keyLength, + keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength; + var transitionManager = createTransitionManager(); + + function setState(nextState) { + (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__.default)(history, nextState); + + history.length = history.entries.length; + transitionManager.notifyListeners(history.location, history.action); + } + + function createKey() { + return Math.random().toString(36).substr(2, keyLength); + } + + var index = clamp(initialIndex, 0, initialEntries.length - 1); + var entries = initialEntries.map(function (entry) { + return typeof entry === 'string' ? createLocation(entry, undefined, createKey()) : createLocation(entry, undefined, entry.key || createKey()); + }); // Public interface + + var createHref = createPath; + + function push(path, state) { + true ? (0,tiny_warning__WEBPACK_IMPORTED_MODULE_3__.default)(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : 0; + var action = 'PUSH'; + var location = createLocation(path, state, createKey(), history.location); + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + var prevIndex = history.index; + var nextIndex = prevIndex + 1; + var nextEntries = history.entries.slice(0); + + if (nextEntries.length > nextIndex) { + nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location); + } else { + nextEntries.push(location); + } + + setState({ + action: action, + location: location, + index: nextIndex, + entries: nextEntries + }); + }); + } + + function replace(path, state) { + true ? (0,tiny_warning__WEBPACK_IMPORTED_MODULE_3__.default)(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : 0; + var action = 'REPLACE'; + var location = createLocation(path, state, createKey(), history.location); + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + history.entries[history.index] = location; + setState({ + action: action, + location: location + }); + }); + } + + function go(n) { + var nextIndex = clamp(history.index + n, 0, history.entries.length - 1); + var action = 'POP'; + var location = history.entries[nextIndex]; + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (ok) { + setState({ + action: action, + location: location, + index: nextIndex + }); + } else { + // Mimic the behavior of DOM histories by + // causing a render after a cancelled POP. + setState(); + } + }); + } + + function goBack() { + go(-1); + } + + function goForward() { + go(1); + } + + function canGo(n) { + var nextIndex = history.index + n; + return nextIndex >= 0 && nextIndex < history.entries.length; + } + + function block(prompt) { + if (prompt === void 0) { + prompt = false; + } + + return transitionManager.setPrompt(prompt); + } + + function listen(listener) { + return transitionManager.appendListener(listener); + } + + var history = { + length: entries.length, + action: 'POP', + location: entries[index], + index: index, + entries: entries, + createHref: createHref, + push: push, + replace: replace, + go: go, + goBack: goBack, + goForward: goForward, + canGo: canGo, + block: block, + listen: listen + }; + return history; +} + + + + +/***/ }), + +/***/ "./node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js ***! + \**********************************************************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var reactIs = __webpack_require__(/*! react-is */ "./node_modules/react-is/index.js"); + +/** + * Copyright 2015, Yahoo! Inc. + * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +var REACT_STATICS = { + childContextTypes: true, + contextType: true, + contextTypes: true, + defaultProps: true, + displayName: true, + getDefaultProps: true, + getDerivedStateFromError: true, + getDerivedStateFromProps: true, + mixins: true, + propTypes: true, + type: true +}; +var KNOWN_STATICS = { + name: true, + length: true, + prototype: true, + caller: true, + callee: true, + arguments: true, + arity: true +}; +var FORWARD_REF_STATICS = { + '$$typeof': true, + render: true, + defaultProps: true, + displayName: true, + propTypes: true +}; +var MEMO_STATICS = { + '$$typeof': true, + compare: true, + defaultProps: true, + displayName: true, + propTypes: true, + type: true +}; +var TYPE_STATICS = {}; +TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS; +TYPE_STATICS[reactIs.Memo] = MEMO_STATICS; + +function getStatics(component) { + // React v16.11 and below + if (reactIs.isMemo(component)) { + return MEMO_STATICS; + } // React v16.12 and above + + + return TYPE_STATICS[component['$$typeof']] || REACT_STATICS; +} + +var defineProperty = Object.defineProperty; +var getOwnPropertyNames = Object.getOwnPropertyNames; +var getOwnPropertySymbols = Object.getOwnPropertySymbols; +var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; +var getPrototypeOf = Object.getPrototypeOf; +var objectPrototype = Object.prototype; +function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) { + if (typeof sourceComponent !== 'string') { + // don't hoist over string (html) components + if (objectPrototype) { + var inheritedComponent = getPrototypeOf(sourceComponent); + + if (inheritedComponent && inheritedComponent !== objectPrototype) { + hoistNonReactStatics(targetComponent, inheritedComponent, blacklist); + } + } + + var keys = getOwnPropertyNames(sourceComponent); + + if (getOwnPropertySymbols) { + keys = keys.concat(getOwnPropertySymbols(sourceComponent)); + } + + var targetStatics = getStatics(targetComponent); + var sourceStatics = getStatics(sourceComponent); + + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + + if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) { + var descriptor = getOwnPropertyDescriptor(sourceComponent, key); + + try { + // Avoid failures from read-only properties + defineProperty(targetComponent, key, descriptor); + } catch (e) {} + } + } + } + + return targetComponent; +} + +module.exports = hoistNonReactStatics; + + +/***/ }), + +/***/ "./node_modules/html-dom-parser/lib/client/constants.js": +/*!**************************************************************!*\ + !*** ./node_modules/html-dom-parser/lib/client/constants.js ***! + \**************************************************************/ +/***/ ((module) => { + +/** + * SVG elements are case-sensitive. + * + * @see {@link https://developer.mozilla.org/docs/Web/SVG/Element#SVG_elements_A_to_Z} + */ +var CASE_SENSITIVE_TAG_NAMES = [ + 'animateMotion', + 'animateTransform', + 'clipPath', + 'feBlend', + 'feColorMatrix', + 'feComponentTransfer', + 'feComposite', + 'feConvolveMatrix', + 'feDiffuseLighting', + 'feDisplacementMap', + 'feDropShadow', + 'feFlood', + 'feFuncA', + 'feFuncB', + 'feFuncG', + 'feFuncR', + 'feGaussainBlur', + 'feImage', + 'feMerge', + 'feMergeNode', + 'feMorphology', + 'feOffset', + 'fePointLight', + 'feSpecularLighting', + 'feSpotLight', + 'feTile', + 'feTurbulence', + 'foreignObject', + 'linearGradient', + 'radialGradient', + 'textPath' +]; + +module.exports = { + CASE_SENSITIVE_TAG_NAMES: CASE_SENSITIVE_TAG_NAMES +}; + + +/***/ }), + +/***/ "./node_modules/html-dom-parser/lib/client/domparser.js": +/*!**************************************************************!*\ + !*** ./node_modules/html-dom-parser/lib/client/domparser.js ***! + \**************************************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +// constants +var HTML = 'html'; +var HEAD = 'head'; +var BODY = 'body'; +var FIRST_TAG_REGEX = /<([a-zA-Z]+[0-9]?)/; // e.g.,

+var HEAD_TAG_REGEX = //i; +var BODY_TAG_REGEX = //i; + +// falls back to `parseFromString` if `createHTMLDocument` cannot be used +var parseFromDocument = function () { + throw new Error( + 'This browser does not support `document.implementation.createHTMLDocument`' + ); +}; + +var parseFromString = function () { + throw new Error( + 'This browser does not support `DOMParser.prototype.parseFromString`' + ); +}; + +/** + * DOMParser (performance: slow). + * + * @see https://developer.mozilla.org/docs/Web/API/DOMParser#Parsing_an_SVG_or_HTML_document + */ +if (typeof window.DOMParser === 'function') { + var domParser = new window.DOMParser(); + var mimeType = 'text/html'; + + /** + * Creates an HTML document using `DOMParser.parseFromString`. + * + * @param {string} html - The HTML string. + * @param {string} [tagName] - The element to render the HTML (with 'body' as fallback). + * @return {HTMLDocument} + */ + parseFromString = function (html, tagName) { + if (tagName) { + html = '<' + tagName + '>' + html + ''; + } + + return domParser.parseFromString(html, mimeType); + }; + + parseFromDocument = parseFromString; +} + +/** + * DOMImplementation (performance: fair). + * + * @see https://developer.mozilla.org/docs/Web/API/DOMImplementation/createHTMLDocument + */ +if (document.implementation) { + var isIE = __webpack_require__(/*! ./utilities */ "./node_modules/html-dom-parser/lib/client/utilities.js").isIE; + + // title parameter is required in IE + // https://msdn.microsoft.com/en-us/library/ff975457(v=vs.85).aspx + var doc = document.implementation.createHTMLDocument( + isIE() ? 'html-dom-parser' : undefined + ); + + /** + * Use HTML document created by `document.implementation.createHTMLDocument`. + * + * @param {string} html - The HTML string. + * @param {string} [tagName] - The element to render the HTML (with 'body' as fallback). + * @return {HTMLDocument} + */ + parseFromDocument = function (html, tagName) { + if (tagName) { + doc.documentElement.getElementsByTagName(tagName)[0].innerHTML = html; + return doc; + } + + doc.documentElement.innerHTML = html; + return doc; + }; +} + +/** + * Template (performance: fast). + * + * @see https://developer.mozilla.org/docs/Web/HTML/Element/template + */ +var template = document.createElement('template'); +var parseFromTemplate; + +if (template.content) { + /** + * Uses a template element (content fragment) to parse HTML. + * + * @param {string} html - The HTML string. + * @return {NodeList} + */ + parseFromTemplate = function (html) { + template.innerHTML = html; + return template.content.childNodes; + }; +} + +/** + * Parses HTML string to DOM nodes. + * + * @param {string} html - HTML markup. + * @return {NodeList} + */ +function domparser(html) { + var firstTagName; + var match = html.match(FIRST_TAG_REGEX); + + if (match && match[1]) { + firstTagName = match[1].toLowerCase(); + } + + var doc; + var element; + var elements; + + switch (firstTagName) { + case HTML: + doc = parseFromString(html); + + // the created document may come with filler head/body elements, + // so make sure to remove them if they don't actually exist + if (!HEAD_TAG_REGEX.test(html)) { + element = doc.getElementsByTagName(HEAD)[0]; + if (element) { + element.parentNode.removeChild(element); + } + } + + if (!BODY_TAG_REGEX.test(html)) { + element = doc.getElementsByTagName(BODY)[0]; + if (element) { + element.parentNode.removeChild(element); + } + } + + return doc.getElementsByTagName(HTML); + + case HEAD: + case BODY: + elements = parseFromDocument(html).getElementsByTagName(firstTagName); + + // if there's a sibling element, then return both elements + if (BODY_TAG_REGEX.test(html) && HEAD_TAG_REGEX.test(html)) { + return elements[0].parentNode.childNodes; + } + return elements; + + // low-level tag or text + default: + if (parseFromTemplate) { + return parseFromTemplate(html); + } + + return parseFromDocument(html, BODY).getElementsByTagName(BODY)[0] + .childNodes; + } +} + +module.exports = domparser; + + +/***/ }), + +/***/ "./node_modules/html-dom-parser/lib/client/html-to-dom.js": +/*!****************************************************************!*\ + !*** ./node_modules/html-dom-parser/lib/client/html-to-dom.js ***! + \****************************************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +var domparser = __webpack_require__(/*! ./domparser */ "./node_modules/html-dom-parser/lib/client/domparser.js"); +var formatDOM = __webpack_require__(/*! ./utilities */ "./node_modules/html-dom-parser/lib/client/utilities.js").formatDOM; + +var DIRECTIVE_REGEX = /<(![a-zA-Z\s]+)>/; // e.g., + +/** + * Parses HTML string to DOM nodes in browser. + * + * @param {string} html - HTML markup. + * @return {DomElement[]} - DOM elements. + */ +function HTMLDOMParser(html) { + if (typeof html !== 'string') { + throw new TypeError('First argument must be a string'); + } + + if (html === '') { + return []; + } + + // match directive + var match = html.match(DIRECTIVE_REGEX); + var directive; + + if (match && match[1]) { + directive = match[1]; + } + + return formatDOM(domparser(html), null, directive); +} + +module.exports = HTMLDOMParser; + + +/***/ }), + +/***/ "./node_modules/html-dom-parser/lib/client/utilities.js": +/*!**************************************************************!*\ + !*** ./node_modules/html-dom-parser/lib/client/utilities.js ***! + \**************************************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +var constants = __webpack_require__(/*! ./constants */ "./node_modules/html-dom-parser/lib/client/constants.js"); +var domhandler = __webpack_require__(/*! domhandler/lib/node */ "./node_modules/domhandler/lib/node.js"); + +var CASE_SENSITIVE_TAG_NAMES = constants.CASE_SENSITIVE_TAG_NAMES; + +var Comment = domhandler.Comment; +var Element = domhandler.Element; +var ProcessingInstruction = domhandler.ProcessingInstruction; +var Text = domhandler.Text; + +var caseSensitiveTagNamesMap = {}; +var tagName; + +for (var i = 0, len = CASE_SENSITIVE_TAG_NAMES.length; i < len; i++) { + tagName = CASE_SENSITIVE_TAG_NAMES[i]; + caseSensitiveTagNamesMap[tagName.toLowerCase()] = tagName; +} + +/** + * Gets case-sensitive tag name. + * + * @param {string} tagName - Tag name in lowercase. + * @return {string|undefined} - Case-sensitive tag name. + */ +function getCaseSensitiveTagName(tagName) { + return caseSensitiveTagNamesMap[tagName]; +} + +/** + * Formats DOM attributes to a hash map. + * + * @param {NamedNodeMap} attributes - List of attributes. + * @return {object} - Map of attribute name to value. + */ +function formatAttributes(attributes) { + var result = {}; + var attribute; + // `NamedNodeMap` is array-like + for (var i = 0, len = attributes.length; i < len; i++) { + attribute = attributes[i]; + result[attribute.name] = attribute.value; + } + return result; +} + +/** + * Corrects the tag name if it is case-sensitive (SVG). + * Otherwise, returns the lowercase tag name (HTML). + * + * @param {string} tagName - Lowercase tag name. + * @return {string} - Formatted tag name. + */ +function formatTagName(tagName) { + tagName = tagName.toLowerCase(); + var caseSensitiveTagName = getCaseSensitiveTagName(tagName); + if (caseSensitiveTagName) { + return caseSensitiveTagName; + } + return tagName; +} + +/** + * Transforms DOM nodes to `domhandler` nodes. + * + * @param {NodeList} nodes - DOM nodes. + * @param {Element|null} [parent=null] - Parent node. + * @param {string} [directive] - Directive. + * @return {Array} + */ +function formatDOM(nodes, parent, directive) { + parent = parent || null; + var result = []; + + for (var index = 0, len = nodes.length; index < len; index++) { + var node = nodes[index]; + var current; + + // set the node data given the type + switch (node.nodeType) { + case 1: + // script, style, or tag + current = new Element( + formatTagName(node.nodeName), + formatAttributes(node.attributes) + ); + current.children = formatDOM(node.childNodes, current); + break; + + case 3: + current = new Text(node.nodeValue); + break; + + case 8: + current = new Comment(node.nodeValue); + break; + + default: + continue; + } + + // set previous node next + var prev = result[index - 1] || null; + if (prev) { + prev.next = current; + } + + // set properties for current node + current.parent = parent; + current.prev = prev; + current.next = null; + + result.push(current); + } + + if (directive) { + current = new ProcessingInstruction( + directive.substring(0, directive.indexOf(' ')).toLowerCase(), + directive + ); + current.next = result[0] || null; + current.parent = parent; + result.unshift(current); + + if (result[1]) { + result[1].prev = result[0]; + } + } + + return result; +} + +/** + * Detects if browser is Internet Explorer. + * + * @return {boolean} - Whether IE is detected. + */ +function isIE() { + return /(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent); +} + +module.exports = { + formatAttributes: formatAttributes, + formatDOM: formatDOM, + isIE: isIE +}; + + +/***/ }), + +/***/ "./node_modules/html-react-parser/index.js": +/*!*************************************************!*\ + !*** ./node_modules/html-react-parser/index.js ***! + \*************************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +var domToReact = __webpack_require__(/*! ./lib/dom-to-react */ "./node_modules/html-react-parser/lib/dom-to-react.js"); +var attributesToProps = __webpack_require__(/*! ./lib/attributes-to-props */ "./node_modules/html-react-parser/lib/attributes-to-props.js"); +var htmlToDOM = __webpack_require__(/*! html-dom-parser */ "./node_modules/html-dom-parser/lib/client/html-to-dom.js"); + +var domParserOptions = { lowerCaseAttributeNames: false }; + +/** + * Converts HTML string to React elements. + * + * @param {String} html - HTML string. + * @param {Object} [options] - Parser options. + * @param {Object} [options.htmlparser2] - htmlparser2 options. + * @param {Object} [options.library] - Library for React, Preact, etc. + * @param {Function} [options.replace] - Replace method. + * @return {JSX.Element|JSX.Element[]|String} - React element(s), empty array, or string. + */ +function HTMLReactParser(html, options) { + if (typeof html !== 'string') { + throw new TypeError('First argument must be a string'); + } + if (html === '') { + return []; + } + options = options || {}; + return domToReact( + htmlToDOM(html, options.htmlparser2 || domParserOptions), + options + ); +} + +HTMLReactParser.domToReact = domToReact; +HTMLReactParser.htmlToDOM = htmlToDOM; +HTMLReactParser.attributesToProps = attributesToProps; + +// support CommonJS and ES Modules +module.exports = HTMLReactParser; +module.exports.default = HTMLReactParser; + + +/***/ }), + +/***/ "./node_modules/html-react-parser/index.mjs": +/*!**************************************************!*\ + !*** ./node_modules/html-react-parser/index.mjs ***! + \**************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "domToReact": () => (/* binding */ domToReact), +/* harmony export */ "htmlToDOM": () => (/* binding */ htmlToDOM), +/* harmony export */ "attributesToProps": () => (/* binding */ attributesToProps), +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./index.js */ "./node_modules/html-react-parser/index.js"); + + +var domToReact = _index_js__WEBPACK_IMPORTED_MODULE_0__.domToReact; +var htmlToDOM = _index_js__WEBPACK_IMPORTED_MODULE_0__.htmlToDOM; +var attributesToProps = _index_js__WEBPACK_IMPORTED_MODULE_0__.attributesToProps; + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_index_js__WEBPACK_IMPORTED_MODULE_0__); + + +/***/ }), + +/***/ "./node_modules/html-react-parser/lib/attributes-to-props.js": +/*!*******************************************************************!*\ + !*** ./node_modules/html-react-parser/lib/attributes-to-props.js ***! + \*******************************************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +var reactProperty = __webpack_require__(/*! react-property */ "./node_modules/react-property/index.js"); +var utilities = __webpack_require__(/*! ./utilities */ "./node_modules/html-react-parser/lib/utilities.js"); + +var setStyleProp = utilities.setStyleProp; + +var htmlProperties = reactProperty.html; +var svgProperties = reactProperty.svg; +var isCustomAttribute = reactProperty.isCustomAttribute; + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Converts HTML/SVG DOM attributes to React props. + * + * @param {object} [attributes={}] - HTML/SVG DOM attributes. + * @return {object} - React props. + */ +function attributesToProps(attributes) { + attributes = attributes || {}; + + var attributeName; + var attributeNameLowerCased; + var attributeValue; + var property; + var props = {}; + + for (attributeName in attributes) { + attributeValue = attributes[attributeName]; + + // ARIA (aria-*) or custom data (data-*) attribute + if (isCustomAttribute(attributeName)) { + props[attributeName] = attributeValue; + continue; + } + + // convert HTML attribute to React prop + attributeNameLowerCased = attributeName.toLowerCase(); + if (hasOwnProperty.call(htmlProperties, attributeNameLowerCased)) { + property = htmlProperties[attributeNameLowerCased]; + props[property.propertyName] = + property.hasBooleanValue || + (property.hasOverloadedBooleanValue && !attributeValue) + ? true + : attributeValue; + continue; + } + + // convert SVG attribute to React prop + if (hasOwnProperty.call(svgProperties, attributeName)) { + property = svgProperties[attributeName]; + props[property.propertyName] = attributeValue; + continue; + } + + // preserve custom attribute if React >=16 + if (utilities.PRESERVE_CUSTOM_ATTRIBUTES) { + props[attributeName] = attributeValue; + } + } + + // transform inline style to object + setStyleProp(attributes.style, props); + + return props; +} + +module.exports = attributesToProps; + + +/***/ }), + +/***/ "./node_modules/html-react-parser/lib/dom-to-react.js": +/*!************************************************************!*\ + !*** ./node_modules/html-react-parser/lib/dom-to-react.js ***! + \************************************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +var React = __webpack_require__(/*! react */ "./node_modules/react/index.js"); +var attributesToProps = __webpack_require__(/*! ./attributes-to-props */ "./node_modules/html-react-parser/lib/attributes-to-props.js"); +var utilities = __webpack_require__(/*! ./utilities */ "./node_modules/html-react-parser/lib/utilities.js"); + +var setStyleProp = utilities.setStyleProp; + +/** + * Converts DOM nodes to JSX element(s). + * + * @param {DomElement[]} nodes - DOM nodes. + * @param {object} [options={}] - Options. + * @param {Function} [options.replace] - Replacer. + * @param {object} [options.library] - Library (React/Preact/etc.). + * @return {string|JSX.Element|JSX.Element[]} + */ +function domToReact(nodes, options) { + options = options || {}; + + var library = options.library || React; + var cloneElement = library.cloneElement; + var createElement = library.createElement; + var isValidElement = library.isValidElement; + + var result = []; + var node; + var hasReplace = typeof options.replace === 'function'; + var replaceElement; + var props; + var children; + var data; + var trim = options.trim; + + for (var i = 0, len = nodes.length; i < len; i++) { + node = nodes[i]; + + // replace with custom React element (if present) + if (hasReplace) { + replaceElement = options.replace(node); + + if (isValidElement(replaceElement)) { + // set "key" prop for sibling elements + // https://fb.me/react-warning-keys + if (len > 1) { + replaceElement = cloneElement(replaceElement, { + key: replaceElement.key || i + }); + } + result.push(replaceElement); + continue; + } + } + + if (node.type === 'text') { + // if trim option is enabled, skip whitespace text nodes + if (trim) { + data = node.data.trim(); + if (data) { + result.push(node.data); + } + } else { + result.push(node.data); + } + continue; + } + + props = node.attribs; + if (skipAttributesToProps(node)) { + setStyleProp(props.style, props); + } else if (props) { + props = attributesToProps(props); + } + + children = null; + + switch (node.type) { + case 'script': + case 'style': + // prevent text in