PluginProbe
Elementor Website Builder – more than just a page builder / 3.34.1
Elementor Website Builder – more than just a page builder v3.34.1
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / assets / js / common.js

common.js in Elementor Website Builder – more than just a page builder 3.34.1, at assets/js/common.js

33,171 lines 1.3 MB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "../assets/dev/js/editor/utils/files-upload-handler.js":
5 /*!*************************************************************!*\
6 !*** ../assets/dev/js/editor/utils/files-upload-handler.js ***!
7 \*************************************************************/
8 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
9
10 "use strict";
11 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
12
13
14 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
15 Object.defineProperty(exports, "__esModule", ({
16 value: true
17 }));
18 exports["default"] = void 0;
19 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
20 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
21 var FilesUploadHandler = exports["default"] = /*#__PURE__*/function () {
22 function FilesUploadHandler() {
23 (0, _classCallCheck2.default)(this, FilesUploadHandler);
24 }
25 return (0, _createClass2.default)(FilesUploadHandler, null, [{
26 key: "isUploadEnabled",
27 value: function isUploadEnabled(mediaType) {
28 var unfilteredFilesTypes = ['svg', 'application/json'];
29 if (!unfilteredFilesTypes.includes(mediaType)) {
30 return true;
31 }
32 return elementorCommon.config.filesUpload.unfilteredFiles;
33 }
34 }, {
35 key: "setUploadTypeCaller",
36 value: function setUploadTypeCaller(frame) {
37 frame.uploader.uploader.param('uploadTypeCaller', 'elementor-wp-media-upload');
38 }
39 }, {
40 key: "getUnfilteredFilesNonAdminDialog",
41 value: function getUnfilteredFilesNonAdminDialog() {
42 return elementorCommon.dialogsManager.createWidget('alert', {
43 id: 'e-unfiltered-files-disabled-dialog',
44 headerMessage: __('Sorry, you can\'t upload that file yet', 'elementor'),
45 message: __('This is because JSON files may pose a security risk.', 'elementor') + '<br><br>' + __('To upload them anyway, ask the site administrator to enable unfiltered file uploads.', 'elementor'),
46 strings: {
47 confirm: __('Got it', 'elementor')
48 }
49 });
50 }
51 }, {
52 key: "getUnfilteredFilesNotEnabledDialog",
53 value: function getUnfilteredFilesNotEnabledDialog(callback) {
54 var elementorInstance = window.elementorAdmin || window.elementor;
55 if (!elementorInstance.config.user.is_administrator) {
56 return this.getUnfilteredFilesNonAdminDialog();
57 }
58 var onConfirm = function onConfirm() {
59 elementorCommon.ajax.addRequest('enable_unfiltered_files_upload', {}, true);
60 elementorCommon.config.filesUpload.unfilteredFiles = true;
61 callback();
62 };
63 return elementorInstance.helpers.getSimpleDialog('e-enable-unfiltered-files-dialog', __('Enable Unfiltered File Uploads', 'elementor'), __('Before you enable unfiltered files upload, note that such files include a security risk. Elementor does run a process to remove possible malicious code, but there is still risk involved when using such files.', 'elementor'), __('Enable', 'elementor'), onConfirm);
64 }
65 }, {
66 key: "getUnfilteredFilesNotEnabledImportTemplateDialog",
67 value: function getUnfilteredFilesNotEnabledImportTemplateDialog(callback) {
68 if (!(window.elementorAdmin || window.elementor).config.user.is_administrator) {
69 return this.getUnfilteredFilesNonAdminDialog();
70 }
71 return elementorCommon.dialogsManager.createWidget('confirm', {
72 id: 'e-enable-unfiltered-files-dialog-import-template',
73 headerMessage: __('Enable Unfiltered File Uploads', 'elementor'),
74 message: __('Before you enable unfiltered files upload, note that such files include a security risk. Elementor does run a process to remove possible malicious code, but there is still risk involved when using such files.', 'elementor') + '<br /><br />' + __('If you do not enable uploading unfiltered files, any SVG or JSON (including lottie) files used in the uploaded template will not be imported.', 'elementor'),
75 position: {
76 my: 'center center',
77 at: 'center center'
78 },
79 strings: {
80 confirm: __('Enable and Import', 'elementor'),
81 cancel: __('Import Without Enabling', 'elementor')
82 },
83 onConfirm: function onConfirm() {
84 elementorCommon.ajax.addRequest('enable_unfiltered_files_upload', {
85 success: function success() {
86 // This utility is used in both the admin and the Editor.
87 elementorCommon.config.filesUpload.unfilteredFiles = true;
88 callback();
89 }
90 }, true);
91 },
92 onCancel: function onCancel() {
93 return callback();
94 }
95 });
96 }
97 }]);
98 }();
99
100 /***/ }),
101
102 /***/ "../assets/dev/js/editor/utils/is-instanceof.js":
103 /*!******************************************************!*\
104 !*** ../assets/dev/js/editor/utils/is-instanceof.js ***!
105 \******************************************************/
106 /***/ ((__unused_webpack_module, exports) => {
107
108 "use strict";
109
110
111 Object.defineProperty(exports, "__esModule", ({
112 value: true
113 }));
114 exports["default"] = void 0;
115 function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
116 function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
117 function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
118 /**
119 * Some FileAPI objects such as FileList, DataTransferItem and DataTransferItemList has inconsistency with the retrieved
120 * object (from events, etc.) and the actual JavaScript object so a regular instanceof doesn't work. This function can
121 * check whether it's instanceof by using the objects constructor and prototype names.
122 *
123 * @param object
124 * @param constructors
125 * @return {boolean}
126 */
127 var _default = exports["default"] = function _default(object, constructors) {
128 constructors = Array.isArray(constructors) ? constructors : [constructors];
129 var _iterator = _createForOfIteratorHelper(constructors),
130 _step;
131 try {
132 for (_iterator.s(); !(_step = _iterator.n()).done;) {
133 var constructor = _step.value;
134 if (object.constructor.name === constructor.prototype[Symbol.toStringTag]) {
135 return true;
136 }
137 }
138 } catch (err) {
139 _iterator.e(err);
140 } finally {
141 _iterator.f();
142 }
143 return false;
144 };
145
146 /***/ }),
147
148 /***/ "../assets/dev/js/modules/imports/args-object.js":
149 /*!*******************************************************!*\
150 !*** ../assets/dev/js/modules/imports/args-object.js ***!
151 \*******************************************************/
152 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
153
154 "use strict";
155
156
157 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
158 Object.defineProperty(exports, "__esModule", ({
159 value: true
160 }));
161 exports["default"] = void 0;
162 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
163 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
164 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
165 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
166 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
167 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
168 var _instanceType = _interopRequireDefault(__webpack_require__(/*! ./instance-type */ "../assets/dev/js/modules/imports/instance-type.js"));
169 var _isInstanceof = _interopRequireDefault(__webpack_require__(/*! ../../editor/utils/is-instanceof */ "../assets/dev/js/editor/utils/is-instanceof.js"));
170 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
171 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
172 var ArgsObject = exports["default"] = /*#__PURE__*/function (_InstanceType) {
173 /**
174 * Function constructor().
175 *
176 * Create ArgsObject.
177 *
178 * @param {{}} args
179 */
180 function ArgsObject(args) {
181 var _this;
182 (0, _classCallCheck2.default)(this, ArgsObject);
183 _this = _callSuper(this, ArgsObject);
184 _this.args = args;
185 return _this;
186 }
187
188 /**
189 * Function requireArgument().
190 *
191 * Validate property in args.
192 *
193 * @param {string} property
194 * @param {{}} args
195 *
196 * @throws {Error}
197 */
198 (0, _inherits2.default)(ArgsObject, _InstanceType);
199 return (0, _createClass2.default)(ArgsObject, [{
200 key: "requireArgument",
201 value: function requireArgument(property) {
202 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.args;
203 if (!Object.prototype.hasOwnProperty.call(args, property)) {
204 throw Error("".concat(property, " is required."));
205 }
206 }
207
208 /**
209 * Function requireArgumentType().
210 *
211 * Validate property in args using `type === typeof(args.whatever)`.
212 *
213 * @param {string} property
214 * @param {string} type
215 * @param {{}} args
216 *
217 * @throws {Error}
218 */
219 }, {
220 key: "requireArgumentType",
221 value: function requireArgumentType(property, type) {
222 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
223 this.requireArgument(property, args);
224 if ((0, _typeof2.default)(args[property]) !== type) {
225 throw Error("".concat(property, " invalid type: ").concat(type, "."));
226 }
227 }
228
229 /**
230 * Function requireArgumentInstance().
231 *
232 * Validate property in args using `args.whatever instanceof instance`.
233 *
234 * @param {string} property
235 * @param {*} instance
236 * @param {{}} args
237 *
238 * @throws {Error}
239 */
240 }, {
241 key: "requireArgumentInstance",
242 value: function requireArgumentInstance(property, instance) {
243 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
244 this.requireArgument(property, args);
245 if (!(args[property] instanceof instance) && !(0, _isInstanceof.default)(args[property], instance)) {
246 throw Error("".concat(property, " invalid instance."));
247 }
248 }
249
250 /**
251 * Function requireArgumentConstructor().
252 *
253 * Validate property in args using `type === args.whatever.constructor`.
254 *
255 * @param {string} property
256 * @param {*} type
257 * @param {{}} args
258 *
259 * @throws {Error}
260 */
261 }, {
262 key: "requireArgumentConstructor",
263 value: function requireArgumentConstructor(property, type) {
264 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
265 this.requireArgument(property, args);
266
267 // Note: Converting the constructor to string in order to avoid equation issues
268 // due to different memory addresses between iframes (window.Object !== window.top.Object).
269 if (args[property].constructor.toString() !== type.prototype.constructor.toString()) {
270 throw Error("".concat(property, " invalid constructor type."));
271 }
272 }
273 }], [{
274 key: "getInstanceType",
275 value: function getInstanceType() {
276 return 'ArgsObject';
277 }
278 }]);
279 }(_instanceType.default);
280
281 /***/ }),
282
283 /***/ "../assets/dev/js/modules/imports/instance-type.js":
284 /*!*********************************************************!*\
285 !*** ../assets/dev/js/modules/imports/instance-type.js ***!
286 \*********************************************************/
287 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
288
289 "use strict";
290
291
292 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
293 Object.defineProperty(exports, "__esModule", ({
294 value: true
295 }));
296 exports["default"] = void 0;
297 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
298 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
299 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
300 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
301 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
302 var InstanceType = exports["default"] = /*#__PURE__*/function () {
303 function InstanceType() {
304 var _this = this;
305 (0, _classCallCheck2.default)(this, InstanceType);
306 // Since anonymous classes sometimes do not get validated by babel, do it manually.
307 var target = this instanceof InstanceType ? this.constructor : void 0;
308 var prototypes = [];
309 while (target.__proto__ && target.__proto__.name) {
310 prototypes.push(target.__proto__);
311 target = target.__proto__;
312 }
313 prototypes.reverse().forEach(function (proto) {
314 return _this instanceof proto;
315 });
316 }
317 return (0, _createClass2.default)(InstanceType, null, [{
318 key: Symbol.hasInstance,
319 value: function value(target) {
320 /**
321 * This is function extending being called each time JS uses instanceOf, since babel use it each time it create new class
322 * its give's opportunity to mange capabilities of instanceOf operator.
323 * saving current class each time will give option later to handle instanceOf manually.
324 */
325 var result = _superPropGet(InstanceType, Symbol.hasInstance, this, 2)([target]);
326
327 // Act normal when validate a class, which does not have instance type.
328 if (target && !target.constructor.getInstanceType) {
329 return result;
330 }
331 if (target) {
332 if (!target.instanceTypes) {
333 target.instanceTypes = [];
334 }
335 if (!result) {
336 if (this.getInstanceType() === target.constructor.getInstanceType()) {
337 result = true;
338 }
339 }
340 if (result) {
341 var name = this.getInstanceType === InstanceType.getInstanceType ? 'BaseInstanceType' : this.getInstanceType();
342 if (-1 === target.instanceTypes.indexOf(name)) {
343 target.instanceTypes.push(name);
344 }
345 }
346 }
347 if (!result && target) {
348 // Check if the given 'target', is instance of known types.
349 result = target.instanceTypes && Array.isArray(target.instanceTypes) && -1 !== target.instanceTypes.indexOf(this.getInstanceType());
350 }
351 return result;
352 }
353 }, {
354 key: "getInstanceType",
355 value: function getInstanceType() {
356 elementorModules.ForceMethodImplementation();
357 }
358 }]);
359 }();
360
361 /***/ }),
362
363 /***/ "../assets/dev/js/modules/imports/module.js":
364 /*!**************************************************!*\
365 !*** ../assets/dev/js/modules/imports/module.js ***!
366 \**************************************************/
367 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
368
369 "use strict";
370
371
372 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
373 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
374 var Module = function Module() {
375 var $ = jQuery,
376 instanceParams = arguments,
377 self = this,
378 events = {};
379 var settings;
380 var ensureClosureMethods = function ensureClosureMethods() {
381 $.each(self, function (methodName) {
382 var oldMethod = self[methodName];
383 if ('function' !== typeof oldMethod) {
384 return;
385 }
386 self[methodName] = function () {
387 return oldMethod.apply(self, arguments);
388 };
389 });
390 };
391 var initSettings = function initSettings() {
392 settings = self.getDefaultSettings();
393 var instanceSettings = instanceParams[0];
394 if (instanceSettings) {
395 $.extend(true, settings, instanceSettings);
396 }
397 };
398 var init = function init() {
399 self.__construct.apply(self, instanceParams);
400 ensureClosureMethods();
401 initSettings();
402 self.trigger('init');
403 };
404 this.getItems = function (items, itemKey) {
405 if (itemKey) {
406 var keyStack = itemKey.split('.'),
407 currentKey = keyStack.splice(0, 1);
408 if (!keyStack.length) {
409 return items[currentKey];
410 }
411 if (!items[currentKey]) {
412 return;
413 }
414 return this.getItems(items[currentKey], keyStack.join('.'));
415 }
416 return items;
417 };
418 this.getSettings = function (setting) {
419 return this.getItems(settings, setting);
420 };
421 this.setSettings = function (settingKey, value, settingsContainer) {
422 if (!settingsContainer) {
423 settingsContainer = settings;
424 }
425 if ('object' === (0, _typeof2.default)(settingKey)) {
426 $.extend(settingsContainer, settingKey);
427 return self;
428 }
429 var keyStack = settingKey.split('.'),
430 currentKey = keyStack.splice(0, 1);
431 if (!keyStack.length) {
432 settingsContainer[currentKey] = value;
433 return self;
434 }
435 if (!settingsContainer[currentKey]) {
436 settingsContainer[currentKey] = {};
437 }
438 return self.setSettings(keyStack.join('.'), value, settingsContainer[currentKey]);
439 };
440 this.getErrorMessage = function (type, functionName) {
441 var message;
442 switch (type) {
443 case 'forceMethodImplementation':
444 message = "The method '".concat(functionName, "' must to be implemented in the inheritor child.");
445 break;
446 default:
447 message = 'An error occurs';
448 }
449 return message;
450 };
451
452 // TODO: This function should be deleted ?.
453 this.forceMethodImplementation = function (functionName) {
454 throw new Error(this.getErrorMessage('forceMethodImplementation', functionName));
455 };
456 this.on = function (eventName, callback) {
457 if ('object' === (0, _typeof2.default)(eventName)) {
458 $.each(eventName, function (singleEventName) {
459 self.on(singleEventName, this);
460 });
461 return self;
462 }
463 var eventNames = eventName.split(' ');
464 eventNames.forEach(function (singleEventName) {
465 if (!events[singleEventName]) {
466 events[singleEventName] = [];
467 }
468 events[singleEventName].push(callback);
469 });
470 return self;
471 };
472 this.off = function (eventName, callback) {
473 if (!events[eventName]) {
474 return self;
475 }
476 if (!callback) {
477 delete events[eventName];
478 return self;
479 }
480 var callbackIndex = events[eventName].indexOf(callback);
481 if (-1 !== callbackIndex) {
482 delete events[eventName][callbackIndex];
483
484 // Reset array index (for next off on same event).
485 events[eventName] = events[eventName].filter(function (val) {
486 return val;
487 });
488 }
489 return self;
490 };
491 this.trigger = function (eventName) {
492 var methodName = 'on' + eventName[0].toUpperCase() + eventName.slice(1),
493 params = Array.prototype.slice.call(arguments, 1);
494 if (self[methodName]) {
495 self[methodName].apply(self, params);
496 }
497 var callbacks = events[eventName];
498 if (!callbacks) {
499 return self;
500 }
501 $.each(callbacks, function (index, callback) {
502 callback.apply(self, params);
503 });
504 return self;
505 };
506 init();
507 };
508 Module.prototype.__construct = function () {};
509 Module.prototype.getDefaultSettings = function () {
510 return {};
511 };
512 Module.prototype.getConstructorID = function () {
513 return this.constructor.name;
514 };
515 Module.extend = function (properties) {
516 var $ = jQuery,
517 parent = this;
518 var child = function child() {
519 return parent.apply(this, arguments);
520 };
521 $.extend(child, parent);
522 child.prototype = Object.create($.extend({}, parent.prototype, properties));
523 child.prototype.constructor = child;
524 child.__super__ = parent.prototype;
525 return child;
526 };
527 module.exports = Module;
528
529 /***/ }),
530
531 /***/ "../assets/dev/js/utils/notifications.js":
532 /*!***********************************************!*\
533 !*** ../assets/dev/js/utils/notifications.js ***!
534 \***********************************************/
535 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
536
537 "use strict";
538
539
540 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
541 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
542 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
543 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
544 module.exports = elementorModules.Module.extend({
545 initToast: function initToast() {
546 var toast = elementorCommon.dialogsManager.createWidget('buttons', {
547 id: 'elementor-toast',
548 position: {
549 my: 'center bottom',
550 at: 'center bottom-10',
551 of: '#elementor-panel-inner',
552 autoRefresh: true
553 },
554 hide: {
555 onClick: true,
556 auto: true,
557 autoDelay: 10000
558 },
559 effects: {
560 show: function show() {
561 var $widget = toast.getElements('widget');
562 $widget.show();
563 toast.refreshPosition();
564 var top = parseInt($widget.css('top'), 10);
565 $widget.hide().css('top', top + 100);
566 $widget.animate({
567 opacity: 'show',
568 height: 'show',
569 paddingBottom: 'show',
570 paddingTop: 'show',
571 top: top
572 }, {
573 easing: 'linear',
574 duration: 300
575 });
576 },
577 hide: function hide() {
578 var $widget = toast.getElements('widget'),
579 top = parseInt($widget.css('top'), 10);
580 $widget.animate({
581 opacity: 'hide',
582 height: 'hide',
583 paddingBottom: 'hide',
584 paddingTop: 'hide',
585 top: top + 100
586 }, {
587 easing: 'linear',
588 duration: 300
589 });
590 }
591 },
592 button: {
593 tag: 'div'
594 }
595 });
596 this.getToast = function () {
597 return toast;
598 };
599 },
600 showToast: function showToast(options) {
601 var toast = this.getToast();
602 toast.setMessage(options.message);
603 toast.getElements('buttonsWrapper').empty();
604 var isPositionValid = this.isPositionValid(options === null || options === void 0 ? void 0 : options.position);
605 if (!isPositionValid) {
606 this.positionToWindow();
607 }
608 if (options !== null && options !== void 0 && options.position && isPositionValid) {
609 toast.setSettings('position', options.position);
610 }
611 if (options.buttons) {
612 options.buttons.forEach(function (button) {
613 toast.addButton(button);
614 });
615 }
616 if (options.classes) {
617 toast.getElements('widget').addClass(options.classes);
618 }
619 if (options.sticky) {
620 toast.setSettings({
621 hide: {
622 auto: false,
623 onClick: false
624 }
625 });
626 }
627 return toast.show();
628 },
629 isPositionValid: function isPositionValid(position) {
630 var _position$of;
631 var positionToCheck = (_position$of = position === null || position === void 0 ? void 0 : position.of) !== null && _position$of !== void 0 ? _position$of : this.getToast().getSettings('position').of;
632 if (!positionToCheck) {
633 return false;
634 }
635 return !!document.querySelector(positionToCheck);
636 },
637 positionToWindow: function positionToWindow() {
638 var toast = this.getToast();
639 var position = _objectSpread(_objectSpread({}, toast.getSettings('position')), {}, {
640 my: 'right top',
641 at: 'right-10 top+42',
642 // 42px is the default admin bar height + 10px
643 of: ''
644 });
645 toast.setSettings('position', position);
646 toast.getElements('widget').addClass('dialog-position-window');
647 },
648 onInit: function onInit() {
649 this.initToast();
650 }
651 });
652
653 /***/ }),
654
655 /***/ "../assets/dev/js/utils/tiers.js":
656 /*!***************************************!*\
657 !*** ../assets/dev/js/utils/tiers.js ***!
658 \***************************************/
659 /***/ ((__unused_webpack_module, exports) => {
660
661 "use strict";
662
663
664 Object.defineProperty(exports, "__esModule", ({
665 value: true
666 }));
667 exports.isTierAtLeast = exports.TIERS_PRIORITY = exports.TIERS = void 0;
668 var TIERS_PRIORITY = exports.TIERS_PRIORITY = Object.freeze(['free', 'essential', 'essential-oct2023', 'advanced', 'expert', 'agency']);
669
670 /**
671 * @type {Readonly<{
672 * free: string;
673 * essential: string;
674 * 'essential-oct2023': string;
675 * advanced: string;
676 * expert: string;
677 * agency: string;
678 * }>}
679 */
680 var TIERS = exports.TIERS = Object.freeze(TIERS_PRIORITY.reduce(function (acc, tier) {
681 acc[tier] = tier;
682 return acc;
683 }, {}));
684 var isTierAtLeast = exports.isTierAtLeast = function isTierAtLeast(currentTier, expectedTier) {
685 var currentTierIndex = TIERS_PRIORITY.indexOf(currentTier);
686 var expectedTierIndex = TIERS_PRIORITY.indexOf(expectedTier);
687 if (-1 === currentTierIndex || -1 === expectedTierIndex) {
688 return false;
689 }
690 return currentTierIndex >= expectedTierIndex;
691 };
692
693 /***/ }),
694
695 /***/ "../assets/dev/js/utils/time.js":
696 /*!**************************************!*\
697 !*** ../assets/dev/js/utils/time.js ***!
698 \**************************************/
699 /***/ ((__unused_webpack_module, exports) => {
700
701 "use strict";
702
703
704 Object.defineProperty(exports, "__esModule", ({
705 value: true
706 }));
707 exports["default"] = getUserTimestamp;
708 /**
709 * Returns the timestamp in ISO8601 format with the UTC timezone offset.
710 *
711 * @since 3.6.0
712 *
713 * @param {Date} date
714 * @return {Date} timestamp
715 */
716 function getUserTimestamp() {
717 var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
718 var timezoneOffset = date.getTimezoneOffset();
719
720 // Local time for the user
721 var UTCTimestamp = new Date(date.getTime() - timezoneOffset * 60000).toISOString();
722
723 // Remove the Z suffix from the string.
724 UTCTimestamp = UTCTimestamp.slice(0, -1);
725
726 // Create the offset string in the format `+HH:00` (or minus (-) prefix for negative offset instead of plus)
727 var decimalTimezoneOffset = timezoneOffset / 60,
728 // Negative offsets include a '-' sign in the getTimezoneOffset value, positive values need a '+' prefix (ISO8601).
729 sign = 0 <= decimalTimezoneOffset ? '+' : '-',
730 hours = Math.abs(Math.floor(decimalTimezoneOffset)),
731 minutes = Math.abs(decimalTimezoneOffset % 1) * 60,
732 addZeroToHour = 10 > hours ? '0' : '',
733 addZeroToMinutes = 10 > minutes ? '0' : '';
734 var formattedTimezoneOffset = sign + addZeroToHour + hours + ':' + addZeroToMinutes + minutes;
735 return UTCTimestamp + formattedTimezoneOffset;
736 }
737
738 /***/ }),
739
740 /***/ "../core/common/assets/js/components/wordpress/commands-data/index.js":
741 /*!****************************************************************************!*\
742 !*** ../core/common/assets/js/components/wordpress/commands-data/index.js ***!
743 \****************************************************************************/
744 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
745
746 "use strict";
747
748
749 Object.defineProperty(exports, "__esModule", ({
750 value: true
751 }));
752 Object.defineProperty(exports, "Media", ({
753 enumerable: true,
754 get: function get() {
755 return _media.Media;
756 }
757 }));
758 var _media = __webpack_require__(/*! ./media */ "../core/common/assets/js/components/wordpress/commands-data/media.js");
759
760 /***/ }),
761
762 /***/ "../core/common/assets/js/components/wordpress/commands-data/media.js":
763 /*!****************************************************************************!*\
764 !*** ../core/common/assets/js/components/wordpress/commands-data/media.js ***!
765 \****************************************************************************/
766 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
767
768 "use strict";
769 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
770
771
772 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
773 Object.defineProperty(exports, "__esModule", ({
774 value: true
775 }));
776 exports.Media = void 0;
777 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
778 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
779 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
780 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
781 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
782 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
783 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
784 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
785 var _commandData = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-data */ "../modules/web-cli/assets/js/modules/command-data.js"));
786 var _filesUploadHandler = _interopRequireDefault(__webpack_require__(/*! elementor-editor/utils/files-upload-handler */ "../assets/dev/js/editor/utils/files-upload-handler.js"));
787 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
788 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
789 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
790 var Media = exports.Media = /*#__PURE__*/function (_CommandData) {
791 function Media() {
792 (0, _classCallCheck2.default)(this, Media);
793 return _callSuper(this, Media, arguments);
794 }
795 (0, _inherits2.default)(Media, _CommandData);
796 return (0, _createClass2.default)(Media, [{
797 key: "validateArgs",
798 value: function validateArgs() {
799 this.requireArgumentInstance('file', File);
800 }
801 }, {
802 key: "getRequestData",
803 value: function getRequestData() {
804 var requestData = _superPropGet(Media, "getRequestData", this, 3)([]);
805 requestData.namespace = 'wp';
806 requestData.version = '2';
807 return requestData;
808 }
809 }, {
810 key: "applyBeforeCreate",
811 value: function applyBeforeCreate(args) {
812 var _args$options;
813 args.headers = {
814 'Content-Disposition': "attachment; filename=".concat(this.file.name),
815 'Content-Type': this.file.type
816 };
817 args.query = {
818 uploadTypeCaller: 'elementor-wp-media-upload'
819 };
820 args.data = this.file;
821 if ((_args$options = args.options) !== null && _args$options !== void 0 && _args$options.progress) {
822 this.toast = elementor.notifications.showToast({
823 // eslint-disable-next-line @wordpress/i18n-ellipsis
824 message: __('Uploading...'),
825 sticky: true
826 });
827 }
828 return args;
829 }
830 }, {
831 key: "applyAfterCreate",
832 value: function applyAfterCreate(data, args) {
833 var _args$options2;
834 if ((_args$options2 = args.options) !== null && _args$options2 !== void 0 && _args$options2.progress) {
835 this.toast.hide();
836 }
837 return data;
838 }
839 }, {
840 key: "run",
841 value: function () {
842 var _run = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
843 return _regenerator.default.wrap(function (_context) {
844 while (1) switch (_context.prev = _context.next) {
845 case 0:
846 this.file = this.args.file;
847 if (!(this.file.size > parseInt(window._wpPluploadSettings.defaults.filters.max_file_size, 10))) {
848 _context.next = 1;
849 break;
850 }
851 throw new Error(__('The file exceeds the maximum upload size for this site.', 'elementor'));
852 case 1:
853 if (!(!window._wpPluploadSettings.defaults.filters.mime_types[0].extensions.split(',').includes(this.file.name.split('.').pop()) && !elementor.config.filesUpload.unfilteredFiles)) {
854 _context.next = 2;
855 break;
856 }
857 _filesUploadHandler.default.getUnfilteredFilesNotEnabledDialog(function () {}).show();
858 return _context.abrupt("return");
859 case 2:
860 _context.next = 3;
861 return _superPropGet(Media, "run", this, 3)([]);
862 case 3:
863 return _context.abrupt("return", _context.sent);
864 case 4:
865 case "end":
866 return _context.stop();
867 }
868 }, _callee, this);
869 }));
870 function run() {
871 return _run.apply(this, arguments);
872 }
873 return run;
874 }()
875 }], [{
876 key: "getEndpointFormat",
877 value: function getEndpointFormat() {
878 // 'wp/media' to 'media' since `requestData.namespace` is 'wp'.
879 return 'media';
880 }
881 }]);
882 }(_commandData.default);
883
884 /***/ }),
885
886 /***/ "../core/common/assets/js/components/wordpress/component.js":
887 /*!******************************************************************!*\
888 !*** ../core/common/assets/js/components/wordpress/component.js ***!
889 \******************************************************************/
890 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
891
892 "use strict";
893
894
895 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
896 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
897 Object.defineProperty(exports, "__esModule", ({
898 value: true
899 }));
900 exports["default"] = void 0;
901 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
902 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
903 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
904 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
905 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
906 var _componentBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
907 var dataCommands = _interopRequireWildcard(__webpack_require__(/*! ./commands-data/ */ "../core/common/assets/js/components/wordpress/commands-data/index.js"));
908 function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
909 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
910 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
911 var Component = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
912 function Component() {
913 (0, _classCallCheck2.default)(this, Component);
914 return _callSuper(this, Component, arguments);
915 }
916 (0, _inherits2.default)(Component, _ComponentBase);
917 return (0, _createClass2.default)(Component, [{
918 key: "getNamespace",
919 value: function getNamespace() {
920 return 'wp';
921 }
922 }, {
923 key: "defaultData",
924 value: function defaultData() {
925 return this.importCommands(dataCommands);
926 }
927 }]);
928 }(_componentBase.default);
929
930 /***/ }),
931
932 /***/ "../core/common/assets/js/utils/debug.js":
933 /*!***********************************************!*\
934 !*** ../core/common/assets/js/utils/debug.js ***!
935 \***********************************************/
936 /***/ ((module) => {
937
938 "use strict";
939
940
941 // Moved from assets/dev/js/editor/utils
942 var Debug = function Debug() {
943 var self = this,
944 errorStack = [],
945 settings = {},
946 elements = {};
947 var initSettings = function initSettings() {
948 settings = {
949 debounceDelay: 500,
950 urlsToWatch: ['elementor/assets']
951 };
952 };
953 var initElements = function initElements() {
954 elements.$window = jQuery(window);
955 };
956 var onError = function onError(event) {
957 var _event$originalEvent;
958 var error = (_event$originalEvent = event.originalEvent) === null || _event$originalEvent === void 0 ? void 0 : _event$originalEvent.error;
959 if (!error) {
960 return;
961 }
962 var isInWatchList = false,
963 urlsToWatch = settings.urlsToWatch;
964 jQuery.each(urlsToWatch, function () {
965 if (-1 !== error.stack.indexOf(this)) {
966 isInWatchList = true;
967 return false;
968 }
969 });
970 if (!isInWatchList) {
971 return;
972 }
973 self.addError({
974 type: error.name,
975 message: error.message,
976 url: event.originalEvent.filename,
977 line: event.originalEvent.lineno,
978 column: event.originalEvent.colno
979 });
980 };
981 var bindEvents = function bindEvents() {
982 elements.$window.on('error', onError);
983 };
984 var init = function init() {
985 initSettings();
986 initElements();
987 bindEvents();
988 self.sendErrors = _.debounce(self.sendErrors, settings.debounceDelay);
989 };
990 this.addURLToWatch = function (url) {
991 settings.urlsToWatch.push(url);
992 };
993 this.addCustomError = function (error, category, tag) {
994 var errorInfo = {
995 type: error.name,
996 message: error.message,
997 url: error.fileName || error.sourceURL,
998 line: error.lineNumber || error.line,
999 column: error.columnNumber || error.column,
1000 customFields: {
1001 category: category || 'general',
1002 tag: tag
1003 }
1004 };
1005 if (!errorInfo.url) {
1006 var stackInfo = error.stack.match(/\n {4}at (.*?(?=:(\d+):(\d+)))/);
1007 if (stackInfo) {
1008 errorInfo.url = stackInfo[1];
1009 errorInfo.line = stackInfo[2];
1010 errorInfo.column = stackInfo[3];
1011 }
1012 }
1013 this.addError(errorInfo);
1014 };
1015 this.addError = function (errorParams) {
1016 var defaultParams = {
1017 type: 'Error',
1018 timestamp: Math.floor(new Date().getTime() / 1000),
1019 message: null,
1020 url: null,
1021 line: null,
1022 column: null,
1023 customFields: {}
1024 };
1025 errorStack.push(jQuery.extend(true, defaultParams, errorParams));
1026 self.sendErrors();
1027 };
1028 this.sendErrors = function () {
1029 // Avoid recursions on errors in ajax
1030 elements.$window.off('error', onError);
1031 jQuery.ajax({
1032 url: elementorCommon.config.ajax.url,
1033 method: 'POST',
1034 data: {
1035 action: 'elementor_js_log',
1036 _nonce: elementorCommon.ajax.getSettings('nonce'),
1037 data: errorStack
1038 },
1039 success: function success() {
1040 errorStack = [];
1041
1042 // Restore error handler
1043 elements.$window.on('error', onError);
1044 }
1045 });
1046 };
1047 init();
1048 };
1049 module.exports = Debug;
1050
1051 /***/ }),
1052
1053 /***/ "../core/common/assets/js/utils/helpers.js":
1054 /*!*************************************************!*\
1055 !*** ../core/common/assets/js/utils/helpers.js ***!
1056 \*************************************************/
1057 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1058
1059 "use strict";
1060
1061
1062 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1063 Object.defineProperty(exports, "__esModule", ({
1064 value: true
1065 }));
1066 exports["default"] = void 0;
1067 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1068 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1069 var Helpers = exports["default"] = /*#__PURE__*/function () {
1070 function Helpers() {
1071 (0, _classCallCheck2.default)(this, Helpers);
1072 }
1073 return (0, _createClass2.default)(Helpers, [{
1074 key: "consoleWarn",
1075 value:
1076 /**
1077 * @param {*} args
1078 * @deprecated since 3.7.0, use `elementorDevTools.consoleWarn()` instead.
1079 */
1080 function consoleWarn() {
1081 var _elementorDevTools;
1082 (_elementorDevTools = elementorDevTools).consoleWarn.apply(_elementorDevTools, arguments);
1083
1084 // This is is self is deprecated.
1085 elementorDevTools.deprecation.deprecated('elementorCommon.helpers.consoleWarn()', '3.7.0', 'elementorDevTools.consoleWarn()');
1086 }
1087
1088 /**
1089 * @param {string} message
1090 * @deprecated since 3.7.0, use `console.error()` instead.
1091 */
1092 }, {
1093 key: "consoleError",
1094 value: function consoleError(message) {
1095 // eslint-disable-next-line no-console
1096 console.error(message);
1097
1098 // This is is self is deprecated.
1099 elementorDevTools.deprecation.deprecated('elementorCommon.helpers.consoleError()', '3.7.0', 'console.error()');
1100 }
1101 }, {
1102 key: "cloneObject",
1103 value: function cloneObject(object) {
1104 return JSON.parse(JSON.stringify(object));
1105 }
1106 }, {
1107 key: "upperCaseWords",
1108 value: function upperCaseWords(string) {
1109 return (string + '').replace(/^(.)|\s+(.)/g, function ($1) {
1110 return $1.toUpperCase();
1111 });
1112 }
1113 }, {
1114 key: "getUniqueId",
1115 value: function getUniqueId() {
1116 return Math.random().toString(16).substr(2, 7);
1117 }
1118 }]);
1119 }();
1120
1121 /***/ }),
1122
1123 /***/ "../core/common/assets/js/utils/storage.js":
1124 /*!*************************************************!*\
1125 !*** ../core/common/assets/js/utils/storage.js ***!
1126 \*************************************************/
1127 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1128
1129 "use strict";
1130
1131
1132 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1133 Object.defineProperty(exports, "__esModule", ({
1134 value: true
1135 }));
1136 exports["default"] = void 0;
1137 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1138 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1139 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1140 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1141 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1142 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1143 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1144 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1145 function _default() {
1146 (0, _classCallCheck2.default)(this, _default);
1147 return _callSuper(this, _default, arguments);
1148 }
1149 (0, _inherits2.default)(_default, _elementorModules$Mod);
1150 return (0, _createClass2.default)(_default, [{
1151 key: "get",
1152 value: function get(key, options) {
1153 options = options || {};
1154 var storage;
1155 try {
1156 storage = options.session ? sessionStorage : localStorage;
1157 } catch (e) {
1158 return key ? undefined : {};
1159 }
1160 var elementorStorage = storage.getItem('elementor');
1161 if (elementorStorage) {
1162 elementorStorage = JSON.parse(elementorStorage);
1163 } else {
1164 elementorStorage = {};
1165 }
1166 if (!elementorStorage.__expiration) {
1167 elementorStorage.__expiration = {};
1168 }
1169 var expiration = elementorStorage.__expiration;
1170 var expirationToCheck = [];
1171 if (key) {
1172 if (expiration[key]) {
1173 expirationToCheck = [key];
1174 }
1175 } else {
1176 expirationToCheck = Object.keys(expiration);
1177 }
1178 var entryExpired = false;
1179 expirationToCheck.forEach(function (expirationKey) {
1180 if (new Date(expiration[expirationKey]) < new Date()) {
1181 delete elementorStorage[expirationKey];
1182 delete expiration[expirationKey];
1183 entryExpired = true;
1184 }
1185 });
1186 if (entryExpired) {
1187 this.save(elementorStorage, options.session);
1188 }
1189 if (key) {
1190 return elementorStorage[key];
1191 }
1192 return elementorStorage;
1193 }
1194 }, {
1195 key: "set",
1196 value: function set(key, value, options) {
1197 options = options || {};
1198 var elementorStorage = this.get(null, options);
1199 elementorStorage[key] = value;
1200 if (options.lifetimeInSeconds) {
1201 var date = new Date();
1202 date.setTime(date.getTime() + options.lifetimeInSeconds * 1000);
1203 elementorStorage.__expiration[key] = date.getTime();
1204 }
1205 this.save(elementorStorage, options.session);
1206 }
1207 }, {
1208 key: "save",
1209 value: function save(object, session) {
1210 var storage;
1211 try {
1212 storage = session ? sessionStorage : localStorage;
1213 } catch (e) {
1214 return;
1215 }
1216 storage.setItem('elementor', JSON.stringify(object));
1217 }
1218 }]);
1219 }(elementorModules.Module);
1220
1221 /***/ }),
1222
1223 /***/ "../core/common/modules/ajax/assets/js/ajax.js":
1224 /*!*****************************************************!*\
1225 !*** ../core/common/modules/ajax/assets/js/ajax.js ***!
1226 \*****************************************************/
1227 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1228
1229 "use strict";
1230
1231
1232 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1233 Object.defineProperty(exports, "__esModule", ({
1234 value: true
1235 }));
1236 exports["default"] = void 0;
1237 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
1238 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1239 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1240 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1241 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1242 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1243 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1244 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1245 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1246 function _default() {
1247 var _this;
1248 (0, _classCallCheck2.default)(this, _default);
1249 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1250 args[_key] = arguments[_key];
1251 }
1252 _this = _callSuper(this, _default, [].concat(args));
1253 _this.requests = {};
1254 _this.cache = {};
1255 _this.initRequestConstants();
1256 _this.debounceSendBatch = _.debounce(_this.sendBatch.bind(_this), 500);
1257 return _this;
1258 }
1259 (0, _inherits2.default)(_default, _elementorModules$Mod);
1260 return (0, _createClass2.default)(_default, [{
1261 key: "getDefaultSettings",
1262 value: function getDefaultSettings() {
1263 return {
1264 ajaxParams: {
1265 type: 'POST',
1266 url: elementorCommon.config.ajax.url,
1267 data: {},
1268 dataType: 'json'
1269 },
1270 actionPrefix: 'elementor_'
1271 };
1272 }
1273 }, {
1274 key: "initRequestConstants",
1275 value: function initRequestConstants() {
1276 this.requestConstants = {
1277 _nonce: this.getSettings('nonce')
1278 };
1279 }
1280 }, {
1281 key: "addRequestConstant",
1282 value: function addRequestConstant(key, value) {
1283 this.requestConstants[key] = value;
1284 }
1285 }, {
1286 key: "getCacheKey",
1287 value: function getCacheKey(request) {
1288 return JSON.stringify({
1289 unique_id: request.unique_id,
1290 data: request.data
1291 });
1292 }
1293 }, {
1294 key: "loadObjects",
1295 value: function loadObjects(options) {
1296 var _this2 = this;
1297 var dataCollection = {};
1298 var deferredArray = [];
1299 if (options.before) {
1300 options.before();
1301 }
1302 options.ids.forEach(function (objectId) {
1303 deferredArray.push(_this2.load({
1304 action: options.action,
1305 unique_id: options.data.unique_id + objectId,
1306 data: jQuery.extend({
1307 id: objectId
1308 }, options.data)
1309 }).done(function (data) {
1310 return dataCollection = jQuery.extend(dataCollection, data);
1311 }));
1312 });
1313 jQuery.when.apply(jQuery, deferredArray).done(function () {
1314 return options.success(dataCollection);
1315 });
1316 }
1317 }, {
1318 key: "load",
1319 value: function load(request, immediately) {
1320 var _this3 = this;
1321 if (!request.unique_id) {
1322 request.unique_id = request.action;
1323 }
1324 if (request.before) {
1325 request.before();
1326 }
1327 var deferred;
1328 var cacheKey = this.getCacheKey(request);
1329 if (_.has(this.cache, cacheKey)) {
1330 deferred = jQuery.Deferred().done(request.success).resolve(this.cache[cacheKey]);
1331 } else {
1332 deferred = this.addRequest(request.action, {
1333 data: request.data,
1334 unique_id: request.unique_id,
1335 success: function success(data) {
1336 return _this3.cache[cacheKey] = data;
1337 }
1338 }, immediately).done(request.success);
1339 }
1340 return deferred;
1341 }
1342 }, {
1343 key: "cancelRequest",
1344 value: function cancelRequest(requestId) {
1345 var request = this.requests[requestId];
1346 if (!request) {
1347 return null;
1348 }
1349 if (request.options.deferred.jqXhr) {
1350 return request.options.deferred.jqXhr.abort('Request canceled');
1351 }
1352 if (request.options.deferred) {
1353 return request.options.deferred.reject('Request canceled');
1354 }
1355 }
1356 }, {
1357 key: "addRequest",
1358 value: function addRequest(action, options, immediately) {
1359 options = options || {};
1360 if (!options.unique_id) {
1361 options.unique_id = action;
1362 }
1363 options.deferred = jQuery.Deferred().done(options.success).fail(options.error).always(options.complete);
1364 var request = {
1365 action: action,
1366 options: options
1367 };
1368 if (immediately) {
1369 var requests = {};
1370 requests[options.unique_id] = request;
1371 options.deferred.jqXhr = this.sendBatch(requests);
1372 } else {
1373 this.requests[options.unique_id] = request;
1374 this.debounceSendBatch();
1375 }
1376 return options.deferred;
1377 }
1378 }, {
1379 key: "sendBatch",
1380 value: function sendBatch(requests) {
1381 var actions = {};
1382 if (!requests) {
1383 requests = this.requests;
1384
1385 // Empty for next batch.
1386 this.requests = {};
1387 }
1388 Object.entries(requests).forEach(function (_ref) {
1389 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
1390 id = _ref2[0],
1391 request = _ref2[1];
1392 return actions[id] = {
1393 action: request.action,
1394 data: request.options.data
1395 };
1396 });
1397 return this.send('ajax', {
1398 data: {
1399 actions: JSON.stringify(actions)
1400 },
1401 success: function success(data) {
1402 Object.entries(data.responses).forEach(function (_ref3) {
1403 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
1404 id = _ref4[0],
1405 response = _ref4[1];
1406 var options = requests[id].options;
1407 if (options) {
1408 if (response.success) {
1409 options.deferred.resolve(response.data);
1410 } else if (!response.success) {
1411 options.deferred.reject(response.data);
1412 }
1413 }
1414 });
1415 },
1416 error: function error(data) {
1417 return Object.values(requests).forEach(function (args) {
1418 if (args.options) {
1419 args.options.deferred.reject(data);
1420 }
1421 });
1422 }
1423 });
1424 }
1425 }, {
1426 key: "prepareSend",
1427 value: function prepareSend(action, options) {
1428 var _this4 = this;
1429 var settings = this.getSettings(),
1430 ajaxParams = elementorCommon.helpers.cloneObject(settings.ajaxParams);
1431 options = options || {};
1432 action = settings.actionPrefix + action;
1433 jQuery.extend(ajaxParams, options);
1434 var requestConstants = elementorCommon.helpers.cloneObject(this.requestConstants);
1435 requestConstants.action = action;
1436 var isFormData = ajaxParams.data instanceof FormData;
1437 Object.entries(requestConstants).forEach(function (_ref5) {
1438 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
1439 key = _ref6[0],
1440 value = _ref6[1];
1441 if (isFormData) {
1442 ajaxParams.data.append(key, value);
1443 } else {
1444 ajaxParams.data[key] = value;
1445 }
1446 });
1447 var successCallback = ajaxParams.success,
1448 errorCallback = ajaxParams.error;
1449 if (successCallback || errorCallback) {
1450 ajaxParams.success = function (response) {
1451 if (response.success && successCallback) {
1452 successCallback(response.data);
1453 }
1454 if (!response.success && errorCallback) {
1455 errorCallback(response.data);
1456 }
1457 };
1458 if (errorCallback) {
1459 ajaxParams.error = function (data) {
1460 return errorCallback(data);
1461 };
1462 } else {
1463 ajaxParams.error = function (xmlHttpRequest) {
1464 if (xmlHttpRequest.readyState || 'abort' !== xmlHttpRequest.statusText) {
1465 _this4.trigger('request:unhandledError', xmlHttpRequest);
1466 }
1467 };
1468 }
1469 }
1470 return ajaxParams;
1471 }
1472 }, {
1473 key: "send",
1474 value: function send(action, options) {
1475 return jQuery.ajax(this.prepareSend(action, options));
1476 }
1477 }, {
1478 key: "addRequestCache",
1479 value: function addRequestCache(request, data) {
1480 var cacheKey = this.getCacheKey(request);
1481 this.cache[cacheKey] = data;
1482 }
1483 }, {
1484 key: "invalidateCache",
1485 value: function invalidateCache(request) {
1486 var cacheKey = this.getCacheKey(request);
1487 delete this.cache[cacheKey];
1488 }
1489 }]);
1490 }(elementorModules.Module);
1491
1492 /***/ }),
1493
1494 /***/ "../core/common/modules/connect/assets/js/connect.js":
1495 /*!***********************************************************!*\
1496 !*** ../core/common/modules/connect/assets/js/connect.js ***!
1497 \***********************************************************/
1498 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1499
1500 "use strict";
1501 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
1502
1503
1504 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1505 Object.defineProperty(exports, "__esModule", ({
1506 value: true
1507 }));
1508 exports["default"] = void 0;
1509 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1510 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1511 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1512 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1513 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
1514 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1515 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1516 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1517 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
1518 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Vie) {
1519 function _default() {
1520 (0, _classCallCheck2.default)(this, _default);
1521 return _callSuper(this, _default, arguments);
1522 }
1523 (0, _inherits2.default)(_default, _elementorModules$Vie);
1524 return (0, _createClass2.default)(_default, [{
1525 key: "addPopupPlugin",
1526 value: function addPopupPlugin() {
1527 var counter = 0;
1528 jQuery.fn.elementorConnect = function (options) {
1529 var _this = this;
1530 // Open the Connect Dialog in a popup window.
1531 if (options !== null && options !== void 0 && options.popup) {
1532 jQuery(this).on('click', function (event) {
1533 var _options$popup, _options$popup2;
1534 event.preventDefault();
1535 var width = ((_options$popup = options.popup) === null || _options$popup === void 0 ? void 0 : _options$popup.width) || 600,
1536 height = ((_options$popup2 = options.popup) === null || _options$popup2 === void 0 ? void 0 : _options$popup2.height) || 700;
1537 window.open(jQuery(_this).attr('href') + '&mode=popup', 'elementorConnect', "toolbar=no, menubar=no, width=".concat(width, ", height=").concat(height, ", top=200, left=0"));
1538 });
1539 delete options.popup;
1540 }
1541 var settings = jQuery.extend({
1542 // These are the defaults.
1543 success: function success() {
1544 return location.reload();
1545 },
1546 error: function error() {
1547 elementor.notifications.showToast({
1548 message: __('Unable to connect', 'elementor')
1549 });
1550 },
1551 parseUrl: function parseUrl(url) {
1552 return url;
1553 } // Allow to change the url, e.g: replace placeholders like '%%template_type%%' with actual value.
1554 }, options);
1555 this.each(function () {
1556 counter++;
1557 var $this = jQuery(this),
1558 callbackId = 'cb' + counter;
1559 $this.attr({
1560 target: '_blank',
1561 rel: 'opener',
1562 href: settings.parseUrl($this.attr('href') + '&mode=popup&callback_id=' + callbackId)
1563 });
1564 elementorCommon.elements.$window.on('elementor/connect/success/' + callbackId, settings.success).on('elementor/connect/error/' + callbackId, settings.error);
1565 });
1566 return this;
1567 };
1568 }
1569 }, {
1570 key: "getDefaultSettings",
1571 value: function getDefaultSettings() {
1572 return {
1573 selectors: {
1574 connectButton: '#elementor-template-library-connect__button'
1575 }
1576 };
1577 }
1578 }, {
1579 key: "getDefaultElements",
1580 value: function getDefaultElements() {
1581 return {
1582 $connectButton: jQuery(this.getSettings('selectors.connectButton'))
1583 };
1584 }
1585 }, {
1586 key: "applyPopup",
1587 value: function applyPopup() {
1588 this.elements.$connectButton.elementorConnect();
1589 }
1590 }, {
1591 key: "onInit",
1592 value: function onInit() {
1593 _superPropGet(_default, "onInit", this, 3)([]);
1594 this.addPopupPlugin();
1595 this.applyPopup();
1596 }
1597 }]);
1598 }(elementorModules.ViewModule);
1599
1600 /***/ }),
1601
1602 /***/ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js":
1603 /*!**********************************************************************************!*\
1604 !*** ../core/common/modules/event-tracker/assets/js/data/commands-data/index.js ***!
1605 \**********************************************************************************/
1606 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1607
1608 "use strict";
1609
1610
1611 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1612 Object.defineProperty(exports, "__esModule", ({
1613 value: true
1614 }));
1615 exports.Index = void 0;
1616 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1617 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1618 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1619 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1620 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1621 var _commandData = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-data */ "../modules/web-cli/assets/js/modules/command-data.js"));
1622 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1623 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1624 var Index = exports.Index = /*#__PURE__*/function (_CommandData) {
1625 function Index() {
1626 (0, _classCallCheck2.default)(this, Index);
1627 return _callSuper(this, Index, arguments);
1628 }
1629 (0, _inherits2.default)(Index, _CommandData);
1630 return (0, _createClass2.default)(Index, null, [{
1631 key: "getEndpointFormat",
1632 value: function getEndpointFormat() {
1633 return 'send-event';
1634 }
1635 }]);
1636 }(_commandData.default);
1637
1638 /***/ }),
1639
1640 /***/ "../core/common/modules/event-tracker/assets/js/data/component.js":
1641 /*!************************************************************************!*\
1642 !*** ../core/common/modules/event-tracker/assets/js/data/component.js ***!
1643 \************************************************************************/
1644 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1645
1646 "use strict";
1647
1648
1649 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1650 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
1651 Object.defineProperty(exports, "__esModule", ({
1652 value: true
1653 }));
1654 exports["default"] = void 0;
1655 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1656 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1657 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1658 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1659 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1660 var _componentBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
1661 var commandsData = _interopRequireWildcard(__webpack_require__(/*! ./commands-data/ */ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js"));
1662 function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
1663 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1664 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1665 var Component = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
1666 function Component() {
1667 (0, _classCallCheck2.default)(this, Component);
1668 return _callSuper(this, Component, arguments);
1669 }
1670 (0, _inherits2.default)(Component, _ComponentBase);
1671 return (0, _createClass2.default)(Component, [{
1672 key: "getNamespace",
1673 value: function getNamespace() {
1674 return 'event-tracker';
1675 }
1676 }, {
1677 key: "defaultData",
1678 value: function defaultData() {
1679 return this.importCommands(commandsData);
1680 }
1681 }]);
1682 }(_componentBase.default);
1683
1684 /***/ }),
1685
1686 /***/ "../core/common/modules/event-tracker/assets/js/events.js":
1687 /*!****************************************************************!*\
1688 !*** ../core/common/modules/event-tracker/assets/js/events.js ***!
1689 \****************************************************************/
1690 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1691
1692 "use strict";
1693
1694
1695 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1696 Object.defineProperty(exports, "__esModule", ({
1697 value: true
1698 }));
1699 exports["default"] = void 0;
1700 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1701 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1702 var _time = _interopRequireDefault(__webpack_require__(/*! elementor-utils/time */ "../assets/dev/js/utils/time.js"));
1703 var Events = exports["default"] = /*#__PURE__*/function () {
1704 function Events() {
1705 (0, _classCallCheck2.default)(this, Events);
1706 }
1707 return (0, _createClass2.default)(Events, [{
1708 key: "dispatchEvent",
1709 value: function dispatchEvent(eventData) {
1710 if (!eventData) {
1711 return;
1712 }
1713 eventData.ts = (0, _time.default)();
1714
1715 // No need to wait for response, no need to block browser in any way.
1716 $e.data.create('event-tracker/index', {
1717 event_data: eventData
1718 });
1719 }
1720 }]);
1721 }();
1722
1723 /***/ }),
1724
1725 /***/ "../core/common/modules/events-manager/assets/js/events-config.js":
1726 /*!************************************************************************!*\
1727 !*** ../core/common/modules/events-manager/assets/js/events-config.js ***!
1728 \************************************************************************/
1729 /***/ ((__unused_webpack_module, exports) => {
1730
1731 "use strict";
1732
1733
1734 Object.defineProperty(exports, "__esModule", ({
1735 value: true
1736 }));
1737 exports["default"] = void 0;
1738 var eventsConfig = {
1739 triggers: {
1740 click: 'Click',
1741 rightClick: 'Right Click',
1742 doubleClick: 'Double Click',
1743 accordionClick: 'Accordion Click',
1744 toggleClick: 'Toggle Click',
1745 dropdownClick: 'Click Dropdown',
1746 editorLoaded: 'Editor Loaded',
1747 visible: 'Visible',
1748 pageLoaded: 'Page Loaded'
1749 },
1750 locations: {
1751 widgetPanel: 'Widget Panel',
1752 topBar: 'Top Bar',
1753 elementorEditor: 'Elementor Editor',
1754 templatesLibrary: {
1755 library: 'Templates Library'
1756 },
1757 app: {
1758 import: 'Import Kit',
1759 export: 'Export Kit',
1760 kitLibrary: 'Kit Library',
1761 cloudKitLibrary: 'Cloud Kit Library'
1762 },
1763 variables: 'Variables Panel',
1764 variablesManager: 'Variables Manager',
1765 admin: 'WP admin',
1766 structurePanel: 'Structure Panel',
1767 canvas: 'Canvas'
1768 },
1769 secondaryLocations: {
1770 layout: 'Layout Section',
1771 basic: 'Basic Section',
1772 'pro-elements': 'Pro Section',
1773 general: 'General Section',
1774 'theme-elements': 'Site Section',
1775 'theme-elements-single': 'Single Section',
1776 'woocommerce-elements': 'WooCommerce Section',
1777 wordpress: 'WordPress Section',
1778 categories: 'Widgets Tab',
1779 global: 'Globals Tab',
1780 'whats-new': 'What\'s New',
1781 'document-settings': 'Document Settings icon',
1782 'preview-page': 'Preview Page',
1783 'publish-button': 'Publish Button',
1784 'widget-panel': 'Widget Panel Icon',
1785 finder: 'Finder',
1786 help: 'Help',
1787 elementorLogoDropdown: 'top_bar_elementor_logo_dropdown',
1788 elementorLogo: 'Elementor Logo',
1789 eLogoMenu: 'E-logo Menu',
1790 notes: 'Notes',
1791 siteSettings: 'Site Settings',
1792 structure: 'Structure',
1793 documentNameDropdown: 'Document Name dropdown',
1794 responsiveControls: 'Responsive controls',
1795 launchpad: 'launchpad',
1796 checklistHeader: 'Checklist Header',
1797 checklistSteps: 'Checklist Steps',
1798 userPreferences: 'User Preferences',
1799 contextMenu: 'Context Menu',
1800 templateLibrary: {
1801 saveModal: 'Save to Modal',
1802 moveModal: 'Move to Modal',
1803 bulkMoveModal: 'Bulk Move to Modal',
1804 copyModal: 'Copy to Modal',
1805 bulkCopyModal: 'Bulk Copy to Modal',
1806 saveModalSelectFolder: 'Save to Modal - select folder',
1807 saveModalSelectConnect: 'Save to Modal - connect',
1808 saveModalSelectUpgrade: 'Save to Modal - upgrade',
1809 importModal: 'Import Modal',
1810 newFolderModal: 'New Folder Modal',
1811 deleteDialog: 'Delete Dialog',
1812 deleteFolderDialog: 'Delete Folder Dialog',
1813 renameDialog: 'Rename Dialog',
1814 createFolderDialog: 'Create Folder Dialog',
1815 applySettingsDialog: 'Apply Settings Dialog',
1816 cloudTab: 'Cloud Tab',
1817 siteTab: 'Site Tab',
1818 cloudTabFolder: 'Cloud Tab - Folder',
1819 cloudTabConnect: 'Cloud Tab - Connect',
1820 cloudTabUpgrade: 'Cloud Tab - Upgrade',
1821 morePopup: 'Context Menu',
1822 quotaBar: 'Quota Bar'
1823 },
1824 kitLibrary: {
1825 cloudKitLibrary: 'kits_cloud_library',
1826 cloudKitLibraryConnect: 'kits_cloud_library_connect',
1827 cloudKitLibraryUpgrade: 'kits_cloud_library_upgrade',
1828 kitExportCustomization: 'kit_export_customization',
1829 kitExport: 'kit_export',
1830 kitExportCustomizationEdit: 'kit_export_customization_edit',
1831 kitExportSummary: 'kit_export_summary',
1832 kitImportUploadBox: 'kit_import_upload_box',
1833 kitImportCustomization: 'kit_import_customization',
1834 kitImportSummary: 'kit_import_summary'
1835 },
1836 variablesPopover: 'Variables Popover',
1837 admin: {
1838 pluginToolsTab: 'plugin_tools_tab',
1839 pluginWebsiteTemplatesTab: 'plugin_website_templates_tab'
1840 },
1841 componentsTab: 'Components Tab',
1842 canvasElement: 'Canvas Element'
1843 },
1844 elements: {
1845 accordionSection: 'Accordion section',
1846 buttonIcon: 'Button Icon',
1847 mainCta: 'Main CTA',
1848 button: 'Button',
1849 link: 'Link',
1850 dropdown: 'Dropdown',
1851 toggle: 'Toggle',
1852 launchpadChecklist: 'Checklist popup'
1853 },
1854 names: {
1855 v1: {
1856 layout: 'v1_widgets_tab_layout_section',
1857 basic: 'v1_widgets_tab_basic_section',
1858 'pro-elements': 'v1_widgets_tab_pro_section',
1859 general: 'v1_widgets_tab_general_section',
1860 'theme-elements': 'v1_widgets_tab_site_section',
1861 'theme-elements-single': 'v1_widgets_tab_single_section',
1862 'woocommerce-elements': 'v1_widgets_tab_woocommerce_section',
1863 wordpress: 'v1_widgets_tab_wordpress_section',
1864 categories: 'v1_widgets_tab',
1865 global: 'v1_globals_tab'
1866 },
1867 topBar: {
1868 whatsNew: 'top_bar_whats_new',
1869 documentSettings: 'top_bar_document_settings_icon',
1870 previewPage: 'top_bar_preview_page',
1871 publishButton: 'top_bar_publish_button',
1872 widgetPanel: 'top_bar_widget_panel_icon',
1873 finder: 'top_bar_finder',
1874 help: 'top_bar_help',
1875 history: 'top_bar_elementor_logo_dropdown_history',
1876 userPreferences: 'top_bar_elementor_logo_dropdown_user_preferences',
1877 keyboardShortcuts: 'top_bar_elementor_logo_dropdown_keyboard_shortcuts',
1878 exitToWordpress: 'top_bar_elementor_logo_dropdown_exit_to_wordpress',
1879 themeBuilder: 'top_bar_elementor_logo_dropdown_theme_builder',
1880 notes: 'top_bar_notes',
1881 siteSettings: 'top_bar_site_setting',
1882 structure: 'top_bar_structure',
1883 documentNameDropdown: 'top_bar_document_name_dropdown',
1884 responsiveControls: 'top_bar_responsive_controls',
1885 launchpadOn: 'top_bar_checklist_icon_show',
1886 launchpadOff: 'top_bar_checklist_icon_hide',
1887 elementorLogoDropdown: 'open_e_menu',
1888 connectAccount: 'connect_account',
1889 accountConnected: 'account_connected'
1890 },
1891 // ChecklistSteps event names are generated dynamically, based on stepId and action type taken: title, action, done, undone, upgrade
1892 elementorEditor: {
1893 checklist: {
1894 checklistHeaderClose: 'checklist_header_close_icon',
1895 checklistFirstPopup: 'checklist popup triggered'
1896 },
1897 userPreferences: {
1898 checklistShow: 'checklist_userpreferences_toggle_show',
1899 checklistHide: 'checklist_userpreferences_toggle_hide'
1900 }
1901 },
1902 variables: {
1903 open: 'open_variables_popover',
1904 add: 'add_new_variable',
1905 connect: 'connect_variable',
1906 save: 'save_new_variable',
1907 openManager: 'open_variables_manager',
1908 saveChanges: 'save_variables_changes',
1909 delete: 'delete_variable'
1910 },
1911 components: {
1912 createClicked: 'component_create_clicked',
1913 createCancelled: 'component_creation_cancelled',
1914 created: 'component_created',
1915 instanceAdded: 'component_instance_added',
1916 edited: 'component_edited'
1917 },
1918 global_classes: {
1919 classApplied: 'class_applied',
1920 classRemoved: 'class_removed',
1921 classManagerFilterCleared: 'class_manager_filter_cleared',
1922 classDeleted: 'class_deleted',
1923 classPublishConflict: 'class_publish_conflict',
1924 classRenamed: 'class_renamed',
1925 classCreated: 'class_created',
1926 classManagerSearched: 'class_manager_searched',
1927 classManagerFiltersOpened: 'class_manager_filters_opened',
1928 classManagerOpened: 'class_manager_opened',
1929 classManagerReorder: 'class_manager_reorder',
1930 classManagerFilterUsed: 'class_manager_filter_used',
1931 classUsageLocate: 'class_usage_locate',
1932 classUsageHovered: 'class_usage_hovered',
1933 classStyled: 'class_styled',
1934 classStateClicked: 'class_state_clicked',
1935 classUsageClicked: 'class_usage_clicked',
1936 classDuplicate: 'class_duplicate'
1937 }
1938 }
1939 };
1940 var _default = exports["default"] = eventsConfig;
1941
1942 /***/ }),
1943
1944 /***/ "../core/common/modules/events-manager/assets/js/module.js":
1945 /*!*****************************************************************!*\
1946 !*** ../core/common/modules/events-manager/assets/js/module.js ***!
1947 \*****************************************************************/
1948 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1949
1950 "use strict";
1951
1952
1953 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1954 Object.defineProperty(exports, "__esModule", ({
1955 value: true
1956 }));
1957 exports["default"] = void 0;
1958 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
1959 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
1960 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1961 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1962 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1963 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1964 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1965 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
1966 var _eventsConfig = _interopRequireDefault(__webpack_require__(/*! ./events-config */ "../core/common/modules/events-manager/assets/js/events-config.js"));
1967 var _mixpanelBrowser = _interopRequireDefault(__webpack_require__(/*! mixpanel-browser */ "../node_modules/mixpanel-browser/dist/mixpanel.module.js"));
1968 var _tiers = __webpack_require__(/*! elementor-utils/tiers */ "../assets/dev/js/utils/tiers.js");
1969 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1970 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1971 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1972 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1973 function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
1974 function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
1975 function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
1976 function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
1977 function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
1978 var _sessionRecordingInProgress = /*#__PURE__*/new WeakMap();
1979 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1980 function _default() {
1981 var _this;
1982 (0, _classCallCheck2.default)(this, _default);
1983 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1984 args[_key] = arguments[_key];
1985 }
1986 _this = _callSuper(this, _default, [].concat(args));
1987 (0, _defineProperty2.default)(_this, "trackingEnabled", false);
1988 _classPrivateFieldInitSpec(_this, _sessionRecordingInProgress, false);
1989 return _this;
1990 }
1991 (0, _inherits2.default)(_default, _elementorModules$Mod);
1992 return (0, _createClass2.default)(_default, [{
1993 key: "onInit",
1994 value: function onInit() {
1995 var _elementorCommon$conf;
1996 this.config = _eventsConfig.default;
1997 if (!this.canSendEvents()) {
1998 return;
1999 }
2000 _mixpanelBrowser.default.init((_elementorCommon$conf = elementorCommon.config.editor_events) === null || _elementorCommon$conf === void 0 ? void 0 : _elementorCommon$conf.token, {
2001 persistence: 'localStorage',
2002 autocapture: false,
2003 record_sessions_percent: 0,
2004 record_idle_timeout_ms: 60000,
2005 record_max_ms: 300000,
2006 record_mask_text_selector: '',
2007 flags: true,
2008 api_hosts: {
2009 flags: 'https://api-eu.mixpanel.com'
2010 }
2011 });
2012 this.enableTracking();
2013 }
2014 }, {
2015 key: "enableTracking",
2016 value: function enableTracking() {
2017 var _elementorCommon$conf2;
2018 var userId = (_elementorCommon$conf2 = elementorCommon.config.library_connect) === null || _elementorCommon$conf2 === void 0 ? void 0 : _elementorCommon$conf2.user_id;
2019 if (userId) {
2020 var _elementorCommon$conf3;
2021 _mixpanelBrowser.default.identify(userId);
2022 _mixpanelBrowser.default.register({
2023 appType: 'Editor'
2024 });
2025 _mixpanelBrowser.default.people.set_once({
2026 $user_id: userId,
2027 $last_login: new Date().toISOString(),
2028 $plan_type: ((_elementorCommon$conf3 = elementorCommon.config.library_connect) === null || _elementorCommon$conf3 === void 0 ? void 0 : _elementorCommon$conf3.plan_type) || _tiers.TIERS.free
2029 });
2030 }
2031 this.trackingEnabled = true;
2032 }
2033 }, {
2034 key: "dispatchEvent",
2035 value: function dispatchEvent(name, data) {
2036 var _elementorCommon$conf4, _elementorCommon$conf5, _elementorCommon$conf6, _elementorCommon$conf7, _elementorCommon$conf8, _elementorCommon$conf9, _elementorCommon$conf0, _elementorCommon$conf1, _elementorCommon$conf10;
2037 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2038 if (!this.canSendEvents()) {
2039 return;
2040 }
2041 if (!this.trackingEnabled) {
2042 this.enableTracking();
2043 }
2044 var eventData = _objectSpread({
2045 user_id: ((_elementorCommon$conf4 = elementorCommon.config.library_connect) === null || _elementorCommon$conf4 === void 0 ? void 0 : _elementorCommon$conf4.user_id) || null,
2046 user_roles: ((_elementorCommon$conf5 = elementorCommon.config.library_connect) === null || _elementorCommon$conf5 === void 0 ? void 0 : _elementorCommon$conf5.user_roles) || [],
2047 subscription_id: ((_elementorCommon$conf6 = elementorCommon.config.editor_events) === null || _elementorCommon$conf6 === void 0 ? void 0 : _elementorCommon$conf6.subscription_id) || null,
2048 user_tier: ((_elementorCommon$conf7 = elementorCommon.config.library_connect) === null || _elementorCommon$conf7 === void 0 ? void 0 : _elementorCommon$conf7.current_access_tier) || null,
2049 url: (_elementorCommon$conf8 = elementorCommon.config.editor_events) === null || _elementorCommon$conf8 === void 0 ? void 0 : _elementorCommon$conf8.site_url,
2050 wp_version: (_elementorCommon$conf9 = elementorCommon.config.editor_events) === null || _elementorCommon$conf9 === void 0 ? void 0 : _elementorCommon$conf9.wp_version,
2051 client_id: (_elementorCommon$conf0 = elementorCommon.config.editor_events) === null || _elementorCommon$conf0 === void 0 ? void 0 : _elementorCommon$conf0.site_key,
2052 app_version: (_elementorCommon$conf1 = elementorCommon.config.editor_events) === null || _elementorCommon$conf1 === void 0 ? void 0 : _elementorCommon$conf1.elementor_version,
2053 site_language: (_elementorCommon$conf10 = elementorCommon.config.editor_events) === null || _elementorCommon$conf10 === void 0 ? void 0 : _elementorCommon$conf10.site_language
2054 }, data);
2055 _mixpanelBrowser.default.track(name, eventData, options);
2056 }
2057 }, {
2058 key: "startSessionRecording",
2059 value: function startSessionRecording() {
2060 if (!this.canSendEvents() || this.isSessionRecordingInProgress()) {
2061 return;
2062 }
2063 if (!this.trackingEnabled) {
2064 this.enableTracking();
2065 }
2066 _mixpanelBrowser.default.start_session_recording();
2067 this.setSessionRecordingInProgress(true);
2068 }
2069 }, {
2070 key: "stopSessionRecording",
2071 value: function stopSessionRecording() {
2072 if (!this.canSendEvents() || !this.isSessionRecordingInProgress()) {
2073 return;
2074 }
2075 _mixpanelBrowser.default.stop_session_recording();
2076 this.setSessionRecordingInProgress(false);
2077 }
2078 }, {
2079 key: "setSessionRecordingInProgress",
2080 value: function setSessionRecordingInProgress(value) {
2081 if ('boolean' !== typeof value) {
2082 return;
2083 }
2084 _classPrivateFieldSet(_sessionRecordingInProgress, this, value);
2085 }
2086 }, {
2087 key: "isSessionRecordingInProgress",
2088 value: function isSessionRecordingInProgress() {
2089 return _classPrivateFieldGet(_sessionRecordingInProgress, this);
2090 }
2091 }, {
2092 key: "featureFlagIsActive",
2093 value: function () {
2094 var _featureFlagIsActive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(flagName) {
2095 var _mixpanel$flags;
2096 var isEnabled;
2097 return _regenerator.default.wrap(function (_context) {
2098 while (1) switch (_context.prev = _context.next) {
2099 case 0:
2100 if (!('function' !== typeof (_mixpanelBrowser.default === null || _mixpanelBrowser.default === void 0 || (_mixpanel$flags = _mixpanelBrowser.default.flags) === null || _mixpanel$flags === void 0 ? void 0 : _mixpanel$flags.is_enabled))) {
2101 _context.next = 1;
2102 break;
2103 }
2104 return _context.abrupt("return", false);
2105 case 1:
2106 _context.next = 2;
2107 return _mixpanelBrowser.default.flags.is_enabled(flagName, false);
2108 case 2:
2109 isEnabled = _context.sent;
2110 return _context.abrupt("return", true === isEnabled);
2111 case 3:
2112 case "end":
2113 return _context.stop();
2114 }
2115 }, _callee);
2116 }));
2117 function featureFlagIsActive(_x) {
2118 return _featureFlagIsActive.apply(this, arguments);
2119 }
2120 return featureFlagIsActive;
2121 }()
2122 }, {
2123 key: "getExperimentVariant",
2124 value: function () {
2125 var _getExperimentVariant = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(experimentName) {
2126 var defaultValue,
2127 _elementorCommon$conf11,
2128 _elementorCommon$conf12,
2129 isAbTestingEnabled,
2130 variant,
2131 _args2 = arguments,
2132 _t;
2133 return _regenerator.default.wrap(function (_context2) {
2134 while (1) switch (_context2.prev = _context2.next) {
2135 case 0:
2136 defaultValue = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 'control';
2137 _context2.prev = 1;
2138 if (this.canSendEvents()) {
2139 _context2.next = 2;
2140 break;
2141 }
2142 return _context2.abrupt("return", defaultValue);
2143 case 2:
2144 isAbTestingEnabled = (_elementorCommon$conf11 = (_elementorCommon$conf12 = elementorCommon.config.editor_events) === null || _elementorCommon$conf12 === void 0 ? void 0 : _elementorCommon$conf12.flags_enabled) !== null && _elementorCommon$conf11 !== void 0 ? _elementorCommon$conf11 : false;
2145 if (isAbTestingEnabled) {
2146 _context2.next = 3;
2147 break;
2148 }
2149 return _context2.abrupt("return", defaultValue);
2150 case 3:
2151 if (_mixpanelBrowser.default) {
2152 _context2.next = 4;
2153 break;
2154 }
2155 return _context2.abrupt("return", defaultValue);
2156 case 4:
2157 if (!this.trackingEnabled) {
2158 this.enableTracking();
2159 }
2160 if (_mixpanelBrowser.default.flags) {
2161 _context2.next = 5;
2162 break;
2163 }
2164 return _context2.abrupt("return", defaultValue);
2165 case 5:
2166 if (!('function' !== typeof _mixpanelBrowser.default.flags.get_variant_value)) {
2167 _context2.next = 6;
2168 break;
2169 }
2170 return _context2.abrupt("return", defaultValue);
2171 case 6:
2172 _context2.next = 7;
2173 return _mixpanelBrowser.default.flags.get_variant_value(experimentName, defaultValue);
2174 case 7:
2175 variant = _context2.sent;
2176 if (!(undefined === variant || null === variant)) {
2177 _context2.next = 8;
2178 break;
2179 }
2180 return _context2.abrupt("return", defaultValue);
2181 case 8:
2182 return _context2.abrupt("return", variant);
2183 case 9:
2184 _context2.prev = 9;
2185 _t = _context2["catch"](1);
2186 return _context2.abrupt("return", defaultValue);
2187 case 10:
2188 case "end":
2189 return _context2.stop();
2190 }
2191 }, _callee2, this, [[1, 9]]);
2192 }));
2193 function getExperimentVariant(_x2) {
2194 return _getExperimentVariant.apply(this, arguments);
2195 }
2196 return getExperimentVariant;
2197 }()
2198 }, {
2199 key: "startExperiment",
2200 value: function startExperiment(experimentName, experimentVariant) {
2201 if (!this.trackingEnabled) {
2202 return;
2203 }
2204 _mixpanelBrowser.default.track('$experiment_started', {
2205 'Experiment name': experimentName,
2206 'Variant name': experimentVariant
2207 });
2208 }
2209 }, {
2210 key: "canSendEvents",
2211 value: function canSendEvents() {
2212 var _elementorCommon;
2213 return !!((_elementorCommon = elementorCommon) !== null && _elementorCommon !== void 0 && (_elementorCommon = _elementorCommon.config) !== null && _elementorCommon !== void 0 && (_elementorCommon = _elementorCommon.editor_events) !== null && _elementorCommon !== void 0 && _elementorCommon.can_send_events);
2214 }
2215 }]);
2216 }(elementorModules.Module);
2217
2218 /***/ }),
2219
2220 /***/ "../core/common/modules/finder/assets/js/commands/index.js":
2221 /*!*****************************************************************!*\
2222 !*** ../core/common/modules/finder/assets/js/commands/index.js ***!
2223 \*****************************************************************/
2224 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2225
2226 "use strict";
2227
2228
2229 Object.defineProperty(exports, "__esModule", ({
2230 value: true
2231 }));
2232 Object.defineProperty(exports, "NavigateDown", ({
2233 enumerable: true,
2234 get: function get() {
2235 return _navigateDown.NavigateDown;
2236 }
2237 }));
2238 Object.defineProperty(exports, "NavigateSelect", ({
2239 enumerable: true,
2240 get: function get() {
2241 return _navigateSelect.NavigateSelect;
2242 }
2243 }));
2244 Object.defineProperty(exports, "NavigateUp", ({
2245 enumerable: true,
2246 get: function get() {
2247 return _navigateUp.NavigateUp;
2248 }
2249 }));
2250 var _navigateDown = __webpack_require__(/*! ./navigate-down */ "../core/common/modules/finder/assets/js/commands/navigate-down.js");
2251 var _navigateSelect = __webpack_require__(/*! ./navigate-select */ "../core/common/modules/finder/assets/js/commands/navigate-select.js");
2252 var _navigateUp = __webpack_require__(/*! ./navigate-up */ "../core/common/modules/finder/assets/js/commands/navigate-up.js");
2253
2254 /***/ }),
2255
2256 /***/ "../core/common/modules/finder/assets/js/commands/navigate-down.js":
2257 /*!*************************************************************************!*\
2258 !*** ../core/common/modules/finder/assets/js/commands/navigate-down.js ***!
2259 \*************************************************************************/
2260 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2261
2262 "use strict";
2263
2264
2265 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2266 Object.defineProperty(exports, "__esModule", ({
2267 value: true
2268 }));
2269 exports["default"] = exports.NavigateDown = void 0;
2270 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2271 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2272 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2273 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2274 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2275 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2276 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2277 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2278 var NavigateDown = exports.NavigateDown = /*#__PURE__*/function (_CommandBase) {
2279 function NavigateDown() {
2280 (0, _classCallCheck2.default)(this, NavigateDown);
2281 return _callSuper(this, NavigateDown, arguments);
2282 }
2283 (0, _inherits2.default)(NavigateDown, _CommandBase);
2284 return (0, _createClass2.default)(NavigateDown, [{
2285 key: "apply",
2286 value: function apply() {
2287 this.component.getItemsView().activateNextItem();
2288 }
2289 }]);
2290 }(_commandBase.default);
2291 var _default = exports["default"] = NavigateDown;
2292
2293 /***/ }),
2294
2295 /***/ "../core/common/modules/finder/assets/js/commands/navigate-select.js":
2296 /*!***************************************************************************!*\
2297 !*** ../core/common/modules/finder/assets/js/commands/navigate-select.js ***!
2298 \***************************************************************************/
2299 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2300
2301 "use strict";
2302
2303
2304 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2305 Object.defineProperty(exports, "__esModule", ({
2306 value: true
2307 }));
2308 exports["default"] = exports.NavigateSelect = void 0;
2309 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2310 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2311 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2312 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2313 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2314 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2315 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2316 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2317 var NavigateSelect = exports.NavigateSelect = /*#__PURE__*/function (_CommandBase) {
2318 function NavigateSelect() {
2319 (0, _classCallCheck2.default)(this, NavigateSelect);
2320 return _callSuper(this, NavigateSelect, arguments);
2321 }
2322 (0, _inherits2.default)(NavigateSelect, _CommandBase);
2323 return (0, _createClass2.default)(NavigateSelect, [{
2324 key: "apply",
2325 value: function apply(args) {
2326 this.component.getItemsView().goToActiveItem(args);
2327 }
2328 }]);
2329 }(_commandBase.default);
2330 var _default = exports["default"] = NavigateSelect;
2331
2332 /***/ }),
2333
2334 /***/ "../core/common/modules/finder/assets/js/commands/navigate-up.js":
2335 /*!***********************************************************************!*\
2336 !*** ../core/common/modules/finder/assets/js/commands/navigate-up.js ***!
2337 \***********************************************************************/
2338 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2339
2340 "use strict";
2341
2342
2343 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2344 Object.defineProperty(exports, "__esModule", ({
2345 value: true
2346 }));
2347 exports["default"] = exports.NavigateUp = void 0;
2348 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2349 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2350 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2351 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2352 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2353 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2354 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2355 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2356 var NavigateUp = exports.NavigateUp = /*#__PURE__*/function (_CommandBase) {
2357 function NavigateUp() {
2358 (0, _classCallCheck2.default)(this, NavigateUp);
2359 return _callSuper(this, NavigateUp, arguments);
2360 }
2361 (0, _inherits2.default)(NavigateUp, _CommandBase);
2362 return (0, _createClass2.default)(NavigateUp, [{
2363 key: "apply",
2364 value: function apply() {
2365 this.component.getItemsView().activateNextItem(true);
2366 }
2367 }]);
2368 }(_commandBase.default);
2369 var _default = exports["default"] = NavigateUp;
2370
2371 /***/ }),
2372
2373 /***/ "../core/common/modules/finder/assets/js/component.js":
2374 /*!************************************************************!*\
2375 !*** ../core/common/modules/finder/assets/js/component.js ***!
2376 \************************************************************/
2377 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2378
2379 "use strict";
2380
2381
2382 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2383 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2384 Object.defineProperty(exports, "__esModule", ({
2385 value: true
2386 }));
2387 exports["default"] = void 0;
2388 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2389 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2390 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2391 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2392 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2393 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2394 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2395 var _componentModalBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-modal-base */ "../modules/web-cli/assets/js/modules/component-modal-base.js"));
2396 var _layout = _interopRequireDefault(__webpack_require__(/*! ./modal/views/layout */ "../core/common/modules/finder/assets/js/modal/views/layout.js"));
2397 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../core/common/modules/finder/assets/js/commands/index.js"));
2398 function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
2399 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2400 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2401 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2402 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2403 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
2404 var Component = exports["default"] = /*#__PURE__*/function (_ComponentModalBase) {
2405 function Component() {
2406 (0, _classCallCheck2.default)(this, Component);
2407 return _callSuper(this, Component, arguments);
2408 }
2409 (0, _inherits2.default)(Component, _ComponentModalBase);
2410 return (0, _createClass2.default)(Component, [{
2411 key: "getNamespace",
2412 value: function getNamespace() {
2413 return 'finder';
2414 }
2415 }, {
2416 key: "defaultShortcuts",
2417 value: function defaultShortcuts() {
2418 var _this = this;
2419 return {
2420 '': {
2421 keys: 'ctrl+e'
2422 },
2423 'navigate-down': {
2424 keys: 'down',
2425 scopes: [this.getNamespace()],
2426 dependency: function dependency() {
2427 return _this.getItemsView();
2428 }
2429 },
2430 'navigate-up': {
2431 keys: 'up',
2432 scopes: [this.getNamespace()],
2433 dependency: function dependency() {
2434 return _this.getItemsView();
2435 }
2436 },
2437 'navigate-select': {
2438 keys: 'enter',
2439 scopes: [this.getNamespace()],
2440 dependency: function dependency() {
2441 return _this.getItemsView().$activeItem;
2442 }
2443 }
2444 };
2445 }
2446 }, {
2447 key: "defaultCommands",
2448 value: function defaultCommands() {
2449 var modalCommands = _superPropGet(Component, "defaultCommands", this, 3)([]);
2450 return _objectSpread(_objectSpread({
2451 'navigate/down': function navigate_down() {
2452 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/down' )", '3.0.0', "$e.run( 'finder/navigate-down' )");
2453 $e.run('finder/navigate-down');
2454 },
2455 'navigate/up': function navigate_up() {
2456 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/up' )", '3.0.0', "$e.run( 'finder/navigate-up' )");
2457 $e.run('finder/navigate-up');
2458 },
2459 'navigate/select': function navigate_select(event) {
2460 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/select', event )", '3.0.0', "$e.run( 'finder/navigate-select', event )");
2461
2462 // TODO: Fix $e.shortcuts use args. ( args.event ).
2463 $e.run('finder/navigate-select', event);
2464 }
2465 }, modalCommands), this.importCommands(commands));
2466 }
2467 }, {
2468 key: "getModalLayout",
2469 value: function getModalLayout() {
2470 return _layout.default;
2471 }
2472 }, {
2473 key: "getItemsView",
2474 value: function getItemsView() {
2475 return this.layout.modalContent.currentView.content.currentView;
2476 }
2477 }]);
2478 }(_componentModalBase.default);
2479
2480 /***/ }),
2481
2482 /***/ "../core/common/modules/finder/assets/js/finder.js":
2483 /*!*********************************************************!*\
2484 !*** ../core/common/modules/finder/assets/js/finder.js ***!
2485 \*********************************************************/
2486 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2487
2488 "use strict";
2489
2490
2491 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2492 Object.defineProperty(exports, "__esModule", ({
2493 value: true
2494 }));
2495 exports["default"] = void 0;
2496 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2497 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2498 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2499 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2500 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2501 var _component = _interopRequireDefault(__webpack_require__(/*! ./component */ "../core/common/modules/finder/assets/js/component.js"));
2502 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2503 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2504 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2505 function _default() {
2506 (0, _classCallCheck2.default)(this, _default);
2507 return _callSuper(this, _default, arguments);
2508 }
2509 (0, _inherits2.default)(_default, _elementorModules$Mod);
2510 return (0, _createClass2.default)(_default, [{
2511 key: "onInit",
2512 value: function onInit() {
2513 // TODO: Temp fix, do not load finder in theme-builder.
2514 // Better to pass into '$e' constructor the app owner. ( admin, editor, preview, iframe ).
2515 if (window.top !== window) {
2516 return;
2517 }
2518 this.channel = Backbone.Radio.channel('ELEMENTOR:finder');
2519 $e.components.register(new _component.default({
2520 manager: this
2521 }));
2522 }
2523 }]);
2524 }(elementorModules.Module);
2525
2526 /***/ }),
2527
2528 /***/ "../core/common/modules/finder/assets/js/modal/model/item.js":
2529 /*!*******************************************************************!*\
2530 !*** ../core/common/modules/finder/assets/js/modal/model/item.js ***!
2531 \*******************************************************************/
2532 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2533
2534 "use strict";
2535
2536
2537 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2538 Object.defineProperty(exports, "__esModule", ({
2539 value: true
2540 }));
2541 exports["default"] = void 0;
2542 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2543 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2544 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2545 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2546 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2547 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2548 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2549 var _default = exports["default"] = /*#__PURE__*/function (_Backbone$Model) {
2550 function _default() {
2551 (0, _classCallCheck2.default)(this, _default);
2552 return _callSuper(this, _default, arguments);
2553 }
2554 (0, _inherits2.default)(_default, _Backbone$Model);
2555 return (0, _createClass2.default)(_default, [{
2556 key: "defaults",
2557 value: function defaults() {
2558 return {
2559 description: '',
2560 icon: 'settings',
2561 url: '',
2562 keywords: [],
2563 actions: [],
2564 lock: null
2565 };
2566 }
2567 }]);
2568 }(Backbone.Model);
2569
2570 /***/ }),
2571
2572 /***/ "../core/common/modules/finder/assets/js/modal/views/categories.js":
2573 /*!*************************************************************************!*\
2574 !*** ../core/common/modules/finder/assets/js/modal/views/categories.js ***!
2575 \*************************************************************************/
2576 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2577
2578 "use strict";
2579
2580
2581 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2582 Object.defineProperty(exports, "__esModule", ({
2583 value: true
2584 }));
2585 exports["default"] = void 0;
2586 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2587 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2588 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2589 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2590 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2591 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
2592 var _dynamicCategory = _interopRequireDefault(__webpack_require__(/*! ./dynamic-category */ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js"));
2593 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2594 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2595 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
2596 function _default() {
2597 (0, _classCallCheck2.default)(this, _default);
2598 return _callSuper(this, _default, arguments);
2599 }
2600 (0, _inherits2.default)(_default, _Marionette$Composite);
2601 return (0, _createClass2.default)(_default, [{
2602 key: "id",
2603 value: function id() {
2604 return 'elementor-finder__results-container';
2605 }
2606 }, {
2607 key: "ui",
2608 value: function ui() {
2609 this.selectors = {
2610 noResults: '#elementor-finder__no-results',
2611 categoryItem: '.elementor-finder__results__item'
2612 };
2613 return this.selectors;
2614 }
2615 }, {
2616 key: "events",
2617 value: function events() {
2618 return {
2619 'mouseenter @ui.categoryItem': 'onCategoryItemMouseEnter'
2620 };
2621 }
2622 }, {
2623 key: "getTemplate",
2624 value: function getTemplate() {
2625 return '#tmpl-elementor-finder-results-container';
2626 }
2627 }, {
2628 key: "getChildView",
2629 value: function getChildView(childModel) {
2630 return childModel.get('dynamic') ? _dynamicCategory.default : _category.default;
2631 }
2632 }, {
2633 key: "initialize",
2634 value: function initialize() {
2635 this.$activeItem = null;
2636 this.childViewContainer = '#elementor-finder__results';
2637 this.collection = new Backbone.Collection(Object.values(elementorCommon.finder.getSettings('data')));
2638 }
2639 }, {
2640 key: "activateItem",
2641 value: function activateItem($item) {
2642 if (this.$activeItem) {
2643 this.$activeItem.removeClass('elementor-active');
2644 }
2645 $item.addClass('elementor-active');
2646 this.$activeItem = $item;
2647 }
2648 }, {
2649 key: "activateNextItem",
2650 value: function activateNextItem(reverse) {
2651 var $allItems = jQuery(this.selectors.categoryItem);
2652 var nextItemIndex = 0;
2653 if (this.$activeItem) {
2654 nextItemIndex = $allItems.index(this.$activeItem) + (reverse ? -1 : 1);
2655 if (nextItemIndex >= $allItems.length) {
2656 nextItemIndex = 0;
2657 } else if (nextItemIndex < 0) {
2658 nextItemIndex = $allItems.length - 1;
2659 }
2660 }
2661 var $nextItem = $allItems.eq(nextItemIndex);
2662 this.activateItem($nextItem);
2663 $nextItem[0].scrollIntoView({
2664 block: 'nearest'
2665 });
2666 }
2667 }, {
2668 key: "goToActiveItem",
2669 value: function goToActiveItem(event) {
2670 var $a = this.$activeItem.children('a'),
2671 isControlClicked = $e.shortcuts.isControlEvent(event);
2672 if (isControlClicked) {
2673 $a.attr('target', '_blank');
2674 }
2675 $a[0].click();
2676 if (isControlClicked) {
2677 $a.removeAttr('target');
2678 }
2679 }
2680 }, {
2681 key: "onCategoryItemMouseEnter",
2682 value: function onCategoryItemMouseEnter(event) {
2683 this.activateItem(jQuery(event.currentTarget));
2684 }
2685 }, {
2686 key: "onChildviewToggleVisibility",
2687 value: function onChildviewToggleVisibility() {
2688 var allCategoriesAreEmpty = this.children.every(function (child) {
2689 return !child.isVisible;
2690 });
2691 this.ui.noResults.toggle(allCategoriesAreEmpty);
2692 }
2693 }]);
2694 }(Marionette.CompositeView);
2695
2696 /***/ }),
2697
2698 /***/ "../core/common/modules/finder/assets/js/modal/views/category.js":
2699 /*!***********************************************************************!*\
2700 !*** ../core/common/modules/finder/assets/js/modal/views/category.js ***!
2701 \***********************************************************************/
2702 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2703
2704 "use strict";
2705
2706
2707 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2708 Object.defineProperty(exports, "__esModule", ({
2709 value: true
2710 }));
2711 exports["default"] = void 0;
2712 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2713 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2714 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2715 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2716 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2717 var _item = _interopRequireDefault(__webpack_require__(/*! ./item */ "../core/common/modules/finder/assets/js/modal/views/item.js"));
2718 var _item2 = _interopRequireDefault(__webpack_require__(/*! ../model/item */ "../core/common/modules/finder/assets/js/modal/model/item.js"));
2719 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2720 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2721 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
2722 function _default() {
2723 (0, _classCallCheck2.default)(this, _default);
2724 return _callSuper(this, _default, arguments);
2725 }
2726 (0, _inherits2.default)(_default, _Marionette$Composite);
2727 return (0, _createClass2.default)(_default, [{
2728 key: "className",
2729 value: function className() {
2730 return 'elementor-finder__results__category';
2731 }
2732 }, {
2733 key: "getTemplate",
2734 value: function getTemplate() {
2735 return '#tmpl-elementor-finder__results__category';
2736 }
2737 }, {
2738 key: "getChildView",
2739 value: function getChildView() {
2740 return _item.default;
2741 }
2742 }, {
2743 key: "initialize",
2744 value: function initialize() {
2745 this.childViewContainer = '.elementor-finder__results__category__items';
2746 this.isVisible = true;
2747 var items = this.model.get('items');
2748 if (items) {
2749 items = Object.values(items);
2750 }
2751 this.collection = new Backbone.Collection(items, {
2752 model: _item2.default
2753 });
2754 }
2755 }, {
2756 key: "filter",
2757 value: function filter(childModel) {
2758 var textFilter = this.getTextFilter();
2759 if (childModel.get('title').toLowerCase().indexOf(textFilter) >= 0) {
2760 return true;
2761 }
2762 return childModel.get('keywords').some(function (keyword) {
2763 return keyword.indexOf(textFilter) >= 0;
2764 });
2765 }
2766 }, {
2767 key: "getTextFilter",
2768 value: function getTextFilter() {
2769 return elementorCommon.finder.channel.request('filter:text').trim().toLowerCase();
2770 }
2771 }, {
2772 key: "toggleElement",
2773 value: function toggleElement() {
2774 var isCurrentlyVisible = !!this.children.length;
2775 if (isCurrentlyVisible !== this.isVisible) {
2776 this.isVisible = isCurrentlyVisible;
2777 this.$el.toggle(isCurrentlyVisible);
2778 this.triggerMethod('toggle:visibility');
2779 }
2780 }
2781 }, {
2782 key: "onRender",
2783 value: function onRender() {
2784 this.listenTo(elementorCommon.finder.channel, 'filter:change', this.onFilterChange.bind(this));
2785 }
2786 }, {
2787 key: "onFilterChange",
2788 value: function onFilterChange() {
2789 this._renderChildren();
2790 }
2791 }, {
2792 key: "onRenderCollection",
2793 value: function onRenderCollection() {
2794 this.toggleElement();
2795 }
2796 }]);
2797 }(Marionette.CompositeView);
2798
2799 /***/ }),
2800
2801 /***/ "../core/common/modules/finder/assets/js/modal/views/content.js":
2802 /*!**********************************************************************!*\
2803 !*** ../core/common/modules/finder/assets/js/modal/views/content.js ***!
2804 \**********************************************************************/
2805 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2806
2807 "use strict";
2808
2809
2810 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2811 Object.defineProperty(exports, "__esModule", ({
2812 value: true
2813 }));
2814 exports["default"] = void 0;
2815 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2816 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2817 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2818 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2819 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2820 var _categories = _interopRequireDefault(__webpack_require__(/*! ./categories */ "../core/common/modules/finder/assets/js/modal/views/categories.js"));
2821 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2822 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2823 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$LayoutVie) {
2824 function _default() {
2825 (0, _classCallCheck2.default)(this, _default);
2826 return _callSuper(this, _default, arguments);
2827 }
2828 (0, _inherits2.default)(_default, _Marionette$LayoutVie);
2829 return (0, _createClass2.default)(_default, [{
2830 key: "id",
2831 value: function id() {
2832 return 'elementor-finder';
2833 }
2834 }, {
2835 key: "getTemplate",
2836 value: function getTemplate() {
2837 return '#tmpl-elementor-finder';
2838 }
2839 }, {
2840 key: "ui",
2841 value: function ui() {
2842 return {
2843 searchInput: '#elementor-finder__search__input'
2844 };
2845 }
2846 }, {
2847 key: "events",
2848 value: function events() {
2849 return {
2850 'input @ui.searchInput': 'onSearchInputInput'
2851 };
2852 }
2853 }, {
2854 key: "regions",
2855 value: function regions() {
2856 return {
2857 content: '#elementor-finder__content'
2858 };
2859 }
2860 }, {
2861 key: "showCategoriesView",
2862 value: function showCategoriesView() {
2863 this.content.show(new _categories.default());
2864 }
2865 }, {
2866 key: "onSearchInputInput",
2867 value: function onSearchInputInput() {
2868 var value = this.ui.searchInput.val();
2869 if (value) {
2870 elementorCommon.finder.channel.reply('filter:text', value).trigger('filter:change');
2871 if (!(this.content.currentView instanceof _categories.default)) {
2872 this.showCategoriesView();
2873 }
2874 }
2875 this.content.currentView.$el.toggle(!!value);
2876 }
2877 }]);
2878 }(Marionette.LayoutView);
2879
2880 /***/ }),
2881
2882 /***/ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js":
2883 /*!*******************************************************************************!*\
2884 !*** ../core/common/modules/finder/assets/js/modal/views/dynamic-category.js ***!
2885 \*******************************************************************************/
2886 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2887
2888 "use strict";
2889
2890
2891 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2892 Object.defineProperty(exports, "__esModule", ({
2893 value: true
2894 }));
2895 exports["default"] = void 0;
2896 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2897 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2898 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2899 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2900 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2901 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2902 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
2903 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2904 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2905 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
2906 var _default = exports["default"] = /*#__PURE__*/function (_Category) {
2907 function _default() {
2908 (0, _classCallCheck2.default)(this, _default);
2909 return _callSuper(this, _default, arguments);
2910 }
2911 (0, _inherits2.default)(_default, _Category);
2912 return (0, _createClass2.default)(_default, [{
2913 key: "className",
2914 value: function className() {
2915 return _superPropGet(_default, "className", this, 3)([]) + ' elementor-finder__results__category--dynamic';
2916 }
2917 }, {
2918 key: "ui",
2919 value: function ui() {
2920 return {
2921 title: '.elementor-finder__results__category__title'
2922 };
2923 }
2924 }, {
2925 key: "fetchData",
2926 value: function fetchData() {
2927 var _this = this;
2928 this.ui.loadingIcon.show();
2929 elementorCommon.ajax.addRequest('finder_get_category_items', {
2930 data: {
2931 category: this.model.get('name'),
2932 filter: this.getTextFilter()
2933 },
2934 success: function success(data) {
2935 if (_this.isDestroyed) {
2936 return;
2937 }
2938 _this.collection.set(data);
2939 _this.toggleElement();
2940 _this.ui.loadingIcon.hide();
2941 }
2942 });
2943 }
2944 }, {
2945 key: "filter",
2946 value: function filter() {
2947 return true;
2948 }
2949 }, {
2950 key: "onFilterChange",
2951 value: function onFilterChange() {
2952 this.fetchData();
2953 }
2954 }, {
2955 key: "onRender",
2956 value: function onRender() {
2957 _superPropGet(_default, "onRender", this, 3)([]);
2958 this.ui.loadingIcon = jQuery('<i>', {
2959 class: 'eicon-loading eicon-animation-spin'
2960 });
2961 this.ui.title.after(this.ui.loadingIcon);
2962 this.fetchData();
2963 }
2964 }]);
2965 }(_category.default);
2966
2967 /***/ }),
2968
2969 /***/ "../core/common/modules/finder/assets/js/modal/views/item.js":
2970 /*!*******************************************************************!*\
2971 !*** ../core/common/modules/finder/assets/js/modal/views/item.js ***!
2972 \*******************************************************************/
2973 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2974
2975 "use strict";
2976 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
2977
2978
2979 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2980 Object.defineProperty(exports, "__esModule", ({
2981 value: true
2982 }));
2983 exports["default"] = void 0;
2984 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2985 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2986 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2987 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2988 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2989 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2990 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2991 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$ItemView) {
2992 function _default() {
2993 (0, _classCallCheck2.default)(this, _default);
2994 return _callSuper(this, _default, arguments);
2995 }
2996 (0, _inherits2.default)(_default, _Marionette$ItemView);
2997 return (0, _createClass2.default)(_default, [{
2998 key: "className",
2999 value: function className() {
3000 return 'elementor-finder__results__item';
3001 }
3002 }, {
3003 key: "getTemplate",
3004 value: function getTemplate() {
3005 return '#tmpl-elementor-finder__results__item';
3006 }
3007 }, {
3008 key: "events",
3009 value: function events() {
3010 this.$el[0].addEventListener('click', this.onClick.bind(this), true);
3011 }
3012 }, {
3013 key: "onClick",
3014 value: function onClick(e) {
3015 var _this = this;
3016 var lockOptions = this.model.get('lock');
3017 if (!(lockOptions !== null && lockOptions !== void 0 && lockOptions.is_locked)) {
3018 return;
3019 }
3020 e.preventDefault();
3021 e.stopImmediatePropagation();
3022 elementorCommon.dialogsManager.createWidget('confirm', {
3023 id: 'elementor-finder__lock-dialog',
3024 headerMessage: lockOptions.content.heading,
3025 message: lockOptions.content.description,
3026 position: {
3027 my: 'center center',
3028 at: 'center center'
3029 },
3030 strings: {
3031 confirm: lockOptions.button.text,
3032 cancel: __('Cancel', 'elementor')
3033 },
3034 onConfirm: function onConfirm() {
3035 var link = _this.replaceLockLinkPlaceholders(lockOptions.button.url);
3036 window.open(link, '_blank');
3037 }
3038 }).show();
3039 }
3040 }, {
3041 key: "replaceLockLinkPlaceholders",
3042 value: function replaceLockLinkPlaceholders(link) {
3043 return link.replace(/%%utm_source%%/g, 'finder').replace(/%%utm_medium%%/g, 'wp-dash');
3044 }
3045 }]);
3046 }(Marionette.ItemView);
3047
3048 /***/ }),
3049
3050 /***/ "../core/common/modules/finder/assets/js/modal/views/layout.js":
3051 /*!*********************************************************************!*\
3052 !*** ../core/common/modules/finder/assets/js/modal/views/layout.js ***!
3053 \*********************************************************************/
3054 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3055
3056 "use strict";
3057 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3058
3059
3060 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3061 Object.defineProperty(exports, "__esModule", ({
3062 value: true
3063 }));
3064 exports["default"] = void 0;
3065 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3066 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3067 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3068 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3069 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3070 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3071 var _content = _interopRequireDefault(__webpack_require__(/*! ./content */ "../core/common/modules/finder/assets/js/modal/views/content.js"));
3072 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3073 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3074 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
3075 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$com) {
3076 function _default() {
3077 (0, _classCallCheck2.default)(this, _default);
3078 return _callSuper(this, _default, arguments);
3079 }
3080 (0, _inherits2.default)(_default, _elementorModules$com);
3081 return (0, _createClass2.default)(_default, [{
3082 key: "getModalOptions",
3083 value: function getModalOptions() {
3084 return {
3085 id: 'elementor-finder__modal',
3086 draggable: true,
3087 effects: {
3088 show: 'show',
3089 hide: 'hide'
3090 },
3091 position: {
3092 enable: false
3093 }
3094 };
3095 }
3096 }, {
3097 key: "getLogoOptions",
3098 value: function getLogoOptions() {
3099 return {
3100 title: __('Finder', 'elementor')
3101 };
3102 }
3103 }, {
3104 key: "initialize",
3105 value: function initialize() {
3106 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3107 args[_key] = arguments[_key];
3108 }
3109 _superPropGet(_default, "initialize", this, 3)(args);
3110 this.showLogo();
3111 this.showContentView();
3112 }
3113 }, {
3114 key: "showContentView",
3115 value: function showContentView() {
3116 this.modalContent.show(new _content.default());
3117 }
3118 }, {
3119 key: "showModal",
3120 value: function showModal() {
3121 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3122 args[_key2] = arguments[_key2];
3123 }
3124 _superPropGet(_default, "showModal", this, 3)(args);
3125 this.modalContent.currentView.ui.searchInput.focus();
3126 }
3127 }]);
3128 }(elementorModules.common.views.modal.Layout);
3129
3130 /***/ }),
3131
3132 /***/ "../modules/web-cli/assets/js/core/data/errors/base-error.js":
3133 /*!*******************************************************************!*\
3134 !*** ../modules/web-cli/assets/js/core/data/errors/base-error.js ***!
3135 \*******************************************************************/
3136 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3137
3138 "use strict";
3139
3140
3141 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3142 Object.defineProperty(exports, "__esModule", ({
3143 value: true
3144 }));
3145 exports["default"] = void 0;
3146 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3147 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3148 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3149 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3150 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3151 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
3152 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3153 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3154 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../../../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
3155 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3156 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3157 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3158 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3159 var BaseError = exports["default"] = /*#__PURE__*/function (_Error) {
3160 /**
3161 * Error constructor.
3162 *
3163 * @param {string} message
3164 * @param {string} code
3165 * @param {*} data
3166 */
3167 function BaseError() {
3168 var _this;
3169 var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
3170 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3171 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3172 (0, _classCallCheck2.default)(this, BaseError);
3173 _this = _callSuper(this, BaseError, [message]);
3174 /**
3175 * The server error code.
3176 *
3177 * @type {string}
3178 */
3179 (0, _defineProperty2.default)(_this, "code", '');
3180 /**
3181 * Additional data about the current error.
3182 *
3183 * @type {*[]}
3184 */
3185 (0, _defineProperty2.default)(_this, "data", []);
3186 _this.code = code;
3187 _this.data = data;
3188 return _this;
3189 }
3190
3191 /**
3192 * Notify a message when the error occurs.
3193 */
3194 (0, _inherits2.default)(BaseError, _Error);
3195 return (0, _createClass2.default)(BaseError, [{
3196 key: "notify",
3197 value: function notify() {
3198 _console.default.error(_objectSpread({
3199 message: this.message
3200 }, this));
3201 }
3202 }], [{
3203 key: "create",
3204 value:
3205 /**
3206 * Static helper function to create the error.
3207 *
3208 * @param {string} message
3209 * @param {string} code
3210 * @param {*} data
3211 * @return {BaseError} error
3212 */
3213 function create(message) {
3214 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3215 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3216 return new this(message, code, data);
3217 }
3218
3219 /**
3220 * Returns the status code of the error.
3221 */
3222 }, {
3223 key: "getHTTPErrorCode",
3224 value: function getHTTPErrorCode() {
3225 (0, _forceMethodImplementation.default)();
3226 }
3227 }]);
3228 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
3229
3230 /***/ }),
3231
3232 /***/ "../modules/web-cli/assets/js/core/data/errors/default-error.js":
3233 /*!**********************************************************************!*\
3234 !*** ../modules/web-cli/assets/js/core/data/errors/default-error.js ***!
3235 \**********************************************************************/
3236 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3237
3238 "use strict";
3239
3240
3241 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3242 Object.defineProperty(exports, "__esModule", ({
3243 value: true
3244 }));
3245 exports["default"] = exports.DefaultError = void 0;
3246 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3247 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3248 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3249 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3250 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3251 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3252 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3253 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3254 var DefaultError = exports.DefaultError = /*#__PURE__*/function (_BaseError) {
3255 function DefaultError() {
3256 (0, _classCallCheck2.default)(this, DefaultError);
3257 return _callSuper(this, DefaultError, arguments);
3258 }
3259 (0, _inherits2.default)(DefaultError, _BaseError);
3260 return (0, _createClass2.default)(DefaultError, null, [{
3261 key: "getHTTPErrorCode",
3262 value: function getHTTPErrorCode() {
3263 return 501;
3264 }
3265 }]);
3266 }(_baseError.default);
3267 var _default = exports["default"] = DefaultError;
3268
3269 /***/ }),
3270
3271 /***/ "../modules/web-cli/assets/js/core/data/errors/error-404.js":
3272 /*!******************************************************************!*\
3273 !*** ../modules/web-cli/assets/js/core/data/errors/error-404.js ***!
3274 \******************************************************************/
3275 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3276
3277 "use strict";
3278
3279
3280 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3281 Object.defineProperty(exports, "__esModule", ({
3282 value: true
3283 }));
3284 exports["default"] = exports.Error404 = void 0;
3285 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3286 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3287 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3288 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3289 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3290 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3291 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3292 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3293 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3294 var Error404 = exports.Error404 = /*#__PURE__*/function (_BaseError) {
3295 function Error404() {
3296 (0, _classCallCheck2.default)(this, Error404);
3297 return _callSuper(this, Error404, arguments);
3298 }
3299 (0, _inherits2.default)(Error404, _BaseError);
3300 return (0, _createClass2.default)(Error404, [{
3301 key: "notify",
3302 value: function notify() {
3303 _console.default.warn(this.message);
3304 }
3305 }], [{
3306 key: "getHTTPErrorCode",
3307 value: function getHTTPErrorCode() {
3308 return 404;
3309 }
3310 }]);
3311 }(_baseError.default);
3312 var _default = exports["default"] = Error404;
3313
3314 /***/ }),
3315
3316 /***/ "../modules/web-cli/assets/js/core/data/errors/index.js":
3317 /*!**************************************************************!*\
3318 !*** ../modules/web-cli/assets/js/core/data/errors/index.js ***!
3319 \**************************************************************/
3320 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3321
3322 "use strict";
3323
3324
3325 Object.defineProperty(exports, "__esModule", ({
3326 value: true
3327 }));
3328 Object.defineProperty(exports, "DefaultError", ({
3329 enumerable: true,
3330 get: function get() {
3331 return _defaultError.DefaultError;
3332 }
3333 }));
3334 Object.defineProperty(exports, "Error404", ({
3335 enumerable: true,
3336 get: function get() {
3337 return _error.Error404;
3338 }
3339 }));
3340 var _defaultError = __webpack_require__(/*! ./default-error */ "../modules/web-cli/assets/js/core/data/errors/default-error.js");
3341 var _error = __webpack_require__(/*! ./error-404 */ "../modules/web-cli/assets/js/core/data/errors/error-404.js");
3342
3343 /***/ }),
3344
3345 /***/ "../modules/web-cli/assets/js/modules/command-base.js":
3346 /*!************************************************************!*\
3347 !*** ../modules/web-cli/assets/js/modules/command-base.js ***!
3348 \************************************************************/
3349 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3350
3351 "use strict";
3352
3353
3354 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3355 Object.defineProperty(exports, "__esModule", ({
3356 value: true
3357 }));
3358 exports["default"] = void 0;
3359 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3360 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3361 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3362 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3363 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3364 var _commandInfra = _interopRequireDefault(__webpack_require__(/*! ./command-infra */ "../modules/web-cli/assets/js/modules/command-infra.js"));
3365 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3366 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3367 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3368 /**
3369 * @name $e.modules.CommandBase
3370 */
3371 var CommandBase = exports["default"] = /*#__PURE__*/function (_CommandInfra) {
3372 function CommandBase() {
3373 (0, _classCallCheck2.default)(this, CommandBase);
3374 return _callSuper(this, CommandBase, arguments);
3375 }
3376 (0, _inherits2.default)(CommandBase, _CommandInfra);
3377 return (0, _createClass2.default)(CommandBase, [{
3378 key: "onBeforeRun",
3379 value: function onBeforeRun() {
3380 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3381 $e.hooks.runUIBefore(this.command, args);
3382 }
3383 }, {
3384 key: "onAfterRun",
3385 value: function onAfterRun() {
3386 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3387 var result = arguments.length > 1 ? arguments[1] : undefined;
3388 $e.hooks.runUIAfter(this.command, args, result);
3389 }
3390 }, {
3391 key: "onBeforeApply",
3392 value: function onBeforeApply() {
3393 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3394 $e.hooks.runDataDependency(this.command, args);
3395 }
3396 }, {
3397 key: "onAfterApply",
3398 value: function onAfterApply() {
3399 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3400 var result = arguments.length > 1 ? arguments[1] : undefined;
3401 return $e.hooks.runDataAfter(this.command, args, result);
3402 }
3403 }, {
3404 key: "onCatchApply",
3405 value: function onCatchApply(e) {
3406 this.runCatchHooks(e);
3407 }
3408
3409 /**
3410 * Run all the catch hooks.
3411 *
3412 * @param {Error} e
3413 */
3414 }, {
3415 key: "runCatchHooks",
3416 value: function runCatchHooks(e) {
3417 $e.hooks.runDataCatch(this.command, this.args, e);
3418 $e.hooks.runUICatch(this.command, this.args, e);
3419 }
3420
3421 /**
3422 * TODO - Remove - Backwards compatibility.
3423 *
3424 * Function requireContainer().
3425 *
3426 * Validate `arg.container` & `arg.containers`.
3427 *
3428 * @param {{}} args
3429 * @deprecated since 3.7.0, extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase` instead.
3430 *
3431 * @throws {Error}
3432 */
3433 }, {
3434 key: "requireContainer",
3435 value: function requireContainer() {
3436 var _this = this;
3437 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
3438 _deprecation.default.deprecated('requireContainer()', '3.7.0', 'Extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase`');
3439 if (!args.container && !args.containers) {
3440 throw Error('container or containers are required.');
3441 }
3442 if (args.container && args.containers) {
3443 throw Error('container and containers cannot go together please select one of them.');
3444 }
3445 var containers = args.containers || [args.container];
3446 containers.forEach(function (container) {
3447 _this.requireArgumentInstance('container', elementorModules.editor.Container, {
3448 container: container
3449 });
3450 });
3451 }
3452 }], [{
3453 key: "getInstanceType",
3454 value: function getInstanceType() {
3455 return 'CommandBase';
3456 }
3457 }]);
3458 }(_commandInfra.default);
3459
3460 /***/ }),
3461
3462 /***/ "../modules/web-cli/assets/js/modules/command-callback-base.js":
3463 /*!*********************************************************************!*\
3464 !*** ../modules/web-cli/assets/js/modules/command-callback-base.js ***!
3465 \*********************************************************************/
3466 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3467
3468 "use strict";
3469
3470
3471 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3472 Object.defineProperty(exports, "__esModule", ({
3473 value: true
3474 }));
3475 exports["default"] = void 0;
3476 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3477 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3478 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3479 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3480 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3481 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3482 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3483 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3484 /**
3485 * To support pure callbacks in the API(commands.js), to ensure they have registered with the proper context.
3486 */
3487 var CommandCallbackBase = exports["default"] = /*#__PURE__*/function (_CommandBase) {
3488 function CommandCallbackBase() {
3489 (0, _classCallCheck2.default)(this, CommandCallbackBase);
3490 return _callSuper(this, CommandCallbackBase, arguments);
3491 }
3492 (0, _inherits2.default)(CommandCallbackBase, _CommandBase);
3493 return (0, _createClass2.default)(CommandCallbackBase, [{
3494 key: "apply",
3495 value: function apply() {
3496 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3497 return this.constructor.getCallback()(args);
3498 }
3499 }], [{
3500 key: "getInstanceType",
3501 value: function getInstanceType() {
3502 return 'CommandCallbackBase';
3503 }
3504
3505 /**
3506 * Get original callback of the command.
3507 *
3508 * Support pure callbacks ( Non command-base ).
3509 *
3510 * @return {()=>{}} Command Results.
3511 */
3512 }, {
3513 key: "getCallback",
3514 value: function getCallback() {
3515 return this.registerConfig.callback;
3516 }
3517 }]);
3518 }(_commandBase.default);
3519
3520 /***/ }),
3521
3522 /***/ "../modules/web-cli/assets/js/modules/command-data.js":
3523 /*!************************************************************!*\
3524 !*** ../modules/web-cli/assets/js/modules/command-data.js ***!
3525 \************************************************************/
3526 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3527
3528 "use strict";
3529
3530
3531 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3532 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
3533 Object.defineProperty(exports, "__esModule", ({
3534 value: true
3535 }));
3536 exports["default"] = void 0;
3537 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3538 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3539 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3540 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3541 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3542 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3543 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3544 var errors = _interopRequireWildcard(__webpack_require__(/*! ../core/data/errors/ */ "../modules/web-cli/assets/js/core/data/errors/index.js"));
3545 function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
3546 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3547 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3548 /**
3549 * @name $e.modules.CommandData
3550 */
3551 /**
3552 * @typedef {('create'|'delete'|'get'|'update'|'options')} DataTypes
3553 */
3554 /**
3555 * @typedef {{}} RequestData
3556 */
3557 /**
3558 * @typedef {import('../core/data/errors/base-error')} BaseError
3559 */
3560 var CommandData = exports["default"] = /*#__PURE__*/function (_CommandBase) {
3561 function CommandData(args) {
3562 var _this$args$options;
3563 var _this;
3564 var commandsAPI = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $e.data;
3565 (0, _classCallCheck2.default)(this, CommandData);
3566 _this = _callSuper(this, CommandData, [args, commandsAPI]);
3567 /**
3568 * Data returned from remote.
3569 *
3570 * @type {*}
3571 */
3572 (0, _defineProperty2.default)(_this, "data", void 0);
3573 /**
3574 * Fetch type.
3575 *
3576 * @type {DataTypes}
3577 */
3578 (0, _defineProperty2.default)(_this, "type", void 0);
3579 if ((_this$args$options = _this.args.options) !== null && _this$args$options !== void 0 && _this$args$options.type) {
3580 _this.type = _this.args.options.type;
3581 }
3582 return _this;
3583 }
3584
3585 /**
3586 * Function getEndpointFormat().
3587 *
3588 * @return {null|string} endpoint format
3589 */
3590 (0, _inherits2.default)(CommandData, _CommandBase);
3591 return (0, _createClass2.default)(CommandData, [{
3592 key: "getApplyMethods",
3593 value:
3594 /**
3595 * @param {DataTypes} type
3596 *
3597 * @return {boolean|{before: (function(*=): {}), after: (function({}, *=): {})}} apply methods
3598 */
3599 function getApplyMethods() {
3600 var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.type;
3601 var before, after;
3602 switch (type) {
3603 case 'create':
3604 before = this.applyBeforeCreate;
3605 after = this.applyAfterCreate;
3606 break;
3607 case 'delete':
3608 before = this.applyBeforeDelete;
3609 after = this.applyAfterDelete;
3610 break;
3611 case 'get':
3612 before = this.applyBeforeGet;
3613 after = this.applyAfterGet;
3614 break;
3615 case 'update':
3616 before = this.applyBeforeUpdate;
3617 after = this.applyAfterUpdate;
3618 break;
3619 case 'options':
3620 before = this.applyBeforeOptions;
3621 after = this.applyAfterOptions;
3622 break;
3623 default:
3624 return false;
3625 }
3626 return {
3627 before: before.bind(this),
3628 after: after.bind(this)
3629 };
3630 }
3631
3632 /**
3633 * Function getRequestData().
3634 *
3635 * @return {RequestData} request data
3636 */
3637 }, {
3638 key: "getRequestData",
3639 value: function getRequestData() {
3640 return {
3641 type: this.type,
3642 args: this.args,
3643 timestamp: new Date().getTime(),
3644 component: this.component,
3645 command: this.command,
3646 endpoint: $e.data.commandToEndpoint(this.command, JSON.parse(JSON.stringify(this.args)), this.constructor.getEndpointFormat())
3647 };
3648 }
3649 }, {
3650 key: "apply",
3651 value: function apply() {
3652 var _this2 = this;
3653 var applyMethods = this.getApplyMethods();
3654
3655 // Run 'before' method.
3656 this.args = applyMethods.before(this.args);
3657 var requestData = this.getRequestData();
3658 return $e.data.fetch(requestData).then(function (data) {
3659 _this2.data = data;
3660
3661 // Run 'after' method.
3662 _this2.data = applyMethods.after(data, _this2.args);
3663 _this2.data = {
3664 data: _this2.data
3665 };
3666
3667 // Append requestData.
3668 _this2.data = Object.assign({
3669 __requestData__: requestData
3670 }, _this2.data);
3671 return _this2.data;
3672 });
3673 }
3674
3675 /**
3676 * @param {*} [args={}]
3677 * @return {{}} filtered args
3678 */
3679 }, {
3680 key: "applyBeforeCreate",
3681 value: function applyBeforeCreate() {
3682 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3683 return args;
3684 }
3685
3686 /**
3687 * @param {{}} data
3688 * @param {*} [args={}]
3689 * @return {{}} filtered result
3690 */
3691 }, {
3692 key: "applyAfterCreate",
3693 value: function applyAfterCreate(data) {
3694 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3695 // eslint-disable-line no-unused-vars
3696 return data;
3697 }
3698
3699 /**
3700 * @param {*} [args={}]
3701 * @return {{}} filtered args
3702 */
3703 }, {
3704 key: "applyBeforeDelete",
3705 value: function applyBeforeDelete() {
3706 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3707 return args;
3708 }
3709
3710 /**
3711 * @param {{}} data
3712 * @param {*} [args={}]
3713 * @return {{}} filtered result
3714 */
3715 }, {
3716 key: "applyAfterDelete",
3717 value: function applyAfterDelete(data) {
3718 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3719 // eslint-disable-line no-unused-vars
3720 return data;
3721 }
3722
3723 /**
3724 * @param {*} [args={}]
3725 * @return {{}} filtered args
3726 */
3727 }, {
3728 key: "applyBeforeGet",
3729 value: function applyBeforeGet() {
3730 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3731 return args;
3732 }
3733
3734 /**
3735 * @param {{}} data
3736 * @param {*} [args={}]
3737 * @return {{}} filtered result
3738 */
3739 }, {
3740 key: "applyAfterGet",
3741 value: function applyAfterGet(data) {
3742 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3743 // eslint-disable-line no-unused-vars
3744 return data;
3745 }
3746
3747 /**
3748 * @param {*} [args={}]
3749 * @return {{}} filtered args
3750 */
3751 }, {
3752 key: "applyBeforeUpdate",
3753 value: function applyBeforeUpdate() {
3754 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3755 return args;
3756 }
3757
3758 /**
3759 * @param {{}} data
3760 * @param {*} [args={}]
3761 * @return {{}} filtered result
3762 */
3763 }, {
3764 key: "applyAfterUpdate",
3765 value: function applyAfterUpdate(data) {
3766 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3767 // eslint-disable-line no-unused-vars
3768 return data;
3769 }
3770
3771 /**
3772 * @param {*} [args={}]
3773 * @return {{}} filtered args
3774 */
3775 }, {
3776 key: "applyBeforeOptions",
3777 value: function applyBeforeOptions() {
3778 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3779 return args;
3780 }
3781
3782 /**
3783 * @param {{}} data
3784 * @param {*} [args={}]
3785 * @return {{}} filtered result
3786 */
3787 }, {
3788 key: "applyAfterOptions",
3789 value: function applyAfterOptions(data) {
3790 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3791 // eslint-disable-line no-unused-vars
3792 return data;
3793 }
3794
3795 /**
3796 * @param {BaseError} e
3797 */
3798 }, {
3799 key: "applyAfterCatch",
3800 value: function applyAfterCatch(e) {
3801 e.notify();
3802 }
3803 }, {
3804 key: "onCatchApply",
3805 value: function onCatchApply(e) {
3806 var _e;
3807 // TODO: If the errors that returns from the server is consistent remove the '?' from 'e'
3808 var httpErrorCode = ((_e = e) === null || _e === void 0 || (_e = _e.data) === null || _e === void 0 ? void 0 : _e.status) || 501;
3809 var dataError = Object.values(errors).find(function (error) {
3810 return error.getHTTPErrorCode() === httpErrorCode;
3811 });
3812 if (!dataError) {
3813 dataError = errors.DefaultError;
3814 }
3815 e = dataError.create(e.message, e.code, e.data || []);
3816 this.runCatchHooks(e);
3817 this.applyAfterCatch(e);
3818 }
3819 }], [{
3820 key: "getInstanceType",
3821 value: function getInstanceType() {
3822 return 'CommandData';
3823 }
3824 }, {
3825 key: "getEndpointFormat",
3826 value: function getEndpointFormat() {
3827 return null;
3828 }
3829 }]);
3830 }(_commandBase.default);
3831
3832 /***/ }),
3833
3834 /***/ "../modules/web-cli/assets/js/modules/command-infra.js":
3835 /*!*************************************************************!*\
3836 !*** ../modules/web-cli/assets/js/modules/command-infra.js ***!
3837 \*************************************************************/
3838 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3839
3840 "use strict";
3841
3842
3843 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3844 Object.defineProperty(exports, "__esModule", ({
3845 value: true
3846 }));
3847 exports["default"] = void 0;
3848 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3849 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3850 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3851 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3852 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3853 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3854 var _argsObject = _interopRequireDefault(__webpack_require__(/*! elementor-assets-js/modules/imports/args-object */ "../assets/dev/js/modules/imports/args-object.js"));
3855 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3856 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3857 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3858 /**
3859 * @typedef {import('../modules/component-base')} ComponentBase
3860 */
3861 var CommandInfra = exports["default"] = /*#__PURE__*/function (_ArgsObject) {
3862 /**
3863 * Function constructor().
3864 *
3865 * Create Commands Base.
3866 *
3867 * @param {{}} args
3868 */
3869 function CommandInfra() {
3870 var _this;
3871 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3872 (0, _classCallCheck2.default)(this, CommandInfra);
3873 _this = _callSuper(this, CommandInfra, [args]);
3874 if (!_this.constructor.registerConfig) {
3875 throw RangeError('Doing it wrong: Each command type should have `registerConfig`.');
3876 }
3877
3878 // Acknowledge self about which command it run.
3879 _this.command = _this.constructor.getCommand();
3880
3881 // Assign instance of current component.
3882 _this.component = _this.constructor.getComponent();
3883
3884 // Who ever need do something before without `super` the constructor can use `initialize` method.
3885 _this.initialize(args);
3886
3887 // Refresh args, maybe the changed via `initialize`.
3888 args = _this.args;
3889
3890 // Validate args before run.
3891 _this.validateArgs(args);
3892 return _this;
3893 }
3894
3895 /**
3896 * Function initialize().
3897 *
3898 * Initialize command, called after construction.
3899 *
3900 * @param {{}} args
3901 */
3902 (0, _inherits2.default)(CommandInfra, _ArgsObject);
3903 return (0, _createClass2.default)(CommandInfra, [{
3904 key: "currentCommand",
3905 get:
3906 /**
3907 * @deprecated since 3.7.0, use `this.command` instead.
3908 */
3909 function get() {
3910 _deprecation.default.deprecated('this.currentCommand', '3.7.0', 'this.command');
3911 return this.command;
3912 }
3913 }, {
3914 key: "initialize",
3915 value: function initialize() {
3916 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3917 } // eslint-disable-line no-unused-vars
3918
3919 /**
3920 * Function validateArgs().
3921 *
3922 * Validate command arguments.
3923 *
3924 * @param {{}} args
3925 */
3926 }, {
3927 key: "validateArgs",
3928 value: function validateArgs() {
3929 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3930 } // eslint-disable-line no-unused-vars
3931
3932 // eslint-disable-next-line jsdoc/require-returns-check
3933 /**
3934 * Function apply().
3935 *
3936 * Do the actual command.
3937 *
3938 * @param {{}} args
3939 *
3940 * @return {*} Command results.
3941 */
3942 }, {
3943 key: "apply",
3944 value: function apply() {
3945 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3946 // eslint-disable-line no-unused-vars
3947 elementorModules.ForceMethodImplementation();
3948 }
3949
3950 /**
3951 * Function run().
3952 *
3953 * Run command with history & hooks.
3954 *
3955 * @return {*} Command results.
3956 */
3957 }, {
3958 key: "run",
3959 value: function run() {
3960 return this.apply(this.args);
3961 }
3962
3963 /**
3964 * Function onBeforeRun.
3965 *
3966 * Called before run().
3967 *
3968 * @param {{}} args
3969 */
3970 }, {
3971 key: "onBeforeRun",
3972 value: function onBeforeRun() {
3973 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3974 } // eslint-disable-line no-unused-vars
3975
3976 /**
3977 * Function onAfterRun.
3978 *
3979 * Called after run().
3980 *
3981 * @param {{}} args
3982 * @param {*} result
3983 */
3984 }, {
3985 key: "onAfterRun",
3986 value: function onAfterRun() {
3987 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3988 var result = arguments.length > 1 ? arguments[1] : undefined;
3989 } // eslint-disable-line no-unused-vars
3990
3991 /**
3992 * Function onBeforeApply.
3993 *
3994 * Called before apply().
3995 *
3996 * @param {{}} args
3997 */
3998 }, {
3999 key: "onBeforeApply",
4000 value: function onBeforeApply() {
4001 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4002 } // eslint-disable-line no-unused-vars
4003
4004 /**
4005 * Function onAfterApply.
4006 *
4007 * Called after apply().
4008 *
4009 * @param {{}} args
4010 * @param {*} result
4011 */
4012 }, {
4013 key: "onAfterApply",
4014 value: function onAfterApply() {
4015 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4016 var result = arguments.length > 1 ? arguments[1] : undefined;
4017 } // eslint-disable-line no-unused-vars
4018
4019 /**
4020 * Function onCatchApply.
4021 *
4022 * Called after apply() failed.
4023 *
4024 * @param {Error} e
4025 */
4026 }, {
4027 key: "onCatchApply",
4028 value: function onCatchApply(e) {} // eslint-disable-line no-unused-vars
4029 }], [{
4030 key: "getInstanceType",
4031 value: function getInstanceType() {
4032 return 'CommandInfra';
4033 }
4034
4035 /**
4036 * Get info of command.
4037 *
4038 * @return {Object} Extra information about the command.
4039 */
4040 }, {
4041 key: "getInfo",
4042 value: function getInfo() {
4043 return {};
4044 }
4045
4046 /**
4047 * @return {string} Self command name.
4048 */
4049 }, {
4050 key: "getCommand",
4051 value: function getCommand() {
4052 return this.registerConfig.command;
4053 }
4054
4055 /**
4056 * @return {ComponentBase} Self component
4057 */
4058 }, {
4059 key: "getComponent",
4060 value: function getComponent() {
4061 return this.registerConfig.component;
4062 }
4063 }, {
4064 key: "setRegisterConfig",
4065 value: function setRegisterConfig(config) {
4066 this.registerConfig = Object.freeze(config);
4067 }
4068 }]);
4069 }(_argsObject.default);
4070 /**
4071 * @type {Object}
4072 */
4073 (0, _defineProperty2.default)(CommandInfra, "registerConfig", null);
4074
4075 /***/ }),
4076
4077 /***/ "../modules/web-cli/assets/js/modules/commands/close.js":
4078 /*!**************************************************************!*\
4079 !*** ../modules/web-cli/assets/js/modules/commands/close.js ***!
4080 \**************************************************************/
4081 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4082
4083 "use strict";
4084
4085
4086 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4087 Object.defineProperty(exports, "__esModule", ({
4088 value: true
4089 }));
4090 exports["default"] = exports.Close = void 0;
4091 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4092 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4093 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4094 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4095 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4096 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4097 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
4098 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4099 var Close = exports.Close = /*#__PURE__*/function (_CommandBase) {
4100 function Close() {
4101 (0, _classCallCheck2.default)(this, Close);
4102 return _callSuper(this, Close, arguments);
4103 }
4104 (0, _inherits2.default)(Close, _CommandBase);
4105 return (0, _createClass2.default)(Close, [{
4106 key: "apply",
4107 value: function apply() {
4108 this.component.close();
4109 }
4110 }]);
4111 }(_commandBase.default);
4112 var _default = exports["default"] = Close;
4113
4114 /***/ }),
4115
4116 /***/ "../modules/web-cli/assets/js/modules/commands/index.js":
4117 /*!**************************************************************!*\
4118 !*** ../modules/web-cli/assets/js/modules/commands/index.js ***!
4119 \**************************************************************/
4120 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4121
4122 "use strict";
4123
4124
4125 Object.defineProperty(exports, "__esModule", ({
4126 value: true
4127 }));
4128 Object.defineProperty(exports, "Close", ({
4129 enumerable: true,
4130 get: function get() {
4131 return _close.Close;
4132 }
4133 }));
4134 Object.defineProperty(exports, "Open", ({
4135 enumerable: true,
4136 get: function get() {
4137 return _open.Open;
4138 }
4139 }));
4140 Object.defineProperty(exports, "Toggle", ({
4141 enumerable: true,
4142 get: function get() {
4143 return _toggle.Toggle;
4144 }
4145 }));
4146 var _close = __webpack_require__(/*! ./close */ "../modules/web-cli/assets/js/modules/commands/close.js");
4147 var _open = __webpack_require__(/*! ./open */ "../modules/web-cli/assets/js/modules/commands/open.js");
4148 var _toggle = __webpack_require__(/*! ./toggle */ "../modules/web-cli/assets/js/modules/commands/toggle.js");
4149
4150 /***/ }),
4151
4152 /***/ "../modules/web-cli/assets/js/modules/commands/open.js":
4153 /*!*************************************************************!*\
4154 !*** ../modules/web-cli/assets/js/modules/commands/open.js ***!
4155 \*************************************************************/
4156 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4157
4158 "use strict";
4159
4160
4161 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4162 Object.defineProperty(exports, "__esModule", ({
4163 value: true
4164 }));
4165 exports["default"] = exports.Open = void 0;
4166 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4167 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4168 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4169 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4170 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4171 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4172 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
4173 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4174 var Open = exports.Open = /*#__PURE__*/function (_CommandBase) {
4175 function Open() {
4176 (0, _classCallCheck2.default)(this, Open);
4177 return _callSuper(this, Open, arguments);
4178 }
4179 (0, _inherits2.default)(Open, _CommandBase);
4180 return (0, _createClass2.default)(Open, [{
4181 key: "apply",
4182 value: function apply() {
4183 $e.route(this.component.getNamespace());
4184 }
4185 }]);
4186 }(_commandBase.default);
4187 var _default = exports["default"] = Open;
4188
4189 /***/ }),
4190
4191 /***/ "../modules/web-cli/assets/js/modules/commands/toggle.js":
4192 /*!***************************************************************!*\
4193 !*** ../modules/web-cli/assets/js/modules/commands/toggle.js ***!
4194 \***************************************************************/
4195 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4196
4197 "use strict";
4198
4199
4200 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4201 Object.defineProperty(exports, "__esModule", ({
4202 value: true
4203 }));
4204 exports["default"] = exports.Toggle = void 0;
4205 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4206 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4207 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4208 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4209 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4210 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4211 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
4212 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4213 var Toggle = exports.Toggle = /*#__PURE__*/function (_CommandBase) {
4214 function Toggle() {
4215 (0, _classCallCheck2.default)(this, Toggle);
4216 return _callSuper(this, Toggle, arguments);
4217 }
4218 (0, _inherits2.default)(Toggle, _CommandBase);
4219 return (0, _createClass2.default)(Toggle, [{
4220 key: "apply",
4221 value: function apply() {
4222 if (this.component.isOpen) {
4223 this.component.close();
4224 } else {
4225 $e.route(this.component.getNamespace());
4226 }
4227 }
4228 }]);
4229 }(_commandBase.default);
4230 var _default = exports["default"] = Toggle;
4231
4232 /***/ }),
4233
4234 /***/ "../modules/web-cli/assets/js/modules/component-base.js":
4235 /*!**************************************************************!*\
4236 !*** ../modules/web-cli/assets/js/modules/component-base.js ***!
4237 \**************************************************************/
4238 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4239
4240 "use strict";
4241
4242
4243 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4244 Object.defineProperty(exports, "__esModule", ({
4245 value: true
4246 }));
4247 exports["default"] = void 0;
4248 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4249 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4250 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4251 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4252 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4253 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4254 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4255 var _commandCallbackBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-callback-base */ "../modules/web-cli/assets/js/modules/command-callback-base.js"));
4256 var _toolkit = __webpack_require__(/*! @reduxjs/toolkit */ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js");
4257 var _module = _interopRequireDefault(__webpack_require__(/*! elementor/assets/dev/js/modules/imports/module.js */ "../assets/dev/js/modules/imports/module.js"));
4258 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4259 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4260 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4261 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4262 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
4263 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4264 /**
4265 * @typedef {import('./command-infra')} CommandInfra
4266 * @typedef {import('./hook-base')} HookBase
4267 * @typedef {import('../core/states/ui-state-base')} UiStateBase
4268 */
4269 var ComponentBase = exports["default"] = /*#__PURE__*/function (_Module) {
4270 function ComponentBase() {
4271 (0, _classCallCheck2.default)(this, ComponentBase);
4272 return _callSuper(this, ComponentBase, arguments);
4273 }
4274 (0, _inherits2.default)(ComponentBase, _Module);
4275 return (0, _createClass2.default)(ComponentBase, [{
4276 key: "__construct",
4277 value: function __construct() {
4278 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4279 if (args.manager) {
4280 this.manager = args.manager;
4281 }
4282 this.commands = this.defaultCommands();
4283 this.commandsInternal = this.defaultCommandsInternal();
4284 this.hooks = this.defaultHooks();
4285 this.routes = this.defaultRoutes();
4286 this.tabs = this.defaultTabs();
4287 this.shortcuts = this.defaultShortcuts();
4288 this.utils = this.defaultUtils();
4289 this.data = this.defaultData();
4290 this.uiStates = this.defaultUiStates();
4291 this.states = this.defaultStates();
4292 this.defaultRoute = '';
4293 this.currentTab = '';
4294 }
4295 }, {
4296 key: "registerAPI",
4297 value: function registerAPI() {
4298 var _this = this;
4299 Object.entries(this.getTabs()).forEach(function (tab) {
4300 return _this.registerTabRoute(tab[0]);
4301 });
4302 Object.entries(this.getRoutes()).forEach(function (_ref) {
4303 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
4304 route = _ref2[0],
4305 callback = _ref2[1];
4306 return _this.registerRoute(route, callback);
4307 });
4308 Object.entries(this.getCommands()).forEach(function (_ref3) {
4309 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
4310 command = _ref4[0],
4311 callback = _ref4[1];
4312 return _this.registerCommand(command, callback);
4313 });
4314 Object.entries(this.getCommandsInternal()).forEach(function (_ref5) {
4315 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
4316 command = _ref6[0],
4317 callback = _ref6[1];
4318 return _this.registerCommandInternal(command, callback);
4319 });
4320 Object.values(this.getHooks()).forEach(function (instance) {
4321 return _this.registerHook(instance);
4322 });
4323 Object.entries(this.getData()).forEach(function (_ref7) {
4324 var _ref8 = (0, _slicedToArray2.default)(_ref7, 2),
4325 command = _ref8[0],
4326 callback = _ref8[1];
4327 return _this.registerData(command, callback);
4328 });
4329 Object.values(this.getUiStates()).forEach(function (instance) {
4330 return _this.registerUiState(instance);
4331 });
4332 Object.entries(this.getStates()).forEach(function (_ref9) {
4333 var _ref0 = (0, _slicedToArray2.default)(_ref9, 2),
4334 id = _ref0[0],
4335 state = _ref0[1];
4336 return _this.registerState(id, state);
4337 });
4338 }
4339
4340 // eslint-disable-next-line jsdoc/require-returns-check
4341 /**
4342 * @return {string} namespace
4343 */
4344 }, {
4345 key: "getNamespace",
4346 value: function getNamespace() {
4347 (0, _forceMethodImplementation.default)();
4348 }
4349
4350 /**
4351 * @deprecated since 3.7.0, use `getServiceName()` instead.
4352 */
4353 }, {
4354 key: "getRootContainer",
4355 value: function getRootContainer() {
4356 _deprecation.default.deprecated('getRootContainer()', '3.7.0', 'getServiceName()');
4357 return this.getServiceName();
4358 }
4359 }, {
4360 key: "getServiceName",
4361 value: function getServiceName() {
4362 return this.getNamespace().split('/')[0];
4363 }
4364 }, {
4365 key: "store",
4366 get: function get() {
4367 return $e.store.get(this.getNamespace());
4368 }
4369 }, {
4370 key: "defaultTabs",
4371 value: function defaultTabs() {
4372 return {};
4373 }
4374 }, {
4375 key: "defaultRoutes",
4376 value: function defaultRoutes() {
4377 return {};
4378 }
4379 }, {
4380 key: "defaultCommands",
4381 value: function defaultCommands() {
4382 return {};
4383 }
4384 }, {
4385 key: "defaultCommandsInternal",
4386 value: function defaultCommandsInternal() {
4387 return {};
4388 }
4389 }, {
4390 key: "defaultHooks",
4391 value: function defaultHooks() {
4392 return {};
4393 }
4394
4395 /**
4396 * Get the component's default UI states.
4397 *
4398 * @return {Object} default UI states
4399 */
4400 }, {
4401 key: "defaultUiStates",
4402 value: function defaultUiStates() {
4403 return {};
4404 }
4405
4406 /**
4407 * Get the component's Redux slice settings.
4408 *
4409 * @return {Object} Redux slice settings
4410 */
4411 }, {
4412 key: "defaultStates",
4413 value: function defaultStates() {
4414 return {};
4415 }
4416 }, {
4417 key: "defaultShortcuts",
4418 value: function defaultShortcuts() {
4419 return {};
4420 }
4421 }, {
4422 key: "defaultUtils",
4423 value: function defaultUtils() {
4424 return {};
4425 }
4426 }, {
4427 key: "defaultData",
4428 value: function defaultData() {
4429 return {};
4430 }
4431 }, {
4432 key: "getCommands",
4433 value: function getCommands() {
4434 return this.commands;
4435 }
4436 }, {
4437 key: "getCommandsInternal",
4438 value: function getCommandsInternal() {
4439 return this.commandsInternal;
4440 }
4441 }, {
4442 key: "getHooks",
4443 value: function getHooks() {
4444 return this.hooks;
4445 }
4446
4447 /**
4448 * Retrieve the component's UI states.
4449 *
4450 * @return {Object} UI states
4451 */
4452 }, {
4453 key: "getUiStates",
4454 value: function getUiStates() {
4455 return this.uiStates;
4456 }
4457
4458 /**
4459 * Retrieve the component's Redux Slice.
4460 *
4461 * @return {Object} Redux Slice
4462 */
4463 }, {
4464 key: "getStates",
4465 value: function getStates() {
4466 return this.states;
4467 }
4468 }, {
4469 key: "getRoutes",
4470 value: function getRoutes() {
4471 return this.routes;
4472 }
4473 }, {
4474 key: "getTabs",
4475 value: function getTabs() {
4476 return this.tabs;
4477 }
4478 }, {
4479 key: "getShortcuts",
4480 value: function getShortcuts() {
4481 return this.shortcuts;
4482 }
4483 }, {
4484 key: "getData",
4485 value: function getData() {
4486 return this.data;
4487 }
4488
4489 /**
4490 * @param {string} command
4491 * @param {(()=>{}|CommandInfra)} context
4492 * @param {'default'|'internal'|'data'} commandsType
4493 */
4494 }, {
4495 key: "registerCommand",
4496 value: function registerCommand(command, context) {
4497 var commandsType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'default';
4498 var commandsManager;
4499 switch (commandsType) {
4500 case 'default':
4501 commandsManager = $e.commands;
4502 break;
4503 case 'internal':
4504 commandsManager = $e.commandsInternal;
4505 break;
4506 case 'data':
4507 commandsManager = $e.data;
4508 break;
4509 default:
4510 throw new Error("Invalid commands type: '".concat(command, "'"));
4511 }
4512 var fullCommand = this.getNamespace() + '/' + command,
4513 instanceType = context.getInstanceType ? context.getInstanceType() : false,
4514 registerConfig = {
4515 command: fullCommand,
4516 component: this
4517 };
4518
4519 // Support pure callback.
4520 if (!instanceType) {
4521 if ($e.devTools) {
4522 $e.devTools.log.warn("Attach command-callback-base, on command: '".concat(fullCommand, "', context is unknown type."));
4523 }
4524 registerConfig.callback = context;
4525
4526 // Unique class.
4527 context = /*#__PURE__*/function (_CommandCallbackBase) {
4528 function context() {
4529 (0, _classCallCheck2.default)(this, context);
4530 return _callSuper(this, context, arguments);
4531 }
4532 (0, _inherits2.default)(context, _CommandCallbackBase);
4533 return (0, _createClass2.default)(context);
4534 }(_commandCallbackBase.default);
4535 }
4536 context.setRegisterConfig(registerConfig);
4537 commandsManager.register(this, command, context);
4538 }
4539
4540 /**
4541 * @param {HookBase} instance
4542 */
4543 }, {
4544 key: "registerHook",
4545 value: function registerHook(instance) {
4546 return instance.register();
4547 }
4548 }, {
4549 key: "registerCommandInternal",
4550 value: function registerCommandInternal(command, context) {
4551 this.registerCommand(command, context, 'internal');
4552 }
4553
4554 /**
4555 * Register a UI state.
4556 *
4557 * @param {UiStateBase} instance - UI state instance.
4558 *
4559 * @return {void}
4560 */
4561 }, {
4562 key: "registerUiState",
4563 value: function registerUiState(instance) {
4564 $e.uiStates.register(instance);
4565 }
4566
4567 /**
4568 * Register a Redux Slice.
4569 *
4570 * @param {string} id - State id.
4571 * @param {Object} stateConfig - The state config.
4572 *
4573 * @return {void}
4574 */
4575 }, {
4576 key: "registerState",
4577 value: function registerState(id, stateConfig) {
4578 id = this.getNamespace() + (id ? "/".concat(id) : '');
4579 var slice = (0, _toolkit.createSlice)(_objectSpread(_objectSpread({}, stateConfig), {}, {
4580 name: id
4581 }));
4582 $e.store.register(id, slice);
4583 }
4584 }, {
4585 key: "registerRoute",
4586 value: function registerRoute(route, callback) {
4587 $e.routes.register(this, route, callback);
4588 }
4589 }, {
4590 key: "registerData",
4591 value: function registerData(command, context) {
4592 this.registerCommand(command, context, 'data');
4593 }
4594 }, {
4595 key: "unregisterRoute",
4596 value: function unregisterRoute(route) {
4597 $e.routes.unregister(this, route);
4598 }
4599 }, {
4600 key: "registerTabRoute",
4601 value: function registerTabRoute(tab) {
4602 var _this2 = this;
4603 this.registerRoute(tab, function (args) {
4604 return _this2.activateTab(tab, args);
4605 });
4606 }
4607 }, {
4608 key: "dependency",
4609 value: function dependency() {
4610 return true;
4611 }
4612 }, {
4613 key: "open",
4614 value: function open() {
4615 return true;
4616 }
4617 }, {
4618 key: "close",
4619 value: function close() {
4620 if (!this.isOpen) {
4621 return false;
4622 }
4623 this.isOpen = false;
4624 this.inactivate();
4625 $e.routes.clearCurrent(this.getNamespace());
4626 $e.routes.clearHistory(this.getServiceName());
4627 return true;
4628 }
4629 }, {
4630 key: "activate",
4631 value: function activate() {
4632 $e.components.activate(this.getNamespace());
4633 }
4634 }, {
4635 key: "inactivate",
4636 value: function inactivate() {
4637 $e.components.inactivate(this.getNamespace());
4638 }
4639 }, {
4640 key: "isActive",
4641 value: function isActive() {
4642 return $e.components.isActive(this.getNamespace());
4643 }
4644 }, {
4645 key: "onRoute",
4646 value: function onRoute(route) {
4647 this.toggleRouteClass(route, true);
4648 this.toggleHistoryClass();
4649 this.activate();
4650 this.trigger('route/open', route);
4651 }
4652 }, {
4653 key: "onCloseRoute",
4654 value: function onCloseRoute(route) {
4655 this.toggleRouteClass(route, false);
4656 this.inactivate();
4657 this.trigger('route/close', route);
4658 }
4659 }, {
4660 key: "setDefaultRoute",
4661 value: function setDefaultRoute(route) {
4662 this.defaultRoute = this.getNamespace() + '/' + route;
4663 }
4664 }, {
4665 key: "getDefaultRoute",
4666 value: function getDefaultRoute() {
4667 return this.defaultRoute;
4668 }
4669 }, {
4670 key: "removeTab",
4671 value: function removeTab(tab) {
4672 delete this.tabs[tab];
4673 this.unregisterRoute(tab);
4674 }
4675 }, {
4676 key: "hasTab",
4677 value: function hasTab(tab) {
4678 return !!this.tabs[tab];
4679 }
4680 }, {
4681 key: "addTab",
4682 value: function addTab(tab, args, position) {
4683 var _this3 = this;
4684 this.tabs[tab] = args;
4685 // It can be 0.
4686 if ('undefined' !== typeof position) {
4687 var newTabs = {};
4688 var ids = Object.keys(this.tabs);
4689 // Remove new tab
4690 ids.pop();
4691
4692 // Add it to position.
4693 ids.splice(position, 0, tab);
4694 ids.forEach(function (id) {
4695 newTabs[id] = _this3.tabs[id];
4696 });
4697 this.tabs = newTabs;
4698 }
4699 this.registerTabRoute(tab);
4700 }
4701 }, {
4702 key: "getTabsWrapperSelector",
4703 value: function getTabsWrapperSelector() {
4704 return '';
4705 }
4706 }, {
4707 key: "getTabRoute",
4708 value: function getTabRoute(tab) {
4709 return this.getNamespace() + '/' + tab;
4710 }
4711 }, {
4712 key: "renderTab",
4713 value: function renderTab(tab) {} // eslint-disable-line
4714 }, {
4715 key: "activateTab",
4716 value: function activateTab(tab, args) {
4717 var _this4 = this;
4718 this.renderTab(tab, args);
4719 jQuery(this.getTabsWrapperSelector() + ' .elementor-component-tab').off('click').on('click', function (event) {
4720 $e.route(_this4.getTabRoute(event.currentTarget.dataset.tab), args);
4721 }).removeClass('elementor-active').filter('[data-tab="' + tab + '"]').addClass('elementor-active');
4722 }
4723 }, {
4724 key: "getActiveTabConfig",
4725 value: function getActiveTabConfig() {
4726 return this.tabs[this.currentTab] || {};
4727 }
4728 }, {
4729 key: "getBodyClass",
4730 value: function getBodyClass(route) {
4731 return 'e-route-' + route.replace(/\//g, '-');
4732 }
4733
4734 /**
4735 * If command includes uppercase character convert it to lowercase and add `-`.
4736 * e.g: `CopyAll` is converted to `copy-all`.
4737 *
4738 * @param {string} commandName
4739 */
4740 }, {
4741 key: "normalizeCommandName",
4742 value: function normalizeCommandName(commandName) {
4743 return commandName.replace(/[A-Z]/g, function (match, offset) {
4744 return (offset > 0 ? '-' : '') + match.toLowerCase();
4745 });
4746 }
4747
4748 /**
4749 * @param {{}} commandsFromImport
4750 * @return {{}} imported commands
4751 */
4752 }, {
4753 key: "importCommands",
4754 value: function importCommands(commandsFromImport) {
4755 var _this5 = this;
4756 var commands = {};
4757
4758 // Convert `Commands` to `ComponentBase` workable format.
4759 Object.entries(commandsFromImport).forEach(function (_ref1) {
4760 var _ref10 = (0, _slicedToArray2.default)(_ref1, 2),
4761 className = _ref10[0],
4762 Class = _ref10[1];
4763 var command = _this5.normalizeCommandName(className);
4764 commands[command] = Class;
4765 });
4766 return commands;
4767 }
4768 }, {
4769 key: "importHooks",
4770 value: function importHooks(hooksFromImport) {
4771 var hooks = {};
4772 for (var key in hooksFromImport) {
4773 var hook = new hooksFromImport[key]();
4774 hooks[hook.getId()] = hook;
4775 }
4776 return hooks;
4777 }
4778
4779 /**
4780 * Import & initialize the component's UI states.
4781 * Should be used inside `defaultUiState()`.
4782 *
4783 * @param {Object} statesFromImport - UI states from import.
4784 *
4785 * @return {Object} UI States
4786 */
4787 }, {
4788 key: "importUiStates",
4789 value: function importUiStates(statesFromImport) {
4790 var _this6 = this;
4791 var uiStates = {};
4792 Object.values(statesFromImport).forEach(function (className) {
4793 var uiState = new className(_this6);
4794 uiStates[uiState.getId()] = uiState;
4795 });
4796 return uiStates;
4797 }
4798
4799 /**
4800 * Set a UI state value.
4801 * TODO: Should we provide such function? Maybe the developer should implicitly pass the full state ID?
4802 *
4803 * @param {string} state - Non-prefixed state ID.
4804 * @param {*} value - New state value.
4805 *
4806 * @return {void}
4807 */
4808 }, {
4809 key: "setUiState",
4810 value: function setUiState(state, value) {
4811 $e.uiStates.set("".concat(this.getNamespace(), "/").concat(state), value);
4812 }
4813 }, {
4814 key: "toggleRouteClass",
4815 value: function toggleRouteClass(route, state) {
4816 document.body.classList.toggle(this.getBodyClass(route), state);
4817 }
4818 }, {
4819 key: "toggleHistoryClass",
4820 value: function toggleHistoryClass() {
4821 document.body.classList.toggle('e-routes-has-history', !!$e.routes.getHistory(this.getServiceName()).length);
4822 }
4823 }]);
4824 }(_module.default);
4825
4826 /***/ }),
4827
4828 /***/ "../modules/web-cli/assets/js/modules/component-modal-base.js":
4829 /*!********************************************************************!*\
4830 !*** ../modules/web-cli/assets/js/modules/component-modal-base.js ***!
4831 \********************************************************************/
4832 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4833
4834 "use strict";
4835
4836
4837 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4838 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
4839 Object.defineProperty(exports, "__esModule", ({
4840 value: true
4841 }));
4842 exports["default"] = void 0;
4843 var _readOnlyError2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/readOnlyError */ "../node_modules/@babel/runtime/helpers/readOnlyError.js"));
4844 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4845 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4846 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4847 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4848 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
4849 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4850 var _componentBase = _interopRequireDefault(__webpack_require__(/*! ./component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
4851 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../modules/web-cli/assets/js/modules/commands/index.js"));
4852 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4853 function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
4854 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
4855 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4856 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
4857 var ComponentModalBase = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
4858 function ComponentModalBase() {
4859 (0, _classCallCheck2.default)(this, ComponentModalBase);
4860 return _callSuper(this, ComponentModalBase, arguments);
4861 }
4862 (0, _inherits2.default)(ComponentModalBase, _ComponentBase);
4863 return (0, _createClass2.default)(ComponentModalBase, [{
4864 key: "registerAPI",
4865 value: function registerAPI() {
4866 var _this = this;
4867 _superPropGet(ComponentModalBase, "registerAPI", this, 3)([]);
4868 $e.shortcuts.register('esc', {
4869 scopes: [this.getNamespace()],
4870 callback: function callback() {
4871 return _this.close();
4872 }
4873 });
4874 }
4875 }, {
4876 key: "defaultCommands",
4877 value: function defaultCommands() {
4878 return this.importCommands(commands);
4879 }
4880 }, {
4881 key: "defaultRoutes",
4882 value: function defaultRoutes() {
4883 return {
4884 '': function _() {/* Nothing to do, it's already rendered. */}
4885 };
4886 }
4887 }, {
4888 key: "open",
4889 value: function open() {
4890 var _this2 = this;
4891 if (!this.layout) {
4892 var layout = this.getModalLayout();
4893 this.layout = new layout({
4894 component: this
4895 });
4896 this.layout.getModal().on('hide', function () {
4897 return _this2.close();
4898 });
4899 }
4900 this.layout.showModal();
4901 return true;
4902 }
4903 }, {
4904 key: "close",
4905 value: function close() {
4906 if (!_superPropGet(ComponentModalBase, "close", this, 3)([])) {
4907 return false;
4908 }
4909 var close = elementor.hooks.applyFilters('component/modal/close', this.layout.getModal().hide.bind(this.layout.getModal()), this);
4910 close();
4911 return true;
4912 }
4913 }, {
4914 key: "getModalLayout",
4915 value: function getModalLayout() {
4916 (0, _forceMethodImplementation.default)();
4917 }
4918 }]);
4919 }(_componentBase.default);
4920
4921 /***/ }),
4922
4923 /***/ "../modules/web-cli/assets/js/utils/console.js":
4924 /*!*****************************************************!*\
4925 !*** ../modules/web-cli/assets/js/utils/console.js ***!
4926 \*****************************************************/
4927 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4928
4929 "use strict";
4930
4931
4932 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4933 Object.defineProperty(exports, "__esModule", ({
4934 value: true
4935 }));
4936 exports["default"] = void 0;
4937 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4938 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4939 var Console = exports["default"] = /*#__PURE__*/function () {
4940 function Console() {
4941 (0, _classCallCheck2.default)(this, Console);
4942 }
4943 return (0, _createClass2.default)(Console, null, [{
4944 key: "error",
4945 value: function error(message) {
4946 // Show an error if devTools is available.
4947 if ($e.devTools) {
4948 $e.devTools.log.error(message);
4949 }
4950
4951 // If not a 'Hook-Break' then show error.
4952 if (!(message instanceof $e.modules.HookBreak)) {
4953 // eslint-disable-next-line no-console
4954 console.error(message);
4955 }
4956 }
4957 }, {
4958 key: "warn",
4959 value: function warn() {
4960 var _console;
4961 var style = "font-size: 12px; background-image: url(\"".concat(elementorWebCliConfig.urls.assets, "images/logo-icon.png\"); background-repeat: no-repeat; background-size: contain;");
4962 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4963 args[_key] = arguments[_key];
4964 }
4965 args.unshift('%c %c', style, '');
4966 (_console = console).warn.apply(_console, args); // eslint-disable-line no-console
4967 }
4968 }]);
4969 }();
4970
4971 /***/ }),
4972
4973 /***/ "../modules/web-cli/assets/js/utils/deprecation.js":
4974 /*!*********************************************************!*\
4975 !*** ../modules/web-cli/assets/js/utils/deprecation.js ***!
4976 \*********************************************************/
4977 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4978
4979 "use strict";
4980
4981
4982 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4983 Object.defineProperty(exports, "__esModule", ({
4984 value: true
4985 }));
4986 exports["default"] = void 0;
4987 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4988 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4989 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4990 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
4991 // Copied from `modules/dev-tools/assets/js/deprecation.js`
4992 /**
4993 * @typedef {Object} Version
4994 * @property {number} major1 The first number
4995 * @property {number} major2 The second number
4996 * @property {number} minor The third number
4997 * @property {string} build The fourth number
4998 */
4999
5000 var softDeprecated = function softDeprecated(name, version, replacement) {
5001 if (elementorWebCliConfig.isDebug) {
5002 deprecatedMessage('soft', name, version, replacement);
5003 }
5004 };
5005 var hardDeprecated = function hardDeprecated(name, version, replacement) {
5006 deprecatedMessage('hard', name, version, replacement);
5007 };
5008 var deprecatedMessage = function deprecatedMessage(type, name, version, replacement) {
5009 var message = "`".concat(name, "` is ").concat(type, " deprecated since ").concat(version);
5010 if (replacement) {
5011 message += " - Use `".concat(replacement, "` instead");
5012 }
5013 _console.default.warn(message);
5014 };
5015 var Deprecation = exports["default"] = /*#__PURE__*/function () {
5016 function Deprecation() {
5017 (0, _classCallCheck2.default)(this, Deprecation);
5018 }
5019 return (0, _createClass2.default)(Deprecation, null, [{
5020 key: "deprecated",
5021 value: function deprecated(name, version, replacement) {
5022 if (this.isHardDeprecated(version)) {
5023 hardDeprecated(name, version, replacement);
5024 } else {
5025 softDeprecated(name, version, replacement);
5026 }
5027 }
5028
5029 /**
5030 * @param {string} version
5031 *
5032 * @return {Version}
5033 */
5034 }, {
5035 key: "parseVersion",
5036 value: function parseVersion(version) {
5037 var versionParts = version.split('.');
5038 if (versionParts.length < 3 || versionParts.length > 4) {
5039 throw new RangeError('Invalid Semantic Version string provided');
5040 }
5041 var _versionParts = (0, _slicedToArray2.default)(versionParts, 4),
5042 major1 = _versionParts[0],
5043 major2 = _versionParts[1],
5044 minor = _versionParts[2],
5045 _versionParts$ = _versionParts[3],
5046 build = _versionParts$ === void 0 ? '' : _versionParts$;
5047 return {
5048 major1: parseInt(major1),
5049 major2: parseInt(major2),
5050 minor: parseInt(minor),
5051 build: build
5052 };
5053 }
5054
5055 /**
5056 * Get total of major.
5057 *
5058 * Since `get_total_major` cannot determine how much really versions between 2.9.0 and 3.3.0 if there is 2.10.0 version for example,
5059 * versions with major2 more then 9 will be added to total.
5060 *
5061 * @param {Version} versionObj
5062 *
5063 * @return {number}
5064 */
5065 }, {
5066 key: "getTotalMajor",
5067 value: function getTotalMajor(versionObj) {
5068 var total = parseInt("".concat(versionObj.major1).concat(versionObj.major2, "0"));
5069 total = Number((total / 10).toFixed(0));
5070 if (versionObj.major2 > 9) {
5071 total = versionObj.major2 - 9;
5072 }
5073 return total;
5074 }
5075
5076 /**
5077 * @param {string} version1
5078 * @param {string} version2
5079 *
5080 * @return {number}
5081 */
5082 }, {
5083 key: "compareVersion",
5084 value: function compareVersion(version1, version2) {
5085 var _this = this;
5086 return [this.parseVersion(version1), this.parseVersion(version2)].map(function (versionObj) {
5087 return _this.getTotalMajor(versionObj);
5088 }).reduce(function (acc, major) {
5089 return acc - major;
5090 });
5091 }
5092
5093 /**
5094 * @param {string} version
5095 *
5096 * @return {boolean}
5097 */
5098 }, {
5099 key: "isSoftDeprecated",
5100 value: function isSoftDeprecated(version) {
5101 var total = this.compareVersion(version, elementorWebCliConfig.version);
5102 return total <= 4;
5103 }
5104
5105 /**
5106 * @param {string} version
5107 * @return {boolean}
5108 */
5109 }, {
5110 key: "isHardDeprecated",
5111 value: function isHardDeprecated(version) {
5112 var total = this.compareVersion(version, elementorWebCliConfig.version);
5113 return total < 0 || total >= 8;
5114 }
5115 }]);
5116 }();
5117
5118 /***/ }),
5119
5120 /***/ "../modules/web-cli/assets/js/utils/force-method-implementation.js":
5121 /*!*************************************************************************!*\
5122 !*** ../modules/web-cli/assets/js/utils/force-method-implementation.js ***!
5123 \*************************************************************************/
5124 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5125
5126 "use strict";
5127
5128
5129 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5130 Object.defineProperty(exports, "__esModule", ({
5131 value: true
5132 }));
5133 exports["default"] = exports.ForceMethodImplementation = void 0;
5134 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5135 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5136 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5137 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5138 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5139 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
5140 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
5141 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5142 // TODO: Copied from `assets/dev/js/modules/imports/force-method-implementation.js`;
5143 var ForceMethodImplementation = exports.ForceMethodImplementation = /*#__PURE__*/function (_Error) {
5144 function ForceMethodImplementation() {
5145 var _this;
5146 var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5147 (0, _classCallCheck2.default)(this, ForceMethodImplementation);
5148 _this = _callSuper(this, ForceMethodImplementation, ["".concat(info.isStatic ? 'static ' : '').concat(info.fullName, "() should be implemented, please provide '").concat(info.functionName || info.fullName, "' functionality.")]);
5149 Error.captureStackTrace(_this, ForceMethodImplementation);
5150 return _this;
5151 }
5152 (0, _inherits2.default)(ForceMethodImplementation, _Error);
5153 return (0, _createClass2.default)(ForceMethodImplementation);
5154 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
5155 var _default = exports["default"] = function _default() {
5156 var stack = Error().stack,
5157 caller = stack.split('\n')[2].trim(),
5158 callerName = caller.startsWith('at new') ? 'constructor' : caller.split(' ')[1],
5159 info = {};
5160 info.functionName = callerName;
5161 info.fullName = callerName;
5162 if (info.functionName.includes('.')) {
5163 var parts = info.functionName.split('.');
5164 info.className = parts[0];
5165 info.functionName = parts[1];
5166 } else {
5167 info.isStatic = true;
5168 }
5169 throw new ForceMethodImplementation(info);
5170 };
5171
5172 /***/ }),
5173
5174 /***/ "../node_modules/@babel/runtime/helpers/OverloadYield.js":
5175 /*!***************************************************************!*\
5176 !*** ../node_modules/@babel/runtime/helpers/OverloadYield.js ***!
5177 \***************************************************************/
5178 /***/ ((module) => {
5179
5180 function _OverloadYield(e, d) {
5181 this.v = e, this.k = d;
5182 }
5183 module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
5184
5185 /***/ }),
5186
5187 /***/ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
5188 /*!******************************************************************!*\
5189 !*** ../node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
5190 \******************************************************************/
5191 /***/ ((module) => {
5192
5193 function _arrayLikeToArray(r, a) {
5194 (null == a || a > r.length) && (a = r.length);
5195 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
5196 return n;
5197 }
5198 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
5199
5200 /***/ }),
5201
5202 /***/ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js":
5203 /*!****************************************************************!*\
5204 !*** ../node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
5205 \****************************************************************/
5206 /***/ ((module) => {
5207
5208 function _arrayWithHoles(r) {
5209 if (Array.isArray(r)) return r;
5210 }
5211 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
5212
5213 /***/ }),
5214
5215 /***/ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js":
5216 /*!***********************************************************************!*\
5217 !*** ../node_modules/@babel/runtime/helpers/assertThisInitialized.js ***!
5218 \***********************************************************************/
5219 /***/ ((module) => {
5220
5221 function _assertThisInitialized(e) {
5222 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5223 return e;
5224 }
5225 module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
5226
5227 /***/ }),
5228
5229 /***/ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js":
5230 /*!******************************************************************!*\
5231 !*** ../node_modules/@babel/runtime/helpers/asyncToGenerator.js ***!
5232 \******************************************************************/
5233 /***/ ((module) => {
5234
5235 function asyncGeneratorStep(n, t, e, r, o, a, c) {
5236 try {
5237 var i = n[a](c),
5238 u = i.value;
5239 } catch (n) {
5240 return void e(n);
5241 }
5242 i.done ? t(u) : Promise.resolve(u).then(r, o);
5243 }
5244 function _asyncToGenerator(n) {
5245 return function () {
5246 var t = this,
5247 e = arguments;
5248 return new Promise(function (r, o) {
5249 var a = n.apply(t, e);
5250 function _next(n) {
5251 asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
5252 }
5253 function _throw(n) {
5254 asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
5255 }
5256 _next(void 0);
5257 });
5258 };
5259 }
5260 module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5261
5262 /***/ }),
5263
5264 /***/ "../node_modules/@babel/runtime/helpers/classCallCheck.js":
5265 /*!****************************************************************!*\
5266 !*** ../node_modules/@babel/runtime/helpers/classCallCheck.js ***!
5267 \****************************************************************/
5268 /***/ ((module) => {
5269
5270 function _classCallCheck(a, n) {
5271 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
5272 }
5273 module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
5274
5275 /***/ }),
5276
5277 /***/ "../node_modules/@babel/runtime/helpers/construct.js":
5278 /*!***********************************************************!*\
5279 !*** ../node_modules/@babel/runtime/helpers/construct.js ***!
5280 \***********************************************************/
5281 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5282
5283 var isNativeReflectConstruct = __webpack_require__(/*! ./isNativeReflectConstruct.js */ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js");
5284 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5285 function _construct(t, e, r) {
5286 if (isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
5287 var o = [null];
5288 o.push.apply(o, e);
5289 var p = new (t.bind.apply(t, o))();
5290 return r && setPrototypeOf(p, r.prototype), p;
5291 }
5292 module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5293
5294 /***/ }),
5295
5296 /***/ "../node_modules/@babel/runtime/helpers/createClass.js":
5297 /*!*************************************************************!*\
5298 !*** ../node_modules/@babel/runtime/helpers/createClass.js ***!
5299 \*************************************************************/
5300 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5301
5302 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5303 function _defineProperties(e, r) {
5304 for (var t = 0; t < r.length; t++) {
5305 var o = r[t];
5306 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
5307 }
5308 }
5309 function _createClass(e, r, t) {
5310 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
5311 writable: !1
5312 }), e;
5313 }
5314 module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
5315
5316 /***/ }),
5317
5318 /***/ "../node_modules/@babel/runtime/helpers/defineProperty.js":
5319 /*!****************************************************************!*\
5320 !*** ../node_modules/@babel/runtime/helpers/defineProperty.js ***!
5321 \****************************************************************/
5322 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5323
5324 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5325 function _defineProperty(e, r, t) {
5326 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5327 value: t,
5328 enumerable: !0,
5329 configurable: !0,
5330 writable: !0
5331 }) : e[r] = t, e;
5332 }
5333 module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
5334
5335 /***/ }),
5336
5337 /***/ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js":
5338 /*!********************************************************************!*\
5339 !*** ../node_modules/@babel/runtime/helpers/esm/defineProperty.js ***!
5340 \********************************************************************/
5341 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5342
5343 "use strict";
5344 __webpack_require__.r(__webpack_exports__);
5345 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5346 /* harmony export */ "default": () => (/* binding */ _defineProperty)
5347 /* harmony export */ });
5348 /* harmony import */ var _toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js");
5349
5350 function _defineProperty(e, r, t) {
5351 return (r = (0,_toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r)) in e ? Object.defineProperty(e, r, {
5352 value: t,
5353 enumerable: !0,
5354 configurable: !0,
5355 writable: !0
5356 }) : e[r] = t, e;
5357 }
5358
5359
5360 /***/ }),
5361
5362 /***/ "../node_modules/@babel/runtime/helpers/esm/objectSpread2.js":
5363 /*!*******************************************************************!*\
5364 !*** ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js ***!
5365 \*******************************************************************/
5366 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5367
5368 "use strict";
5369 __webpack_require__.r(__webpack_exports__);
5370 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5371 /* harmony export */ "default": () => (/* binding */ _objectSpread2)
5372 /* harmony export */ });
5373 /* harmony import */ var _defineProperty_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defineProperty.js */ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js");
5374
5375 function ownKeys(e, r) {
5376 var t = Object.keys(e);
5377 if (Object.getOwnPropertySymbols) {
5378 var o = Object.getOwnPropertySymbols(e);
5379 r && (o = o.filter(function (r) {
5380 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5381 })), t.push.apply(t, o);
5382 }
5383 return t;
5384 }
5385 function _objectSpread2(e) {
5386 for (var r = 1; r < arguments.length; r++) {
5387 var t = null != arguments[r] ? arguments[r] : {};
5388 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
5389 (0,_defineProperty_js__WEBPACK_IMPORTED_MODULE_0__["default"])(e, r, t[r]);
5390 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
5391 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5392 });
5393 }
5394 return e;
5395 }
5396
5397
5398 /***/ }),
5399
5400 /***/ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js":
5401 /*!*****************************************************************!*\
5402 !*** ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js ***!
5403 \*****************************************************************/
5404 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5405
5406 "use strict";
5407 __webpack_require__.r(__webpack_exports__);
5408 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5409 /* harmony export */ "default": () => (/* binding */ toPrimitive)
5410 /* harmony export */ });
5411 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5412
5413 function toPrimitive(t, r) {
5414 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(t) || !t) return t;
5415 var e = t[Symbol.toPrimitive];
5416 if (void 0 !== e) {
5417 var i = e.call(t, r || "default");
5418 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i)) return i;
5419 throw new TypeError("@@toPrimitive must return a primitive value.");
5420 }
5421 return ("string" === r ? String : Number)(t);
5422 }
5423
5424
5425 /***/ }),
5426
5427 /***/ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js":
5428 /*!*******************************************************************!*\
5429 !*** ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js ***!
5430 \*******************************************************************/
5431 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5432
5433 "use strict";
5434 __webpack_require__.r(__webpack_exports__);
5435 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5436 /* harmony export */ "default": () => (/* binding */ toPropertyKey)
5437 /* harmony export */ });
5438 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5439 /* harmony import */ var _toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js");
5440
5441
5442 function toPropertyKey(t) {
5443 var i = (0,_toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__["default"])(t, "string");
5444 return "symbol" == (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i) ? i : i + "";
5445 }
5446
5447
5448 /***/ }),
5449
5450 /***/ "../node_modules/@babel/runtime/helpers/esm/typeof.js":
5451 /*!************************************************************!*\
5452 !*** ../node_modules/@babel/runtime/helpers/esm/typeof.js ***!
5453 \************************************************************/
5454 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5455
5456 "use strict";
5457 __webpack_require__.r(__webpack_exports__);
5458 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5459 /* harmony export */ "default": () => (/* binding */ _typeof)
5460 /* harmony export */ });
5461 function _typeof(o) {
5462 "@babel/helpers - typeof";
5463
5464 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
5465 return typeof o;
5466 } : function (o) {
5467 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
5468 }, _typeof(o);
5469 }
5470
5471
5472 /***/ }),
5473
5474 /***/ "../node_modules/@babel/runtime/helpers/get.js":
5475 /*!*****************************************************!*\
5476 !*** ../node_modules/@babel/runtime/helpers/get.js ***!
5477 \*****************************************************/
5478 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5479
5480 var superPropBase = __webpack_require__(/*! ./superPropBase.js */ "../node_modules/@babel/runtime/helpers/superPropBase.js");
5481 function _get() {
5482 return module.exports = _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
5483 var p = superPropBase(e, t);
5484 if (p) {
5485 var n = Object.getOwnPropertyDescriptor(p, t);
5486 return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
5487 }
5488 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _get.apply(null, arguments);
5489 }
5490 module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
5491
5492 /***/ }),
5493
5494 /***/ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js":
5495 /*!****************************************************************!*\
5496 !*** ../node_modules/@babel/runtime/helpers/getPrototypeOf.js ***!
5497 \****************************************************************/
5498 /***/ ((module) => {
5499
5500 function _getPrototypeOf(t) {
5501 return module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
5502 return t.__proto__ || Object.getPrototypeOf(t);
5503 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _getPrototypeOf(t);
5504 }
5505 module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
5506
5507 /***/ }),
5508
5509 /***/ "../node_modules/@babel/runtime/helpers/inherits.js":
5510 /*!**********************************************************!*\
5511 !*** ../node_modules/@babel/runtime/helpers/inherits.js ***!
5512 \**********************************************************/
5513 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5514
5515 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5516 function _inherits(t, e) {
5517 if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
5518 t.prototype = Object.create(e && e.prototype, {
5519 constructor: {
5520 value: t,
5521 writable: !0,
5522 configurable: !0
5523 }
5524 }), Object.defineProperty(t, "prototype", {
5525 writable: !1
5526 }), e && setPrototypeOf(t, e);
5527 }
5528 module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
5529
5530 /***/ }),
5531
5532 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
5533 /*!***********************************************************************!*\
5534 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
5535 \***********************************************************************/
5536 /***/ ((module) => {
5537
5538 function _interopRequireDefault(e) {
5539 return e && e.__esModule ? e : {
5540 "default": e
5541 };
5542 }
5543 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
5544
5545 /***/ }),
5546
5547 /***/ "../node_modules/@babel/runtime/helpers/isNativeFunction.js":
5548 /*!******************************************************************!*\
5549 !*** ../node_modules/@babel/runtime/helpers/isNativeFunction.js ***!
5550 \******************************************************************/
5551 /***/ ((module) => {
5552
5553 function _isNativeFunction(t) {
5554 try {
5555 return -1 !== Function.toString.call(t).indexOf("[native code]");
5556 } catch (n) {
5557 return "function" == typeof t;
5558 }
5559 }
5560 module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
5561
5562 /***/ }),
5563
5564 /***/ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js":
5565 /*!**************************************************************************!*\
5566 !*** ../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js ***!
5567 \**************************************************************************/
5568 /***/ ((module) => {
5569
5570 function _isNativeReflectConstruct() {
5571 try {
5572 var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
5573 } catch (t) {}
5574 return (module.exports = _isNativeReflectConstruct = function _isNativeReflectConstruct() {
5575 return !!t;
5576 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5577 }
5578 module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5579
5580 /***/ }),
5581
5582 /***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
5583 /*!**********************************************************************!*\
5584 !*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
5585 \**********************************************************************/
5586 /***/ ((module) => {
5587
5588 function _iterableToArrayLimit(r, l) {
5589 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
5590 if (null != t) {
5591 var e,
5592 n,
5593 i,
5594 u,
5595 a = [],
5596 f = !0,
5597 o = !1;
5598 try {
5599 if (i = (t = t.call(r)).next, 0 === l) {
5600 if (Object(t) !== t) return;
5601 f = !1;
5602 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
5603 } catch (r) {
5604 o = !0, n = r;
5605 } finally {
5606 try {
5607 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
5608 } finally {
5609 if (o) throw n;
5610 }
5611 }
5612 return a;
5613 }
5614 }
5615 module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
5616
5617 /***/ }),
5618
5619 /***/ "../node_modules/@babel/runtime/helpers/nonIterableRest.js":
5620 /*!*****************************************************************!*\
5621 !*** ../node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
5622 \*****************************************************************/
5623 /***/ ((module) => {
5624
5625 function _nonIterableRest() {
5626 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5627 }
5628 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
5629
5630 /***/ }),
5631
5632 /***/ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js":
5633 /*!***************************************************************************!*\
5634 !*** ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js ***!
5635 \***************************************************************************/
5636 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5637
5638 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5639 var assertThisInitialized = __webpack_require__(/*! ./assertThisInitialized.js */ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js");
5640 function _possibleConstructorReturn(t, e) {
5641 if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
5642 if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
5643 return assertThisInitialized(t);
5644 }
5645 module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
5646
5647 /***/ }),
5648
5649 /***/ "../node_modules/@babel/runtime/helpers/readOnlyError.js":
5650 /*!***************************************************************!*\
5651 !*** ../node_modules/@babel/runtime/helpers/readOnlyError.js ***!
5652 \***************************************************************/
5653 /***/ ((module) => {
5654
5655 function _readOnlyError(r) {
5656 throw new TypeError('"' + r + '" is read-only');
5657 }
5658 module.exports = _readOnlyError, module.exports.__esModule = true, module.exports["default"] = module.exports;
5659
5660 /***/ }),
5661
5662 /***/ "../node_modules/@babel/runtime/helpers/regenerator.js":
5663 /*!*************************************************************!*\
5664 !*** ../node_modules/@babel/runtime/helpers/regenerator.js ***!
5665 \*************************************************************/
5666 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5667
5668 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
5669 function _regenerator() {
5670 /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
5671 var e,
5672 t,
5673 r = "function" == typeof Symbol ? Symbol : {},
5674 n = r.iterator || "@@iterator",
5675 o = r.toStringTag || "@@toStringTag";
5676 function i(r, n, o, i) {
5677 var c = n && n.prototype instanceof Generator ? n : Generator,
5678 u = Object.create(c.prototype);
5679 return regeneratorDefine(u, "_invoke", function (r, n, o) {
5680 var i,
5681 c,
5682 u,
5683 f = 0,
5684 p = o || [],
5685 y = !1,
5686 G = {
5687 p: 0,
5688 n: 0,
5689 v: e,
5690 a: d,
5691 f: d.bind(e, 4),
5692 d: function d(t, r) {
5693 return i = t, c = 0, u = e, G.n = r, a;
5694 }
5695 };
5696 function d(r, n) {
5697 for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
5698 var o,
5699 i = p[t],
5700 d = G.p,
5701 l = i[2];
5702 r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
5703 }
5704 if (o || r > 1) return a;
5705 throw y = !0, n;
5706 }
5707 return function (o, p, l) {
5708 if (f > 1) throw TypeError("Generator is already running");
5709 for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
5710 i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
5711 try {
5712 if (f = 2, i) {
5713 if (c || (o = "next"), t = i[o]) {
5714 if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
5715 if (!t.done) return t;
5716 u = t.value, c < 2 && (c = 0);
5717 } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
5718 i = e;
5719 } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
5720 } catch (t) {
5721 i = e, c = 1, u = t;
5722 } finally {
5723 f = 1;
5724 }
5725 }
5726 return {
5727 value: t,
5728 done: y
5729 };
5730 };
5731 }(r, o, i), !0), u;
5732 }
5733 var a = {};
5734 function Generator() {}
5735 function GeneratorFunction() {}
5736 function GeneratorFunctionPrototype() {}
5737 t = Object.getPrototypeOf;
5738 var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
5739 return this;
5740 }), t),
5741 u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
5742 function f(e) {
5743 return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
5744 }
5745 return GeneratorFunction.prototype = GeneratorFunctionPrototype, regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), regeneratorDefine(u), regeneratorDefine(u, o, "Generator"), regeneratorDefine(u, n, function () {
5746 return this;
5747 }), regeneratorDefine(u, "toString", function () {
5748 return "[object Generator]";
5749 }), (module.exports = _regenerator = function _regenerator() {
5750 return {
5751 w: i,
5752 m: f
5753 };
5754 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5755 }
5756 module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5757
5758 /***/ }),
5759
5760 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js":
5761 /*!******************************************************************!*\
5762 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsync.js ***!
5763 \******************************************************************/
5764 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5765
5766 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
5767 function _regeneratorAsync(n, e, r, t, o) {
5768 var a = regeneratorAsyncGen(n, e, r, t, o);
5769 return a.next().then(function (n) {
5770 return n.done ? n.value : a.next();
5771 });
5772 }
5773 module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
5774
5775 /***/ }),
5776
5777 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js":
5778 /*!*********************************************************************!*\
5779 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js ***!
5780 \*********************************************************************/
5781 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5782
5783 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
5784 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
5785 function _regeneratorAsyncGen(r, e, t, o, n) {
5786 return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
5787 }
5788 module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
5789
5790 /***/ }),
5791
5792 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js":
5793 /*!**************************************************************************!*\
5794 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js ***!
5795 \**************************************************************************/
5796 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5797
5798 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
5799 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
5800 function AsyncIterator(t, e) {
5801 function n(r, o, i, f) {
5802 try {
5803 var c = t[r](o),
5804 u = c.value;
5805 return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
5806 n("next", t, i, f);
5807 }, function (t) {
5808 n("throw", t, i, f);
5809 }) : e.resolve(u).then(function (t) {
5810 c.value = t, i(c);
5811 }, function (t) {
5812 return n("throw", t, i, f);
5813 });
5814 } catch (t) {
5815 f(t);
5816 }
5817 }
5818 var r;
5819 this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
5820 return this;
5821 })), regeneratorDefine(this, "_invoke", function (t, o, i) {
5822 function f() {
5823 return new e(function (e, r) {
5824 n(t, i, e, r);
5825 });
5826 }
5827 return r = r ? r.then(f, f) : f();
5828 }, !0);
5829 }
5830 module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5831
5832 /***/ }),
5833
5834 /***/ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js":
5835 /*!*******************************************************************!*\
5836 !*** ../node_modules/@babel/runtime/helpers/regeneratorDefine.js ***!
5837 \*******************************************************************/
5838 /***/ ((module) => {
5839
5840 function _regeneratorDefine(e, r, n, t) {
5841 var i = Object.defineProperty;
5842 try {
5843 i({}, "", {});
5844 } catch (e) {
5845 i = 0;
5846 }
5847 module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
5848 function o(r, n) {
5849 _regeneratorDefine(e, r, function (e) {
5850 return this._invoke(r, n, e);
5851 });
5852 }
5853 r ? i ? i(e, r, {
5854 value: n,
5855 enumerable: !t,
5856 configurable: !t,
5857 writable: !t
5858 }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
5859 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
5860 }
5861 module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
5862
5863 /***/ }),
5864
5865 /***/ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js":
5866 /*!*****************************************************************!*\
5867 !*** ../node_modules/@babel/runtime/helpers/regeneratorKeys.js ***!
5868 \*****************************************************************/
5869 /***/ ((module) => {
5870
5871 function _regeneratorKeys(e) {
5872 var n = Object(e),
5873 r = [];
5874 for (var t in n) r.unshift(t);
5875 return function e() {
5876 for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
5877 return e.done = !0, e;
5878 };
5879 }
5880 module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
5881
5882 /***/ }),
5883
5884 /***/ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js":
5885 /*!********************************************************************!*\
5886 !*** ../node_modules/@babel/runtime/helpers/regeneratorRuntime.js ***!
5887 \********************************************************************/
5888 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5889
5890 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
5891 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
5892 var regeneratorAsync = __webpack_require__(/*! ./regeneratorAsync.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js");
5893 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
5894 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
5895 var regeneratorKeys = __webpack_require__(/*! ./regeneratorKeys.js */ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js");
5896 var regeneratorValues = __webpack_require__(/*! ./regeneratorValues.js */ "../node_modules/@babel/runtime/helpers/regeneratorValues.js");
5897 function _regeneratorRuntime() {
5898 "use strict";
5899
5900 var r = regenerator(),
5901 e = r.m(_regeneratorRuntime),
5902 t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
5903 function n(r) {
5904 var e = "function" == typeof r && r.constructor;
5905 return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
5906 }
5907 var o = {
5908 "throw": 1,
5909 "return": 2,
5910 "break": 3,
5911 "continue": 3
5912 };
5913 function a(r) {
5914 var e, t;
5915 return function (n) {
5916 e || (e = {
5917 stop: function stop() {
5918 return t(n.a, 2);
5919 },
5920 "catch": function _catch() {
5921 return n.v;
5922 },
5923 abrupt: function abrupt(r, e) {
5924 return t(n.a, o[r], e);
5925 },
5926 delegateYield: function delegateYield(r, o, a) {
5927 return e.resultName = o, t(n.d, regeneratorValues(r), a);
5928 },
5929 finish: function finish(r) {
5930 return t(n.f, r);
5931 }
5932 }, t = function t(r, _t, o) {
5933 n.p = e.prev, n.n = e.next;
5934 try {
5935 return r(_t, o);
5936 } finally {
5937 e.next = n.n;
5938 }
5939 }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
5940 try {
5941 return r.call(this, e);
5942 } finally {
5943 n.p = e.prev, n.n = e.next;
5944 }
5945 };
5946 }
5947 return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
5948 return {
5949 wrap: function wrap(e, t, n, o) {
5950 return r.w(a(e), t, n, o && o.reverse());
5951 },
5952 isGeneratorFunction: n,
5953 mark: r.m,
5954 awrap: function awrap(r, e) {
5955 return new OverloadYield(r, e);
5956 },
5957 AsyncIterator: regeneratorAsyncIterator,
5958 async: function async(r, e, t, o, u) {
5959 return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
5960 },
5961 keys: regeneratorKeys,
5962 values: regeneratorValues
5963 };
5964 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5965 }
5966 module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
5967
5968 /***/ }),
5969
5970 /***/ "../node_modules/@babel/runtime/helpers/regeneratorValues.js":
5971 /*!*******************************************************************!*\
5972 !*** ../node_modules/@babel/runtime/helpers/regeneratorValues.js ***!
5973 \*******************************************************************/
5974 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5975
5976 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5977 function _regeneratorValues(e) {
5978 if (null != e) {
5979 var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
5980 r = 0;
5981 if (t) return t.call(e);
5982 if ("function" == typeof e.next) return e;
5983 if (!isNaN(e.length)) return {
5984 next: function next() {
5985 return e && r >= e.length && (e = void 0), {
5986 value: e && e[r++],
5987 done: !e
5988 };
5989 }
5990 };
5991 }
5992 throw new TypeError(_typeof(e) + " is not iterable");
5993 }
5994 module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
5995
5996 /***/ }),
5997
5998 /***/ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js":
5999 /*!****************************************************************!*\
6000 !*** ../node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
6001 \****************************************************************/
6002 /***/ ((module) => {
6003
6004 function _setPrototypeOf(t, e) {
6005 return module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
6006 return t.__proto__ = e, t;
6007 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _setPrototypeOf(t, e);
6008 }
6009 module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6010
6011 /***/ }),
6012
6013 /***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js":
6014 /*!***************************************************************!*\
6015 !*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***!
6016 \***************************************************************/
6017 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6018
6019 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js");
6020 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
6021 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
6022 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "../node_modules/@babel/runtime/helpers/nonIterableRest.js");
6023 function _slicedToArray(r, e) {
6024 return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();
6025 }
6026 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6027
6028 /***/ }),
6029
6030 /***/ "../node_modules/@babel/runtime/helpers/superPropBase.js":
6031 /*!***************************************************************!*\
6032 !*** ../node_modules/@babel/runtime/helpers/superPropBase.js ***!
6033 \***************************************************************/
6034 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6035
6036 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6037 function _superPropBase(t, o) {
6038 for (; !{}.hasOwnProperty.call(t, o) && null !== (t = getPrototypeOf(t)););
6039 return t;
6040 }
6041 module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
6042
6043 /***/ }),
6044
6045 /***/ "../node_modules/@babel/runtime/helpers/toPrimitive.js":
6046 /*!*************************************************************!*\
6047 !*** ../node_modules/@babel/runtime/helpers/toPrimitive.js ***!
6048 \*************************************************************/
6049 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6050
6051 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6052 function toPrimitive(t, r) {
6053 if ("object" != _typeof(t) || !t) return t;
6054 var e = t[Symbol.toPrimitive];
6055 if (void 0 !== e) {
6056 var i = e.call(t, r || "default");
6057 if ("object" != _typeof(i)) return i;
6058 throw new TypeError("@@toPrimitive must return a primitive value.");
6059 }
6060 return ("string" === r ? String : Number)(t);
6061 }
6062 module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
6063
6064 /***/ }),
6065
6066 /***/ "../node_modules/@babel/runtime/helpers/toPropertyKey.js":
6067 /*!***************************************************************!*\
6068 !*** ../node_modules/@babel/runtime/helpers/toPropertyKey.js ***!
6069 \***************************************************************/
6070 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6071
6072 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6073 var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/toPrimitive.js");
6074 function toPropertyKey(t) {
6075 var i = toPrimitive(t, "string");
6076 return "symbol" == _typeof(i) ? i : i + "";
6077 }
6078 module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
6079
6080 /***/ }),
6081
6082 /***/ "../node_modules/@babel/runtime/helpers/typeof.js":
6083 /*!********************************************************!*\
6084 !*** ../node_modules/@babel/runtime/helpers/typeof.js ***!
6085 \********************************************************/
6086 /***/ ((module) => {
6087
6088 function _typeof(o) {
6089 "@babel/helpers - typeof";
6090
6091 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
6092 return typeof o;
6093 } : function (o) {
6094 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
6095 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
6096 }
6097 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
6098
6099 /***/ }),
6100
6101 /***/ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
6102 /*!****************************************************************************!*\
6103 !*** ../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
6104 \****************************************************************************/
6105 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6106
6107 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
6108 function _unsupportedIterableToArray(r, a) {
6109 if (r) {
6110 if ("string" == typeof r) return arrayLikeToArray(r, a);
6111 var t = {}.toString.call(r).slice(8, -1);
6112 return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? arrayLikeToArray(r, a) : void 0;
6113 }
6114 }
6115 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6116
6117 /***/ }),
6118
6119 /***/ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js":
6120 /*!*****************************************************************!*\
6121 !*** ../node_modules/@babel/runtime/helpers/wrapNativeSuper.js ***!
6122 \*****************************************************************/
6123 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6124
6125 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6126 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6127 var isNativeFunction = __webpack_require__(/*! ./isNativeFunction.js */ "../node_modules/@babel/runtime/helpers/isNativeFunction.js");
6128 var construct = __webpack_require__(/*! ./construct.js */ "../node_modules/@babel/runtime/helpers/construct.js");
6129 function _wrapNativeSuper(t) {
6130 var r = "function" == typeof Map ? new Map() : void 0;
6131 return module.exports = _wrapNativeSuper = function _wrapNativeSuper(t) {
6132 if (null === t || !isNativeFunction(t)) return t;
6133 if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
6134 if (void 0 !== r) {
6135 if (r.has(t)) return r.get(t);
6136 r.set(t, Wrapper);
6137 }
6138 function Wrapper() {
6139 return construct(t, arguments, getPrototypeOf(this).constructor);
6140 }
6141 return Wrapper.prototype = Object.create(t.prototype, {
6142 constructor: {
6143 value: Wrapper,
6144 enumerable: !1,
6145 writable: !0,
6146 configurable: !0
6147 }
6148 }), setPrototypeOf(Wrapper, t);
6149 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _wrapNativeSuper(t);
6150 }
6151 module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
6152
6153 /***/ }),
6154
6155 /***/ "../node_modules/@babel/runtime/regenerator/index.js":
6156 /*!***********************************************************!*\
6157 !*** ../node_modules/@babel/runtime/regenerator/index.js ***!
6158 \***********************************************************/
6159 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6160
6161 // TODO(Babel 8): Remove this file.
6162
6163 var runtime = __webpack_require__(/*! ../helpers/regeneratorRuntime */ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js")();
6164 module.exports = runtime;
6165
6166 // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
6167 try {
6168 regeneratorRuntime = runtime;
6169 } catch (accidentalStrictMode) {
6170 if (typeof globalThis === "object") {
6171 globalThis.regeneratorRuntime = runtime;
6172 } else {
6173 Function("r", "regeneratorRuntime = r")(runtime);
6174 }
6175 }
6176
6177
6178 /***/ }),
6179
6180 /***/ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js":
6181 /*!******************************************************************!*\
6182 !*** ../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js ***!
6183 \******************************************************************/
6184 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6185
6186 "use strict";
6187 __webpack_require__.r(__webpack_exports__);
6188 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6189 /* harmony export */ EnhancerArray: () => (/* binding */ EnhancerArray),
6190 /* harmony export */ MiddlewareArray: () => (/* binding */ MiddlewareArray),
6191 /* harmony export */ SHOULD_AUTOBATCH: () => (/* binding */ SHOULD_AUTOBATCH),
6192 /* harmony export */ TaskAbortError: () => (/* binding */ TaskAbortError),
6193 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.__DO_NOT_USE__ActionTypes),
6194 /* harmony export */ addListener: () => (/* binding */ addListener),
6195 /* harmony export */ applyMiddleware: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware),
6196 /* harmony export */ autoBatchEnhancer: () => (/* binding */ autoBatchEnhancer),
6197 /* harmony export */ bindActionCreators: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.bindActionCreators),
6198 /* harmony export */ clearAllListeners: () => (/* binding */ clearAllListeners),
6199 /* harmony export */ combineReducers: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers),
6200 /* harmony export */ compose: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.compose),
6201 /* harmony export */ configureStore: () => (/* binding */ configureStore),
6202 /* harmony export */ createAction: () => (/* binding */ createAction),
6203 /* harmony export */ createActionCreatorInvariantMiddleware: () => (/* binding */ createActionCreatorInvariantMiddleware),
6204 /* harmony export */ createAsyncThunk: () => (/* binding */ createAsyncThunk),
6205 /* harmony export */ createDraftSafeSelector: () => (/* binding */ createDraftSafeSelector),
6206 /* harmony export */ createEntityAdapter: () => (/* binding */ createEntityAdapter),
6207 /* harmony export */ createImmutableStateInvariantMiddleware: () => (/* binding */ createImmutableStateInvariantMiddleware),
6208 /* harmony export */ createListenerMiddleware: () => (/* binding */ createListenerMiddleware),
6209 /* harmony export */ createNextState: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__["default"]),
6210 /* harmony export */ createReducer: () => (/* binding */ createReducer),
6211 /* harmony export */ createSelector: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector),
6212 /* harmony export */ createSerializableStateInvariantMiddleware: () => (/* binding */ createSerializableStateInvariantMiddleware),
6213 /* harmony export */ createSlice: () => (/* binding */ createSlice),
6214 /* harmony export */ createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.createStore),
6215 /* harmony export */ current: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.current),
6216 /* harmony export */ findNonSerializableValue: () => (/* binding */ findNonSerializableValue),
6217 /* harmony export */ freeze: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.freeze),
6218 /* harmony export */ getDefaultMiddleware: () => (/* binding */ getDefaultMiddleware),
6219 /* harmony export */ getType: () => (/* binding */ getType),
6220 /* harmony export */ isAction: () => (/* binding */ isAction),
6221 /* harmony export */ isActionCreator: () => (/* binding */ isActionCreator),
6222 /* harmony export */ isAllOf: () => (/* binding */ isAllOf),
6223 /* harmony export */ isAnyOf: () => (/* binding */ isAnyOf),
6224 /* harmony export */ isAsyncThunkAction: () => (/* binding */ isAsyncThunkAction),
6225 /* harmony export */ isDraft: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.isDraft),
6226 /* harmony export */ isFluxStandardAction: () => (/* binding */ isFSA),
6227 /* harmony export */ isFulfilled: () => (/* binding */ isFulfilled),
6228 /* harmony export */ isImmutableDefault: () => (/* binding */ isImmutableDefault),
6229 /* harmony export */ isPending: () => (/* binding */ isPending),
6230 /* harmony export */ isPlain: () => (/* binding */ isPlain),
6231 /* harmony export */ isPlainObject: () => (/* binding */ isPlainObject),
6232 /* harmony export */ isRejected: () => (/* binding */ isRejected),
6233 /* harmony export */ isRejectedWithValue: () => (/* binding */ isRejectedWithValue),
6234 /* harmony export */ legacy_createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.legacy_createStore),
6235 /* harmony export */ miniSerializeError: () => (/* binding */ miniSerializeError),
6236 /* harmony export */ nanoid: () => (/* binding */ nanoid),
6237 /* harmony export */ original: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.original),
6238 /* harmony export */ prepareAutoBatched: () => (/* binding */ prepareAutoBatched),
6239 /* harmony export */ removeListener: () => (/* binding */ removeListener),
6240 /* harmony export */ unwrapResult: () => (/* binding */ unwrapResult)
6241 /* harmony export */ });
6242 /* harmony import */ var immer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! immer */ "../node_modules/immer/dist/immer.esm.mjs");
6243 /* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! redux */ "../node_modules/redux/es/redux.js");
6244 /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! reselect */ "../node_modules/reselect/es/index.js");
6245 /* harmony import */ var redux_thunk__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! redux-thunk */ "../node_modules/redux-thunk/es/index.js");
6246 var __extends = (undefined && undefined.__extends) || (function () {
6247 var extendStatics = function (d, b) {
6248 extendStatics = Object.setPrototypeOf ||
6249 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6250 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6251 return extendStatics(d, b);
6252 };
6253 return function (d, b) {
6254 if (typeof b !== "function" && b !== null)
6255 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
6256 extendStatics(d, b);
6257 function __() { this.constructor = d; }
6258 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6259 };
6260 })();
6261 var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
6262 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6263 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6264 function verb(n) { return function (v) { return step([n, v]); }; }
6265 function step(op) {
6266 if (f) throw new TypeError("Generator is already executing.");
6267 while (_) try {
6268 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
6269 if (y = 0, t) op = [op[0] & 2, t.value];
6270 switch (op[0]) {
6271 case 0: case 1: t = op; break;
6272 case 4: _.label++; return { value: op[1], done: false };
6273 case 5: _.label++; y = op[1]; op = [0]; continue;
6274 case 7: op = _.ops.pop(); _.trys.pop(); continue;
6275 default:
6276 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6277 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6278 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6279 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6280 if (t[2]) _.ops.pop();
6281 _.trys.pop(); continue;
6282 }
6283 op = body.call(thisArg, _);
6284 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6285 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6286 }
6287 };
6288 var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
6289 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
6290 to[j] = from[i];
6291 return to;
6292 };
6293 var __defProp = Object.defineProperty;
6294 var __defProps = Object.defineProperties;
6295 var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6296 var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6297 var __hasOwnProp = Object.prototype.hasOwnProperty;
6298 var __propIsEnum = Object.prototype.propertyIsEnumerable;
6299 var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
6300 var __spreadValues = function (a, b) {
6301 for (var prop in b || (b = {}))
6302 if (__hasOwnProp.call(b, prop))
6303 __defNormalProp(a, prop, b[prop]);
6304 if (__getOwnPropSymbols)
6305 for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
6306 var prop = _c[_i];
6307 if (__propIsEnum.call(b, prop))
6308 __defNormalProp(a, prop, b[prop]);
6309 }
6310 return a;
6311 };
6312 var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
6313 var __async = function (__this, __arguments, generator) {
6314 return new Promise(function (resolve, reject) {
6315 var fulfilled = function (value) {
6316 try {
6317 step(generator.next(value));
6318 }
6319 catch (e) {
6320 reject(e);
6321 }
6322 };
6323 var rejected = function (value) {
6324 try {
6325 step(generator.throw(value));
6326 }
6327 catch (e) {
6328 reject(e);
6329 }
6330 };
6331 var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
6332 step((generator = generator.apply(__this, __arguments)).next());
6333 });
6334 };
6335 // src/index.ts
6336
6337
6338
6339
6340 // src/createDraftSafeSelector.ts
6341
6342
6343 var createDraftSafeSelector = function () {
6344 var args = [];
6345 for (var _i = 0; _i < arguments.length; _i++) {
6346 args[_i] = arguments[_i];
6347 }
6348 var selector = reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector.apply(void 0, args);
6349 var wrappedSelector = function (value) {
6350 var rest = [];
6351 for (var _i = 1; _i < arguments.length; _i++) {
6352 rest[_i - 1] = arguments[_i];
6353 }
6354 return selector.apply(void 0, __spreadArray([(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(value) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__.current)(value) : value], rest));
6355 };
6356 return wrappedSelector;
6357 };
6358 // src/configureStore.ts
6359
6360 // src/devtoolsExtension.ts
6361
6362 var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
6363 if (arguments.length === 0)
6364 return void 0;
6365 if (typeof arguments[0] === "object")
6366 return redux__WEBPACK_IMPORTED_MODULE_1__.compose;
6367 return redux__WEBPACK_IMPORTED_MODULE_1__.compose.apply(null, arguments);
6368 };
6369 var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function () {
6370 return function (noop2) {
6371 return noop2;
6372 };
6373 };
6374 // src/isPlainObject.ts
6375 function isPlainObject(value) {
6376 if (typeof value !== "object" || value === null)
6377 return false;
6378 var proto = Object.getPrototypeOf(value);
6379 if (proto === null)
6380 return true;
6381 var baseProto = proto;
6382 while (Object.getPrototypeOf(baseProto) !== null) {
6383 baseProto = Object.getPrototypeOf(baseProto);
6384 }
6385 return proto === baseProto;
6386 }
6387 // src/getDefaultMiddleware.ts
6388
6389 // src/tsHelpers.ts
6390 var hasMatchFunction = function (v) {
6391 return v && typeof v.match === "function";
6392 };
6393 // src/createAction.ts
6394 function createAction(type, prepareAction) {
6395 function actionCreator() {
6396 var args = [];
6397 for (var _i = 0; _i < arguments.length; _i++) {
6398 args[_i] = arguments[_i];
6399 }
6400 if (prepareAction) {
6401 var prepared = prepareAction.apply(void 0, args);
6402 if (!prepared) {
6403 throw new Error("prepareAction did not return an object");
6404 }
6405 return __spreadValues(__spreadValues({
6406 type: type,
6407 payload: prepared.payload
6408 }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
6409 }
6410 return { type: type, payload: args[0] };
6411 }
6412 actionCreator.toString = function () { return "" + type; };
6413 actionCreator.type = type;
6414 actionCreator.match = function (action) { return action.type === type; };
6415 return actionCreator;
6416 }
6417 function isAction(action) {
6418 return isPlainObject(action) && "type" in action;
6419 }
6420 function isActionCreator(action) {
6421 return typeof action === "function" && "type" in action && hasMatchFunction(action);
6422 }
6423 function isFSA(action) {
6424 return isAction(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
6425 }
6426 function isValidKey(key) {
6427 return ["type", "payload", "error", "meta"].indexOf(key) > -1;
6428 }
6429 function getType(actionCreator) {
6430 return "" + actionCreator;
6431 }
6432 // src/actionCreatorInvariantMiddleware.ts
6433 function getMessage(type) {
6434 var splitType = type ? ("" + type).split("/") : [];
6435 var actionName = splitType[splitType.length - 1] || "actionCreator";
6436 return "Detected an action creator with type \"" + (type || "unknown") + "\" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. `dispatch(" + actionName + "())` instead of `dispatch(" + actionName + ")`. This is necessary even if the action has no payload.";
6437 }
6438 function createActionCreatorInvariantMiddleware(options) {
6439 if (options === void 0) { options = {}; }
6440 if (false) // removed by dead control flow
6441 {}
6442 var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
6443 return function () { return function (next) { return function (action) {
6444 if (isActionCreator2(action)) {
6445 console.warn(getMessage(action.type));
6446 }
6447 return next(action);
6448 }; }; };
6449 }
6450 // src/utils.ts
6451
6452 function getTimeMeasureUtils(maxDelay, fnName) {
6453 var elapsed = 0;
6454 return {
6455 measureTime: function (fn) {
6456 var started = Date.now();
6457 try {
6458 return fn();
6459 }
6460 finally {
6461 var finished = Date.now();
6462 elapsed += finished - started;
6463 }
6464 },
6465 warnIfExceeded: function () {
6466 if (elapsed > maxDelay) {
6467 console.warn(fnName + " took " + elapsed + "ms, which is more than the warning threshold of " + maxDelay + "ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.");
6468 }
6469 }
6470 };
6471 }
6472 var MiddlewareArray = /** @class */ (function (_super) {
6473 __extends(MiddlewareArray, _super);
6474 function MiddlewareArray() {
6475 var args = [];
6476 for (var _i = 0; _i < arguments.length; _i++) {
6477 args[_i] = arguments[_i];
6478 }
6479 var _this = _super.apply(this, args) || this;
6480 Object.setPrototypeOf(_this, MiddlewareArray.prototype);
6481 return _this;
6482 }
6483 Object.defineProperty(MiddlewareArray, Symbol.species, {
6484 get: function () {
6485 return MiddlewareArray;
6486 },
6487 enumerable: false,
6488 configurable: true
6489 });
6490 MiddlewareArray.prototype.concat = function () {
6491 var arr = [];
6492 for (var _i = 0; _i < arguments.length; _i++) {
6493 arr[_i] = arguments[_i];
6494 }
6495 return _super.prototype.concat.apply(this, arr);
6496 };
6497 MiddlewareArray.prototype.prepend = function () {
6498 var arr = [];
6499 for (var _i = 0; _i < arguments.length; _i++) {
6500 arr[_i] = arguments[_i];
6501 }
6502 if (arr.length === 1 && Array.isArray(arr[0])) {
6503 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
6504 }
6505 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
6506 };
6507 return MiddlewareArray;
6508 }(Array));
6509 var EnhancerArray = /** @class */ (function (_super) {
6510 __extends(EnhancerArray, _super);
6511 function EnhancerArray() {
6512 var args = [];
6513 for (var _i = 0; _i < arguments.length; _i++) {
6514 args[_i] = arguments[_i];
6515 }
6516 var _this = _super.apply(this, args) || this;
6517 Object.setPrototypeOf(_this, EnhancerArray.prototype);
6518 return _this;
6519 }
6520 Object.defineProperty(EnhancerArray, Symbol.species, {
6521 get: function () {
6522 return EnhancerArray;
6523 },
6524 enumerable: false,
6525 configurable: true
6526 });
6527 EnhancerArray.prototype.concat = function () {
6528 var arr = [];
6529 for (var _i = 0; _i < arguments.length; _i++) {
6530 arr[_i] = arguments[_i];
6531 }
6532 return _super.prototype.concat.apply(this, arr);
6533 };
6534 EnhancerArray.prototype.prepend = function () {
6535 var arr = [];
6536 for (var _i = 0; _i < arguments.length; _i++) {
6537 arr[_i] = arguments[_i];
6538 }
6539 if (arr.length === 1 && Array.isArray(arr[0])) {
6540 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
6541 }
6542 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
6543 };
6544 return EnhancerArray;
6545 }(Array));
6546 function freezeDraftable(val) {
6547 return (0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(val) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(val, function () {
6548 }) : val;
6549 }
6550 // src/immutableStateInvariantMiddleware.ts
6551 var isProduction = "development" === "production";
6552 var prefix = "Invariant failed";
6553 function invariant(condition, message) {
6554 if (condition) {
6555 return;
6556 }
6557 if (isProduction) {
6558 throw new Error(prefix);
6559 }
6560 throw new Error(prefix + ": " + (message || ""));
6561 }
6562 function stringify(obj, serializer, indent, decycler) {
6563 return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
6564 }
6565 function getSerialize(serializer, decycler) {
6566 var stack = [], keys = [];
6567 if (!decycler)
6568 decycler = function (_, value) {
6569 if (stack[0] === value)
6570 return "[Circular ~]";
6571 return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
6572 };
6573 return function (key, value) {
6574 if (stack.length > 0) {
6575 var thisPos = stack.indexOf(this);
6576 ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
6577 ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
6578 if (~stack.indexOf(value))
6579 value = decycler.call(this, key, value);
6580 }
6581 else
6582 stack.push(value);
6583 return serializer == null ? value : serializer.call(this, key, value);
6584 };
6585 }
6586 function isImmutableDefault(value) {
6587 return typeof value !== "object" || value == null || Object.isFrozen(value);
6588 }
6589 function trackForMutations(isImmutable, ignorePaths, obj) {
6590 var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
6591 return {
6592 detectMutations: function () {
6593 return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
6594 }
6595 };
6596 }
6597 function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
6598 if (ignorePaths === void 0) { ignorePaths = []; }
6599 if (path === void 0) { path = ""; }
6600 if (checkedObjects === void 0) { checkedObjects = new Set(); }
6601 var tracked = { value: obj };
6602 if (!isImmutable(obj) && !checkedObjects.has(obj)) {
6603 checkedObjects.add(obj);
6604 tracked.children = {};
6605 for (var key in obj) {
6606 var childPath = path ? path + "." + key : key;
6607 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
6608 continue;
6609 }
6610 tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
6611 }
6612 }
6613 return tracked;
6614 }
6615 function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
6616 if (ignoredPaths === void 0) { ignoredPaths = []; }
6617 if (sameParentRef === void 0) { sameParentRef = false; }
6618 if (path === void 0) { path = ""; }
6619 var prevObj = trackedProperty ? trackedProperty.value : void 0;
6620 var sameRef = prevObj === obj;
6621 if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
6622 return { wasMutated: true, path: path };
6623 }
6624 if (isImmutable(prevObj) || isImmutable(obj)) {
6625 return { wasMutated: false };
6626 }
6627 var keysToDetect = {};
6628 for (var key in trackedProperty.children) {
6629 keysToDetect[key] = true;
6630 }
6631 for (var key in obj) {
6632 keysToDetect[key] = true;
6633 }
6634 var hasIgnoredPaths = ignoredPaths.length > 0;
6635 var _loop_1 = function (key) {
6636 var nestedPath = path ? path + "." + key : key;
6637 if (hasIgnoredPaths) {
6638 var hasMatches = ignoredPaths.some(function (ignored) {
6639 if (ignored instanceof RegExp) {
6640 return ignored.test(nestedPath);
6641 }
6642 return nestedPath === ignored;
6643 });
6644 if (hasMatches) {
6645 return "continue";
6646 }
6647 }
6648 var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
6649 if (result.wasMutated) {
6650 return { value: result };
6651 }
6652 };
6653 for (var key in keysToDetect) {
6654 var state_1 = _loop_1(key);
6655 if (typeof state_1 === "object")
6656 return state_1.value;
6657 }
6658 return { wasMutated: false };
6659 }
6660 function createImmutableStateInvariantMiddleware(options) {
6661 if (options === void 0) { options = {}; }
6662 if (false) // removed by dead control flow
6663 {}
6664 var _c = options.isImmutable, isImmutable = _c === void 0 ? isImmutableDefault : _c, ignoredPaths = options.ignoredPaths, _d = options.warnAfter, warnAfter = _d === void 0 ? 32 : _d, ignore = options.ignore;
6665 ignoredPaths = ignoredPaths || ignore;
6666 var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
6667 return function (_c) {
6668 var getState = _c.getState;
6669 var state = getState();
6670 var tracker = track(state);
6671 var result;
6672 return function (next) { return function (action) {
6673 var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
6674 measureUtils.measureTime(function () {
6675 state = getState();
6676 result = tracker.detectMutations();
6677 tracker = track(state);
6678 invariant(!result.wasMutated, "A state mutation was detected between dispatches, in the path '" + (result.path || "") + "'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
6679 });
6680 var dispatchedAction = next(action);
6681 measureUtils.measureTime(function () {
6682 state = getState();
6683 result = tracker.detectMutations();
6684 tracker = track(state);
6685 result.wasMutated && invariant(!result.wasMutated, "A state mutation was detected inside a dispatch, in the path: " + (result.path || "") + ". Take a look at the reducer(s) handling the action " + stringify(action) + ". (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
6686 });
6687 measureUtils.warnIfExceeded();
6688 return dispatchedAction;
6689 }; };
6690 };
6691 }
6692 // src/serializableStateInvariantMiddleware.ts
6693 function isPlain(val) {
6694 var type = typeof val;
6695 return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
6696 }
6697 function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
6698 if (path === void 0) { path = ""; }
6699 if (isSerializable === void 0) { isSerializable = isPlain; }
6700 if (ignoredPaths === void 0) { ignoredPaths = []; }
6701 var foundNestedSerializable;
6702 if (!isSerializable(value)) {
6703 return {
6704 keyPath: path || "<root>",
6705 value: value
6706 };
6707 }
6708 if (typeof value !== "object" || value === null) {
6709 return false;
6710 }
6711 if (cache == null ? void 0 : cache.has(value))
6712 return false;
6713 var entries = getEntries != null ? getEntries(value) : Object.entries(value);
6714 var hasIgnoredPaths = ignoredPaths.length > 0;
6715 var _loop_2 = function (key, nestedValue) {
6716 var nestedPath = path ? path + "." + key : key;
6717 if (hasIgnoredPaths) {
6718 var hasMatches = ignoredPaths.some(function (ignored) {
6719 if (ignored instanceof RegExp) {
6720 return ignored.test(nestedPath);
6721 }
6722 return nestedPath === ignored;
6723 });
6724 if (hasMatches) {
6725 return "continue";
6726 }
6727 }
6728 if (!isSerializable(nestedValue)) {
6729 return { value: {
6730 keyPath: nestedPath,
6731 value: nestedValue
6732 } };
6733 }
6734 if (typeof nestedValue === "object") {
6735 foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
6736 if (foundNestedSerializable) {
6737 return { value: foundNestedSerializable };
6738 }
6739 }
6740 };
6741 for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
6742 var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
6743 var state_2 = _loop_2(key, nestedValue);
6744 if (typeof state_2 === "object")
6745 return state_2.value;
6746 }
6747 if (cache && isNestedFrozen(value))
6748 cache.add(value);
6749 return false;
6750 }
6751 function isNestedFrozen(value) {
6752 if (!Object.isFrozen(value))
6753 return false;
6754 for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
6755 var nestedValue = _c[_i];
6756 if (typeof nestedValue !== "object" || nestedValue === null)
6757 continue;
6758 if (!isNestedFrozen(nestedValue))
6759 return false;
6760 }
6761 return true;
6762 }
6763 function createSerializableStateInvariantMiddleware(options) {
6764 if (options === void 0) { options = {}; }
6765 if (false) // removed by dead control flow
6766 {}
6767 var _c = options.isSerializable, isSerializable = _c === void 0 ? isPlain : _c, getEntries = options.getEntries, _d = options.ignoredActions, ignoredActions = _d === void 0 ? [] : _d, _e = options.ignoredActionPaths, ignoredActionPaths = _e === void 0 ? ["meta.arg", "meta.baseQueryMeta"] : _e, _f = options.ignoredPaths, ignoredPaths = _f === void 0 ? [] : _f, _g = options.warnAfter, warnAfter = _g === void 0 ? 32 : _g, _h = options.ignoreState, ignoreState = _h === void 0 ? false : _h, _j = options.ignoreActions, ignoreActions = _j === void 0 ? false : _j, _k = options.disableCache, disableCache = _k === void 0 ? false : _k;
6768 var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
6769 return function (storeAPI) { return function (next) { return function (action) {
6770 var result = next(action);
6771 var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
6772 if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
6773 measureUtils.measureTime(function () {
6774 var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
6775 if (foundActionNonSerializableValue) {
6776 var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
6777 console.error("A non-serializable value was detected in an action, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the logic that dispatched this action: ", action, "\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)", "\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)");
6778 }
6779 });
6780 }
6781 if (!ignoreState) {
6782 measureUtils.measureTime(function () {
6783 var state = storeAPI.getState();
6784 var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
6785 if (foundStateNonSerializableValue) {
6786 var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
6787 console.error("A non-serializable value was detected in the state, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the reducer(s) handling this action type: " + action.type + ".\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)");
6788 }
6789 });
6790 measureUtils.warnIfExceeded();
6791 }
6792 return result;
6793 }; }; };
6794 }
6795 // src/getDefaultMiddleware.ts
6796 function isBoolean(x) {
6797 return typeof x === "boolean";
6798 }
6799 function curryGetDefaultMiddleware() {
6800 return function curriedGetDefaultMiddleware(options) {
6801 return getDefaultMiddleware(options);
6802 };
6803 }
6804 function getDefaultMiddleware(options) {
6805 if (options === void 0) { options = {}; }
6806 var _c = options.thunk, thunk = _c === void 0 ? true : _c, _d = options.immutableCheck, immutableCheck = _d === void 0 ? true : _d, _e = options.serializableCheck, serializableCheck = _e === void 0 ? true : _e, _f = options.actionCreatorCheck, actionCreatorCheck = _f === void 0 ? true : _f;
6807 var middlewareArray = new MiddlewareArray();
6808 if (thunk) {
6809 if (isBoolean(thunk)) {
6810 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"]);
6811 }
6812 else {
6813 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"].withExtraArgument(thunk.extraArgument));
6814 }
6815 }
6816 if (true) {
6817 if (immutableCheck) {
6818 var immutableOptions = {};
6819 if (!isBoolean(immutableCheck)) {
6820 immutableOptions = immutableCheck;
6821 }
6822 middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
6823 }
6824 if (serializableCheck) {
6825 var serializableOptions = {};
6826 if (!isBoolean(serializableCheck)) {
6827 serializableOptions = serializableCheck;
6828 }
6829 middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
6830 }
6831 if (actionCreatorCheck) {
6832 var actionCreatorOptions = {};
6833 if (!isBoolean(actionCreatorCheck)) {
6834 actionCreatorOptions = actionCreatorCheck;
6835 }
6836 middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
6837 }
6838 }
6839 return middlewareArray;
6840 }
6841 // src/configureStore.ts
6842 var IS_PRODUCTION = "development" === "production";
6843 function configureStore(options) {
6844 var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
6845 var _c = options || {}, _d = _c.reducer, reducer = _d === void 0 ? void 0 : _d, _e = _c.middleware, middleware = _e === void 0 ? curriedGetDefaultMiddleware() : _e, _f = _c.devTools, devTools = _f === void 0 ? true : _f, _g = _c.preloadedState, preloadedState = _g === void 0 ? void 0 : _g, _h = _c.enhancers, enhancers = _h === void 0 ? void 0 : _h;
6846 var rootReducer;
6847 if (typeof reducer === "function") {
6848 rootReducer = reducer;
6849 }
6850 else if (isPlainObject(reducer)) {
6851 rootReducer = (0,redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers)(reducer);
6852 }
6853 else {
6854 throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
6855 }
6856 var finalMiddleware = middleware;
6857 if (typeof finalMiddleware === "function") {
6858 finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
6859 if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
6860 throw new Error("when using a middleware builder function, an array of middleware must be returned");
6861 }
6862 }
6863 if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
6864 throw new Error("each middleware provided to configureStore must be a function");
6865 }
6866 var middlewareEnhancer = redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware.apply(void 0, finalMiddleware);
6867 var finalCompose = redux__WEBPACK_IMPORTED_MODULE_1__.compose;
6868 if (devTools) {
6869 finalCompose = composeWithDevTools(__spreadValues({
6870 trace: !IS_PRODUCTION
6871 }, typeof devTools === "object" && devTools));
6872 }
6873 var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
6874 var storeEnhancers = defaultEnhancers;
6875 if (Array.isArray(enhancers)) {
6876 storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
6877 }
6878 else if (typeof enhancers === "function") {
6879 storeEnhancers = enhancers(defaultEnhancers);
6880 }
6881 var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
6882 return (0,redux__WEBPACK_IMPORTED_MODULE_1__.createStore)(rootReducer, preloadedState, composedEnhancer);
6883 }
6884 // src/createReducer.ts
6885
6886 // src/mapBuilders.ts
6887 function executeReducerBuilderCallback(builderCallback) {
6888 var actionsMap = {};
6889 var actionMatchers = [];
6890 var defaultCaseReducer;
6891 var builder = {
6892 addCase: function (typeOrActionCreator, reducer) {
6893 if (true) {
6894 if (actionMatchers.length > 0) {
6895 throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
6896 }
6897 if (defaultCaseReducer) {
6898 throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
6899 }
6900 }
6901 var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
6902 if (!type) {
6903 throw new Error("`builder.addCase` cannot be called with an empty action type");
6904 }
6905 if (type in actionsMap) {
6906 throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");
6907 }
6908 actionsMap[type] = reducer;
6909 return builder;
6910 },
6911 addMatcher: function (matcher, reducer) {
6912 if (true) {
6913 if (defaultCaseReducer) {
6914 throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
6915 }
6916 }
6917 actionMatchers.push({ matcher: matcher, reducer: reducer });
6918 return builder;
6919 },
6920 addDefaultCase: function (reducer) {
6921 if (true) {
6922 if (defaultCaseReducer) {
6923 throw new Error("`builder.addDefaultCase` can only be called once");
6924 }
6925 }
6926 defaultCaseReducer = reducer;
6927 return builder;
6928 }
6929 };
6930 builderCallback(builder);
6931 return [actionsMap, actionMatchers, defaultCaseReducer];
6932 }
6933 // src/createReducer.ts
6934 function isStateFunction(x) {
6935 return typeof x === "function";
6936 }
6937 var hasWarnedAboutObjectNotation = false;
6938 function createReducer(initialState, mapOrBuilderCallback, actionMatchers, defaultCaseReducer) {
6939 if (actionMatchers === void 0) { actionMatchers = []; }
6940 if (true) {
6941 if (typeof mapOrBuilderCallback === "object") {
6942 if (!hasWarnedAboutObjectNotation) {
6943 hasWarnedAboutObjectNotation = true;
6944 console.warn("The object notation for `createReducer` is deprecated, and will be removed in RTK 2.0. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");
6945 }
6946 }
6947 }
6948 var _c = typeof mapOrBuilderCallback === "function" ? executeReducerBuilderCallback(mapOrBuilderCallback) : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer], actionsMap = _c[0], finalActionMatchers = _c[1], finalDefaultCaseReducer = _c[2];
6949 var getInitialState;
6950 if (isStateFunction(initialState)) {
6951 getInitialState = function () { return freezeDraftable(initialState()); };
6952 }
6953 else {
6954 var frozenInitialState_1 = freezeDraftable(initialState);
6955 getInitialState = function () { return frozenInitialState_1; };
6956 }
6957 function reducer(state, action) {
6958 if (state === void 0) { state = getInitialState(); }
6959 var caseReducers = __spreadArray([
6960 actionsMap[action.type]
6961 ], finalActionMatchers.filter(function (_c) {
6962 var matcher = _c.matcher;
6963 return matcher(action);
6964 }).map(function (_c) {
6965 var reducer2 = _c.reducer;
6966 return reducer2;
6967 }));
6968 if (caseReducers.filter(function (cr) { return !!cr; }).length === 0) {
6969 caseReducers = [finalDefaultCaseReducer];
6970 }
6971 return caseReducers.reduce(function (previousState, caseReducer) {
6972 if (caseReducer) {
6973 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(previousState)) {
6974 var draft = previousState;
6975 var result = caseReducer(draft, action);
6976 if (result === void 0) {
6977 return previousState;
6978 }
6979 return result;
6980 }
6981 else if (!(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(previousState)) {
6982 var result = caseReducer(previousState, action);
6983 if (result === void 0) {
6984 if (previousState === null) {
6985 return previousState;
6986 }
6987 throw Error("A case reducer on a non-draftable value must not return undefined");
6988 }
6989 return result;
6990 }
6991 else {
6992 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(previousState, function (draft) {
6993 return caseReducer(draft, action);
6994 });
6995 }
6996 }
6997 return previousState;
6998 }, state);
6999 }
7000 reducer.getInitialState = getInitialState;
7001 return reducer;
7002 }
7003 // src/createSlice.ts
7004 var hasWarnedAboutObjectNotation2 = false;
7005 function getType2(slice, actionKey) {
7006 return slice + "/" + actionKey;
7007 }
7008 function createSlice(options) {
7009 var name = options.name;
7010 if (!name) {
7011 throw new Error("`name` is a required option for createSlice");
7012 }
7013 if (typeof process !== "undefined" && "development" === "development") {
7014 if (options.initialState === void 0) {
7015 console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
7016 }
7017 }
7018 var initialState = typeof options.initialState == "function" ? options.initialState : freezeDraftable(options.initialState);
7019 var reducers = options.reducers || {};
7020 var reducerNames = Object.keys(reducers);
7021 var sliceCaseReducersByName = {};
7022 var sliceCaseReducersByType = {};
7023 var actionCreators = {};
7024 reducerNames.forEach(function (reducerName) {
7025 var maybeReducerWithPrepare = reducers[reducerName];
7026 var type = getType2(name, reducerName);
7027 var caseReducer;
7028 var prepareCallback;
7029 if ("reducer" in maybeReducerWithPrepare) {
7030 caseReducer = maybeReducerWithPrepare.reducer;
7031 prepareCallback = maybeReducerWithPrepare.prepare;
7032 }
7033 else {
7034 caseReducer = maybeReducerWithPrepare;
7035 }
7036 sliceCaseReducersByName[reducerName] = caseReducer;
7037 sliceCaseReducersByType[type] = caseReducer;
7038 actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type);
7039 });
7040 function buildReducer() {
7041 if (true) {
7042 if (typeof options.extraReducers === "object") {
7043 if (!hasWarnedAboutObjectNotation2) {
7044 hasWarnedAboutObjectNotation2 = true;
7045 console.warn("The object notation for `createSlice.extraReducers` is deprecated, and will be removed in RTK 2.0. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");
7046 }
7047 }
7048 }
7049 var _c = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers], _d = _c[0], extraReducers = _d === void 0 ? {} : _d, _e = _c[1], actionMatchers = _e === void 0 ? [] : _e, _f = _c[2], defaultCaseReducer = _f === void 0 ? void 0 : _f;
7050 var finalCaseReducers = __spreadValues(__spreadValues({}, extraReducers), sliceCaseReducersByType);
7051 return createReducer(initialState, function (builder) {
7052 for (var key in finalCaseReducers) {
7053 builder.addCase(key, finalCaseReducers[key]);
7054 }
7055 for (var _i = 0, actionMatchers_1 = actionMatchers; _i < actionMatchers_1.length; _i++) {
7056 var m = actionMatchers_1[_i];
7057 builder.addMatcher(m.matcher, m.reducer);
7058 }
7059 if (defaultCaseReducer) {
7060 builder.addDefaultCase(defaultCaseReducer);
7061 }
7062 });
7063 }
7064 var _reducer;
7065 return {
7066 name: name,
7067 reducer: function (state, action) {
7068 if (!_reducer)
7069 _reducer = buildReducer();
7070 return _reducer(state, action);
7071 },
7072 actions: actionCreators,
7073 caseReducers: sliceCaseReducersByName,
7074 getInitialState: function () {
7075 if (!_reducer)
7076 _reducer = buildReducer();
7077 return _reducer.getInitialState();
7078 }
7079 };
7080 }
7081 // src/entities/entity_state.ts
7082 function getInitialEntityState() {
7083 return {
7084 ids: [],
7085 entities: {}
7086 };
7087 }
7088 function createInitialStateFactory() {
7089 function getInitialState(additionalState) {
7090 if (additionalState === void 0) { additionalState = {}; }
7091 return Object.assign(getInitialEntityState(), additionalState);
7092 }
7093 return { getInitialState: getInitialState };
7094 }
7095 // src/entities/state_selectors.ts
7096 function createSelectorsFactory() {
7097 function getSelectors(selectState) {
7098 var selectIds = function (state) { return state.ids; };
7099 var selectEntities = function (state) { return state.entities; };
7100 var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) { return ids.map(function (id) { return entities[id]; }); });
7101 var selectId = function (_, id) { return id; };
7102 var selectById = function (entities, id) { return entities[id]; };
7103 var selectTotal = createDraftSafeSelector(selectIds, function (ids) { return ids.length; });
7104 if (!selectState) {
7105 return {
7106 selectIds: selectIds,
7107 selectEntities: selectEntities,
7108 selectAll: selectAll,
7109 selectTotal: selectTotal,
7110 selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
7111 };
7112 }
7113 var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
7114 return {
7115 selectIds: createDraftSafeSelector(selectState, selectIds),
7116 selectEntities: selectGlobalizedEntities,
7117 selectAll: createDraftSafeSelector(selectState, selectAll),
7118 selectTotal: createDraftSafeSelector(selectState, selectTotal),
7119 selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
7120 };
7121 }
7122 return { getSelectors: getSelectors };
7123 }
7124 // src/entities/state_adapter.ts
7125
7126 function createSingleArgumentStateOperator(mutator) {
7127 var operator = createStateOperator(function (_, state) { return mutator(state); });
7128 return function operation(state) {
7129 return operator(state, void 0);
7130 };
7131 }
7132 function createStateOperator(mutator) {
7133 return function operation(state, arg) {
7134 function isPayloadActionArgument(arg2) {
7135 return isFSA(arg2);
7136 }
7137 var runMutator = function (draft) {
7138 if (isPayloadActionArgument(arg)) {
7139 mutator(arg.payload, draft);
7140 }
7141 else {
7142 mutator(arg, draft);
7143 }
7144 };
7145 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(state)) {
7146 runMutator(state);
7147 return state;
7148 }
7149 else {
7150 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(state, runMutator);
7151 }
7152 };
7153 }
7154 // src/entities/utils.ts
7155 function selectIdValue(entity, selectId) {
7156 var key = selectId(entity);
7157 if ( true && key === void 0) {
7158 console.warn("The entity passed to the `selectId` implementation returned undefined.", "You should probably provide your own `selectId` implementation.", "The entity that was passed:", entity, "The `selectId` implementation:", selectId.toString());
7159 }
7160 return key;
7161 }
7162 function ensureEntitiesArray(entities) {
7163 if (!Array.isArray(entities)) {
7164 entities = Object.values(entities);
7165 }
7166 return entities;
7167 }
7168 function splitAddedUpdatedEntities(newEntities, selectId, state) {
7169 newEntities = ensureEntitiesArray(newEntities);
7170 var added = [];
7171 var updated = [];
7172 for (var _i = 0, newEntities_1 = newEntities; _i < newEntities_1.length; _i++) {
7173 var entity = newEntities_1[_i];
7174 var id = selectIdValue(entity, selectId);
7175 if (id in state.entities) {
7176 updated.push({ id: id, changes: entity });
7177 }
7178 else {
7179 added.push(entity);
7180 }
7181 }
7182 return [added, updated];
7183 }
7184 // src/entities/unsorted_state_adapter.ts
7185 function createUnsortedStateAdapter(selectId) {
7186 function addOneMutably(entity, state) {
7187 var key = selectIdValue(entity, selectId);
7188 if (key in state.entities) {
7189 return;
7190 }
7191 state.ids.push(key);
7192 state.entities[key] = entity;
7193 }
7194 function addManyMutably(newEntities, state) {
7195 newEntities = ensureEntitiesArray(newEntities);
7196 for (var _i = 0, newEntities_2 = newEntities; _i < newEntities_2.length; _i++) {
7197 var entity = newEntities_2[_i];
7198 addOneMutably(entity, state);
7199 }
7200 }
7201 function setOneMutably(entity, state) {
7202 var key = selectIdValue(entity, selectId);
7203 if (!(key in state.entities)) {
7204 state.ids.push(key);
7205 }
7206 state.entities[key] = entity;
7207 }
7208 function setManyMutably(newEntities, state) {
7209 newEntities = ensureEntitiesArray(newEntities);
7210 for (var _i = 0, newEntities_3 = newEntities; _i < newEntities_3.length; _i++) {
7211 var entity = newEntities_3[_i];
7212 setOneMutably(entity, state);
7213 }
7214 }
7215 function setAllMutably(newEntities, state) {
7216 newEntities = ensureEntitiesArray(newEntities);
7217 state.ids = [];
7218 state.entities = {};
7219 addManyMutably(newEntities, state);
7220 }
7221 function removeOneMutably(key, state) {
7222 return removeManyMutably([key], state);
7223 }
7224 function removeManyMutably(keys, state) {
7225 var didMutate = false;
7226 keys.forEach(function (key) {
7227 if (key in state.entities) {
7228 delete state.entities[key];
7229 didMutate = true;
7230 }
7231 });
7232 if (didMutate) {
7233 state.ids = state.ids.filter(function (id) { return id in state.entities; });
7234 }
7235 }
7236 function removeAllMutably(state) {
7237 Object.assign(state, {
7238 ids: [],
7239 entities: {}
7240 });
7241 }
7242 function takeNewKey(keys, update, state) {
7243 var original2 = state.entities[update.id];
7244 var updated = Object.assign({}, original2, update.changes);
7245 var newKey = selectIdValue(updated, selectId);
7246 var hasNewKey = newKey !== update.id;
7247 if (hasNewKey) {
7248 keys[update.id] = newKey;
7249 delete state.entities[update.id];
7250 }
7251 state.entities[newKey] = updated;
7252 return hasNewKey;
7253 }
7254 function updateOneMutably(update, state) {
7255 return updateManyMutably([update], state);
7256 }
7257 function updateManyMutably(updates, state) {
7258 var newKeys = {};
7259 var updatesPerEntity = {};
7260 updates.forEach(function (update) {
7261 if (update.id in state.entities) {
7262 updatesPerEntity[update.id] = {
7263 id: update.id,
7264 changes: __spreadValues(__spreadValues({}, updatesPerEntity[update.id] ? updatesPerEntity[update.id].changes : null), update.changes)
7265 };
7266 }
7267 });
7268 updates = Object.values(updatesPerEntity);
7269 var didMutateEntities = updates.length > 0;
7270 if (didMutateEntities) {
7271 var didMutateIds = updates.filter(function (update) { return takeNewKey(newKeys, update, state); }).length > 0;
7272 if (didMutateIds) {
7273 state.ids = Object.keys(state.entities);
7274 }
7275 }
7276 }
7277 function upsertOneMutably(entity, state) {
7278 return upsertManyMutably([entity], state);
7279 }
7280 function upsertManyMutably(newEntities, state) {
7281 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7282 updateManyMutably(updated, state);
7283 addManyMutably(added, state);
7284 }
7285 return {
7286 removeAll: createSingleArgumentStateOperator(removeAllMutably),
7287 addOne: createStateOperator(addOneMutably),
7288 addMany: createStateOperator(addManyMutably),
7289 setOne: createStateOperator(setOneMutably),
7290 setMany: createStateOperator(setManyMutably),
7291 setAll: createStateOperator(setAllMutably),
7292 updateOne: createStateOperator(updateOneMutably),
7293 updateMany: createStateOperator(updateManyMutably),
7294 upsertOne: createStateOperator(upsertOneMutably),
7295 upsertMany: createStateOperator(upsertManyMutably),
7296 removeOne: createStateOperator(removeOneMutably),
7297 removeMany: createStateOperator(removeManyMutably)
7298 };
7299 }
7300 // src/entities/sorted_state_adapter.ts
7301 function createSortedStateAdapter(selectId, sort) {
7302 var _c = createUnsortedStateAdapter(selectId), removeOne = _c.removeOne, removeMany = _c.removeMany, removeAll = _c.removeAll;
7303 function addOneMutably(entity, state) {
7304 return addManyMutably([entity], state);
7305 }
7306 function addManyMutably(newEntities, state) {
7307 newEntities = ensureEntitiesArray(newEntities);
7308 var models = newEntities.filter(function (model) { return !(selectIdValue(model, selectId) in state.entities); });
7309 if (models.length !== 0) {
7310 merge(models, state);
7311 }
7312 }
7313 function setOneMutably(entity, state) {
7314 return setManyMutably([entity], state);
7315 }
7316 function setManyMutably(newEntities, state) {
7317 newEntities = ensureEntitiesArray(newEntities);
7318 if (newEntities.length !== 0) {
7319 merge(newEntities, state);
7320 }
7321 }
7322 function setAllMutably(newEntities, state) {
7323 newEntities = ensureEntitiesArray(newEntities);
7324 state.entities = {};
7325 state.ids = [];
7326 addManyMutably(newEntities, state);
7327 }
7328 function updateOneMutably(update, state) {
7329 return updateManyMutably([update], state);
7330 }
7331 function updateManyMutably(updates, state) {
7332 var appliedUpdates = false;
7333 for (var _i = 0, updates_1 = updates; _i < updates_1.length; _i++) {
7334 var update = updates_1[_i];
7335 var entity = state.entities[update.id];
7336 if (!entity) {
7337 continue;
7338 }
7339 appliedUpdates = true;
7340 Object.assign(entity, update.changes);
7341 var newId = selectId(entity);
7342 if (update.id !== newId) {
7343 delete state.entities[update.id];
7344 state.entities[newId] = entity;
7345 }
7346 }
7347 if (appliedUpdates) {
7348 resortEntities(state);
7349 }
7350 }
7351 function upsertOneMutably(entity, state) {
7352 return upsertManyMutably([entity], state);
7353 }
7354 function upsertManyMutably(newEntities, state) {
7355 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7356 updateManyMutably(updated, state);
7357 addManyMutably(added, state);
7358 }
7359 function areArraysEqual(a, b) {
7360 if (a.length !== b.length) {
7361 return false;
7362 }
7363 for (var i = 0; i < a.length && i < b.length; i++) {
7364 if (a[i] === b[i]) {
7365 continue;
7366 }
7367 return false;
7368 }
7369 return true;
7370 }
7371 function merge(models, state) {
7372 models.forEach(function (model) {
7373 state.entities[selectId(model)] = model;
7374 });
7375 resortEntities(state);
7376 }
7377 function resortEntities(state) {
7378 var allEntities = Object.values(state.entities);
7379 allEntities.sort(sort);
7380 var newSortedIds = allEntities.map(selectId);
7381 var ids = state.ids;
7382 if (!areArraysEqual(ids, newSortedIds)) {
7383 state.ids = newSortedIds;
7384 }
7385 }
7386 return {
7387 removeOne: removeOne,
7388 removeMany: removeMany,
7389 removeAll: removeAll,
7390 addOne: createStateOperator(addOneMutably),
7391 updateOne: createStateOperator(updateOneMutably),
7392 upsertOne: createStateOperator(upsertOneMutably),
7393 setOne: createStateOperator(setOneMutably),
7394 setMany: createStateOperator(setManyMutably),
7395 setAll: createStateOperator(setAllMutably),
7396 addMany: createStateOperator(addManyMutably),
7397 updateMany: createStateOperator(updateManyMutably),
7398 upsertMany: createStateOperator(upsertManyMutably)
7399 };
7400 }
7401 // src/entities/create_adapter.ts
7402 function createEntityAdapter(options) {
7403 if (options === void 0) { options = {}; }
7404 var _c = __spreadValues({
7405 sortComparer: false,
7406 selectId: function (instance) { return instance.id; }
7407 }, options), selectId = _c.selectId, sortComparer = _c.sortComparer;
7408 var stateFactory = createInitialStateFactory();
7409 var selectorsFactory = createSelectorsFactory();
7410 var stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
7411 return __spreadValues(__spreadValues(__spreadValues({
7412 selectId: selectId,
7413 sortComparer: sortComparer
7414 }, stateFactory), selectorsFactory), stateAdapter);
7415 }
7416 // src/nanoid.ts
7417 var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
7418 var nanoid = function (size) {
7419 if (size === void 0) { size = 21; }
7420 var id = "";
7421 var i = size;
7422 while (i--) {
7423 id += urlAlphabet[Math.random() * 64 | 0];
7424 }
7425 return id;
7426 };
7427 // src/createAsyncThunk.ts
7428 var commonProperties = [
7429 "name",
7430 "message",
7431 "stack",
7432 "code"
7433 ];
7434 var RejectWithValue = /** @class */ (function () {
7435 function RejectWithValue(payload, meta) {
7436 this.payload = payload;
7437 this.meta = meta;
7438 }
7439 return RejectWithValue;
7440 }());
7441 var FulfillWithMeta = /** @class */ (function () {
7442 function FulfillWithMeta(payload, meta) {
7443 this.payload = payload;
7444 this.meta = meta;
7445 }
7446 return FulfillWithMeta;
7447 }());
7448 var miniSerializeError = function (value) {
7449 if (typeof value === "object" && value !== null) {
7450 var simpleError = {};
7451 for (var _i = 0, commonProperties_1 = commonProperties; _i < commonProperties_1.length; _i++) {
7452 var property = commonProperties_1[_i];
7453 if (typeof value[property] === "string") {
7454 simpleError[property] = value[property];
7455 }
7456 }
7457 return simpleError;
7458 }
7459 return { message: String(value) };
7460 };
7461 var createAsyncThunk = (function () {
7462 function createAsyncThunk2(typePrefix, payloadCreator, options) {
7463 var fulfilled = createAction(typePrefix + "/fulfilled", function (payload, requestId, arg, meta) { return ({
7464 payload: payload,
7465 meta: __spreadProps(__spreadValues({}, meta || {}), {
7466 arg: arg,
7467 requestId: requestId,
7468 requestStatus: "fulfilled"
7469 })
7470 }); });
7471 var pending = createAction(typePrefix + "/pending", function (requestId, arg, meta) { return ({
7472 payload: void 0,
7473 meta: __spreadProps(__spreadValues({}, meta || {}), {
7474 arg: arg,
7475 requestId: requestId,
7476 requestStatus: "pending"
7477 })
7478 }); });
7479 var rejected = createAction(typePrefix + "/rejected", function (error, requestId, arg, payload, meta) { return ({
7480 payload: payload,
7481 error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
7482 meta: __spreadProps(__spreadValues({}, meta || {}), {
7483 arg: arg,
7484 requestId: requestId,
7485 rejectedWithValue: !!payload,
7486 requestStatus: "rejected",
7487 aborted: (error == null ? void 0 : error.name) === "AbortError",
7488 condition: (error == null ? void 0 : error.name) === "ConditionError"
7489 })
7490 }); });
7491 var displayedWarning = false;
7492 var AC = typeof AbortController !== "undefined" ? AbortController : /** @class */ (function () {
7493 function class_1() {
7494 this.signal = {
7495 aborted: false,
7496 addEventListener: function () {
7497 },
7498 dispatchEvent: function () {
7499 return false;
7500 },
7501 onabort: function () {
7502 },
7503 removeEventListener: function () {
7504 },
7505 reason: void 0,
7506 throwIfAborted: function () {
7507 }
7508 };
7509 }
7510 class_1.prototype.abort = function () {
7511 if (true) {
7512 if (!displayedWarning) {
7513 displayedWarning = true;
7514 console.info("This platform does not implement AbortController. \nIf you want to use the AbortController to react to `abort` events, please consider importing a polyfill like 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'.");
7515 }
7516 }
7517 };
7518 return class_1;
7519 }());
7520 function actionCreator(arg) {
7521 return function (dispatch, getState, extra) {
7522 var requestId = (options == null ? void 0 : options.idGenerator) ? options.idGenerator(arg) : nanoid();
7523 var abortController = new AC();
7524 var abortReason;
7525 var started = false;
7526 function abort(reason) {
7527 abortReason = reason;
7528 abortController.abort();
7529 }
7530 var promise2 = function () {
7531 return __async(this, null, function () {
7532 var _a, _b, finalAction, conditionResult, abortedPromise, err_1, skipDispatch;
7533 return __generator(this, function (_c) {
7534 switch (_c.label) {
7535 case 0:
7536 _c.trys.push([0, 4, , 5]);
7537 conditionResult = (_a = options == null ? void 0 : options.condition) == null ? void 0 : _a.call(options, arg, { getState: getState, extra: extra });
7538 if (!isThenable(conditionResult)) return [3 /*break*/, 2];
7539 return [4 /*yield*/, conditionResult];
7540 case 1:
7541 conditionResult = _c.sent();
7542 _c.label = 2;
7543 case 2:
7544 if (conditionResult === false || abortController.signal.aborted) {
7545 throw {
7546 name: "ConditionError",
7547 message: "Aborted due to condition callback returning false."
7548 };
7549 }
7550 started = true;
7551 abortedPromise = new Promise(function (_, reject) { return abortController.signal.addEventListener("abort", function () { return reject({
7552 name: "AbortError",
7553 message: abortReason || "Aborted"
7554 }); }); });
7555 dispatch(pending(requestId, arg, (_b = options == null ? void 0 : options.getPendingMeta) == null ? void 0 : _b.call(options, { requestId: requestId, arg: arg }, { getState: getState, extra: extra })));
7556 return [4 /*yield*/, Promise.race([
7557 abortedPromise,
7558 Promise.resolve(payloadCreator(arg, {
7559 dispatch: dispatch,
7560 getState: getState,
7561 extra: extra,
7562 requestId: requestId,
7563 signal: abortController.signal,
7564 abort: abort,
7565 rejectWithValue: function (value, meta) {
7566 return new RejectWithValue(value, meta);
7567 },
7568 fulfillWithValue: function (value, meta) {
7569 return new FulfillWithMeta(value, meta);
7570 }
7571 })).then(function (result) {
7572 if (result instanceof RejectWithValue) {
7573 throw result;
7574 }
7575 if (result instanceof FulfillWithMeta) {
7576 return fulfilled(result.payload, requestId, arg, result.meta);
7577 }
7578 return fulfilled(result, requestId, arg);
7579 })
7580 ])];
7581 case 3:
7582 finalAction = _c.sent();
7583 return [3 /*break*/, 5];
7584 case 4:
7585 err_1 = _c.sent();
7586 finalAction = err_1 instanceof RejectWithValue ? rejected(null, requestId, arg, err_1.payload, err_1.meta) : rejected(err_1, requestId, arg);
7587 return [3 /*break*/, 5];
7588 case 5:
7589 skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
7590 if (!skipDispatch) {
7591 dispatch(finalAction);
7592 }
7593 return [2 /*return*/, finalAction];
7594 }
7595 });
7596 });
7597 }();
7598 return Object.assign(promise2, {
7599 abort: abort,
7600 requestId: requestId,
7601 arg: arg,
7602 unwrap: function () {
7603 return promise2.then(unwrapResult);
7604 }
7605 });
7606 };
7607 }
7608 return Object.assign(actionCreator, {
7609 pending: pending,
7610 rejected: rejected,
7611 fulfilled: fulfilled,
7612 typePrefix: typePrefix
7613 });
7614 }
7615 createAsyncThunk2.withTypes = function () { return createAsyncThunk2; };
7616 return createAsyncThunk2;
7617 })();
7618 function unwrapResult(action) {
7619 if (action.meta && action.meta.rejectedWithValue) {
7620 throw action.payload;
7621 }
7622 if (action.error) {
7623 throw action.error;
7624 }
7625 return action.payload;
7626 }
7627 function isThenable(value) {
7628 return value !== null && typeof value === "object" && typeof value.then === "function";
7629 }
7630 // src/matchers.ts
7631 var matches = function (matcher, action) {
7632 if (hasMatchFunction(matcher)) {
7633 return matcher.match(action);
7634 }
7635 else {
7636 return matcher(action);
7637 }
7638 };
7639 function isAnyOf() {
7640 var matchers = [];
7641 for (var _i = 0; _i < arguments.length; _i++) {
7642 matchers[_i] = arguments[_i];
7643 }
7644 return function (action) {
7645 return matchers.some(function (matcher) { return matches(matcher, action); });
7646 };
7647 }
7648 function isAllOf() {
7649 var matchers = [];
7650 for (var _i = 0; _i < arguments.length; _i++) {
7651 matchers[_i] = arguments[_i];
7652 }
7653 return function (action) {
7654 return matchers.every(function (matcher) { return matches(matcher, action); });
7655 };
7656 }
7657 function hasExpectedRequestMetadata(action, validStatus) {
7658 if (!action || !action.meta)
7659 return false;
7660 var hasValidRequestId = typeof action.meta.requestId === "string";
7661 var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
7662 return hasValidRequestId && hasValidRequestStatus;
7663 }
7664 function isAsyncThunkArray(a) {
7665 return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
7666 }
7667 function isPending() {
7668 var asyncThunks = [];
7669 for (var _i = 0; _i < arguments.length; _i++) {
7670 asyncThunks[_i] = arguments[_i];
7671 }
7672 if (asyncThunks.length === 0) {
7673 return function (action) { return hasExpectedRequestMetadata(action, ["pending"]); };
7674 }
7675 if (!isAsyncThunkArray(asyncThunks)) {
7676 return isPending()(asyncThunks[0]);
7677 }
7678 return function (action) {
7679 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.pending; });
7680 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7681 return combinedMatcher(action);
7682 };
7683 }
7684 function isRejected() {
7685 var asyncThunks = [];
7686 for (var _i = 0; _i < arguments.length; _i++) {
7687 asyncThunks[_i] = arguments[_i];
7688 }
7689 if (asyncThunks.length === 0) {
7690 return function (action) { return hasExpectedRequestMetadata(action, ["rejected"]); };
7691 }
7692 if (!isAsyncThunkArray(asyncThunks)) {
7693 return isRejected()(asyncThunks[0]);
7694 }
7695 return function (action) {
7696 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.rejected; });
7697 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7698 return combinedMatcher(action);
7699 };
7700 }
7701 function isRejectedWithValue() {
7702 var asyncThunks = [];
7703 for (var _i = 0; _i < arguments.length; _i++) {
7704 asyncThunks[_i] = arguments[_i];
7705 }
7706 var hasFlag = function (action) {
7707 return action && action.meta && action.meta.rejectedWithValue;
7708 };
7709 if (asyncThunks.length === 0) {
7710 return function (action) {
7711 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
7712 return combinedMatcher(action);
7713 };
7714 }
7715 if (!isAsyncThunkArray(asyncThunks)) {
7716 return isRejectedWithValue()(asyncThunks[0]);
7717 }
7718 return function (action) {
7719 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
7720 return combinedMatcher(action);
7721 };
7722 }
7723 function isFulfilled() {
7724 var asyncThunks = [];
7725 for (var _i = 0; _i < arguments.length; _i++) {
7726 asyncThunks[_i] = arguments[_i];
7727 }
7728 if (asyncThunks.length === 0) {
7729 return function (action) { return hasExpectedRequestMetadata(action, ["fulfilled"]); };
7730 }
7731 if (!isAsyncThunkArray(asyncThunks)) {
7732 return isFulfilled()(asyncThunks[0]);
7733 }
7734 return function (action) {
7735 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.fulfilled; });
7736 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7737 return combinedMatcher(action);
7738 };
7739 }
7740 function isAsyncThunkAction() {
7741 var asyncThunks = [];
7742 for (var _i = 0; _i < arguments.length; _i++) {
7743 asyncThunks[_i] = arguments[_i];
7744 }
7745 if (asyncThunks.length === 0) {
7746 return function (action) { return hasExpectedRequestMetadata(action, ["pending", "fulfilled", "rejected"]); };
7747 }
7748 if (!isAsyncThunkArray(asyncThunks)) {
7749 return isAsyncThunkAction()(asyncThunks[0]);
7750 }
7751 return function (action) {
7752 var matchers = [];
7753 for (var _i = 0, asyncThunks_1 = asyncThunks; _i < asyncThunks_1.length; _i++) {
7754 var asyncThunk = asyncThunks_1[_i];
7755 matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
7756 }
7757 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7758 return combinedMatcher(action);
7759 };
7760 }
7761 // src/listenerMiddleware/utils.ts
7762 var assertFunction = function (func, expected) {
7763 if (typeof func !== "function") {
7764 throw new TypeError(expected + " is not a function");
7765 }
7766 };
7767 var noop = function () {
7768 };
7769 var catchRejection = function (promise2, onError) {
7770 if (onError === void 0) { onError = noop; }
7771 promise2.catch(onError);
7772 return promise2;
7773 };
7774 var addAbortSignalListener = function (abortSignal, callback) {
7775 abortSignal.addEventListener("abort", callback, { once: true });
7776 return function () { return abortSignal.removeEventListener("abort", callback); };
7777 };
7778 var abortControllerWithReason = function (abortController, reason) {
7779 var signal = abortController.signal;
7780 if (signal.aborted) {
7781 return;
7782 }
7783 if (!("reason" in signal)) {
7784 Object.defineProperty(signal, "reason", {
7785 enumerable: true,
7786 value: reason,
7787 configurable: true,
7788 writable: true
7789 });
7790 }
7791 ;
7792 abortController.abort(reason);
7793 };
7794 // src/listenerMiddleware/exceptions.ts
7795 var task = "task";
7796 var listener = "listener";
7797 var completed = "completed";
7798 var cancelled = "cancelled";
7799 var taskCancelled = "task-" + cancelled;
7800 var taskCompleted = "task-" + completed;
7801 var listenerCancelled = listener + "-" + cancelled;
7802 var listenerCompleted = listener + "-" + completed;
7803 var TaskAbortError = /** @class */ (function () {
7804 function TaskAbortError(code) {
7805 this.code = code;
7806 this.name = "TaskAbortError";
7807 this.message = task + " " + cancelled + " (reason: " + code + ")";
7808 }
7809 return TaskAbortError;
7810 }());
7811 // src/listenerMiddleware/task.ts
7812 var validateActive = function (signal) {
7813 if (signal.aborted) {
7814 throw new TaskAbortError(signal.reason);
7815 }
7816 };
7817 function raceWithSignal(signal, promise2) {
7818 var cleanup = noop;
7819 return new Promise(function (resolve, reject) {
7820 var notifyRejection = function () { return reject(new TaskAbortError(signal.reason)); };
7821 if (signal.aborted) {
7822 notifyRejection();
7823 return;
7824 }
7825 cleanup = addAbortSignalListener(signal, notifyRejection);
7826 promise2.finally(function () { return cleanup(); }).then(resolve, reject);
7827 }).finally(function () {
7828 cleanup = noop;
7829 });
7830 }
7831 var runTask = function (task2, cleanUp) { return __async(void 0, null, function () {
7832 var value, error_1;
7833 return __generator(this, function (_c) {
7834 switch (_c.label) {
7835 case 0:
7836 _c.trys.push([0, 3, 4, 5]);
7837 return [4 /*yield*/, Promise.resolve()];
7838 case 1:
7839 _c.sent();
7840 return [4 /*yield*/, task2()];
7841 case 2:
7842 value = _c.sent();
7843 return [2 /*return*/, {
7844 status: "ok",
7845 value: value
7846 }];
7847 case 3:
7848 error_1 = _c.sent();
7849 return [2 /*return*/, {
7850 status: error_1 instanceof TaskAbortError ? "cancelled" : "rejected",
7851 error: error_1
7852 }];
7853 case 4:
7854 cleanUp == null ? void 0 : cleanUp();
7855 return [7 /*endfinally*/];
7856 case 5: return [2 /*return*/];
7857 }
7858 });
7859 }); };
7860 var createPause = function (signal) {
7861 return function (promise2) {
7862 return catchRejection(raceWithSignal(signal, promise2).then(function (output) {
7863 validateActive(signal);
7864 return output;
7865 }));
7866 };
7867 };
7868 var createDelay = function (signal) {
7869 var pause = createPause(signal);
7870 return function (timeoutMs) {
7871 return pause(new Promise(function (resolve) { return setTimeout(resolve, timeoutMs); }));
7872 };
7873 };
7874 // src/listenerMiddleware/index.ts
7875 var assign = Object.assign;
7876 var INTERNAL_NIL_TOKEN = {};
7877 var alm = "listenerMiddleware";
7878 var createFork = function (parentAbortSignal, parentBlockingPromises) {
7879 var linkControllers = function (controller) { return addAbortSignalListener(parentAbortSignal, function () { return abortControllerWithReason(controller, parentAbortSignal.reason); }); };
7880 return function (taskExecutor, opts) {
7881 assertFunction(taskExecutor, "taskExecutor");
7882 var childAbortController = new AbortController();
7883 linkControllers(childAbortController);
7884 var result = runTask(function () { return __async(void 0, null, function () {
7885 var result2;
7886 return __generator(this, function (_c) {
7887 switch (_c.label) {
7888 case 0:
7889 validateActive(parentAbortSignal);
7890 validateActive(childAbortController.signal);
7891 return [4 /*yield*/, taskExecutor({
7892 pause: createPause(childAbortController.signal),
7893 delay: createDelay(childAbortController.signal),
7894 signal: childAbortController.signal
7895 })];
7896 case 1:
7897 result2 = _c.sent();
7898 validateActive(childAbortController.signal);
7899 return [2 /*return*/, result2];
7900 }
7901 });
7902 }); }, function () { return abortControllerWithReason(childAbortController, taskCompleted); });
7903 if (opts == null ? void 0 : opts.autoJoin) {
7904 parentBlockingPromises.push(result);
7905 }
7906 return {
7907 result: createPause(parentAbortSignal)(result),
7908 cancel: function () {
7909 abortControllerWithReason(childAbortController, taskCancelled);
7910 }
7911 };
7912 };
7913 };
7914 var createTakePattern = function (startListening, signal) {
7915 var take = function (predicate, timeout) { return __async(void 0, null, function () {
7916 var unsubscribe, tuplePromise, promises, output;
7917 return __generator(this, function (_c) {
7918 switch (_c.label) {
7919 case 0:
7920 validateActive(signal);
7921 unsubscribe = function () {
7922 };
7923 tuplePromise = new Promise(function (resolve, reject) {
7924 var stopListening = startListening({
7925 predicate: predicate,
7926 effect: function (action, listenerApi) {
7927 listenerApi.unsubscribe();
7928 resolve([
7929 action,
7930 listenerApi.getState(),
7931 listenerApi.getOriginalState()
7932 ]);
7933 }
7934 });
7935 unsubscribe = function () {
7936 stopListening();
7937 reject();
7938 };
7939 });
7940 promises = [
7941 tuplePromise
7942 ];
7943 if (timeout != null) {
7944 promises.push(new Promise(function (resolve) { return setTimeout(resolve, timeout, null); }));
7945 }
7946 _c.label = 1;
7947 case 1:
7948 _c.trys.push([1, , 3, 4]);
7949 return [4 /*yield*/, raceWithSignal(signal, Promise.race(promises))];
7950 case 2:
7951 output = _c.sent();
7952 validateActive(signal);
7953 return [2 /*return*/, output];
7954 case 3:
7955 unsubscribe();
7956 return [7 /*endfinally*/];
7957 case 4: return [2 /*return*/];
7958 }
7959 });
7960 }); };
7961 return function (predicate, timeout) { return catchRejection(take(predicate, timeout)); };
7962 };
7963 var getListenerEntryPropsFrom = function (options) {
7964 var type = options.type, actionCreator = options.actionCreator, matcher = options.matcher, predicate = options.predicate, effect = options.effect;
7965 if (type) {
7966 predicate = createAction(type).match;
7967 }
7968 else if (actionCreator) {
7969 type = actionCreator.type;
7970 predicate = actionCreator.match;
7971 }
7972 else if (matcher) {
7973 predicate = matcher;
7974 }
7975 else if (predicate) {
7976 }
7977 else {
7978 throw new Error("Creating or removing a listener requires one of the known fields for matching an action");
7979 }
7980 assertFunction(effect, "options.listener");
7981 return { predicate: predicate, type: type, effect: effect };
7982 };
7983 var createListenerEntry = function (options) {
7984 var _c = getListenerEntryPropsFrom(options), type = _c.type, predicate = _c.predicate, effect = _c.effect;
7985 var id = nanoid();
7986 var entry = {
7987 id: id,
7988 effect: effect,
7989 type: type,
7990 predicate: predicate,
7991 pending: new Set(),
7992 unsubscribe: function () {
7993 throw new Error("Unsubscribe not initialized");
7994 }
7995 };
7996 return entry;
7997 };
7998 var cancelActiveListeners = function (entry) {
7999 entry.pending.forEach(function (controller) {
8000 abortControllerWithReason(controller, listenerCancelled);
8001 });
8002 };
8003 var createClearListenerMiddleware = function (listenerMap) {
8004 return function () {
8005 listenerMap.forEach(cancelActiveListeners);
8006 listenerMap.clear();
8007 };
8008 };
8009 var safelyNotifyError = function (errorHandler, errorToNotify, errorInfo) {
8010 try {
8011 errorHandler(errorToNotify, errorInfo);
8012 }
8013 catch (errorHandlerError) {
8014 setTimeout(function () {
8015 throw errorHandlerError;
8016 }, 0);
8017 }
8018 };
8019 var addListener = createAction(alm + "/add");
8020 var clearAllListeners = createAction(alm + "/removeAll");
8021 var removeListener = createAction(alm + "/remove");
8022 var defaultErrorHandler = function () {
8023 var args = [];
8024 for (var _i = 0; _i < arguments.length; _i++) {
8025 args[_i] = arguments[_i];
8026 }
8027 console.error.apply(console, __spreadArray([alm + "/error"], args));
8028 };
8029 function createListenerMiddleware(middlewareOptions) {
8030 var _this = this;
8031 if (middlewareOptions === void 0) { middlewareOptions = {}; }
8032 var listenerMap = new Map();
8033 var extra = middlewareOptions.extra, _c = middlewareOptions.onError, onError = _c === void 0 ? defaultErrorHandler : _c;
8034 assertFunction(onError, "onError");
8035 var insertEntry = function (entry) {
8036 entry.unsubscribe = function () { return listenerMap.delete(entry.id); };
8037 listenerMap.set(entry.id, entry);
8038 return function (cancelOptions) {
8039 entry.unsubscribe();
8040 if (cancelOptions == null ? void 0 : cancelOptions.cancelActive) {
8041 cancelActiveListeners(entry);
8042 }
8043 };
8044 };
8045 var findListenerEntry = function (comparator) {
8046 for (var _i = 0, _c = Array.from(listenerMap.values()); _i < _c.length; _i++) {
8047 var entry = _c[_i];
8048 if (comparator(entry)) {
8049 return entry;
8050 }
8051 }
8052 return void 0;
8053 };
8054 var startListening = function (options) {
8055 var entry = findListenerEntry(function (existingEntry) { return existingEntry.effect === options.effect; });
8056 if (!entry) {
8057 entry = createListenerEntry(options);
8058 }
8059 return insertEntry(entry);
8060 };
8061 var stopListening = function (options) {
8062 var _c = getListenerEntryPropsFrom(options), type = _c.type, effect = _c.effect, predicate = _c.predicate;
8063 var entry = findListenerEntry(function (entry2) {
8064 var matchPredicateOrType = typeof type === "string" ? entry2.type === type : entry2.predicate === predicate;
8065 return matchPredicateOrType && entry2.effect === effect;
8066 });
8067 if (entry) {
8068 entry.unsubscribe();
8069 if (options.cancelActive) {
8070 cancelActiveListeners(entry);
8071 }
8072 }
8073 return !!entry;
8074 };
8075 var notifyListener = function (entry, action, api, getOriginalState) { return __async(_this, null, function () {
8076 var internalTaskController, take, autoJoinPromises, listenerError_1;
8077 return __generator(this, function (_c) {
8078 switch (_c.label) {
8079 case 0:
8080 internalTaskController = new AbortController();
8081 take = createTakePattern(startListening, internalTaskController.signal);
8082 autoJoinPromises = [];
8083 _c.label = 1;
8084 case 1:
8085 _c.trys.push([1, 3, 4, 6]);
8086 entry.pending.add(internalTaskController);
8087 return [4 /*yield*/, Promise.resolve(entry.effect(action, assign({}, api, {
8088 getOriginalState: getOriginalState,
8089 condition: function (predicate, timeout) { return take(predicate, timeout).then(Boolean); },
8090 take: take,
8091 delay: createDelay(internalTaskController.signal),
8092 pause: createPause(internalTaskController.signal),
8093 extra: extra,
8094 signal: internalTaskController.signal,
8095 fork: createFork(internalTaskController.signal, autoJoinPromises),
8096 unsubscribe: entry.unsubscribe,
8097 subscribe: function () {
8098 listenerMap.set(entry.id, entry);
8099 },
8100 cancelActiveListeners: function () {
8101 entry.pending.forEach(function (controller, _, set) {
8102 if (controller !== internalTaskController) {
8103 abortControllerWithReason(controller, listenerCancelled);
8104 set.delete(controller);
8105 }
8106 });
8107 }
8108 })))];
8109 case 2:
8110 _c.sent();
8111 return [3 /*break*/, 6];
8112 case 3:
8113 listenerError_1 = _c.sent();
8114 if (!(listenerError_1 instanceof TaskAbortError)) {
8115 safelyNotifyError(onError, listenerError_1, {
8116 raisedBy: "effect"
8117 });
8118 }
8119 return [3 /*break*/, 6];
8120 case 4: return [4 /*yield*/, Promise.allSettled(autoJoinPromises)];
8121 case 5:
8122 _c.sent();
8123 abortControllerWithReason(internalTaskController, listenerCompleted);
8124 entry.pending.delete(internalTaskController);
8125 return [7 /*endfinally*/];
8126 case 6: return [2 /*return*/];
8127 }
8128 });
8129 }); };
8130 var clearListenerMiddleware = createClearListenerMiddleware(listenerMap);
8131 var middleware = function (api) { return function (next) { return function (action) {
8132 if (!isAction(action)) {
8133 return next(action);
8134 }
8135 if (addListener.match(action)) {
8136 return startListening(action.payload);
8137 }
8138 if (clearAllListeners.match(action)) {
8139 clearListenerMiddleware();
8140 return;
8141 }
8142 if (removeListener.match(action)) {
8143 return stopListening(action.payload);
8144 }
8145 var originalState = api.getState();
8146 var getOriginalState = function () {
8147 if (originalState === INTERNAL_NIL_TOKEN) {
8148 throw new Error(alm + ": getOriginalState can only be called synchronously");
8149 }
8150 return originalState;
8151 };
8152 var result;
8153 try {
8154 result = next(action);
8155 if (listenerMap.size > 0) {
8156 var currentState = api.getState();
8157 var listenerEntries = Array.from(listenerMap.values());
8158 for (var _i = 0, listenerEntries_1 = listenerEntries; _i < listenerEntries_1.length; _i++) {
8159 var entry = listenerEntries_1[_i];
8160 var runListener = false;
8161 try {
8162 runListener = entry.predicate(action, currentState, originalState);
8163 }
8164 catch (predicateError) {
8165 runListener = false;
8166 safelyNotifyError(onError, predicateError, {
8167 raisedBy: "predicate"
8168 });
8169 }
8170 if (!runListener) {
8171 continue;
8172 }
8173 notifyListener(entry, action, api, getOriginalState);
8174 }
8175 }
8176 }
8177 finally {
8178 originalState = INTERNAL_NIL_TOKEN;
8179 }
8180 return result;
8181 }; }; };
8182 return {
8183 middleware: middleware,
8184 startListening: startListening,
8185 stopListening: stopListening,
8186 clearListeners: clearListenerMiddleware
8187 };
8188 }
8189 // src/autoBatchEnhancer.ts
8190 var SHOULD_AUTOBATCH = "RTK_autoBatch";
8191 var prepareAutoBatched = function () { return function (payload) {
8192 var _c;
8193 return ({
8194 payload: payload,
8195 meta: (_c = {}, _c[SHOULD_AUTOBATCH] = true, _c)
8196 });
8197 }; };
8198 var promise;
8199 var queueMicrotaskShim = typeof queueMicrotask === "function" ? queueMicrotask.bind(typeof window !== "undefined" ? window : typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : globalThis) : function (cb) { return (promise || (promise = Promise.resolve())).then(cb).catch(function (err) { return setTimeout(function () {
8200 throw err;
8201 }, 0); }); };
8202 var createQueueWithTimer = function (timeout) {
8203 return function (notify) {
8204 setTimeout(notify, timeout);
8205 };
8206 };
8207 var rAF = typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10);
8208 var autoBatchEnhancer = function (options) {
8209 if (options === void 0) { options = { type: "raf" }; }
8210 return function (next) { return function () {
8211 var args = [];
8212 for (var _i = 0; _i < arguments.length; _i++) {
8213 args[_i] = arguments[_i];
8214 }
8215 var store = next.apply(void 0, args);
8216 var notifying = true;
8217 var shouldNotifyAtEndOfTick = false;
8218 var notificationQueued = false;
8219 var listeners = new Set();
8220 var queueCallback = options.type === "tick" ? queueMicrotaskShim : options.type === "raf" ? rAF : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
8221 var notifyListeners = function () {
8222 notificationQueued = false;
8223 if (shouldNotifyAtEndOfTick) {
8224 shouldNotifyAtEndOfTick = false;
8225 listeners.forEach(function (l) { return l(); });
8226 }
8227 };
8228 return Object.assign({}, store, {
8229 subscribe: function (listener2) {
8230 var wrappedListener = function () { return notifying && listener2(); };
8231 var unsubscribe = store.subscribe(wrappedListener);
8232 listeners.add(listener2);
8233 return function () {
8234 unsubscribe();
8235 listeners.delete(listener2);
8236 };
8237 },
8238 dispatch: function (action) {
8239 var _a;
8240 try {
8241 notifying = !((_a = action == null ? void 0 : action.meta) == null ? void 0 : _a[SHOULD_AUTOBATCH]);
8242 shouldNotifyAtEndOfTick = !notifying;
8243 if (shouldNotifyAtEndOfTick) {
8244 if (!notificationQueued) {
8245 notificationQueued = true;
8246 queueCallback(notifyListeners);
8247 }
8248 }
8249 return store.dispatch(action);
8250 }
8251 finally {
8252 notifying = true;
8253 }
8254 }
8255 });
8256 }; };
8257 };
8258 // src/index.ts
8259 (0,immer__WEBPACK_IMPORTED_MODULE_0__.enableES5)();
8260
8261 //# sourceMappingURL=redux-toolkit.esm.js.map
8262
8263 /***/ }),
8264
8265 /***/ "../node_modules/immer/dist/immer.esm.mjs":
8266 /*!************************************************!*\
8267 !*** ../node_modules/immer/dist/immer.esm.mjs ***!
8268 \************************************************/
8269 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8270
8271 "use strict";
8272 __webpack_require__.r(__webpack_exports__);
8273 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8274 /* harmony export */ Immer: () => (/* binding */ un),
8275 /* harmony export */ applyPatches: () => (/* binding */ pn),
8276 /* harmony export */ castDraft: () => (/* binding */ K),
8277 /* harmony export */ castImmutable: () => (/* binding */ $),
8278 /* harmony export */ createDraft: () => (/* binding */ ln),
8279 /* harmony export */ current: () => (/* binding */ R),
8280 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
8281 /* harmony export */ enableAllPlugins: () => (/* binding */ J),
8282 /* harmony export */ enableES5: () => (/* binding */ F),
8283 /* harmony export */ enableMapSet: () => (/* binding */ C),
8284 /* harmony export */ enablePatches: () => (/* binding */ T),
8285 /* harmony export */ finishDraft: () => (/* binding */ dn),
8286 /* harmony export */ freeze: () => (/* binding */ d),
8287 /* harmony export */ immerable: () => (/* binding */ L),
8288 /* harmony export */ isDraft: () => (/* binding */ r),
8289 /* harmony export */ isDraftable: () => (/* binding */ t),
8290 /* harmony export */ nothing: () => (/* binding */ H),
8291 /* harmony export */ original: () => (/* binding */ e),
8292 /* harmony export */ produce: () => (/* binding */ fn),
8293 /* harmony export */ produceWithPatches: () => (/* binding */ cn),
8294 /* harmony export */ setAutoFreeze: () => (/* binding */ sn),
8295 /* harmony export */ setUseProxies: () => (/* binding */ vn)
8296 /* harmony export */ });
8297 function n(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=arguments[e];if(true){var i=Y[n],o=i?"function"==typeof i?i.apply(null,t):i:"unknown error nr: "+n;throw Error("[Immer] "+o)}// removed by dead control flow
8298 }function r(n){return!!n&&!!n[Q]}function t(n){var r;return!!n&&(function(n){if(!n||"object"!=typeof n)return!1;var r=Object.getPrototypeOf(n);if(null===r)return!0;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return t===Object||"function"==typeof t&&Function.toString.call(t)===Z}(n)||Array.isArray(n)||!!n[L]||!!(null===(r=n.constructor)||void 0===r?void 0:r[L])||s(n)||v(n))}function e(t){return r(t)||n(23,t),t[Q].t}function i(n,r,t){void 0===t&&(t=!1),0===o(n)?(t?Object.keys:nn)(n).forEach((function(e){t&&"symbol"==typeof e||r(e,n[e],n)})):n.forEach((function(t,e){return r(e,t,n)}))}function o(n){var r=n[Q];return r?r.i>3?r.i-4:r.i:Array.isArray(n)?1:s(n)?2:v(n)?3:0}function u(n,r){return 2===o(n)?n.has(r):Object.prototype.hasOwnProperty.call(n,r)}function a(n,r){return 2===o(n)?n.get(r):n[r]}function f(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?n.add(t):n[r]=t}function c(n,r){return n===r?0!==n||1/n==1/r:n!=n&&r!=r}function s(n){return X&&n instanceof Map}function v(n){return q&&n instanceof Set}function p(n){return n.o||n.t}function l(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var r=rn(n);delete r[Q];for(var t=nn(r),e=0;e<t.length;e++){var i=t[e],o=r[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[i]})}return Object.create(Object.getPrototypeOf(n),r)}function d(n,e){return void 0===e&&(e=!1),y(n)||r(n)||!t(n)||(o(n)>1&&(n.set=n.add=n.clear=n.delete=h),Object.freeze(n),e&&i(n,(function(n,r){return d(r,!0)}),!0)),n}function h(){n(2)}function y(n){return null==n||"object"!=typeof n||Object.isFrozen(n)}function b(r){var t=tn[r];return t||n(18,r),t}function m(n,r){tn[n]||(tn[n]=r)}function _(){return false||U||n(0),U}function j(n,r){r&&(b("Patches"),n.u=[],n.s=[],n.v=r)}function g(n){O(n),n.p.forEach(S),n.p=null}function O(n){n===U&&(U=n.l)}function w(n){return U={p:[],l:U,h:n,m:!0,_:0}}function S(n){var r=n[Q];0===r.i||1===r.i?r.j():r.g=!0}function P(r,e){e._=e.p.length;var i=e.p[0],o=void 0!==r&&r!==i;return e.h.O||b("ES5").S(e,r,o),o?(i[Q].P&&(g(e),n(4)),t(r)&&(r=M(e,r),e.l||x(e,r)),e.u&&b("Patches").M(i[Q].t,r,e.u,e.s)):r=M(e,i,[]),g(e),e.u&&e.v(e.u,e.s),r!==H?r:void 0}function M(n,r,t){if(y(r))return r;var e=r[Q];if(!e)return i(r,(function(i,o){return A(n,e,r,i,o,t)}),!0),r;if(e.A!==n)return r;if(!e.P)return x(n,e.t,!0),e.t;if(!e.I){e.I=!0,e.A._--;var o=4===e.i||5===e.i?e.o=l(e.k):e.o,u=o,a=!1;3===e.i&&(u=new Set(o),o.clear(),a=!0),i(u,(function(r,i){return A(n,e,o,r,i,t,a)})),x(n,o,!1),t&&n.u&&b("Patches").N(e,t,n.u,n.s)}return e.o}function A(e,i,o,a,c,s,v){if( true&&c===o&&n(5),r(c)){var p=M(e,c,s&&i&&3!==i.i&&!u(i.R,a)?s.concat(a):void 0);if(f(o,a,p),!r(p))return;e.m=!1}else v&&o.add(c);if(t(c)&&!y(c)){if(!e.h.D&&e._<1)return;M(e,c),i&&i.A.l||x(e,c)}}function x(n,r,t){void 0===t&&(t=!1),!n.l&&n.h.D&&n.m&&d(r,t)}function z(n,r){var t=n[Q];return(t?p(t):n)[r]}function I(n,r){if(r in n)for(var t=Object.getPrototypeOf(n);t;){var e=Object.getOwnPropertyDescriptor(t,r);if(e)return e;t=Object.getPrototypeOf(t)}}function k(n){n.P||(n.P=!0,n.l&&k(n.l))}function E(n){n.o||(n.o=l(n.t))}function N(n,r,t){var e=s(r)?b("MapSet").F(r,t):v(r)?b("MapSet").T(r,t):n.O?function(n,r){var t=Array.isArray(n),e={i:t?1:0,A:r?r.A:_(),P:!1,I:!1,R:{},l:r,t:n,k:null,o:null,j:null,C:!1},i=e,o=en;t&&(i=[e],o=on);var u=Proxy.revocable(i,o),a=u.revoke,f=u.proxy;return e.k=f,e.j=a,f}(r,t):b("ES5").J(r,t);return(t?t.A:_()).p.push(e),e}function R(e){return r(e)||n(22,e),function n(r){if(!t(r))return r;var e,u=r[Q],c=o(r);if(u){if(!u.P&&(u.i<4||!b("ES5").K(u)))return u.t;u.I=!0,e=D(r,c),u.I=!1}else e=D(r,c);return i(e,(function(r,t){u&&a(u.t,r)===t||f(e,r,n(t))})),3===c?new Set(e):e}(e)}function D(n,r){switch(r){case 2:return new Map(n);case 3:return Array.from(n)}return l(n)}function F(){function t(n,r){var t=s[n];return t?t.enumerable=r:s[n]=t={configurable:!0,enumerable:r,get:function(){var r=this[Q];return true&&f(r),en.get(r,n)},set:function(r){var t=this[Q]; true&&f(t),en.set(t,n,r)}},t}function e(n){for(var r=n.length-1;r>=0;r--){var t=n[r][Q];if(!t.P)switch(t.i){case 5:a(t)&&k(t);break;case 4:o(t)&&k(t)}}}function o(n){for(var r=n.t,t=n.k,e=nn(t),i=e.length-1;i>=0;i--){var o=e[i];if(o!==Q){var a=r[o];if(void 0===a&&!u(r,o))return!0;var f=t[o],s=f&&f[Q];if(s?s.t!==a:!c(f,a))return!0}}var v=!!r[Q];return e.length!==nn(r).length+(v?0:1)}function a(n){var r=n.k;if(r.length!==n.t.length)return!0;var t=Object.getOwnPropertyDescriptor(r,r.length-1);if(t&&!t.get)return!0;for(var e=0;e<r.length;e++)if(!r.hasOwnProperty(e))return!0;return!1}function f(r){r.g&&n(3,JSON.stringify(p(r)))}var s={};m("ES5",{J:function(n,r){var e=Array.isArray(n),i=function(n,r){if(n){for(var e=Array(r.length),i=0;i<r.length;i++)Object.defineProperty(e,""+i,t(i,!0));return e}var o=rn(r);delete o[Q];for(var u=nn(o),a=0;a<u.length;a++){var f=u[a];o[f]=t(f,n||!!o[f].enumerable)}return Object.create(Object.getPrototypeOf(r),o)}(e,n),o={i:e?5:4,A:r?r.A:_(),P:!1,I:!1,R:{},l:r,t:n,k:i,o:null,g:!1,C:!1};return Object.defineProperty(i,Q,{value:o,writable:!0}),i},S:function(n,t,o){o?r(t)&&t[Q].A===n&&e(n.p):(n.u&&function n(r){if(r&&"object"==typeof r){var t=r[Q];if(t){var e=t.t,o=t.k,f=t.R,c=t.i;if(4===c)i(o,(function(r){r!==Q&&(void 0!==e[r]||u(e,r)?f[r]||n(o[r]):(f[r]=!0,k(t)))})),i(e,(function(n){void 0!==o[n]||u(o,n)||(f[n]=!1,k(t))}));else if(5===c){if(a(t)&&(k(t),f.length=!0),o.length<e.length)for(var s=o.length;s<e.length;s++)f[s]=!1;else for(var v=e.length;v<o.length;v++)f[v]=!0;for(var p=Math.min(o.length,e.length),l=0;l<p;l++)o.hasOwnProperty(l)||(f[l]=!0),void 0===f[l]&&n(o[l])}}}}(n.p[0]),e(n.p))},K:function(n){return 4===n.i?o(n):a(n)}})}function T(){function e(n){if(!t(n))return n;if(Array.isArray(n))return n.map(e);if(s(n))return new Map(Array.from(n.entries()).map((function(n){return[n[0],e(n[1])]})));if(v(n))return new Set(Array.from(n).map(e));var r=Object.create(Object.getPrototypeOf(n));for(var i in n)r[i]=e(n[i]);return u(n,L)&&(r[L]=n[L]),r}function f(n){return r(n)?e(n):n}var c="add";m("Patches",{$:function(r,t){return t.forEach((function(t){for(var i=t.path,u=t.op,f=r,s=0;s<i.length-1;s++){var v=o(f),p=i[s];"string"!=typeof p&&"number"!=typeof p&&(p=""+p),0!==v&&1!==v||"__proto__"!==p&&"constructor"!==p||n(24),"function"==typeof f&&"prototype"===p&&n(24),"object"!=typeof(f=a(f,p))&&n(15,i.join("/"))}var l=o(f),d=e(t.value),h=i[i.length-1];switch(u){case"replace":switch(l){case 2:return f.set(h,d);case 3:n(16);default:return f[h]=d}case c:switch(l){case 1:return"-"===h?f.push(d):f.splice(h,0,d);case 2:return f.set(h,d);case 3:return f.add(d);default:return f[h]=d}case"remove":switch(l){case 1:return f.splice(h,1);case 2:return f.delete(h);case 3:return f.delete(t.value);default:return delete f[h]}default:n(17,u)}})),r},N:function(n,r,t,e){switch(n.i){case 0:case 4:case 2:return function(n,r,t,e){var o=n.t,s=n.o;i(n.R,(function(n,i){var v=a(o,n),p=a(s,n),l=i?u(o,n)?"replace":c:"remove";if(v!==p||"replace"!==l){var d=r.concat(n);t.push("remove"===l?{op:l,path:d}:{op:l,path:d,value:p}),e.push(l===c?{op:"remove",path:d}:"remove"===l?{op:c,path:d,value:f(v)}:{op:"replace",path:d,value:f(v)})}}))}(n,r,t,e);case 5:case 1:return function(n,r,t,e){var i=n.t,o=n.R,u=n.o;if(u.length<i.length){var a=[u,i];i=a[0],u=a[1];var s=[e,t];t=s[0],e=s[1]}for(var v=0;v<i.length;v++)if(o[v]&&u[v]!==i[v]){var p=r.concat([v]);t.push({op:"replace",path:p,value:f(u[v])}),e.push({op:"replace",path:p,value:f(i[v])})}for(var l=i.length;l<u.length;l++){var d=r.concat([l]);t.push({op:c,path:d,value:f(u[l])})}i.length<u.length&&e.push({op:"replace",path:r.concat(["length"]),value:i.length})}(n,r,t,e);case 3:return function(n,r,t,e){var i=n.t,o=n.o,u=0;i.forEach((function(n){if(!o.has(n)){var i=r.concat([u]);t.push({op:"remove",path:i,value:n}),e.unshift({op:c,path:i,value:n})}u++})),u=0,o.forEach((function(n){if(!i.has(n)){var o=r.concat([u]);t.push({op:c,path:o,value:n}),e.unshift({op:"remove",path:o,value:n})}u++}))}(n,r,t,e)}},M:function(n,r,t,e){t.push({op:"replace",path:[],value:r===H?void 0:r}),e.push({op:"replace",path:[],value:n})}})}function C(){function r(n,r){function t(){this.constructor=n}a(n,r),n.prototype=(t.prototype=r.prototype,new t)}function e(n){n.o||(n.R=new Map,n.o=new Map(n.t))}function o(n){n.o||(n.o=new Set,n.t.forEach((function(r){if(t(r)){var e=N(n.A.h,r,n);n.p.set(r,e),n.o.add(e)}else n.o.add(r)})))}function u(r){r.g&&n(3,JSON.stringify(p(r)))}var a=function(n,r){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var t in r)r.hasOwnProperty(t)&&(n[t]=r[t])})(n,r)},f=function(){function n(n,r){return this[Q]={i:2,l:r,A:r?r.A:_(),P:!1,I:!1,o:void 0,R:void 0,t:n,k:this,C:!1,g:!1},this}r(n,Map);var o=n.prototype;return Object.defineProperty(o,"size",{get:function(){return p(this[Q]).size}}),o.has=function(n){return p(this[Q]).has(n)},o.set=function(n,r){var t=this[Q];return u(t),p(t).has(n)&&p(t).get(n)===r||(e(t),k(t),t.R.set(n,!0),t.o.set(n,r),t.R.set(n,!0)),this},o.delete=function(n){if(!this.has(n))return!1;var r=this[Q];return u(r),e(r),k(r),r.t.has(n)?r.R.set(n,!1):r.R.delete(n),r.o.delete(n),!0},o.clear=function(){var n=this[Q];u(n),p(n).size&&(e(n),k(n),n.R=new Map,i(n.t,(function(r){n.R.set(r,!1)})),n.o.clear())},o.forEach=function(n,r){var t=this;p(this[Q]).forEach((function(e,i){n.call(r,t.get(i),i,t)}))},o.get=function(n){var r=this[Q];u(r);var i=p(r).get(n);if(r.I||!t(i))return i;if(i!==r.t.get(n))return i;var o=N(r.A.h,i,r);return e(r),r.o.set(n,o),o},o.keys=function(){return p(this[Q]).keys()},o.values=function(){var n,r=this,t=this.keys();return(n={})[V]=function(){return r.values()},n.next=function(){var n=t.next();return n.done?n:{done:!1,value:r.get(n.value)}},n},o.entries=function(){var n,r=this,t=this.keys();return(n={})[V]=function(){return r.entries()},n.next=function(){var n=t.next();if(n.done)return n;var e=r.get(n.value);return{done:!1,value:[n.value,e]}},n},o[V]=function(){return this.entries()},n}(),c=function(){function n(n,r){return this[Q]={i:3,l:r,A:r?r.A:_(),P:!1,I:!1,o:void 0,t:n,k:this,p:new Map,g:!1,C:!1},this}r(n,Set);var t=n.prototype;return Object.defineProperty(t,"size",{get:function(){return p(this[Q]).size}}),t.has=function(n){var r=this[Q];return u(r),r.o?!!r.o.has(n)||!(!r.p.has(n)||!r.o.has(r.p.get(n))):r.t.has(n)},t.add=function(n){var r=this[Q];return u(r),this.has(n)||(o(r),k(r),r.o.add(n)),this},t.delete=function(n){if(!this.has(n))return!1;var r=this[Q];return u(r),o(r),k(r),r.o.delete(n)||!!r.p.has(n)&&r.o.delete(r.p.get(n))},t.clear=function(){var n=this[Q];u(n),p(n).size&&(o(n),k(n),n.o.clear())},t.values=function(){var n=this[Q];return u(n),o(n),n.o.values()},t.entries=function(){var n=this[Q];return u(n),o(n),n.o.entries()},t.keys=function(){return this.values()},t[V]=function(){return this.values()},t.forEach=function(n,r){for(var t=this.values(),e=t.next();!e.done;)n.call(r,e.value,e.value,this),e=t.next()},n}();m("MapSet",{F:function(n,r){return new f(n,r)},T:function(n,r){return new c(n,r)}})}function J(){F(),C(),T()}function K(n){return n}function $(n){return n}var G,U,W="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),X="undefined"!=typeof Map,q="undefined"!=typeof Set,B="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,H=W?Symbol.for("immer-nothing"):((G={})["immer-nothing"]=!0,G),L=W?Symbol.for("immer-draftable"):"__$immer_draftable",Q=W?Symbol.for("immer-state"):"__$immer_state",V="undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator",Y={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(n){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(n){return"Cannot apply patch, path doesn't resolve: "+n},16:'Sets cannot have "replace" patches.',17:function(n){return"Unsupported patch operation: "+n},18:function(n){return"The plugin for '"+n+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+n+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(n){return"produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+n+"'"},22:function(n){return"'current' expects a draft, got: "+n},23:function(n){return"'original' expects a draft, got: "+n},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Z=""+Object.prototype.constructor,nn="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,rn=Object.getOwnPropertyDescriptors||function(n){var r={};return nn(n).forEach((function(t){r[t]=Object.getOwnPropertyDescriptor(n,t)})),r},tn={},en={get:function(n,r){if(r===Q)return n;var e=p(n);if(!u(e,r))return function(n,r,t){var e,i=I(r,t);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(n.k):void 0}(n,e,r);var i=e[r];return n.I||!t(i)?i:i===z(n.t,r)?(E(n),n.o[r]=N(n.A.h,i,n)):i},has:function(n,r){return r in p(n)},ownKeys:function(n){return Reflect.ownKeys(p(n))},set:function(n,r,t){var e=I(p(n),r);if(null==e?void 0:e.set)return e.set.call(n.k,t),!0;if(!n.P){var i=z(p(n),r),o=null==i?void 0:i[Q];if(o&&o.t===t)return n.o[r]=t,n.R[r]=!1,!0;if(c(t,i)&&(void 0!==t||u(n.t,r)))return!0;E(n),k(n)}return n.o[r]===t&&(void 0!==t||r in n.o)||Number.isNaN(t)&&Number.isNaN(n.o[r])||(n.o[r]=t,n.R[r]=!0),!0},deleteProperty:function(n,r){return void 0!==z(n.t,r)||r in n.t?(n.R[r]=!1,E(n),k(n)):delete n.R[r],n.o&&delete n.o[r],!0},getOwnPropertyDescriptor:function(n,r){var t=p(n),e=Reflect.getOwnPropertyDescriptor(t,r);return e?{writable:!0,configurable:1!==n.i||"length"!==r,enumerable:e.enumerable,value:t[r]}:e},defineProperty:function(){n(11)},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){n(12)}},on={};i(en,(function(n,r){on[n]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}})),on.deleteProperty=function(r,t){return true&&isNaN(parseInt(t))&&n(13),on.set.call(this,r,t,void 0)},on.set=function(r,t,e){return true&&"length"!==t&&isNaN(parseInt(t))&&n(14),en.set.call(this,r[0],t,e,r[0])};var un=function(){function e(r){var e=this;this.O=B,this.D=!0,this.produce=function(r,i,o){if("function"==typeof r&&"function"!=typeof i){var u=i;i=r;var a=e;return function(n){var r=this;void 0===n&&(n=u);for(var t=arguments.length,e=Array(t>1?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];return a.produce(n,(function(n){var t;return(t=i).call.apply(t,[r,n].concat(e))}))}}var f;if("function"!=typeof i&&n(6),void 0!==o&&"function"!=typeof o&&n(7),t(r)){var c=w(e),s=N(e,r,void 0),v=!0;try{f=i(s),v=!1}finally{v?g(c):O(c)}return"undefined"!=typeof Promise&&f instanceof Promise?f.then((function(n){return j(c,o),P(n,c)}),(function(n){throw g(c),n})):(j(c,o),P(f,c))}if(!r||"object"!=typeof r){if(void 0===(f=i(r))&&(f=r),f===H&&(f=void 0),e.D&&d(f,!0),o){var p=[],l=[];b("Patches").M(r,f,p,l),o(p,l)}return f}n(21,r)},this.produceWithPatches=function(n,r){if("function"==typeof n)return function(r){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;o<t;o++)i[o-1]=arguments[o];return e.produceWithPatches(r,(function(r){return n.apply(void 0,[r].concat(i))}))};var t,i,o=e.produce(n,r,(function(n,r){t=n,i=r}));return"undefined"!=typeof Promise&&o instanceof Promise?o.then((function(n){return[n,t,i]})):[o,t,i]},"boolean"==typeof(null==r?void 0:r.useProxies)&&this.setUseProxies(r.useProxies),"boolean"==typeof(null==r?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze)}var i=e.prototype;return i.createDraft=function(e){t(e)||n(8),r(e)&&(e=R(e));var i=w(this),o=N(this,e,void 0);return o[Q].C=!0,O(i),o},i.finishDraft=function(r,t){var e=r&&r[Q]; true&&(e&&e.C||n(9),e.I&&n(10));var i=e.A;return j(i,t),P(void 0,i)},i.setAutoFreeze=function(n){this.D=n},i.setUseProxies=function(r){r&&!B&&n(20),this.O=r},i.applyPatches=function(n,t){var e;for(e=t.length-1;e>=0;e--){var i=t[e];if(0===i.path.length&&"replace"===i.op){n=i.value;break}}e>-1&&(t=t.slice(e+1));var o=b("Patches").$;return r(n)?o(n,t):this.produce(n,(function(n){return o(n,t)}))},e}(),an=new un,fn=an.produce,cn=an.produceWithPatches.bind(an),sn=an.setAutoFreeze.bind(an),vn=an.setUseProxies.bind(an),pn=an.applyPatches.bind(an),ln=an.createDraft.bind(an),dn=an.finishDraft.bind(an);/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (fn);
8299 //# sourceMappingURL=immer.esm.js.map
8300
8301
8302 /***/ }),
8303
8304 /***/ "../node_modules/mixpanel-browser/dist/mixpanel.module.js":
8305 /*!****************************************************************!*\
8306 !*** ../node_modules/mixpanel-browser/dist/mixpanel.module.js ***!
8307 \****************************************************************/
8308 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8309
8310 "use strict";
8311 __webpack_require__.r(__webpack_exports__);
8312 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8313 /* harmony export */ "default": () => (/* binding */ mixpanel)
8314 /* harmony export */ });
8315 // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
8316 var win;
8317 if (typeof(window) === 'undefined') {
8318 var loc = {
8319 hostname: ''
8320 };
8321 win = {
8322 crypto: {randomUUID: function() {throw Error('unsupported');}},
8323 navigator: { userAgent: '', onLine: true },
8324 document: {
8325 createElement: function() { return {}; },
8326 location: loc,
8327 referrer: ''
8328 },
8329 screen: { width: 0, height: 0 },
8330 location: loc,
8331 addEventListener: function() {},
8332 removeEventListener: function() {}
8333 };
8334 } else {
8335 win = window;
8336 }
8337
8338 function _array_like_to_array(arr, len) {
8339 if (len == null || len > arr.length) len = arr.length;
8340 for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8341 return arr2;
8342 }
8343 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8344 try {
8345 var info = gen[key](arg);
8346 var value = info.value;
8347 } catch (error) {
8348 reject(error);
8349 return;
8350 }
8351 if (info.done) {
8352 resolve(value);
8353 } else {
8354 Promise.resolve(value).then(_next, _throw);
8355 }
8356 }
8357 function _async_to_generator(fn) {
8358 return function() {
8359 var self = this, args = arguments;
8360 return new Promise(function(resolve, reject) {
8361 var gen = fn.apply(self, args);
8362 function _next(value) {
8363 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8364 }
8365 function _throw(err) {
8366 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8367 }
8368 _next(undefined);
8369 });
8370 };
8371 }
8372 function _construct(Parent, args, Class) {
8373 if (_is_native_reflect_construct()) {
8374 _construct = Reflect.construct;
8375 } else {
8376 _construct = function construct(Parent, args, Class) {
8377 var a = [
8378 null
8379 ];
8380 a.push.apply(a, args);
8381 var Constructor = Function.bind.apply(Parent, a);
8382 var instance = new Constructor();
8383 if (Class) _set_prototype_of(instance, Class.prototype);
8384 return instance;
8385 };
8386 }
8387 return _construct.apply(null, arguments);
8388 }
8389 function _defineProperties(target, props) {
8390 for(var i = 0; i < props.length; i++){
8391 var descriptor = props[i];
8392 descriptor.enumerable = descriptor.enumerable || false;
8393 descriptor.configurable = true;
8394 if ("value" in descriptor) descriptor.writable = true;
8395 Object.defineProperty(target, descriptor.key, descriptor);
8396 }
8397 }
8398 function _create_class(Constructor, protoProps, staticProps) {
8399 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
8400 return Constructor;
8401 }
8402 function _extends() {
8403 _extends = Object.assign || function(target) {
8404 for(var i = 1; i < arguments.length; i++){
8405 var source = arguments[i];
8406 for(var key in source){
8407 if (Object.prototype.hasOwnProperty.call(source, key)) {
8408 target[key] = source[key];
8409 }
8410 }
8411 }
8412 return target;
8413 };
8414 return _extends.apply(this, arguments);
8415 }
8416 function _get_prototype_of(o) {
8417 _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
8418 return o.__proto__ || Object.getPrototypeOf(o);
8419 };
8420 return _get_prototype_of(o);
8421 }
8422 function _inherits(subClass, superClass) {
8423 if (typeof superClass !== "function" && superClass !== null) {
8424 throw new TypeError("Super expression must either be null or a function");
8425 }
8426 subClass.prototype = Object.create(superClass && superClass.prototype, {
8427 constructor: {
8428 value: subClass,
8429 writable: true,
8430 configurable: true
8431 }
8432 });
8433 if (superClass) _set_prototype_of(subClass, superClass);
8434 }
8435 function _instanceof(left, right) {
8436 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
8437 return !!right[Symbol.hasInstance](left);
8438 } else {
8439 return left instanceof right;
8440 }
8441 }
8442 function _is_native_function(fn) {
8443 return Function.toString.call(fn).indexOf("[native code]") !== -1;
8444 }
8445 function _object_without_properties_loose(source, excluded) {
8446 if (source == null) return {};
8447 var target = {};
8448 var sourceKeys = Object.keys(source);
8449 var key, i;
8450 for(i = 0; i < sourceKeys.length; i++){
8451 key = sourceKeys[i];
8452 if (excluded.indexOf(key) >= 0) continue;
8453 target[key] = source[key];
8454 }
8455 return target;
8456 }
8457 function _set_prototype_of(o, p) {
8458 _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
8459 o.__proto__ = p;
8460 return o;
8461 };
8462 return _set_prototype_of(o, p);
8463 }
8464 function _type_of(obj) {
8465 "@swc/helpers - typeof";
8466 return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
8467 }
8468 function _unsupported_iterable_to_array(o, minLen) {
8469 if (!o) return;
8470 if (typeof o === "string") return _array_like_to_array(o, minLen);
8471 var n = Object.prototype.toString.call(o).slice(8, -1);
8472 if (n === "Object" && o.constructor) n = o.constructor.name;
8473 if (n === "Map" || n === "Set") return Array.from(n);
8474 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
8475 }
8476 function _wrap_native_super(Class) {
8477 var _cache = typeof Map === "function" ? new Map() : undefined;
8478 _wrap_native_super = function wrapNativeSuper(Class) {
8479 if (Class === null || !_is_native_function(Class)) return Class;
8480 if (typeof Class !== "function") {
8481 throw new TypeError("Super expression must either be null or a function");
8482 }
8483 if (typeof _cache !== "undefined") {
8484 if (_cache.has(Class)) return _cache.get(Class);
8485 _cache.set(Class, Wrapper);
8486 }
8487 function Wrapper() {
8488 return _construct(Class, arguments, _get_prototype_of(this).constructor);
8489 }
8490 Wrapper.prototype = Object.create(Class.prototype, {
8491 constructor: {
8492 value: Wrapper,
8493 enumerable: false,
8494 writable: true,
8495 configurable: true
8496 }
8497 });
8498 return _set_prototype_of(Wrapper, Class);
8499 };
8500 return _wrap_native_super(Class);
8501 }
8502 function _is_native_reflect_construct() {
8503 try {
8504 var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
8505 } catch (_) {}
8506 return (_is_native_reflect_construct = function() {
8507 return !!result;
8508 })();
8509 }
8510 function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
8511 var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
8512 if (it) return (it = it.call(o)).next.bind(it);
8513 if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike) {
8514 if (it) o = it;
8515 var i = 0;
8516 return function() {
8517 if (i >= o.length) {
8518 return {
8519 done: true
8520 };
8521 }
8522 return {
8523 done: false,
8524 value: o[i++]
8525 };
8526 };
8527 }
8528 throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8529 }
8530 function _ts_generator(thisArg, body) {
8531 var f, y, t, g, _ = {
8532 label: 0,
8533 sent: function() {
8534 if (t[0] & 1) throw t[1];
8535 return t[1];
8536 },
8537 trys: [],
8538 ops: []
8539 };
8540 return g = {
8541 next: verb(0),
8542 "throw": verb(1),
8543 "return": verb(2)
8544 }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
8545 return this;
8546 }), g;
8547 function verb(n) {
8548 return function(v) {
8549 return step([
8550 n,
8551 v
8552 ]);
8553 };
8554 }
8555 function step(op) {
8556 if (f) throw new TypeError("Generator is already executing.");
8557 while(_)try {
8558 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
8559 if (y = 0, t) op = [
8560 op[0] & 2,
8561 t.value
8562 ];
8563 switch(op[0]){
8564 case 0:
8565 case 1:
8566 t = op;
8567 break;
8568 case 4:
8569 _.label++;
8570 return {
8571 value: op[1],
8572 done: false
8573 };
8574 case 5:
8575 _.label++;
8576 y = op[1];
8577 op = [
8578 0
8579 ];
8580 continue;
8581 case 7:
8582 op = _.ops.pop();
8583 _.trys.pop();
8584 continue;
8585 default:
8586 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
8587 _ = 0;
8588 continue;
8589 }
8590 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
8591 _.label = op[1];
8592 break;
8593 }
8594 if (op[0] === 6 && _.label < t[1]) {
8595 _.label = t[1];
8596 t = op;
8597 break;
8598 }
8599 if (t && _.label < t[2]) {
8600 _.label = t[2];
8601 _.ops.push(op);
8602 break;
8603 }
8604 if (t[2]) _.ops.pop();
8605 _.trys.pop();
8606 continue;
8607 }
8608 op = body.call(thisArg, _);
8609 } catch (e) {
8610 op = [
8611 6,
8612 e
8613 ];
8614 y = 0;
8615 } finally{
8616 f = t = 0;
8617 }
8618 if (op[0] & 5) throw op[1];
8619 return {
8620 value: op[0] ? op[1] : void 0,
8621 done: true
8622 };
8623 }
8624 }
8625 function _ts_values(o) {
8626 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
8627 if (m) return m.call(o);
8628 if (o && typeof o.length === "number") return {
8629 next: function() {
8630 if (o && i >= o.length) o = void 0;
8631 return {
8632 value: o && o[i++],
8633 done: !o
8634 };
8635 }
8636 };
8637 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
8638 }
8639 var __defProp = Object.defineProperty;
8640 var __defNormalProp = function(obj, key, value) {
8641 return key in obj ? __defProp(obj, key, {
8642 enumerable: true,
8643 configurable: true,
8644 writable: true,
8645 value: value
8646 }) : obj[key] = value;
8647 };
8648 var __publicField = function(obj, key, value) {
8649 return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
8650 };
8651 var _a;
8652 var __defProp$1 = Object.defineProperty;
8653 var __defNormalProp$1 = function(obj, key, value) {
8654 return key in obj ? __defProp$1(obj, key, {
8655 enumerable: true,
8656 configurable: true,
8657 writable: true,
8658 value: value
8659 }) : obj[key] = value;
8660 };
8661 var __publicField$1 = function(obj, key, value) {
8662 return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
8663 };
8664 var NodeType$3 = /* @__PURE__ */ function(NodeType2) {
8665 NodeType2[NodeType2["Document"] = 0] = "Document";
8666 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
8667 NodeType2[NodeType2["Element"] = 2] = "Element";
8668 NodeType2[NodeType2["Text"] = 3] = "Text";
8669 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
8670 NodeType2[NodeType2["Comment"] = 5] = "Comment";
8671 return NodeType2;
8672 }(NodeType$3 || {});
8673 var testableAccessors$1 = {
8674 Node: [
8675 "childNodes",
8676 "parentNode",
8677 "parentElement",
8678 "textContent"
8679 ],
8680 ShadowRoot: [
8681 "host",
8682 "styleSheets"
8683 ],
8684 Element: [
8685 "shadowRoot",
8686 "querySelector",
8687 "querySelectorAll"
8688 ],
8689 MutationObserver: []
8690 };
8691 var testableMethods$1 = {
8692 Node: [
8693 "contains",
8694 "getRootNode"
8695 ],
8696 ShadowRoot: [
8697 "getSelection"
8698 ],
8699 Element: [],
8700 MutationObserver: [
8701 "constructor"
8702 ]
8703 };
8704 var untaintedBasePrototype$1 = {};
8705 var isAngularZonePresent$1 = function() {
8706 return !!globalThis.Zone;
8707 };
8708 function getUntaintedPrototype$1(key) {
8709 if (untaintedBasePrototype$1[key]) return untaintedBasePrototype$1[key];
8710 var defaultObj = globalThis[key];
8711 var defaultPrototype = defaultObj.prototype;
8712 var accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
8713 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
8714 accessorNames.every(function(accessor) {
8715 var _a2, _b;
8716 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
8717 }));
8718 var methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
8719 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
8720 function(method) {
8721 var _a2;
8722 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
8723 }));
8724 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent$1()) {
8725 untaintedBasePrototype$1[key] = defaultObj.prototype;
8726 return defaultObj.prototype;
8727 }
8728 try {
8729 var iframeEl = document.createElement("iframe");
8730 document.body.appendChild(iframeEl);
8731 var win = iframeEl.contentWindow;
8732 if (!win) return defaultObj.prototype;
8733 var untaintedObject = win[key].prototype;
8734 document.body.removeChild(iframeEl);
8735 if (!untaintedObject) return defaultPrototype;
8736 return untaintedBasePrototype$1[key] = untaintedObject;
8737 } catch (e) {
8738 return defaultPrototype;
8739 }
8740 }
8741 var untaintedAccessorCache$1 = {};
8742 function getUntaintedAccessor$1(key, instance, accessor) {
8743 var _a2;
8744 var cacheKey = key + "." + String(accessor);
8745 if (untaintedAccessorCache$1[cacheKey]) return untaintedAccessorCache$1[cacheKey].call(instance);
8746 var untaintedPrototype = getUntaintedPrototype$1(key);
8747 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
8748 if (!untaintedAccessor) return instance[accessor];
8749 untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
8750 return untaintedAccessor.call(instance);
8751 }
8752 var untaintedMethodCache$1 = {};
8753 function getUntaintedMethod$1(key, instance, method) {
8754 var cacheKey = key + "." + String(method);
8755 if (untaintedMethodCache$1[cacheKey]) return untaintedMethodCache$1[cacheKey].bind(instance);
8756 var untaintedPrototype = getUntaintedPrototype$1(key);
8757 var untaintedMethod = untaintedPrototype[method];
8758 if (typeof untaintedMethod !== "function") return instance[method];
8759 untaintedMethodCache$1[cacheKey] = untaintedMethod;
8760 return untaintedMethod.bind(instance);
8761 }
8762 function childNodes$1(n2) {
8763 return getUntaintedAccessor$1("Node", n2, "childNodes");
8764 }
8765 function parentNode$1(n2) {
8766 return getUntaintedAccessor$1("Node", n2, "parentNode");
8767 }
8768 function parentElement$1(n2) {
8769 return getUntaintedAccessor$1("Node", n2, "parentElement");
8770 }
8771 function textContent$1(n2) {
8772 return getUntaintedAccessor$1("Node", n2, "textContent");
8773 }
8774 function contains$1(n2, other) {
8775 return getUntaintedMethod$1("Node", n2, "contains")(other);
8776 }
8777 function getRootNode$1(n2) {
8778 return getUntaintedMethod$1("Node", n2, "getRootNode")();
8779 }
8780 function host$1(n2) {
8781 if (!n2 || !("host" in n2)) return null;
8782 return getUntaintedAccessor$1("ShadowRoot", n2, "host");
8783 }
8784 function styleSheets$1(n2) {
8785 return n2.styleSheets;
8786 }
8787 function shadowRoot$1(n2) {
8788 if (!n2 || !("shadowRoot" in n2)) return null;
8789 return getUntaintedAccessor$1("Element", n2, "shadowRoot");
8790 }
8791 function querySelector$1(n2, selectors) {
8792 return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
8793 }
8794 function querySelectorAll$1(n2, selectors) {
8795 return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
8796 }
8797 function mutationObserverCtor$1() {
8798 return getUntaintedPrototype$1("MutationObserver").constructor;
8799 }
8800 function patch$1(source, name, replacement) {
8801 try {
8802 if (!(name in source)) {
8803 return function() {};
8804 }
8805 var original = source[name];
8806 var wrapped = replacement(original);
8807 if (typeof wrapped === "function") {
8808 wrapped.prototype = wrapped.prototype || {};
8809 Object.defineProperties(wrapped, {
8810 __rrweb_original__: {
8811 enumerable: false,
8812 value: original
8813 }
8814 });
8815 }
8816 source[name] = wrapped;
8817 return function() {
8818 source[name] = original;
8819 };
8820 } catch (e) {
8821 return function() {};
8822 }
8823 }
8824 var index$1 = {
8825 childNodes: childNodes$1,
8826 parentNode: parentNode$1,
8827 parentElement: parentElement$1,
8828 textContent: textContent$1,
8829 contains: contains$1,
8830 getRootNode: getRootNode$1,
8831 host: host$1,
8832 styleSheets: styleSheets$1,
8833 shadowRoot: shadowRoot$1,
8834 querySelector: querySelector$1,
8835 querySelectorAll: querySelectorAll$1,
8836 mutationObserver: mutationObserverCtor$1,
8837 patch: patch$1
8838 };
8839 function isElement(n2) {
8840 return n2.nodeType === n2.ELEMENT_NODE;
8841 }
8842 function isShadowRoot(n2) {
8843 var hostEl = // anchor and textarea elements also have a `host` property
8844 // but only shadow roots have a `mode` property
8845 n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null;
8846 return Boolean(hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2);
8847 }
8848 function isNativeShadowDom(shadowRoot2) {
8849 return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
8850 }
8851 function fixBrowserCompatibilityIssuesInCSS(cssText) {
8852 if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
8853 cssText = cssText.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;");
8854 }
8855 return cssText;
8856 }
8857 function escapeImportStatement(rule2) {
8858 var cssText = rule2.cssText;
8859 if (cssText.split('"').length < 3) return cssText;
8860 var statement = [
8861 "@import",
8862 "url(" + JSON.stringify(rule2.href) + ")"
8863 ];
8864 if (rule2.layerName === "") {
8865 statement.push("layer");
8866 } else if (rule2.layerName) {
8867 statement.push("layer(" + rule2.layerName + ")");
8868 }
8869 if (rule2.supportsText) {
8870 statement.push("supports(" + rule2.supportsText + ")");
8871 }
8872 if (rule2.media.length) {
8873 statement.push(rule2.media.mediaText);
8874 }
8875 return statement.join(" ") + ";";
8876 }
8877 function stringifyStylesheet(s2) {
8878 try {
8879 var rules2 = s2.rules || s2.cssRules;
8880 if (!rules2) {
8881 return null;
8882 }
8883 var sheetHref = s2.href;
8884 if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
8885 sheetHref = s2.ownerNode.ownerDocument.location.href;
8886 }
8887 var stringifiedRules = Array.from(rules2, function(rule2) {
8888 return stringifyRule(rule2, sheetHref);
8889 }).join("");
8890 return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
8891 } catch (error) {
8892 return null;
8893 }
8894 }
8895 function stringifyRule(rule2, sheetHref) {
8896 if (isCSSImportRule(rule2)) {
8897 var importStringified;
8898 try {
8899 importStringified = // we can access the imported stylesheet rules directly
8900 stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
8901 escapeImportStatement(rule2);
8902 } catch (error) {
8903 importStringified = rule2.cssText;
8904 }
8905 if (rule2.styleSheet.href) {
8906 return absolutifyURLs(importStringified, rule2.styleSheet.href);
8907 }
8908 return importStringified;
8909 } else {
8910 var ruleStringified = rule2.cssText;
8911 if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
8912 ruleStringified = fixSafariColons(ruleStringified);
8913 }
8914 if (sheetHref) {
8915 return absolutifyURLs(ruleStringified, sheetHref);
8916 }
8917 return ruleStringified;
8918 }
8919 }
8920 function fixSafariColons(cssStringified) {
8921 var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
8922 return cssStringified.replace(regex, "$1\\$2");
8923 }
8924 function isCSSImportRule(rule2) {
8925 return "styleSheet" in rule2;
8926 }
8927 function isCSSStyleRule(rule2) {
8928 return "selectorText" in rule2;
8929 }
8930 var Mirror = /*#__PURE__*/ function() {
8931 function Mirror() {
8932 __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
8933 __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
8934 }
8935 var _proto = Mirror.prototype;
8936 _proto.getId = function getId(n2) {
8937 var _a2;
8938 if (!n2) return -1;
8939 var id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id;
8940 return id != null ? id : -1;
8941 };
8942 _proto.getNode = function getNode(id) {
8943 return this.idNodeMap.get(id) || null;
8944 };
8945 _proto.getIds = function getIds() {
8946 return Array.from(this.idNodeMap.keys());
8947 };
8948 _proto.getMeta = function getMeta(n2) {
8949 return this.nodeMetaMap.get(n2) || null;
8950 };
8951 // removes the node from idNodeMap
8952 // doesn't remove the node from nodeMetaMap
8953 _proto.removeNodeFromMap = function removeNodeFromMap(n2) {
8954 var _this = this;
8955 var id = this.getId(n2);
8956 this.idNodeMap.delete(id);
8957 if (n2.childNodes) {
8958 n2.childNodes.forEach(function(childNode) {
8959 return _this.removeNodeFromMap(childNode);
8960 });
8961 }
8962 };
8963 _proto.has = function has(id) {
8964 return this.idNodeMap.has(id);
8965 };
8966 _proto.hasNode = function hasNode(node2) {
8967 return this.nodeMetaMap.has(node2);
8968 };
8969 _proto.add = function add(n2, meta) {
8970 var id = meta.id;
8971 this.idNodeMap.set(id, n2);
8972 this.nodeMetaMap.set(n2, meta);
8973 };
8974 _proto.replace = function replace(id, n2) {
8975 var oldNode = this.getNode(id);
8976 if (oldNode) {
8977 var meta = this.nodeMetaMap.get(oldNode);
8978 if (meta) this.nodeMetaMap.set(n2, meta);
8979 }
8980 this.idNodeMap.set(id, n2);
8981 };
8982 _proto.reset = function reset() {
8983 this.idNodeMap = /* @__PURE__ */ new Map();
8984 this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
8985 };
8986 return Mirror;
8987 }();
8988 function createMirror$2() {
8989 return new Mirror();
8990 }
8991 function maskInputValue(param) {
8992 var element = param.element, maskInputOptions = param.maskInputOptions, tagName = param.tagName, type = param.type, value = param.value, maskInputFn = param.maskInputFn;
8993 var text = value || "";
8994 var actualType = type && toLowerCase(type);
8995 if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
8996 if (maskInputFn) {
8997 text = maskInputFn(text, element);
8998 } else {
8999 text = "*".repeat(text.length);
9000 }
9001 }
9002 return text;
9003 }
9004 function toLowerCase(str) {
9005 return str.toLowerCase();
9006 }
9007 var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
9008 function is2DCanvasBlank(canvas) {
9009 var ctx = canvas.getContext("2d");
9010 if (!ctx) return true;
9011 var chunkSize = 50;
9012 for(var x2 = 0; x2 < canvas.width; x2 += chunkSize){
9013 for(var y = 0; y < canvas.height; y += chunkSize){
9014 var getImageData = ctx.getImageData;
9015 var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
9016 var pixelBuffer = new Uint32Array(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
9017 originalGetImageData.call(ctx, x2, y, Math.min(chunkSize, canvas.width - x2), Math.min(chunkSize, canvas.height - y)).data.buffer);
9018 if (pixelBuffer.some(function(pixel) {
9019 return pixel !== 0;
9020 })) return false;
9021 }
9022 }
9023 return true;
9024 }
9025 function getInputType(element) {
9026 var type = element.type;
9027 return element.hasAttribute("data-rr-is-password") ? "password" : type ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
9028 toLowerCase(type) : null;
9029 }
9030 function extractFileExtension(path, baseURL) {
9031 var url;
9032 try {
9033 url = new URL(path, baseURL != null ? baseURL : window.location.href);
9034 } catch (err) {
9035 return null;
9036 }
9037 var regex = /\.([0-9a-z]+)(?:$)/i;
9038 var match = url.pathname.match(regex);
9039 var _ref;
9040 return (_ref = match == null ? void 0 : match[1]) != null ? _ref : null;
9041 }
9042 function extractOrigin(url) {
9043 var origin = "";
9044 if (url.indexOf("//") > -1) {
9045 origin = url.split("/").slice(0, 3).join("/");
9046 } else {
9047 origin = url.split("/")[0];
9048 }
9049 origin = origin.split("?")[0];
9050 return origin;
9051 }
9052 var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
9053 var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
9054 var URL_WWW_MATCH = /^www\..*/i;
9055 var DATA_URI = /^(data:)([^,]*),(.*)/i;
9056 function absolutifyURLs(cssText, href) {
9057 return (cssText || "").replace(URL_IN_CSS_REF, function(origin, quote1, path1, quote2, path2, path3) {
9058 var filePath = path1 || path2 || path3;
9059 var maybeQuote = quote1 || quote2 || "";
9060 if (!filePath) {
9061 return origin;
9062 }
9063 if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
9064 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9065 }
9066 if (DATA_URI.test(filePath)) {
9067 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9068 }
9069 if (filePath[0] === "/") {
9070 return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
9071 }
9072 var stack = href.split("/");
9073 var parts = filePath.split("/");
9074 stack.pop();
9075 for(var _iterator = _create_for_of_iterator_helper_loose(parts), _step; !(_step = _iterator()).done;){
9076 var part = _step.value;
9077 if (part === ".") {
9078 continue;
9079 } else if (part === "..") {
9080 stack.pop();
9081 } else {
9082 stack.push(part);
9083 }
9084 }
9085 return "url(" + maybeQuote + stack.join("/") + maybeQuote + ")";
9086 });
9087 }
9088 function normalizeCssString(cssText, _testNoPxNorm) {
9089 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9090 if (_testNoPxNorm) {
9091 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
9092 } else {
9093 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
9094 }
9095 }
9096 function splitCssText(cssText, style, _testNoPxNorm) {
9097 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9098 var childNodes2 = Array.from(style.childNodes);
9099 var splits = [];
9100 var iterCount = 0;
9101 if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
9102 var cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
9103 var normFactor = cssTextNorm.length / cssText.length;
9104 for(var i2 = 1; i2 < childNodes2.length; i2++){
9105 if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
9106 var textContentNorm = normalizeCssString(childNodes2[i2].textContent, _testNoPxNorm);
9107 var jLimit = 100;
9108 var j = 3;
9109 for(; j < textContentNorm.length; j++){
9110 if (// keep consuming css identifiers (to get a decent chunk more quickly)
9111 textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
9112 textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1) {
9113 continue;
9114 }
9115 break;
9116 }
9117 for(; j < textContentNorm.length; j++){
9118 var startSubstring = textContentNorm.substring(0, j);
9119 var cssNormSplits = cssTextNorm.split(startSubstring);
9120 var splitNorm = -1;
9121 if (cssNormSplits.length === 2) {
9122 splitNorm = cssNormSplits[0].length;
9123 } else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
9124 splitNorm = cssTextNorm.indexOf(startSubstring, 1);
9125 } else if (cssNormSplits.length === 1) {
9126 startSubstring = startSubstring.substring(0, startSubstring.length - 1);
9127 cssNormSplits = cssTextNorm.split(startSubstring);
9128 if (cssNormSplits.length <= 1) {
9129 splits.push(cssText);
9130 return splits;
9131 }
9132 j = jLimit + 1;
9133 } else if (j === textContentNorm.length - 1) {
9134 splitNorm = cssTextNorm.indexOf(startSubstring);
9135 }
9136 if (cssNormSplits.length >= 2 && j > jLimit) {
9137 var prevTextContent = childNodes2[i2 - 1].textContent;
9138 if (prevTextContent && typeof prevTextContent === "string") {
9139 var prevMinLength = normalizeCssString(prevTextContent).length;
9140 splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
9141 }
9142 if (splitNorm === -1) {
9143 splitNorm = cssNormSplits[0].length;
9144 }
9145 }
9146 if (splitNorm !== -1) {
9147 var k = Math.floor(splitNorm / normFactor);
9148 for(; k > 0 && k < cssText.length;){
9149 iterCount += 1;
9150 if (iterCount > 50 * childNodes2.length) {
9151 splits.push(cssText);
9152 return splits;
9153 }
9154 var normPart = normalizeCssString(cssText.substring(0, k), _testNoPxNorm);
9155 if (normPart.length === splitNorm) {
9156 splits.push(cssText.substring(0, k));
9157 cssText = cssText.substring(k);
9158 cssTextNorm = cssTextNorm.substring(splitNorm);
9159 break;
9160 } else if (normPart.length < splitNorm) {
9161 k += Math.max(1, Math.floor((splitNorm - normPart.length) / normFactor));
9162 } else {
9163 k -= Math.max(1, Math.floor((normPart.length - splitNorm) * normFactor));
9164 }
9165 }
9166 break;
9167 }
9168 }
9169 }
9170 }
9171 }
9172 splits.push(cssText);
9173 return splits;
9174 }
9175 function markCssSplits(cssText, style) {
9176 return splitCssText(cssText, style).join("/* rr_split */");
9177 }
9178 var _id = 1;
9179 var tagNameRegex = new RegExp("[^a-z0-9-_:]");
9180 var IGNORED_NODE = -2;
9181 function genId() {
9182 return _id++;
9183 }
9184 function getValidTagName$1(element) {
9185 if (_instanceof(element, HTMLFormElement)) {
9186 return "form";
9187 }
9188 var processedTagName = toLowerCase(element.tagName);
9189 if (tagNameRegex.test(processedTagName)) {
9190 return "div";
9191 }
9192 return processedTagName;
9193 }
9194 var canvasService;
9195 var canvasCtx;
9196 var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
9197 var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
9198 function getAbsoluteSrcsetString(doc, attributeValue) {
9199 if (attributeValue.trim() === "") {
9200 return attributeValue;
9201 }
9202 var pos = 0;
9203 function collectCharacters(regEx) {
9204 var chars2;
9205 var match = regEx.exec(attributeValue.substring(pos));
9206 if (match) {
9207 chars2 = match[0];
9208 pos += chars2.length;
9209 return chars2;
9210 }
9211 return "";
9212 }
9213 var output = [];
9214 while(true){
9215 collectCharacters(SRCSET_COMMAS_OR_SPACES);
9216 if (pos >= attributeValue.length) {
9217 break;
9218 }
9219 var url = collectCharacters(SRCSET_NOT_SPACES);
9220 if (url.slice(-1) === ",") {
9221 url = absoluteToDoc(doc, url.substring(0, url.length - 1));
9222 output.push(url);
9223 } else {
9224 var descriptorsStr = "";
9225 url = absoluteToDoc(doc, url);
9226 var inParens = false;
9227 while(true){
9228 var c2 = attributeValue.charAt(pos);
9229 if (c2 === "") {
9230 output.push((url + descriptorsStr).trim());
9231 break;
9232 } else if (!inParens) {
9233 if (c2 === ",") {
9234 pos += 1;
9235 output.push((url + descriptorsStr).trim());
9236 break;
9237 } else if (c2 === "(") {
9238 inParens = true;
9239 }
9240 } else {
9241 if (c2 === ")") {
9242 inParens = false;
9243 }
9244 }
9245 descriptorsStr += c2;
9246 pos += 1;
9247 }
9248 }
9249 }
9250 return output.join(", ");
9251 }
9252 var cachedDocument = /* @__PURE__ */ new WeakMap();
9253 function absoluteToDoc(doc, attributeValue) {
9254 if (!attributeValue || attributeValue.trim() === "") {
9255 return attributeValue;
9256 }
9257 return getHref(doc, attributeValue);
9258 }
9259 function isSVGElement(el) {
9260 return Boolean(el.tagName === "svg" || el.ownerSVGElement);
9261 }
9262 function getHref(doc, customHref) {
9263 var a2 = cachedDocument.get(doc);
9264 if (!a2) {
9265 a2 = doc.createElement("a");
9266 cachedDocument.set(doc, a2);
9267 }
9268 if (!customHref) {
9269 customHref = "";
9270 } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
9271 return customHref;
9272 }
9273 a2.setAttribute("href", customHref);
9274 return a2.href;
9275 }
9276 function transformAttribute(doc, tagName, name, value) {
9277 if (!value) {
9278 return value;
9279 }
9280 if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
9281 return absoluteToDoc(doc, value);
9282 } else if (name === "xlink:href" && value[0] !== "#") {
9283 return absoluteToDoc(doc, value);
9284 } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
9285 return absoluteToDoc(doc, value);
9286 } else if (name === "srcset") {
9287 return getAbsoluteSrcsetString(doc, value);
9288 } else if (name === "style") {
9289 return absolutifyURLs(value, getHref(doc));
9290 } else if (tagName === "object" && name === "data") {
9291 return absoluteToDoc(doc, value);
9292 }
9293 return value;
9294 }
9295 function ignoreAttribute(tagName, name, _value) {
9296 return (tagName === "video" || tagName === "audio") && name === "autoplay";
9297 }
9298 function _isBlockedElement(element, blockClass, blockSelector) {
9299 try {
9300 if (typeof blockClass === "string") {
9301 if (element.classList.contains(blockClass)) {
9302 return true;
9303 }
9304 } else {
9305 for(var eIndex = element.classList.length; eIndex--;){
9306 var className = element.classList[eIndex];
9307 if (blockClass.test(className)) {
9308 return true;
9309 }
9310 }
9311 }
9312 if (blockSelector) {
9313 return element.matches(blockSelector);
9314 }
9315 } catch (e2) {}
9316 return false;
9317 }
9318 function classMatchesRegex(node2, regex, checkAncestors) {
9319 if (!node2) return false;
9320 if (node2.nodeType !== node2.ELEMENT_NODE) {
9321 if (!checkAncestors) return false;
9322 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9323 }
9324 for(var eIndex = node2.classList.length; eIndex--;){
9325 var className = node2.classList[eIndex];
9326 if (regex.test(className)) {
9327 return true;
9328 }
9329 }
9330 if (!checkAncestors) return false;
9331 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9332 }
9333 function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
9334 var el;
9335 if (isElement(node2)) {
9336 el = node2;
9337 if (!index$1.childNodes(el).length) {
9338 return false;
9339 }
9340 } else if (index$1.parentElement(node2) === null) {
9341 return false;
9342 } else {
9343 el = index$1.parentElement(node2);
9344 }
9345 try {
9346 if (typeof maskTextClass === "string") {
9347 if (checkAncestors) {
9348 if (el.closest("." + maskTextClass)) return true;
9349 } else {
9350 if (el.classList.contains(maskTextClass)) return true;
9351 }
9352 } else {
9353 if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
9354 }
9355 if (maskTextSelector) {
9356 if (checkAncestors) {
9357 if (el.closest(maskTextSelector)) return true;
9358 } else {
9359 if (el.matches(maskTextSelector)) return true;
9360 }
9361 }
9362 } catch (e2) {}
9363 return false;
9364 }
9365 function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
9366 var win = iframeEl.contentWindow;
9367 if (!win) {
9368 return;
9369 }
9370 var fired = false;
9371 var readyState;
9372 try {
9373 readyState = win.document.readyState;
9374 } catch (error) {
9375 return;
9376 }
9377 if (readyState !== "complete") {
9378 var timer = setTimeout(function() {
9379 if (!fired) {
9380 listener();
9381 fired = true;
9382 }
9383 }, iframeLoadTimeout);
9384 iframeEl.addEventListener("load", function() {
9385 clearTimeout(timer);
9386 fired = true;
9387 listener();
9388 });
9389 return;
9390 }
9391 var blankUrl = "about:blank";
9392 if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
9393 setTimeout(listener, 0);
9394 return iframeEl.addEventListener("load", listener);
9395 }
9396 iframeEl.addEventListener("load", listener);
9397 }
9398 function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
9399 var fired = false;
9400 var styleSheetLoaded;
9401 try {
9402 styleSheetLoaded = link.sheet;
9403 } catch (error) {
9404 return;
9405 }
9406 if (styleSheetLoaded) return;
9407 var timer = setTimeout(function() {
9408 if (!fired) {
9409 listener();
9410 fired = true;
9411 }
9412 }, styleSheetLoadTimeout);
9413 link.addEventListener("load", function() {
9414 clearTimeout(timer);
9415 fired = true;
9416 listener();
9417 });
9418 }
9419 function serializeNode(n2, options) {
9420 var doc = options.doc, mirror2 = options.mirror, blockClass = options.blockClass, blockSelector = options.blockSelector, needsMask = options.needsMask, inlineStylesheet = options.inlineStylesheet, _options_maskInputOptions = options.maskInputOptions, maskInputOptions = _options_maskInputOptions === void 0 ? {} : _options_maskInputOptions, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _options_dataURLOptions = options.dataURLOptions, dataURLOptions = _options_dataURLOptions === void 0 ? {} : _options_dataURLOptions, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn, _options_newlyAddedElement = options.newlyAddedElement, newlyAddedElement = _options_newlyAddedElement === void 0 ? false : _options_newlyAddedElement, _options_cssCaptured = options.cssCaptured, cssCaptured = _options_cssCaptured === void 0 ? false : _options_cssCaptured;
9421 var rootId = getRootId(doc, mirror2);
9422 switch(n2.nodeType){
9423 case n2.DOCUMENT_NODE:
9424 if (n2.compatMode !== "CSS1Compat") {
9425 return {
9426 type: NodeType$3.Document,
9427 childNodes: [],
9428 compatMode: n2.compatMode
9429 };
9430 } else {
9431 return {
9432 type: NodeType$3.Document,
9433 childNodes: []
9434 };
9435 }
9436 case n2.DOCUMENT_TYPE_NODE:
9437 return {
9438 type: NodeType$3.DocumentType,
9439 name: n2.name,
9440 publicId: n2.publicId,
9441 systemId: n2.systemId,
9442 rootId: rootId
9443 };
9444 case n2.ELEMENT_NODE:
9445 return serializeElementNode(n2, {
9446 doc: doc,
9447 blockClass: blockClass,
9448 blockSelector: blockSelector,
9449 inlineStylesheet: inlineStylesheet,
9450 maskInputOptions: maskInputOptions,
9451 maskInputFn: maskInputFn,
9452 dataURLOptions: dataURLOptions,
9453 inlineImages: inlineImages,
9454 recordCanvas: recordCanvas,
9455 keepIframeSrcFn: keepIframeSrcFn,
9456 newlyAddedElement: newlyAddedElement,
9457 rootId: rootId
9458 });
9459 case n2.TEXT_NODE:
9460 return serializeTextNode(n2, {
9461 doc: doc,
9462 needsMask: needsMask,
9463 maskTextFn: maskTextFn,
9464 rootId: rootId,
9465 cssCaptured: cssCaptured
9466 });
9467 case n2.CDATA_SECTION_NODE:
9468 return {
9469 type: NodeType$3.CDATA,
9470 textContent: "",
9471 rootId: rootId
9472 };
9473 case n2.COMMENT_NODE:
9474 return {
9475 type: NodeType$3.Comment,
9476 textContent: index$1.textContent(n2) || "",
9477 rootId: rootId
9478 };
9479 default:
9480 return false;
9481 }
9482 }
9483 function getRootId(doc, mirror2) {
9484 if (!mirror2.hasNode(doc)) return void 0;
9485 var docId = mirror2.getId(doc);
9486 return docId === 1 ? void 0 : docId;
9487 }
9488 function serializeTextNode(n2, options) {
9489 var needsMask = options.needsMask, maskTextFn = options.maskTextFn, rootId = options.rootId, cssCaptured = options.cssCaptured;
9490 var parent = index$1.parentNode(n2);
9491 var parentTagName = parent && parent.tagName;
9492 var textContent2 = "";
9493 var isStyle = parentTagName === "STYLE" ? true : void 0;
9494 var isScript = parentTagName === "SCRIPT" ? true : void 0;
9495 if (isScript) {
9496 textContent2 = "SCRIPT_PLACEHOLDER";
9497 } else if (!cssCaptured) {
9498 textContent2 = index$1.textContent(n2);
9499 if (isStyle && textContent2) {
9500 textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
9501 }
9502 }
9503 if (!isStyle && !isScript && textContent2 && needsMask) {
9504 textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
9505 }
9506 return {
9507 type: NodeType$3.Text,
9508 textContent: textContent2 || "",
9509 rootId: rootId
9510 };
9511 }
9512 function serializeElementNode(n2, options) {
9513 var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, inlineStylesheet = options.inlineStylesheet, _options_maskInputOptions = options.maskInputOptions, maskInputOptions = _options_maskInputOptions === void 0 ? {} : _options_maskInputOptions, maskInputFn = options.maskInputFn, _options_dataURLOptions = options.dataURLOptions, dataURLOptions = _options_dataURLOptions === void 0 ? {} : _options_dataURLOptions, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn, _options_newlyAddedElement = options.newlyAddedElement, newlyAddedElement = _options_newlyAddedElement === void 0 ? false : _options_newlyAddedElement, rootId = options.rootId;
9514 var needBlock = _isBlockedElement(n2, blockClass, blockSelector);
9515 var tagName = getValidTagName$1(n2);
9516 var attributes = {};
9517 var len = n2.attributes.length;
9518 for(var i2 = 0; i2 < len; i2++){
9519 var attr = n2.attributes[i2];
9520 if (!ignoreAttribute(tagName, attr.name, attr.value)) {
9521 attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
9522 }
9523 }
9524 if (tagName === "link" && inlineStylesheet) {
9525 var stylesheet = Array.from(doc.styleSheets).find(function(s2) {
9526 return s2.href === n2.href;
9527 });
9528 var cssText = null;
9529 if (stylesheet) {
9530 cssText = stringifyStylesheet(stylesheet);
9531 }
9532 if (cssText) {
9533 delete attributes.rel;
9534 delete attributes.href;
9535 attributes._cssText = cssText;
9536 }
9537 }
9538 if (tagName === "style" && n2.sheet) {
9539 var cssText1 = stringifyStylesheet(n2.sheet);
9540 if (cssText1) {
9541 if (n2.childNodes.length > 1) {
9542 cssText1 = markCssSplits(cssText1, n2);
9543 }
9544 attributes._cssText = cssText1;
9545 }
9546 }
9547 if (tagName === "input" || tagName === "textarea" || tagName === "select") {
9548 var value = n2.value;
9549 var checked = n2.checked;
9550 if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
9551 attributes.value = maskInputValue({
9552 element: n2,
9553 type: getInputType(n2),
9554 tagName: tagName,
9555 value: value,
9556 maskInputOptions: maskInputOptions,
9557 maskInputFn: maskInputFn
9558 });
9559 } else if (checked) {
9560 attributes.checked = checked;
9561 }
9562 }
9563 if (tagName === "option") {
9564 if (n2.selected && !maskInputOptions["select"]) {
9565 attributes.selected = true;
9566 } else {
9567 delete attributes.selected;
9568 }
9569 }
9570 if (tagName === "dialog" && n2.open) {
9571 attributes.rr_open_mode = n2.matches("dialog:modal") ? "modal" : "non-modal";
9572 }
9573 if (tagName === "canvas" && recordCanvas) {
9574 if (n2.__context === "2d") {
9575 if (!is2DCanvasBlank(n2)) {
9576 attributes.rr_dataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9577 }
9578 } else if (!("__context" in n2)) {
9579 var canvasDataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9580 var blankCanvas = doc.createElement("canvas");
9581 blankCanvas.width = n2.width;
9582 blankCanvas.height = n2.height;
9583 var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9584 if (canvasDataURL !== blankCanvasDataURL) {
9585 attributes.rr_dataURL = canvasDataURL;
9586 }
9587 }
9588 }
9589 if (tagName === "img" && inlineImages) {
9590 if (!canvasService) {
9591 canvasService = doc.createElement("canvas");
9592 canvasCtx = canvasService.getContext("2d");
9593 }
9594 var image = n2;
9595 var imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
9596 var priorCrossOrigin = image.crossOrigin;
9597 var recordInlineImage = function() {
9598 image.removeEventListener("load", recordInlineImage);
9599 try {
9600 canvasService.width = image.naturalWidth;
9601 canvasService.height = image.naturalHeight;
9602 canvasCtx.drawImage(image, 0, 0);
9603 attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9604 } catch (err) {
9605 if (image.crossOrigin !== "anonymous") {
9606 image.crossOrigin = "anonymous";
9607 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
9608 else image.addEventListener("load", recordInlineImage);
9609 return;
9610 } else {
9611 console.warn("Cannot inline img src=" + imageSrc + "! Error: " + err);
9612 }
9613 }
9614 if (image.crossOrigin === "anonymous") {
9615 priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
9616 }
9617 };
9618 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
9619 else image.addEventListener("load", recordInlineImage);
9620 }
9621 if (tagName === "audio" || tagName === "video") {
9622 var mediaAttributes = attributes;
9623 mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
9624 mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
9625 mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
9626 mediaAttributes.rr_mediaMuted = n2.muted;
9627 mediaAttributes.rr_mediaLoop = n2.loop;
9628 mediaAttributes.rr_mediaVolume = n2.volume;
9629 }
9630 if (!newlyAddedElement) {
9631 if (n2.scrollLeft) {
9632 attributes.rr_scrollLeft = n2.scrollLeft;
9633 }
9634 if (n2.scrollTop) {
9635 attributes.rr_scrollTop = n2.scrollTop;
9636 }
9637 }
9638 if (needBlock) {
9639 var _n2_getBoundingClientRect = n2.getBoundingClientRect(), width = _n2_getBoundingClientRect.width, height = _n2_getBoundingClientRect.height;
9640 attributes = {
9641 class: attributes.class,
9642 rr_width: "" + width + "px",
9643 rr_height: "" + height + "px"
9644 };
9645 }
9646 if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
9647 if (!n2.contentDocument) {
9648 attributes.rr_src = attributes.src;
9649 }
9650 delete attributes.src;
9651 }
9652 var isCustomElement;
9653 try {
9654 if (customElements.get(tagName)) isCustomElement = true;
9655 } catch (e2) {}
9656 return {
9657 type: NodeType$3.Element,
9658 tagName: tagName,
9659 attributes: attributes,
9660 childNodes: [],
9661 isSVG: isSVGElement(n2) || void 0,
9662 needBlock: needBlock,
9663 rootId: rootId,
9664 isCustom: isCustomElement
9665 };
9666 }
9667 function lowerIfExists(maybeAttr) {
9668 if (maybeAttr === void 0 || maybeAttr === null) {
9669 return "";
9670 } else {
9671 return maybeAttr.toLowerCase();
9672 }
9673 }
9674 function slimDOMExcluded(sn, slimDOMOptions) {
9675 if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
9676 return true;
9677 } else if (sn.type === NodeType$3.Element) {
9678 if (slimDOMOptions.script && // script tag
9679 (sn.tagName === "script" || // (module)preload link
9680 sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
9681 sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
9682 return true;
9683 } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) || lowerIfExists(sn.attributes.name) === "application-name" || lowerIfExists(sn.attributes.rel) === "icon" || lowerIfExists(sn.attributes.rel) === "apple-touch-icon" || lowerIfExists(sn.attributes.rel) === "shortcut icon"))) {
9684 return true;
9685 } else if (sn.tagName === "meta") {
9686 if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
9687 return true;
9688 } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
9689 lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
9690 return true;
9691 } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
9692 return true;
9693 } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
9694 return true;
9695 } else if (slimDOMOptions.headMetaAuthorship && (lowerIfExists(sn.attributes.name) === "author" || lowerIfExists(sn.attributes.name) === "generator" || lowerIfExists(sn.attributes.name) === "framework" || lowerIfExists(sn.attributes.name) === "publisher" || lowerIfExists(sn.attributes.name) === "progid" || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
9696 return true;
9697 } else if (slimDOMOptions.headMetaVerification && (lowerIfExists(sn.attributes.name) === "google-site-verification" || lowerIfExists(sn.attributes.name) === "yandex-verification" || lowerIfExists(sn.attributes.name) === "csrf-token" || lowerIfExists(sn.attributes.name) === "p:domain_verify" || lowerIfExists(sn.attributes.name) === "verify-v1" || lowerIfExists(sn.attributes.name) === "verification" || lowerIfExists(sn.attributes.name) === "shopify-checkout-api-token")) {
9698 return true;
9699 }
9700 }
9701 }
9702 return false;
9703 }
9704 function serializeNodeWithId(n2, options) {
9705 var doc = options.doc, mirror2 = options.mirror, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _options_skipChild = options.skipChild, skipChild = _options_skipChild === void 0 ? false : _options_skipChild, _options_inlineStylesheet = options.inlineStylesheet, inlineStylesheet = _options_inlineStylesheet === void 0 ? true : _options_inlineStylesheet, _options_maskInputOptions = options.maskInputOptions, maskInputOptions = _options_maskInputOptions === void 0 ? {} : _options_maskInputOptions, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _options_dataURLOptions = options.dataURLOptions, dataURLOptions = _options_dataURLOptions === void 0 ? {} : _options_dataURLOptions, _options_inlineImages = options.inlineImages, inlineImages = _options_inlineImages === void 0 ? false : _options_inlineImages, _options_recordCanvas = options.recordCanvas, recordCanvas = _options_recordCanvas === void 0 ? false : _options_recordCanvas, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _options_iframeLoadTimeout = options.iframeLoadTimeout, iframeLoadTimeout = _options_iframeLoadTimeout === void 0 ? 5e3 : _options_iframeLoadTimeout, onStylesheetLoad = options.onStylesheetLoad, _options_stylesheetLoadTimeout = options.stylesheetLoadTimeout, stylesheetLoadTimeout = _options_stylesheetLoadTimeout === void 0 ? 5e3 : _options_stylesheetLoadTimeout, _options_keepIframeSrcFn = options.keepIframeSrcFn, keepIframeSrcFn = _options_keepIframeSrcFn === void 0 ? function() {
9706 return false;
9707 } : _options_keepIframeSrcFn, _options_newlyAddedElement = options.newlyAddedElement, newlyAddedElement = _options_newlyAddedElement === void 0 ? false : _options_newlyAddedElement, _options_cssCaptured = options.cssCaptured, cssCaptured = _options_cssCaptured === void 0 ? false : _options_cssCaptured;
9708 var needsMask = options.needsMask;
9709 var _options_preserveWhiteSpace = options.preserveWhiteSpace, preserveWhiteSpace = _options_preserveWhiteSpace === void 0 ? true : _options_preserveWhiteSpace;
9710 if (!needsMask) {
9711 var checkAncestors = needsMask === void 0;
9712 needsMask = needMaskingText(n2, maskTextClass, maskTextSelector, checkAncestors);
9713 }
9714 var _serializedNode = serializeNode(n2, {
9715 doc: doc,
9716 mirror: mirror2,
9717 blockClass: blockClass,
9718 blockSelector: blockSelector,
9719 needsMask: needsMask,
9720 inlineStylesheet: inlineStylesheet,
9721 maskInputOptions: maskInputOptions,
9722 maskTextFn: maskTextFn,
9723 maskInputFn: maskInputFn,
9724 dataURLOptions: dataURLOptions,
9725 inlineImages: inlineImages,
9726 recordCanvas: recordCanvas,
9727 keepIframeSrcFn: keepIframeSrcFn,
9728 newlyAddedElement: newlyAddedElement,
9729 cssCaptured: cssCaptured
9730 });
9731 if (!_serializedNode) {
9732 console.warn(n2, "not serialized");
9733 return null;
9734 }
9735 var id;
9736 if (mirror2.hasNode(n2)) {
9737 id = mirror2.getId(n2);
9738 } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
9739 id = IGNORED_NODE;
9740 } else {
9741 id = genId();
9742 }
9743 var serializedNode = Object.assign(_serializedNode, {
9744 id: id
9745 });
9746 mirror2.add(n2, serializedNode);
9747 if (id === IGNORED_NODE) {
9748 return null;
9749 }
9750 if (onSerialize) {
9751 onSerialize(n2);
9752 }
9753 var recordChild = !skipChild;
9754 if (serializedNode.type === NodeType$3.Element) {
9755 recordChild = recordChild && !serializedNode.needBlock;
9756 delete serializedNode.needBlock;
9757 var shadowRootEl = index$1.shadowRoot(n2);
9758 if (shadowRootEl && isNativeShadowDom(shadowRootEl)) serializedNode.isShadowHost = true;
9759 }
9760 if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
9761 if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
9762 preserveWhiteSpace = false;
9763 }
9764 var bypassOptions = {
9765 doc: doc,
9766 mirror: mirror2,
9767 blockClass: blockClass,
9768 blockSelector: blockSelector,
9769 needsMask: needsMask,
9770 maskTextClass: maskTextClass,
9771 maskTextSelector: maskTextSelector,
9772 skipChild: skipChild,
9773 inlineStylesheet: inlineStylesheet,
9774 maskInputOptions: maskInputOptions,
9775 maskTextFn: maskTextFn,
9776 maskInputFn: maskInputFn,
9777 slimDOMOptions: slimDOMOptions,
9778 dataURLOptions: dataURLOptions,
9779 inlineImages: inlineImages,
9780 recordCanvas: recordCanvas,
9781 preserveWhiteSpace: preserveWhiteSpace,
9782 onSerialize: onSerialize,
9783 onIframeLoad: onIframeLoad,
9784 iframeLoadTimeout: iframeLoadTimeout,
9785 onStylesheetLoad: onStylesheetLoad,
9786 stylesheetLoadTimeout: stylesheetLoadTimeout,
9787 keepIframeSrcFn: keepIframeSrcFn,
9788 cssCaptured: false
9789 };
9790 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
9791 else {
9792 if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
9793 bypassOptions.cssCaptured = true;
9794 }
9795 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(n2))), _step; !(_step = _iterator()).done;){
9796 var childN = _step.value;
9797 var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
9798 if (serializedChildNode) {
9799 serializedNode.childNodes.push(serializedChildNode);
9800 }
9801 }
9802 }
9803 var shadowRootEl1 = null;
9804 if (isElement(n2) && (shadowRootEl1 = index$1.shadowRoot(n2))) {
9805 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(shadowRootEl1))), _step1; !(_step1 = _iterator1()).done;){
9806 var childN1 = _step1.value;
9807 var serializedChildNode1 = serializeNodeWithId(childN1, bypassOptions);
9808 if (serializedChildNode1) {
9809 isNativeShadowDom(shadowRootEl1) && (serializedChildNode1.isShadow = true);
9810 serializedNode.childNodes.push(serializedChildNode1);
9811 }
9812 }
9813 }
9814 }
9815 var parent = index$1.parentNode(n2);
9816 if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
9817 serializedNode.isShadow = true;
9818 }
9819 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
9820 onceIframeLoaded(n2, function() {
9821 var iframeDoc = n2.contentDocument;
9822 if (iframeDoc && onIframeLoad) {
9823 var serializedIframeNode = serializeNodeWithId(iframeDoc, {
9824 doc: iframeDoc,
9825 mirror: mirror2,
9826 blockClass: blockClass,
9827 blockSelector: blockSelector,
9828 needsMask: needsMask,
9829 maskTextClass: maskTextClass,
9830 maskTextSelector: maskTextSelector,
9831 skipChild: false,
9832 inlineStylesheet: inlineStylesheet,
9833 maskInputOptions: maskInputOptions,
9834 maskTextFn: maskTextFn,
9835 maskInputFn: maskInputFn,
9836 slimDOMOptions: slimDOMOptions,
9837 dataURLOptions: dataURLOptions,
9838 inlineImages: inlineImages,
9839 recordCanvas: recordCanvas,
9840 preserveWhiteSpace: preserveWhiteSpace,
9841 onSerialize: onSerialize,
9842 onIframeLoad: onIframeLoad,
9843 iframeLoadTimeout: iframeLoadTimeout,
9844 onStylesheetLoad: onStylesheetLoad,
9845 stylesheetLoadTimeout: stylesheetLoadTimeout,
9846 keepIframeSrcFn: keepIframeSrcFn
9847 });
9848 if (serializedIframeNode) {
9849 onIframeLoad(n2, serializedIframeNode);
9850 }
9851 }
9852 }, iframeLoadTimeout);
9853 }
9854 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && extractFileExtension(serializedNode.attributes.href) === "css")) {
9855 onceStylesheetLoaded(n2, function() {
9856 if (onStylesheetLoad) {
9857 var serializedLinkNode = serializeNodeWithId(n2, {
9858 doc: doc,
9859 mirror: mirror2,
9860 blockClass: blockClass,
9861 blockSelector: blockSelector,
9862 needsMask: needsMask,
9863 maskTextClass: maskTextClass,
9864 maskTextSelector: maskTextSelector,
9865 skipChild: false,
9866 inlineStylesheet: inlineStylesheet,
9867 maskInputOptions: maskInputOptions,
9868 maskTextFn: maskTextFn,
9869 maskInputFn: maskInputFn,
9870 slimDOMOptions: slimDOMOptions,
9871 dataURLOptions: dataURLOptions,
9872 inlineImages: inlineImages,
9873 recordCanvas: recordCanvas,
9874 preserveWhiteSpace: preserveWhiteSpace,
9875 onSerialize: onSerialize,
9876 onIframeLoad: onIframeLoad,
9877 iframeLoadTimeout: iframeLoadTimeout,
9878 onStylesheetLoad: onStylesheetLoad,
9879 stylesheetLoadTimeout: stylesheetLoadTimeout,
9880 keepIframeSrcFn: keepIframeSrcFn
9881 });
9882 if (serializedLinkNode) {
9883 onStylesheetLoad(n2, serializedLinkNode);
9884 }
9885 }
9886 }, stylesheetLoadTimeout);
9887 }
9888 return serializedNode;
9889 }
9890 function snapshot(n2, options) {
9891 var _ref = options || {}, tmp = _ref.mirror, mirror2 = tmp === void 0 ? new Mirror() : tmp, _ref_blockClass = _ref.blockClass, blockClass = _ref_blockClass === void 0 ? "rr-block" : _ref_blockClass, _ref_blockSelector = _ref.blockSelector, blockSelector = _ref_blockSelector === void 0 ? null : _ref_blockSelector, _ref_maskTextClass = _ref.maskTextClass, maskTextClass = _ref_maskTextClass === void 0 ? "rr-mask" : _ref_maskTextClass, _ref_maskTextSelector = _ref.maskTextSelector, maskTextSelector = _ref_maskTextSelector === void 0 ? null : _ref_maskTextSelector, _ref_inlineStylesheet = _ref.inlineStylesheet, inlineStylesheet = _ref_inlineStylesheet === void 0 ? true : _ref_inlineStylesheet, _ref_inlineImages = _ref.inlineImages, inlineImages = _ref_inlineImages === void 0 ? false : _ref_inlineImages, _ref_recordCanvas = _ref.recordCanvas, recordCanvas = _ref_recordCanvas === void 0 ? false : _ref_recordCanvas, _ref_maskAllInputs = _ref.maskAllInputs, maskAllInputs = _ref_maskAllInputs === void 0 ? false : _ref_maskAllInputs, maskTextFn = _ref.maskTextFn, maskInputFn = _ref.maskInputFn, _ref_slimDOM = _ref.slimDOM, slimDOM = _ref_slimDOM === void 0 ? false : _ref_slimDOM, dataURLOptions = _ref.dataURLOptions, preserveWhiteSpace = _ref.preserveWhiteSpace, onSerialize = _ref.onSerialize, onIframeLoad = _ref.onIframeLoad, iframeLoadTimeout = _ref.iframeLoadTimeout, onStylesheetLoad = _ref.onStylesheetLoad, stylesheetLoadTimeout = _ref.stylesheetLoadTimeout, _ref_keepIframeSrcFn = _ref.keepIframeSrcFn, keepIframeSrcFn = _ref_keepIframeSrcFn === void 0 ? function() {
9892 return false;
9893 } : _ref_keepIframeSrcFn;
9894 var maskInputOptions = maskAllInputs === true ? {
9895 color: true,
9896 date: true,
9897 "datetime-local": true,
9898 email: true,
9899 month: true,
9900 number: true,
9901 range: true,
9902 search: true,
9903 tel: true,
9904 text: true,
9905 time: true,
9906 url: true,
9907 week: true,
9908 textarea: true,
9909 select: true,
9910 password: true,
9911 hidden: true
9912 } : maskAllInputs === false ? {
9913 password: true
9914 } : maskAllInputs;
9915 var slimDOMOptions = slimDOM === true || slimDOM === "all" ? // if true: set of sensible options that should not throw away any information
9916 {
9917 script: true,
9918 comment: true,
9919 headFavicon: true,
9920 headWhitespace: true,
9921 headMetaDescKeywords: slimDOM === "all",
9922 // destructive
9923 headMetaSocial: true,
9924 headMetaRobots: true,
9925 headMetaHttpEquiv: true,
9926 headMetaAuthorship: true,
9927 headMetaVerification: true
9928 } : slimDOM === false ? {} : slimDOM;
9929 return serializeNodeWithId(n2, {
9930 doc: n2,
9931 mirror: mirror2,
9932 blockClass: blockClass,
9933 blockSelector: blockSelector,
9934 maskTextClass: maskTextClass,
9935 maskTextSelector: maskTextSelector,
9936 skipChild: false,
9937 inlineStylesheet: inlineStylesheet,
9938 maskInputOptions: maskInputOptions,
9939 maskTextFn: maskTextFn,
9940 maskInputFn: maskInputFn,
9941 slimDOMOptions: slimDOMOptions,
9942 dataURLOptions: dataURLOptions,
9943 inlineImages: inlineImages,
9944 recordCanvas: recordCanvas,
9945 preserveWhiteSpace: preserveWhiteSpace,
9946 onSerialize: onSerialize,
9947 onIframeLoad: onIframeLoad,
9948 iframeLoadTimeout: iframeLoadTimeout,
9949 onStylesheetLoad: onStylesheetLoad,
9950 stylesheetLoadTimeout: stylesheetLoadTimeout,
9951 keepIframeSrcFn: keepIframeSrcFn,
9952 newlyAddedElement: false
9953 });
9954 }
9955 function getDefaultExportFromCjs$1(x2) {
9956 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
9957 }
9958 function getAugmentedNamespace$1(n2) {
9959 if (n2.__esModule) return n2;
9960 var f2 = n2.default;
9961 if (typeof f2 == "function") {
9962 var a2 = function a22() {
9963 if (_instanceof(this, a22)) {
9964 return Reflect.construct(f2, arguments, this.constructor);
9965 }
9966 return f2.apply(this, arguments);
9967 };
9968 a2.prototype = f2.prototype;
9969 } else a2 = {};
9970 Object.defineProperty(a2, "__esModule", {
9971 value: true
9972 });
9973 Object.keys(n2).forEach(function(k) {
9974 var d = Object.getOwnPropertyDescriptor(n2, k);
9975 Object.defineProperty(a2, k, d.get ? d : {
9976 enumerable: true,
9977 get: function get() {
9978 return n2[k];
9979 }
9980 });
9981 });
9982 return a2;
9983 }
9984 var picocolors_browser$1 = {
9985 exports: {}
9986 };
9987 var x$1 = String;
9988 var create$1 = function create$1() {
9989 return {
9990 isColorSupported: false,
9991 reset: x$1,
9992 bold: x$1,
9993 dim: x$1,
9994 italic: x$1,
9995 underline: x$1,
9996 inverse: x$1,
9997 hidden: x$1,
9998 strikethrough: x$1,
9999 black: x$1,
10000 red: x$1,
10001 green: x$1,
10002 yellow: x$1,
10003 blue: x$1,
10004 magenta: x$1,
10005 cyan: x$1,
10006 white: x$1,
10007 gray: x$1,
10008 bgBlack: x$1,
10009 bgRed: x$1,
10010 bgGreen: x$1,
10011 bgYellow: x$1,
10012 bgBlue: x$1,
10013 bgMagenta: x$1,
10014 bgCyan: x$1,
10015 bgWhite: x$1
10016 };
10017 };
10018 picocolors_browser$1.exports = create$1();
10019 picocolors_browser$1.exports.createColors = create$1;
10020 var picocolors_browserExports$1 = picocolors_browser$1.exports;
10021 var __viteBrowserExternal$2 = {};
10022 var __viteBrowserExternal$1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10023 __proto__: null,
10024 default: __viteBrowserExternal$2
10025 }, Symbol.toStringTag, {
10026 value: "Module"
10027 }));
10028 var require$$2$1 = /* @__PURE__ */ getAugmentedNamespace$1(__viteBrowserExternal$1$1);
10029 var pico$1 = picocolors_browserExports$1;
10030 var terminalHighlight$1$1 = require$$2$1;
10031 var CssSyntaxError$3$1 = /*#__PURE__*/ function(Error1) {
10032 _inherits(CssSyntaxError, Error1);
10033 function CssSyntaxError(message, line, column, source, file, plugin22) {
10034 var _this;
10035 _this = Error1.call(this, message) || this;
10036 _this.name = "CssSyntaxError";
10037 _this.reason = message;
10038 if (file) {
10039 _this.file = file;
10040 }
10041 if (source) {
10042 _this.source = source;
10043 }
10044 if (plugin22) {
10045 _this.plugin = plugin22;
10046 }
10047 if (typeof line !== "undefined" && typeof column !== "undefined") {
10048 if (typeof line === "number") {
10049 _this.line = line;
10050 _this.column = column;
10051 } else {
10052 _this.line = line.line;
10053 _this.column = line.column;
10054 _this.endLine = column.line;
10055 _this.endColumn = column.column;
10056 }
10057 }
10058 _this.setMessage();
10059 if (Error.captureStackTrace) {
10060 Error.captureStackTrace(_this, CssSyntaxError);
10061 }
10062 return _this;
10063 }
10064 var _proto = CssSyntaxError.prototype;
10065 _proto.setMessage = function setMessage() {
10066 this.message = this.plugin ? this.plugin + ": " : "";
10067 this.message += this.file ? this.file : "<css input>";
10068 if (typeof this.line !== "undefined") {
10069 this.message += ":" + this.line + ":" + this.column;
10070 }
10071 this.message += ": " + this.reason;
10072 };
10073 _proto.showSourceCode = function showSourceCode(color) {
10074 var _this = this;
10075 if (!this.source) return "";
10076 var css = this.source;
10077 if (color == null) color = pico$1.isColorSupported;
10078 if (terminalHighlight$1$1) {
10079 if (color) css = terminalHighlight$1$1(css);
10080 }
10081 var lines = css.split(/\r?\n/);
10082 var start = Math.max(this.line - 3, 0);
10083 var end = Math.min(this.line + 2, lines.length);
10084 var maxWidth = String(end).length;
10085 var mark, aside;
10086 if (color) {
10087 var _pico$1_createColors = pico$1.createColors(true), bold = _pico$1_createColors.bold, gray = _pico$1_createColors.gray, red = _pico$1_createColors.red;
10088 mark = function(text) {
10089 return bold(red(text));
10090 };
10091 aside = function(text) {
10092 return gray(text);
10093 };
10094 } else {
10095 mark = aside = function(str) {
10096 return str;
10097 };
10098 }
10099 return lines.slice(start, end).map(function(line, index2) {
10100 var number = start + 1 + index2;
10101 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
10102 if (number === _this.line) {
10103 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
10104 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
10105 }
10106 return " " + aside(gutter) + line;
10107 }).join("\n");
10108 };
10109 _proto.toString = function toString() {
10110 var code = this.showSourceCode();
10111 if (code) {
10112 code = "\n\n" + code + "\n";
10113 }
10114 return this.name + ": " + this.message + code;
10115 };
10116 return CssSyntaxError;
10117 }(_wrap_native_super(Error));
10118 var cssSyntaxError$1 = CssSyntaxError$3$1;
10119 CssSyntaxError$3$1.default = CssSyntaxError$3$1;
10120 var symbols$1 = {};
10121 symbols$1.isClean = Symbol("isClean");
10122 symbols$1.my = Symbol("my");
10123 var DEFAULT_RAW$1 = {
10124 after: "\n",
10125 beforeClose: "\n",
10126 beforeComment: "\n",
10127 beforeDecl: "\n",
10128 beforeOpen: " ",
10129 beforeRule: "\n",
10130 colon: ": ",
10131 commentLeft: " ",
10132 commentRight: " ",
10133 emptyBody: "",
10134 indent: " ",
10135 semicolon: false
10136 };
10137 function capitalize$1(str) {
10138 return str[0].toUpperCase() + str.slice(1);
10139 }
10140 var Stringifier$2$1 = /*#__PURE__*/ function() {
10141 function Stringifier(builder) {
10142 this.builder = builder;
10143 }
10144 var _proto = Stringifier.prototype;
10145 _proto.atrule = function atrule(node2, semicolon) {
10146 var name = "@" + node2.name;
10147 var params = node2.params ? this.rawValue(node2, "params") : "";
10148 if (typeof node2.raws.afterName !== "undefined") {
10149 name += node2.raws.afterName;
10150 } else if (params) {
10151 name += " ";
10152 }
10153 if (node2.nodes) {
10154 this.block(node2, name + params);
10155 } else {
10156 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
10157 this.builder(name + params + end, node2);
10158 }
10159 };
10160 _proto.beforeAfter = function beforeAfter(node2, detect) {
10161 var value;
10162 if (node2.type === "decl") {
10163 value = this.raw(node2, null, "beforeDecl");
10164 } else if (node2.type === "comment") {
10165 value = this.raw(node2, null, "beforeComment");
10166 } else if (detect === "before") {
10167 value = this.raw(node2, null, "beforeRule");
10168 } else {
10169 value = this.raw(node2, null, "beforeClose");
10170 }
10171 var buf = node2.parent;
10172 var depth = 0;
10173 while(buf && buf.type !== "root"){
10174 depth += 1;
10175 buf = buf.parent;
10176 }
10177 if (value.includes("\n")) {
10178 var indent = this.raw(node2, null, "indent");
10179 if (indent.length) {
10180 for(var step = 0; step < depth; step++)value += indent;
10181 }
10182 }
10183 return value;
10184 };
10185 _proto.block = function block(node2, start) {
10186 var between = this.raw(node2, "between", "beforeOpen");
10187 this.builder(start + between + "{", node2, "start");
10188 var after;
10189 if (node2.nodes && node2.nodes.length) {
10190 this.body(node2);
10191 after = this.raw(node2, "after");
10192 } else {
10193 after = this.raw(node2, "after", "emptyBody");
10194 }
10195 if (after) this.builder(after);
10196 this.builder("}", node2, "end");
10197 };
10198 _proto.body = function body(node2) {
10199 var last = node2.nodes.length - 1;
10200 while(last > 0){
10201 if (node2.nodes[last].type !== "comment") break;
10202 last -= 1;
10203 }
10204 var semicolon = this.raw(node2, "semicolon");
10205 for(var i2 = 0; i2 < node2.nodes.length; i2++){
10206 var child = node2.nodes[i2];
10207 var before = this.raw(child, "before");
10208 if (before) this.builder(before);
10209 this.stringify(child, last !== i2 || semicolon);
10210 }
10211 };
10212 _proto.comment = function comment(node2) {
10213 var left = this.raw(node2, "left", "commentLeft");
10214 var right = this.raw(node2, "right", "commentRight");
10215 this.builder("/*" + left + node2.text + right + "*/", node2);
10216 };
10217 _proto.decl = function decl(node2, semicolon) {
10218 var between = this.raw(node2, "between", "colon");
10219 var string = node2.prop + between + this.rawValue(node2, "value");
10220 if (node2.important) {
10221 string += node2.raws.important || " !important";
10222 }
10223 if (semicolon) string += ";";
10224 this.builder(string, node2);
10225 };
10226 _proto.document = function document1(node2) {
10227 this.body(node2);
10228 };
10229 _proto.raw = function raw(node2, own, detect) {
10230 var value;
10231 if (!detect) detect = own;
10232 if (own) {
10233 value = node2.raws[own];
10234 if (typeof value !== "undefined") return value;
10235 }
10236 var parent = node2.parent;
10237 if (detect === "before") {
10238 if (!parent || parent.type === "root" && parent.first === node2) {
10239 return "";
10240 }
10241 if (parent && parent.type === "document") {
10242 return "";
10243 }
10244 }
10245 if (!parent) return DEFAULT_RAW$1[detect];
10246 var root2 = node2.root();
10247 if (!root2.rawCache) root2.rawCache = {};
10248 if (typeof root2.rawCache[detect] !== "undefined") {
10249 return root2.rawCache[detect];
10250 }
10251 if (detect === "before" || detect === "after") {
10252 return this.beforeAfter(node2, detect);
10253 } else {
10254 var method = "raw" + capitalize$1(detect);
10255 if (this[method]) {
10256 value = this[method](root2, node2);
10257 } else {
10258 root2.walk(function(i2) {
10259 value = i2.raws[own];
10260 if (typeof value !== "undefined") return false;
10261 });
10262 }
10263 }
10264 if (typeof value === "undefined") value = DEFAULT_RAW$1[detect];
10265 root2.rawCache[detect] = value;
10266 return value;
10267 };
10268 _proto.rawBeforeClose = function rawBeforeClose(root2) {
10269 var value;
10270 root2.walk(function(i2) {
10271 if (i2.nodes && i2.nodes.length > 0) {
10272 if (typeof i2.raws.after !== "undefined") {
10273 value = i2.raws.after;
10274 if (value.includes("\n")) {
10275 value = value.replace(/[^\n]+$/, "");
10276 }
10277 return false;
10278 }
10279 }
10280 });
10281 if (value) value = value.replace(/\S/g, "");
10282 return value;
10283 };
10284 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
10285 var value;
10286 root2.walkComments(function(i2) {
10287 if (typeof i2.raws.before !== "undefined") {
10288 value = i2.raws.before;
10289 if (value.includes("\n")) {
10290 value = value.replace(/[^\n]+$/, "");
10291 }
10292 return false;
10293 }
10294 });
10295 if (typeof value === "undefined") {
10296 value = this.raw(node2, null, "beforeDecl");
10297 } else if (value) {
10298 value = value.replace(/\S/g, "");
10299 }
10300 return value;
10301 };
10302 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
10303 var value;
10304 root2.walkDecls(function(i2) {
10305 if (typeof i2.raws.before !== "undefined") {
10306 value = i2.raws.before;
10307 if (value.includes("\n")) {
10308 value = value.replace(/[^\n]+$/, "");
10309 }
10310 return false;
10311 }
10312 });
10313 if (typeof value === "undefined") {
10314 value = this.raw(node2, null, "beforeRule");
10315 } else if (value) {
10316 value = value.replace(/\S/g, "");
10317 }
10318 return value;
10319 };
10320 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
10321 var value;
10322 root2.walk(function(i2) {
10323 if (i2.type !== "decl") {
10324 value = i2.raws.between;
10325 if (typeof value !== "undefined") return false;
10326 }
10327 });
10328 return value;
10329 };
10330 _proto.rawBeforeRule = function rawBeforeRule(root2) {
10331 var value;
10332 root2.walk(function(i2) {
10333 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
10334 if (typeof i2.raws.before !== "undefined") {
10335 value = i2.raws.before;
10336 if (value.includes("\n")) {
10337 value = value.replace(/[^\n]+$/, "");
10338 }
10339 return false;
10340 }
10341 }
10342 });
10343 if (value) value = value.replace(/\S/g, "");
10344 return value;
10345 };
10346 _proto.rawColon = function rawColon(root2) {
10347 var value;
10348 root2.walkDecls(function(i2) {
10349 if (typeof i2.raws.between !== "undefined") {
10350 value = i2.raws.between.replace(/[^\s:]/g, "");
10351 return false;
10352 }
10353 });
10354 return value;
10355 };
10356 _proto.rawEmptyBody = function rawEmptyBody(root2) {
10357 var value;
10358 root2.walk(function(i2) {
10359 if (i2.nodes && i2.nodes.length === 0) {
10360 value = i2.raws.after;
10361 if (typeof value !== "undefined") return false;
10362 }
10363 });
10364 return value;
10365 };
10366 _proto.rawIndent = function rawIndent(root2) {
10367 if (root2.raws.indent) return root2.raws.indent;
10368 var value;
10369 root2.walk(function(i2) {
10370 var p = i2.parent;
10371 if (p && p !== root2 && p.parent && p.parent === root2) {
10372 if (typeof i2.raws.before !== "undefined") {
10373 var parts = i2.raws.before.split("\n");
10374 value = parts[parts.length - 1];
10375 value = value.replace(/\S/g, "");
10376 return false;
10377 }
10378 }
10379 });
10380 return value;
10381 };
10382 _proto.rawSemicolon = function rawSemicolon(root2) {
10383 var value;
10384 root2.walk(function(i2) {
10385 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
10386 value = i2.raws.semicolon;
10387 if (typeof value !== "undefined") return false;
10388 }
10389 });
10390 return value;
10391 };
10392 _proto.rawValue = function rawValue(node2, prop) {
10393 var value = node2[prop];
10394 var raw = node2.raws[prop];
10395 if (raw && raw.value === value) {
10396 return raw.raw;
10397 }
10398 return value;
10399 };
10400 _proto.root = function root(node2) {
10401 this.body(node2);
10402 if (node2.raws.after) this.builder(node2.raws.after);
10403 };
10404 _proto.rule = function rule(node2) {
10405 this.block(node2, this.rawValue(node2, "selector"));
10406 if (node2.raws.ownSemicolon) {
10407 this.builder(node2.raws.ownSemicolon, node2, "end");
10408 }
10409 };
10410 _proto.stringify = function stringify(node2, semicolon) {
10411 if (!this[node2.type]) {
10412 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
10413 }
10414 this[node2.type](node2, semicolon);
10415 };
10416 return Stringifier;
10417 }();
10418 var stringifier$1 = Stringifier$2$1;
10419 Stringifier$2$1.default = Stringifier$2$1;
10420 var Stringifier$1$1 = stringifier$1;
10421 function stringify$4$1(node2, builder) {
10422 var str = new Stringifier$1$1(builder);
10423 str.stringify(node2);
10424 }
10425 var stringify_1$1 = stringify$4$1;
10426 stringify$4$1.default = stringify$4$1;
10427 var isClean$2$1 = symbols$1.isClean, my$2$1 = symbols$1.my;
10428 var CssSyntaxError$2$1 = cssSyntaxError$1;
10429 var Stringifier2$1 = stringifier$1;
10430 var stringify$3$1 = stringify_1$1;
10431 function cloneNode$1(obj, parent) {
10432 var cloned = new obj.constructor();
10433 for(var i2 in obj){
10434 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
10435 continue;
10436 }
10437 if (i2 === "proxyCache") continue;
10438 var value = obj[i2];
10439 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
10440 if (i2 === "parent" && type === "object") {
10441 if (parent) cloned[i2] = parent;
10442 } else if (i2 === "source") {
10443 cloned[i2] = value;
10444 } else if (Array.isArray(value)) {
10445 cloned[i2] = value.map(function(j) {
10446 return cloneNode$1(j, cloned);
10447 });
10448 } else {
10449 if (type === "object" && value !== null) value = cloneNode$1(value);
10450 cloned[i2] = value;
10451 }
10452 }
10453 return cloned;
10454 }
10455 var Node$4$1 = /*#__PURE__*/ function() {
10456 function Node2(defaults) {
10457 if (defaults === void 0) defaults = {};
10458 this.raws = {};
10459 this[isClean$2$1] = false;
10460 this[my$2$1] = true;
10461 for(var name in defaults){
10462 if (name === "nodes") {
10463 this.nodes = [];
10464 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
10465 var node2 = _step.value;
10466 if (typeof node2.clone === "function") {
10467 this.append(node2.clone());
10468 } else {
10469 this.append(node2);
10470 }
10471 }
10472 } else {
10473 this[name] = defaults[name];
10474 }
10475 }
10476 }
10477 var _proto = Node2.prototype;
10478 _proto.addToError = function addToError(error) {
10479 error.postcssNode = this;
10480 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
10481 var s2 = this.source;
10482 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
10483 }
10484 return error;
10485 };
10486 _proto.after = function after(add) {
10487 this.parent.insertAfter(this, add);
10488 return this;
10489 };
10490 _proto.assign = function assign(overrides) {
10491 if (overrides === void 0) overrides = {};
10492 for(var name in overrides){
10493 this[name] = overrides[name];
10494 }
10495 return this;
10496 };
10497 _proto.before = function before(add) {
10498 this.parent.insertBefore(this, add);
10499 return this;
10500 };
10501 _proto.cleanRaws = function cleanRaws(keepBetween) {
10502 delete this.raws.before;
10503 delete this.raws.after;
10504 if (!keepBetween) delete this.raws.between;
10505 };
10506 _proto.clone = function clone(overrides) {
10507 if (overrides === void 0) overrides = {};
10508 var cloned = cloneNode$1(this);
10509 for(var name in overrides){
10510 cloned[name] = overrides[name];
10511 }
10512 return cloned;
10513 };
10514 _proto.cloneAfter = function cloneAfter(overrides) {
10515 if (overrides === void 0) overrides = {};
10516 var cloned = this.clone(overrides);
10517 this.parent.insertAfter(this, cloned);
10518 return cloned;
10519 };
10520 _proto.cloneBefore = function cloneBefore(overrides) {
10521 if (overrides === void 0) overrides = {};
10522 var cloned = this.clone(overrides);
10523 this.parent.insertBefore(this, cloned);
10524 return cloned;
10525 };
10526 _proto.error = function error(message, opts) {
10527 if (opts === void 0) opts = {};
10528 if (this.source) {
10529 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
10530 return this.source.input.error(message, {
10531 column: start.column,
10532 line: start.line
10533 }, {
10534 column: end.column,
10535 line: end.line
10536 }, opts);
10537 }
10538 return new CssSyntaxError$2$1(message);
10539 };
10540 _proto.getProxyProcessor = function getProxyProcessor() {
10541 return {
10542 get: function get(node2, prop) {
10543 if (prop === "proxyOf") {
10544 return node2;
10545 } else if (prop === "root") {
10546 return function() {
10547 return node2.root().toProxy();
10548 };
10549 } else {
10550 return node2[prop];
10551 }
10552 },
10553 set: function set(node2, prop, value) {
10554 if (node2[prop] === value) return true;
10555 node2[prop] = value;
10556 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
10557 node2.markDirty();
10558 }
10559 return true;
10560 }
10561 };
10562 };
10563 _proto.markDirty = function markDirty() {
10564 if (this[isClean$2$1]) {
10565 this[isClean$2$1] = false;
10566 var next = this;
10567 while(next = next.parent){
10568 next[isClean$2$1] = false;
10569 }
10570 }
10571 };
10572 _proto.next = function next() {
10573 if (!this.parent) return void 0;
10574 var index2 = this.parent.index(this);
10575 return this.parent.nodes[index2 + 1];
10576 };
10577 _proto.positionBy = function positionBy(opts, stringRepresentation) {
10578 var pos = this.source.start;
10579 if (opts.index) {
10580 pos = this.positionInside(opts.index, stringRepresentation);
10581 } else if (opts.word) {
10582 stringRepresentation = this.toString();
10583 var index2 = stringRepresentation.indexOf(opts.word);
10584 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
10585 }
10586 return pos;
10587 };
10588 _proto.positionInside = function positionInside(index2, stringRepresentation) {
10589 var string = stringRepresentation || this.toString();
10590 var column = this.source.start.column;
10591 var line = this.source.start.line;
10592 for(var i2 = 0; i2 < index2; i2++){
10593 if (string[i2] === "\n") {
10594 column = 1;
10595 line += 1;
10596 } else {
10597 column += 1;
10598 }
10599 }
10600 return {
10601 column: column,
10602 line: line
10603 };
10604 };
10605 _proto.prev = function prev() {
10606 if (!this.parent) return void 0;
10607 var index2 = this.parent.index(this);
10608 return this.parent.nodes[index2 - 1];
10609 };
10610 _proto.rangeBy = function rangeBy(opts) {
10611 var start = {
10612 column: this.source.start.column,
10613 line: this.source.start.line
10614 };
10615 var end = this.source.end ? {
10616 column: this.source.end.column + 1,
10617 line: this.source.end.line
10618 } : {
10619 column: start.column + 1,
10620 line: start.line
10621 };
10622 if (opts.word) {
10623 var stringRepresentation = this.toString();
10624 var index2 = stringRepresentation.indexOf(opts.word);
10625 if (index2 !== -1) {
10626 start = this.positionInside(index2, stringRepresentation);
10627 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
10628 }
10629 } else {
10630 if (opts.start) {
10631 start = {
10632 column: opts.start.column,
10633 line: opts.start.line
10634 };
10635 } else if (opts.index) {
10636 start = this.positionInside(opts.index);
10637 }
10638 if (opts.end) {
10639 end = {
10640 column: opts.end.column,
10641 line: opts.end.line
10642 };
10643 } else if (typeof opts.endIndex === "number") {
10644 end = this.positionInside(opts.endIndex);
10645 } else if (opts.index) {
10646 end = this.positionInside(opts.index + 1);
10647 }
10648 }
10649 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
10650 end = {
10651 column: start.column + 1,
10652 line: start.line
10653 };
10654 }
10655 return {
10656 end: end,
10657 start: start
10658 };
10659 };
10660 _proto.raw = function raw(prop, defaultType) {
10661 var str = new Stringifier2$1();
10662 return str.raw(this, prop, defaultType);
10663 };
10664 _proto.remove = function remove() {
10665 if (this.parent) {
10666 this.parent.removeChild(this);
10667 }
10668 this.parent = void 0;
10669 return this;
10670 };
10671 _proto.replaceWith = function replaceWith() {
10672 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
10673 nodes[_key] = arguments[_key];
10674 }
10675 if (this.parent) {
10676 var bookmark = this;
10677 var foundSelf = false;
10678 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
10679 var node2 = _step.value;
10680 if (node2 === this) {
10681 foundSelf = true;
10682 } else if (foundSelf) {
10683 this.parent.insertAfter(bookmark, node2);
10684 bookmark = node2;
10685 } else {
10686 this.parent.insertBefore(bookmark, node2);
10687 }
10688 }
10689 if (!foundSelf) {
10690 this.remove();
10691 }
10692 }
10693 return this;
10694 };
10695 _proto.root = function root() {
10696 var result2 = this;
10697 while(result2.parent && result2.parent.type !== "document"){
10698 result2 = result2.parent;
10699 }
10700 return result2;
10701 };
10702 _proto.toJSON = function toJSON(_, inputs) {
10703 var fixed = {};
10704 var emitInputs = inputs == null;
10705 inputs = inputs || /* @__PURE__ */ new Map();
10706 var inputsNextIndex = 0;
10707 for(var name in this){
10708 if (!Object.prototype.hasOwnProperty.call(this, name)) {
10709 continue;
10710 }
10711 if (name === "parent" || name === "proxyCache") continue;
10712 var value = this[name];
10713 if (Array.isArray(value)) {
10714 fixed[name] = value.map(function(i2) {
10715 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
10716 return i2.toJSON(null, inputs);
10717 } else {
10718 return i2;
10719 }
10720 });
10721 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
10722 fixed[name] = value.toJSON(null, inputs);
10723 } else if (name === "source") {
10724 var inputId = inputs.get(value.input);
10725 if (inputId == null) {
10726 inputId = inputsNextIndex;
10727 inputs.set(value.input, inputsNextIndex);
10728 inputsNextIndex++;
10729 }
10730 fixed[name] = {
10731 end: value.end,
10732 inputId: inputId,
10733 start: value.start
10734 };
10735 } else {
10736 fixed[name] = value;
10737 }
10738 }
10739 if (emitInputs) {
10740 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
10741 return input2.toJSON();
10742 });
10743 }
10744 return fixed;
10745 };
10746 _proto.toProxy = function toProxy() {
10747 if (!this.proxyCache) {
10748 this.proxyCache = new Proxy(this, this.getProxyProcessor());
10749 }
10750 return this.proxyCache;
10751 };
10752 _proto.toString = function toString(stringifier2) {
10753 if (stringifier2 === void 0) stringifier2 = stringify$3$1;
10754 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
10755 var result2 = "";
10756 stringifier2(this, function(i2) {
10757 result2 += i2;
10758 });
10759 return result2;
10760 };
10761 _proto.warn = function warn(result2, text, opts) {
10762 var data = {
10763 node: this
10764 };
10765 for(var i2 in opts)data[i2] = opts[i2];
10766 return result2.warn(text, data);
10767 };
10768 _create_class(Node2, [
10769 {
10770 key: "proxyOf",
10771 get: function get() {
10772 return this;
10773 }
10774 }
10775 ]);
10776 return Node2;
10777 }();
10778 var node$1 = Node$4$1;
10779 Node$4$1.default = Node$4$1;
10780 var Node$3$1 = node$1;
10781 var Declaration$4$1 = /*#__PURE__*/ function(Node$3$1) {
10782 _inherits(Declaration, Node$3$1);
10783 function Declaration(defaults) {
10784 var _this;
10785 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
10786 defaults = _extends({}, defaults, {
10787 value: String(defaults.value)
10788 });
10789 }
10790 _this = Node$3$1.call(this, defaults) || this;
10791 _this.type = "decl";
10792 return _this;
10793 }
10794 _create_class(Declaration, [
10795 {
10796 key: "variable",
10797 get: function get() {
10798 return this.prop.startsWith("--") || this.prop[0] === "$";
10799 }
10800 }
10801 ]);
10802 return Declaration;
10803 }(Node$3$1);
10804 var declaration$1 = Declaration$4$1;
10805 Declaration$4$1.default = Declaration$4$1;
10806 var urlAlphabet$1 = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
10807 var nanoid$1$1 = function(size) {
10808 if (size === void 0) size = 21;
10809 var id = "";
10810 var i2 = size;
10811 while(i2--){
10812 id += urlAlphabet$1[Math.random() * 64 | 0];
10813 }
10814 return id;
10815 };
10816 var nonSecure$1 = {
10817 nanoid: nanoid$1$1};
10818 var SourceMapConsumer$2$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$2$1 = require$$2$1.SourceMapGenerator;
10819 var existsSync$1 = require$$2$1.existsSync, readFileSync$1 = require$$2$1.readFileSync;
10820 var dirname$1$1 = require$$2$1.dirname, join$1 = require$$2$1.join;
10821 function fromBase64$1(str) {
10822 if (Buffer) {
10823 return Buffer.from(str, "base64").toString();
10824 } else {
10825 return window.atob(str);
10826 }
10827 }
10828 var PreviousMap$2$1 = /*#__PURE__*/ function() {
10829 function PreviousMap(css, opts) {
10830 if (opts.map === false) return;
10831 this.loadAnnotation(css);
10832 this.inline = this.startWith(this.annotation, "data:");
10833 var prev = opts.map ? opts.map.prev : void 0;
10834 var text = this.loadMap(opts.from, prev);
10835 if (!this.mapFile && opts.from) {
10836 this.mapFile = opts.from;
10837 }
10838 if (this.mapFile) this.root = dirname$1$1(this.mapFile);
10839 if (text) this.text = text;
10840 }
10841 var _proto = PreviousMap.prototype;
10842 _proto.consumer = function consumer() {
10843 if (!this.consumerCache) {
10844 this.consumerCache = new SourceMapConsumer$2$1(this.text);
10845 }
10846 return this.consumerCache;
10847 };
10848 _proto.decodeInline = function decodeInline(text) {
10849 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
10850 var baseUri = /^data:application\/json;base64,/;
10851 var charsetUri = /^data:application\/json;charset=utf-?8,/;
10852 var uri = /^data:application\/json,/;
10853 if (charsetUri.test(text) || uri.test(text)) {
10854 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
10855 }
10856 if (baseCharsetUri.test(text) || baseUri.test(text)) {
10857 return fromBase64$1(text.substr(RegExp.lastMatch.length));
10858 }
10859 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
10860 throw new Error("Unsupported source map encoding " + encoding);
10861 };
10862 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
10863 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
10864 };
10865 _proto.isMap = function isMap(map) {
10866 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
10867 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
10868 };
10869 _proto.loadAnnotation = function loadAnnotation(css) {
10870 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
10871 if (!comments) return;
10872 var start = css.lastIndexOf(comments.pop());
10873 var end = css.indexOf("*/", start);
10874 if (start > -1 && end > -1) {
10875 this.annotation = this.getAnnotationURL(css.substring(start, end));
10876 }
10877 };
10878 _proto.loadFile = function loadFile(path) {
10879 this.root = dirname$1$1(path);
10880 if (existsSync$1(path)) {
10881 this.mapFile = path;
10882 return readFileSync$1(path, "utf-8").toString().trim();
10883 }
10884 };
10885 _proto.loadMap = function loadMap(file, prev) {
10886 if (prev === false) return false;
10887 if (prev) {
10888 if (typeof prev === "string") {
10889 return prev;
10890 } else if (typeof prev === "function") {
10891 var prevPath = prev(file);
10892 if (prevPath) {
10893 var map = this.loadFile(prevPath);
10894 if (!map) {
10895 throw new Error("Unable to load previous source map: " + prevPath.toString());
10896 }
10897 return map;
10898 }
10899 } else if (_instanceof(prev, SourceMapConsumer$2$1)) {
10900 return SourceMapGenerator$2$1.fromSourceMap(prev).toString();
10901 } else if (_instanceof(prev, SourceMapGenerator$2$1)) {
10902 return prev.toString();
10903 } else if (this.isMap(prev)) {
10904 return JSON.stringify(prev);
10905 } else {
10906 throw new Error("Unsupported previous source map format: " + prev.toString());
10907 }
10908 } else if (this.inline) {
10909 return this.decodeInline(this.annotation);
10910 } else if (this.annotation) {
10911 var map1 = this.annotation;
10912 if (file) map1 = join$1(dirname$1$1(file), map1);
10913 return this.loadFile(map1);
10914 }
10915 };
10916 _proto.startWith = function startWith(string, start) {
10917 if (!string) return false;
10918 return string.substr(0, start.length) === start;
10919 };
10920 _proto.withContent = function withContent() {
10921 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
10922 };
10923 return PreviousMap;
10924 }();
10925 var previousMap$1 = PreviousMap$2$1;
10926 PreviousMap$2$1.default = PreviousMap$2$1;
10927 var SourceMapConsumer$1$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$1$1 = require$$2$1.SourceMapGenerator;
10928 var fileURLToPath$1 = require$$2$1.fileURLToPath, pathToFileURL$1$1 = require$$2$1.pathToFileURL;
10929 var isAbsolute$1 = require$$2$1.isAbsolute, resolve$1$1 = require$$2$1.resolve;
10930 var nanoid$2 = nonSecure$1.nanoid;
10931 var terminalHighlight$2 = require$$2$1;
10932 var CssSyntaxError$1$1 = cssSyntaxError$1;
10933 var PreviousMap$1$1 = previousMap$1;
10934 var fromOffsetCache$1 = Symbol("fromOffsetCache");
10935 var sourceMapAvailable$1$1 = Boolean(SourceMapConsumer$1$1 && SourceMapGenerator$1$1);
10936 var pathAvailable$1$1 = Boolean(resolve$1$1 && isAbsolute$1);
10937 var Input$4$1 = /*#__PURE__*/ function() {
10938 function Input(css, opts) {
10939 if (opts === void 0) opts = {};
10940 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
10941 throw new Error("PostCSS received " + css + " instead of CSS string");
10942 }
10943 this.css = css.toString();
10944 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
10945 this.hasBOM = true;
10946 this.css = this.css.slice(1);
10947 } else {
10948 this.hasBOM = false;
10949 }
10950 if (opts.from) {
10951 if (!pathAvailable$1$1 || /^\w+:\/\//.test(opts.from) || isAbsolute$1(opts.from)) {
10952 this.file = opts.from;
10953 } else {
10954 this.file = resolve$1$1(opts.from);
10955 }
10956 }
10957 if (pathAvailable$1$1 && sourceMapAvailable$1$1) {
10958 var map = new PreviousMap$1$1(this.css, opts);
10959 if (map.text) {
10960 this.map = map;
10961 var file = map.consumer().file;
10962 if (!this.file && file) this.file = this.mapResolve(file);
10963 }
10964 }
10965 if (!this.file) {
10966 this.id = "<input css " + nanoid$2(6) + ">";
10967 }
10968 if (this.map) this.map.file = this.from;
10969 }
10970 var _proto = Input.prototype;
10971 _proto.error = function error(message, line, column, opts) {
10972 if (opts === void 0) opts = {};
10973 var result2, endLine, endColumn;
10974 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
10975 var start = line;
10976 var end = column;
10977 if (typeof start.offset === "number") {
10978 var pos = this.fromOffset(start.offset);
10979 line = pos.line;
10980 column = pos.col;
10981 } else {
10982 line = start.line;
10983 column = start.column;
10984 }
10985 if (typeof end.offset === "number") {
10986 var pos1 = this.fromOffset(end.offset);
10987 endLine = pos1.line;
10988 endColumn = pos1.col;
10989 } else {
10990 endLine = end.line;
10991 endColumn = end.column;
10992 }
10993 } else if (!column) {
10994 var pos2 = this.fromOffset(line);
10995 line = pos2.line;
10996 column = pos2.col;
10997 }
10998 var origin = this.origin(line, column, endLine, endColumn);
10999 if (origin) {
11000 result2 = new CssSyntaxError$1$1(message, origin.endLine === void 0 ? origin.line : {
11001 column: origin.column,
11002 line: origin.line
11003 }, origin.endLine === void 0 ? origin.column : {
11004 column: origin.endColumn,
11005 line: origin.endLine
11006 }, origin.source, origin.file, opts.plugin);
11007 } else {
11008 result2 = new CssSyntaxError$1$1(message, endLine === void 0 ? line : {
11009 column: column,
11010 line: line
11011 }, endLine === void 0 ? column : {
11012 column: endColumn,
11013 line: endLine
11014 }, this.css, this.file, opts.plugin);
11015 }
11016 result2.input = {
11017 column: column,
11018 endColumn: endColumn,
11019 endLine: endLine,
11020 line: line,
11021 source: this.css
11022 };
11023 if (this.file) {
11024 if (pathToFileURL$1$1) {
11025 result2.input.url = pathToFileURL$1$1(this.file).toString();
11026 }
11027 result2.input.file = this.file;
11028 }
11029 return result2;
11030 };
11031 _proto.fromOffset = function fromOffset(offset) {
11032 var lastLine, lineToIndex;
11033 if (!this[fromOffsetCache$1]) {
11034 var lines = this.css.split("\n");
11035 lineToIndex = new Array(lines.length);
11036 var prevIndex = 0;
11037 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
11038 lineToIndex[i2] = prevIndex;
11039 prevIndex += lines[i2].length + 1;
11040 }
11041 this[fromOffsetCache$1] = lineToIndex;
11042 } else {
11043 lineToIndex = this[fromOffsetCache$1];
11044 }
11045 lastLine = lineToIndex[lineToIndex.length - 1];
11046 var min = 0;
11047 if (offset >= lastLine) {
11048 min = lineToIndex.length - 1;
11049 } else {
11050 var max = lineToIndex.length - 2;
11051 var mid;
11052 while(min < max){
11053 mid = min + (max - min >> 1);
11054 if (offset < lineToIndex[mid]) {
11055 max = mid - 1;
11056 } else if (offset >= lineToIndex[mid + 1]) {
11057 min = mid + 1;
11058 } else {
11059 min = mid;
11060 break;
11061 }
11062 }
11063 }
11064 return {
11065 col: offset - lineToIndex[min] + 1,
11066 line: min + 1
11067 };
11068 };
11069 _proto.mapResolve = function mapResolve(file) {
11070 if (/^\w+:\/\//.test(file)) {
11071 return file;
11072 }
11073 return resolve$1$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
11074 };
11075 _proto.origin = function origin(line, column, endLine, endColumn) {
11076 if (!this.map) return false;
11077 var consumer = this.map.consumer();
11078 var from = consumer.originalPositionFor({
11079 column: column,
11080 line: line
11081 });
11082 if (!from.source) return false;
11083 var to;
11084 if (typeof endLine === "number") {
11085 to = consumer.originalPositionFor({
11086 column: endColumn,
11087 line: endLine
11088 });
11089 }
11090 var fromUrl;
11091 if (isAbsolute$1(from.source)) {
11092 fromUrl = pathToFileURL$1$1(from.source);
11093 } else {
11094 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1$1(this.map.mapFile));
11095 }
11096 var result2 = {
11097 column: from.column,
11098 endColumn: to && to.column,
11099 endLine: to && to.line,
11100 line: from.line,
11101 url: fromUrl.toString()
11102 };
11103 if (fromUrl.protocol === "file:") {
11104 if (fileURLToPath$1) {
11105 result2.file = fileURLToPath$1(fromUrl);
11106 } else {
11107 throw new Error("file: protocol is not available in this PostCSS build");
11108 }
11109 }
11110 var source = consumer.sourceContentFor(from.source);
11111 if (source) result2.source = source;
11112 return result2;
11113 };
11114 _proto.toJSON = function toJSON() {
11115 var json = {};
11116 for(var _i = 0, _iter = [
11117 "hasBOM",
11118 "css",
11119 "file",
11120 "id"
11121 ]; _i < _iter.length; _i++){
11122 var name = _iter[_i];
11123 if (this[name] != null) {
11124 json[name] = this[name];
11125 }
11126 }
11127 if (this.map) {
11128 json.map = _extends({}, this.map);
11129 if (json.map.consumerCache) {
11130 json.map.consumerCache = void 0;
11131 }
11132 }
11133 return json;
11134 };
11135 _create_class(Input, [
11136 {
11137 key: "from",
11138 get: function get() {
11139 return this.file || this.id;
11140 }
11141 }
11142 ]);
11143 return Input;
11144 }();
11145 var input$1 = Input$4$1;
11146 Input$4$1.default = Input$4$1;
11147 if (terminalHighlight$2 && terminalHighlight$2.registerInput) {
11148 terminalHighlight$2.registerInput(Input$4$1);
11149 }
11150 var SourceMapConsumer$3 = require$$2$1.SourceMapConsumer, SourceMapGenerator$3 = require$$2$1.SourceMapGenerator;
11151 var dirname$2 = require$$2$1.dirname, relative$1 = require$$2$1.relative, resolve$2 = require$$2$1.resolve, sep$1 = require$$2$1.sep;
11152 var pathToFileURL$2 = require$$2$1.pathToFileURL;
11153 var Input$3$1 = input$1;
11154 var sourceMapAvailable$2 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$3);
11155 var pathAvailable$2 = Boolean(dirname$2 && resolve$2 && relative$1 && sep$1);
11156 var MapGenerator$2$1 = /*#__PURE__*/ function() {
11157 function MapGenerator(stringify2, root2, opts, cssString) {
11158 this.stringify = stringify2;
11159 this.mapOpts = opts.map || {};
11160 this.root = root2;
11161 this.opts = opts;
11162 this.css = cssString;
11163 this.originalCSS = cssString;
11164 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
11165 this.memoizedFileURLs = /* @__PURE__ */ new Map();
11166 this.memoizedPaths = /* @__PURE__ */ new Map();
11167 this.memoizedURLs = /* @__PURE__ */ new Map();
11168 }
11169 var _proto = MapGenerator.prototype;
11170 _proto.addAnnotation = function addAnnotation() {
11171 var content;
11172 if (this.isInline()) {
11173 content = "data:application/json;base64," + this.toBase64(this.map.toString());
11174 } else if (typeof this.mapOpts.annotation === "string") {
11175 content = this.mapOpts.annotation;
11176 } else if (typeof this.mapOpts.annotation === "function") {
11177 content = this.mapOpts.annotation(this.opts.to, this.root);
11178 } else {
11179 content = this.outputFile() + ".map";
11180 }
11181 var eol = "\n";
11182 if (this.css.includes("\r\n")) eol = "\r\n";
11183 this.css += eol + "/*# sourceMappingURL=" + content + " */";
11184 };
11185 _proto.applyPrevMaps = function applyPrevMaps() {
11186 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
11187 var prev = _step.value;
11188 var from = this.toUrl(this.path(prev.file));
11189 var root2 = prev.root || dirname$2(prev.file);
11190 var map = void 0;
11191 if (this.mapOpts.sourcesContent === false) {
11192 map = new SourceMapConsumer$3(prev.text);
11193 if (map.sourcesContent) {
11194 map.sourcesContent = null;
11195 }
11196 } else {
11197 map = prev.consumer();
11198 }
11199 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
11200 }
11201 };
11202 _proto.clearAnnotation = function clearAnnotation() {
11203 if (this.mapOpts.annotation === false) return;
11204 if (this.root) {
11205 var node2;
11206 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
11207 node2 = this.root.nodes[i2];
11208 if (node2.type !== "comment") continue;
11209 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
11210 this.root.removeChild(i2);
11211 }
11212 }
11213 } else if (this.css) {
11214 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
11215 }
11216 };
11217 _proto.generate = function generate() {
11218 this.clearAnnotation();
11219 if (pathAvailable$2 && sourceMapAvailable$2 && this.isMap()) {
11220 return this.generateMap();
11221 } else {
11222 var result2 = "";
11223 this.stringify(this.root, function(i2) {
11224 result2 += i2;
11225 });
11226 return [
11227 result2
11228 ];
11229 }
11230 };
11231 _proto.generateMap = function generateMap() {
11232 if (this.root) {
11233 this.generateString();
11234 } else if (this.previous().length === 1) {
11235 var prev = this.previous()[0].consumer();
11236 prev.file = this.outputFile();
11237 this.map = SourceMapGenerator$3.fromSourceMap(prev, {
11238 ignoreInvalidMapping: true
11239 });
11240 } else {
11241 this.map = new SourceMapGenerator$3({
11242 file: this.outputFile(),
11243 ignoreInvalidMapping: true
11244 });
11245 this.map.addMapping({
11246 generated: {
11247 column: 0,
11248 line: 1
11249 },
11250 original: {
11251 column: 0,
11252 line: 1
11253 },
11254 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
11255 });
11256 }
11257 if (this.isSourcesContent()) this.setSourcesContent();
11258 if (this.root && this.previous().length > 0) this.applyPrevMaps();
11259 if (this.isAnnotation()) this.addAnnotation();
11260 if (this.isInline()) {
11261 return [
11262 this.css
11263 ];
11264 } else {
11265 return [
11266 this.css,
11267 this.map
11268 ];
11269 }
11270 };
11271 _proto.generateString = function generateString() {
11272 var _this = this;
11273 this.css = "";
11274 this.map = new SourceMapGenerator$3({
11275 file: this.outputFile(),
11276 ignoreInvalidMapping: true
11277 });
11278 var line = 1;
11279 var column = 1;
11280 var noSource = "<no source>";
11281 var mapping = {
11282 generated: {
11283 column: 0,
11284 line: 0
11285 },
11286 original: {
11287 column: 0,
11288 line: 0
11289 },
11290 source: ""
11291 };
11292 var lines, last;
11293 this.stringify(this.root, function(str, node2, type) {
11294 _this.css += str;
11295 if (node2 && type !== "end") {
11296 mapping.generated.line = line;
11297 mapping.generated.column = column - 1;
11298 if (node2.source && node2.source.start) {
11299 mapping.source = _this.sourcePath(node2);
11300 mapping.original.line = node2.source.start.line;
11301 mapping.original.column = node2.source.start.column - 1;
11302 _this.map.addMapping(mapping);
11303 } else {
11304 mapping.source = noSource;
11305 mapping.original.line = 1;
11306 mapping.original.column = 0;
11307 _this.map.addMapping(mapping);
11308 }
11309 }
11310 lines = str.match(/\n/g);
11311 if (lines) {
11312 line += lines.length;
11313 last = str.lastIndexOf("\n");
11314 column = str.length - last;
11315 } else {
11316 column += str.length;
11317 }
11318 if (node2 && type !== "start") {
11319 var p = node2.parent || {
11320 raws: {}
11321 };
11322 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
11323 if (!childless || node2 !== p.last || p.raws.semicolon) {
11324 if (node2.source && node2.source.end) {
11325 mapping.source = _this.sourcePath(node2);
11326 mapping.original.line = node2.source.end.line;
11327 mapping.original.column = node2.source.end.column - 1;
11328 mapping.generated.line = line;
11329 mapping.generated.column = column - 2;
11330 _this.map.addMapping(mapping);
11331 } else {
11332 mapping.source = noSource;
11333 mapping.original.line = 1;
11334 mapping.original.column = 0;
11335 mapping.generated.line = line;
11336 mapping.generated.column = column - 1;
11337 _this.map.addMapping(mapping);
11338 }
11339 }
11340 }
11341 });
11342 };
11343 _proto.isAnnotation = function isAnnotation() {
11344 if (this.isInline()) {
11345 return true;
11346 }
11347 if (typeof this.mapOpts.annotation !== "undefined") {
11348 return this.mapOpts.annotation;
11349 }
11350 if (this.previous().length) {
11351 return this.previous().some(function(i2) {
11352 return i2.annotation;
11353 });
11354 }
11355 return true;
11356 };
11357 _proto.isInline = function isInline() {
11358 if (typeof this.mapOpts.inline !== "undefined") {
11359 return this.mapOpts.inline;
11360 }
11361 var annotation = this.mapOpts.annotation;
11362 if (typeof annotation !== "undefined" && annotation !== true) {
11363 return false;
11364 }
11365 if (this.previous().length) {
11366 return this.previous().some(function(i2) {
11367 return i2.inline;
11368 });
11369 }
11370 return true;
11371 };
11372 _proto.isMap = function isMap() {
11373 if (typeof this.opts.map !== "undefined") {
11374 return !!this.opts.map;
11375 }
11376 return this.previous().length > 0;
11377 };
11378 _proto.isSourcesContent = function isSourcesContent() {
11379 if (typeof this.mapOpts.sourcesContent !== "undefined") {
11380 return this.mapOpts.sourcesContent;
11381 }
11382 if (this.previous().length) {
11383 return this.previous().some(function(i2) {
11384 return i2.withContent();
11385 });
11386 }
11387 return true;
11388 };
11389 _proto.outputFile = function outputFile() {
11390 if (this.opts.to) {
11391 return this.path(this.opts.to);
11392 } else if (this.opts.from) {
11393 return this.path(this.opts.from);
11394 } else {
11395 return "to.css";
11396 }
11397 };
11398 _proto.path = function path(file) {
11399 if (this.mapOpts.absolute) return file;
11400 if (file.charCodeAt(0) === 60) return file;
11401 if (/^\w+:\/\//.test(file)) return file;
11402 var cached = this.memoizedPaths.get(file);
11403 if (cached) return cached;
11404 var from = this.opts.to ? dirname$2(this.opts.to) : ".";
11405 if (typeof this.mapOpts.annotation === "string") {
11406 from = dirname$2(resolve$2(from, this.mapOpts.annotation));
11407 }
11408 var path = relative$1(from, file);
11409 this.memoizedPaths.set(file, path);
11410 return path;
11411 };
11412 _proto.previous = function previous() {
11413 var _this = this;
11414 if (!this.previousMaps) {
11415 this.previousMaps = [];
11416 if (this.root) {
11417 this.root.walk(function(node2) {
11418 if (node2.source && node2.source.input.map) {
11419 var map = node2.source.input.map;
11420 if (!_this.previousMaps.includes(map)) {
11421 _this.previousMaps.push(map);
11422 }
11423 }
11424 });
11425 } else {
11426 var input2 = new Input$3$1(this.originalCSS, this.opts);
11427 if (input2.map) this.previousMaps.push(input2.map);
11428 }
11429 }
11430 return this.previousMaps;
11431 };
11432 _proto.setSourcesContent = function setSourcesContent() {
11433 var _this = this;
11434 var already = {};
11435 if (this.root) {
11436 this.root.walk(function(node2) {
11437 if (node2.source) {
11438 var from = node2.source.input.from;
11439 if (from && !already[from]) {
11440 already[from] = true;
11441 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
11442 _this.map.setSourceContent(fromUrl, node2.source.input.css);
11443 }
11444 }
11445 });
11446 } else if (this.css) {
11447 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
11448 this.map.setSourceContent(from, this.css);
11449 }
11450 };
11451 _proto.sourcePath = function sourcePath(node2) {
11452 if (this.mapOpts.from) {
11453 return this.toUrl(this.mapOpts.from);
11454 } else if (this.usesFileUrls) {
11455 return this.toFileUrl(node2.source.input.from);
11456 } else {
11457 return this.toUrl(this.path(node2.source.input.from));
11458 }
11459 };
11460 _proto.toBase64 = function toBase64(str) {
11461 if (Buffer) {
11462 return Buffer.from(str).toString("base64");
11463 } else {
11464 return window.btoa(unescape(encodeURIComponent(str)));
11465 }
11466 };
11467 _proto.toFileUrl = function toFileUrl(path) {
11468 var cached = this.memoizedFileURLs.get(path);
11469 if (cached) return cached;
11470 if (pathToFileURL$2) {
11471 var fileURL = pathToFileURL$2(path).toString();
11472 this.memoizedFileURLs.set(path, fileURL);
11473 return fileURL;
11474 } else {
11475 throw new Error("`map.absolute` option is not available in this PostCSS build");
11476 }
11477 };
11478 _proto.toUrl = function toUrl(path) {
11479 var cached = this.memoizedURLs.get(path);
11480 if (cached) return cached;
11481 if (sep$1 === "\\") {
11482 path = path.replace(/\\/g, "/");
11483 }
11484 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
11485 this.memoizedURLs.set(path, url);
11486 return url;
11487 };
11488 return MapGenerator;
11489 }();
11490 var mapGenerator$1 = MapGenerator$2$1;
11491 var Node$2$1 = node$1;
11492 var Comment$4$1 = /*#__PURE__*/ function(Node$2$1) {
11493 _inherits(Comment, Node$2$1);
11494 function Comment(defaults) {
11495 var _this;
11496 _this = Node$2$1.call(this, defaults) || this;
11497 _this.type = "comment";
11498 return _this;
11499 }
11500 return Comment;
11501 }(Node$2$1);
11502 var comment$1 = Comment$4$1;
11503 Comment$4$1.default = Comment$4$1;
11504 var isClean$1$1 = symbols$1.isClean, my$1$1 = symbols$1.my;
11505 var Declaration$3$1 = declaration$1;
11506 var Comment$3$1 = comment$1;
11507 var Node$1$1 = node$1;
11508 var parse$4$1, Rule$4$1, AtRule$4$1, Root$6$1;
11509 function cleanSource$1(nodes) {
11510 return nodes.map(function(i2) {
11511 if (i2.nodes) i2.nodes = cleanSource$1(i2.nodes);
11512 delete i2.source;
11513 return i2;
11514 });
11515 }
11516 function markDirtyUp$1(node2) {
11517 node2[isClean$1$1] = false;
11518 if (node2.proxyOf.nodes) {
11519 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
11520 var i2 = _step.value;
11521 markDirtyUp$1(i2);
11522 }
11523 }
11524 }
11525 var Container$7$1 = /*#__PURE__*/ function(Node$1$1) {
11526 _inherits(Container, Node$1$1);
11527 function Container() {
11528 return Node$1$1.apply(this, arguments) || this;
11529 }
11530 var _proto = Container.prototype;
11531 _proto.append = function append() {
11532 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
11533 children[_key] = arguments[_key];
11534 }
11535 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
11536 var child = _step.value;
11537 var nodes = this.normalize(child, this.last);
11538 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11539 var node2 = _step1.value;
11540 this.proxyOf.nodes.push(node2);
11541 }
11542 }
11543 this.markDirty();
11544 return this;
11545 };
11546 _proto.cleanRaws = function cleanRaws(keepBetween) {
11547 Node$1$1.prototype.cleanRaws.call(this, keepBetween);
11548 if (this.nodes) {
11549 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
11550 var node2 = _step.value;
11551 node2.cleanRaws(keepBetween);
11552 }
11553 }
11554 };
11555 _proto.each = function each(callback) {
11556 if (!this.proxyOf.nodes) return void 0;
11557 var iterator = this.getIterator();
11558 var index2, result2;
11559 while(this.indexes[iterator] < this.proxyOf.nodes.length){
11560 index2 = this.indexes[iterator];
11561 result2 = callback(this.proxyOf.nodes[index2], index2);
11562 if (result2 === false) break;
11563 this.indexes[iterator] += 1;
11564 }
11565 delete this.indexes[iterator];
11566 return result2;
11567 };
11568 _proto.every = function every(condition) {
11569 return this.nodes.every(condition);
11570 };
11571 _proto.getIterator = function getIterator() {
11572 if (!this.lastEach) this.lastEach = 0;
11573 if (!this.indexes) this.indexes = {};
11574 this.lastEach += 1;
11575 var iterator = this.lastEach;
11576 this.indexes[iterator] = 0;
11577 return iterator;
11578 };
11579 _proto.getProxyProcessor = function getProxyProcessor() {
11580 return {
11581 get: function get(node2, prop) {
11582 if (prop === "proxyOf") {
11583 return node2;
11584 } else if (!node2[prop]) {
11585 return node2[prop];
11586 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
11587 return function() {
11588 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
11589 args[_key] = arguments[_key];
11590 }
11591 var _node2;
11592 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
11593 if (typeof i2 === "function") {
11594 return function(child, index2) {
11595 return i2(child.toProxy(), index2);
11596 };
11597 } else {
11598 return i2;
11599 }
11600 })));
11601 };
11602 } else if (prop === "every" || prop === "some") {
11603 return function(cb) {
11604 return node2[prop](function(child) {
11605 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
11606 other[_key - 1] = arguments[_key];
11607 }
11608 return cb.apply(void 0, [].concat([
11609 child.toProxy()
11610 ], other));
11611 });
11612 };
11613 } else if (prop === "root") {
11614 return function() {
11615 return node2.root().toProxy();
11616 };
11617 } else if (prop === "nodes") {
11618 return node2.nodes.map(function(i2) {
11619 return i2.toProxy();
11620 });
11621 } else if (prop === "first" || prop === "last") {
11622 return node2[prop].toProxy();
11623 } else {
11624 return node2[prop];
11625 }
11626 },
11627 set: function set(node2, prop, value) {
11628 if (node2[prop] === value) return true;
11629 node2[prop] = value;
11630 if (prop === "name" || prop === "params" || prop === "selector") {
11631 node2.markDirty();
11632 }
11633 return true;
11634 }
11635 };
11636 };
11637 _proto.index = function index(child) {
11638 if (typeof child === "number") return child;
11639 if (child.proxyOf) child = child.proxyOf;
11640 return this.proxyOf.nodes.indexOf(child);
11641 };
11642 _proto.insertAfter = function insertAfter(exist, add) {
11643 var existIndex = this.index(exist);
11644 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
11645 existIndex = this.index(exist);
11646 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11647 var node2 = _step.value;
11648 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
11649 }
11650 var index2;
11651 for(var id in this.indexes){
11652 index2 = this.indexes[id];
11653 if (existIndex < index2) {
11654 this.indexes[id] = index2 + nodes.length;
11655 }
11656 }
11657 this.markDirty();
11658 return this;
11659 };
11660 _proto.insertBefore = function insertBefore(exist, add) {
11661 var existIndex = this.index(exist);
11662 var type = existIndex === 0 ? "prepend" : false;
11663 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
11664 existIndex = this.index(exist);
11665 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11666 var node2 = _step.value;
11667 this.proxyOf.nodes.splice(existIndex, 0, node2);
11668 }
11669 var index2;
11670 for(var id in this.indexes){
11671 index2 = this.indexes[id];
11672 if (existIndex <= index2) {
11673 this.indexes[id] = index2 + nodes.length;
11674 }
11675 }
11676 this.markDirty();
11677 return this;
11678 };
11679 _proto.normalize = function normalize(nodes, sample) {
11680 var _this = this;
11681 if (typeof nodes === "string") {
11682 nodes = cleanSource$1(parse$4$1(nodes).nodes);
11683 } else if (typeof nodes === "undefined") {
11684 nodes = [];
11685 } else if (Array.isArray(nodes)) {
11686 nodes = nodes.slice(0);
11687 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11688 var i2 = _step.value;
11689 if (i2.parent) i2.parent.removeChild(i2, "ignore");
11690 }
11691 } else if (nodes.type === "root" && this.type !== "document") {
11692 nodes = nodes.nodes.slice(0);
11693 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11694 var i21 = _step1.value;
11695 if (i21.parent) i21.parent.removeChild(i21, "ignore");
11696 }
11697 } else if (nodes.type) {
11698 nodes = [
11699 nodes
11700 ];
11701 } else if (nodes.prop) {
11702 if (typeof nodes.value === "undefined") {
11703 throw new Error("Value field is missed in node creation");
11704 } else if (typeof nodes.value !== "string") {
11705 nodes.value = String(nodes.value);
11706 }
11707 nodes = [
11708 new Declaration$3$1(nodes)
11709 ];
11710 } else if (nodes.selector) {
11711 nodes = [
11712 new Rule$4$1(nodes)
11713 ];
11714 } else if (nodes.name) {
11715 nodes = [
11716 new AtRule$4$1(nodes)
11717 ];
11718 } else if (nodes.text) {
11719 nodes = [
11720 new Comment$3$1(nodes)
11721 ];
11722 } else {
11723 throw new Error("Unknown node type in node creation");
11724 }
11725 var processed = nodes.map(function(i2) {
11726 if (!i2[my$1$1]) Container.rebuild(i2);
11727 i2 = i2.proxyOf;
11728 if (i2.parent) i2.parent.removeChild(i2);
11729 if (i2[isClean$1$1]) markDirtyUp$1(i2);
11730 if (typeof i2.raws.before === "undefined") {
11731 if (sample && typeof sample.raws.before !== "undefined") {
11732 i2.raws.before = sample.raws.before.replace(/\S/g, "");
11733 }
11734 }
11735 i2.parent = _this.proxyOf;
11736 return i2;
11737 });
11738 return processed;
11739 };
11740 _proto.prepend = function prepend() {
11741 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
11742 children[_key] = arguments[_key];
11743 }
11744 children = children.reverse();
11745 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
11746 var child = _step.value;
11747 var nodes = this.normalize(child, this.first, "prepend").reverse();
11748 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11749 var node2 = _step1.value;
11750 this.proxyOf.nodes.unshift(node2);
11751 }
11752 for(var id in this.indexes){
11753 this.indexes[id] = this.indexes[id] + nodes.length;
11754 }
11755 }
11756 this.markDirty();
11757 return this;
11758 };
11759 _proto.push = function push(child) {
11760 child.parent = this;
11761 this.proxyOf.nodes.push(child);
11762 return this;
11763 };
11764 _proto.removeAll = function removeAll() {
11765 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
11766 var node2 = _step.value;
11767 node2.parent = void 0;
11768 }
11769 this.proxyOf.nodes = [];
11770 this.markDirty();
11771 return this;
11772 };
11773 _proto.removeChild = function removeChild(child) {
11774 child = this.index(child);
11775 this.proxyOf.nodes[child].parent = void 0;
11776 this.proxyOf.nodes.splice(child, 1);
11777 var index2;
11778 for(var id in this.indexes){
11779 index2 = this.indexes[id];
11780 if (index2 >= child) {
11781 this.indexes[id] = index2 - 1;
11782 }
11783 }
11784 this.markDirty();
11785 return this;
11786 };
11787 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
11788 if (!callback) {
11789 callback = opts;
11790 opts = {};
11791 }
11792 this.walkDecls(function(decl) {
11793 if (opts.props && !opts.props.includes(decl.prop)) return;
11794 if (opts.fast && !decl.value.includes(opts.fast)) return;
11795 decl.value = decl.value.replace(pattern, callback);
11796 });
11797 this.markDirty();
11798 return this;
11799 };
11800 _proto.some = function some(condition) {
11801 return this.nodes.some(condition);
11802 };
11803 _proto.walk = function walk(callback) {
11804 return this.each(function(child, i2) {
11805 var result2;
11806 try {
11807 result2 = callback(child, i2);
11808 } catch (e2) {
11809 throw child.addToError(e2);
11810 }
11811 if (result2 !== false && child.walk) {
11812 result2 = child.walk(callback);
11813 }
11814 return result2;
11815 });
11816 };
11817 _proto.walkAtRules = function walkAtRules(name, callback) {
11818 if (!callback) {
11819 callback = name;
11820 return this.walk(function(child, i2) {
11821 if (child.type === "atrule") {
11822 return callback(child, i2);
11823 }
11824 });
11825 }
11826 if (_instanceof(name, RegExp)) {
11827 return this.walk(function(child, i2) {
11828 if (child.type === "atrule" && name.test(child.name)) {
11829 return callback(child, i2);
11830 }
11831 });
11832 }
11833 return this.walk(function(child, i2) {
11834 if (child.type === "atrule" && child.name === name) {
11835 return callback(child, i2);
11836 }
11837 });
11838 };
11839 _proto.walkComments = function walkComments(callback) {
11840 return this.walk(function(child, i2) {
11841 if (child.type === "comment") {
11842 return callback(child, i2);
11843 }
11844 });
11845 };
11846 _proto.walkDecls = function walkDecls(prop, callback) {
11847 if (!callback) {
11848 callback = prop;
11849 return this.walk(function(child, i2) {
11850 if (child.type === "decl") {
11851 return callback(child, i2);
11852 }
11853 });
11854 }
11855 if (_instanceof(prop, RegExp)) {
11856 return this.walk(function(child, i2) {
11857 if (child.type === "decl" && prop.test(child.prop)) {
11858 return callback(child, i2);
11859 }
11860 });
11861 }
11862 return this.walk(function(child, i2) {
11863 if (child.type === "decl" && child.prop === prop) {
11864 return callback(child, i2);
11865 }
11866 });
11867 };
11868 _proto.walkRules = function walkRules(selector, callback) {
11869 if (!callback) {
11870 callback = selector;
11871 return this.walk(function(child, i2) {
11872 if (child.type === "rule") {
11873 return callback(child, i2);
11874 }
11875 });
11876 }
11877 if (_instanceof(selector, RegExp)) {
11878 return this.walk(function(child, i2) {
11879 if (child.type === "rule" && selector.test(child.selector)) {
11880 return callback(child, i2);
11881 }
11882 });
11883 }
11884 return this.walk(function(child, i2) {
11885 if (child.type === "rule" && child.selector === selector) {
11886 return callback(child, i2);
11887 }
11888 });
11889 };
11890 _create_class(Container, [
11891 {
11892 key: "first",
11893 get: function get() {
11894 if (!this.proxyOf.nodes) return void 0;
11895 return this.proxyOf.nodes[0];
11896 }
11897 },
11898 {
11899 key: "last",
11900 get: function get() {
11901 if (!this.proxyOf.nodes) return void 0;
11902 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
11903 }
11904 }
11905 ]);
11906 return Container;
11907 }(Node$1$1);
11908 Container$7$1.registerParse = function(dependant) {
11909 parse$4$1 = dependant;
11910 };
11911 Container$7$1.registerRule = function(dependant) {
11912 Rule$4$1 = dependant;
11913 };
11914 Container$7$1.registerAtRule = function(dependant) {
11915 AtRule$4$1 = dependant;
11916 };
11917 Container$7$1.registerRoot = function(dependant) {
11918 Root$6$1 = dependant;
11919 };
11920 var container$1 = Container$7$1;
11921 Container$7$1.default = Container$7$1;
11922 Container$7$1.rebuild = function(node2) {
11923 if (node2.type === "atrule") {
11924 Object.setPrototypeOf(node2, AtRule$4$1.prototype);
11925 } else if (node2.type === "rule") {
11926 Object.setPrototypeOf(node2, Rule$4$1.prototype);
11927 } else if (node2.type === "decl") {
11928 Object.setPrototypeOf(node2, Declaration$3$1.prototype);
11929 } else if (node2.type === "comment") {
11930 Object.setPrototypeOf(node2, Comment$3$1.prototype);
11931 } else if (node2.type === "root") {
11932 Object.setPrototypeOf(node2, Root$6$1.prototype);
11933 }
11934 node2[my$1$1] = true;
11935 if (node2.nodes) {
11936 node2.nodes.forEach(function(child) {
11937 Container$7$1.rebuild(child);
11938 });
11939 }
11940 };
11941 var Container$6$1 = container$1;
11942 var LazyResult$4$1, Processor$3$1;
11943 var Document$3$1 = /*#__PURE__*/ function(Container$6$1) {
11944 _inherits(Document2, Container$6$1);
11945 function Document2(defaults) {
11946 var _this;
11947 _this = Container$6$1.call(this, _extends({
11948 type: "document"
11949 }, defaults)) || this;
11950 if (!_this.nodes) {
11951 _this.nodes = [];
11952 }
11953 return _this;
11954 }
11955 var _proto = Document2.prototype;
11956 _proto.toResult = function toResult(opts) {
11957 if (opts === void 0) opts = {};
11958 var lazy = new LazyResult$4$1(new Processor$3$1(), this, opts);
11959 return lazy.stringify();
11960 };
11961 return Document2;
11962 }(Container$6$1);
11963 Document$3$1.registerLazyResult = function(dependant) {
11964 LazyResult$4$1 = dependant;
11965 };
11966 Document$3$1.registerProcessor = function(dependant) {
11967 Processor$3$1 = dependant;
11968 };
11969 var document$1$1 = Document$3$1;
11970 Document$3$1.default = Document$3$1;
11971 var printed$1 = {};
11972 var warnOnce$2$1 = function warnOnce(message) {
11973 if (printed$1[message]) return;
11974 printed$1[message] = true;
11975 if (typeof console !== "undefined" && console.warn) {
11976 console.warn(message);
11977 }
11978 };
11979 var Warning$2$1 = /*#__PURE__*/ function() {
11980 function Warning(text, opts) {
11981 if (opts === void 0) opts = {};
11982 this.type = "warning";
11983 this.text = text;
11984 if (opts.node && opts.node.source) {
11985 var range = opts.node.rangeBy(opts);
11986 this.line = range.start.line;
11987 this.column = range.start.column;
11988 this.endLine = range.end.line;
11989 this.endColumn = range.end.column;
11990 }
11991 for(var opt in opts)this[opt] = opts[opt];
11992 }
11993 var _proto = Warning.prototype;
11994 _proto.toString = function toString() {
11995 if (this.node) {
11996 return this.node.error(this.text, {
11997 index: this.index,
11998 plugin: this.plugin,
11999 word: this.word
12000 }).message;
12001 }
12002 if (this.plugin) {
12003 return this.plugin + ": " + this.text;
12004 }
12005 return this.text;
12006 };
12007 return Warning;
12008 }();
12009 var warning$1 = Warning$2$1;
12010 Warning$2$1.default = Warning$2$1;
12011 var Warning$1$1 = warning$1;
12012 var Result$3$1 = /*#__PURE__*/ function() {
12013 function Result(processor2, root2, opts) {
12014 this.processor = processor2;
12015 this.messages = [];
12016 this.root = root2;
12017 this.opts = opts;
12018 this.css = void 0;
12019 this.map = void 0;
12020 }
12021 var _proto = Result.prototype;
12022 _proto.toString = function toString() {
12023 return this.css;
12024 };
12025 _proto.warn = function warn(text, opts) {
12026 if (opts === void 0) opts = {};
12027 if (!opts.plugin) {
12028 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
12029 opts.plugin = this.lastPlugin.postcssPlugin;
12030 }
12031 }
12032 var warning2 = new Warning$1$1(text, opts);
12033 this.messages.push(warning2);
12034 return warning2;
12035 };
12036 _proto.warnings = function warnings() {
12037 return this.messages.filter(function(i2) {
12038 return i2.type === "warning";
12039 });
12040 };
12041 _create_class(Result, [
12042 {
12043 key: "content",
12044 get: function get() {
12045 return this.css;
12046 }
12047 }
12048 ]);
12049 return Result;
12050 }();
12051 var result$1 = Result$3$1;
12052 Result$3$1.default = Result$3$1;
12053 var SINGLE_QUOTE$1 = "'".charCodeAt(0);
12054 var DOUBLE_QUOTE$1 = '"'.charCodeAt(0);
12055 var BACKSLASH$1 = "\\".charCodeAt(0);
12056 var SLASH$1 = "/".charCodeAt(0);
12057 var NEWLINE$1 = "\n".charCodeAt(0);
12058 var SPACE$1 = " ".charCodeAt(0);
12059 var FEED$1 = "\f".charCodeAt(0);
12060 var TAB$1 = " ".charCodeAt(0);
12061 var CR$1 = "\r".charCodeAt(0);
12062 var OPEN_SQUARE$1 = "[".charCodeAt(0);
12063 var CLOSE_SQUARE$1 = "]".charCodeAt(0);
12064 var OPEN_PARENTHESES$1 = "(".charCodeAt(0);
12065 var CLOSE_PARENTHESES$1 = ")".charCodeAt(0);
12066 var OPEN_CURLY$1 = "{".charCodeAt(0);
12067 var CLOSE_CURLY$1 = "}".charCodeAt(0);
12068 var SEMICOLON$1 = ";".charCodeAt(0);
12069 var ASTERISK$1 = "*".charCodeAt(0);
12070 var COLON$1 = ":".charCodeAt(0);
12071 var AT$1 = "@".charCodeAt(0);
12072 var RE_AT_END$1 = /[\t\n\f\r "#'()/;[\\\]{}]/g;
12073 var RE_WORD_END$1 = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
12074 var RE_BAD_BRACKET$1 = /.[\r\n"'(/\\]/;
12075 var RE_HEX_ESCAPE$1 = /[\da-f]/i;
12076 var tokenize$1 = function tokenizer(input2, options) {
12077 if (options === void 0) options = {};
12078 var css = input2.css.valueOf();
12079 var ignore = options.ignoreErrors;
12080 var code, next, quote, content, escape;
12081 var escaped, escapePos, prev, n2, currentToken;
12082 var length = css.length;
12083 var pos = 0;
12084 var buffer = [];
12085 var returned = [];
12086 function position() {
12087 return pos;
12088 }
12089 function unclosed(what) {
12090 throw input2.error("Unclosed " + what, pos);
12091 }
12092 function endOfFile() {
12093 return returned.length === 0 && pos >= length;
12094 }
12095 function nextToken(opts) {
12096 if (returned.length) return returned.pop();
12097 if (pos >= length) return;
12098 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
12099 code = css.charCodeAt(pos);
12100 switch(code){
12101 case NEWLINE$1:
12102 case SPACE$1:
12103 case TAB$1:
12104 case CR$1:
12105 case FEED$1:
12106 {
12107 next = pos;
12108 do {
12109 next += 1;
12110 code = css.charCodeAt(next);
12111 }while (code === SPACE$1 || code === NEWLINE$1 || code === TAB$1 || code === CR$1 || code === FEED$1);
12112 currentToken = [
12113 "space",
12114 css.slice(pos, next)
12115 ];
12116 pos = next - 1;
12117 break;
12118 }
12119 case OPEN_SQUARE$1:
12120 case CLOSE_SQUARE$1:
12121 case OPEN_CURLY$1:
12122 case CLOSE_CURLY$1:
12123 case COLON$1:
12124 case SEMICOLON$1:
12125 case CLOSE_PARENTHESES$1:
12126 {
12127 var controlChar = String.fromCharCode(code);
12128 currentToken = [
12129 controlChar,
12130 controlChar,
12131 pos
12132 ];
12133 break;
12134 }
12135 case OPEN_PARENTHESES$1:
12136 {
12137 prev = buffer.length ? buffer.pop()[1] : "";
12138 n2 = css.charCodeAt(pos + 1);
12139 if (prev === "url" && n2 !== SINGLE_QUOTE$1 && n2 !== DOUBLE_QUOTE$1 && n2 !== SPACE$1 && n2 !== NEWLINE$1 && n2 !== TAB$1 && n2 !== FEED$1 && n2 !== CR$1) {
12140 next = pos;
12141 do {
12142 escaped = false;
12143 next = css.indexOf(")", next + 1);
12144 if (next === -1) {
12145 if (ignore || ignoreUnclosed) {
12146 next = pos;
12147 break;
12148 } else {
12149 unclosed("bracket");
12150 }
12151 }
12152 escapePos = next;
12153 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12154 escapePos -= 1;
12155 escaped = !escaped;
12156 }
12157 }while (escaped);
12158 currentToken = [
12159 "brackets",
12160 css.slice(pos, next + 1),
12161 pos,
12162 next
12163 ];
12164 pos = next;
12165 } else {
12166 next = css.indexOf(")", pos + 1);
12167 content = css.slice(pos, next + 1);
12168 if (next === -1 || RE_BAD_BRACKET$1.test(content)) {
12169 currentToken = [
12170 "(",
12171 "(",
12172 pos
12173 ];
12174 } else {
12175 currentToken = [
12176 "brackets",
12177 content,
12178 pos,
12179 next
12180 ];
12181 pos = next;
12182 }
12183 }
12184 break;
12185 }
12186 case SINGLE_QUOTE$1:
12187 case DOUBLE_QUOTE$1:
12188 {
12189 quote = code === SINGLE_QUOTE$1 ? "'" : '"';
12190 next = pos;
12191 do {
12192 escaped = false;
12193 next = css.indexOf(quote, next + 1);
12194 if (next === -1) {
12195 if (ignore || ignoreUnclosed) {
12196 next = pos + 1;
12197 break;
12198 } else {
12199 unclosed("string");
12200 }
12201 }
12202 escapePos = next;
12203 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12204 escapePos -= 1;
12205 escaped = !escaped;
12206 }
12207 }while (escaped);
12208 currentToken = [
12209 "string",
12210 css.slice(pos, next + 1),
12211 pos,
12212 next
12213 ];
12214 pos = next;
12215 break;
12216 }
12217 case AT$1:
12218 {
12219 RE_AT_END$1.lastIndex = pos + 1;
12220 RE_AT_END$1.test(css);
12221 if (RE_AT_END$1.lastIndex === 0) {
12222 next = css.length - 1;
12223 } else {
12224 next = RE_AT_END$1.lastIndex - 2;
12225 }
12226 currentToken = [
12227 "at-word",
12228 css.slice(pos, next + 1),
12229 pos,
12230 next
12231 ];
12232 pos = next;
12233 break;
12234 }
12235 case BACKSLASH$1:
12236 {
12237 next = pos;
12238 escape = true;
12239 while(css.charCodeAt(next + 1) === BACKSLASH$1){
12240 next += 1;
12241 escape = !escape;
12242 }
12243 code = css.charCodeAt(next + 1);
12244 if (escape && code !== SLASH$1 && code !== SPACE$1 && code !== NEWLINE$1 && code !== TAB$1 && code !== CR$1 && code !== FEED$1) {
12245 next += 1;
12246 if (RE_HEX_ESCAPE$1.test(css.charAt(next))) {
12247 while(RE_HEX_ESCAPE$1.test(css.charAt(next + 1))){
12248 next += 1;
12249 }
12250 if (css.charCodeAt(next + 1) === SPACE$1) {
12251 next += 1;
12252 }
12253 }
12254 }
12255 currentToken = [
12256 "word",
12257 css.slice(pos, next + 1),
12258 pos,
12259 next
12260 ];
12261 pos = next;
12262 break;
12263 }
12264 default:
12265 {
12266 if (code === SLASH$1 && css.charCodeAt(pos + 1) === ASTERISK$1) {
12267 next = css.indexOf("*/", pos + 2) + 1;
12268 if (next === 0) {
12269 if (ignore || ignoreUnclosed) {
12270 next = css.length;
12271 } else {
12272 unclosed("comment");
12273 }
12274 }
12275 currentToken = [
12276 "comment",
12277 css.slice(pos, next + 1),
12278 pos,
12279 next
12280 ];
12281 pos = next;
12282 } else {
12283 RE_WORD_END$1.lastIndex = pos + 1;
12284 RE_WORD_END$1.test(css);
12285 if (RE_WORD_END$1.lastIndex === 0) {
12286 next = css.length - 1;
12287 } else {
12288 next = RE_WORD_END$1.lastIndex - 2;
12289 }
12290 currentToken = [
12291 "word",
12292 css.slice(pos, next + 1),
12293 pos,
12294 next
12295 ];
12296 buffer.push(currentToken);
12297 pos = next;
12298 }
12299 break;
12300 }
12301 }
12302 pos++;
12303 return currentToken;
12304 }
12305 function back(token) {
12306 returned.push(token);
12307 }
12308 return {
12309 back: back,
12310 endOfFile: endOfFile,
12311 nextToken: nextToken,
12312 position: position
12313 };
12314 };
12315 var Container$5$1 = container$1;
12316 var AtRule$3$1 = /*#__PURE__*/ function(Container$5$1) {
12317 _inherits(AtRule, Container$5$1);
12318 function AtRule(defaults) {
12319 var _this;
12320 _this = Container$5$1.call(this, defaults) || this;
12321 _this.type = "atrule";
12322 return _this;
12323 }
12324 var _proto = AtRule.prototype;
12325 _proto.append = function append() {
12326 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12327 children[_key] = arguments[_key];
12328 }
12329 var _Container$5$1_prototype_append;
12330 if (!this.proxyOf.nodes) this.nodes = [];
12331 return (_Container$5$1_prototype_append = Container$5$1.prototype.append).call.apply(_Container$5$1_prototype_append, [].concat([
12332 this
12333 ], children));
12334 };
12335 _proto.prepend = function prepend() {
12336 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12337 children[_key] = arguments[_key];
12338 }
12339 var _Container$5$1_prototype_prepend;
12340 if (!this.proxyOf.nodes) this.nodes = [];
12341 return (_Container$5$1_prototype_prepend = Container$5$1.prototype.prepend).call.apply(_Container$5$1_prototype_prepend, [].concat([
12342 this
12343 ], children));
12344 };
12345 return AtRule;
12346 }(Container$5$1);
12347 var atRule$1 = AtRule$3$1;
12348 AtRule$3$1.default = AtRule$3$1;
12349 Container$5$1.registerAtRule(AtRule$3$1);
12350 var Container$4$1 = container$1;
12351 var LazyResult$3$1, Processor$2$1;
12352 var Root$5$1 = /*#__PURE__*/ function(Container$4$1) {
12353 _inherits(Root, Container$4$1);
12354 function Root(defaults) {
12355 var _this;
12356 _this = Container$4$1.call(this, defaults) || this;
12357 _this.type = "root";
12358 if (!_this.nodes) _this.nodes = [];
12359 return _this;
12360 }
12361 var _proto = Root.prototype;
12362 _proto.normalize = function normalize(child, sample, type) {
12363 var nodes = Container$4$1.prototype.normalize.call(this, child);
12364 if (sample) {
12365 if (type === "prepend") {
12366 if (this.nodes.length > 1) {
12367 sample.raws.before = this.nodes[1].raws.before;
12368 } else {
12369 delete sample.raws.before;
12370 }
12371 } else if (this.first !== sample) {
12372 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12373 var node2 = _step.value;
12374 node2.raws.before = sample.raws.before;
12375 }
12376 }
12377 }
12378 return nodes;
12379 };
12380 _proto.removeChild = function removeChild(child, ignore) {
12381 var index2 = this.index(child);
12382 if (!ignore && index2 === 0 && this.nodes.length > 1) {
12383 this.nodes[1].raws.before = this.nodes[index2].raws.before;
12384 }
12385 return Container$4$1.prototype.removeChild.call(this, child);
12386 };
12387 _proto.toResult = function toResult(opts) {
12388 if (opts === void 0) opts = {};
12389 var lazy = new LazyResult$3$1(new Processor$2$1(), this, opts);
12390 return lazy.stringify();
12391 };
12392 return Root;
12393 }(Container$4$1);
12394 Root$5$1.registerLazyResult = function(dependant) {
12395 LazyResult$3$1 = dependant;
12396 };
12397 Root$5$1.registerProcessor = function(dependant) {
12398 Processor$2$1 = dependant;
12399 };
12400 var root$1 = Root$5$1;
12401 Root$5$1.default = Root$5$1;
12402 Container$4$1.registerRoot(Root$5$1);
12403 var list$2$1 = {
12404 comma: function comma(string) {
12405 return list$2$1.split(string, [
12406 ","
12407 ], true);
12408 },
12409 space: function space(string) {
12410 var spaces = [
12411 " ",
12412 "\n",
12413 " "
12414 ];
12415 return list$2$1.split(string, spaces);
12416 },
12417 split: function split(string, separators, last) {
12418 var array = [];
12419 var current = "";
12420 var split = false;
12421 var func = 0;
12422 var inQuote = false;
12423 var prevQuote = "";
12424 var escape = false;
12425 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
12426 var letter = _step.value;
12427 if (escape) {
12428 escape = false;
12429 } else if (letter === "\\") {
12430 escape = true;
12431 } else if (inQuote) {
12432 if (letter === prevQuote) {
12433 inQuote = false;
12434 }
12435 } else if (letter === '"' || letter === "'") {
12436 inQuote = true;
12437 prevQuote = letter;
12438 } else if (letter === "(") {
12439 func += 1;
12440 } else if (letter === ")") {
12441 if (func > 0) func -= 1;
12442 } else if (func === 0) {
12443 if (separators.includes(letter)) split = true;
12444 }
12445 if (split) {
12446 if (current !== "") array.push(current.trim());
12447 current = "";
12448 split = false;
12449 } else {
12450 current += letter;
12451 }
12452 }
12453 if (last || current !== "") array.push(current.trim());
12454 return array;
12455 }
12456 };
12457 var list_1$1 = list$2$1;
12458 list$2$1.default = list$2$1;
12459 var Container$3$1 = container$1;
12460 var list$1$1 = list_1$1;
12461 var Rule$3$1 = /*#__PURE__*/ function(Container$3$1) {
12462 _inherits(Rule, Container$3$1);
12463 function Rule(defaults) {
12464 var _this;
12465 _this = Container$3$1.call(this, defaults) || this;
12466 _this.type = "rule";
12467 if (!_this.nodes) _this.nodes = [];
12468 return _this;
12469 }
12470 _create_class(Rule, [
12471 {
12472 key: "selectors",
12473 get: function get() {
12474 return list$1$1.comma(this.selector);
12475 },
12476 set: function set(values) {
12477 var match = this.selector ? this.selector.match(/,\s*/) : null;
12478 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
12479 this.selector = values.join(sep2);
12480 }
12481 }
12482 ]);
12483 return Rule;
12484 }(Container$3$1);
12485 var rule$1 = Rule$3$1;
12486 Rule$3$1.default = Rule$3$1;
12487 Container$3$1.registerRule(Rule$3$1);
12488 var Declaration$2$1 = declaration$1;
12489 var tokenizer2$1 = tokenize$1;
12490 var Comment$2$1 = comment$1;
12491 var AtRule$2$1 = atRule$1;
12492 var Root$4$1 = root$1;
12493 var Rule$2$1 = rule$1;
12494 var SAFE_COMMENT_NEIGHBOR$1 = {
12495 empty: true,
12496 space: true
12497 };
12498 function findLastWithPosition$1(tokens) {
12499 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
12500 var token = tokens[i2];
12501 var pos = token[3] || token[2];
12502 if (pos) return pos;
12503 }
12504 }
12505 var Parser$1$1 = /*#__PURE__*/ function() {
12506 function Parser(input2) {
12507 this.input = input2;
12508 this.root = new Root$4$1();
12509 this.current = this.root;
12510 this.spaces = "";
12511 this.semicolon = false;
12512 this.createTokenizer();
12513 this.root.source = {
12514 input: input2,
12515 start: {
12516 column: 1,
12517 line: 1,
12518 offset: 0
12519 }
12520 };
12521 }
12522 var _proto = Parser.prototype;
12523 _proto.atrule = function atrule(token) {
12524 var node2 = new AtRule$2$1();
12525 node2.name = token[1].slice(1);
12526 if (node2.name === "") {
12527 this.unnamedAtrule(node2, token);
12528 }
12529 this.init(node2, token[2]);
12530 var type;
12531 var prev;
12532 var shift;
12533 var last = false;
12534 var open = false;
12535 var params = [];
12536 var brackets = [];
12537 while(!this.tokenizer.endOfFile()){
12538 token = this.tokenizer.nextToken();
12539 type = token[0];
12540 if (type === "(" || type === "[") {
12541 brackets.push(type === "(" ? ")" : "]");
12542 } else if (type === "{" && brackets.length > 0) {
12543 brackets.push("}");
12544 } else if (type === brackets[brackets.length - 1]) {
12545 brackets.pop();
12546 }
12547 if (brackets.length === 0) {
12548 if (type === ";") {
12549 node2.source.end = this.getPosition(token[2]);
12550 node2.source.end.offset++;
12551 this.semicolon = true;
12552 break;
12553 } else if (type === "{") {
12554 open = true;
12555 break;
12556 } else if (type === "}") {
12557 if (params.length > 0) {
12558 shift = params.length - 1;
12559 prev = params[shift];
12560 while(prev && prev[0] === "space"){
12561 prev = params[--shift];
12562 }
12563 if (prev) {
12564 node2.source.end = this.getPosition(prev[3] || prev[2]);
12565 node2.source.end.offset++;
12566 }
12567 }
12568 this.end(token);
12569 break;
12570 } else {
12571 params.push(token);
12572 }
12573 } else {
12574 params.push(token);
12575 }
12576 if (this.tokenizer.endOfFile()) {
12577 last = true;
12578 break;
12579 }
12580 }
12581 node2.raws.between = this.spacesAndCommentsFromEnd(params);
12582 if (params.length) {
12583 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
12584 this.raw(node2, "params", params);
12585 if (last) {
12586 token = params[params.length - 1];
12587 node2.source.end = this.getPosition(token[3] || token[2]);
12588 node2.source.end.offset++;
12589 this.spaces = node2.raws.between;
12590 node2.raws.between = "";
12591 }
12592 } else {
12593 node2.raws.afterName = "";
12594 node2.params = "";
12595 }
12596 if (open) {
12597 node2.nodes = [];
12598 this.current = node2;
12599 }
12600 };
12601 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
12602 var colon = this.colon(tokens);
12603 if (colon === false) return;
12604 var founded = 0;
12605 var token;
12606 for(var j = colon - 1; j >= 0; j--){
12607 token = tokens[j];
12608 if (token[0] !== "space") {
12609 founded += 1;
12610 if (founded === 2) break;
12611 }
12612 }
12613 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
12614 };
12615 _proto.colon = function colon(tokens) {
12616 var brackets = 0;
12617 var token, type, prev;
12618 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
12619 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
12620 token = element;
12621 type = token[0];
12622 if (type === "(") {
12623 brackets += 1;
12624 }
12625 if (type === ")") {
12626 brackets -= 1;
12627 }
12628 if (brackets === 0 && type === ":") {
12629 if (!prev) {
12630 this.doubleColon(token);
12631 } else if (prev[0] === "word" && prev[1] === "progid") {
12632 continue;
12633 } else {
12634 return i2;
12635 }
12636 }
12637 prev = token;
12638 }
12639 return false;
12640 };
12641 _proto.comment = function comment(token) {
12642 var node2 = new Comment$2$1();
12643 this.init(node2, token[2]);
12644 node2.source.end = this.getPosition(token[3] || token[2]);
12645 node2.source.end.offset++;
12646 var text = token[1].slice(2, -2);
12647 if (/^\s*$/.test(text)) {
12648 node2.text = "";
12649 node2.raws.left = text;
12650 node2.raws.right = "";
12651 } else {
12652 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
12653 node2.text = match[2];
12654 node2.raws.left = match[1];
12655 node2.raws.right = match[3];
12656 }
12657 };
12658 _proto.createTokenizer = function createTokenizer() {
12659 this.tokenizer = tokenizer2$1(this.input);
12660 };
12661 _proto.decl = function decl(tokens, customProperty) {
12662 var node2 = new Declaration$2$1();
12663 this.init(node2, tokens[0][2]);
12664 var last = tokens[tokens.length - 1];
12665 if (last[0] === ";") {
12666 this.semicolon = true;
12667 tokens.pop();
12668 }
12669 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition$1(tokens));
12670 node2.source.end.offset++;
12671 while(tokens[0][0] !== "word"){
12672 if (tokens.length === 1) this.unknownWord(tokens);
12673 node2.raws.before += tokens.shift()[1];
12674 }
12675 node2.source.start = this.getPosition(tokens[0][2]);
12676 node2.prop = "";
12677 while(tokens.length){
12678 var type = tokens[0][0];
12679 if (type === ":" || type === "space" || type === "comment") {
12680 break;
12681 }
12682 node2.prop += tokens.shift()[1];
12683 }
12684 node2.raws.between = "";
12685 var token;
12686 while(tokens.length){
12687 token = tokens.shift();
12688 if (token[0] === ":") {
12689 node2.raws.between += token[1];
12690 break;
12691 } else {
12692 if (token[0] === "word" && /\w/.test(token[1])) {
12693 this.unknownWord([
12694 token
12695 ]);
12696 }
12697 node2.raws.between += token[1];
12698 }
12699 }
12700 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
12701 node2.raws.before += node2.prop[0];
12702 node2.prop = node2.prop.slice(1);
12703 }
12704 var firstSpaces = [];
12705 var next;
12706 while(tokens.length){
12707 next = tokens[0][0];
12708 if (next !== "space" && next !== "comment") break;
12709 firstSpaces.push(tokens.shift());
12710 }
12711 this.precheckMissedSemicolon(tokens);
12712 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
12713 token = tokens[i2];
12714 if (token[1].toLowerCase() === "!important") {
12715 node2.important = true;
12716 var string = this.stringFrom(tokens, i2);
12717 string = this.spacesFromEnd(tokens) + string;
12718 if (string !== " !important") node2.raws.important = string;
12719 break;
12720 } else if (token[1].toLowerCase() === "important") {
12721 var cache = tokens.slice(0);
12722 var str = "";
12723 for(var j = i2; j > 0; j--){
12724 var type1 = cache[j][0];
12725 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
12726 break;
12727 }
12728 str = cache.pop()[1] + str;
12729 }
12730 if (str.trim().indexOf("!") === 0) {
12731 node2.important = true;
12732 node2.raws.important = str;
12733 tokens = cache;
12734 }
12735 }
12736 if (token[0] !== "space" && token[0] !== "comment") {
12737 break;
12738 }
12739 }
12740 var hasWord = tokens.some(function(i2) {
12741 return i2[0] !== "space" && i2[0] !== "comment";
12742 });
12743 if (hasWord) {
12744 node2.raws.between += firstSpaces.map(function(i2) {
12745 return i2[1];
12746 }).join("");
12747 firstSpaces = [];
12748 }
12749 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
12750 if (node2.value.includes(":") && !customProperty) {
12751 this.checkMissedSemicolon(tokens);
12752 }
12753 };
12754 _proto.doubleColon = function doubleColon(token) {
12755 throw this.input.error("Double colon", {
12756 offset: token[2]
12757 }, {
12758 offset: token[2] + token[1].length
12759 });
12760 };
12761 _proto.emptyRule = function emptyRule(token) {
12762 var node2 = new Rule$2$1();
12763 this.init(node2, token[2]);
12764 node2.selector = "";
12765 node2.raws.between = "";
12766 this.current = node2;
12767 };
12768 _proto.end = function end(token) {
12769 if (this.current.nodes && this.current.nodes.length) {
12770 this.current.raws.semicolon = this.semicolon;
12771 }
12772 this.semicolon = false;
12773 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
12774 this.spaces = "";
12775 if (this.current.parent) {
12776 this.current.source.end = this.getPosition(token[2]);
12777 this.current.source.end.offset++;
12778 this.current = this.current.parent;
12779 } else {
12780 this.unexpectedClose(token);
12781 }
12782 };
12783 _proto.endFile = function endFile() {
12784 if (this.current.parent) this.unclosedBlock();
12785 if (this.current.nodes && this.current.nodes.length) {
12786 this.current.raws.semicolon = this.semicolon;
12787 }
12788 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
12789 this.root.source.end = this.getPosition(this.tokenizer.position());
12790 };
12791 _proto.freeSemicolon = function freeSemicolon(token) {
12792 this.spaces += token[1];
12793 if (this.current.nodes) {
12794 var prev = this.current.nodes[this.current.nodes.length - 1];
12795 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
12796 prev.raws.ownSemicolon = this.spaces;
12797 this.spaces = "";
12798 }
12799 }
12800 };
12801 // Helpers
12802 _proto.getPosition = function getPosition(offset) {
12803 var pos = this.input.fromOffset(offset);
12804 return {
12805 column: pos.col,
12806 line: pos.line,
12807 offset: offset
12808 };
12809 };
12810 _proto.init = function init(node2, offset) {
12811 this.current.push(node2);
12812 node2.source = {
12813 input: this.input,
12814 start: this.getPosition(offset)
12815 };
12816 node2.raws.before = this.spaces;
12817 this.spaces = "";
12818 if (node2.type !== "comment") this.semicolon = false;
12819 };
12820 _proto.other = function other(start) {
12821 var end = false;
12822 var type = null;
12823 var colon = false;
12824 var bracket = null;
12825 var brackets = [];
12826 var customProperty = start[1].startsWith("--");
12827 var tokens = [];
12828 var token = start;
12829 while(token){
12830 type = token[0];
12831 tokens.push(token);
12832 if (type === "(" || type === "[") {
12833 if (!bracket) bracket = token;
12834 brackets.push(type === "(" ? ")" : "]");
12835 } else if (customProperty && colon && type === "{") {
12836 if (!bracket) bracket = token;
12837 brackets.push("}");
12838 } else if (brackets.length === 0) {
12839 if (type === ";") {
12840 if (colon) {
12841 this.decl(tokens, customProperty);
12842 return;
12843 } else {
12844 break;
12845 }
12846 } else if (type === "{") {
12847 this.rule(tokens);
12848 return;
12849 } else if (type === "}") {
12850 this.tokenizer.back(tokens.pop());
12851 end = true;
12852 break;
12853 } else if (type === ":") {
12854 colon = true;
12855 }
12856 } else if (type === brackets[brackets.length - 1]) {
12857 brackets.pop();
12858 if (brackets.length === 0) bracket = null;
12859 }
12860 token = this.tokenizer.nextToken();
12861 }
12862 if (this.tokenizer.endOfFile()) end = true;
12863 if (brackets.length > 0) this.unclosedBracket(bracket);
12864 if (end && colon) {
12865 if (!customProperty) {
12866 while(tokens.length){
12867 token = tokens[tokens.length - 1][0];
12868 if (token !== "space" && token !== "comment") break;
12869 this.tokenizer.back(tokens.pop());
12870 }
12871 }
12872 this.decl(tokens, customProperty);
12873 } else {
12874 this.unknownWord(tokens);
12875 }
12876 };
12877 _proto.parse = function parse() {
12878 var token;
12879 while(!this.tokenizer.endOfFile()){
12880 token = this.tokenizer.nextToken();
12881 switch(token[0]){
12882 case "space":
12883 this.spaces += token[1];
12884 break;
12885 case ";":
12886 this.freeSemicolon(token);
12887 break;
12888 case "}":
12889 this.end(token);
12890 break;
12891 case "comment":
12892 this.comment(token);
12893 break;
12894 case "at-word":
12895 this.atrule(token);
12896 break;
12897 case "{":
12898 this.emptyRule(token);
12899 break;
12900 default:
12901 this.other(token);
12902 break;
12903 }
12904 }
12905 this.endFile();
12906 };
12907 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
12908 _proto.raw = function raw(node2, prop, tokens, customProperty) {
12909 var token, type;
12910 var length = tokens.length;
12911 var value = "";
12912 var clean = true;
12913 var next, prev;
12914 for(var i2 = 0; i2 < length; i2 += 1){
12915 token = tokens[i2];
12916 type = token[0];
12917 if (type === "space" && i2 === length - 1 && !customProperty) {
12918 clean = false;
12919 } else if (type === "comment") {
12920 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
12921 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
12922 if (!SAFE_COMMENT_NEIGHBOR$1[prev] && !SAFE_COMMENT_NEIGHBOR$1[next]) {
12923 if (value.slice(-1) === ",") {
12924 clean = false;
12925 } else {
12926 value += token[1];
12927 }
12928 } else {
12929 clean = false;
12930 }
12931 } else {
12932 value += token[1];
12933 }
12934 }
12935 if (!clean) {
12936 var raw = tokens.reduce(function(all, i2) {
12937 return all + i2[1];
12938 }, "");
12939 node2.raws[prop] = {
12940 raw: raw,
12941 value: value
12942 };
12943 }
12944 node2[prop] = value;
12945 };
12946 _proto.rule = function rule(tokens) {
12947 tokens.pop();
12948 var node2 = new Rule$2$1();
12949 this.init(node2, tokens[0][2]);
12950 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
12951 this.raw(node2, "selector", tokens);
12952 this.current = node2;
12953 };
12954 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
12955 var lastTokenType;
12956 var spaces = "";
12957 while(tokens.length){
12958 lastTokenType = tokens[tokens.length - 1][0];
12959 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
12960 spaces = tokens.pop()[1] + spaces;
12961 }
12962 return spaces;
12963 };
12964 // Errors
12965 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
12966 var next;
12967 var spaces = "";
12968 while(tokens.length){
12969 next = tokens[0][0];
12970 if (next !== "space" && next !== "comment") break;
12971 spaces += tokens.shift()[1];
12972 }
12973 return spaces;
12974 };
12975 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
12976 var lastTokenType;
12977 var spaces = "";
12978 while(tokens.length){
12979 lastTokenType = tokens[tokens.length - 1][0];
12980 if (lastTokenType !== "space") break;
12981 spaces = tokens.pop()[1] + spaces;
12982 }
12983 return spaces;
12984 };
12985 _proto.stringFrom = function stringFrom(tokens, from) {
12986 var result2 = "";
12987 for(var i2 = from; i2 < tokens.length; i2++){
12988 result2 += tokens[i2][1];
12989 }
12990 tokens.splice(from, tokens.length - from);
12991 return result2;
12992 };
12993 _proto.unclosedBlock = function unclosedBlock() {
12994 var pos = this.current.source.start;
12995 throw this.input.error("Unclosed block", pos.line, pos.column);
12996 };
12997 _proto.unclosedBracket = function unclosedBracket(bracket) {
12998 throw this.input.error("Unclosed bracket", {
12999 offset: bracket[2]
13000 }, {
13001 offset: bracket[2] + 1
13002 });
13003 };
13004 _proto.unexpectedClose = function unexpectedClose(token) {
13005 throw this.input.error("Unexpected }", {
13006 offset: token[2]
13007 }, {
13008 offset: token[2] + 1
13009 });
13010 };
13011 _proto.unknownWord = function unknownWord(tokens) {
13012 throw this.input.error("Unknown word", {
13013 offset: tokens[0][2]
13014 }, {
13015 offset: tokens[0][2] + tokens[0][1].length
13016 });
13017 };
13018 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
13019 throw this.input.error("At-rule without name", {
13020 offset: token[2]
13021 }, {
13022 offset: token[2] + token[1].length
13023 });
13024 };
13025 return Parser;
13026 }();
13027 var parser$1 = Parser$1$1;
13028 var Container$2$1 = container$1;
13029 var Parser2$1 = parser$1;
13030 var Input$2$1 = input$1;
13031 function parse$3$1(css, opts) {
13032 var input2 = new Input$2$1(css, opts);
13033 var parser2 = new Parser2$1(input2);
13034 try {
13035 parser2.parse();
13036 } catch (e2) {
13037 if (true) {
13038 if (e2.name === "CssSyntaxError" && opts && opts.from) {
13039 if (/\.scss$/i.test(opts.from)) {
13040 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
13041 } else if (/\.sass/i.test(opts.from)) {
13042 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
13043 } else if (/\.less$/i.test(opts.from)) {
13044 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
13045 }
13046 }
13047 }
13048 throw e2;
13049 }
13050 return parser2.root;
13051 }
13052 var parse_1$1 = parse$3$1;
13053 parse$3$1.default = parse$3$1;
13054 Container$2$1.registerParse(parse$3$1);
13055 var isClean$3 = symbols$1.isClean, my$3 = symbols$1.my;
13056 var MapGenerator$1$1 = mapGenerator$1;
13057 var stringify$2$1 = stringify_1$1;
13058 var Container$1$1 = container$1;
13059 var Document$2$1 = document$1$1;
13060 var warnOnce$1$1 = warnOnce$2$1;
13061 var Result$2$1 = result$1;
13062 var parse$2$1 = parse_1$1;
13063 var Root$3$1 = root$1;
13064 var TYPE_TO_CLASS_NAME$1 = {
13065 atrule: "AtRule",
13066 comment: "Comment",
13067 decl: "Declaration",
13068 document: "Document",
13069 root: "Root",
13070 rule: "Rule"
13071 };
13072 var PLUGIN_PROPS$1 = {
13073 AtRule: true,
13074 AtRuleExit: true,
13075 Comment: true,
13076 CommentExit: true,
13077 Declaration: true,
13078 DeclarationExit: true,
13079 Document: true,
13080 DocumentExit: true,
13081 Once: true,
13082 OnceExit: true,
13083 postcssPlugin: true,
13084 prepare: true,
13085 Root: true,
13086 RootExit: true,
13087 Rule: true,
13088 RuleExit: true
13089 };
13090 var NOT_VISITORS$1 = {
13091 Once: true,
13092 postcssPlugin: true,
13093 prepare: true
13094 };
13095 var CHILDREN$1 = 0;
13096 function isPromise$1(obj) {
13097 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
13098 }
13099 function getEvents$1(node2) {
13100 var key = false;
13101 var type = TYPE_TO_CLASS_NAME$1[node2.type];
13102 if (node2.type === "decl") {
13103 key = node2.prop.toLowerCase();
13104 } else if (node2.type === "atrule") {
13105 key = node2.name.toLowerCase();
13106 }
13107 if (key && node2.append) {
13108 return [
13109 type,
13110 type + "-" + key,
13111 CHILDREN$1,
13112 type + "Exit",
13113 type + "Exit-" + key
13114 ];
13115 } else if (key) {
13116 return [
13117 type,
13118 type + "-" + key,
13119 type + "Exit",
13120 type + "Exit-" + key
13121 ];
13122 } else if (node2.append) {
13123 return [
13124 type,
13125 CHILDREN$1,
13126 type + "Exit"
13127 ];
13128 } else {
13129 return [
13130 type,
13131 type + "Exit"
13132 ];
13133 }
13134 }
13135 function toStack$1(node2) {
13136 var events;
13137 if (node2.type === "document") {
13138 events = [
13139 "Document",
13140 CHILDREN$1,
13141 "DocumentExit"
13142 ];
13143 } else if (node2.type === "root") {
13144 events = [
13145 "Root",
13146 CHILDREN$1,
13147 "RootExit"
13148 ];
13149 } else {
13150 events = getEvents$1(node2);
13151 }
13152 return {
13153 eventIndex: 0,
13154 events: events,
13155 iterator: 0,
13156 node: node2,
13157 visitorIndex: 0,
13158 visitors: []
13159 };
13160 }
13161 function cleanMarks$1(node2) {
13162 node2[isClean$3] = false;
13163 if (node2.nodes) node2.nodes.forEach(function(i2) {
13164 return cleanMarks$1(i2);
13165 });
13166 return node2;
13167 }
13168 var postcss$2$1 = {};
13169 var LazyResult$2$1 = /*#__PURE__*/ function() {
13170 function LazyResult(processor2, css, opts) {
13171 var _this = this;
13172 this.stringified = false;
13173 this.processed = false;
13174 var root2;
13175 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
13176 root2 = cleanMarks$1(css);
13177 } else if (_instanceof(css, LazyResult) || _instanceof(css, Result$2$1)) {
13178 root2 = cleanMarks$1(css.root);
13179 if (css.map) {
13180 if (typeof opts.map === "undefined") opts.map = {};
13181 if (!opts.map.inline) opts.map.inline = false;
13182 opts.map.prev = css.map;
13183 }
13184 } else {
13185 var parser2 = parse$2$1;
13186 if (opts.syntax) parser2 = opts.syntax.parse;
13187 if (opts.parser) parser2 = opts.parser;
13188 if (parser2.parse) parser2 = parser2.parse;
13189 try {
13190 root2 = parser2(css, opts);
13191 } catch (error) {
13192 this.processed = true;
13193 this.error = error;
13194 }
13195 if (root2 && !root2[my$3]) {
13196 Container$1$1.rebuild(root2);
13197 }
13198 }
13199 this.result = new Result$2$1(processor2, root2, opts);
13200 this.helpers = _extends({}, postcss$2$1, {
13201 postcss: postcss$2$1,
13202 result: this.result
13203 });
13204 this.plugins = this.processor.plugins.map(function(plugin22) {
13205 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
13206 return _extends({}, plugin22, plugin22.prepare(_this.result));
13207 } else {
13208 return plugin22;
13209 }
13210 });
13211 }
13212 var _proto = LazyResult.prototype;
13213 _proto.async = function async() {
13214 if (this.error) return Promise.reject(this.error);
13215 if (this.processed) return Promise.resolve(this.result);
13216 if (!this.processing) {
13217 this.processing = this.runAsync();
13218 }
13219 return this.processing;
13220 };
13221 _proto.catch = function _catch(onRejected) {
13222 return this.async().catch(onRejected);
13223 };
13224 _proto.finally = function _finally(onFinally) {
13225 return this.async().then(onFinally, onFinally);
13226 };
13227 _proto.getAsyncError = function getAsyncError() {
13228 throw new Error("Use process(css).then(cb) to work with async plugins");
13229 };
13230 _proto.handleError = function handleError(error, node2) {
13231 var plugin22 = this.result.lastPlugin;
13232 try {
13233 if (node2) node2.addToError(error);
13234 this.error = error;
13235 if (error.name === "CssSyntaxError" && !error.plugin) {
13236 error.plugin = plugin22.postcssPlugin;
13237 error.setMessage();
13238 } else if (plugin22.postcssVersion) {
13239 if (true) {
13240 var pluginName = plugin22.postcssPlugin;
13241 var pluginVer = plugin22.postcssVersion;
13242 var runtimeVer = this.result.processor.version;
13243 var a2 = pluginVer.split(".");
13244 var b = runtimeVer.split(".");
13245 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
13246 console.error("Unknown error from PostCSS plugin. Your current PostCSS version is " + runtimeVer + ", but " + pluginName + " uses " + pluginVer + ". Perhaps this is the source of the error below.");
13247 }
13248 }
13249 }
13250 } catch (err) {
13251 if (console && console.error) console.error(err);
13252 }
13253 return error;
13254 };
13255 _proto.prepareVisitors = function prepareVisitors() {
13256 var _this = this;
13257 this.listeners = {};
13258 var add = function(plugin22, type, cb) {
13259 if (!_this.listeners[type]) _this.listeners[type] = [];
13260 _this.listeners[type].push([
13261 plugin22,
13262 cb
13263 ]);
13264 };
13265 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13266 var plugin22 = _step.value;
13267 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
13268 for(var event in plugin22){
13269 if (!PLUGIN_PROPS$1[event] && /^[A-Z]/.test(event)) {
13270 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
13271 }
13272 if (!NOT_VISITORS$1[event]) {
13273 if (_type_of(plugin22[event]) === "object") {
13274 for(var filter in plugin22[event]){
13275 if (filter === "*") {
13276 add(plugin22, event, plugin22[event][filter]);
13277 } else {
13278 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
13279 }
13280 }
13281 } else if (typeof plugin22[event] === "function") {
13282 add(plugin22, event, plugin22[event]);
13283 }
13284 }
13285 }
13286 }
13287 }
13288 this.hasListener = Object.keys(this.listeners).length > 0;
13289 };
13290 _proto.runAsync = function runAsync() {
13291 var _this = this;
13292 return _async_to_generator(function() {
13293 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
13294 return _ts_generator(this, function(_state) {
13295 switch(_state.label){
13296 case 0:
13297 _this.plugin = 0;
13298 i2 = 0;
13299 _state.label = 1;
13300 case 1:
13301 if (!(i2 < _this.plugins.length)) return [
13302 3,
13303 6
13304 ];
13305 plugin22 = _this.plugins[i2];
13306 promise = _this.runOnRoot(plugin22);
13307 if (!isPromise$1(promise)) return [
13308 3,
13309 5
13310 ];
13311 _state.label = 2;
13312 case 2:
13313 _state.trys.push([
13314 2,
13315 4,
13316 ,
13317 5
13318 ]);
13319 return [
13320 4,
13321 promise
13322 ];
13323 case 3:
13324 _state.sent();
13325 return [
13326 3,
13327 5
13328 ];
13329 case 4:
13330 error = _state.sent();
13331 throw _this.handleError(error);
13332 case 5:
13333 i2++;
13334 return [
13335 3,
13336 1
13337 ];
13338 case 6:
13339 _this.prepareVisitors();
13340 if (!_this.hasListener) return [
13341 3,
13342 18
13343 ];
13344 root2 = _this.result.root;
13345 _state.label = 7;
13346 case 7:
13347 if (!!root2[isClean$3]) return [
13348 3,
13349 14
13350 ];
13351 root2[isClean$3] = true;
13352 stack = [
13353 toStack$1(root2)
13354 ];
13355 _state.label = 8;
13356 case 8:
13357 if (!(stack.length > 0)) return [
13358 3,
13359 13
13360 ];
13361 promise1 = _this.visitTick(stack);
13362 if (!isPromise$1(promise1)) return [
13363 3,
13364 12
13365 ];
13366 _state.label = 9;
13367 case 9:
13368 _state.trys.push([
13369 9,
13370 11,
13371 ,
13372 12
13373 ]);
13374 return [
13375 4,
13376 promise1
13377 ];
13378 case 10:
13379 _state.sent();
13380 return [
13381 3,
13382 12
13383 ];
13384 case 11:
13385 e2 = _state.sent();
13386 node2 = stack[stack.length - 1].node;
13387 throw _this.handleError(e2, node2);
13388 case 12:
13389 return [
13390 3,
13391 8
13392 ];
13393 case 13:
13394 return [
13395 3,
13396 7
13397 ];
13398 case 14:
13399 if (!_this.listeners.OnceExit) return [
13400 3,
13401 18
13402 ];
13403 _loop = function() {
13404 var _step_value, plugin22, visitor, roots, e2;
13405 return _ts_generator(this, function(_state) {
13406 switch(_state.label){
13407 case 0:
13408 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13409 _this.result.lastPlugin = plugin22;
13410 _state.label = 1;
13411 case 1:
13412 _state.trys.push([
13413 1,
13414 6,
13415 ,
13416 7
13417 ]);
13418 if (!(root2.type === "document")) return [
13419 3,
13420 3
13421 ];
13422 roots = root2.nodes.map(function(subRoot) {
13423 return visitor(subRoot, _this.helpers);
13424 });
13425 return [
13426 4,
13427 Promise.all(roots)
13428 ];
13429 case 2:
13430 _state.sent();
13431 return [
13432 3,
13433 5
13434 ];
13435 case 3:
13436 return [
13437 4,
13438 visitor(root2, _this.helpers)
13439 ];
13440 case 4:
13441 _state.sent();
13442 _state.label = 5;
13443 case 5:
13444 return [
13445 3,
13446 7
13447 ];
13448 case 6:
13449 e2 = _state.sent();
13450 throw _this.handleError(e2);
13451 case 7:
13452 return [
13453 2
13454 ];
13455 }
13456 });
13457 };
13458 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
13459 _state.label = 15;
13460 case 15:
13461 if (!!(_step = _iterator()).done) return [
13462 3,
13463 18
13464 ];
13465 return [
13466 5,
13467 _ts_values(_loop())
13468 ];
13469 case 16:
13470 _state.sent();
13471 _state.label = 17;
13472 case 17:
13473 return [
13474 3,
13475 15
13476 ];
13477 case 18:
13478 _this.processed = true;
13479 return [
13480 2,
13481 _this.stringify()
13482 ];
13483 }
13484 });
13485 })();
13486 };
13487 _proto.runOnRoot = function runOnRoot(plugin22) {
13488 var _this = this;
13489 this.result.lastPlugin = plugin22;
13490 try {
13491 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
13492 if (this.result.root.type === "document") {
13493 var roots = this.result.root.nodes.map(function(root2) {
13494 return plugin22.Once(root2, _this.helpers);
13495 });
13496 if (isPromise$1(roots[0])) {
13497 return Promise.all(roots);
13498 }
13499 return roots;
13500 }
13501 return plugin22.Once(this.result.root, this.helpers);
13502 } else if (typeof plugin22 === "function") {
13503 return plugin22(this.result.root, this.result);
13504 }
13505 } catch (error) {
13506 throw this.handleError(error);
13507 }
13508 };
13509 _proto.stringify = function stringify() {
13510 if (this.error) throw this.error;
13511 if (this.stringified) return this.result;
13512 this.stringified = true;
13513 this.sync();
13514 var opts = this.result.opts;
13515 var str = stringify$2$1;
13516 if (opts.syntax) str = opts.syntax.stringify;
13517 if (opts.stringifier) str = opts.stringifier;
13518 if (str.stringify) str = str.stringify;
13519 var map = new MapGenerator$1$1(str, this.result.root, this.result.opts);
13520 var data = map.generate();
13521 this.result.css = data[0];
13522 this.result.map = data[1];
13523 return this.result;
13524 };
13525 _proto.sync = function sync() {
13526 if (this.error) throw this.error;
13527 if (this.processed) return this.result;
13528 this.processed = true;
13529 if (this.processing) {
13530 throw this.getAsyncError();
13531 }
13532 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13533 var plugin22 = _step.value;
13534 var promise = this.runOnRoot(plugin22);
13535 if (isPromise$1(promise)) {
13536 throw this.getAsyncError();
13537 }
13538 }
13539 this.prepareVisitors();
13540 if (this.hasListener) {
13541 var root2 = this.result.root;
13542 while(!root2[isClean$3]){
13543 root2[isClean$3] = true;
13544 this.walkSync(root2);
13545 }
13546 if (this.listeners.OnceExit) {
13547 if (root2.type === "document") {
13548 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
13549 var subRoot = _step1.value;
13550 this.visitSync(this.listeners.OnceExit, subRoot);
13551 }
13552 } else {
13553 this.visitSync(this.listeners.OnceExit, root2);
13554 }
13555 }
13556 }
13557 return this.result;
13558 };
13559 _proto.then = function then(onFulfilled, onRejected) {
13560 if (true) {
13561 if (!("from" in this.opts)) {
13562 warnOnce$1$1("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.");
13563 }
13564 }
13565 return this.async().then(onFulfilled, onRejected);
13566 };
13567 _proto.toString = function toString() {
13568 return this.css;
13569 };
13570 _proto.visitSync = function visitSync(visitors, node2) {
13571 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
13572 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13573 this.result.lastPlugin = plugin22;
13574 var promise = void 0;
13575 try {
13576 promise = visitor(node2, this.helpers);
13577 } catch (e2) {
13578 throw this.handleError(e2, node2.proxyOf);
13579 }
13580 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
13581 return true;
13582 }
13583 if (isPromise$1(promise)) {
13584 throw this.getAsyncError();
13585 }
13586 }
13587 };
13588 _proto.visitTick = function visitTick(stack) {
13589 var visit2 = stack[stack.length - 1];
13590 var node2 = visit2.node, visitors = visit2.visitors;
13591 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
13592 stack.pop();
13593 return;
13594 }
13595 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
13596 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
13597 visit2.visitorIndex += 1;
13598 if (visit2.visitorIndex === visitors.length) {
13599 visit2.visitors = [];
13600 visit2.visitorIndex = 0;
13601 }
13602 this.result.lastPlugin = plugin22;
13603 try {
13604 return visitor(node2.toProxy(), this.helpers);
13605 } catch (e2) {
13606 throw this.handleError(e2, node2);
13607 }
13608 }
13609 if (visit2.iterator !== 0) {
13610 var iterator = visit2.iterator;
13611 var child;
13612 while(child = node2.nodes[node2.indexes[iterator]]){
13613 node2.indexes[iterator] += 1;
13614 if (!child[isClean$3]) {
13615 child[isClean$3] = true;
13616 stack.push(toStack$1(child));
13617 return;
13618 }
13619 }
13620 visit2.iterator = 0;
13621 delete node2.indexes[iterator];
13622 }
13623 var events = visit2.events;
13624 while(visit2.eventIndex < events.length){
13625 var event = events[visit2.eventIndex];
13626 visit2.eventIndex += 1;
13627 if (event === CHILDREN$1) {
13628 if (node2.nodes && node2.nodes.length) {
13629 node2[isClean$3] = true;
13630 visit2.iterator = node2.getIterator();
13631 }
13632 return;
13633 } else if (this.listeners[event]) {
13634 visit2.visitors = this.listeners[event];
13635 return;
13636 }
13637 }
13638 stack.pop();
13639 };
13640 _proto.walkSync = function walkSync(node2) {
13641 var _this = this;
13642 node2[isClean$3] = true;
13643 var events = getEvents$1(node2);
13644 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
13645 var event = _step.value;
13646 if (event === CHILDREN$1) {
13647 if (node2.nodes) {
13648 node2.each(function(child) {
13649 if (!child[isClean$3]) _this.walkSync(child);
13650 });
13651 }
13652 } else {
13653 var visitors = this.listeners[event];
13654 if (visitors) {
13655 if (this.visitSync(visitors, node2.toProxy())) return;
13656 }
13657 }
13658 }
13659 };
13660 _proto.warnings = function warnings() {
13661 return this.sync().warnings();
13662 };
13663 _create_class(LazyResult, [
13664 {
13665 key: "content",
13666 get: function get() {
13667 return this.stringify().content;
13668 }
13669 },
13670 {
13671 key: "css",
13672 get: function get() {
13673 return this.stringify().css;
13674 }
13675 },
13676 {
13677 key: "map",
13678 get: function get() {
13679 return this.stringify().map;
13680 }
13681 },
13682 {
13683 key: "messages",
13684 get: function get() {
13685 return this.sync().messages;
13686 }
13687 },
13688 {
13689 key: "opts",
13690 get: function get() {
13691 return this.result.opts;
13692 }
13693 },
13694 {
13695 key: "processor",
13696 get: function get() {
13697 return this.result.processor;
13698 }
13699 },
13700 {
13701 key: "root",
13702 get: function get() {
13703 return this.sync().root;
13704 }
13705 },
13706 {
13707 key: Symbol.toStringTag,
13708 get: function get() {
13709 return "LazyResult";
13710 }
13711 }
13712 ]);
13713 return LazyResult;
13714 }();
13715 LazyResult$2$1.registerPostcss = function(dependant) {
13716 postcss$2$1 = dependant;
13717 };
13718 var lazyResult$1 = LazyResult$2$1;
13719 LazyResult$2$1.default = LazyResult$2$1;
13720 Root$3$1.registerLazyResult(LazyResult$2$1);
13721 Document$2$1.registerLazyResult(LazyResult$2$1);
13722 var MapGenerator2$1 = mapGenerator$1;
13723 var stringify$1$1 = stringify_1$1;
13724 var warnOnce2$1 = warnOnce$2$1;
13725 var parse$1$1 = parse_1$1;
13726 var Result$1$1 = result$1;
13727 var NoWorkResult$1$1 = /*#__PURE__*/ function() {
13728 function NoWorkResult(processor2, css, opts) {
13729 css = css.toString();
13730 this.stringified = false;
13731 this._processor = processor2;
13732 this._css = css;
13733 this._opts = opts;
13734 this._map = void 0;
13735 var root2;
13736 var str = stringify$1$1;
13737 this.result = new Result$1$1(this._processor, root2, this._opts);
13738 this.result.css = css;
13739 var self = this;
13740 Object.defineProperty(this.result, "root", {
13741 get: function get() {
13742 return self.root;
13743 }
13744 });
13745 var map = new MapGenerator2$1(str, root2, this._opts, css);
13746 if (map.isMap()) {
13747 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
13748 if (generatedCSS) {
13749 this.result.css = generatedCSS;
13750 }
13751 if (generatedMap) {
13752 this.result.map = generatedMap;
13753 }
13754 } else {
13755 map.clearAnnotation();
13756 this.result.css = map.css;
13757 }
13758 }
13759 var _proto = NoWorkResult.prototype;
13760 _proto.async = function async() {
13761 if (this.error) return Promise.reject(this.error);
13762 return Promise.resolve(this.result);
13763 };
13764 _proto.catch = function _catch(onRejected) {
13765 return this.async().catch(onRejected);
13766 };
13767 _proto.finally = function _finally(onFinally) {
13768 return this.async().then(onFinally, onFinally);
13769 };
13770 _proto.sync = function sync() {
13771 if (this.error) throw this.error;
13772 return this.result;
13773 };
13774 _proto.then = function then(onFulfilled, onRejected) {
13775 if (true) {
13776 if (!("from" in this._opts)) {
13777 warnOnce2$1("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.");
13778 }
13779 }
13780 return this.async().then(onFulfilled, onRejected);
13781 };
13782 _proto.toString = function toString() {
13783 return this._css;
13784 };
13785 _proto.warnings = function warnings() {
13786 return [];
13787 };
13788 _create_class(NoWorkResult, [
13789 {
13790 key: "content",
13791 get: function get() {
13792 return this.result.css;
13793 }
13794 },
13795 {
13796 key: "css",
13797 get: function get() {
13798 return this.result.css;
13799 }
13800 },
13801 {
13802 key: "map",
13803 get: function get() {
13804 return this.result.map;
13805 }
13806 },
13807 {
13808 key: "messages",
13809 get: function get() {
13810 return [];
13811 }
13812 },
13813 {
13814 key: "opts",
13815 get: function get() {
13816 return this.result.opts;
13817 }
13818 },
13819 {
13820 key: "processor",
13821 get: function get() {
13822 return this.result.processor;
13823 }
13824 },
13825 {
13826 key: "root",
13827 get: function get() {
13828 if (this._root) {
13829 return this._root;
13830 }
13831 var root2;
13832 var parser2 = parse$1$1;
13833 try {
13834 root2 = parser2(this._css, this._opts);
13835 } catch (error) {
13836 this.error = error;
13837 }
13838 if (this.error) {
13839 throw this.error;
13840 } else {
13841 this._root = root2;
13842 return root2;
13843 }
13844 }
13845 },
13846 {
13847 key: Symbol.toStringTag,
13848 get: function get() {
13849 return "NoWorkResult";
13850 }
13851 }
13852 ]);
13853 return NoWorkResult;
13854 }();
13855 var noWorkResult$1 = NoWorkResult$1$1;
13856 NoWorkResult$1$1.default = NoWorkResult$1$1;
13857 var NoWorkResult2$1 = noWorkResult$1;
13858 var LazyResult$1$1 = lazyResult$1;
13859 var Document$1$1 = document$1$1;
13860 var Root$2$1 = root$1;
13861 var Processor$1$1 = /*#__PURE__*/ function() {
13862 function Processor(plugins) {
13863 if (plugins === void 0) plugins = [];
13864 this.version = "8.4.38";
13865 this.plugins = this.normalize(plugins);
13866 }
13867 var _proto = Processor.prototype;
13868 _proto.normalize = function normalize(plugins) {
13869 var normalized = [];
13870 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
13871 var i2 = _step.value;
13872 if (i2.postcss === true) {
13873 i2 = i2();
13874 } else if (i2.postcss) {
13875 i2 = i2.postcss;
13876 }
13877 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
13878 normalized = normalized.concat(i2.plugins);
13879 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
13880 normalized.push(i2);
13881 } else if (typeof i2 === "function") {
13882 normalized.push(i2);
13883 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
13884 if (true) {
13885 throw new Error("PostCSS syntaxes cannot be used as plugins. Instead, please use one of the syntax/parser/stringifier options as outlined in your PostCSS runner documentation.");
13886 }
13887 } else {
13888 throw new Error(i2 + " is not a PostCSS plugin");
13889 }
13890 }
13891 return normalized;
13892 };
13893 _proto.process = function process1(css, opts) {
13894 if (opts === void 0) opts = {};
13895 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
13896 return new NoWorkResult2$1(this, css, opts);
13897 } else {
13898 return new LazyResult$1$1(this, css, opts);
13899 }
13900 };
13901 _proto.use = function use(plugin22) {
13902 this.plugins = this.plugins.concat(this.normalize([
13903 plugin22
13904 ]));
13905 return this;
13906 };
13907 return Processor;
13908 }();
13909 var processor$1 = Processor$1$1;
13910 Processor$1$1.default = Processor$1$1;
13911 Root$2$1.registerProcessor(Processor$1$1);
13912 Document$1$1.registerProcessor(Processor$1$1);
13913 var Declaration$1$1 = declaration$1;
13914 var PreviousMap2$1 = previousMap$1;
13915 var Comment$1$1 = comment$1;
13916 var AtRule$1$1 = atRule$1;
13917 var Input$1$1 = input$1;
13918 var Root$1$1 = root$1;
13919 var Rule$1$1 = rule$1;
13920 function fromJSON$1$1(json, inputs) {
13921 if (Array.isArray(json)) return json.map(function(n2) {
13922 return fromJSON$1$1(n2);
13923 });
13924 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
13925 "inputs"
13926 ]);
13927 if (ownInputs) {
13928 inputs = [];
13929 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
13930 var input2 = _step.value;
13931 var inputHydrated = _extends({}, input2, {
13932 __proto__: Input$1$1.prototype
13933 });
13934 if (inputHydrated.map) {
13935 inputHydrated.map = _extends({}, inputHydrated.map, {
13936 __proto__: PreviousMap2$1.prototype
13937 });
13938 }
13939 inputs.push(inputHydrated);
13940 }
13941 }
13942 if (defaults.nodes) {
13943 defaults.nodes = json.nodes.map(function(n2) {
13944 return fromJSON$1$1(n2, inputs);
13945 });
13946 }
13947 if (defaults.source) {
13948 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
13949 "inputId"
13950 ]);
13951 defaults.source = source;
13952 if (inputId != null) {
13953 defaults.source.input = inputs[inputId];
13954 }
13955 }
13956 if (defaults.type === "root") {
13957 return new Root$1$1(defaults);
13958 } else if (defaults.type === "decl") {
13959 return new Declaration$1$1(defaults);
13960 } else if (defaults.type === "rule") {
13961 return new Rule$1$1(defaults);
13962 } else if (defaults.type === "comment") {
13963 return new Comment$1$1(defaults);
13964 } else if (defaults.type === "atrule") {
13965 return new AtRule$1$1(defaults);
13966 } else {
13967 throw new Error("Unknown node type: " + json.type);
13968 }
13969 }
13970 var fromJSON_1$1 = fromJSON$1$1;
13971 fromJSON$1$1.default = fromJSON$1$1;
13972 var CssSyntaxError2$1 = cssSyntaxError$1;
13973 var Declaration2$1 = declaration$1;
13974 var LazyResult2$1 = lazyResult$1;
13975 var Container2$1 = container$1;
13976 var Processor2$1 = processor$1;
13977 var stringify$5 = stringify_1$1;
13978 var fromJSON$2 = fromJSON_1$1;
13979 var Document22 = document$1$1;
13980 var Warning2$1 = warning$1;
13981 var Comment2$1 = comment$1;
13982 var AtRule2$1 = atRule$1;
13983 var Result2$1 = result$1;
13984 var Input2$1 = input$1;
13985 var parse$5 = parse_1$1;
13986 var list$3 = list_1$1;
13987 var Rule2$1 = rule$1;
13988 var Root2$1 = root$1;
13989 var Node2$1 = node$1;
13990 function postcss$3() {
13991 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
13992 plugins[_key] = arguments[_key];
13993 }
13994 if (plugins.length === 1 && Array.isArray(plugins[0])) {
13995 plugins = plugins[0];
13996 }
13997 return new Processor2$1(plugins);
13998 }
13999 postcss$3.plugin = function plugin(name, initializer) {
14000 var warningPrinted = false;
14001 function creator() {
14002 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
14003 args[_key] = arguments[_key];
14004 }
14005 if (console && console.warn && !warningPrinted) {
14006 warningPrinted = true;
14007 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
14008 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
14009 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
14010 }
14011 }
14012 var transformer = initializer.apply(void 0, [].concat(args));
14013 transformer.postcssPlugin = name;
14014 transformer.postcssVersion = new Processor2$1().version;
14015 return transformer;
14016 }
14017 var cache;
14018 Object.defineProperty(creator, "postcss", {
14019 get: function get() {
14020 if (!cache) cache = creator();
14021 return cache;
14022 }
14023 });
14024 creator.process = function(css, processOpts, pluginOpts) {
14025 return postcss$3([
14026 creator(pluginOpts)
14027 ]).process(css, processOpts);
14028 };
14029 return creator;
14030 };
14031 postcss$3.stringify = stringify$5;
14032 postcss$3.parse = parse$5;
14033 postcss$3.fromJSON = fromJSON$2;
14034 postcss$3.list = list$3;
14035 postcss$3.comment = function(defaults) {
14036 return new Comment2$1(defaults);
14037 };
14038 postcss$3.atRule = function(defaults) {
14039 return new AtRule2$1(defaults);
14040 };
14041 postcss$3.decl = function(defaults) {
14042 return new Declaration2$1(defaults);
14043 };
14044 postcss$3.rule = function(defaults) {
14045 return new Rule2$1(defaults);
14046 };
14047 postcss$3.root = function(defaults) {
14048 return new Root2$1(defaults);
14049 };
14050 postcss$3.document = function(defaults) {
14051 return new Document22(defaults);
14052 };
14053 postcss$3.CssSyntaxError = CssSyntaxError2$1;
14054 postcss$3.Declaration = Declaration2$1;
14055 postcss$3.Container = Container2$1;
14056 postcss$3.Processor = Processor2$1;
14057 postcss$3.Document = Document22;
14058 postcss$3.Comment = Comment2$1;
14059 postcss$3.Warning = Warning2$1;
14060 postcss$3.AtRule = AtRule2$1;
14061 postcss$3.Result = Result2$1;
14062 postcss$3.Input = Input2$1;
14063 postcss$3.Rule = Rule2$1;
14064 postcss$3.Root = Root2$1;
14065 postcss$3.Node = Node2$1;
14066 LazyResult2$1.registerPostcss(postcss$3);
14067 var postcss_1$1 = postcss$3;
14068 postcss$3.default = postcss$3;
14069 var postcss$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(postcss_1$1);
14070 postcss$1$1.stringify;
14071 postcss$1$1.fromJSON;
14072 postcss$1$1.plugin;
14073 postcss$1$1.parse;
14074 postcss$1$1.list;
14075 postcss$1$1.document;
14076 postcss$1$1.comment;
14077 postcss$1$1.atRule;
14078 postcss$1$1.rule;
14079 postcss$1$1.decl;
14080 postcss$1$1.root;
14081 postcss$1$1.CssSyntaxError;
14082 postcss$1$1.Declaration;
14083 postcss$1$1.Container;
14084 postcss$1$1.Processor;
14085 postcss$1$1.Document;
14086 postcss$1$1.Comment;
14087 postcss$1$1.Warning;
14088 postcss$1$1.AtRule;
14089 postcss$1$1.Result;
14090 postcss$1$1.Input;
14091 postcss$1$1.Rule;
14092 postcss$1$1.Root;
14093 postcss$1$1.Node;
14094 var __defProp2 = Object.defineProperty;
14095 var __defNormalProp2 = function(obj, key, value) {
14096 return key in obj ? __defProp2(obj, key, {
14097 enumerable: true,
14098 configurable: true,
14099 writable: true,
14100 value: value
14101 }) : obj[key] = value;
14102 };
14103 var __publicField2 = function(obj, key, value) {
14104 return __defNormalProp2(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
14105 };
14106 function getDefaultExportFromCjs(x2) {
14107 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
14108 }
14109 function getAugmentedNamespace(n2) {
14110 if (n2.__esModule) return n2;
14111 var f2 = n2.default;
14112 if (typeof f2 == "function") {
14113 var a2 = function a22() {
14114 if (_instanceof(this, a22)) {
14115 return Reflect.construct(f2, arguments, this.constructor);
14116 }
14117 return f2.apply(this, arguments);
14118 };
14119 a2.prototype = f2.prototype;
14120 } else a2 = {};
14121 Object.defineProperty(a2, "__esModule", {
14122 value: true
14123 });
14124 Object.keys(n2).forEach(function(k) {
14125 var d = Object.getOwnPropertyDescriptor(n2, k);
14126 Object.defineProperty(a2, k, d.get ? d : {
14127 enumerable: true,
14128 get: function get() {
14129 return n2[k];
14130 }
14131 });
14132 });
14133 return a2;
14134 }
14135 var picocolors_browser = {
14136 exports: {}
14137 };
14138 var x = String;
14139 var create = function create() {
14140 return {
14141 isColorSupported: false,
14142 reset: x,
14143 bold: x,
14144 dim: x,
14145 italic: x,
14146 underline: x,
14147 inverse: x,
14148 hidden: x,
14149 strikethrough: x,
14150 black: x,
14151 red: x,
14152 green: x,
14153 yellow: x,
14154 blue: x,
14155 magenta: x,
14156 cyan: x,
14157 white: x,
14158 gray: x,
14159 bgBlack: x,
14160 bgRed: x,
14161 bgGreen: x,
14162 bgYellow: x,
14163 bgBlue: x,
14164 bgMagenta: x,
14165 bgCyan: x,
14166 bgWhite: x
14167 };
14168 };
14169 picocolors_browser.exports = create();
14170 picocolors_browser.exports.createColors = create;
14171 var picocolors_browserExports = picocolors_browser.exports;
14172 var __viteBrowserExternal = {};
14173 var __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
14174 __proto__: null,
14175 default: __viteBrowserExternal
14176 }, Symbol.toStringTag, {
14177 value: "Module"
14178 }));
14179 var require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
14180 var pico = picocolors_browserExports;
14181 var terminalHighlight$1 = require$$2;
14182 var CssSyntaxError$3 = /*#__PURE__*/ function(Error1) {
14183 _inherits(CssSyntaxError2, Error1);
14184 function CssSyntaxError2(message, line, column, source, file, plugin22) {
14185 var _this;
14186 _this = Error1.call(this, message) || this;
14187 _this.name = "CssSyntaxError";
14188 _this.reason = message;
14189 if (file) {
14190 _this.file = file;
14191 }
14192 if (source) {
14193 _this.source = source;
14194 }
14195 if (plugin22) {
14196 _this.plugin = plugin22;
14197 }
14198 if (typeof line !== "undefined" && typeof column !== "undefined") {
14199 if (typeof line === "number") {
14200 _this.line = line;
14201 _this.column = column;
14202 } else {
14203 _this.line = line.line;
14204 _this.column = line.column;
14205 _this.endLine = column.line;
14206 _this.endColumn = column.column;
14207 }
14208 }
14209 _this.setMessage();
14210 if (Error.captureStackTrace) {
14211 Error.captureStackTrace(_this, CssSyntaxError2);
14212 }
14213 return _this;
14214 }
14215 var _proto = CssSyntaxError2.prototype;
14216 _proto.setMessage = function setMessage() {
14217 this.message = this.plugin ? this.plugin + ": " : "";
14218 this.message += this.file ? this.file : "<css input>";
14219 if (typeof this.line !== "undefined") {
14220 this.message += ":" + this.line + ":" + this.column;
14221 }
14222 this.message += ": " + this.reason;
14223 };
14224 _proto.showSourceCode = function showSourceCode(color) {
14225 var _this = this;
14226 if (!this.source) return "";
14227 var css = this.source;
14228 if (color == null) color = pico.isColorSupported;
14229 if (terminalHighlight$1) {
14230 if (color) css = terminalHighlight$1(css);
14231 }
14232 var lines = css.split(/\r?\n/);
14233 var start = Math.max(this.line - 3, 0);
14234 var end = Math.min(this.line + 2, lines.length);
14235 var maxWidth = String(end).length;
14236 var mark, aside;
14237 if (color) {
14238 var _pico_createColors = pico.createColors(true), bold = _pico_createColors.bold, gray = _pico_createColors.gray, red = _pico_createColors.red;
14239 mark = function(text) {
14240 return bold(red(text));
14241 };
14242 aside = function(text) {
14243 return gray(text);
14244 };
14245 } else {
14246 mark = aside = function(str) {
14247 return str;
14248 };
14249 }
14250 return lines.slice(start, end).map(function(line, index2) {
14251 var number = start + 1 + index2;
14252 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
14253 if (number === _this.line) {
14254 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
14255 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
14256 }
14257 return " " + aside(gutter) + line;
14258 }).join("\n");
14259 };
14260 _proto.toString = function toString() {
14261 var code = this.showSourceCode();
14262 if (code) {
14263 code = "\n\n" + code + "\n";
14264 }
14265 return this.name + ": " + this.message + code;
14266 };
14267 return CssSyntaxError2;
14268 }(_wrap_native_super(Error));
14269 var cssSyntaxError = CssSyntaxError$3;
14270 CssSyntaxError$3.default = CssSyntaxError$3;
14271 var symbols = {};
14272 symbols.isClean = Symbol("isClean");
14273 symbols.my = Symbol("my");
14274 var DEFAULT_RAW = {
14275 after: "\n",
14276 beforeClose: "\n",
14277 beforeComment: "\n",
14278 beforeDecl: "\n",
14279 beforeOpen: " ",
14280 beforeRule: "\n",
14281 colon: ": ",
14282 commentLeft: " ",
14283 commentRight: " ",
14284 emptyBody: "",
14285 indent: " ",
14286 semicolon: false
14287 };
14288 function capitalize(str) {
14289 return str[0].toUpperCase() + str.slice(1);
14290 }
14291 var Stringifier$2 = /*#__PURE__*/ function() {
14292 function Stringifier2(builder) {
14293 this.builder = builder;
14294 }
14295 var _proto = Stringifier2.prototype;
14296 _proto.atrule = function atrule(node2, semicolon) {
14297 var name = "@" + node2.name;
14298 var params = node2.params ? this.rawValue(node2, "params") : "";
14299 if (typeof node2.raws.afterName !== "undefined") {
14300 name += node2.raws.afterName;
14301 } else if (params) {
14302 name += " ";
14303 }
14304 if (node2.nodes) {
14305 this.block(node2, name + params);
14306 } else {
14307 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
14308 this.builder(name + params + end, node2);
14309 }
14310 };
14311 _proto.beforeAfter = function beforeAfter(node2, detect) {
14312 var value;
14313 if (node2.type === "decl") {
14314 value = this.raw(node2, null, "beforeDecl");
14315 } else if (node2.type === "comment") {
14316 value = this.raw(node2, null, "beforeComment");
14317 } else if (detect === "before") {
14318 value = this.raw(node2, null, "beforeRule");
14319 } else {
14320 value = this.raw(node2, null, "beforeClose");
14321 }
14322 var buf = node2.parent;
14323 var depth = 0;
14324 while(buf && buf.type !== "root"){
14325 depth += 1;
14326 buf = buf.parent;
14327 }
14328 if (value.includes("\n")) {
14329 var indent = this.raw(node2, null, "indent");
14330 if (indent.length) {
14331 for(var step = 0; step < depth; step++)value += indent;
14332 }
14333 }
14334 return value;
14335 };
14336 _proto.block = function block(node2, start) {
14337 var between = this.raw(node2, "between", "beforeOpen");
14338 this.builder(start + between + "{", node2, "start");
14339 var after;
14340 if (node2.nodes && node2.nodes.length) {
14341 this.body(node2);
14342 after = this.raw(node2, "after");
14343 } else {
14344 after = this.raw(node2, "after", "emptyBody");
14345 }
14346 if (after) this.builder(after);
14347 this.builder("}", node2, "end");
14348 };
14349 _proto.body = function body(node2) {
14350 var last = node2.nodes.length - 1;
14351 while(last > 0){
14352 if (node2.nodes[last].type !== "comment") break;
14353 last -= 1;
14354 }
14355 var semicolon = this.raw(node2, "semicolon");
14356 for(var i2 = 0; i2 < node2.nodes.length; i2++){
14357 var child = node2.nodes[i2];
14358 var before = this.raw(child, "before");
14359 if (before) this.builder(before);
14360 this.stringify(child, last !== i2 || semicolon);
14361 }
14362 };
14363 _proto.comment = function comment(node2) {
14364 var left = this.raw(node2, "left", "commentLeft");
14365 var right = this.raw(node2, "right", "commentRight");
14366 this.builder("/*" + left + node2.text + right + "*/", node2);
14367 };
14368 _proto.decl = function decl(node2, semicolon) {
14369 var between = this.raw(node2, "between", "colon");
14370 var string = node2.prop + between + this.rawValue(node2, "value");
14371 if (node2.important) {
14372 string += node2.raws.important || " !important";
14373 }
14374 if (semicolon) string += ";";
14375 this.builder(string, node2);
14376 };
14377 _proto.document = function document1(node2) {
14378 this.body(node2);
14379 };
14380 _proto.raw = function raw(node2, own, detect) {
14381 var value;
14382 if (!detect) detect = own;
14383 if (own) {
14384 value = node2.raws[own];
14385 if (typeof value !== "undefined") return value;
14386 }
14387 var parent = node2.parent;
14388 if (detect === "before") {
14389 if (!parent || parent.type === "root" && parent.first === node2) {
14390 return "";
14391 }
14392 if (parent && parent.type === "document") {
14393 return "";
14394 }
14395 }
14396 if (!parent) return DEFAULT_RAW[detect];
14397 var root2 = node2.root();
14398 if (!root2.rawCache) root2.rawCache = {};
14399 if (typeof root2.rawCache[detect] !== "undefined") {
14400 return root2.rawCache[detect];
14401 }
14402 if (detect === "before" || detect === "after") {
14403 return this.beforeAfter(node2, detect);
14404 } else {
14405 var method = "raw" + capitalize(detect);
14406 if (this[method]) {
14407 value = this[method](root2, node2);
14408 } else {
14409 root2.walk(function(i2) {
14410 value = i2.raws[own];
14411 if (typeof value !== "undefined") return false;
14412 });
14413 }
14414 }
14415 if (typeof value === "undefined") value = DEFAULT_RAW[detect];
14416 root2.rawCache[detect] = value;
14417 return value;
14418 };
14419 _proto.rawBeforeClose = function rawBeforeClose(root2) {
14420 var value;
14421 root2.walk(function(i2) {
14422 if (i2.nodes && i2.nodes.length > 0) {
14423 if (typeof i2.raws.after !== "undefined") {
14424 value = i2.raws.after;
14425 if (value.includes("\n")) {
14426 value = value.replace(/[^\n]+$/, "");
14427 }
14428 return false;
14429 }
14430 }
14431 });
14432 if (value) value = value.replace(/\S/g, "");
14433 return value;
14434 };
14435 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
14436 var value;
14437 root2.walkComments(function(i2) {
14438 if (typeof i2.raws.before !== "undefined") {
14439 value = i2.raws.before;
14440 if (value.includes("\n")) {
14441 value = value.replace(/[^\n]+$/, "");
14442 }
14443 return false;
14444 }
14445 });
14446 if (typeof value === "undefined") {
14447 value = this.raw(node2, null, "beforeDecl");
14448 } else if (value) {
14449 value = value.replace(/\S/g, "");
14450 }
14451 return value;
14452 };
14453 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
14454 var value;
14455 root2.walkDecls(function(i2) {
14456 if (typeof i2.raws.before !== "undefined") {
14457 value = i2.raws.before;
14458 if (value.includes("\n")) {
14459 value = value.replace(/[^\n]+$/, "");
14460 }
14461 return false;
14462 }
14463 });
14464 if (typeof value === "undefined") {
14465 value = this.raw(node2, null, "beforeRule");
14466 } else if (value) {
14467 value = value.replace(/\S/g, "");
14468 }
14469 return value;
14470 };
14471 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
14472 var value;
14473 root2.walk(function(i2) {
14474 if (i2.type !== "decl") {
14475 value = i2.raws.between;
14476 if (typeof value !== "undefined") return false;
14477 }
14478 });
14479 return value;
14480 };
14481 _proto.rawBeforeRule = function rawBeforeRule(root2) {
14482 var value;
14483 root2.walk(function(i2) {
14484 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
14485 if (typeof i2.raws.before !== "undefined") {
14486 value = i2.raws.before;
14487 if (value.includes("\n")) {
14488 value = value.replace(/[^\n]+$/, "");
14489 }
14490 return false;
14491 }
14492 }
14493 });
14494 if (value) value = value.replace(/\S/g, "");
14495 return value;
14496 };
14497 _proto.rawColon = function rawColon(root2) {
14498 var value;
14499 root2.walkDecls(function(i2) {
14500 if (typeof i2.raws.between !== "undefined") {
14501 value = i2.raws.between.replace(/[^\s:]/g, "");
14502 return false;
14503 }
14504 });
14505 return value;
14506 };
14507 _proto.rawEmptyBody = function rawEmptyBody(root2) {
14508 var value;
14509 root2.walk(function(i2) {
14510 if (i2.nodes && i2.nodes.length === 0) {
14511 value = i2.raws.after;
14512 if (typeof value !== "undefined") return false;
14513 }
14514 });
14515 return value;
14516 };
14517 _proto.rawIndent = function rawIndent(root2) {
14518 if (root2.raws.indent) return root2.raws.indent;
14519 var value;
14520 root2.walk(function(i2) {
14521 var p = i2.parent;
14522 if (p && p !== root2 && p.parent && p.parent === root2) {
14523 if (typeof i2.raws.before !== "undefined") {
14524 var parts = i2.raws.before.split("\n");
14525 value = parts[parts.length - 1];
14526 value = value.replace(/\S/g, "");
14527 return false;
14528 }
14529 }
14530 });
14531 return value;
14532 };
14533 _proto.rawSemicolon = function rawSemicolon(root2) {
14534 var value;
14535 root2.walk(function(i2) {
14536 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
14537 value = i2.raws.semicolon;
14538 if (typeof value !== "undefined") return false;
14539 }
14540 });
14541 return value;
14542 };
14543 _proto.rawValue = function rawValue(node2, prop) {
14544 var value = node2[prop];
14545 var raw = node2.raws[prop];
14546 if (raw && raw.value === value) {
14547 return raw.raw;
14548 }
14549 return value;
14550 };
14551 _proto.root = function root(node2) {
14552 this.body(node2);
14553 if (node2.raws.after) this.builder(node2.raws.after);
14554 };
14555 _proto.rule = function rule(node2) {
14556 this.block(node2, this.rawValue(node2, "selector"));
14557 if (node2.raws.ownSemicolon) {
14558 this.builder(node2.raws.ownSemicolon, node2, "end");
14559 }
14560 };
14561 _proto.stringify = function stringify(node2, semicolon) {
14562 if (!this[node2.type]) {
14563 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
14564 }
14565 this[node2.type](node2, semicolon);
14566 };
14567 return Stringifier2;
14568 }();
14569 var stringifier = Stringifier$2;
14570 Stringifier$2.default = Stringifier$2;
14571 var Stringifier$1 = stringifier;
14572 function stringify$4(node2, builder) {
14573 var str = new Stringifier$1(builder);
14574 str.stringify(node2);
14575 }
14576 var stringify_1 = stringify$4;
14577 stringify$4.default = stringify$4;
14578 var isClean$2 = symbols.isClean, my$2 = symbols.my;
14579 var CssSyntaxError$2 = cssSyntaxError;
14580 var Stringifier22 = stringifier;
14581 var stringify$3 = stringify_1;
14582 function cloneNode(obj, parent) {
14583 var cloned = new obj.constructor();
14584 for(var i2 in obj){
14585 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
14586 continue;
14587 }
14588 if (i2 === "proxyCache") continue;
14589 var value = obj[i2];
14590 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
14591 if (i2 === "parent" && type === "object") {
14592 if (parent) cloned[i2] = parent;
14593 } else if (i2 === "source") {
14594 cloned[i2] = value;
14595 } else if (Array.isArray(value)) {
14596 cloned[i2] = value.map(function(j) {
14597 return cloneNode(j, cloned);
14598 });
14599 } else {
14600 if (type === "object" && value !== null) value = cloneNode(value);
14601 cloned[i2] = value;
14602 }
14603 }
14604 return cloned;
14605 }
14606 var Node$4 = /*#__PURE__*/ function() {
14607 function Node3(defaults) {
14608 if (defaults === void 0) defaults = {};
14609 this.raws = {};
14610 this[isClean$2] = false;
14611 this[my$2] = true;
14612 for(var name in defaults){
14613 if (name === "nodes") {
14614 this.nodes = [];
14615 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
14616 var node2 = _step.value;
14617 if (typeof node2.clone === "function") {
14618 this.append(node2.clone());
14619 } else {
14620 this.append(node2);
14621 }
14622 }
14623 } else {
14624 this[name] = defaults[name];
14625 }
14626 }
14627 }
14628 var _proto = Node3.prototype;
14629 _proto.addToError = function addToError(error) {
14630 error.postcssNode = this;
14631 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
14632 var s2 = this.source;
14633 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
14634 }
14635 return error;
14636 };
14637 _proto.after = function after(add) {
14638 this.parent.insertAfter(this, add);
14639 return this;
14640 };
14641 _proto.assign = function assign(overrides) {
14642 if (overrides === void 0) overrides = {};
14643 for(var name in overrides){
14644 this[name] = overrides[name];
14645 }
14646 return this;
14647 };
14648 _proto.before = function before(add) {
14649 this.parent.insertBefore(this, add);
14650 return this;
14651 };
14652 _proto.cleanRaws = function cleanRaws(keepBetween) {
14653 delete this.raws.before;
14654 delete this.raws.after;
14655 if (!keepBetween) delete this.raws.between;
14656 };
14657 _proto.clone = function clone(overrides) {
14658 if (overrides === void 0) overrides = {};
14659 var cloned = cloneNode(this);
14660 for(var name in overrides){
14661 cloned[name] = overrides[name];
14662 }
14663 return cloned;
14664 };
14665 _proto.cloneAfter = function cloneAfter(overrides) {
14666 if (overrides === void 0) overrides = {};
14667 var cloned = this.clone(overrides);
14668 this.parent.insertAfter(this, cloned);
14669 return cloned;
14670 };
14671 _proto.cloneBefore = function cloneBefore(overrides) {
14672 if (overrides === void 0) overrides = {};
14673 var cloned = this.clone(overrides);
14674 this.parent.insertBefore(this, cloned);
14675 return cloned;
14676 };
14677 _proto.error = function error(message, opts) {
14678 if (opts === void 0) opts = {};
14679 if (this.source) {
14680 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
14681 return this.source.input.error(message, {
14682 column: start.column,
14683 line: start.line
14684 }, {
14685 column: end.column,
14686 line: end.line
14687 }, opts);
14688 }
14689 return new CssSyntaxError$2(message);
14690 };
14691 _proto.getProxyProcessor = function getProxyProcessor() {
14692 return {
14693 get: function get(node2, prop) {
14694 if (prop === "proxyOf") {
14695 return node2;
14696 } else if (prop === "root") {
14697 return function() {
14698 return node2.root().toProxy();
14699 };
14700 } else {
14701 return node2[prop];
14702 }
14703 },
14704 set: function set(node2, prop, value) {
14705 if (node2[prop] === value) return true;
14706 node2[prop] = value;
14707 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
14708 node2.markDirty();
14709 }
14710 return true;
14711 }
14712 };
14713 };
14714 _proto.markDirty = function markDirty() {
14715 if (this[isClean$2]) {
14716 this[isClean$2] = false;
14717 var next = this;
14718 while(next = next.parent){
14719 next[isClean$2] = false;
14720 }
14721 }
14722 };
14723 _proto.next = function next() {
14724 if (!this.parent) return void 0;
14725 var index2 = this.parent.index(this);
14726 return this.parent.nodes[index2 + 1];
14727 };
14728 _proto.positionBy = function positionBy(opts, stringRepresentation) {
14729 var pos = this.source.start;
14730 if (opts.index) {
14731 pos = this.positionInside(opts.index, stringRepresentation);
14732 } else if (opts.word) {
14733 stringRepresentation = this.toString();
14734 var index2 = stringRepresentation.indexOf(opts.word);
14735 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
14736 }
14737 return pos;
14738 };
14739 _proto.positionInside = function positionInside(index2, stringRepresentation) {
14740 var string = stringRepresentation || this.toString();
14741 var column = this.source.start.column;
14742 var line = this.source.start.line;
14743 for(var i2 = 0; i2 < index2; i2++){
14744 if (string[i2] === "\n") {
14745 column = 1;
14746 line += 1;
14747 } else {
14748 column += 1;
14749 }
14750 }
14751 return {
14752 column: column,
14753 line: line
14754 };
14755 };
14756 _proto.prev = function prev() {
14757 if (!this.parent) return void 0;
14758 var index2 = this.parent.index(this);
14759 return this.parent.nodes[index2 - 1];
14760 };
14761 _proto.rangeBy = function rangeBy(opts) {
14762 var start = {
14763 column: this.source.start.column,
14764 line: this.source.start.line
14765 };
14766 var end = this.source.end ? {
14767 column: this.source.end.column + 1,
14768 line: this.source.end.line
14769 } : {
14770 column: start.column + 1,
14771 line: start.line
14772 };
14773 if (opts.word) {
14774 var stringRepresentation = this.toString();
14775 var index2 = stringRepresentation.indexOf(opts.word);
14776 if (index2 !== -1) {
14777 start = this.positionInside(index2, stringRepresentation);
14778 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
14779 }
14780 } else {
14781 if (opts.start) {
14782 start = {
14783 column: opts.start.column,
14784 line: opts.start.line
14785 };
14786 } else if (opts.index) {
14787 start = this.positionInside(opts.index);
14788 }
14789 if (opts.end) {
14790 end = {
14791 column: opts.end.column,
14792 line: opts.end.line
14793 };
14794 } else if (typeof opts.endIndex === "number") {
14795 end = this.positionInside(opts.endIndex);
14796 } else if (opts.index) {
14797 end = this.positionInside(opts.index + 1);
14798 }
14799 }
14800 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
14801 end = {
14802 column: start.column + 1,
14803 line: start.line
14804 };
14805 }
14806 return {
14807 end: end,
14808 start: start
14809 };
14810 };
14811 _proto.raw = function raw(prop, defaultType) {
14812 var str = new Stringifier22();
14813 return str.raw(this, prop, defaultType);
14814 };
14815 _proto.remove = function remove() {
14816 if (this.parent) {
14817 this.parent.removeChild(this);
14818 }
14819 this.parent = void 0;
14820 return this;
14821 };
14822 _proto.replaceWith = function replaceWith() {
14823 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
14824 nodes[_key] = arguments[_key];
14825 }
14826 if (this.parent) {
14827 var bookmark = this;
14828 var foundSelf = false;
14829 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
14830 var node2 = _step.value;
14831 if (node2 === this) {
14832 foundSelf = true;
14833 } else if (foundSelf) {
14834 this.parent.insertAfter(bookmark, node2);
14835 bookmark = node2;
14836 } else {
14837 this.parent.insertBefore(bookmark, node2);
14838 }
14839 }
14840 if (!foundSelf) {
14841 this.remove();
14842 }
14843 }
14844 return this;
14845 };
14846 _proto.root = function root() {
14847 var result2 = this;
14848 while(result2.parent && result2.parent.type !== "document"){
14849 result2 = result2.parent;
14850 }
14851 return result2;
14852 };
14853 _proto.toJSON = function toJSON(_, inputs) {
14854 var fixed = {};
14855 var emitInputs = inputs == null;
14856 inputs = inputs || /* @__PURE__ */ new Map();
14857 var inputsNextIndex = 0;
14858 for(var name in this){
14859 if (!Object.prototype.hasOwnProperty.call(this, name)) {
14860 continue;
14861 }
14862 if (name === "parent" || name === "proxyCache") continue;
14863 var value = this[name];
14864 if (Array.isArray(value)) {
14865 fixed[name] = value.map(function(i2) {
14866 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
14867 return i2.toJSON(null, inputs);
14868 } else {
14869 return i2;
14870 }
14871 });
14872 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
14873 fixed[name] = value.toJSON(null, inputs);
14874 } else if (name === "source") {
14875 var inputId = inputs.get(value.input);
14876 if (inputId == null) {
14877 inputId = inputsNextIndex;
14878 inputs.set(value.input, inputsNextIndex);
14879 inputsNextIndex++;
14880 }
14881 fixed[name] = {
14882 end: value.end,
14883 inputId: inputId,
14884 start: value.start
14885 };
14886 } else {
14887 fixed[name] = value;
14888 }
14889 }
14890 if (emitInputs) {
14891 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
14892 return input2.toJSON();
14893 });
14894 }
14895 return fixed;
14896 };
14897 _proto.toProxy = function toProxy() {
14898 if (!this.proxyCache) {
14899 this.proxyCache = new Proxy(this, this.getProxyProcessor());
14900 }
14901 return this.proxyCache;
14902 };
14903 _proto.toString = function toString(stringifier2) {
14904 if (stringifier2 === void 0) stringifier2 = stringify$3;
14905 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
14906 var result2 = "";
14907 stringifier2(this, function(i2) {
14908 result2 += i2;
14909 });
14910 return result2;
14911 };
14912 _proto.warn = function warn(result2, text, opts) {
14913 var data = {
14914 node: this
14915 };
14916 for(var i2 in opts)data[i2] = opts[i2];
14917 return result2.warn(text, data);
14918 };
14919 _create_class(Node3, [
14920 {
14921 key: "proxyOf",
14922 get: function get() {
14923 return this;
14924 }
14925 }
14926 ]);
14927 return Node3;
14928 }();
14929 var node = Node$4;
14930 Node$4.default = Node$4;
14931 var Node$3 = node;
14932 var Declaration$4 = /*#__PURE__*/ function(Node$3) {
14933 _inherits(Declaration2, Node$3);
14934 function Declaration2(defaults) {
14935 var _this;
14936 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
14937 defaults = _extends({}, defaults, {
14938 value: String(defaults.value)
14939 });
14940 }
14941 _this = Node$3.call(this, defaults) || this;
14942 _this.type = "decl";
14943 return _this;
14944 }
14945 _create_class(Declaration2, [
14946 {
14947 key: "variable",
14948 get: function get() {
14949 return this.prop.startsWith("--") || this.prop[0] === "$";
14950 }
14951 }
14952 ]);
14953 return Declaration2;
14954 }(Node$3);
14955 var declaration = Declaration$4;
14956 Declaration$4.default = Declaration$4;
14957 var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
14958 var nanoid$1 = function(size) {
14959 if (size === void 0) size = 21;
14960 var id = "";
14961 var i2 = size;
14962 while(i2--){
14963 id += urlAlphabet[Math.random() * 64 | 0];
14964 }
14965 return id;
14966 };
14967 var nonSecure = {
14968 nanoid: nanoid$1};
14969 var SourceMapConsumer$2 = require$$2.SourceMapConsumer, SourceMapGenerator$2 = require$$2.SourceMapGenerator;
14970 var existsSync = require$$2.existsSync, readFileSync = require$$2.readFileSync;
14971 var dirname$1 = require$$2.dirname, join = require$$2.join;
14972 function fromBase64(str) {
14973 if (Buffer) {
14974 return Buffer.from(str, "base64").toString();
14975 } else {
14976 return window.atob(str);
14977 }
14978 }
14979 var PreviousMap$2 = /*#__PURE__*/ function() {
14980 function PreviousMap2(css, opts) {
14981 if (opts.map === false) return;
14982 this.loadAnnotation(css);
14983 this.inline = this.startWith(this.annotation, "data:");
14984 var prev = opts.map ? opts.map.prev : void 0;
14985 var text = this.loadMap(opts.from, prev);
14986 if (!this.mapFile && opts.from) {
14987 this.mapFile = opts.from;
14988 }
14989 if (this.mapFile) this.root = dirname$1(this.mapFile);
14990 if (text) this.text = text;
14991 }
14992 var _proto = PreviousMap2.prototype;
14993 _proto.consumer = function consumer() {
14994 if (!this.consumerCache) {
14995 this.consumerCache = new SourceMapConsumer$2(this.text);
14996 }
14997 return this.consumerCache;
14998 };
14999 _proto.decodeInline = function decodeInline(text) {
15000 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
15001 var baseUri = /^data:application\/json;base64,/;
15002 var charsetUri = /^data:application\/json;charset=utf-?8,/;
15003 var uri = /^data:application\/json,/;
15004 if (charsetUri.test(text) || uri.test(text)) {
15005 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
15006 }
15007 if (baseCharsetUri.test(text) || baseUri.test(text)) {
15008 return fromBase64(text.substr(RegExp.lastMatch.length));
15009 }
15010 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
15011 throw new Error("Unsupported source map encoding " + encoding);
15012 };
15013 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
15014 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
15015 };
15016 _proto.isMap = function isMap(map) {
15017 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
15018 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
15019 };
15020 _proto.loadAnnotation = function loadAnnotation(css) {
15021 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
15022 if (!comments) return;
15023 var start = css.lastIndexOf(comments.pop());
15024 var end = css.indexOf("*/", start);
15025 if (start > -1 && end > -1) {
15026 this.annotation = this.getAnnotationURL(css.substring(start, end));
15027 }
15028 };
15029 _proto.loadFile = function loadFile(path) {
15030 this.root = dirname$1(path);
15031 if (existsSync(path)) {
15032 this.mapFile = path;
15033 return readFileSync(path, "utf-8").toString().trim();
15034 }
15035 };
15036 _proto.loadMap = function loadMap(file, prev) {
15037 if (prev === false) return false;
15038 if (prev) {
15039 if (typeof prev === "string") {
15040 return prev;
15041 } else if (typeof prev === "function") {
15042 var prevPath = prev(file);
15043 if (prevPath) {
15044 var map = this.loadFile(prevPath);
15045 if (!map) {
15046 throw new Error("Unable to load previous source map: " + prevPath.toString());
15047 }
15048 return map;
15049 }
15050 } else if (_instanceof(prev, SourceMapConsumer$2)) {
15051 return SourceMapGenerator$2.fromSourceMap(prev).toString();
15052 } else if (_instanceof(prev, SourceMapGenerator$2)) {
15053 return prev.toString();
15054 } else if (this.isMap(prev)) {
15055 return JSON.stringify(prev);
15056 } else {
15057 throw new Error("Unsupported previous source map format: " + prev.toString());
15058 }
15059 } else if (this.inline) {
15060 return this.decodeInline(this.annotation);
15061 } else if (this.annotation) {
15062 var map1 = this.annotation;
15063 if (file) map1 = join(dirname$1(file), map1);
15064 return this.loadFile(map1);
15065 }
15066 };
15067 _proto.startWith = function startWith(string, start) {
15068 if (!string) return false;
15069 return string.substr(0, start.length) === start;
15070 };
15071 _proto.withContent = function withContent() {
15072 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
15073 };
15074 return PreviousMap2;
15075 }();
15076 var previousMap = PreviousMap$2;
15077 PreviousMap$2.default = PreviousMap$2;
15078 var SourceMapConsumer$1 = require$$2.SourceMapConsumer, SourceMapGenerator$1 = require$$2.SourceMapGenerator;
15079 var fileURLToPath = require$$2.fileURLToPath, pathToFileURL$1 = require$$2.pathToFileURL;
15080 var isAbsolute = require$$2.isAbsolute, resolve$1 = require$$2.resolve;
15081 var nanoid = nonSecure.nanoid;
15082 var terminalHighlight = require$$2;
15083 var CssSyntaxError$1 = cssSyntaxError;
15084 var PreviousMap$1 = previousMap;
15085 var fromOffsetCache = Symbol("fromOffsetCache");
15086 var sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
15087 var pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
15088 var Input$4 = /*#__PURE__*/ function() {
15089 function Input2(css, opts) {
15090 if (opts === void 0) opts = {};
15091 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
15092 throw new Error("PostCSS received " + css + " instead of CSS string");
15093 }
15094 this.css = css.toString();
15095 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
15096 this.hasBOM = true;
15097 this.css = this.css.slice(1);
15098 } else {
15099 this.hasBOM = false;
15100 }
15101 if (opts.from) {
15102 if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
15103 this.file = opts.from;
15104 } else {
15105 this.file = resolve$1(opts.from);
15106 }
15107 }
15108 if (pathAvailable$1 && sourceMapAvailable$1) {
15109 var map = new PreviousMap$1(this.css, opts);
15110 if (map.text) {
15111 this.map = map;
15112 var file = map.consumer().file;
15113 if (!this.file && file) this.file = this.mapResolve(file);
15114 }
15115 }
15116 if (!this.file) {
15117 this.id = "<input css " + nanoid(6) + ">";
15118 }
15119 if (this.map) this.map.file = this.from;
15120 }
15121 var _proto = Input2.prototype;
15122 _proto.error = function error(message, line, column, opts) {
15123 if (opts === void 0) opts = {};
15124 var result2, endLine, endColumn;
15125 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
15126 var start = line;
15127 var end = column;
15128 if (typeof start.offset === "number") {
15129 var pos = this.fromOffset(start.offset);
15130 line = pos.line;
15131 column = pos.col;
15132 } else {
15133 line = start.line;
15134 column = start.column;
15135 }
15136 if (typeof end.offset === "number") {
15137 var pos1 = this.fromOffset(end.offset);
15138 endLine = pos1.line;
15139 endColumn = pos1.col;
15140 } else {
15141 endLine = end.line;
15142 endColumn = end.column;
15143 }
15144 } else if (!column) {
15145 var pos2 = this.fromOffset(line);
15146 line = pos2.line;
15147 column = pos2.col;
15148 }
15149 var origin = this.origin(line, column, endLine, endColumn);
15150 if (origin) {
15151 result2 = new CssSyntaxError$1(message, origin.endLine === void 0 ? origin.line : {
15152 column: origin.column,
15153 line: origin.line
15154 }, origin.endLine === void 0 ? origin.column : {
15155 column: origin.endColumn,
15156 line: origin.endLine
15157 }, origin.source, origin.file, opts.plugin);
15158 } else {
15159 result2 = new CssSyntaxError$1(message, endLine === void 0 ? line : {
15160 column: column,
15161 line: line
15162 }, endLine === void 0 ? column : {
15163 column: endColumn,
15164 line: endLine
15165 }, this.css, this.file, opts.plugin);
15166 }
15167 result2.input = {
15168 column: column,
15169 endColumn: endColumn,
15170 endLine: endLine,
15171 line: line,
15172 source: this.css
15173 };
15174 if (this.file) {
15175 if (pathToFileURL$1) {
15176 result2.input.url = pathToFileURL$1(this.file).toString();
15177 }
15178 result2.input.file = this.file;
15179 }
15180 return result2;
15181 };
15182 _proto.fromOffset = function fromOffset(offset) {
15183 var lastLine, lineToIndex;
15184 if (!this[fromOffsetCache]) {
15185 var lines = this.css.split("\n");
15186 lineToIndex = new Array(lines.length);
15187 var prevIndex = 0;
15188 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
15189 lineToIndex[i2] = prevIndex;
15190 prevIndex += lines[i2].length + 1;
15191 }
15192 this[fromOffsetCache] = lineToIndex;
15193 } else {
15194 lineToIndex = this[fromOffsetCache];
15195 }
15196 lastLine = lineToIndex[lineToIndex.length - 1];
15197 var min = 0;
15198 if (offset >= lastLine) {
15199 min = lineToIndex.length - 1;
15200 } else {
15201 var max = lineToIndex.length - 2;
15202 var mid;
15203 while(min < max){
15204 mid = min + (max - min >> 1);
15205 if (offset < lineToIndex[mid]) {
15206 max = mid - 1;
15207 } else if (offset >= lineToIndex[mid + 1]) {
15208 min = mid + 1;
15209 } else {
15210 min = mid;
15211 break;
15212 }
15213 }
15214 }
15215 return {
15216 col: offset - lineToIndex[min] + 1,
15217 line: min + 1
15218 };
15219 };
15220 _proto.mapResolve = function mapResolve(file) {
15221 if (/^\w+:\/\//.test(file)) {
15222 return file;
15223 }
15224 return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
15225 };
15226 _proto.origin = function origin(line, column, endLine, endColumn) {
15227 if (!this.map) return false;
15228 var consumer = this.map.consumer();
15229 var from = consumer.originalPositionFor({
15230 column: column,
15231 line: line
15232 });
15233 if (!from.source) return false;
15234 var to;
15235 if (typeof endLine === "number") {
15236 to = consumer.originalPositionFor({
15237 column: endColumn,
15238 line: endLine
15239 });
15240 }
15241 var fromUrl;
15242 if (isAbsolute(from.source)) {
15243 fromUrl = pathToFileURL$1(from.source);
15244 } else {
15245 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile));
15246 }
15247 var result2 = {
15248 column: from.column,
15249 endColumn: to && to.column,
15250 endLine: to && to.line,
15251 line: from.line,
15252 url: fromUrl.toString()
15253 };
15254 if (fromUrl.protocol === "file:") {
15255 if (fileURLToPath) {
15256 result2.file = fileURLToPath(fromUrl);
15257 } else {
15258 throw new Error("file: protocol is not available in this PostCSS build");
15259 }
15260 }
15261 var source = consumer.sourceContentFor(from.source);
15262 if (source) result2.source = source;
15263 return result2;
15264 };
15265 _proto.toJSON = function toJSON() {
15266 var json = {};
15267 for(var _i = 0, _iter = [
15268 "hasBOM",
15269 "css",
15270 "file",
15271 "id"
15272 ]; _i < _iter.length; _i++){
15273 var name = _iter[_i];
15274 if (this[name] != null) {
15275 json[name] = this[name];
15276 }
15277 }
15278 if (this.map) {
15279 json.map = _extends({}, this.map);
15280 if (json.map.consumerCache) {
15281 json.map.consumerCache = void 0;
15282 }
15283 }
15284 return json;
15285 };
15286 _create_class(Input2, [
15287 {
15288 key: "from",
15289 get: function get() {
15290 return this.file || this.id;
15291 }
15292 }
15293 ]);
15294 return Input2;
15295 }();
15296 var input = Input$4;
15297 Input$4.default = Input$4;
15298 if (terminalHighlight && terminalHighlight.registerInput) {
15299 terminalHighlight.registerInput(Input$4);
15300 }
15301 var SourceMapConsumer = require$$2.SourceMapConsumer, SourceMapGenerator = require$$2.SourceMapGenerator;
15302 var dirname = require$$2.dirname, relative = require$$2.relative, resolve$3 = require$$2.resolve, sep = require$$2.sep;
15303 var pathToFileURL = require$$2.pathToFileURL;
15304 var Input$3 = input;
15305 var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
15306 var pathAvailable = Boolean(dirname && resolve$3 && relative && sep);
15307 var MapGenerator$2 = /*#__PURE__*/ function() {
15308 function MapGenerator2(stringify2, root2, opts, cssString) {
15309 this.stringify = stringify2;
15310 this.mapOpts = opts.map || {};
15311 this.root = root2;
15312 this.opts = opts;
15313 this.css = cssString;
15314 this.originalCSS = cssString;
15315 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
15316 this.memoizedFileURLs = /* @__PURE__ */ new Map();
15317 this.memoizedPaths = /* @__PURE__ */ new Map();
15318 this.memoizedURLs = /* @__PURE__ */ new Map();
15319 }
15320 var _proto = MapGenerator2.prototype;
15321 _proto.addAnnotation = function addAnnotation() {
15322 var content;
15323 if (this.isInline()) {
15324 content = "data:application/json;base64," + this.toBase64(this.map.toString());
15325 } else if (typeof this.mapOpts.annotation === "string") {
15326 content = this.mapOpts.annotation;
15327 } else if (typeof this.mapOpts.annotation === "function") {
15328 content = this.mapOpts.annotation(this.opts.to, this.root);
15329 } else {
15330 content = this.outputFile() + ".map";
15331 }
15332 var eol = "\n";
15333 if (this.css.includes("\r\n")) eol = "\r\n";
15334 this.css += eol + "/*# sourceMappingURL=" + content + " */";
15335 };
15336 _proto.applyPrevMaps = function applyPrevMaps() {
15337 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
15338 var prev = _step.value;
15339 var from = this.toUrl(this.path(prev.file));
15340 var root2 = prev.root || dirname(prev.file);
15341 var map = void 0;
15342 if (this.mapOpts.sourcesContent === false) {
15343 map = new SourceMapConsumer(prev.text);
15344 if (map.sourcesContent) {
15345 map.sourcesContent = null;
15346 }
15347 } else {
15348 map = prev.consumer();
15349 }
15350 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
15351 }
15352 };
15353 _proto.clearAnnotation = function clearAnnotation() {
15354 if (this.mapOpts.annotation === false) return;
15355 if (this.root) {
15356 var node2;
15357 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
15358 node2 = this.root.nodes[i2];
15359 if (node2.type !== "comment") continue;
15360 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
15361 this.root.removeChild(i2);
15362 }
15363 }
15364 } else if (this.css) {
15365 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
15366 }
15367 };
15368 _proto.generate = function generate() {
15369 this.clearAnnotation();
15370 if (pathAvailable && sourceMapAvailable && this.isMap()) {
15371 return this.generateMap();
15372 } else {
15373 var result2 = "";
15374 this.stringify(this.root, function(i2) {
15375 result2 += i2;
15376 });
15377 return [
15378 result2
15379 ];
15380 }
15381 };
15382 _proto.generateMap = function generateMap() {
15383 if (this.root) {
15384 this.generateString();
15385 } else if (this.previous().length === 1) {
15386 var prev = this.previous()[0].consumer();
15387 prev.file = this.outputFile();
15388 this.map = SourceMapGenerator.fromSourceMap(prev, {
15389 ignoreInvalidMapping: true
15390 });
15391 } else {
15392 this.map = new SourceMapGenerator({
15393 file: this.outputFile(),
15394 ignoreInvalidMapping: true
15395 });
15396 this.map.addMapping({
15397 generated: {
15398 column: 0,
15399 line: 1
15400 },
15401 original: {
15402 column: 0,
15403 line: 1
15404 },
15405 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
15406 });
15407 }
15408 if (this.isSourcesContent()) this.setSourcesContent();
15409 if (this.root && this.previous().length > 0) this.applyPrevMaps();
15410 if (this.isAnnotation()) this.addAnnotation();
15411 if (this.isInline()) {
15412 return [
15413 this.css
15414 ];
15415 } else {
15416 return [
15417 this.css,
15418 this.map
15419 ];
15420 }
15421 };
15422 _proto.generateString = function generateString() {
15423 var _this = this;
15424 this.css = "";
15425 this.map = new SourceMapGenerator({
15426 file: this.outputFile(),
15427 ignoreInvalidMapping: true
15428 });
15429 var line = 1;
15430 var column = 1;
15431 var noSource = "<no source>";
15432 var mapping = {
15433 generated: {
15434 column: 0,
15435 line: 0
15436 },
15437 original: {
15438 column: 0,
15439 line: 0
15440 },
15441 source: ""
15442 };
15443 var lines, last;
15444 this.stringify(this.root, function(str, node2, type) {
15445 _this.css += str;
15446 if (node2 && type !== "end") {
15447 mapping.generated.line = line;
15448 mapping.generated.column = column - 1;
15449 if (node2.source && node2.source.start) {
15450 mapping.source = _this.sourcePath(node2);
15451 mapping.original.line = node2.source.start.line;
15452 mapping.original.column = node2.source.start.column - 1;
15453 _this.map.addMapping(mapping);
15454 } else {
15455 mapping.source = noSource;
15456 mapping.original.line = 1;
15457 mapping.original.column = 0;
15458 _this.map.addMapping(mapping);
15459 }
15460 }
15461 lines = str.match(/\n/g);
15462 if (lines) {
15463 line += lines.length;
15464 last = str.lastIndexOf("\n");
15465 column = str.length - last;
15466 } else {
15467 column += str.length;
15468 }
15469 if (node2 && type !== "start") {
15470 var p = node2.parent || {
15471 raws: {}
15472 };
15473 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
15474 if (!childless || node2 !== p.last || p.raws.semicolon) {
15475 if (node2.source && node2.source.end) {
15476 mapping.source = _this.sourcePath(node2);
15477 mapping.original.line = node2.source.end.line;
15478 mapping.original.column = node2.source.end.column - 1;
15479 mapping.generated.line = line;
15480 mapping.generated.column = column - 2;
15481 _this.map.addMapping(mapping);
15482 } else {
15483 mapping.source = noSource;
15484 mapping.original.line = 1;
15485 mapping.original.column = 0;
15486 mapping.generated.line = line;
15487 mapping.generated.column = column - 1;
15488 _this.map.addMapping(mapping);
15489 }
15490 }
15491 }
15492 });
15493 };
15494 _proto.isAnnotation = function isAnnotation() {
15495 if (this.isInline()) {
15496 return true;
15497 }
15498 if (typeof this.mapOpts.annotation !== "undefined") {
15499 return this.mapOpts.annotation;
15500 }
15501 if (this.previous().length) {
15502 return this.previous().some(function(i2) {
15503 return i2.annotation;
15504 });
15505 }
15506 return true;
15507 };
15508 _proto.isInline = function isInline() {
15509 if (typeof this.mapOpts.inline !== "undefined") {
15510 return this.mapOpts.inline;
15511 }
15512 var annotation = this.mapOpts.annotation;
15513 if (typeof annotation !== "undefined" && annotation !== true) {
15514 return false;
15515 }
15516 if (this.previous().length) {
15517 return this.previous().some(function(i2) {
15518 return i2.inline;
15519 });
15520 }
15521 return true;
15522 };
15523 _proto.isMap = function isMap() {
15524 if (typeof this.opts.map !== "undefined") {
15525 return !!this.opts.map;
15526 }
15527 return this.previous().length > 0;
15528 };
15529 _proto.isSourcesContent = function isSourcesContent() {
15530 if (typeof this.mapOpts.sourcesContent !== "undefined") {
15531 return this.mapOpts.sourcesContent;
15532 }
15533 if (this.previous().length) {
15534 return this.previous().some(function(i2) {
15535 return i2.withContent();
15536 });
15537 }
15538 return true;
15539 };
15540 _proto.outputFile = function outputFile() {
15541 if (this.opts.to) {
15542 return this.path(this.opts.to);
15543 } else if (this.opts.from) {
15544 return this.path(this.opts.from);
15545 } else {
15546 return "to.css";
15547 }
15548 };
15549 _proto.path = function path(file) {
15550 if (this.mapOpts.absolute) return file;
15551 if (file.charCodeAt(0) === 60) return file;
15552 if (/^\w+:\/\//.test(file)) return file;
15553 var cached = this.memoizedPaths.get(file);
15554 if (cached) return cached;
15555 var from = this.opts.to ? dirname(this.opts.to) : ".";
15556 if (typeof this.mapOpts.annotation === "string") {
15557 from = dirname(resolve$3(from, this.mapOpts.annotation));
15558 }
15559 var path = relative(from, file);
15560 this.memoizedPaths.set(file, path);
15561 return path;
15562 };
15563 _proto.previous = function previous() {
15564 var _this = this;
15565 if (!this.previousMaps) {
15566 this.previousMaps = [];
15567 if (this.root) {
15568 this.root.walk(function(node2) {
15569 if (node2.source && node2.source.input.map) {
15570 var map = node2.source.input.map;
15571 if (!_this.previousMaps.includes(map)) {
15572 _this.previousMaps.push(map);
15573 }
15574 }
15575 });
15576 } else {
15577 var input2 = new Input$3(this.originalCSS, this.opts);
15578 if (input2.map) this.previousMaps.push(input2.map);
15579 }
15580 }
15581 return this.previousMaps;
15582 };
15583 _proto.setSourcesContent = function setSourcesContent() {
15584 var _this = this;
15585 var already = {};
15586 if (this.root) {
15587 this.root.walk(function(node2) {
15588 if (node2.source) {
15589 var from = node2.source.input.from;
15590 if (from && !already[from]) {
15591 already[from] = true;
15592 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
15593 _this.map.setSourceContent(fromUrl, node2.source.input.css);
15594 }
15595 }
15596 });
15597 } else if (this.css) {
15598 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
15599 this.map.setSourceContent(from, this.css);
15600 }
15601 };
15602 _proto.sourcePath = function sourcePath(node2) {
15603 if (this.mapOpts.from) {
15604 return this.toUrl(this.mapOpts.from);
15605 } else if (this.usesFileUrls) {
15606 return this.toFileUrl(node2.source.input.from);
15607 } else {
15608 return this.toUrl(this.path(node2.source.input.from));
15609 }
15610 };
15611 _proto.toBase64 = function toBase64(str) {
15612 if (Buffer) {
15613 return Buffer.from(str).toString("base64");
15614 } else {
15615 return window.btoa(unescape(encodeURIComponent(str)));
15616 }
15617 };
15618 _proto.toFileUrl = function toFileUrl(path) {
15619 var cached = this.memoizedFileURLs.get(path);
15620 if (cached) return cached;
15621 if (pathToFileURL) {
15622 var fileURL = pathToFileURL(path).toString();
15623 this.memoizedFileURLs.set(path, fileURL);
15624 return fileURL;
15625 } else {
15626 throw new Error("`map.absolute` option is not available in this PostCSS build");
15627 }
15628 };
15629 _proto.toUrl = function toUrl(path) {
15630 var cached = this.memoizedURLs.get(path);
15631 if (cached) return cached;
15632 if (sep === "\\") {
15633 path = path.replace(/\\/g, "/");
15634 }
15635 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
15636 this.memoizedURLs.set(path, url);
15637 return url;
15638 };
15639 return MapGenerator2;
15640 }();
15641 var mapGenerator = MapGenerator$2;
15642 var Node$2 = node;
15643 var Comment$4 = /*#__PURE__*/ function(Node$2) {
15644 _inherits(Comment2, Node$2);
15645 function Comment2(defaults) {
15646 var _this;
15647 _this = Node$2.call(this, defaults) || this;
15648 _this.type = "comment";
15649 return _this;
15650 }
15651 return Comment2;
15652 }(Node$2);
15653 var comment = Comment$4;
15654 Comment$4.default = Comment$4;
15655 var isClean$1 = symbols.isClean, my$1 = symbols.my;
15656 var Declaration$3 = declaration;
15657 var Comment$3 = comment;
15658 var Node$1 = node;
15659 var parse$4, Rule$4, AtRule$4, Root$6;
15660 function cleanSource(nodes) {
15661 return nodes.map(function(i2) {
15662 if (i2.nodes) i2.nodes = cleanSource(i2.nodes);
15663 delete i2.source;
15664 return i2;
15665 });
15666 }
15667 function markDirtyUp(node2) {
15668 node2[isClean$1] = false;
15669 if (node2.proxyOf.nodes) {
15670 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
15671 var i2 = _step.value;
15672 markDirtyUp(i2);
15673 }
15674 }
15675 }
15676 var Container$7 = /*#__PURE__*/ function(Node$1) {
15677 _inherits(Container2, Node$1);
15678 function Container2() {
15679 return Node$1.apply(this, arguments) || this;
15680 }
15681 var _proto = Container2.prototype;
15682 _proto.append = function append() {
15683 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
15684 children[_key] = arguments[_key];
15685 }
15686 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
15687 var child = _step.value;
15688 var nodes = this.normalize(child, this.last);
15689 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15690 var node2 = _step1.value;
15691 this.proxyOf.nodes.push(node2);
15692 }
15693 }
15694 this.markDirty();
15695 return this;
15696 };
15697 _proto.cleanRaws = function cleanRaws(keepBetween) {
15698 Node$1.prototype.cleanRaws.call(this, keepBetween);
15699 if (this.nodes) {
15700 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
15701 var node2 = _step.value;
15702 node2.cleanRaws(keepBetween);
15703 }
15704 }
15705 };
15706 _proto.each = function each(callback) {
15707 if (!this.proxyOf.nodes) return void 0;
15708 var iterator = this.getIterator();
15709 var index2, result2;
15710 while(this.indexes[iterator] < this.proxyOf.nodes.length){
15711 index2 = this.indexes[iterator];
15712 result2 = callback(this.proxyOf.nodes[index2], index2);
15713 if (result2 === false) break;
15714 this.indexes[iterator] += 1;
15715 }
15716 delete this.indexes[iterator];
15717 return result2;
15718 };
15719 _proto.every = function every(condition) {
15720 return this.nodes.every(condition);
15721 };
15722 _proto.getIterator = function getIterator() {
15723 if (!this.lastEach) this.lastEach = 0;
15724 if (!this.indexes) this.indexes = {};
15725 this.lastEach += 1;
15726 var iterator = this.lastEach;
15727 this.indexes[iterator] = 0;
15728 return iterator;
15729 };
15730 _proto.getProxyProcessor = function getProxyProcessor() {
15731 return {
15732 get: function get(node2, prop) {
15733 if (prop === "proxyOf") {
15734 return node2;
15735 } else if (!node2[prop]) {
15736 return node2[prop];
15737 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
15738 return function() {
15739 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
15740 args[_key] = arguments[_key];
15741 }
15742 var _node2;
15743 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
15744 if (typeof i2 === "function") {
15745 return function(child, index2) {
15746 return i2(child.toProxy(), index2);
15747 };
15748 } else {
15749 return i2;
15750 }
15751 })));
15752 };
15753 } else if (prop === "every" || prop === "some") {
15754 return function(cb) {
15755 return node2[prop](function(child) {
15756 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
15757 other[_key - 1] = arguments[_key];
15758 }
15759 return cb.apply(void 0, [].concat([
15760 child.toProxy()
15761 ], other));
15762 });
15763 };
15764 } else if (prop === "root") {
15765 return function() {
15766 return node2.root().toProxy();
15767 };
15768 } else if (prop === "nodes") {
15769 return node2.nodes.map(function(i2) {
15770 return i2.toProxy();
15771 });
15772 } else if (prop === "first" || prop === "last") {
15773 return node2[prop].toProxy();
15774 } else {
15775 return node2[prop];
15776 }
15777 },
15778 set: function set(node2, prop, value) {
15779 if (node2[prop] === value) return true;
15780 node2[prop] = value;
15781 if (prop === "name" || prop === "params" || prop === "selector") {
15782 node2.markDirty();
15783 }
15784 return true;
15785 }
15786 };
15787 };
15788 _proto.index = function index(child) {
15789 if (typeof child === "number") return child;
15790 if (child.proxyOf) child = child.proxyOf;
15791 return this.proxyOf.nodes.indexOf(child);
15792 };
15793 _proto.insertAfter = function insertAfter(exist, add) {
15794 var existIndex = this.index(exist);
15795 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
15796 existIndex = this.index(exist);
15797 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15798 var node2 = _step.value;
15799 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
15800 }
15801 var index2;
15802 for(var id in this.indexes){
15803 index2 = this.indexes[id];
15804 if (existIndex < index2) {
15805 this.indexes[id] = index2 + nodes.length;
15806 }
15807 }
15808 this.markDirty();
15809 return this;
15810 };
15811 _proto.insertBefore = function insertBefore(exist, add) {
15812 var existIndex = this.index(exist);
15813 var type = existIndex === 0 ? "prepend" : false;
15814 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
15815 existIndex = this.index(exist);
15816 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15817 var node2 = _step.value;
15818 this.proxyOf.nodes.splice(existIndex, 0, node2);
15819 }
15820 var index2;
15821 for(var id in this.indexes){
15822 index2 = this.indexes[id];
15823 if (existIndex <= index2) {
15824 this.indexes[id] = index2 + nodes.length;
15825 }
15826 }
15827 this.markDirty();
15828 return this;
15829 };
15830 _proto.normalize = function normalize(nodes, sample) {
15831 var _this = this;
15832 if (typeof nodes === "string") {
15833 nodes = cleanSource(parse$4(nodes).nodes);
15834 } else if (typeof nodes === "undefined") {
15835 nodes = [];
15836 } else if (Array.isArray(nodes)) {
15837 nodes = nodes.slice(0);
15838 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15839 var i2 = _step.value;
15840 if (i2.parent) i2.parent.removeChild(i2, "ignore");
15841 }
15842 } else if (nodes.type === "root" && this.type !== "document") {
15843 nodes = nodes.nodes.slice(0);
15844 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15845 var i21 = _step1.value;
15846 if (i21.parent) i21.parent.removeChild(i21, "ignore");
15847 }
15848 } else if (nodes.type) {
15849 nodes = [
15850 nodes
15851 ];
15852 } else if (nodes.prop) {
15853 if (typeof nodes.value === "undefined") {
15854 throw new Error("Value field is missed in node creation");
15855 } else if (typeof nodes.value !== "string") {
15856 nodes.value = String(nodes.value);
15857 }
15858 nodes = [
15859 new Declaration$3(nodes)
15860 ];
15861 } else if (nodes.selector) {
15862 nodes = [
15863 new Rule$4(nodes)
15864 ];
15865 } else if (nodes.name) {
15866 nodes = [
15867 new AtRule$4(nodes)
15868 ];
15869 } else if (nodes.text) {
15870 nodes = [
15871 new Comment$3(nodes)
15872 ];
15873 } else {
15874 throw new Error("Unknown node type in node creation");
15875 }
15876 var processed = nodes.map(function(i2) {
15877 if (!i2[my$1]) Container2.rebuild(i2);
15878 i2 = i2.proxyOf;
15879 if (i2.parent) i2.parent.removeChild(i2);
15880 if (i2[isClean$1]) markDirtyUp(i2);
15881 if (typeof i2.raws.before === "undefined") {
15882 if (sample && typeof sample.raws.before !== "undefined") {
15883 i2.raws.before = sample.raws.before.replace(/\S/g, "");
15884 }
15885 }
15886 i2.parent = _this.proxyOf;
15887 return i2;
15888 });
15889 return processed;
15890 };
15891 _proto.prepend = function prepend() {
15892 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
15893 children[_key] = arguments[_key];
15894 }
15895 children = children.reverse();
15896 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
15897 var child = _step.value;
15898 var nodes = this.normalize(child, this.first, "prepend").reverse();
15899 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15900 var node2 = _step1.value;
15901 this.proxyOf.nodes.unshift(node2);
15902 }
15903 for(var id in this.indexes){
15904 this.indexes[id] = this.indexes[id] + nodes.length;
15905 }
15906 }
15907 this.markDirty();
15908 return this;
15909 };
15910 _proto.push = function push(child) {
15911 child.parent = this;
15912 this.proxyOf.nodes.push(child);
15913 return this;
15914 };
15915 _proto.removeAll = function removeAll() {
15916 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
15917 var node2 = _step.value;
15918 node2.parent = void 0;
15919 }
15920 this.proxyOf.nodes = [];
15921 this.markDirty();
15922 return this;
15923 };
15924 _proto.removeChild = function removeChild(child) {
15925 child = this.index(child);
15926 this.proxyOf.nodes[child].parent = void 0;
15927 this.proxyOf.nodes.splice(child, 1);
15928 var index2;
15929 for(var id in this.indexes){
15930 index2 = this.indexes[id];
15931 if (index2 >= child) {
15932 this.indexes[id] = index2 - 1;
15933 }
15934 }
15935 this.markDirty();
15936 return this;
15937 };
15938 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
15939 if (!callback) {
15940 callback = opts;
15941 opts = {};
15942 }
15943 this.walkDecls(function(decl) {
15944 if (opts.props && !opts.props.includes(decl.prop)) return;
15945 if (opts.fast && !decl.value.includes(opts.fast)) return;
15946 decl.value = decl.value.replace(pattern, callback);
15947 });
15948 this.markDirty();
15949 return this;
15950 };
15951 _proto.some = function some(condition) {
15952 return this.nodes.some(condition);
15953 };
15954 _proto.walk = function walk(callback) {
15955 return this.each(function(child, i2) {
15956 var result2;
15957 try {
15958 result2 = callback(child, i2);
15959 } catch (e2) {
15960 throw child.addToError(e2);
15961 }
15962 if (result2 !== false && child.walk) {
15963 result2 = child.walk(callback);
15964 }
15965 return result2;
15966 });
15967 };
15968 _proto.walkAtRules = function walkAtRules(name, callback) {
15969 if (!callback) {
15970 callback = name;
15971 return this.walk(function(child, i2) {
15972 if (child.type === "atrule") {
15973 return callback(child, i2);
15974 }
15975 });
15976 }
15977 if (_instanceof(name, RegExp)) {
15978 return this.walk(function(child, i2) {
15979 if (child.type === "atrule" && name.test(child.name)) {
15980 return callback(child, i2);
15981 }
15982 });
15983 }
15984 return this.walk(function(child, i2) {
15985 if (child.type === "atrule" && child.name === name) {
15986 return callback(child, i2);
15987 }
15988 });
15989 };
15990 _proto.walkComments = function walkComments(callback) {
15991 return this.walk(function(child, i2) {
15992 if (child.type === "comment") {
15993 return callback(child, i2);
15994 }
15995 });
15996 };
15997 _proto.walkDecls = function walkDecls(prop, callback) {
15998 if (!callback) {
15999 callback = prop;
16000 return this.walk(function(child, i2) {
16001 if (child.type === "decl") {
16002 return callback(child, i2);
16003 }
16004 });
16005 }
16006 if (_instanceof(prop, RegExp)) {
16007 return this.walk(function(child, i2) {
16008 if (child.type === "decl" && prop.test(child.prop)) {
16009 return callback(child, i2);
16010 }
16011 });
16012 }
16013 return this.walk(function(child, i2) {
16014 if (child.type === "decl" && child.prop === prop) {
16015 return callback(child, i2);
16016 }
16017 });
16018 };
16019 _proto.walkRules = function walkRules(selector, callback) {
16020 if (!callback) {
16021 callback = selector;
16022 return this.walk(function(child, i2) {
16023 if (child.type === "rule") {
16024 return callback(child, i2);
16025 }
16026 });
16027 }
16028 if (_instanceof(selector, RegExp)) {
16029 return this.walk(function(child, i2) {
16030 if (child.type === "rule" && selector.test(child.selector)) {
16031 return callback(child, i2);
16032 }
16033 });
16034 }
16035 return this.walk(function(child, i2) {
16036 if (child.type === "rule" && child.selector === selector) {
16037 return callback(child, i2);
16038 }
16039 });
16040 };
16041 _create_class(Container2, [
16042 {
16043 key: "first",
16044 get: function get() {
16045 if (!this.proxyOf.nodes) return void 0;
16046 return this.proxyOf.nodes[0];
16047 }
16048 },
16049 {
16050 key: "last",
16051 get: function get() {
16052 if (!this.proxyOf.nodes) return void 0;
16053 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
16054 }
16055 }
16056 ]);
16057 return Container2;
16058 }(Node$1);
16059 Container$7.registerParse = function(dependant) {
16060 parse$4 = dependant;
16061 };
16062 Container$7.registerRule = function(dependant) {
16063 Rule$4 = dependant;
16064 };
16065 Container$7.registerAtRule = function(dependant) {
16066 AtRule$4 = dependant;
16067 };
16068 Container$7.registerRoot = function(dependant) {
16069 Root$6 = dependant;
16070 };
16071 var container = Container$7;
16072 Container$7.default = Container$7;
16073 Container$7.rebuild = function(node2) {
16074 if (node2.type === "atrule") {
16075 Object.setPrototypeOf(node2, AtRule$4.prototype);
16076 } else if (node2.type === "rule") {
16077 Object.setPrototypeOf(node2, Rule$4.prototype);
16078 } else if (node2.type === "decl") {
16079 Object.setPrototypeOf(node2, Declaration$3.prototype);
16080 } else if (node2.type === "comment") {
16081 Object.setPrototypeOf(node2, Comment$3.prototype);
16082 } else if (node2.type === "root") {
16083 Object.setPrototypeOf(node2, Root$6.prototype);
16084 }
16085 node2[my$1] = true;
16086 if (node2.nodes) {
16087 node2.nodes.forEach(function(child) {
16088 Container$7.rebuild(child);
16089 });
16090 }
16091 };
16092 var Container$6 = container;
16093 var LazyResult$4, Processor$3;
16094 var Document$3 = /*#__PURE__*/ function(Container$6) {
16095 _inherits(Document23, Container$6);
16096 function Document23(defaults) {
16097 var _this;
16098 _this = Container$6.call(this, _extends({
16099 type: "document"
16100 }, defaults)) || this;
16101 if (!_this.nodes) {
16102 _this.nodes = [];
16103 }
16104 return _this;
16105 }
16106 var _proto = Document23.prototype;
16107 _proto.toResult = function toResult(opts) {
16108 if (opts === void 0) opts = {};
16109 var lazy = new LazyResult$4(new Processor$3(), this, opts);
16110 return lazy.stringify();
16111 };
16112 return Document23;
16113 }(Container$6);
16114 Document$3.registerLazyResult = function(dependant) {
16115 LazyResult$4 = dependant;
16116 };
16117 Document$3.registerProcessor = function(dependant) {
16118 Processor$3 = dependant;
16119 };
16120 var document$1$2 = Document$3;
16121 Document$3.default = Document$3;
16122 var printed = {};
16123 var warnOnce$2 = function warnOnce2(message) {
16124 if (printed[message]) return;
16125 printed[message] = true;
16126 if (typeof console !== "undefined" && console.warn) {
16127 console.warn(message);
16128 }
16129 };
16130 var Warning$2 = /*#__PURE__*/ function() {
16131 function Warning2(text, opts) {
16132 if (opts === void 0) opts = {};
16133 this.type = "warning";
16134 this.text = text;
16135 if (opts.node && opts.node.source) {
16136 var range = opts.node.rangeBy(opts);
16137 this.line = range.start.line;
16138 this.column = range.start.column;
16139 this.endLine = range.end.line;
16140 this.endColumn = range.end.column;
16141 }
16142 for(var opt in opts)this[opt] = opts[opt];
16143 }
16144 var _proto = Warning2.prototype;
16145 _proto.toString = function toString() {
16146 if (this.node) {
16147 return this.node.error(this.text, {
16148 index: this.index,
16149 plugin: this.plugin,
16150 word: this.word
16151 }).message;
16152 }
16153 if (this.plugin) {
16154 return this.plugin + ": " + this.text;
16155 }
16156 return this.text;
16157 };
16158 return Warning2;
16159 }();
16160 var warning = Warning$2;
16161 Warning$2.default = Warning$2;
16162 var Warning$1 = warning;
16163 var Result$3 = /*#__PURE__*/ function() {
16164 function Result2(processor2, root2, opts) {
16165 this.processor = processor2;
16166 this.messages = [];
16167 this.root = root2;
16168 this.opts = opts;
16169 this.css = void 0;
16170 this.map = void 0;
16171 }
16172 var _proto = Result2.prototype;
16173 _proto.toString = function toString() {
16174 return this.css;
16175 };
16176 _proto.warn = function warn(text, opts) {
16177 if (opts === void 0) opts = {};
16178 if (!opts.plugin) {
16179 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
16180 opts.plugin = this.lastPlugin.postcssPlugin;
16181 }
16182 }
16183 var warning2 = new Warning$1(text, opts);
16184 this.messages.push(warning2);
16185 return warning2;
16186 };
16187 _proto.warnings = function warnings() {
16188 return this.messages.filter(function(i2) {
16189 return i2.type === "warning";
16190 });
16191 };
16192 _create_class(Result2, [
16193 {
16194 key: "content",
16195 get: function get() {
16196 return this.css;
16197 }
16198 }
16199 ]);
16200 return Result2;
16201 }();
16202 var result = Result$3;
16203 Result$3.default = Result$3;
16204 var SINGLE_QUOTE = "'".charCodeAt(0);
16205 var DOUBLE_QUOTE = '"'.charCodeAt(0);
16206 var BACKSLASH = "\\".charCodeAt(0);
16207 var SLASH = "/".charCodeAt(0);
16208 var NEWLINE = "\n".charCodeAt(0);
16209 var SPACE = " ".charCodeAt(0);
16210 var FEED = "\f".charCodeAt(0);
16211 var TAB = " ".charCodeAt(0);
16212 var CR = "\r".charCodeAt(0);
16213 var OPEN_SQUARE = "[".charCodeAt(0);
16214 var CLOSE_SQUARE = "]".charCodeAt(0);
16215 var OPEN_PARENTHESES = "(".charCodeAt(0);
16216 var CLOSE_PARENTHESES = ")".charCodeAt(0);
16217 var OPEN_CURLY = "{".charCodeAt(0);
16218 var CLOSE_CURLY = "}".charCodeAt(0);
16219 var SEMICOLON = ";".charCodeAt(0);
16220 var ASTERISK = "*".charCodeAt(0);
16221 var COLON = ":".charCodeAt(0);
16222 var AT = "@".charCodeAt(0);
16223 var RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
16224 var RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
16225 var RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
16226 var RE_HEX_ESCAPE = /[\da-f]/i;
16227 var tokenize = function tokenizer2(input2, options) {
16228 if (options === void 0) options = {};
16229 var css = input2.css.valueOf();
16230 var ignore = options.ignoreErrors;
16231 var code, next, quote, content, escape;
16232 var escaped, escapePos, prev, n2, currentToken;
16233 var length = css.length;
16234 var pos = 0;
16235 var buffer = [];
16236 var returned = [];
16237 function position() {
16238 return pos;
16239 }
16240 function unclosed(what) {
16241 throw input2.error("Unclosed " + what, pos);
16242 }
16243 function endOfFile() {
16244 return returned.length === 0 && pos >= length;
16245 }
16246 function nextToken(opts) {
16247 if (returned.length) return returned.pop();
16248 if (pos >= length) return;
16249 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
16250 code = css.charCodeAt(pos);
16251 switch(code){
16252 case NEWLINE:
16253 case SPACE:
16254 case TAB:
16255 case CR:
16256 case FEED:
16257 {
16258 next = pos;
16259 do {
16260 next += 1;
16261 code = css.charCodeAt(next);
16262 }while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED);
16263 currentToken = [
16264 "space",
16265 css.slice(pos, next)
16266 ];
16267 pos = next - 1;
16268 break;
16269 }
16270 case OPEN_SQUARE:
16271 case CLOSE_SQUARE:
16272 case OPEN_CURLY:
16273 case CLOSE_CURLY:
16274 case COLON:
16275 case SEMICOLON:
16276 case CLOSE_PARENTHESES:
16277 {
16278 var controlChar = String.fromCharCode(code);
16279 currentToken = [
16280 controlChar,
16281 controlChar,
16282 pos
16283 ];
16284 break;
16285 }
16286 case OPEN_PARENTHESES:
16287 {
16288 prev = buffer.length ? buffer.pop()[1] : "";
16289 n2 = css.charCodeAt(pos + 1);
16290 if (prev === "url" && n2 !== SINGLE_QUOTE && n2 !== DOUBLE_QUOTE && n2 !== SPACE && n2 !== NEWLINE && n2 !== TAB && n2 !== FEED && n2 !== CR) {
16291 next = pos;
16292 do {
16293 escaped = false;
16294 next = css.indexOf(")", next + 1);
16295 if (next === -1) {
16296 if (ignore || ignoreUnclosed) {
16297 next = pos;
16298 break;
16299 } else {
16300 unclosed("bracket");
16301 }
16302 }
16303 escapePos = next;
16304 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16305 escapePos -= 1;
16306 escaped = !escaped;
16307 }
16308 }while (escaped);
16309 currentToken = [
16310 "brackets",
16311 css.slice(pos, next + 1),
16312 pos,
16313 next
16314 ];
16315 pos = next;
16316 } else {
16317 next = css.indexOf(")", pos + 1);
16318 content = css.slice(pos, next + 1);
16319 if (next === -1 || RE_BAD_BRACKET.test(content)) {
16320 currentToken = [
16321 "(",
16322 "(",
16323 pos
16324 ];
16325 } else {
16326 currentToken = [
16327 "brackets",
16328 content,
16329 pos,
16330 next
16331 ];
16332 pos = next;
16333 }
16334 }
16335 break;
16336 }
16337 case SINGLE_QUOTE:
16338 case DOUBLE_QUOTE:
16339 {
16340 quote = code === SINGLE_QUOTE ? "'" : '"';
16341 next = pos;
16342 do {
16343 escaped = false;
16344 next = css.indexOf(quote, next + 1);
16345 if (next === -1) {
16346 if (ignore || ignoreUnclosed) {
16347 next = pos + 1;
16348 break;
16349 } else {
16350 unclosed("string");
16351 }
16352 }
16353 escapePos = next;
16354 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16355 escapePos -= 1;
16356 escaped = !escaped;
16357 }
16358 }while (escaped);
16359 currentToken = [
16360 "string",
16361 css.slice(pos, next + 1),
16362 pos,
16363 next
16364 ];
16365 pos = next;
16366 break;
16367 }
16368 case AT:
16369 {
16370 RE_AT_END.lastIndex = pos + 1;
16371 RE_AT_END.test(css);
16372 if (RE_AT_END.lastIndex === 0) {
16373 next = css.length - 1;
16374 } else {
16375 next = RE_AT_END.lastIndex - 2;
16376 }
16377 currentToken = [
16378 "at-word",
16379 css.slice(pos, next + 1),
16380 pos,
16381 next
16382 ];
16383 pos = next;
16384 break;
16385 }
16386 case BACKSLASH:
16387 {
16388 next = pos;
16389 escape = true;
16390 while(css.charCodeAt(next + 1) === BACKSLASH){
16391 next += 1;
16392 escape = !escape;
16393 }
16394 code = css.charCodeAt(next + 1);
16395 if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
16396 next += 1;
16397 if (RE_HEX_ESCAPE.test(css.charAt(next))) {
16398 while(RE_HEX_ESCAPE.test(css.charAt(next + 1))){
16399 next += 1;
16400 }
16401 if (css.charCodeAt(next + 1) === SPACE) {
16402 next += 1;
16403 }
16404 }
16405 }
16406 currentToken = [
16407 "word",
16408 css.slice(pos, next + 1),
16409 pos,
16410 next
16411 ];
16412 pos = next;
16413 break;
16414 }
16415 default:
16416 {
16417 if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
16418 next = css.indexOf("*/", pos + 2) + 1;
16419 if (next === 0) {
16420 if (ignore || ignoreUnclosed) {
16421 next = css.length;
16422 } else {
16423 unclosed("comment");
16424 }
16425 }
16426 currentToken = [
16427 "comment",
16428 css.slice(pos, next + 1),
16429 pos,
16430 next
16431 ];
16432 pos = next;
16433 } else {
16434 RE_WORD_END.lastIndex = pos + 1;
16435 RE_WORD_END.test(css);
16436 if (RE_WORD_END.lastIndex === 0) {
16437 next = css.length - 1;
16438 } else {
16439 next = RE_WORD_END.lastIndex - 2;
16440 }
16441 currentToken = [
16442 "word",
16443 css.slice(pos, next + 1),
16444 pos,
16445 next
16446 ];
16447 buffer.push(currentToken);
16448 pos = next;
16449 }
16450 break;
16451 }
16452 }
16453 pos++;
16454 return currentToken;
16455 }
16456 function back(token) {
16457 returned.push(token);
16458 }
16459 return {
16460 back: back,
16461 endOfFile: endOfFile,
16462 nextToken: nextToken,
16463 position: position
16464 };
16465 };
16466 var Container$5 = container;
16467 var AtRule$3 = /*#__PURE__*/ function(Container$5) {
16468 _inherits(AtRule2, Container$5);
16469 function AtRule2(defaults) {
16470 var _this;
16471 _this = Container$5.call(this, defaults) || this;
16472 _this.type = "atrule";
16473 return _this;
16474 }
16475 var _proto = AtRule2.prototype;
16476 _proto.append = function append() {
16477 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16478 children[_key] = arguments[_key];
16479 }
16480 var _Container$5_prototype_append;
16481 if (!this.proxyOf.nodes) this.nodes = [];
16482 return (_Container$5_prototype_append = Container$5.prototype.append).call.apply(_Container$5_prototype_append, [].concat([
16483 this
16484 ], children));
16485 };
16486 _proto.prepend = function prepend() {
16487 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16488 children[_key] = arguments[_key];
16489 }
16490 var _Container$5_prototype_prepend;
16491 if (!this.proxyOf.nodes) this.nodes = [];
16492 return (_Container$5_prototype_prepend = Container$5.prototype.prepend).call.apply(_Container$5_prototype_prepend, [].concat([
16493 this
16494 ], children));
16495 };
16496 return AtRule2;
16497 }(Container$5);
16498 var atRule = AtRule$3;
16499 AtRule$3.default = AtRule$3;
16500 Container$5.registerAtRule(AtRule$3);
16501 var Container$4 = container;
16502 var LazyResult$3, Processor$2;
16503 var Root$5 = /*#__PURE__*/ function(Container$4) {
16504 _inherits(Root2, Container$4);
16505 function Root2(defaults) {
16506 var _this;
16507 _this = Container$4.call(this, defaults) || this;
16508 _this.type = "root";
16509 if (!_this.nodes) _this.nodes = [];
16510 return _this;
16511 }
16512 var _proto = Root2.prototype;
16513 _proto.normalize = function normalize(child, sample, type) {
16514 var nodes = Container$4.prototype.normalize.call(this, child);
16515 if (sample) {
16516 if (type === "prepend") {
16517 if (this.nodes.length > 1) {
16518 sample.raws.before = this.nodes[1].raws.before;
16519 } else {
16520 delete sample.raws.before;
16521 }
16522 } else if (this.first !== sample) {
16523 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16524 var node2 = _step.value;
16525 node2.raws.before = sample.raws.before;
16526 }
16527 }
16528 }
16529 return nodes;
16530 };
16531 _proto.removeChild = function removeChild(child, ignore) {
16532 var index2 = this.index(child);
16533 if (!ignore && index2 === 0 && this.nodes.length > 1) {
16534 this.nodes[1].raws.before = this.nodes[index2].raws.before;
16535 }
16536 return Container$4.prototype.removeChild.call(this, child);
16537 };
16538 _proto.toResult = function toResult(opts) {
16539 if (opts === void 0) opts = {};
16540 var lazy = new LazyResult$3(new Processor$2(), this, opts);
16541 return lazy.stringify();
16542 };
16543 return Root2;
16544 }(Container$4);
16545 Root$5.registerLazyResult = function(dependant) {
16546 LazyResult$3 = dependant;
16547 };
16548 Root$5.registerProcessor = function(dependant) {
16549 Processor$2 = dependant;
16550 };
16551 var root = Root$5;
16552 Root$5.default = Root$5;
16553 Container$4.registerRoot(Root$5);
16554 var list$2 = {
16555 comma: function comma(string) {
16556 return list$2.split(string, [
16557 ","
16558 ], true);
16559 },
16560 space: function space(string) {
16561 var spaces = [
16562 " ",
16563 "\n",
16564 " "
16565 ];
16566 return list$2.split(string, spaces);
16567 },
16568 split: function split(string, separators, last) {
16569 var array = [];
16570 var current = "";
16571 var split = false;
16572 var func = 0;
16573 var inQuote = false;
16574 var prevQuote = "";
16575 var escape = false;
16576 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
16577 var letter = _step.value;
16578 if (escape) {
16579 escape = false;
16580 } else if (letter === "\\") {
16581 escape = true;
16582 } else if (inQuote) {
16583 if (letter === prevQuote) {
16584 inQuote = false;
16585 }
16586 } else if (letter === '"' || letter === "'") {
16587 inQuote = true;
16588 prevQuote = letter;
16589 } else if (letter === "(") {
16590 func += 1;
16591 } else if (letter === ")") {
16592 if (func > 0) func -= 1;
16593 } else if (func === 0) {
16594 if (separators.includes(letter)) split = true;
16595 }
16596 if (split) {
16597 if (current !== "") array.push(current.trim());
16598 current = "";
16599 split = false;
16600 } else {
16601 current += letter;
16602 }
16603 }
16604 if (last || current !== "") array.push(current.trim());
16605 return array;
16606 }
16607 };
16608 var list_1 = list$2;
16609 list$2.default = list$2;
16610 var Container$3 = container;
16611 var list$1 = list_1;
16612 var Rule$3 = /*#__PURE__*/ function(Container$3) {
16613 _inherits(Rule2, Container$3);
16614 function Rule2(defaults) {
16615 var _this;
16616 _this = Container$3.call(this, defaults) || this;
16617 _this.type = "rule";
16618 if (!_this.nodes) _this.nodes = [];
16619 return _this;
16620 }
16621 _create_class(Rule2, [
16622 {
16623 key: "selectors",
16624 get: function get() {
16625 return list$1.comma(this.selector);
16626 },
16627 set: function set(values) {
16628 var match = this.selector ? this.selector.match(/,\s*/) : null;
16629 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
16630 this.selector = values.join(sep2);
16631 }
16632 }
16633 ]);
16634 return Rule2;
16635 }(Container$3);
16636 var rule = Rule$3;
16637 Rule$3.default = Rule$3;
16638 Container$3.registerRule(Rule$3);
16639 var Declaration$2 = declaration;
16640 var tokenizer22 = tokenize;
16641 var Comment$2 = comment;
16642 var AtRule$2 = atRule;
16643 var Root$4 = root;
16644 var Rule$2 = rule;
16645 var SAFE_COMMENT_NEIGHBOR = {
16646 empty: true,
16647 space: true
16648 };
16649 function findLastWithPosition(tokens) {
16650 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
16651 var token = tokens[i2];
16652 var pos = token[3] || token[2];
16653 if (pos) return pos;
16654 }
16655 }
16656 var Parser$1 = /*#__PURE__*/ function() {
16657 function Parser2(input2) {
16658 this.input = input2;
16659 this.root = new Root$4();
16660 this.current = this.root;
16661 this.spaces = "";
16662 this.semicolon = false;
16663 this.createTokenizer();
16664 this.root.source = {
16665 input: input2,
16666 start: {
16667 column: 1,
16668 line: 1,
16669 offset: 0
16670 }
16671 };
16672 }
16673 var _proto = Parser2.prototype;
16674 _proto.atrule = function atrule(token) {
16675 var node2 = new AtRule$2();
16676 node2.name = token[1].slice(1);
16677 if (node2.name === "") {
16678 this.unnamedAtrule(node2, token);
16679 }
16680 this.init(node2, token[2]);
16681 var type;
16682 var prev;
16683 var shift;
16684 var last = false;
16685 var open = false;
16686 var params = [];
16687 var brackets = [];
16688 while(!this.tokenizer.endOfFile()){
16689 token = this.tokenizer.nextToken();
16690 type = token[0];
16691 if (type === "(" || type === "[") {
16692 brackets.push(type === "(" ? ")" : "]");
16693 } else if (type === "{" && brackets.length > 0) {
16694 brackets.push("}");
16695 } else if (type === brackets[brackets.length - 1]) {
16696 brackets.pop();
16697 }
16698 if (brackets.length === 0) {
16699 if (type === ";") {
16700 node2.source.end = this.getPosition(token[2]);
16701 node2.source.end.offset++;
16702 this.semicolon = true;
16703 break;
16704 } else if (type === "{") {
16705 open = true;
16706 break;
16707 } else if (type === "}") {
16708 if (params.length > 0) {
16709 shift = params.length - 1;
16710 prev = params[shift];
16711 while(prev && prev[0] === "space"){
16712 prev = params[--shift];
16713 }
16714 if (prev) {
16715 node2.source.end = this.getPosition(prev[3] || prev[2]);
16716 node2.source.end.offset++;
16717 }
16718 }
16719 this.end(token);
16720 break;
16721 } else {
16722 params.push(token);
16723 }
16724 } else {
16725 params.push(token);
16726 }
16727 if (this.tokenizer.endOfFile()) {
16728 last = true;
16729 break;
16730 }
16731 }
16732 node2.raws.between = this.spacesAndCommentsFromEnd(params);
16733 if (params.length) {
16734 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
16735 this.raw(node2, "params", params);
16736 if (last) {
16737 token = params[params.length - 1];
16738 node2.source.end = this.getPosition(token[3] || token[2]);
16739 node2.source.end.offset++;
16740 this.spaces = node2.raws.between;
16741 node2.raws.between = "";
16742 }
16743 } else {
16744 node2.raws.afterName = "";
16745 node2.params = "";
16746 }
16747 if (open) {
16748 node2.nodes = [];
16749 this.current = node2;
16750 }
16751 };
16752 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
16753 var colon = this.colon(tokens);
16754 if (colon === false) return;
16755 var founded = 0;
16756 var token;
16757 for(var j = colon - 1; j >= 0; j--){
16758 token = tokens[j];
16759 if (token[0] !== "space") {
16760 founded += 1;
16761 if (founded === 2) break;
16762 }
16763 }
16764 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
16765 };
16766 _proto.colon = function colon(tokens) {
16767 var brackets = 0;
16768 var token, type, prev;
16769 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
16770 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
16771 token = element;
16772 type = token[0];
16773 if (type === "(") {
16774 brackets += 1;
16775 }
16776 if (type === ")") {
16777 brackets -= 1;
16778 }
16779 if (brackets === 0 && type === ":") {
16780 if (!prev) {
16781 this.doubleColon(token);
16782 } else if (prev[0] === "word" && prev[1] === "progid") {
16783 continue;
16784 } else {
16785 return i2;
16786 }
16787 }
16788 prev = token;
16789 }
16790 return false;
16791 };
16792 _proto.comment = function comment(token) {
16793 var node2 = new Comment$2();
16794 this.init(node2, token[2]);
16795 node2.source.end = this.getPosition(token[3] || token[2]);
16796 node2.source.end.offset++;
16797 var text = token[1].slice(2, -2);
16798 if (/^\s*$/.test(text)) {
16799 node2.text = "";
16800 node2.raws.left = text;
16801 node2.raws.right = "";
16802 } else {
16803 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
16804 node2.text = match[2];
16805 node2.raws.left = match[1];
16806 node2.raws.right = match[3];
16807 }
16808 };
16809 _proto.createTokenizer = function createTokenizer() {
16810 this.tokenizer = tokenizer22(this.input);
16811 };
16812 _proto.decl = function decl(tokens, customProperty) {
16813 var node2 = new Declaration$2();
16814 this.init(node2, tokens[0][2]);
16815 var last = tokens[tokens.length - 1];
16816 if (last[0] === ";") {
16817 this.semicolon = true;
16818 tokens.pop();
16819 }
16820 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition(tokens));
16821 node2.source.end.offset++;
16822 while(tokens[0][0] !== "word"){
16823 if (tokens.length === 1) this.unknownWord(tokens);
16824 node2.raws.before += tokens.shift()[1];
16825 }
16826 node2.source.start = this.getPosition(tokens[0][2]);
16827 node2.prop = "";
16828 while(tokens.length){
16829 var type = tokens[0][0];
16830 if (type === ":" || type === "space" || type === "comment") {
16831 break;
16832 }
16833 node2.prop += tokens.shift()[1];
16834 }
16835 node2.raws.between = "";
16836 var token;
16837 while(tokens.length){
16838 token = tokens.shift();
16839 if (token[0] === ":") {
16840 node2.raws.between += token[1];
16841 break;
16842 } else {
16843 if (token[0] === "word" && /\w/.test(token[1])) {
16844 this.unknownWord([
16845 token
16846 ]);
16847 }
16848 node2.raws.between += token[1];
16849 }
16850 }
16851 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
16852 node2.raws.before += node2.prop[0];
16853 node2.prop = node2.prop.slice(1);
16854 }
16855 var firstSpaces = [];
16856 var next;
16857 while(tokens.length){
16858 next = tokens[0][0];
16859 if (next !== "space" && next !== "comment") break;
16860 firstSpaces.push(tokens.shift());
16861 }
16862 this.precheckMissedSemicolon(tokens);
16863 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
16864 token = tokens[i2];
16865 if (token[1].toLowerCase() === "!important") {
16866 node2.important = true;
16867 var string = this.stringFrom(tokens, i2);
16868 string = this.spacesFromEnd(tokens) + string;
16869 if (string !== " !important") node2.raws.important = string;
16870 break;
16871 } else if (token[1].toLowerCase() === "important") {
16872 var cache = tokens.slice(0);
16873 var str = "";
16874 for(var j = i2; j > 0; j--){
16875 var type1 = cache[j][0];
16876 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
16877 break;
16878 }
16879 str = cache.pop()[1] + str;
16880 }
16881 if (str.trim().indexOf("!") === 0) {
16882 node2.important = true;
16883 node2.raws.important = str;
16884 tokens = cache;
16885 }
16886 }
16887 if (token[0] !== "space" && token[0] !== "comment") {
16888 break;
16889 }
16890 }
16891 var hasWord = tokens.some(function(i2) {
16892 return i2[0] !== "space" && i2[0] !== "comment";
16893 });
16894 if (hasWord) {
16895 node2.raws.between += firstSpaces.map(function(i2) {
16896 return i2[1];
16897 }).join("");
16898 firstSpaces = [];
16899 }
16900 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
16901 if (node2.value.includes(":") && !customProperty) {
16902 this.checkMissedSemicolon(tokens);
16903 }
16904 };
16905 _proto.doubleColon = function doubleColon(token) {
16906 throw this.input.error("Double colon", {
16907 offset: token[2]
16908 }, {
16909 offset: token[2] + token[1].length
16910 });
16911 };
16912 _proto.emptyRule = function emptyRule(token) {
16913 var node2 = new Rule$2();
16914 this.init(node2, token[2]);
16915 node2.selector = "";
16916 node2.raws.between = "";
16917 this.current = node2;
16918 };
16919 _proto.end = function end(token) {
16920 if (this.current.nodes && this.current.nodes.length) {
16921 this.current.raws.semicolon = this.semicolon;
16922 }
16923 this.semicolon = false;
16924 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
16925 this.spaces = "";
16926 if (this.current.parent) {
16927 this.current.source.end = this.getPosition(token[2]);
16928 this.current.source.end.offset++;
16929 this.current = this.current.parent;
16930 } else {
16931 this.unexpectedClose(token);
16932 }
16933 };
16934 _proto.endFile = function endFile() {
16935 if (this.current.parent) this.unclosedBlock();
16936 if (this.current.nodes && this.current.nodes.length) {
16937 this.current.raws.semicolon = this.semicolon;
16938 }
16939 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
16940 this.root.source.end = this.getPosition(this.tokenizer.position());
16941 };
16942 _proto.freeSemicolon = function freeSemicolon(token) {
16943 this.spaces += token[1];
16944 if (this.current.nodes) {
16945 var prev = this.current.nodes[this.current.nodes.length - 1];
16946 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
16947 prev.raws.ownSemicolon = this.spaces;
16948 this.spaces = "";
16949 }
16950 }
16951 };
16952 // Helpers
16953 _proto.getPosition = function getPosition(offset) {
16954 var pos = this.input.fromOffset(offset);
16955 return {
16956 column: pos.col,
16957 line: pos.line,
16958 offset: offset
16959 };
16960 };
16961 _proto.init = function init(node2, offset) {
16962 this.current.push(node2);
16963 node2.source = {
16964 input: this.input,
16965 start: this.getPosition(offset)
16966 };
16967 node2.raws.before = this.spaces;
16968 this.spaces = "";
16969 if (node2.type !== "comment") this.semicolon = false;
16970 };
16971 _proto.other = function other(start) {
16972 var end = false;
16973 var type = null;
16974 var colon = false;
16975 var bracket = null;
16976 var brackets = [];
16977 var customProperty = start[1].startsWith("--");
16978 var tokens = [];
16979 var token = start;
16980 while(token){
16981 type = token[0];
16982 tokens.push(token);
16983 if (type === "(" || type === "[") {
16984 if (!bracket) bracket = token;
16985 brackets.push(type === "(" ? ")" : "]");
16986 } else if (customProperty && colon && type === "{") {
16987 if (!bracket) bracket = token;
16988 brackets.push("}");
16989 } else if (brackets.length === 0) {
16990 if (type === ";") {
16991 if (colon) {
16992 this.decl(tokens, customProperty);
16993 return;
16994 } else {
16995 break;
16996 }
16997 } else if (type === "{") {
16998 this.rule(tokens);
16999 return;
17000 } else if (type === "}") {
17001 this.tokenizer.back(tokens.pop());
17002 end = true;
17003 break;
17004 } else if (type === ":") {
17005 colon = true;
17006 }
17007 } else if (type === brackets[brackets.length - 1]) {
17008 brackets.pop();
17009 if (brackets.length === 0) bracket = null;
17010 }
17011 token = this.tokenizer.nextToken();
17012 }
17013 if (this.tokenizer.endOfFile()) end = true;
17014 if (brackets.length > 0) this.unclosedBracket(bracket);
17015 if (end && colon) {
17016 if (!customProperty) {
17017 while(tokens.length){
17018 token = tokens[tokens.length - 1][0];
17019 if (token !== "space" && token !== "comment") break;
17020 this.tokenizer.back(tokens.pop());
17021 }
17022 }
17023 this.decl(tokens, customProperty);
17024 } else {
17025 this.unknownWord(tokens);
17026 }
17027 };
17028 _proto.parse = function parse() {
17029 var token;
17030 while(!this.tokenizer.endOfFile()){
17031 token = this.tokenizer.nextToken();
17032 switch(token[0]){
17033 case "space":
17034 this.spaces += token[1];
17035 break;
17036 case ";":
17037 this.freeSemicolon(token);
17038 break;
17039 case "}":
17040 this.end(token);
17041 break;
17042 case "comment":
17043 this.comment(token);
17044 break;
17045 case "at-word":
17046 this.atrule(token);
17047 break;
17048 case "{":
17049 this.emptyRule(token);
17050 break;
17051 default:
17052 this.other(token);
17053 break;
17054 }
17055 }
17056 this.endFile();
17057 };
17058 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
17059 _proto.raw = function raw(node2, prop, tokens, customProperty) {
17060 var token, type;
17061 var length = tokens.length;
17062 var value = "";
17063 var clean = true;
17064 var next, prev;
17065 for(var i2 = 0; i2 < length; i2 += 1){
17066 token = tokens[i2];
17067 type = token[0];
17068 if (type === "space" && i2 === length - 1 && !customProperty) {
17069 clean = false;
17070 } else if (type === "comment") {
17071 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
17072 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
17073 if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
17074 if (value.slice(-1) === ",") {
17075 clean = false;
17076 } else {
17077 value += token[1];
17078 }
17079 } else {
17080 clean = false;
17081 }
17082 } else {
17083 value += token[1];
17084 }
17085 }
17086 if (!clean) {
17087 var raw = tokens.reduce(function(all, i2) {
17088 return all + i2[1];
17089 }, "");
17090 node2.raws[prop] = {
17091 raw: raw,
17092 value: value
17093 };
17094 }
17095 node2[prop] = value;
17096 };
17097 _proto.rule = function rule(tokens) {
17098 tokens.pop();
17099 var node2 = new Rule$2();
17100 this.init(node2, tokens[0][2]);
17101 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
17102 this.raw(node2, "selector", tokens);
17103 this.current = node2;
17104 };
17105 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
17106 var lastTokenType;
17107 var spaces = "";
17108 while(tokens.length){
17109 lastTokenType = tokens[tokens.length - 1][0];
17110 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
17111 spaces = tokens.pop()[1] + spaces;
17112 }
17113 return spaces;
17114 };
17115 // Errors
17116 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
17117 var next;
17118 var spaces = "";
17119 while(tokens.length){
17120 next = tokens[0][0];
17121 if (next !== "space" && next !== "comment") break;
17122 spaces += tokens.shift()[1];
17123 }
17124 return spaces;
17125 };
17126 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
17127 var lastTokenType;
17128 var spaces = "";
17129 while(tokens.length){
17130 lastTokenType = tokens[tokens.length - 1][0];
17131 if (lastTokenType !== "space") break;
17132 spaces = tokens.pop()[1] + spaces;
17133 }
17134 return spaces;
17135 };
17136 _proto.stringFrom = function stringFrom(tokens, from) {
17137 var result2 = "";
17138 for(var i2 = from; i2 < tokens.length; i2++){
17139 result2 += tokens[i2][1];
17140 }
17141 tokens.splice(from, tokens.length - from);
17142 return result2;
17143 };
17144 _proto.unclosedBlock = function unclosedBlock() {
17145 var pos = this.current.source.start;
17146 throw this.input.error("Unclosed block", pos.line, pos.column);
17147 };
17148 _proto.unclosedBracket = function unclosedBracket(bracket) {
17149 throw this.input.error("Unclosed bracket", {
17150 offset: bracket[2]
17151 }, {
17152 offset: bracket[2] + 1
17153 });
17154 };
17155 _proto.unexpectedClose = function unexpectedClose(token) {
17156 throw this.input.error("Unexpected }", {
17157 offset: token[2]
17158 }, {
17159 offset: token[2] + 1
17160 });
17161 };
17162 _proto.unknownWord = function unknownWord(tokens) {
17163 throw this.input.error("Unknown word", {
17164 offset: tokens[0][2]
17165 }, {
17166 offset: tokens[0][2] + tokens[0][1].length
17167 });
17168 };
17169 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
17170 throw this.input.error("At-rule without name", {
17171 offset: token[2]
17172 }, {
17173 offset: token[2] + token[1].length
17174 });
17175 };
17176 return Parser2;
17177 }();
17178 var parser = Parser$1;
17179 var Container$2 = container;
17180 var Parser22 = parser;
17181 var Input$2 = input;
17182 function parse$3(css, opts) {
17183 var input2 = new Input$2(css, opts);
17184 var parser2 = new Parser22(input2);
17185 try {
17186 parser2.parse();
17187 } catch (e2) {
17188 if (true) {
17189 if (e2.name === "CssSyntaxError" && opts && opts.from) {
17190 if (/\.scss$/i.test(opts.from)) {
17191 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
17192 } else if (/\.sass/i.test(opts.from)) {
17193 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
17194 } else if (/\.less$/i.test(opts.from)) {
17195 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
17196 }
17197 }
17198 }
17199 throw e2;
17200 }
17201 return parser2.root;
17202 }
17203 var parse_1 = parse$3;
17204 parse$3.default = parse$3;
17205 Container$2.registerParse(parse$3);
17206 var isClean = symbols.isClean, my = symbols.my;
17207 var MapGenerator$1 = mapGenerator;
17208 var stringify$2 = stringify_1;
17209 var Container$1 = container;
17210 var Document$2 = document$1$2;
17211 var warnOnce$1 = warnOnce$2;
17212 var Result$2 = result;
17213 var parse$2 = parse_1;
17214 var Root$3 = root;
17215 var TYPE_TO_CLASS_NAME = {
17216 atrule: "AtRule",
17217 comment: "Comment",
17218 decl: "Declaration",
17219 document: "Document",
17220 root: "Root",
17221 rule: "Rule"
17222 };
17223 var PLUGIN_PROPS = {
17224 AtRule: true,
17225 AtRuleExit: true,
17226 Comment: true,
17227 CommentExit: true,
17228 Declaration: true,
17229 DeclarationExit: true,
17230 Document: true,
17231 DocumentExit: true,
17232 Once: true,
17233 OnceExit: true,
17234 postcssPlugin: true,
17235 prepare: true,
17236 Root: true,
17237 RootExit: true,
17238 Rule: true,
17239 RuleExit: true
17240 };
17241 var NOT_VISITORS = {
17242 Once: true,
17243 postcssPlugin: true,
17244 prepare: true
17245 };
17246 var CHILDREN = 0;
17247 function isPromise(obj) {
17248 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
17249 }
17250 function getEvents(node2) {
17251 var key = false;
17252 var type = TYPE_TO_CLASS_NAME[node2.type];
17253 if (node2.type === "decl") {
17254 key = node2.prop.toLowerCase();
17255 } else if (node2.type === "atrule") {
17256 key = node2.name.toLowerCase();
17257 }
17258 if (key && node2.append) {
17259 return [
17260 type,
17261 type + "-" + key,
17262 CHILDREN,
17263 type + "Exit",
17264 type + "Exit-" + key
17265 ];
17266 } else if (key) {
17267 return [
17268 type,
17269 type + "-" + key,
17270 type + "Exit",
17271 type + "Exit-" + key
17272 ];
17273 } else if (node2.append) {
17274 return [
17275 type,
17276 CHILDREN,
17277 type + "Exit"
17278 ];
17279 } else {
17280 return [
17281 type,
17282 type + "Exit"
17283 ];
17284 }
17285 }
17286 function toStack(node2) {
17287 var events;
17288 if (node2.type === "document") {
17289 events = [
17290 "Document",
17291 CHILDREN,
17292 "DocumentExit"
17293 ];
17294 } else if (node2.type === "root") {
17295 events = [
17296 "Root",
17297 CHILDREN,
17298 "RootExit"
17299 ];
17300 } else {
17301 events = getEvents(node2);
17302 }
17303 return {
17304 eventIndex: 0,
17305 events: events,
17306 iterator: 0,
17307 node: node2,
17308 visitorIndex: 0,
17309 visitors: []
17310 };
17311 }
17312 function cleanMarks(node2) {
17313 node2[isClean] = false;
17314 if (node2.nodes) node2.nodes.forEach(function(i2) {
17315 return cleanMarks(i2);
17316 });
17317 return node2;
17318 }
17319 var postcss$2 = {};
17320 var LazyResult$2 = /*#__PURE__*/ function() {
17321 function LazyResult2(processor2, css, opts) {
17322 var _this = this;
17323 this.stringified = false;
17324 this.processed = false;
17325 var root2;
17326 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
17327 root2 = cleanMarks(css);
17328 } else if (_instanceof(css, LazyResult2) || _instanceof(css, Result$2)) {
17329 root2 = cleanMarks(css.root);
17330 if (css.map) {
17331 if (typeof opts.map === "undefined") opts.map = {};
17332 if (!opts.map.inline) opts.map.inline = false;
17333 opts.map.prev = css.map;
17334 }
17335 } else {
17336 var parser2 = parse$2;
17337 if (opts.syntax) parser2 = opts.syntax.parse;
17338 if (opts.parser) parser2 = opts.parser;
17339 if (parser2.parse) parser2 = parser2.parse;
17340 try {
17341 root2 = parser2(css, opts);
17342 } catch (error) {
17343 this.processed = true;
17344 this.error = error;
17345 }
17346 if (root2 && !root2[my]) {
17347 Container$1.rebuild(root2);
17348 }
17349 }
17350 this.result = new Result$2(processor2, root2, opts);
17351 this.helpers = _extends({}, postcss$2, {
17352 postcss: postcss$2,
17353 result: this.result
17354 });
17355 this.plugins = this.processor.plugins.map(function(plugin22) {
17356 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
17357 return _extends({}, plugin22, plugin22.prepare(_this.result));
17358 } else {
17359 return plugin22;
17360 }
17361 });
17362 }
17363 var _proto = LazyResult2.prototype;
17364 _proto.async = function async() {
17365 if (this.error) return Promise.reject(this.error);
17366 if (this.processed) return Promise.resolve(this.result);
17367 if (!this.processing) {
17368 this.processing = this.runAsync();
17369 }
17370 return this.processing;
17371 };
17372 _proto.catch = function _catch(onRejected) {
17373 return this.async().catch(onRejected);
17374 };
17375 _proto.finally = function _finally(onFinally) {
17376 return this.async().then(onFinally, onFinally);
17377 };
17378 _proto.getAsyncError = function getAsyncError() {
17379 throw new Error("Use process(css).then(cb) to work with async plugins");
17380 };
17381 _proto.handleError = function handleError(error, node2) {
17382 var plugin22 = this.result.lastPlugin;
17383 try {
17384 if (node2) node2.addToError(error);
17385 this.error = error;
17386 if (error.name === "CssSyntaxError" && !error.plugin) {
17387 error.plugin = plugin22.postcssPlugin;
17388 error.setMessage();
17389 } else if (plugin22.postcssVersion) {
17390 if (true) {
17391 var pluginName = plugin22.postcssPlugin;
17392 var pluginVer = plugin22.postcssVersion;
17393 var runtimeVer = this.result.processor.version;
17394 var a2 = pluginVer.split(".");
17395 var b = runtimeVer.split(".");
17396 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
17397 console.error("Unknown error from PostCSS plugin. Your current PostCSS version is " + runtimeVer + ", but " + pluginName + " uses " + pluginVer + ". Perhaps this is the source of the error below.");
17398 }
17399 }
17400 }
17401 } catch (err) {
17402 if (console && console.error) console.error(err);
17403 }
17404 return error;
17405 };
17406 _proto.prepareVisitors = function prepareVisitors() {
17407 var _this = this;
17408 this.listeners = {};
17409 var add = function(plugin22, type, cb) {
17410 if (!_this.listeners[type]) _this.listeners[type] = [];
17411 _this.listeners[type].push([
17412 plugin22,
17413 cb
17414 ]);
17415 };
17416 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17417 var plugin22 = _step.value;
17418 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
17419 for(var event in plugin22){
17420 if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
17421 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
17422 }
17423 if (!NOT_VISITORS[event]) {
17424 if (_type_of(plugin22[event]) === "object") {
17425 for(var filter in plugin22[event]){
17426 if (filter === "*") {
17427 add(plugin22, event, plugin22[event][filter]);
17428 } else {
17429 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
17430 }
17431 }
17432 } else if (typeof plugin22[event] === "function") {
17433 add(plugin22, event, plugin22[event]);
17434 }
17435 }
17436 }
17437 }
17438 }
17439 this.hasListener = Object.keys(this.listeners).length > 0;
17440 };
17441 _proto.runAsync = function runAsync() {
17442 var _this = this;
17443 return _async_to_generator(function() {
17444 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
17445 return _ts_generator(this, function(_state) {
17446 switch(_state.label){
17447 case 0:
17448 _this.plugin = 0;
17449 i2 = 0;
17450 _state.label = 1;
17451 case 1:
17452 if (!(i2 < _this.plugins.length)) return [
17453 3,
17454 6
17455 ];
17456 plugin22 = _this.plugins[i2];
17457 promise = _this.runOnRoot(plugin22);
17458 if (!isPromise(promise)) return [
17459 3,
17460 5
17461 ];
17462 _state.label = 2;
17463 case 2:
17464 _state.trys.push([
17465 2,
17466 4,
17467 ,
17468 5
17469 ]);
17470 return [
17471 4,
17472 promise
17473 ];
17474 case 3:
17475 _state.sent();
17476 return [
17477 3,
17478 5
17479 ];
17480 case 4:
17481 error = _state.sent();
17482 throw _this.handleError(error);
17483 case 5:
17484 i2++;
17485 return [
17486 3,
17487 1
17488 ];
17489 case 6:
17490 _this.prepareVisitors();
17491 if (!_this.hasListener) return [
17492 3,
17493 18
17494 ];
17495 root2 = _this.result.root;
17496 _state.label = 7;
17497 case 7:
17498 if (!!root2[isClean]) return [
17499 3,
17500 14
17501 ];
17502 root2[isClean] = true;
17503 stack = [
17504 toStack(root2)
17505 ];
17506 _state.label = 8;
17507 case 8:
17508 if (!(stack.length > 0)) return [
17509 3,
17510 13
17511 ];
17512 promise1 = _this.visitTick(stack);
17513 if (!isPromise(promise1)) return [
17514 3,
17515 12
17516 ];
17517 _state.label = 9;
17518 case 9:
17519 _state.trys.push([
17520 9,
17521 11,
17522 ,
17523 12
17524 ]);
17525 return [
17526 4,
17527 promise1
17528 ];
17529 case 10:
17530 _state.sent();
17531 return [
17532 3,
17533 12
17534 ];
17535 case 11:
17536 e2 = _state.sent();
17537 node2 = stack[stack.length - 1].node;
17538 throw _this.handleError(e2, node2);
17539 case 12:
17540 return [
17541 3,
17542 8
17543 ];
17544 case 13:
17545 return [
17546 3,
17547 7
17548 ];
17549 case 14:
17550 if (!_this.listeners.OnceExit) return [
17551 3,
17552 18
17553 ];
17554 _loop = function() {
17555 var _step_value, plugin22, visitor, roots, e2;
17556 return _ts_generator(this, function(_state) {
17557 switch(_state.label){
17558 case 0:
17559 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
17560 _this.result.lastPlugin = plugin22;
17561 _state.label = 1;
17562 case 1:
17563 _state.trys.push([
17564 1,
17565 6,
17566 ,
17567 7
17568 ]);
17569 if (!(root2.type === "document")) return [
17570 3,
17571 3
17572 ];
17573 roots = root2.nodes.map(function(subRoot) {
17574 return visitor(subRoot, _this.helpers);
17575 });
17576 return [
17577 4,
17578 Promise.all(roots)
17579 ];
17580 case 2:
17581 _state.sent();
17582 return [
17583 3,
17584 5
17585 ];
17586 case 3:
17587 return [
17588 4,
17589 visitor(root2, _this.helpers)
17590 ];
17591 case 4:
17592 _state.sent();
17593 _state.label = 5;
17594 case 5:
17595 return [
17596 3,
17597 7
17598 ];
17599 case 6:
17600 e2 = _state.sent();
17601 throw _this.handleError(e2);
17602 case 7:
17603 return [
17604 2
17605 ];
17606 }
17607 });
17608 };
17609 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
17610 _state.label = 15;
17611 case 15:
17612 if (!!(_step = _iterator()).done) return [
17613 3,
17614 18
17615 ];
17616 return [
17617 5,
17618 _ts_values(_loop())
17619 ];
17620 case 16:
17621 _state.sent();
17622 _state.label = 17;
17623 case 17:
17624 return [
17625 3,
17626 15
17627 ];
17628 case 18:
17629 _this.processed = true;
17630 return [
17631 2,
17632 _this.stringify()
17633 ];
17634 }
17635 });
17636 })();
17637 };
17638 _proto.runOnRoot = function runOnRoot(plugin22) {
17639 var _this = this;
17640 this.result.lastPlugin = plugin22;
17641 try {
17642 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
17643 if (this.result.root.type === "document") {
17644 var roots = this.result.root.nodes.map(function(root2) {
17645 return plugin22.Once(root2, _this.helpers);
17646 });
17647 if (isPromise(roots[0])) {
17648 return Promise.all(roots);
17649 }
17650 return roots;
17651 }
17652 return plugin22.Once(this.result.root, this.helpers);
17653 } else if (typeof plugin22 === "function") {
17654 return plugin22(this.result.root, this.result);
17655 }
17656 } catch (error) {
17657 throw this.handleError(error);
17658 }
17659 };
17660 _proto.stringify = function stringify() {
17661 if (this.error) throw this.error;
17662 if (this.stringified) return this.result;
17663 this.stringified = true;
17664 this.sync();
17665 var opts = this.result.opts;
17666 var str = stringify$2;
17667 if (opts.syntax) str = opts.syntax.stringify;
17668 if (opts.stringifier) str = opts.stringifier;
17669 if (str.stringify) str = str.stringify;
17670 var map = new MapGenerator$1(str, this.result.root, this.result.opts);
17671 var data = map.generate();
17672 this.result.css = data[0];
17673 this.result.map = data[1];
17674 return this.result;
17675 };
17676 _proto.sync = function sync() {
17677 if (this.error) throw this.error;
17678 if (this.processed) return this.result;
17679 this.processed = true;
17680 if (this.processing) {
17681 throw this.getAsyncError();
17682 }
17683 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17684 var plugin22 = _step.value;
17685 var promise = this.runOnRoot(plugin22);
17686 if (isPromise(promise)) {
17687 throw this.getAsyncError();
17688 }
17689 }
17690 this.prepareVisitors();
17691 if (this.hasListener) {
17692 var root2 = this.result.root;
17693 while(!root2[isClean]){
17694 root2[isClean] = true;
17695 this.walkSync(root2);
17696 }
17697 if (this.listeners.OnceExit) {
17698 if (root2.type === "document") {
17699 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
17700 var subRoot = _step1.value;
17701 this.visitSync(this.listeners.OnceExit, subRoot);
17702 }
17703 } else {
17704 this.visitSync(this.listeners.OnceExit, root2);
17705 }
17706 }
17707 }
17708 return this.result;
17709 };
17710 _proto.then = function then(onFulfilled, onRejected) {
17711 if (true) {
17712 if (!("from" in this.opts)) {
17713 warnOnce$1("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.");
17714 }
17715 }
17716 return this.async().then(onFulfilled, onRejected);
17717 };
17718 _proto.toString = function toString() {
17719 return this.css;
17720 };
17721 _proto.visitSync = function visitSync(visitors, node2) {
17722 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
17723 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
17724 this.result.lastPlugin = plugin22;
17725 var promise = void 0;
17726 try {
17727 promise = visitor(node2, this.helpers);
17728 } catch (e2) {
17729 throw this.handleError(e2, node2.proxyOf);
17730 }
17731 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
17732 return true;
17733 }
17734 if (isPromise(promise)) {
17735 throw this.getAsyncError();
17736 }
17737 }
17738 };
17739 _proto.visitTick = function visitTick(stack) {
17740 var visit2 = stack[stack.length - 1];
17741 var node2 = visit2.node, visitors = visit2.visitors;
17742 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
17743 stack.pop();
17744 return;
17745 }
17746 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
17747 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
17748 visit2.visitorIndex += 1;
17749 if (visit2.visitorIndex === visitors.length) {
17750 visit2.visitors = [];
17751 visit2.visitorIndex = 0;
17752 }
17753 this.result.lastPlugin = plugin22;
17754 try {
17755 return visitor(node2.toProxy(), this.helpers);
17756 } catch (e2) {
17757 throw this.handleError(e2, node2);
17758 }
17759 }
17760 if (visit2.iterator !== 0) {
17761 var iterator = visit2.iterator;
17762 var child;
17763 while(child = node2.nodes[node2.indexes[iterator]]){
17764 node2.indexes[iterator] += 1;
17765 if (!child[isClean]) {
17766 child[isClean] = true;
17767 stack.push(toStack(child));
17768 return;
17769 }
17770 }
17771 visit2.iterator = 0;
17772 delete node2.indexes[iterator];
17773 }
17774 var events = visit2.events;
17775 while(visit2.eventIndex < events.length){
17776 var event = events[visit2.eventIndex];
17777 visit2.eventIndex += 1;
17778 if (event === CHILDREN) {
17779 if (node2.nodes && node2.nodes.length) {
17780 node2[isClean] = true;
17781 visit2.iterator = node2.getIterator();
17782 }
17783 return;
17784 } else if (this.listeners[event]) {
17785 visit2.visitors = this.listeners[event];
17786 return;
17787 }
17788 }
17789 stack.pop();
17790 };
17791 _proto.walkSync = function walkSync(node2) {
17792 var _this = this;
17793 node2[isClean] = true;
17794 var events = getEvents(node2);
17795 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
17796 var event = _step.value;
17797 if (event === CHILDREN) {
17798 if (node2.nodes) {
17799 node2.each(function(child) {
17800 if (!child[isClean]) _this.walkSync(child);
17801 });
17802 }
17803 } else {
17804 var visitors = this.listeners[event];
17805 if (visitors) {
17806 if (this.visitSync(visitors, node2.toProxy())) return;
17807 }
17808 }
17809 }
17810 };
17811 _proto.warnings = function warnings() {
17812 return this.sync().warnings();
17813 };
17814 _create_class(LazyResult2, [
17815 {
17816 key: "content",
17817 get: function get() {
17818 return this.stringify().content;
17819 }
17820 },
17821 {
17822 key: "css",
17823 get: function get() {
17824 return this.stringify().css;
17825 }
17826 },
17827 {
17828 key: "map",
17829 get: function get() {
17830 return this.stringify().map;
17831 }
17832 },
17833 {
17834 key: "messages",
17835 get: function get() {
17836 return this.sync().messages;
17837 }
17838 },
17839 {
17840 key: "opts",
17841 get: function get() {
17842 return this.result.opts;
17843 }
17844 },
17845 {
17846 key: "processor",
17847 get: function get() {
17848 return this.result.processor;
17849 }
17850 },
17851 {
17852 key: "root",
17853 get: function get() {
17854 return this.sync().root;
17855 }
17856 },
17857 {
17858 key: Symbol.toStringTag,
17859 get: function get() {
17860 return "LazyResult";
17861 }
17862 }
17863 ]);
17864 return LazyResult2;
17865 }();
17866 LazyResult$2.registerPostcss = function(dependant) {
17867 postcss$2 = dependant;
17868 };
17869 var lazyResult = LazyResult$2;
17870 LazyResult$2.default = LazyResult$2;
17871 Root$3.registerLazyResult(LazyResult$2);
17872 Document$2.registerLazyResult(LazyResult$2);
17873 var MapGenerator22 = mapGenerator;
17874 var stringify$1 = stringify_1;
17875 var warnOnce22 = warnOnce$2;
17876 var parse$1 = parse_1;
17877 var Result$1 = result;
17878 var NoWorkResult$1 = /*#__PURE__*/ function() {
17879 function NoWorkResult2(processor2, css, opts) {
17880 css = css.toString();
17881 this.stringified = false;
17882 this._processor = processor2;
17883 this._css = css;
17884 this._opts = opts;
17885 this._map = void 0;
17886 var root2;
17887 var str = stringify$1;
17888 this.result = new Result$1(this._processor, root2, this._opts);
17889 this.result.css = css;
17890 var self = this;
17891 Object.defineProperty(this.result, "root", {
17892 get: function get() {
17893 return self.root;
17894 }
17895 });
17896 var map = new MapGenerator22(str, root2, this._opts, css);
17897 if (map.isMap()) {
17898 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
17899 if (generatedCSS) {
17900 this.result.css = generatedCSS;
17901 }
17902 if (generatedMap) {
17903 this.result.map = generatedMap;
17904 }
17905 } else {
17906 map.clearAnnotation();
17907 this.result.css = map.css;
17908 }
17909 }
17910 var _proto = NoWorkResult2.prototype;
17911 _proto.async = function async() {
17912 if (this.error) return Promise.reject(this.error);
17913 return Promise.resolve(this.result);
17914 };
17915 _proto.catch = function _catch(onRejected) {
17916 return this.async().catch(onRejected);
17917 };
17918 _proto.finally = function _finally(onFinally) {
17919 return this.async().then(onFinally, onFinally);
17920 };
17921 _proto.sync = function sync() {
17922 if (this.error) throw this.error;
17923 return this.result;
17924 };
17925 _proto.then = function then(onFulfilled, onRejected) {
17926 if (true) {
17927 if (!("from" in this._opts)) {
17928 warnOnce22("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.");
17929 }
17930 }
17931 return this.async().then(onFulfilled, onRejected);
17932 };
17933 _proto.toString = function toString() {
17934 return this._css;
17935 };
17936 _proto.warnings = function warnings() {
17937 return [];
17938 };
17939 _create_class(NoWorkResult2, [
17940 {
17941 key: "content",
17942 get: function get() {
17943 return this.result.css;
17944 }
17945 },
17946 {
17947 key: "css",
17948 get: function get() {
17949 return this.result.css;
17950 }
17951 },
17952 {
17953 key: "map",
17954 get: function get() {
17955 return this.result.map;
17956 }
17957 },
17958 {
17959 key: "messages",
17960 get: function get() {
17961 return [];
17962 }
17963 },
17964 {
17965 key: "opts",
17966 get: function get() {
17967 return this.result.opts;
17968 }
17969 },
17970 {
17971 key: "processor",
17972 get: function get() {
17973 return this.result.processor;
17974 }
17975 },
17976 {
17977 key: "root",
17978 get: function get() {
17979 if (this._root) {
17980 return this._root;
17981 }
17982 var root2;
17983 var parser2 = parse$1;
17984 try {
17985 root2 = parser2(this._css, this._opts);
17986 } catch (error) {
17987 this.error = error;
17988 }
17989 if (this.error) {
17990 throw this.error;
17991 } else {
17992 this._root = root2;
17993 return root2;
17994 }
17995 }
17996 },
17997 {
17998 key: Symbol.toStringTag,
17999 get: function get() {
18000 return "NoWorkResult";
18001 }
18002 }
18003 ]);
18004 return NoWorkResult2;
18005 }();
18006 var noWorkResult = NoWorkResult$1;
18007 NoWorkResult$1.default = NoWorkResult$1;
18008 var NoWorkResult22 = noWorkResult;
18009 var LazyResult$1 = lazyResult;
18010 var Document$1 = document$1$2;
18011 var Root$2 = root;
18012 var Processor$1 = /*#__PURE__*/ function() {
18013 function Processor2(plugins) {
18014 if (plugins === void 0) plugins = [];
18015 this.version = "8.4.38";
18016 this.plugins = this.normalize(plugins);
18017 }
18018 var _proto = Processor2.prototype;
18019 _proto.normalize = function normalize(plugins) {
18020 var normalized = [];
18021 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
18022 var i2 = _step.value;
18023 if (i2.postcss === true) {
18024 i2 = i2();
18025 } else if (i2.postcss) {
18026 i2 = i2.postcss;
18027 }
18028 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
18029 normalized = normalized.concat(i2.plugins);
18030 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
18031 normalized.push(i2);
18032 } else if (typeof i2 === "function") {
18033 normalized.push(i2);
18034 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
18035 if (true) {
18036 throw new Error("PostCSS syntaxes cannot be used as plugins. Instead, please use one of the syntax/parser/stringifier options as outlined in your PostCSS runner documentation.");
18037 }
18038 } else {
18039 throw new Error(i2 + " is not a PostCSS plugin");
18040 }
18041 }
18042 return normalized;
18043 };
18044 _proto.process = function process1(css, opts) {
18045 if (opts === void 0) opts = {};
18046 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
18047 return new NoWorkResult22(this, css, opts);
18048 } else {
18049 return new LazyResult$1(this, css, opts);
18050 }
18051 };
18052 _proto.use = function use(plugin22) {
18053 this.plugins = this.plugins.concat(this.normalize([
18054 plugin22
18055 ]));
18056 return this;
18057 };
18058 return Processor2;
18059 }();
18060 var processor = Processor$1;
18061 Processor$1.default = Processor$1;
18062 Root$2.registerProcessor(Processor$1);
18063 Document$1.registerProcessor(Processor$1);
18064 var Declaration$1 = declaration;
18065 var PreviousMap22 = previousMap;
18066 var Comment$1 = comment;
18067 var AtRule$1 = atRule;
18068 var Input$1 = input;
18069 var Root$1 = root;
18070 var Rule$1 = rule;
18071 function fromJSON$1(json, inputs) {
18072 if (Array.isArray(json)) return json.map(function(n2) {
18073 return fromJSON$1(n2);
18074 });
18075 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
18076 "inputs"
18077 ]);
18078 if (ownInputs) {
18079 inputs = [];
18080 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
18081 var input2 = _step.value;
18082 var inputHydrated = _extends({}, input2, {
18083 __proto__: Input$1.prototype
18084 });
18085 if (inputHydrated.map) {
18086 inputHydrated.map = _extends({}, inputHydrated.map, {
18087 __proto__: PreviousMap22.prototype
18088 });
18089 }
18090 inputs.push(inputHydrated);
18091 }
18092 }
18093 if (defaults.nodes) {
18094 defaults.nodes = json.nodes.map(function(n2) {
18095 return fromJSON$1(n2, inputs);
18096 });
18097 }
18098 if (defaults.source) {
18099 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
18100 "inputId"
18101 ]);
18102 defaults.source = source;
18103 if (inputId != null) {
18104 defaults.source.input = inputs[inputId];
18105 }
18106 }
18107 if (defaults.type === "root") {
18108 return new Root$1(defaults);
18109 } else if (defaults.type === "decl") {
18110 return new Declaration$1(defaults);
18111 } else if (defaults.type === "rule") {
18112 return new Rule$1(defaults);
18113 } else if (defaults.type === "comment") {
18114 return new Comment$1(defaults);
18115 } else if (defaults.type === "atrule") {
18116 return new AtRule$1(defaults);
18117 } else {
18118 throw new Error("Unknown node type: " + json.type);
18119 }
18120 }
18121 var fromJSON_1 = fromJSON$1;
18122 fromJSON$1.default = fromJSON$1;
18123 var CssSyntaxError22 = cssSyntaxError;
18124 var Declaration22 = declaration;
18125 var LazyResult22 = lazyResult;
18126 var Container22 = container;
18127 var Processor22 = processor;
18128 var stringify = stringify_1;
18129 var fromJSON = fromJSON_1;
18130 var Document222 = document$1$2;
18131 var Warning22 = warning;
18132 var Comment22 = comment;
18133 var AtRule22 = atRule;
18134 var Result22 = result;
18135 var Input22 = input;
18136 var parse = parse_1;
18137 var list = list_1;
18138 var Rule22 = rule;
18139 var Root22 = root;
18140 var Node22 = node;
18141 function postcss() {
18142 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
18143 plugins[_key] = arguments[_key];
18144 }
18145 if (plugins.length === 1 && Array.isArray(plugins[0])) {
18146 plugins = plugins[0];
18147 }
18148 return new Processor22(plugins);
18149 }
18150 postcss.plugin = function plugin2(name, initializer) {
18151 var warningPrinted = false;
18152 function creator() {
18153 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18154 args[_key] = arguments[_key];
18155 }
18156 if (console && console.warn && !warningPrinted) {
18157 warningPrinted = true;
18158 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
18159 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
18160 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
18161 }
18162 }
18163 var transformer = initializer.apply(void 0, [].concat(args));
18164 transformer.postcssPlugin = name;
18165 transformer.postcssVersion = new Processor22().version;
18166 return transformer;
18167 }
18168 var cache;
18169 Object.defineProperty(creator, "postcss", {
18170 get: function get() {
18171 if (!cache) cache = creator();
18172 return cache;
18173 }
18174 });
18175 creator.process = function(css, processOpts, pluginOpts) {
18176 return postcss([
18177 creator(pluginOpts)
18178 ]).process(css, processOpts);
18179 };
18180 return creator;
18181 };
18182 postcss.stringify = stringify;
18183 postcss.parse = parse;
18184 postcss.fromJSON = fromJSON;
18185 postcss.list = list;
18186 postcss.comment = function(defaults) {
18187 return new Comment22(defaults);
18188 };
18189 postcss.atRule = function(defaults) {
18190 return new AtRule22(defaults);
18191 };
18192 postcss.decl = function(defaults) {
18193 return new Declaration22(defaults);
18194 };
18195 postcss.rule = function(defaults) {
18196 return new Rule22(defaults);
18197 };
18198 postcss.root = function(defaults) {
18199 return new Root22(defaults);
18200 };
18201 postcss.document = function(defaults) {
18202 return new Document222(defaults);
18203 };
18204 postcss.CssSyntaxError = CssSyntaxError22;
18205 postcss.Declaration = Declaration22;
18206 postcss.Container = Container22;
18207 postcss.Processor = Processor22;
18208 postcss.Document = Document222;
18209 postcss.Comment = Comment22;
18210 postcss.Warning = Warning22;
18211 postcss.AtRule = AtRule22;
18212 postcss.Result = Result22;
18213 postcss.Input = Input22;
18214 postcss.Rule = Rule22;
18215 postcss.Root = Root22;
18216 postcss.Node = Node22;
18217 LazyResult22.registerPostcss(postcss);
18218 var postcss_1 = postcss;
18219 postcss.default = postcss;
18220 var postcss$1 = /* @__PURE__ */ getDefaultExportFromCjs(postcss_1);
18221 postcss$1.stringify;
18222 postcss$1.fromJSON;
18223 postcss$1.plugin;
18224 postcss$1.parse;
18225 postcss$1.list;
18226 postcss$1.document;
18227 postcss$1.comment;
18228 postcss$1.atRule;
18229 postcss$1.rule;
18230 postcss$1.decl;
18231 postcss$1.root;
18232 postcss$1.CssSyntaxError;
18233 postcss$1.Declaration;
18234 postcss$1.Container;
18235 postcss$1.Processor;
18236 postcss$1.Document;
18237 postcss$1.Comment;
18238 postcss$1.Warning;
18239 postcss$1.AtRule;
18240 postcss$1.Result;
18241 postcss$1.Input;
18242 postcss$1.Rule;
18243 postcss$1.Root;
18244 postcss$1.Node;
18245 var BaseRRNode = /*#__PURE__*/ function() {
18246 function BaseRRNode() {
18247 for(var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++){
18248 _args[_key] = arguments[_key];
18249 }
18250 __publicField2(this, "parentElement", null);
18251 __publicField2(this, "parentNode", null);
18252 __publicField2(this, "ownerDocument");
18253 __publicField2(this, "firstChild", null);
18254 __publicField2(this, "lastChild", null);
18255 __publicField2(this, "previousSibling", null);
18256 __publicField2(this, "nextSibling", null);
18257 __publicField2(this, "ELEMENT_NODE", 1);
18258 __publicField2(this, "TEXT_NODE", 3);
18259 __publicField2(this, "nodeType");
18260 __publicField2(this, "nodeName");
18261 __publicField2(this, "RRNodeType");
18262 }
18263 var _proto = BaseRRNode.prototype;
18264 _proto.contains = function contains(node2) {
18265 if (!_instanceof(node2, BaseRRNode)) return false;
18266 else if (node2.ownerDocument !== this.ownerDocument) return false;
18267 else if (node2 === this) return true;
18268 while(node2.parentNode){
18269 if (node2.parentNode === this) return true;
18270 node2 = node2.parentNode;
18271 }
18272 return false;
18273 };
18274 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18275 _proto.appendChild = function appendChild(_newChild) {
18276 throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.");
18277 };
18278 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18279 _proto.insertBefore = function insertBefore(_newChild, _refChild) {
18280 throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.");
18281 };
18282 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18283 _proto.removeChild = function removeChild(_node) {
18284 throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.");
18285 };
18286 _proto.toString = function toString() {
18287 return "RRNode";
18288 };
18289 _create_class(BaseRRNode, [
18290 {
18291 key: "childNodes",
18292 get: function get() {
18293 var childNodes2 = [];
18294 var childIterator = this.firstChild;
18295 while(childIterator){
18296 childNodes2.push(childIterator);
18297 childIterator = childIterator.nextSibling;
18298 }
18299 return childNodes2;
18300 }
18301 }
18302 ]);
18303 return BaseRRNode;
18304 }();
18305 var testableAccessors = {
18306 Node: [
18307 "childNodes",
18308 "parentNode",
18309 "parentElement",
18310 "textContent"
18311 ],
18312 ShadowRoot: [
18313 "host",
18314 "styleSheets"
18315 ],
18316 Element: [
18317 "shadowRoot",
18318 "querySelector",
18319 "querySelectorAll"
18320 ],
18321 MutationObserver: []
18322 };
18323 var testableMethods = {
18324 Node: [
18325 "contains",
18326 "getRootNode"
18327 ],
18328 ShadowRoot: [
18329 "getSelection"
18330 ],
18331 Element: [],
18332 MutationObserver: [
18333 "constructor"
18334 ]
18335 };
18336 var untaintedBasePrototype = {};
18337 var isAngularZonePresent = function() {
18338 return !!globalThis.Zone;
18339 };
18340 function getUntaintedPrototype(key) {
18341 if (untaintedBasePrototype[key]) return untaintedBasePrototype[key];
18342 var defaultObj = globalThis[key];
18343 var defaultPrototype = defaultObj.prototype;
18344 var accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
18345 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
18346 accessorNames.every(function(accessor) {
18347 var _a2, _b;
18348 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
18349 }));
18350 var methodNames = key in testableMethods ? testableMethods[key] : void 0;
18351 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
18352 function(method) {
18353 var _a2;
18354 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
18355 }));
18356 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {
18357 untaintedBasePrototype[key] = defaultObj.prototype;
18358 return defaultObj.prototype;
18359 }
18360 try {
18361 var iframeEl = document.createElement("iframe");
18362 document.body.appendChild(iframeEl);
18363 var win = iframeEl.contentWindow;
18364 if (!win) return defaultObj.prototype;
18365 var untaintedObject = win[key].prototype;
18366 document.body.removeChild(iframeEl);
18367 if (!untaintedObject) return defaultPrototype;
18368 return untaintedBasePrototype[key] = untaintedObject;
18369 } catch (e) {
18370 return defaultPrototype;
18371 }
18372 }
18373 var untaintedAccessorCache = {};
18374 function getUntaintedAccessor(key, instance, accessor) {
18375 var _a2;
18376 var cacheKey = key + "." + String(accessor);
18377 if (untaintedAccessorCache[cacheKey]) return untaintedAccessorCache[cacheKey].call(instance);
18378 var untaintedPrototype = getUntaintedPrototype(key);
18379 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
18380 if (!untaintedAccessor) return instance[accessor];
18381 untaintedAccessorCache[cacheKey] = untaintedAccessor;
18382 return untaintedAccessor.call(instance);
18383 }
18384 var untaintedMethodCache = {};
18385 function getUntaintedMethod(key, instance, method) {
18386 var cacheKey = key + "." + String(method);
18387 if (untaintedMethodCache[cacheKey]) return untaintedMethodCache[cacheKey].bind(instance);
18388 var untaintedPrototype = getUntaintedPrototype(key);
18389 var untaintedMethod = untaintedPrototype[method];
18390 if (typeof untaintedMethod !== "function") return instance[method];
18391 untaintedMethodCache[cacheKey] = untaintedMethod;
18392 return untaintedMethod.bind(instance);
18393 }
18394 function childNodes(n2) {
18395 return getUntaintedAccessor("Node", n2, "childNodes");
18396 }
18397 function parentNode(n2) {
18398 return getUntaintedAccessor("Node", n2, "parentNode");
18399 }
18400 function parentElement(n2) {
18401 return getUntaintedAccessor("Node", n2, "parentElement");
18402 }
18403 function textContent(n2) {
18404 return getUntaintedAccessor("Node", n2, "textContent");
18405 }
18406 function contains(n2, other) {
18407 return getUntaintedMethod("Node", n2, "contains")(other);
18408 }
18409 function getRootNode(n2) {
18410 return getUntaintedMethod("Node", n2, "getRootNode")();
18411 }
18412 function host(n2) {
18413 if (!n2 || !("host" in n2)) return null;
18414 return getUntaintedAccessor("ShadowRoot", n2, "host");
18415 }
18416 function styleSheets(n2) {
18417 return n2.styleSheets;
18418 }
18419 function shadowRoot(n2) {
18420 if (!n2 || !("shadowRoot" in n2)) return null;
18421 return getUntaintedAccessor("Element", n2, "shadowRoot");
18422 }
18423 function querySelector(n2, selectors) {
18424 return getUntaintedAccessor("Element", n2, "querySelector")(selectors);
18425 }
18426 function querySelectorAll(n2, selectors) {
18427 return getUntaintedAccessor("Element", n2, "querySelectorAll")(selectors);
18428 }
18429 function mutationObserverCtor() {
18430 return getUntaintedPrototype("MutationObserver").constructor;
18431 }
18432 function patch(source, name, replacement) {
18433 try {
18434 if (!(name in source)) {
18435 return function() {};
18436 }
18437 var original = source[name];
18438 var wrapped = replacement(original);
18439 if (typeof wrapped === "function") {
18440 wrapped.prototype = wrapped.prototype || {};
18441 Object.defineProperties(wrapped, {
18442 __rrweb_original__: {
18443 enumerable: false,
18444 value: original
18445 }
18446 });
18447 }
18448 source[name] = wrapped;
18449 return function() {
18450 source[name] = original;
18451 };
18452 } catch (e) {
18453 return function() {};
18454 }
18455 }
18456 var index = {
18457 childNodes: childNodes,
18458 parentNode: parentNode,
18459 parentElement: parentElement,
18460 textContent: textContent,
18461 contains: contains,
18462 getRootNode: getRootNode,
18463 host: host,
18464 styleSheets: styleSheets,
18465 shadowRoot: shadowRoot,
18466 querySelector: querySelector,
18467 querySelectorAll: querySelectorAll,
18468 mutationObserver: mutationObserverCtor,
18469 patch: patch
18470 };
18471 function on(type, fn, target) {
18472 if (target === void 0) target = document;
18473 var options = {
18474 capture: true,
18475 passive: true
18476 };
18477 target.addEventListener(type, fn, options);
18478 return function() {
18479 return target.removeEventListener(type, fn, options);
18480 };
18481 }
18482 var DEPARTED_MIRROR_ACCESS_WARNING = "Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";
18483 var _mirror = {
18484 map: {},
18485 getId: function getId() {
18486 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18487 return -1;
18488 },
18489 getNode: function getNode() {
18490 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18491 return null;
18492 },
18493 removeNodeFromMap: function removeNodeFromMap() {
18494 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18495 },
18496 has: function has() {
18497 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18498 return false;
18499 },
18500 reset: function reset() {
18501 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18502 }
18503 };
18504 if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
18505 _mirror = new Proxy(_mirror, {
18506 get: function get(target, prop, receiver) {
18507 if (prop === "map") {
18508 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18509 }
18510 return Reflect.get(target, prop, receiver);
18511 }
18512 });
18513 }
18514 function throttle(func, wait, options) {
18515 if (options === void 0) options = {};
18516 var timeout = null;
18517 var previous = 0;
18518 return function() {
18519 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18520 args[_key] = arguments[_key];
18521 }
18522 var now = Date.now();
18523 if (!previous && options.leading === false) {
18524 previous = now;
18525 }
18526 var remaining = wait - (now - previous);
18527 var context = this;
18528 if (remaining <= 0 || remaining > wait) {
18529 if (timeout) {
18530 clearTimeout(timeout);
18531 timeout = null;
18532 }
18533 previous = now;
18534 func.apply(context, args);
18535 } else if (!timeout && options.trailing !== false) {
18536 timeout = setTimeout(function() {
18537 previous = options.leading === false ? 0 : Date.now();
18538 timeout = null;
18539 func.apply(context, args);
18540 }, remaining);
18541 }
18542 };
18543 }
18544 function hookSetter(target, key, d, isRevoked, win) {
18545 if (win === void 0) win = window;
18546 var original = win.Object.getOwnPropertyDescriptor(target, key);
18547 win.Object.defineProperty(target, key, isRevoked ? d : {
18548 set: function set(value) {
18549 var _this = this;
18550 setTimeout(function() {
18551 d.set.call(_this, value);
18552 }, 0);
18553 if (original && original.set) {
18554 original.set.call(this, value);
18555 }
18556 }
18557 });
18558 return function() {
18559 return hookSetter(target, key, original || {}, true);
18560 };
18561 }
18562 var nowTimestamp = Date.now;
18563 if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
18564 nowTimestamp = function() {
18565 return /* @__PURE__ */ new Date().getTime();
18566 };
18567 }
18568 function getWindowScroll(win) {
18569 var _a2, _b, _c, _d;
18570 var doc = win.document;
18571 return {
18572 left: doc.scrollingElement ? doc.scrollingElement.scrollLeft : win.pageXOffset !== void 0 ? win.pageXOffset : doc.documentElement.scrollLeft || (doc == null ? void 0 : doc.body) && ((_a2 = index.parentElement(doc.body)) == null ? void 0 : _a2.scrollLeft) || ((_b = doc == null ? void 0 : doc.body) == null ? void 0 : _b.scrollLeft) || 0,
18573 top: doc.scrollingElement ? doc.scrollingElement.scrollTop : win.pageYOffset !== void 0 ? win.pageYOffset : (doc == null ? void 0 : doc.documentElement.scrollTop) || (doc == null ? void 0 : doc.body) && ((_c = index.parentElement(doc.body)) == null ? void 0 : _c.scrollTop) || ((_d = doc == null ? void 0 : doc.body) == null ? void 0 : _d.scrollTop) || 0
18574 };
18575 }
18576 function getWindowHeight() {
18577 return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
18578 }
18579 function getWindowWidth() {
18580 return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
18581 }
18582 function closestElementOfNode(node2) {
18583 if (!node2) {
18584 return null;
18585 }
18586 var el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index.parentElement(node2);
18587 return el;
18588 }
18589 function isBlocked(node2, blockClass, blockSelector, checkAncestors) {
18590 if (!node2) {
18591 return false;
18592 }
18593 var el = closestElementOfNode(node2);
18594 if (!el) {
18595 return false;
18596 }
18597 try {
18598 if (typeof blockClass === "string") {
18599 if (el.classList.contains(blockClass)) return true;
18600 if (checkAncestors && el.closest("." + blockClass) !== null) return true;
18601 } else {
18602 if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
18603 }
18604 } catch (e2) {}
18605 if (blockSelector) {
18606 if (el.matches(blockSelector)) return true;
18607 if (checkAncestors && el.closest(blockSelector) !== null) return true;
18608 }
18609 return false;
18610 }
18611 function isSerialized(n2, mirror2) {
18612 return mirror2.getId(n2) !== -1;
18613 }
18614 function isIgnored(n2, mirror2, slimDOMOptions) {
18615 if (n2.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
18616 return true;
18617 }
18618 return mirror2.getId(n2) === IGNORED_NODE;
18619 }
18620 function isAncestorRemoved(target, mirror2) {
18621 if (isShadowRoot(target)) {
18622 return false;
18623 }
18624 var id = mirror2.getId(target);
18625 if (!mirror2.has(id)) {
18626 return true;
18627 }
18628 var parent = index.parentNode(target);
18629 if (parent && parent.nodeType === target.DOCUMENT_NODE) {
18630 return false;
18631 }
18632 if (!parent) {
18633 return true;
18634 }
18635 return isAncestorRemoved(parent, mirror2);
18636 }
18637 function legacy_isTouchEvent(event) {
18638 return Boolean(event.changedTouches);
18639 }
18640 function polyfill$1(win) {
18641 if (win === void 0) win = window;
18642 if ("NodeList" in win && !win.NodeList.prototype.forEach) {
18643 win.NodeList.prototype.forEach = Array.prototype.forEach;
18644 }
18645 if ("DOMTokenList" in win && !win.DOMTokenList.prototype.forEach) {
18646 win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
18647 }
18648 }
18649 function isSerializedIframe(n2, mirror2) {
18650 return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
18651 }
18652 function isSerializedStylesheet(n2, mirror2) {
18653 return Boolean(n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2));
18654 }
18655 function hasShadowRoot(n2) {
18656 if (!n2) return false;
18657 if (_instanceof(n2, BaseRRNode) && "shadowRoot" in n2) {
18658 return Boolean(n2.shadowRoot);
18659 }
18660 return Boolean(index.shadowRoot(n2));
18661 }
18662 var StyleSheetMirror = /*#__PURE__*/ function() {
18663 function StyleSheetMirror() {
18664 __publicField(this, "id", 1);
18665 __publicField(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
18666 __publicField(this, "idStyleMap", /* @__PURE__ */ new Map());
18667 }
18668 var _proto = StyleSheetMirror.prototype;
18669 _proto.getId = function getId(stylesheet) {
18670 var _this_styleIDMap_get;
18671 return (_this_styleIDMap_get = this.styleIDMap.get(stylesheet)) != null ? _this_styleIDMap_get : -1;
18672 };
18673 _proto.has = function has(stylesheet) {
18674 return this.styleIDMap.has(stylesheet);
18675 };
18676 /**
18677 * @returns If the stylesheet is in the mirror, returns the id of the stylesheet. If not, return the new assigned id.
18678 */ _proto.add = function add(stylesheet, id) {
18679 if (this.has(stylesheet)) return this.getId(stylesheet);
18680 var newId;
18681 if (id === void 0) {
18682 newId = this.id++;
18683 } else newId = id;
18684 this.styleIDMap.set(stylesheet, newId);
18685 this.idStyleMap.set(newId, stylesheet);
18686 return newId;
18687 };
18688 _proto.getStyle = function getStyle(id) {
18689 return this.idStyleMap.get(id) || null;
18690 };
18691 _proto.reset = function reset() {
18692 this.styleIDMap = /* @__PURE__ */ new WeakMap();
18693 this.idStyleMap = /* @__PURE__ */ new Map();
18694 this.id = 1;
18695 };
18696 _proto.generateId = function generateId() {
18697 return this.id++;
18698 };
18699 return StyleSheetMirror;
18700 }();
18701 function getShadowHost(n2) {
18702 var _a2;
18703 var shadowHost = null;
18704 if ("getRootNode" in n2 && ((_a2 = index.getRootNode(n2)) == null ? void 0 : _a2.nodeType) === Node.DOCUMENT_FRAGMENT_NODE && index.host(index.getRootNode(n2))) shadowHost = index.host(index.getRootNode(n2));
18705 return shadowHost;
18706 }
18707 function getRootShadowHost(n2) {
18708 var rootShadowHost = n2;
18709 var shadowHost;
18710 while(shadowHost = getShadowHost(rootShadowHost))rootShadowHost = shadowHost;
18711 return rootShadowHost;
18712 }
18713 function shadowHostInDom(n2) {
18714 var doc = n2.ownerDocument;
18715 if (!doc) return false;
18716 var shadowHost = getRootShadowHost(n2);
18717 return index.contains(doc, shadowHost);
18718 }
18719 function inDom(n2) {
18720 var doc = n2.ownerDocument;
18721 if (!doc) return false;
18722 return index.contains(doc, n2) || shadowHostInDom(n2);
18723 }
18724 var EventType = /* @__PURE__ */ function(EventType2) {
18725 EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
18726 EventType2[EventType2["Load"] = 1] = "Load";
18727 EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
18728 EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
18729 EventType2[EventType2["Meta"] = 4] = "Meta";
18730 EventType2[EventType2["Custom"] = 5] = "Custom";
18731 EventType2[EventType2["Plugin"] = 6] = "Plugin";
18732 return EventType2;
18733 }(EventType || {});
18734 var IncrementalSource = /* @__PURE__ */ function(IncrementalSource2) {
18735 IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
18736 IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
18737 IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
18738 IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
18739 IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
18740 IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
18741 IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
18742 IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
18743 IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
18744 IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
18745 IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
18746 IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
18747 IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
18748 IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
18749 IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
18750 IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
18751 IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
18752 return IncrementalSource2;
18753 }(IncrementalSource || {});
18754 var MouseInteractions = /* @__PURE__ */ function(MouseInteractions2) {
18755 MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
18756 MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
18757 MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
18758 MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
18759 MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
18760 MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
18761 MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
18762 MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
18763 MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
18764 MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
18765 MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
18766 return MouseInteractions2;
18767 }(MouseInteractions || {});
18768 var PointerTypes = /* @__PURE__ */ function(PointerTypes2) {
18769 PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
18770 PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
18771 PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
18772 return PointerTypes2;
18773 }(PointerTypes || {});
18774 var CanvasContext = /* @__PURE__ */ function(CanvasContext2) {
18775 CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
18776 CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
18777 CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
18778 return CanvasContext2;
18779 }(CanvasContext || {});
18780 var MediaInteractions = /* @__PURE__ */ function(MediaInteractions2) {
18781 MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
18782 MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
18783 MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
18784 MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
18785 MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
18786 return MediaInteractions2;
18787 }(MediaInteractions || {});
18788 var NodeType = /* @__PURE__ */ function(NodeType2) {
18789 NodeType2[NodeType2["Document"] = 0] = "Document";
18790 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
18791 NodeType2[NodeType2["Element"] = 2] = "Element";
18792 NodeType2[NodeType2["Text"] = 3] = "Text";
18793 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
18794 NodeType2[NodeType2["Comment"] = 5] = "Comment";
18795 return NodeType2;
18796 }(NodeType || {});
18797 function isNodeInLinkedList(n2) {
18798 return "__ln" in n2;
18799 }
18800 var DoubleLinkedList = /*#__PURE__*/ function() {
18801 function DoubleLinkedList() {
18802 __publicField(this, "length", 0);
18803 __publicField(this, "head", null);
18804 __publicField(this, "tail", null);
18805 }
18806 var _proto = DoubleLinkedList.prototype;
18807 _proto.get = function get(position) {
18808 if (position >= this.length) {
18809 throw new Error("Position outside of list range");
18810 }
18811 var current = this.head;
18812 for(var index2 = 0; index2 < position; index2++){
18813 current = (current == null ? void 0 : current.next) || null;
18814 }
18815 return current;
18816 };
18817 _proto.addNode = function addNode(n2) {
18818 var node2 = {
18819 value: n2,
18820 previous: null,
18821 next: null
18822 };
18823 n2.__ln = node2;
18824 if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
18825 var current = n2.previousSibling.__ln.next;
18826 node2.next = current;
18827 node2.previous = n2.previousSibling.__ln;
18828 n2.previousSibling.__ln.next = node2;
18829 if (current) {
18830 current.previous = node2;
18831 }
18832 } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
18833 var current1 = n2.nextSibling.__ln.previous;
18834 node2.previous = current1;
18835 node2.next = n2.nextSibling.__ln;
18836 n2.nextSibling.__ln.previous = node2;
18837 if (current1) {
18838 current1.next = node2;
18839 }
18840 } else {
18841 if (this.head) {
18842 this.head.previous = node2;
18843 }
18844 node2.next = this.head;
18845 this.head = node2;
18846 }
18847 if (node2.next === null) {
18848 this.tail = node2;
18849 }
18850 this.length++;
18851 };
18852 _proto.removeNode = function removeNode(n2) {
18853 var current = n2.__ln;
18854 if (!this.head) {
18855 return;
18856 }
18857 if (!current.previous) {
18858 this.head = current.next;
18859 if (this.head) {
18860 this.head.previous = null;
18861 } else {
18862 this.tail = null;
18863 }
18864 } else {
18865 current.previous.next = current.next;
18866 if (current.next) {
18867 current.next.previous = current.previous;
18868 } else {
18869 this.tail = current.previous;
18870 }
18871 }
18872 if (n2.__ln) {
18873 delete n2.__ln;
18874 }
18875 this.length--;
18876 };
18877 return DoubleLinkedList;
18878 }();
18879 var moveKey = function(id, parentId) {
18880 return id + "@" + parentId;
18881 };
18882 var MutationBuffer = /*#__PURE__*/ function() {
18883 function MutationBuffer() {
18884 var _this = this;
18885 __publicField(this, "frozen", false);
18886 __publicField(this, "locked", false);
18887 __publicField(this, "texts", []);
18888 __publicField(this, "attributes", []);
18889 __publicField(this, "attributeMap", /* @__PURE__ */ new WeakMap());
18890 __publicField(this, "removes", []);
18891 __publicField(this, "mapRemoves", []);
18892 __publicField(this, "movedMap", {});
18893 /**
18894 * the browser MutationObserver emits multiple mutations after
18895 * a delay for performance reasons, making tracing added nodes hard
18896 * in our `processMutations` callback function.
18897 * For example, if we append an element el_1 into body, and then append
18898 * another element el_2 into el_1, these two mutations may be passed to the
18899 * callback function together when the two operations were done.
18900 * Generally we need to trace child nodes of newly added nodes, but in this
18901 * case if we count el_2 as el_1's child node in the first mutation record,
18902 * then we will count el_2 again in the second mutation record which was
18903 * duplicated.
18904 * To avoid of duplicate counting added nodes, we use a Set to store
18905 * added nodes and its child nodes during iterate mutation records. Then
18906 * collect added nodes from the Set which have no duplicate copy. But
18907 * this also causes newly added nodes will not be serialized with id ASAP,
18908 * which means all the id related calculation should be lazy too.
18909 */ __publicField(this, "addedSet", /* @__PURE__ */ new Set());
18910 __publicField(this, "movedSet", /* @__PURE__ */ new Set());
18911 __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
18912 __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
18913 __publicField(this, "mutationCb");
18914 __publicField(this, "blockClass");
18915 __publicField(this, "blockSelector");
18916 __publicField(this, "maskTextClass");
18917 __publicField(this, "maskTextSelector");
18918 __publicField(this, "inlineStylesheet");
18919 __publicField(this, "maskInputOptions");
18920 __publicField(this, "maskTextFn");
18921 __publicField(this, "maskInputFn");
18922 __publicField(this, "keepIframeSrcFn");
18923 __publicField(this, "recordCanvas");
18924 __publicField(this, "inlineImages");
18925 __publicField(this, "slimDOMOptions");
18926 __publicField(this, "dataURLOptions");
18927 __publicField(this, "doc");
18928 __publicField(this, "mirror");
18929 __publicField(this, "iframeManager");
18930 __publicField(this, "stylesheetManager");
18931 __publicField(this, "shadowDomManager");
18932 __publicField(this, "canvasManager");
18933 __publicField(this, "processedNodeManager");
18934 __publicField(this, "unattachedDoc");
18935 __publicField(this, "processMutations", function(mutations) {
18936 mutations.forEach(_this.processMutation);
18937 _this.emit();
18938 });
18939 __publicField(this, "emit", function() {
18940 if (_this.frozen || _this.locked) {
18941 return;
18942 }
18943 var adds = [];
18944 var addedIds = /* @__PURE__ */ new Set();
18945 var addList = new DoubleLinkedList();
18946 var getNextId = function(n2) {
18947 var ns = n2;
18948 var nextId = IGNORED_NODE;
18949 while(nextId === IGNORED_NODE){
18950 ns = ns && ns.nextSibling;
18951 nextId = ns && _this.mirror.getId(ns);
18952 }
18953 return nextId;
18954 };
18955 var pushAdd = function(n2) {
18956 var parent = index.parentNode(n2);
18957 if (!parent || !inDom(n2)) {
18958 return;
18959 }
18960 var cssCaptured = false;
18961 if (n2.nodeType === Node.TEXT_NODE) {
18962 var parentTag = parent.tagName;
18963 if (parentTag === "TEXTAREA") {
18964 return;
18965 } else if (parentTag === "STYLE" && _this.addedSet.has(parent)) {
18966 cssCaptured = true;
18967 }
18968 }
18969 var parentId = isShadowRoot(parent) ? _this.mirror.getId(getShadowHost(n2)) : _this.mirror.getId(parent);
18970 var nextId = getNextId(n2);
18971 if (parentId === -1 || nextId === -1) {
18972 return addList.addNode(n2);
18973 }
18974 var sn = serializeNodeWithId(n2, {
18975 doc: _this.doc,
18976 mirror: _this.mirror,
18977 blockClass: _this.blockClass,
18978 blockSelector: _this.blockSelector,
18979 maskTextClass: _this.maskTextClass,
18980 maskTextSelector: _this.maskTextSelector,
18981 skipChild: true,
18982 newlyAddedElement: true,
18983 inlineStylesheet: _this.inlineStylesheet,
18984 maskInputOptions: _this.maskInputOptions,
18985 maskTextFn: _this.maskTextFn,
18986 maskInputFn: _this.maskInputFn,
18987 slimDOMOptions: _this.slimDOMOptions,
18988 dataURLOptions: _this.dataURLOptions,
18989 recordCanvas: _this.recordCanvas,
18990 inlineImages: _this.inlineImages,
18991 onSerialize: function(currentN) {
18992 if (isSerializedIframe(currentN, _this.mirror)) {
18993 _this.iframeManager.addIframe(currentN);
18994 }
18995 if (isSerializedStylesheet(currentN, _this.mirror)) {
18996 _this.stylesheetManager.trackLinkElement(currentN);
18997 }
18998 if (hasShadowRoot(n2)) {
18999 _this.shadowDomManager.addShadowRoot(index.shadowRoot(n2), _this.doc);
19000 }
19001 },
19002 onIframeLoad: function(iframe, childSn) {
19003 _this.iframeManager.attachIframe(iframe, childSn);
19004 _this.shadowDomManager.observeAttachShadow(iframe);
19005 },
19006 onStylesheetLoad: function(link, childSn) {
19007 _this.stylesheetManager.attachLinkElement(link, childSn);
19008 },
19009 cssCaptured: cssCaptured
19010 });
19011 if (sn) {
19012 adds.push({
19013 parentId: parentId,
19014 nextId: nextId,
19015 node: sn
19016 });
19017 addedIds.add(sn.id);
19018 }
19019 };
19020 while(_this.mapRemoves.length){
19021 _this.mirror.removeNodeFromMap(_this.mapRemoves.shift());
19022 }
19023 for(var _iterator = _create_for_of_iterator_helper_loose(_this.movedSet), _step; !(_step = _iterator()).done;){
19024 var n2 = _step.value;
19025 if (isParentRemoved(_this.removesSubTreeCache, n2, _this.mirror) && !_this.movedSet.has(index.parentNode(n2))) {
19026 continue;
19027 }
19028 pushAdd(n2);
19029 }
19030 for(var _iterator1 = _create_for_of_iterator_helper_loose(_this.addedSet), _step1; !(_step1 = _iterator1()).done;){
19031 var n21 = _step1.value;
19032 if (!isAncestorInSet(_this.droppedSet, n21) && !isParentRemoved(_this.removesSubTreeCache, n21, _this.mirror)) {
19033 pushAdd(n21);
19034 } else if (isAncestorInSet(_this.movedSet, n21)) {
19035 pushAdd(n21);
19036 } else {
19037 _this.droppedSet.add(n21);
19038 }
19039 }
19040 var candidate = null;
19041 while(addList.length){
19042 var node2 = null;
19043 if (candidate) {
19044 var parentId = _this.mirror.getId(index.parentNode(candidate.value));
19045 var nextId = getNextId(candidate.value);
19046 if (parentId !== -1 && nextId !== -1) {
19047 node2 = candidate;
19048 }
19049 }
19050 if (!node2) {
19051 var tailNode = addList.tail;
19052 while(tailNode){
19053 var _node = tailNode;
19054 tailNode = tailNode.previous;
19055 if (_node) {
19056 var parentId1 = _this.mirror.getId(index.parentNode(_node.value));
19057 var nextId1 = getNextId(_node.value);
19058 if (nextId1 === -1) continue;
19059 else if (parentId1 !== -1) {
19060 node2 = _node;
19061 break;
19062 } else {
19063 var unhandledNode = _node.value;
19064 var parent = index.parentNode(unhandledNode);
19065 if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
19066 var shadowHost = index.host(parent);
19067 var parentId2 = _this.mirror.getId(shadowHost);
19068 if (parentId2 !== -1) {
19069 node2 = _node;
19070 break;
19071 }
19072 }
19073 }
19074 }
19075 }
19076 }
19077 if (!node2) {
19078 while(addList.head){
19079 addList.removeNode(addList.head.value);
19080 }
19081 break;
19082 }
19083 candidate = node2.previous;
19084 addList.removeNode(node2.value);
19085 pushAdd(node2.value);
19086 }
19087 var payload = {
19088 texts: _this.texts.map(function(text) {
19089 var n2 = text.node;
19090 var parent = index.parentNode(n2);
19091 if (parent && parent.tagName === "TEXTAREA") {
19092 _this.genTextAreaValueMutation(parent);
19093 }
19094 return {
19095 id: _this.mirror.getId(n2),
19096 value: text.value
19097 };
19098 }).filter(function(text) {
19099 return !addedIds.has(text.id);
19100 }).filter(function(text) {
19101 return _this.mirror.has(text.id);
19102 }),
19103 attributes: _this.attributes.map(function(attribute) {
19104 var attributes = attribute.attributes;
19105 if (typeof attributes.style === "string") {
19106 var diffAsStr = JSON.stringify(attribute.styleDiff);
19107 var unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
19108 if (diffAsStr.length < attributes.style.length) {
19109 if ((diffAsStr + unchangedAsStr).split("var(").length === attributes.style.split("var(").length) {
19110 attributes.style = attribute.styleDiff;
19111 }
19112 }
19113 }
19114 return {
19115 id: _this.mirror.getId(attribute.node),
19116 attributes: attributes
19117 };
19118 }).filter(function(attribute) {
19119 return !addedIds.has(attribute.id);
19120 }).filter(function(attribute) {
19121 return _this.mirror.has(attribute.id);
19122 }),
19123 removes: _this.removes,
19124 adds: adds
19125 };
19126 if (!payload.texts.length && !payload.attributes.length && !payload.removes.length && !payload.adds.length) {
19127 return;
19128 }
19129 _this.texts = [];
19130 _this.attributes = [];
19131 _this.attributeMap = /* @__PURE__ */ new WeakMap();
19132 _this.removes = [];
19133 _this.addedSet = /* @__PURE__ */ new Set();
19134 _this.movedSet = /* @__PURE__ */ new Set();
19135 _this.droppedSet = /* @__PURE__ */ new Set();
19136 _this.removesSubTreeCache = /* @__PURE__ */ new Set();
19137 _this.movedMap = {};
19138 _this.mutationCb(payload);
19139 });
19140 __publicField(this, "genTextAreaValueMutation", function(textarea) {
19141 var item = _this.attributeMap.get(textarea);
19142 if (!item) {
19143 item = {
19144 node: textarea,
19145 attributes: {},
19146 styleDiff: {},
19147 _unchangedStyles: {}
19148 };
19149 _this.attributes.push(item);
19150 _this.attributeMap.set(textarea, item);
19151 }
19152 var value = Array.from(index.childNodes(textarea), function(cn) {
19153 return index.textContent(cn) || "";
19154 }).join("");
19155 item.attributes.value = maskInputValue({
19156 element: textarea,
19157 maskInputOptions: _this.maskInputOptions,
19158 tagName: textarea.tagName,
19159 type: getInputType(textarea),
19160 value: value,
19161 maskInputFn: _this.maskInputFn
19162 });
19163 });
19164 __publicField(this, "processMutation", function(m) {
19165 if (isIgnored(m.target, _this.mirror, _this.slimDOMOptions)) {
19166 return;
19167 }
19168 switch(m.type){
19169 case "characterData":
19170 {
19171 var value = index.textContent(m.target);
19172 if (!isBlocked(m.target, _this.blockClass, _this.blockSelector, false) && value !== m.oldValue) {
19173 _this.texts.push({
19174 value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, true) && value ? _this.maskTextFn ? _this.maskTextFn(value, closestElementOfNode(m.target)) : value.replace(/[\S]/g, "*") : value,
19175 node: m.target
19176 });
19177 }
19178 break;
19179 }
19180 case "attributes":
19181 {
19182 var target = m.target;
19183 var attributeName = m.attributeName;
19184 var value1 = m.target.getAttribute(attributeName);
19185 if (attributeName === "value") {
19186 var type = getInputType(target);
19187 value1 = maskInputValue({
19188 element: target,
19189 maskInputOptions: _this.maskInputOptions,
19190 tagName: target.tagName,
19191 type: type,
19192 value: value1,
19193 maskInputFn: _this.maskInputFn
19194 });
19195 }
19196 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || value1 === m.oldValue) {
19197 return;
19198 }
19199 var item = _this.attributeMap.get(m.target);
19200 if (target.tagName === "IFRAME" && attributeName === "src" && !_this.keepIframeSrcFn(value1)) {
19201 if (!target.contentDocument) {
19202 attributeName = "rr_src";
19203 } else {
19204 return;
19205 }
19206 }
19207 if (!item) {
19208 item = {
19209 node: m.target,
19210 attributes: {},
19211 styleDiff: {},
19212 _unchangedStyles: {}
19213 };
19214 _this.attributes.push(item);
19215 _this.attributeMap.set(m.target, item);
19216 }
19217 if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
19218 target.setAttribute("data-rr-is-password", "true");
19219 }
19220 if (!ignoreAttribute(target.tagName, attributeName)) {
19221 item.attributes[attributeName] = transformAttribute(_this.doc, toLowerCase(target.tagName), toLowerCase(attributeName), value1);
19222 if (attributeName === "style") {
19223 if (!_this.unattachedDoc) {
19224 try {
19225 _this.unattachedDoc = document.implementation.createHTMLDocument();
19226 } catch (e2) {
19227 _this.unattachedDoc = _this.doc;
19228 }
19229 }
19230 var old = _this.unattachedDoc.createElement("span");
19231 if (m.oldValue) {
19232 old.setAttribute("style", m.oldValue);
19233 }
19234 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(target.style)), _step; !(_step = _iterator()).done;){
19235 var pname = _step.value;
19236 var newValue = target.style.getPropertyValue(pname);
19237 var newPriority = target.style.getPropertyPriority(pname);
19238 if (newValue !== old.style.getPropertyValue(pname) || newPriority !== old.style.getPropertyPriority(pname)) {
19239 if (newPriority === "") {
19240 item.styleDiff[pname] = newValue;
19241 } else {
19242 item.styleDiff[pname] = [
19243 newValue,
19244 newPriority
19245 ];
19246 }
19247 } else {
19248 item._unchangedStyles[pname] = [
19249 newValue,
19250 newPriority
19251 ];
19252 }
19253 }
19254 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(old.style)), _step1; !(_step1 = _iterator1()).done;){
19255 var pname1 = _step1.value;
19256 if (target.style.getPropertyValue(pname1) === "") {
19257 item.styleDiff[pname1] = false;
19258 }
19259 }
19260 } else if (attributeName === "open" && target.tagName === "DIALOG") {
19261 if (target.matches("dialog:modal")) {
19262 item.attributes["rr_open_mode"] = "modal";
19263 } else {
19264 item.attributes["rr_open_mode"] = "non-modal";
19265 }
19266 }
19267 }
19268 break;
19269 }
19270 case "childList":
19271 {
19272 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, true)) return;
19273 if (m.target.tagName === "TEXTAREA") {
19274 _this.genTextAreaValueMutation(m.target);
19275 return;
19276 }
19277 m.addedNodes.forEach(function(n2) {
19278 return _this.genAdds(n2, m.target);
19279 });
19280 m.removedNodes.forEach(function(n2) {
19281 var nodeId = _this.mirror.getId(n2);
19282 var parentId = isShadowRoot(m.target) ? _this.mirror.getId(index.host(m.target)) : _this.mirror.getId(m.target);
19283 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || isIgnored(n2, _this.mirror, _this.slimDOMOptions) || !isSerialized(n2, _this.mirror)) {
19284 return;
19285 }
19286 if (_this.addedSet.has(n2)) {
19287 deepDelete(_this.addedSet, n2);
19288 _this.droppedSet.add(n2);
19289 } else if (_this.addedSet.has(m.target) && nodeId === -1) ;
19290 else if (isAncestorRemoved(m.target, _this.mirror)) ;
19291 else if (_this.movedSet.has(n2) && _this.movedMap[moveKey(nodeId, parentId)]) {
19292 deepDelete(_this.movedSet, n2);
19293 } else {
19294 _this.removes.push({
19295 parentId: parentId,
19296 id: nodeId,
19297 isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
19298 });
19299 processRemoves(n2, _this.removesSubTreeCache);
19300 }
19301 _this.mapRemoves.push(n2);
19302 });
19303 break;
19304 }
19305 }
19306 });
19307 /**
19308 * Make sure you check if `n`'s parent is blocked before calling this function
19309 * */ __publicField(this, "genAdds", function(n2, target) {
19310 if (_this.processedNodeManager.inOtherBuffer(n2, _this)) return;
19311 if (_this.addedSet.has(n2) || _this.movedSet.has(n2)) return;
19312 if (_this.mirror.hasNode(n2)) {
19313 if (isIgnored(n2, _this.mirror, _this.slimDOMOptions)) {
19314 return;
19315 }
19316 _this.movedSet.add(n2);
19317 var targetId = null;
19318 if (target && _this.mirror.hasNode(target)) {
19319 targetId = _this.mirror.getId(target);
19320 }
19321 if (targetId && targetId !== -1) {
19322 _this.movedMap[moveKey(_this.mirror.getId(n2), targetId)] = true;
19323 }
19324 } else {
19325 _this.addedSet.add(n2);
19326 _this.droppedSet.delete(n2);
19327 }
19328 if (!isBlocked(n2, _this.blockClass, _this.blockSelector, false)) {
19329 index.childNodes(n2).forEach(function(childN) {
19330 return _this.genAdds(childN);
19331 });
19332 if (hasShadowRoot(n2)) {
19333 index.childNodes(index.shadowRoot(n2)).forEach(function(childN) {
19334 _this.processedNodeManager.add(childN, _this);
19335 _this.genAdds(childN, n2);
19336 });
19337 }
19338 }
19339 });
19340 }
19341 var _proto = MutationBuffer.prototype;
19342 _proto.init = function init(options) {
19343 var _this = this;
19344 [
19345 "mutationCb",
19346 "blockClass",
19347 "blockSelector",
19348 "maskTextClass",
19349 "maskTextSelector",
19350 "inlineStylesheet",
19351 "maskInputOptions",
19352 "maskTextFn",
19353 "maskInputFn",
19354 "keepIframeSrcFn",
19355 "recordCanvas",
19356 "inlineImages",
19357 "slimDOMOptions",
19358 "dataURLOptions",
19359 "doc",
19360 "mirror",
19361 "iframeManager",
19362 "stylesheetManager",
19363 "shadowDomManager",
19364 "canvasManager",
19365 "processedNodeManager"
19366 ].forEach(function(key) {
19367 _this[key] = options[key];
19368 });
19369 };
19370 _proto.freeze = function freeze() {
19371 this.frozen = true;
19372 this.canvasManager.freeze();
19373 };
19374 _proto.unfreeze = function unfreeze() {
19375 this.frozen = false;
19376 this.canvasManager.unfreeze();
19377 this.emit();
19378 };
19379 _proto.isFrozen = function isFrozen() {
19380 return this.frozen;
19381 };
19382 _proto.lock = function lock() {
19383 this.locked = true;
19384 this.canvasManager.lock();
19385 };
19386 _proto.unlock = function unlock() {
19387 this.locked = false;
19388 this.canvasManager.unlock();
19389 this.emit();
19390 };
19391 _proto.reset = function reset() {
19392 this.shadowDomManager.reset();
19393 this.canvasManager.reset();
19394 };
19395 return MutationBuffer;
19396 }();
19397 function deepDelete(addsSet, n2) {
19398 addsSet.delete(n2);
19399 index.childNodes(n2).forEach(function(childN) {
19400 return deepDelete(addsSet, childN);
19401 });
19402 }
19403 function processRemoves(n2, cache) {
19404 var queue = [
19405 n2
19406 ];
19407 while(queue.length){
19408 var next = queue.pop();
19409 if (cache.has(next)) continue;
19410 cache.add(next);
19411 index.childNodes(next).forEach(function(n22) {
19412 return queue.push(n22);
19413 });
19414 }
19415 return;
19416 }
19417 function isParentRemoved(removes, n2, mirror2) {
19418 if (removes.size === 0) return false;
19419 return _isParentRemoved(removes, n2);
19420 }
19421 function _isParentRemoved(removes, n2, _mirror2) {
19422 var node2 = index.parentNode(n2);
19423 if (!node2) return false;
19424 return removes.has(node2);
19425 }
19426 function isAncestorInSet(set, n2) {
19427 if (set.size === 0) return false;
19428 return _isAncestorInSet(set, n2);
19429 }
19430 function _isAncestorInSet(set, n2) {
19431 var parent = index.parentNode(n2);
19432 if (!parent) {
19433 return false;
19434 }
19435 if (set.has(parent)) {
19436 return true;
19437 }
19438 return _isAncestorInSet(set, parent);
19439 }
19440 var errorHandler;
19441 function registerErrorHandler(handler) {
19442 errorHandler = handler;
19443 }
19444 function unregisterErrorHandler() {
19445 errorHandler = void 0;
19446 }
19447 var callbackWrapper = function(cb) {
19448 if (!errorHandler) {
19449 return cb;
19450 }
19451 var rrwebWrapped = function() {
19452 for(var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++){
19453 rest[_key] = arguments[_key];
19454 }
19455 try {
19456 return cb.apply(void 0, [].concat(rest));
19457 } catch (error) {
19458 if (errorHandler && errorHandler(error) === true) {
19459 return;
19460 }
19461 throw error;
19462 }
19463 };
19464 return rrwebWrapped;
19465 };
19466 var mutationBuffers = [];
19467 function getEventTarget(event) {
19468 try {
19469 if ("composedPath" in event) {
19470 var path = event.composedPath();
19471 if (path.length) {
19472 return path[0];
19473 }
19474 } else if ("path" in event && event.path.length) {
19475 return event.path[0];
19476 }
19477 } catch (e) {}
19478 return event && event.target;
19479 }
19480 function initMutationObserver(options, rootEl) {
19481 var mutationBuffer = new MutationBuffer();
19482 mutationBuffers.push(mutationBuffer);
19483 mutationBuffer.init(options);
19484 var observer = new (mutationObserverCtor())(callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer)));
19485 observer.observe(rootEl, {
19486 attributes: true,
19487 attributeOldValue: true,
19488 characterData: true,
19489 characterDataOldValue: true,
19490 childList: true,
19491 subtree: true
19492 });
19493 return observer;
19494 }
19495 function initMoveObserver(param) {
19496 var mousemoveCb = param.mousemoveCb, sampling = param.sampling, doc = param.doc, mirror2 = param.mirror;
19497 if (sampling.mousemove === false) {
19498 return function() {};
19499 }
19500 var threshold = typeof sampling.mousemove === "number" ? sampling.mousemove : 50;
19501 var callbackThreshold = typeof sampling.mousemoveCallback === "number" ? sampling.mousemoveCallback : 500;
19502 var positions = [];
19503 var timeBaseline;
19504 var wrappedCb = throttle(callbackWrapper(function(source) {
19505 var totalOffset = Date.now() - timeBaseline;
19506 mousemoveCb(positions.map(function(p) {
19507 p.timeOffset -= totalOffset;
19508 return p;
19509 }), source);
19510 positions = [];
19511 timeBaseline = null;
19512 }), callbackThreshold);
19513 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
19514 var target = getEventTarget(evt);
19515 var _ref = legacy_isTouchEvent(evt) ? evt.changedTouches[0] : evt, clientX = _ref.clientX, clientY = _ref.clientY;
19516 if (!timeBaseline) {
19517 timeBaseline = nowTimestamp();
19518 }
19519 positions.push({
19520 x: clientX,
19521 y: clientY,
19522 id: mirror2.getId(target),
19523 timeOffset: nowTimestamp() - timeBaseline
19524 });
19525 wrappedCb(typeof DragEvent !== "undefined" && _instanceof(evt, DragEvent) ? IncrementalSource.Drag : _instanceof(evt, MouseEvent) ? IncrementalSource.MouseMove : IncrementalSource.TouchMove);
19526 }), threshold, {
19527 trailing: false
19528 }));
19529 var handlers = [
19530 on("mousemove", updatePosition, doc),
19531 on("touchmove", updatePosition, doc),
19532 on("drag", updatePosition, doc)
19533 ];
19534 return callbackWrapper(function() {
19535 handlers.forEach(function(h) {
19536 return h();
19537 });
19538 });
19539 }
19540 function initMouseInteractionObserver(param) {
19541 var mouseInteractionCb = param.mouseInteractionCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
19542 if (sampling.mouseInteraction === false) {
19543 return function() {};
19544 }
19545 var disableMap = sampling.mouseInteraction === true || sampling.mouseInteraction === void 0 ? {} : sampling.mouseInteraction;
19546 var handlers = [];
19547 var currentPointerType = null;
19548 var getHandler = function(eventKey) {
19549 return function(event) {
19550 var target = getEventTarget(event);
19551 if (isBlocked(target, blockClass, blockSelector, true)) {
19552 return;
19553 }
19554 var pointerType = null;
19555 var thisEventKey = eventKey;
19556 if ("pointerType" in event) {
19557 switch(event.pointerType){
19558 case "mouse":
19559 pointerType = PointerTypes.Mouse;
19560 break;
19561 case "touch":
19562 pointerType = PointerTypes.Touch;
19563 break;
19564 case "pen":
19565 pointerType = PointerTypes.Pen;
19566 break;
19567 }
19568 if (pointerType === PointerTypes.Touch) {
19569 if (MouseInteractions[eventKey] === MouseInteractions.MouseDown) {
19570 thisEventKey = "TouchStart";
19571 } else if (MouseInteractions[eventKey] === MouseInteractions.MouseUp) {
19572 thisEventKey = "TouchEnd";
19573 }
19574 } else if (pointerType === PointerTypes.Pen) ;
19575 } else if (legacy_isTouchEvent(event)) {
19576 pointerType = PointerTypes.Touch;
19577 }
19578 if (pointerType !== null) {
19579 currentPointerType = pointerType;
19580 if (thisEventKey.startsWith("Touch") && pointerType === PointerTypes.Touch || thisEventKey.startsWith("Mouse") && pointerType === PointerTypes.Mouse) {
19581 pointerType = null;
19582 }
19583 } else if (MouseInteractions[eventKey] === MouseInteractions.Click) {
19584 pointerType = currentPointerType;
19585 currentPointerType = null;
19586 }
19587 var e2 = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
19588 if (!e2) {
19589 return;
19590 }
19591 var id = mirror2.getId(target);
19592 var clientX = e2.clientX, clientY = e2.clientY;
19593 callbackWrapper(mouseInteractionCb)(_extends({
19594 type: MouseInteractions[thisEventKey],
19595 id: id,
19596 x: clientX,
19597 y: clientY
19598 }, pointerType !== null && {
19599 pointerType: pointerType
19600 }));
19601 };
19602 };
19603 Object.keys(MouseInteractions).filter(function(key) {
19604 return Number.isNaN(Number(key)) && !key.endsWith("_Departed") && disableMap[key] !== false;
19605 }).forEach(function(eventKey) {
19606 var eventName = toLowerCase(eventKey);
19607 var handler = getHandler(eventKey);
19608 if (window.PointerEvent) {
19609 switch(MouseInteractions[eventKey]){
19610 case MouseInteractions.MouseDown:
19611 case MouseInteractions.MouseUp:
19612 eventName = eventName.replace("mouse", "pointer");
19613 break;
19614 case MouseInteractions.TouchStart:
19615 case MouseInteractions.TouchEnd:
19616 return;
19617 }
19618 }
19619 handlers.push(on(eventName, handler, doc));
19620 });
19621 return callbackWrapper(function() {
19622 handlers.forEach(function(h) {
19623 return h();
19624 });
19625 });
19626 }
19627 function initScrollObserver(param) {
19628 var scrollCb = param.scrollCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
19629 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
19630 var target = getEventTarget(evt);
19631 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
19632 return;
19633 }
19634 var id = mirror2.getId(target);
19635 if (target === doc && doc.defaultView) {
19636 var scrollLeftTop = getWindowScroll(doc.defaultView);
19637 scrollCb({
19638 id: id,
19639 x: scrollLeftTop.left,
19640 y: scrollLeftTop.top
19641 });
19642 } else {
19643 scrollCb({
19644 id: id,
19645 x: target.scrollLeft,
19646 y: target.scrollTop
19647 });
19648 }
19649 }), sampling.scroll || 100));
19650 return on("scroll", updatePosition, doc);
19651 }
19652 function initViewportResizeObserver(param, param1) {
19653 var viewportResizeCb = param.viewportResizeCb;
19654 var win = param1.win;
19655 var lastH = -1;
19656 var lastW = -1;
19657 var updateDimension = callbackWrapper(throttle(callbackWrapper(function() {
19658 var height = getWindowHeight();
19659 var width = getWindowWidth();
19660 if (lastH !== height || lastW !== width) {
19661 viewportResizeCb({
19662 width: Number(width),
19663 height: Number(height)
19664 });
19665 lastH = height;
19666 lastW = width;
19667 }
19668 }), 200));
19669 return on("resize", updateDimension, win);
19670 }
19671 var INPUT_TAGS = [
19672 "INPUT",
19673 "TEXTAREA",
19674 "SELECT"
19675 ];
19676 var lastInputValueMap = /* @__PURE__ */ new WeakMap();
19677 function initInputObserver(param) {
19678 var inputCb = param.inputCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, ignoreClass = param.ignoreClass, ignoreSelector = param.ignoreSelector, maskInputOptions = param.maskInputOptions, maskInputFn = param.maskInputFn, sampling = param.sampling, userTriggeredOnInput = param.userTriggeredOnInput;
19679 function eventHandler(event) {
19680 var target = getEventTarget(event);
19681 var userTriggered = event.isTrusted;
19682 var tagName = target && target.tagName;
19683 if (target && tagName === "OPTION") {
19684 target = index.parentElement(target);
19685 }
19686 if (!target || !tagName || INPUT_TAGS.indexOf(tagName) < 0 || isBlocked(target, blockClass, blockSelector, true)) {
19687 return;
19688 }
19689 if (target.classList.contains(ignoreClass) || ignoreSelector && target.matches(ignoreSelector)) {
19690 return;
19691 }
19692 var text = target.value;
19693 var isChecked = false;
19694 var type = getInputType(target) || "";
19695 if (type === "radio" || type === "checkbox") {
19696 isChecked = target.checked;
19697 } else if (maskInputOptions[tagName.toLowerCase()] || maskInputOptions[type]) {
19698 text = maskInputValue({
19699 element: target,
19700 maskInputOptions: maskInputOptions,
19701 tagName: tagName,
19702 type: type,
19703 value: text,
19704 maskInputFn: maskInputFn
19705 });
19706 }
19707 cbWithDedup(target, userTriggeredOnInput ? {
19708 text: text,
19709 isChecked: isChecked,
19710 userTriggered: userTriggered
19711 } : {
19712 text: text,
19713 isChecked: isChecked
19714 });
19715 var name = target.name;
19716 if (type === "radio" && name && isChecked) {
19717 doc.querySelectorAll('input[type="radio"][name="' + name + '"]').forEach(function(el) {
19718 if (el !== target) {
19719 var text2 = el.value;
19720 cbWithDedup(el, userTriggeredOnInput ? {
19721 text: text2,
19722 isChecked: !isChecked,
19723 userTriggered: false
19724 } : {
19725 text: text2,
19726 isChecked: !isChecked
19727 });
19728 }
19729 });
19730 }
19731 }
19732 function cbWithDedup(target, v2) {
19733 var lastInputValue = lastInputValueMap.get(target);
19734 if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
19735 lastInputValueMap.set(target, v2);
19736 var id = mirror2.getId(target);
19737 callbackWrapper(inputCb)(_extends({}, v2, {
19738 id: id
19739 }));
19740 }
19741 }
19742 var events = sampling.input === "last" ? [
19743 "change"
19744 ] : [
19745 "input",
19746 "change"
19747 ];
19748 var handlers = events.map(function(eventName) {
19749 return on(eventName, callbackWrapper(eventHandler), doc);
19750 });
19751 var currentWindow = doc.defaultView;
19752 if (!currentWindow) {
19753 return function() {
19754 handlers.forEach(function(h) {
19755 return h();
19756 });
19757 };
19758 }
19759 var propertyDescriptor = currentWindow.Object.getOwnPropertyDescriptor(currentWindow.HTMLInputElement.prototype, "value");
19760 var hookProperties = [
19761 [
19762 currentWindow.HTMLInputElement.prototype,
19763 "value"
19764 ],
19765 [
19766 currentWindow.HTMLInputElement.prototype,
19767 "checked"
19768 ],
19769 [
19770 currentWindow.HTMLSelectElement.prototype,
19771 "value"
19772 ],
19773 [
19774 currentWindow.HTMLTextAreaElement.prototype,
19775 "value"
19776 ],
19777 // Some UI library use selectedIndex to set select value
19778 [
19779 currentWindow.HTMLSelectElement.prototype,
19780 "selectedIndex"
19781 ],
19782 [
19783 currentWindow.HTMLOptionElement.prototype,
19784 "selected"
19785 ]
19786 ];
19787 if (propertyDescriptor && propertyDescriptor.set) {
19788 var _handlers;
19789 (_handlers = handlers).push.apply(_handlers, [].concat(hookProperties.map(function(p) {
19790 return hookSetter(p[0], p[1], {
19791 set: function set() {
19792 callbackWrapper(eventHandler)({
19793 target: this,
19794 isTrusted: false
19795 });
19796 }
19797 }, false, currentWindow);
19798 })));
19799 }
19800 return callbackWrapper(function() {
19801 handlers.forEach(function(h) {
19802 return h();
19803 });
19804 });
19805 }
19806 function getNestedCSSRulePositions(rule2) {
19807 var positions = [];
19808 function recurse(childRule, pos) {
19809 if (hasNestedCSSRule("CSSGroupingRule") && _instanceof(childRule.parentRule, CSSGroupingRule) || hasNestedCSSRule("CSSMediaRule") && _instanceof(childRule.parentRule, CSSMediaRule) || hasNestedCSSRule("CSSSupportsRule") && _instanceof(childRule.parentRule, CSSSupportsRule) || hasNestedCSSRule("CSSConditionRule") && _instanceof(childRule.parentRule, CSSConditionRule)) {
19810 var rules2 = Array.from(childRule.parentRule.cssRules);
19811 var index2 = rules2.indexOf(childRule);
19812 pos.unshift(index2);
19813 } else if (childRule.parentStyleSheet) {
19814 var rules21 = Array.from(childRule.parentStyleSheet.cssRules);
19815 var index21 = rules21.indexOf(childRule);
19816 pos.unshift(index21);
19817 }
19818 return pos;
19819 }
19820 return recurse(rule2, positions);
19821 }
19822 function getIdAndStyleId(sheet, mirror2, styleMirror) {
19823 var id, styleId;
19824 if (!sheet) return {};
19825 if (sheet.ownerNode) id = mirror2.getId(sheet.ownerNode);
19826 else styleId = styleMirror.getId(sheet);
19827 return {
19828 styleId: styleId,
19829 id: id
19830 };
19831 }
19832 function initStyleSheetObserver(param, param1) {
19833 var styleSheetRuleCb = param.styleSheetRuleCb, mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
19834 var win = param1.win;
19835 if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
19836 return function() {};
19837 }
19838 var insertRule = win.CSSStyleSheet.prototype.insertRule;
19839 win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
19840 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19841 var rule2 = argumentsList[0], index2 = argumentsList[1];
19842 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19843 if (id && id !== -1 || styleId && styleId !== -1) {
19844 styleSheetRuleCb({
19845 id: id,
19846 styleId: styleId,
19847 adds: [
19848 {
19849 rule: rule2,
19850 index: index2
19851 }
19852 ]
19853 });
19854 }
19855 return target.apply(thisArg, argumentsList);
19856 })
19857 });
19858 win.CSSStyleSheet.prototype.addRule = function(selector, styleBlock, index2) {
19859 if (index2 === void 0) index2 = this.cssRules.length;
19860 var rule2 = selector + " { " + styleBlock + " }";
19861 return win.CSSStyleSheet.prototype.insertRule.apply(this, [
19862 rule2,
19863 index2
19864 ]);
19865 };
19866 var deleteRule = win.CSSStyleSheet.prototype.deleteRule;
19867 win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
19868 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19869 var index2 = argumentsList[0];
19870 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19871 if (id && id !== -1 || styleId && styleId !== -1) {
19872 styleSheetRuleCb({
19873 id: id,
19874 styleId: styleId,
19875 removes: [
19876 {
19877 index: index2
19878 }
19879 ]
19880 });
19881 }
19882 return target.apply(thisArg, argumentsList);
19883 })
19884 });
19885 win.CSSStyleSheet.prototype.removeRule = function(index2) {
19886 return win.CSSStyleSheet.prototype.deleteRule.apply(this, [
19887 index2
19888 ]);
19889 };
19890 var replace;
19891 if (win.CSSStyleSheet.prototype.replace) {
19892 replace = win.CSSStyleSheet.prototype.replace;
19893 win.CSSStyleSheet.prototype.replace = new Proxy(replace, {
19894 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19895 var text = argumentsList[0];
19896 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19897 if (id && id !== -1 || styleId && styleId !== -1) {
19898 styleSheetRuleCb({
19899 id: id,
19900 styleId: styleId,
19901 replace: text
19902 });
19903 }
19904 return target.apply(thisArg, argumentsList);
19905 })
19906 });
19907 }
19908 var replaceSync;
19909 if (win.CSSStyleSheet.prototype.replaceSync) {
19910 replaceSync = win.CSSStyleSheet.prototype.replaceSync;
19911 win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {
19912 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19913 var text = argumentsList[0];
19914 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19915 if (id && id !== -1 || styleId && styleId !== -1) {
19916 styleSheetRuleCb({
19917 id: id,
19918 styleId: styleId,
19919 replaceSync: text
19920 });
19921 }
19922 return target.apply(thisArg, argumentsList);
19923 })
19924 });
19925 }
19926 var supportedNestedCSSRuleTypes = {};
19927 if (canMonkeyPatchNestedCSSRule("CSSGroupingRule")) {
19928 supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
19929 } else {
19930 if (canMonkeyPatchNestedCSSRule("CSSMediaRule")) {
19931 supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
19932 }
19933 if (canMonkeyPatchNestedCSSRule("CSSConditionRule")) {
19934 supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
19935 }
19936 if (canMonkeyPatchNestedCSSRule("CSSSupportsRule")) {
19937 supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
19938 }
19939 }
19940 var unmodifiedFunctions = {};
19941 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
19942 var typeKey = param[0], type = param[1];
19943 unmodifiedFunctions[typeKey] = {
19944 // eslint-disable-next-line @typescript-eslint/unbound-method
19945 insertRule: type.prototype.insertRule,
19946 // eslint-disable-next-line @typescript-eslint/unbound-method
19947 deleteRule: type.prototype.deleteRule
19948 };
19949 type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
19950 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19951 var rule2 = argumentsList[0], index2 = argumentsList[1];
19952 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19953 if (id && id !== -1 || styleId && styleId !== -1) {
19954 styleSheetRuleCb({
19955 id: id,
19956 styleId: styleId,
19957 adds: [
19958 {
19959 rule: rule2,
19960 index: [].concat(getNestedCSSRulePositions(thisArg), [
19961 index2 || 0
19962 ])
19963 }
19964 ]
19965 });
19966 }
19967 return target.apply(thisArg, argumentsList);
19968 })
19969 });
19970 type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
19971 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19972 var index2 = argumentsList[0];
19973 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19974 if (id && id !== -1 || styleId && styleId !== -1) {
19975 styleSheetRuleCb({
19976 id: id,
19977 styleId: styleId,
19978 removes: [
19979 {
19980 index: [].concat(getNestedCSSRulePositions(thisArg), [
19981 index2
19982 ])
19983 }
19984 ]
19985 });
19986 }
19987 return target.apply(thisArg, argumentsList);
19988 })
19989 });
19990 });
19991 return callbackWrapper(function() {
19992 win.CSSStyleSheet.prototype.insertRule = insertRule;
19993 win.CSSStyleSheet.prototype.deleteRule = deleteRule;
19994 replace && (win.CSSStyleSheet.prototype.replace = replace);
19995 replaceSync && (win.CSSStyleSheet.prototype.replaceSync = replaceSync);
19996 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
19997 var typeKey = param[0], type = param[1];
19998 type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
19999 type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
20000 });
20001 });
20002 }
20003 function initAdoptedStyleSheetObserver(param, host2) {
20004 var mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
20005 var _a2, _b, _c;
20006 var hostId = null;
20007 if (host2.nodeName === "#document") hostId = mirror2.getId(host2);
20008 else hostId = mirror2.getId(index.host(host2));
20009 var patchTarget = host2.nodeName === "#document" ? (_a2 = host2.defaultView) == null ? void 0 : _a2.Document : (_c = (_b = host2.ownerDocument) == null ? void 0 : _b.defaultView) == null ? void 0 : _c.ShadowRoot;
20010 var originalPropertyDescriptor = (patchTarget == null ? void 0 : patchTarget.prototype) ? Object.getOwnPropertyDescriptor(patchTarget == null ? void 0 : patchTarget.prototype, "adoptedStyleSheets") : void 0;
20011 if (hostId === null || hostId === -1 || !patchTarget || !originalPropertyDescriptor) return function() {};
20012 Object.defineProperty(host2, "adoptedStyleSheets", {
20013 configurable: originalPropertyDescriptor.configurable,
20014 enumerable: originalPropertyDescriptor.enumerable,
20015 get: function get() {
20016 var _a3;
20017 return (_a3 = originalPropertyDescriptor.get) == null ? void 0 : _a3.call(this);
20018 },
20019 set: function set(sheets) {
20020 var _a3;
20021 var result2 = (_a3 = originalPropertyDescriptor.set) == null ? void 0 : _a3.call(this, sheets);
20022 if (hostId !== null && hostId !== -1) {
20023 try {
20024 stylesheetManager.adoptStyleSheets(sheets, hostId);
20025 } catch (e2) {}
20026 }
20027 return result2;
20028 }
20029 });
20030 return callbackWrapper(function() {
20031 Object.defineProperty(host2, "adoptedStyleSheets", {
20032 configurable: originalPropertyDescriptor.configurable,
20033 enumerable: originalPropertyDescriptor.enumerable,
20034 // eslint-disable-next-line @typescript-eslint/unbound-method
20035 get: originalPropertyDescriptor.get,
20036 // eslint-disable-next-line @typescript-eslint/unbound-method
20037 set: originalPropertyDescriptor.set
20038 });
20039 });
20040 }
20041 function initStyleDeclarationObserver(param, param1) {
20042 var styleDeclarationCb = param.styleDeclarationCb, mirror2 = param.mirror, ignoreCSSAttributes = param.ignoreCSSAttributes, stylesheetManager = param.stylesheetManager;
20043 var win = param1.win;
20044 var setProperty = win.CSSStyleDeclaration.prototype.setProperty;
20045 win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
20046 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20047 var _a2;
20048 var property = argumentsList[0], value = argumentsList[1], priority = argumentsList[2];
20049 if (ignoreCSSAttributes.has(property)) {
20050 return setProperty.apply(thisArg, [
20051 property,
20052 value,
20053 priority
20054 ]);
20055 }
20056 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20057 if (id && id !== -1 || styleId && styleId !== -1) {
20058 styleDeclarationCb({
20059 id: id,
20060 styleId: styleId,
20061 set: {
20062 property: property,
20063 value: value,
20064 priority: priority
20065 },
20066 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20067 index: getNestedCSSRulePositions(thisArg.parentRule)
20068 });
20069 }
20070 return target.apply(thisArg, argumentsList);
20071 })
20072 });
20073 var removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
20074 win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
20075 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20076 var _a2;
20077 var property = argumentsList[0];
20078 if (ignoreCSSAttributes.has(property)) {
20079 return removeProperty.apply(thisArg, [
20080 property
20081 ]);
20082 }
20083 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20084 if (id && id !== -1 || styleId && styleId !== -1) {
20085 styleDeclarationCb({
20086 id: id,
20087 styleId: styleId,
20088 remove: {
20089 property: property
20090 },
20091 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20092 index: getNestedCSSRulePositions(thisArg.parentRule)
20093 });
20094 }
20095 return target.apply(thisArg, argumentsList);
20096 })
20097 });
20098 return callbackWrapper(function() {
20099 win.CSSStyleDeclaration.prototype.setProperty = setProperty;
20100 win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
20101 });
20102 }
20103 function initMediaInteractionObserver(param) {
20104 var mediaInteractionCb = param.mediaInteractionCb, blockClass = param.blockClass, blockSelector = param.blockSelector, mirror2 = param.mirror, sampling = param.sampling, doc = param.doc;
20105 var handler = callbackWrapper(function(type) {
20106 return throttle(callbackWrapper(function(event) {
20107 var target = getEventTarget(event);
20108 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20109 return;
20110 }
20111 var currentTime = target.currentTime, volume = target.volume, muted = target.muted, playbackRate = target.playbackRate, loop = target.loop;
20112 mediaInteractionCb({
20113 type: type,
20114 id: mirror2.getId(target),
20115 currentTime: currentTime,
20116 volume: volume,
20117 muted: muted,
20118 playbackRate: playbackRate,
20119 loop: loop
20120 });
20121 }), sampling.media || 500);
20122 });
20123 var handlers = [
20124 on("play", handler(MediaInteractions.Play), doc),
20125 on("pause", handler(MediaInteractions.Pause), doc),
20126 on("seeked", handler(MediaInteractions.Seeked), doc),
20127 on("volumechange", handler(MediaInteractions.VolumeChange), doc),
20128 on("ratechange", handler(MediaInteractions.RateChange), doc)
20129 ];
20130 return callbackWrapper(function() {
20131 handlers.forEach(function(h) {
20132 return h();
20133 });
20134 });
20135 }
20136 function initFontObserver(param) {
20137 var fontCb = param.fontCb, doc = param.doc;
20138 var win = doc.defaultView;
20139 if (!win) {
20140 return function() {};
20141 }
20142 var handlers = [];
20143 var fontMap = /* @__PURE__ */ new WeakMap();
20144 var originalFontFace = win.FontFace;
20145 win.FontFace = function FontFace2(family, source, descriptors) {
20146 var fontFace = new originalFontFace(family, source, descriptors);
20147 fontMap.set(fontFace, {
20148 family: family,
20149 buffer: typeof source !== "string",
20150 descriptors: descriptors,
20151 fontSource: typeof source === "string" ? source : JSON.stringify(Array.from(new Uint8Array(source)))
20152 });
20153 return fontFace;
20154 };
20155 var restoreHandler = patch(doc.fonts, "add", function(original) {
20156 return function(fontFace) {
20157 setTimeout(callbackWrapper(function() {
20158 var p = fontMap.get(fontFace);
20159 if (p) {
20160 fontCb(p);
20161 fontMap.delete(fontFace);
20162 }
20163 }), 0);
20164 return original.apply(this, [
20165 fontFace
20166 ]);
20167 };
20168 });
20169 handlers.push(function() {
20170 win.FontFace = originalFontFace;
20171 });
20172 handlers.push(restoreHandler);
20173 return callbackWrapper(function() {
20174 handlers.forEach(function(h) {
20175 return h();
20176 });
20177 });
20178 }
20179 function initSelectionObserver(param) {
20180 var doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, selectionCb = param.selectionCb;
20181 var collapsed = true;
20182 var updateSelection = callbackWrapper(function() {
20183 var selection = doc.getSelection();
20184 if (!selection || collapsed && (selection == null ? void 0 : selection.isCollapsed)) return;
20185 collapsed = selection.isCollapsed || false;
20186 var ranges = [];
20187 var count = selection.rangeCount || 0;
20188 for(var i2 = 0; i2 < count; i2++){
20189 var range = selection.getRangeAt(i2);
20190 var startContainer = range.startContainer, startOffset = range.startOffset, endContainer = range.endContainer, endOffset = range.endOffset;
20191 var blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
20192 if (blocked) continue;
20193 ranges.push({
20194 start: mirror2.getId(startContainer),
20195 startOffset: startOffset,
20196 end: mirror2.getId(endContainer),
20197 endOffset: endOffset
20198 });
20199 }
20200 selectionCb({
20201 ranges: ranges
20202 });
20203 });
20204 updateSelection();
20205 return on("selectionchange", updateSelection);
20206 }
20207 function initCustomElementObserver(param) {
20208 var doc = param.doc, customElementCb = param.customElementCb;
20209 var win = doc.defaultView;
20210 if (!win || !win.customElements) return function() {};
20211 var restoreHandler = patch(win.customElements, "define", function(original) {
20212 return function(name, constructor, options) {
20213 try {
20214 customElementCb({
20215 define: {
20216 name: name
20217 }
20218 });
20219 } catch (e2) {
20220 console.warn("Custom element callback failed for " + name);
20221 }
20222 return original.apply(this, [
20223 name,
20224 constructor,
20225 options
20226 ]);
20227 };
20228 });
20229 return restoreHandler;
20230 }
20231 function mergeHooks(o2, hooks) {
20232 var mutationCb = o2.mutationCb, mousemoveCb = o2.mousemoveCb, mouseInteractionCb = o2.mouseInteractionCb, scrollCb = o2.scrollCb, viewportResizeCb = o2.viewportResizeCb, inputCb = o2.inputCb, mediaInteractionCb = o2.mediaInteractionCb, styleSheetRuleCb = o2.styleSheetRuleCb, styleDeclarationCb = o2.styleDeclarationCb, canvasMutationCb = o2.canvasMutationCb, fontCb = o2.fontCb, selectionCb = o2.selectionCb, customElementCb = o2.customElementCb;
20233 o2.mutationCb = function() {
20234 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20235 p[_key] = arguments[_key];
20236 }
20237 if (hooks.mutation) {
20238 var _hooks;
20239 (_hooks = hooks).mutation.apply(_hooks, [].concat(p));
20240 }
20241 mutationCb.apply(void 0, [].concat(p));
20242 };
20243 o2.mousemoveCb = function() {
20244 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20245 p[_key] = arguments[_key];
20246 }
20247 if (hooks.mousemove) {
20248 var _hooks;
20249 (_hooks = hooks).mousemove.apply(_hooks, [].concat(p));
20250 }
20251 mousemoveCb.apply(void 0, [].concat(p));
20252 };
20253 o2.mouseInteractionCb = function() {
20254 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20255 p[_key] = arguments[_key];
20256 }
20257 if (hooks.mouseInteraction) {
20258 var _hooks;
20259 (_hooks = hooks).mouseInteraction.apply(_hooks, [].concat(p));
20260 }
20261 mouseInteractionCb.apply(void 0, [].concat(p));
20262 };
20263 o2.scrollCb = function() {
20264 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20265 p[_key] = arguments[_key];
20266 }
20267 if (hooks.scroll) {
20268 var _hooks;
20269 (_hooks = hooks).scroll.apply(_hooks, [].concat(p));
20270 }
20271 scrollCb.apply(void 0, [].concat(p));
20272 };
20273 o2.viewportResizeCb = function() {
20274 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20275 p[_key] = arguments[_key];
20276 }
20277 if (hooks.viewportResize) {
20278 var _hooks;
20279 (_hooks = hooks).viewportResize.apply(_hooks, [].concat(p));
20280 }
20281 viewportResizeCb.apply(void 0, [].concat(p));
20282 };
20283 o2.inputCb = function() {
20284 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20285 p[_key] = arguments[_key];
20286 }
20287 if (hooks.input) {
20288 var _hooks;
20289 (_hooks = hooks).input.apply(_hooks, [].concat(p));
20290 }
20291 inputCb.apply(void 0, [].concat(p));
20292 };
20293 o2.mediaInteractionCb = function() {
20294 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20295 p[_key] = arguments[_key];
20296 }
20297 if (hooks.mediaInteaction) {
20298 var _hooks;
20299 (_hooks = hooks).mediaInteaction.apply(_hooks, [].concat(p));
20300 }
20301 mediaInteractionCb.apply(void 0, [].concat(p));
20302 };
20303 o2.styleSheetRuleCb = function() {
20304 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20305 p[_key] = arguments[_key];
20306 }
20307 if (hooks.styleSheetRule) {
20308 var _hooks;
20309 (_hooks = hooks).styleSheetRule.apply(_hooks, [].concat(p));
20310 }
20311 styleSheetRuleCb.apply(void 0, [].concat(p));
20312 };
20313 o2.styleDeclarationCb = function() {
20314 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20315 p[_key] = arguments[_key];
20316 }
20317 if (hooks.styleDeclaration) {
20318 var _hooks;
20319 (_hooks = hooks).styleDeclaration.apply(_hooks, [].concat(p));
20320 }
20321 styleDeclarationCb.apply(void 0, [].concat(p));
20322 };
20323 o2.canvasMutationCb = function() {
20324 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20325 p[_key] = arguments[_key];
20326 }
20327 if (hooks.canvasMutation) {
20328 var _hooks;
20329 (_hooks = hooks).canvasMutation.apply(_hooks, [].concat(p));
20330 }
20331 canvasMutationCb.apply(void 0, [].concat(p));
20332 };
20333 o2.fontCb = function() {
20334 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20335 p[_key] = arguments[_key];
20336 }
20337 if (hooks.font) {
20338 var _hooks;
20339 (_hooks = hooks).font.apply(_hooks, [].concat(p));
20340 }
20341 fontCb.apply(void 0, [].concat(p));
20342 };
20343 o2.selectionCb = function() {
20344 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20345 p[_key] = arguments[_key];
20346 }
20347 if (hooks.selection) {
20348 var _hooks;
20349 (_hooks = hooks).selection.apply(_hooks, [].concat(p));
20350 }
20351 selectionCb.apply(void 0, [].concat(p));
20352 };
20353 o2.customElementCb = function() {
20354 for(var _len = arguments.length, c2 = new Array(_len), _key = 0; _key < _len; _key++){
20355 c2[_key] = arguments[_key];
20356 }
20357 if (hooks.customElement) {
20358 var _hooks;
20359 (_hooks = hooks).customElement.apply(_hooks, [].concat(c2));
20360 }
20361 customElementCb.apply(void 0, [].concat(c2));
20362 };
20363 }
20364 function initObservers(o2, hooks) {
20365 if (hooks === void 0) hooks = {};
20366 var currentWindow = o2.doc.defaultView;
20367 if (!currentWindow) {
20368 return function() {};
20369 }
20370 mergeHooks(o2, hooks);
20371 var mutationObserver;
20372 if (o2.recordDOM) {
20373 mutationObserver = initMutationObserver(o2, o2.doc);
20374 }
20375 var mousemoveHandler = initMoveObserver(o2);
20376 var mouseInteractionHandler = initMouseInteractionObserver(o2);
20377 var scrollHandler = initScrollObserver(o2);
20378 var viewportResizeHandler = initViewportResizeObserver(o2, {
20379 win: currentWindow
20380 });
20381 var inputHandler = initInputObserver(o2);
20382 var mediaInteractionHandler = initMediaInteractionObserver(o2);
20383 var styleSheetObserver = function() {};
20384 var adoptedStyleSheetObserver = function() {};
20385 var styleDeclarationObserver = function() {};
20386 var fontObserver = function() {};
20387 if (o2.recordDOM) {
20388 styleSheetObserver = initStyleSheetObserver(o2, {
20389 win: currentWindow
20390 });
20391 adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o2, o2.doc);
20392 styleDeclarationObserver = initStyleDeclarationObserver(o2, {
20393 win: currentWindow
20394 });
20395 if (o2.collectFonts) {
20396 fontObserver = initFontObserver(o2);
20397 }
20398 }
20399 var selectionObserver = initSelectionObserver(o2);
20400 var customElementObserver = initCustomElementObserver(o2);
20401 var pluginHandlers = [];
20402 for(var _iterator = _create_for_of_iterator_helper_loose(o2.plugins), _step; !(_step = _iterator()).done;){
20403 var plugin3 = _step.value;
20404 pluginHandlers.push(plugin3.observer(plugin3.callback, currentWindow, plugin3.options));
20405 }
20406 return callbackWrapper(function() {
20407 mutationBuffers.forEach(function(b) {
20408 return b.reset();
20409 });
20410 mutationObserver == null ? void 0 : mutationObserver.disconnect();
20411 mousemoveHandler();
20412 mouseInteractionHandler();
20413 scrollHandler();
20414 viewportResizeHandler();
20415 inputHandler();
20416 mediaInteractionHandler();
20417 styleSheetObserver();
20418 adoptedStyleSheetObserver();
20419 styleDeclarationObserver();
20420 fontObserver();
20421 selectionObserver();
20422 customElementObserver();
20423 pluginHandlers.forEach(function(h) {
20424 return h();
20425 });
20426 });
20427 }
20428 function hasNestedCSSRule(prop) {
20429 return typeof window[prop] !== "undefined";
20430 }
20431 function canMonkeyPatchNestedCSSRule(prop) {
20432 return Boolean(typeof window[prop] !== "undefined" && // Note: Generally, this check _shouldn't_ be necessary
20433 // However, in some scenarios (e.g. jsdom) this can sometimes fail, so we check for it here
20434 window[prop].prototype && "insertRule" in window[prop].prototype && "deleteRule" in window[prop].prototype);
20435 }
20436 var CrossOriginIframeMirror = /*#__PURE__*/ function() {
20437 function CrossOriginIframeMirror(generateIdFn) {
20438 __publicField(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
20439 __publicField(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
20440 this.generateIdFn = generateIdFn;
20441 }
20442 var _proto = CrossOriginIframeMirror.prototype;
20443 _proto.getId = function getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) {
20444 var idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe);
20445 var remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe);
20446 var id = idToRemoteIdMap.get(remoteId);
20447 if (!id) {
20448 id = this.generateIdFn();
20449 idToRemoteIdMap.set(remoteId, id);
20450 remoteIdToIdMap.set(id, remoteId);
20451 }
20452 return id;
20453 };
20454 _proto.getIds = function getIds(iframe, remoteId) {
20455 var _this = this;
20456 var idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);
20457 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20458 return remoteId.map(function(id) {
20459 return _this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap);
20460 });
20461 };
20462 _proto.getRemoteId = function getRemoteId(iframe, id, map) {
20463 var remoteIdToIdMap = map || this.getRemoteIdToIdMap(iframe);
20464 if (typeof id !== "number") return id;
20465 var remoteId = remoteIdToIdMap.get(id);
20466 if (!remoteId) return -1;
20467 return remoteId;
20468 };
20469 _proto.getRemoteIds = function getRemoteIds(iframe, ids) {
20470 var _this = this;
20471 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20472 return ids.map(function(id) {
20473 return _this.getRemoteId(iframe, id, remoteIdToIdMap);
20474 });
20475 };
20476 _proto.reset = function reset(iframe) {
20477 if (!iframe) {
20478 this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap();
20479 this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
20480 return;
20481 }
20482 this.iframeIdToRemoteIdMap.delete(iframe);
20483 this.iframeRemoteIdToIdMap.delete(iframe);
20484 };
20485 _proto.getIdToRemoteIdMap = function getIdToRemoteIdMap(iframe) {
20486 var idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe);
20487 if (!idToRemoteIdMap) {
20488 idToRemoteIdMap = /* @__PURE__ */ new Map();
20489 this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap);
20490 }
20491 return idToRemoteIdMap;
20492 };
20493 _proto.getRemoteIdToIdMap = function getRemoteIdToIdMap(iframe) {
20494 var remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe);
20495 if (!remoteIdToIdMap) {
20496 remoteIdToIdMap = /* @__PURE__ */ new Map();
20497 this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap);
20498 }
20499 return remoteIdToIdMap;
20500 };
20501 return CrossOriginIframeMirror;
20502 }();
20503 var IframeManager = /*#__PURE__*/ function() {
20504 function IframeManager(options) {
20505 __publicField(this, "iframes", /* @__PURE__ */ new WeakMap());
20506 __publicField(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
20507 __publicField(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
20508 __publicField(this, "crossOriginIframeStyleMirror");
20509 __publicField(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
20510 __publicField(this, "mirror");
20511 __publicField(this, "mutationCb");
20512 __publicField(this, "wrappedEmit");
20513 __publicField(this, "loadListener");
20514 __publicField(this, "stylesheetManager");
20515 __publicField(this, "recordCrossOriginIframes");
20516 this.mutationCb = options.mutationCb;
20517 this.wrappedEmit = options.wrappedEmit;
20518 this.stylesheetManager = options.stylesheetManager;
20519 this.recordCrossOriginIframes = options.recordCrossOriginIframes;
20520 this.crossOriginIframeStyleMirror = new CrossOriginIframeMirror(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror));
20521 this.mirror = options.mirror;
20522 if (this.recordCrossOriginIframes) {
20523 window.addEventListener("message", this.handleMessage.bind(this));
20524 }
20525 }
20526 var _proto = IframeManager.prototype;
20527 _proto.addIframe = function addIframe(iframeEl) {
20528 this.iframes.set(iframeEl, true);
20529 if (iframeEl.contentWindow) this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
20530 };
20531 _proto.addLoadListener = function addLoadListener(cb) {
20532 this.loadListener = cb;
20533 };
20534 _proto.attachIframe = function attachIframe(iframeEl, childSn) {
20535 var _a2, _b;
20536 this.mutationCb({
20537 adds: [
20538 {
20539 parentId: this.mirror.getId(iframeEl),
20540 nextId: null,
20541 node: childSn
20542 }
20543 ],
20544 removes: [],
20545 texts: [],
20546 attributes: [],
20547 isAttachIframe: true
20548 });
20549 if (this.recordCrossOriginIframes) (_a2 = iframeEl.contentWindow) == null ? void 0 : _a2.addEventListener("message", this.handleMessage.bind(this));
20550 (_b = this.loadListener) == null ? void 0 : _b.call(this, iframeEl);
20551 if (iframeEl.contentDocument && iframeEl.contentDocument.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0) this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
20552 };
20553 _proto.handleMessage = function handleMessage(message) {
20554 var crossOriginMessageEvent = message;
20555 if (crossOriginMessageEvent.data.type !== "rrweb" || // To filter out the rrweb messages which are forwarded by some sites.
20556 crossOriginMessageEvent.origin !== crossOriginMessageEvent.data.origin) return;
20557 var iframeSourceWindow = message.source;
20558 if (!iframeSourceWindow) return;
20559 var iframeEl = this.crossOriginIframeMap.get(message.source);
20560 if (!iframeEl) return;
20561 var transformedEvent = this.transformCrossOriginEvent(iframeEl, crossOriginMessageEvent.data.event);
20562 if (transformedEvent) this.wrappedEmit(transformedEvent, crossOriginMessageEvent.data.isCheckout);
20563 };
20564 _proto.transformCrossOriginEvent = function transformCrossOriginEvent(iframeEl, e2) {
20565 var _this = this;
20566 var _a2;
20567 switch(e2.type){
20568 case EventType.FullSnapshot:
20569 {
20570 this.crossOriginIframeMirror.reset(iframeEl);
20571 this.crossOriginIframeStyleMirror.reset(iframeEl);
20572 this.replaceIdOnNode(e2.data.node, iframeEl);
20573 var rootId = e2.data.node.id;
20574 this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
20575 this.patchRootIdOnNode(e2.data.node, rootId);
20576 return {
20577 timestamp: e2.timestamp,
20578 type: EventType.IncrementalSnapshot,
20579 data: {
20580 source: IncrementalSource.Mutation,
20581 adds: [
20582 {
20583 parentId: this.mirror.getId(iframeEl),
20584 nextId: null,
20585 node: e2.data.node
20586 }
20587 ],
20588 removes: [],
20589 texts: [],
20590 attributes: [],
20591 isAttachIframe: true
20592 }
20593 };
20594 }
20595 case EventType.Meta:
20596 case EventType.Load:
20597 case EventType.DomContentLoaded:
20598 {
20599 return false;
20600 }
20601 case EventType.Plugin:
20602 {
20603 return e2;
20604 }
20605 case EventType.Custom:
20606 {
20607 this.replaceIds(e2.data.payload, iframeEl, [
20608 "id",
20609 "parentId",
20610 "previousId",
20611 "nextId"
20612 ]);
20613 return e2;
20614 }
20615 case EventType.IncrementalSnapshot:
20616 {
20617 switch(e2.data.source){
20618 case IncrementalSource.Mutation:
20619 {
20620 e2.data.adds.forEach(function(n2) {
20621 _this.replaceIds(n2, iframeEl, [
20622 "parentId",
20623 "nextId",
20624 "previousId"
20625 ]);
20626 _this.replaceIdOnNode(n2.node, iframeEl);
20627 var rootId = _this.crossOriginIframeRootIdMap.get(iframeEl);
20628 rootId && _this.patchRootIdOnNode(n2.node, rootId);
20629 });
20630 e2.data.removes.forEach(function(n2) {
20631 _this.replaceIds(n2, iframeEl, [
20632 "parentId",
20633 "id"
20634 ]);
20635 });
20636 e2.data.attributes.forEach(function(n2) {
20637 _this.replaceIds(n2, iframeEl, [
20638 "id"
20639 ]);
20640 });
20641 e2.data.texts.forEach(function(n2) {
20642 _this.replaceIds(n2, iframeEl, [
20643 "id"
20644 ]);
20645 });
20646 return e2;
20647 }
20648 case IncrementalSource.Drag:
20649 case IncrementalSource.TouchMove:
20650 case IncrementalSource.MouseMove:
20651 {
20652 e2.data.positions.forEach(function(p) {
20653 _this.replaceIds(p, iframeEl, [
20654 "id"
20655 ]);
20656 });
20657 return e2;
20658 }
20659 case IncrementalSource.ViewportResize:
20660 {
20661 return false;
20662 }
20663 case IncrementalSource.MediaInteraction:
20664 case IncrementalSource.MouseInteraction:
20665 case IncrementalSource.Scroll:
20666 case IncrementalSource.CanvasMutation:
20667 case IncrementalSource.Input:
20668 {
20669 this.replaceIds(e2.data, iframeEl, [
20670 "id"
20671 ]);
20672 return e2;
20673 }
20674 case IncrementalSource.StyleSheetRule:
20675 case IncrementalSource.StyleDeclaration:
20676 {
20677 this.replaceIds(e2.data, iframeEl, [
20678 "id"
20679 ]);
20680 this.replaceStyleIds(e2.data, iframeEl, [
20681 "styleId"
20682 ]);
20683 return e2;
20684 }
20685 case IncrementalSource.Font:
20686 {
20687 return e2;
20688 }
20689 case IncrementalSource.Selection:
20690 {
20691 e2.data.ranges.forEach(function(range) {
20692 _this.replaceIds(range, iframeEl, [
20693 "start",
20694 "end"
20695 ]);
20696 });
20697 return e2;
20698 }
20699 case IncrementalSource.AdoptedStyleSheet:
20700 {
20701 this.replaceIds(e2.data, iframeEl, [
20702 "id"
20703 ]);
20704 this.replaceStyleIds(e2.data, iframeEl, [
20705 "styleIds"
20706 ]);
20707 (_a2 = e2.data.styles) == null ? void 0 : _a2.forEach(function(style) {
20708 _this.replaceStyleIds(style, iframeEl, [
20709 "styleId"
20710 ]);
20711 });
20712 return e2;
20713 }
20714 }
20715 }
20716 }
20717 return false;
20718 };
20719 _proto.replace = function replace(iframeMirror, obj, iframeEl, keys) {
20720 for(var _iterator = _create_for_of_iterator_helper_loose(keys), _step; !(_step = _iterator()).done;){
20721 var key = _step.value;
20722 if (!Array.isArray(obj[key]) && typeof obj[key] !== "number") continue;
20723 if (Array.isArray(obj[key])) {
20724 obj[key] = iframeMirror.getIds(iframeEl, obj[key]);
20725 } else {
20726 obj[key] = iframeMirror.getId(iframeEl, obj[key]);
20727 }
20728 }
20729 return obj;
20730 };
20731 _proto.replaceIds = function replaceIds(obj, iframeEl, keys) {
20732 return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);
20733 };
20734 _proto.replaceStyleIds = function replaceStyleIds(obj, iframeEl, keys) {
20735 return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
20736 };
20737 _proto.replaceIdOnNode = function replaceIdOnNode(node2, iframeEl) {
20738 var _this = this;
20739 this.replaceIds(node2, iframeEl, [
20740 "id",
20741 "rootId"
20742 ]);
20743 if ("childNodes" in node2) {
20744 node2.childNodes.forEach(function(child) {
20745 _this.replaceIdOnNode(child, iframeEl);
20746 });
20747 }
20748 };
20749 _proto.patchRootIdOnNode = function patchRootIdOnNode(node2, rootId) {
20750 var _this = this;
20751 if (node2.type !== NodeType.Document && !node2.rootId) node2.rootId = rootId;
20752 if ("childNodes" in node2) {
20753 node2.childNodes.forEach(function(child) {
20754 _this.patchRootIdOnNode(child, rootId);
20755 });
20756 }
20757 };
20758 return IframeManager;
20759 }();
20760 var ShadowDomManager = /*#__PURE__*/ function() {
20761 function ShadowDomManager(options) {
20762 __publicField(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
20763 __publicField(this, "mutationCb");
20764 __publicField(this, "scrollCb");
20765 __publicField(this, "bypassOptions");
20766 __publicField(this, "mirror");
20767 __publicField(this, "restoreHandlers", []);
20768 this.mutationCb = options.mutationCb;
20769 this.scrollCb = options.scrollCb;
20770 this.bypassOptions = options.bypassOptions;
20771 this.mirror = options.mirror;
20772 this.init();
20773 }
20774 var _proto = ShadowDomManager.prototype;
20775 _proto.init = function init() {
20776 this.reset();
20777 this.patchAttachShadow(Element, document);
20778 };
20779 _proto.addShadowRoot = function addShadowRoot(shadowRoot2, doc) {
20780 var _this = this;
20781 if (!isNativeShadowDom(shadowRoot2)) return;
20782 if (this.shadowDoms.has(shadowRoot2)) return;
20783 this.shadowDoms.add(shadowRoot2);
20784 var observer = initMutationObserver(_extends({}, this.bypassOptions, {
20785 doc: doc,
20786 mutationCb: this.mutationCb,
20787 mirror: this.mirror,
20788 shadowDomManager: this
20789 }), shadowRoot2);
20790 this.restoreHandlers.push(function() {
20791 return observer.disconnect();
20792 });
20793 this.restoreHandlers.push(initScrollObserver(_extends({}, this.bypassOptions, {
20794 scrollCb: this.scrollCb,
20795 // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813
20796 // scroll is not allowed to pass the boundary, so we need to listen the shadow document
20797 doc: shadowRoot2,
20798 mirror: this.mirror
20799 })));
20800 setTimeout(function() {
20801 if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0) _this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot2.adoptedStyleSheets, _this.mirror.getId(index.host(shadowRoot2)));
20802 _this.restoreHandlers.push(initAdoptedStyleSheetObserver({
20803 mirror: _this.mirror,
20804 stylesheetManager: _this.bypassOptions.stylesheetManager
20805 }, shadowRoot2));
20806 }, 0);
20807 };
20808 /**
20809 * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
20810 */ _proto.observeAttachShadow = function observeAttachShadow(iframeElement) {
20811 if (!iframeElement.contentWindow || !iframeElement.contentDocument) return;
20812 this.patchAttachShadow(iframeElement.contentWindow.Element, iframeElement.contentDocument);
20813 };
20814 /**
20815 * Patch 'attachShadow' to observe newly added shadow doms.
20816 */ _proto.patchAttachShadow = function patchAttachShadow(element, doc) {
20817 var manager = this;
20818 this.restoreHandlers.push(patch(element.prototype, "attachShadow", function(original) {
20819 return function(option) {
20820 var sRoot = original.call(this, option);
20821 var shadowRootEl = index.shadowRoot(this);
20822 if (shadowRootEl && inDom(this)) manager.addShadowRoot(shadowRootEl, doc);
20823 return sRoot;
20824 };
20825 }));
20826 };
20827 _proto.reset = function reset() {
20828 this.restoreHandlers.forEach(function(handler) {
20829 try {
20830 handler();
20831 } catch (e2) {}
20832 });
20833 this.restoreHandlers = [];
20834 this.shadowDoms = /* @__PURE__ */ new WeakSet();
20835 };
20836 return ShadowDomManager;
20837 }();
20838 var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
20839 var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
20840 for(var i$1 = 0; i$1 < chars.length; i$1++){
20841 lookup[chars.charCodeAt(i$1)] = i$1;
20842 }
20843 var encode = function encode(arraybuffer) {
20844 var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
20845 for(i2 = 0; i2 < len; i2 += 3){
20846 base64 += chars[bytes[i2] >> 2];
20847 base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
20848 base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
20849 base64 += chars[bytes[i2 + 2] & 63];
20850 }
20851 if (len % 3 === 2) {
20852 base64 = base64.substring(0, base64.length - 1) + "=";
20853 } else if (len % 3 === 1) {
20854 base64 = base64.substring(0, base64.length - 2) + "==";
20855 }
20856 return base64;
20857 };
20858 var canvasVarMap = /* @__PURE__ */ new Map();
20859 function variableListFor$1(ctx, ctor) {
20860 var contextMap = canvasVarMap.get(ctx);
20861 if (!contextMap) {
20862 contextMap = /* @__PURE__ */ new Map();
20863 canvasVarMap.set(ctx, contextMap);
20864 }
20865 if (!contextMap.has(ctor)) {
20866 contextMap.set(ctor, []);
20867 }
20868 return contextMap.get(ctor);
20869 }
20870 var saveWebGLVar = function(value, win, ctx) {
20871 if (!value || !(isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object")) return;
20872 var name = value.constructor.name;
20873 var list2 = variableListFor$1(ctx, name);
20874 var index2 = list2.indexOf(value);
20875 if (index2 === -1) {
20876 index2 = list2.length;
20877 list2.push(value);
20878 }
20879 return index2;
20880 };
20881 function serializeArg(value, win, ctx) {
20882 if (_instanceof(value, Array)) {
20883 return value.map(function(arg) {
20884 return serializeArg(arg, win, ctx);
20885 });
20886 } else if (value === null) {
20887 return value;
20888 } else if (_instanceof(value, Float32Array) || _instanceof(value, Float64Array) || _instanceof(value, Int32Array) || _instanceof(value, Uint32Array) || _instanceof(value, Uint8Array) || _instanceof(value, Uint16Array) || _instanceof(value, Int16Array) || _instanceof(value, Int8Array) || _instanceof(value, Uint8ClampedArray)) {
20889 var name = value.constructor.name;
20890 return {
20891 rr_type: name,
20892 args: [
20893 Object.values(value)
20894 ]
20895 };
20896 } else if (// SharedArrayBuffer disabled on most browsers due to spectre.
20897 // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer
20898 // value instanceof SharedArrayBuffer ||
20899 _instanceof(value, ArrayBuffer)) {
20900 var name1 = value.constructor.name;
20901 var base64 = encode(value);
20902 return {
20903 rr_type: name1,
20904 base64: base64
20905 };
20906 } else if (_instanceof(value, DataView)) {
20907 var name2 = value.constructor.name;
20908 return {
20909 rr_type: name2,
20910 args: [
20911 serializeArg(value.buffer, win, ctx),
20912 value.byteOffset,
20913 value.byteLength
20914 ]
20915 };
20916 } else if (_instanceof(value, HTMLImageElement)) {
20917 var name3 = value.constructor.name;
20918 var src = value.src;
20919 return {
20920 rr_type: name3,
20921 src: src
20922 };
20923 } else if (_instanceof(value, HTMLCanvasElement)) {
20924 var name4 = "HTMLImageElement";
20925 var src1 = value.toDataURL();
20926 return {
20927 rr_type: name4,
20928 src: src1
20929 };
20930 } else if (_instanceof(value, ImageData)) {
20931 var name5 = value.constructor.name;
20932 return {
20933 rr_type: name5,
20934 args: [
20935 serializeArg(value.data, win, ctx),
20936 value.width,
20937 value.height
20938 ]
20939 };
20940 } else if (isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
20941 var name6 = value.constructor.name;
20942 var index2 = saveWebGLVar(value, win, ctx);
20943 return {
20944 rr_type: name6,
20945 index: index2
20946 };
20947 }
20948 return value;
20949 }
20950 var serializeArgs = function(args, win, ctx) {
20951 return args.map(function(arg) {
20952 return serializeArg(arg, win, ctx);
20953 });
20954 };
20955 var isInstanceOfWebGLObject = function(value, win) {
20956 var webGLConstructorNames = [
20957 "WebGLActiveInfo",
20958 "WebGLBuffer",
20959 "WebGLFramebuffer",
20960 "WebGLProgram",
20961 "WebGLRenderbuffer",
20962 "WebGLShader",
20963 "WebGLShaderPrecisionFormat",
20964 "WebGLTexture",
20965 "WebGLUniformLocation",
20966 "WebGLVertexArrayObject",
20967 // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.
20968 "WebGLVertexArrayObjectOES"
20969 ];
20970 var supportedWebGLConstructorNames = webGLConstructorNames.filter(function(name) {
20971 return typeof win[name] === "function";
20972 });
20973 return Boolean(supportedWebGLConstructorNames.find(function(name) {
20974 return _instanceof(value, win[name]);
20975 }));
20976 };
20977 function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
20978 var _loop = function() {
20979 var prop = _step.value;
20980 try {
20981 if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
20982 return "continue";
20983 }
20984 var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
20985 return function() {
20986 var _this = this;
20987 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
20988 args[_key] = arguments[_key];
20989 }
20990 if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
20991 setTimeout(function() {
20992 var recordArgs = serializeArgs(args, win, _this);
20993 cb(_this.canvas, {
20994 type: CanvasContext["2D"],
20995 property: prop,
20996 args: recordArgs
20997 });
20998 }, 0);
20999 }
21000 return original.apply(this, args);
21001 };
21002 });
21003 handlers.push(restoreHandler);
21004 } catch (e) {
21005 var hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
21006 set: function set(v2) {
21007 cb(this.canvas, {
21008 type: CanvasContext["2D"],
21009 property: prop,
21010 args: [
21011 v2
21012 ],
21013 setter: true
21014 });
21015 }
21016 });
21017 handlers.push(hookHandler);
21018 }
21019 };
21020 var handlers = [];
21021 var props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
21022 for(var _iterator = _create_for_of_iterator_helper_loose(props2D), _step; !(_step = _iterator()).done;)_loop();
21023 return function() {
21024 handlers.forEach(function(h) {
21025 return h();
21026 });
21027 };
21028 }
21029 function getNormalizedContextName(contextType) {
21030 return contextType === "experimental-webgl" ? "webgl" : contextType;
21031 }
21032 function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
21033 var handlers = [];
21034 try {
21035 var restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
21036 return function(contextType) {
21037 for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
21038 args[_key - 1] = arguments[_key];
21039 }
21040 if (!isBlocked(this, blockClass, blockSelector, true)) {
21041 var ctxName = getNormalizedContextName(contextType);
21042 if (!("__context" in this)) this.__context = ctxName;
21043 if (setPreserveDrawingBufferToTrue && [
21044 "webgl",
21045 "webgl2"
21046 ].includes(ctxName)) {
21047 if (args[0] && _type_of(args[0]) === "object") {
21048 var contextAttributes = args[0];
21049 if (!contextAttributes.preserveDrawingBuffer) {
21050 contextAttributes.preserveDrawingBuffer = true;
21051 }
21052 } else {
21053 args.splice(0, 1, {
21054 preserveDrawingBuffer: true
21055 });
21056 }
21057 }
21058 }
21059 return original.apply(this, [].concat([
21060 contextType
21061 ], args));
21062 };
21063 });
21064 handlers.push(restoreHandler);
21065 } catch (e) {
21066 console.error("failed to patch HTMLCanvasElement.prototype.getContext");
21067 }
21068 return function() {
21069 handlers.forEach(function(h) {
21070 return h();
21071 });
21072 };
21073 }
21074 function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
21075 var _loop = function() {
21076 var prop = _step.value;
21077 if (//prop.startsWith('get') || // e.g. getProgramParameter, but too risky
21078 [
21079 "isContextLost",
21080 "canvas",
21081 "drawingBufferWidth",
21082 "drawingBufferHeight"
21083 ].includes(prop)) {
21084 return "continue";
21085 }
21086 try {
21087 if (typeof prototype[prop] !== "function") {
21088 return "continue";
21089 }
21090 var restoreHandler = patch(prototype, prop, function(original) {
21091 return function() {
21092 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21093 args[_key] = arguments[_key];
21094 }
21095 var result2 = original.apply(this, args);
21096 saveWebGLVar(result2, win, this);
21097 if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
21098 var recordArgs = serializeArgs(args, win, this);
21099 var mutation = {
21100 type: type,
21101 property: prop,
21102 args: recordArgs
21103 };
21104 cb(this.canvas, mutation);
21105 }
21106 return result2;
21107 };
21108 });
21109 handlers.push(restoreHandler);
21110 } catch (e) {
21111 var hookHandler = hookSetter(prototype, prop, {
21112 set: function set(v2) {
21113 cb(this.canvas, {
21114 type: type,
21115 property: prop,
21116 args: [
21117 v2
21118 ],
21119 setter: true
21120 });
21121 }
21122 });
21123 handlers.push(hookHandler);
21124 }
21125 };
21126 var handlers = [];
21127 var props = Object.getOwnPropertyNames(prototype);
21128 for(var _iterator = _create_for_of_iterator_helper_loose(props), _step; !(_step = _iterator()).done;)_loop();
21129 return handlers;
21130 }
21131 function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
21132 var _handlers;
21133 var handlers = [];
21134 (_handlers = handlers).push.apply(_handlers, [].concat(patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, blockSelector, win)));
21135 if (typeof win.WebGL2RenderingContext !== "undefined") {
21136 var _handlers1;
21137 (_handlers1 = handlers).push.apply(_handlers1, [].concat(patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, blockSelector, win)));
21138 }
21139 return function() {
21140 handlers.forEach(function(h) {
21141 return h();
21142 });
21143 };
21144 }
21145 var encodedJs = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=";
21146 var decodeBase64 = function(base64) {
21147 return Uint8Array.from(atob(base64), function(c2) {
21148 return c2.charCodeAt(0);
21149 });
21150 };
21151 var blob = typeof window !== "undefined" && window.Blob && new Blob([
21152 decodeBase64(encodedJs)
21153 ], {
21154 type: "text/javascript;charset=utf-8"
21155 });
21156 function WorkerWrapper(options) {
21157 var objURL;
21158 try {
21159 objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
21160 if (!objURL) throw "";
21161 var worker = new Worker(objURL, {
21162 name: options == null ? void 0 : options.name
21163 });
21164 worker.addEventListener("error", function() {
21165 (window.URL || window.webkitURL).revokeObjectURL(objURL);
21166 });
21167 return worker;
21168 } catch (e2) {
21169 return new Worker("data:text/javascript;base64," + encodedJs, {
21170 name: options == null ? void 0 : options.name
21171 });
21172 } finally{
21173 objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
21174 }
21175 }
21176 var CanvasManager = /*#__PURE__*/ function() {
21177 function CanvasManager(options) {
21178 var _this = this;
21179 __publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
21180 __publicField(this, "rafStamps", {
21181 latestId: 0,
21182 invokeId: null
21183 });
21184 __publicField(this, "mirror");
21185 __publicField(this, "mutationCb");
21186 __publicField(this, "resetObservers");
21187 __publicField(this, "frozen", false);
21188 __publicField(this, "locked", false);
21189 __publicField(this, "processMutation", function(target, mutation) {
21190 var newFrame = _this.rafStamps.invokeId && _this.rafStamps.latestId !== _this.rafStamps.invokeId;
21191 if (newFrame || !_this.rafStamps.invokeId) _this.rafStamps.invokeId = _this.rafStamps.latestId;
21192 if (!_this.pendingCanvasMutations.has(target)) {
21193 _this.pendingCanvasMutations.set(target, []);
21194 }
21195 _this.pendingCanvasMutations.get(target).push(mutation);
21196 });
21197 var _options_sampling = options.sampling, sampling = _options_sampling === void 0 ? "all" : _options_sampling, win = options.win, blockClass = options.blockClass, blockSelector = options.blockSelector, recordCanvas = options.recordCanvas, dataURLOptions = options.dataURLOptions;
21198 this.mutationCb = options.mutationCb;
21199 this.mirror = options.mirror;
21200 if (recordCanvas && sampling === "all") this.initCanvasMutationObserver(win, blockClass, blockSelector);
21201 if (recordCanvas && typeof sampling === "number") this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
21202 dataURLOptions: dataURLOptions
21203 });
21204 }
21205 var _proto = CanvasManager.prototype;
21206 _proto.reset = function reset() {
21207 this.pendingCanvasMutations.clear();
21208 this.resetObservers && this.resetObservers();
21209 };
21210 _proto.freeze = function freeze() {
21211 this.frozen = true;
21212 };
21213 _proto.unfreeze = function unfreeze() {
21214 this.frozen = false;
21215 };
21216 _proto.lock = function lock() {
21217 this.locked = true;
21218 };
21219 _proto.unlock = function unlock() {
21220 this.locked = false;
21221 };
21222 _proto.initCanvasFPSObserver = function initCanvasFPSObserver(fps, win, blockClass, blockSelector, options) {
21223 var _this = this;
21224 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, true);
21225 var snapshotInProgressMap = /* @__PURE__ */ new Map();
21226 var worker = new WorkerWrapper();
21227 worker.onmessage = function(e2) {
21228 var id = e2.data.id;
21229 snapshotInProgressMap.set(id, false);
21230 if (!("base64" in e2.data)) return;
21231 var _e2_data = e2.data, base64 = _e2_data.base64, type = _e2_data.type, width = _e2_data.width, height = _e2_data.height;
21232 _this.mutationCb({
21233 id: id,
21234 type: CanvasContext["2D"],
21235 commands: [
21236 {
21237 property: "clearRect",
21238 // wipe canvas
21239 args: [
21240 0,
21241 0,
21242 width,
21243 height
21244 ]
21245 },
21246 {
21247 property: "drawImage",
21248 // draws (semi-transparent) image
21249 args: [
21250 {
21251 rr_type: "ImageBitmap",
21252 args: [
21253 {
21254 rr_type: "Blob",
21255 data: [
21256 {
21257 rr_type: "ArrayBuffer",
21258 base64: base64
21259 }
21260 ],
21261 type: type
21262 }
21263 ]
21264 },
21265 0,
21266 0
21267 ]
21268 }
21269 ]
21270 });
21271 };
21272 var timeBetweenSnapshots = 1e3 / fps;
21273 var lastSnapshotTime = 0;
21274 var rafId;
21275 var getCanvas = function() {
21276 var matchedCanvas = [];
21277 win.document.querySelectorAll("canvas").forEach(function(canvas) {
21278 if (!isBlocked(canvas, blockClass, blockSelector, true)) {
21279 matchedCanvas.push(canvas);
21280 }
21281 });
21282 return matchedCanvas;
21283 };
21284 var takeCanvasSnapshots = function(timestamp) {
21285 if (lastSnapshotTime && timestamp - lastSnapshotTime < timeBetweenSnapshots) {
21286 rafId = requestAnimationFrame(takeCanvasSnapshots);
21287 return;
21288 }
21289 lastSnapshotTime = timestamp;
21290 var _this1 = _this;
21291 getCanvas().forEach(/*#__PURE__*/ _async_to_generator(function(canvas) {
21292 var _a2, id, context, bitmap;
21293 return _ts_generator(this, function(_state) {
21294 switch(_state.label){
21295 case 0:
21296 id = _this1.mirror.getId(canvas);
21297 if (snapshotInProgressMap.get(id)) return [
21298 2
21299 ];
21300 if (canvas.width === 0 || canvas.height === 0) return [
21301 2
21302 ];
21303 snapshotInProgressMap.set(id, true);
21304 if ([
21305 "webgl",
21306 "webgl2"
21307 ].includes(canvas.__context)) {
21308 context = canvas.getContext(canvas.__context);
21309 if (((_a2 = context == null ? void 0 : context.getContextAttributes()) == null ? void 0 : _a2.preserveDrawingBuffer) === false) {
21310 context.clear(context.COLOR_BUFFER_BIT);
21311 }
21312 }
21313 return [
21314 4,
21315 createImageBitmap(canvas)
21316 ];
21317 case 1:
21318 bitmap = _state.sent();
21319 worker.postMessage({
21320 id: id,
21321 bitmap: bitmap,
21322 width: canvas.width,
21323 height: canvas.height,
21324 dataURLOptions: options.dataURLOptions
21325 }, [
21326 bitmap
21327 ]);
21328 return [
21329 2
21330 ];
21331 }
21332 });
21333 }));
21334 rafId = requestAnimationFrame(takeCanvasSnapshots);
21335 };
21336 rafId = requestAnimationFrame(takeCanvasSnapshots);
21337 this.resetObservers = function() {
21338 canvasContextReset();
21339 cancelAnimationFrame(rafId);
21340 };
21341 };
21342 _proto.initCanvasMutationObserver = function initCanvasMutationObserver(win, blockClass, blockSelector) {
21343 this.startRAFTimestamping();
21344 this.startPendingCanvasMutationFlusher();
21345 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, false);
21346 var canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21347 var canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21348 this.resetObservers = function() {
21349 canvasContextReset();
21350 canvas2DReset();
21351 canvasWebGL1and2Reset();
21352 };
21353 };
21354 _proto.startPendingCanvasMutationFlusher = function startPendingCanvasMutationFlusher() {
21355 var _this = this;
21356 requestAnimationFrame(function() {
21357 return _this.flushPendingCanvasMutations();
21358 });
21359 };
21360 _proto.startRAFTimestamping = function startRAFTimestamping() {
21361 var _this = this;
21362 var setLatestRAFTimestamp = function(timestamp) {
21363 _this.rafStamps.latestId = timestamp;
21364 requestAnimationFrame(setLatestRAFTimestamp);
21365 };
21366 requestAnimationFrame(setLatestRAFTimestamp);
21367 };
21368 _proto.flushPendingCanvasMutations = function flushPendingCanvasMutations() {
21369 var _this = this;
21370 this.pendingCanvasMutations.forEach(function(_values, canvas) {
21371 var id = _this.mirror.getId(canvas);
21372 _this.flushPendingCanvasMutationFor(canvas, id);
21373 });
21374 requestAnimationFrame(function() {
21375 return _this.flushPendingCanvasMutations();
21376 });
21377 };
21378 _proto.flushPendingCanvasMutationFor = function flushPendingCanvasMutationFor(canvas, id) {
21379 if (this.frozen || this.locked) {
21380 return;
21381 }
21382 var valuesWithType = this.pendingCanvasMutations.get(canvas);
21383 if (!valuesWithType || id === -1) return;
21384 var values = valuesWithType.map(function(value) {
21385 value.type; var rest = _object_without_properties_loose(value, [
21386 "type"
21387 ]);
21388 return rest;
21389 });
21390 var type = valuesWithType[0].type;
21391 this.mutationCb({
21392 id: id,
21393 type: type,
21394 commands: values
21395 });
21396 this.pendingCanvasMutations.delete(canvas);
21397 };
21398 return CanvasManager;
21399 }();
21400 var StylesheetManager = /*#__PURE__*/ function() {
21401 function StylesheetManager(options) {
21402 __publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
21403 __publicField(this, "mutationCb");
21404 __publicField(this, "adoptedStyleSheetCb");
21405 __publicField(this, "styleMirror", new StyleSheetMirror());
21406 this.mutationCb = options.mutationCb;
21407 this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
21408 }
21409 var _proto = StylesheetManager.prototype;
21410 _proto.attachLinkElement = function attachLinkElement(linkEl, childSn) {
21411 if ("_cssText" in childSn.attributes) this.mutationCb({
21412 adds: [],
21413 removes: [],
21414 texts: [],
21415 attributes: [
21416 {
21417 id: childSn.id,
21418 attributes: childSn.attributes
21419 }
21420 ]
21421 });
21422 this.trackLinkElement(linkEl);
21423 };
21424 _proto.trackLinkElement = function trackLinkElement(linkEl) {
21425 if (this.trackedLinkElements.has(linkEl)) return;
21426 this.trackedLinkElements.add(linkEl);
21427 this.trackStylesheetInLinkElement(linkEl);
21428 };
21429 _proto.adoptStyleSheets = function adoptStyleSheets(sheets, hostId) {
21430 var _this, _loop = function() {
21431 var sheet = _step.value;
21432 var styleId = void 0;
21433 if (!_this.styleMirror.has(sheet)) {
21434 styleId = _this.styleMirror.add(sheet);
21435 styles.push({
21436 styleId: styleId,
21437 rules: Array.from(sheet.rules || CSSRule, function(r2, index2) {
21438 return {
21439 rule: stringifyRule(r2, sheet.href),
21440 index: index2
21441 };
21442 })
21443 });
21444 } else styleId = _this.styleMirror.getId(sheet);
21445 adoptedStyleSheetData.styleIds.push(styleId);
21446 };
21447 if (sheets.length === 0) return;
21448 var adoptedStyleSheetData = {
21449 id: hostId,
21450 styleIds: []
21451 };
21452 var styles = [];
21453 for(var _iterator = _create_for_of_iterator_helper_loose(sheets), _step; !(_step = _iterator()).done;)_this = this, _loop();
21454 if (styles.length > 0) adoptedStyleSheetData.styles = styles;
21455 this.adoptedStyleSheetCb(adoptedStyleSheetData);
21456 };
21457 _proto.reset = function reset() {
21458 this.styleMirror.reset();
21459 this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
21460 };
21461 // TODO: take snapshot on stylesheet reload by applying event listener
21462 _proto.trackStylesheetInLinkElement = function trackStylesheetInLinkElement(_linkEl) {};
21463 return StylesheetManager;
21464 }();
21465 var ProcessedNodeManager = /*#__PURE__*/ function() {
21466 function ProcessedNodeManager() {
21467 __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap());
21468 __publicField(this, "active", false);
21469 }
21470 var _proto = ProcessedNodeManager.prototype;
21471 _proto.inOtherBuffer = function inOtherBuffer(node2, thisBuffer) {
21472 var buffers = this.nodeMap.get(node2);
21473 return buffers && Array.from(buffers).some(function(buffer) {
21474 return buffer !== thisBuffer;
21475 });
21476 };
21477 _proto.add = function add(node2, buffer) {
21478 var _this = this;
21479 if (!this.active) {
21480 this.active = true;
21481 requestAnimationFrame(function() {
21482 _this.nodeMap = /* @__PURE__ */ new WeakMap();
21483 _this.active = false;
21484 });
21485 }
21486 this.nodeMap.set(node2, (this.nodeMap.get(node2) || /* @__PURE__ */ new Set()).add(buffer));
21487 };
21488 _proto.destroy = function destroy() {};
21489 return ProcessedNodeManager;
21490 }();
21491 var wrappedEmit;
21492 var takeFullSnapshot$1;
21493 var canvasManager;
21494 var recording = false;
21495 try {
21496 if (Array.from([
21497 1
21498 ], function(x2) {
21499 return x2 * 2;
21500 })[0] !== 2) {
21501 var cleanFrame = document.createElement("iframe");
21502 document.body.appendChild(cleanFrame);
21503 Array.from = ((_a = cleanFrame.contentWindow) == null ? void 0 : _a.Array.from) || Array.from;
21504 document.body.removeChild(cleanFrame);
21505 }
21506 } catch (err) {
21507 console.debug("Unable to override Array.from", err);
21508 }
21509 var mirror = createMirror$2();
21510 function record(options) {
21511 if (options === void 0) options = {};
21512 var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _options_blockClass = options.blockClass, blockClass = _options_blockClass === void 0 ? "rr-block" : _options_blockClass, _options_blockSelector = options.blockSelector, blockSelector = _options_blockSelector === void 0 ? null : _options_blockSelector, _options_ignoreClass = options.ignoreClass, ignoreClass = _options_ignoreClass === void 0 ? "rr-ignore" : _options_ignoreClass, _options_ignoreSelector = options.ignoreSelector, ignoreSelector = _options_ignoreSelector === void 0 ? null : _options_ignoreSelector, _options_maskTextClass = options.maskTextClass, maskTextClass = _options_maskTextClass === void 0 ? "rr-mask" : _options_maskTextClass, _options_maskTextSelector = options.maskTextSelector, maskTextSelector = _options_maskTextSelector === void 0 ? null : _options_maskTextSelector, _options_inlineStylesheet = options.inlineStylesheet, inlineStylesheet = _options_inlineStylesheet === void 0 ? true : _options_inlineStylesheet, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _options_sampling = options.sampling, sampling = _options_sampling === void 0 ? {} : _options_sampling, _options_dataURLOptions = options.dataURLOptions, dataURLOptions = _options_dataURLOptions === void 0 ? {} : _options_dataURLOptions, mousemoveWait = options.mousemoveWait, _options_recordDOM = options.recordDOM, recordDOM = _options_recordDOM === void 0 ? true : _options_recordDOM, _options_recordCanvas = options.recordCanvas, recordCanvas = _options_recordCanvas === void 0 ? false : _options_recordCanvas, _options_recordCrossOriginIframes = options.recordCrossOriginIframes, recordCrossOriginIframes = _options_recordCrossOriginIframes === void 0 ? false : _options_recordCrossOriginIframes, _options_recordAfter = options.recordAfter, recordAfter = _options_recordAfter === void 0 ? options.recordAfter === "DOMContentLoaded" ? options.recordAfter : "load" : _options_recordAfter, _options_userTriggeredOnInput = options.userTriggeredOnInput, userTriggeredOnInput = _options_userTriggeredOnInput === void 0 ? false : _options_userTriggeredOnInput, _options_collectFonts = options.collectFonts, collectFonts = _options_collectFonts === void 0 ? false : _options_collectFonts, _options_inlineImages = options.inlineImages, inlineImages = _options_inlineImages === void 0 ? false : _options_inlineImages, plugins = options.plugins, _options_keepIframeSrcFn = options.keepIframeSrcFn, keepIframeSrcFn = _options_keepIframeSrcFn === void 0 ? function() {
21513 return false;
21514 } : _options_keepIframeSrcFn, _options_ignoreCSSAttributes = options.ignoreCSSAttributes, ignoreCSSAttributes = _options_ignoreCSSAttributes === void 0 ? /* @__PURE__ */ new Set([]) : _options_ignoreCSSAttributes, errorHandler2 = options.errorHandler;
21515 registerErrorHandler(errorHandler2);
21516 var inEmittingFrame = recordCrossOriginIframes ? window.parent === window : true;
21517 var passEmitsToParent = false;
21518 if (!inEmittingFrame) {
21519 try {
21520 if (window.parent.document) {
21521 passEmitsToParent = false;
21522 }
21523 } catch (e2) {
21524 passEmitsToParent = true;
21525 }
21526 }
21527 if (inEmittingFrame && !emit) {
21528 throw new Error("emit function is required");
21529 }
21530 if (!inEmittingFrame && !passEmitsToParent) {
21531 return function() {};
21532 }
21533 if (mousemoveWait !== void 0 && sampling.mousemove === void 0) {
21534 sampling.mousemove = mousemoveWait;
21535 }
21536 mirror.reset();
21537 var maskInputOptions = maskAllInputs === true ? {
21538 color: true,
21539 date: true,
21540 "datetime-local": true,
21541 email: true,
21542 month: true,
21543 number: true,
21544 range: true,
21545 search: true,
21546 tel: true,
21547 text: true,
21548 time: true,
21549 url: true,
21550 week: true,
21551 textarea: true,
21552 select: true,
21553 password: true,
21554 hidden: true
21555 } : _maskInputOptions !== void 0 ? _maskInputOptions : {
21556 password: true
21557 };
21558 var slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
21559 script: true,
21560 comment: true,
21561 headFavicon: true,
21562 headWhitespace: true,
21563 headMetaSocial: true,
21564 headMetaRobots: true,
21565 headMetaHttpEquiv: true,
21566 headMetaVerification: true,
21567 // the following are off for slimDOMOptions === true,
21568 // as they destroy some (hidden) info:
21569 headMetaAuthorship: _slimDOMOptions === "all",
21570 headMetaDescKeywords: _slimDOMOptions === "all",
21571 headTitleMutations: _slimDOMOptions === "all"
21572 } : _slimDOMOptions ? _slimDOMOptions : {};
21573 polyfill$1();
21574 var lastFullSnapshotEvent;
21575 var incrementalSnapshotCount = 0;
21576 var eventProcessor = function(e2) {
21577 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
21578 var plugin3 = _step.value;
21579 if (plugin3.eventProcessor) {
21580 e2 = plugin3.eventProcessor(e2);
21581 }
21582 }
21583 if (packFn && // Disable packing events which will be emitted to parent frames.
21584 !passEmitsToParent) {
21585 e2 = packFn(e2);
21586 }
21587 return e2;
21588 };
21589 wrappedEmit = function(r2, isCheckout) {
21590 var _a2;
21591 var e2 = r2;
21592 e2.timestamp = nowTimestamp();
21593 if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
21594 mutationBuffers.forEach(function(buf) {
21595 return buf.unfreeze();
21596 });
21597 }
21598 if (inEmittingFrame) {
21599 emit == null ? void 0 : emit(eventProcessor(e2), isCheckout);
21600 } else if (passEmitsToParent) {
21601 var message = {
21602 type: "rrweb",
21603 event: eventProcessor(e2),
21604 origin: window.location.origin,
21605 isCheckout: isCheckout
21606 };
21607 window.parent.postMessage(message, "*");
21608 }
21609 if (e2.type === EventType.FullSnapshot) {
21610 lastFullSnapshotEvent = e2;
21611 incrementalSnapshotCount = 0;
21612 } else if (e2.type === EventType.IncrementalSnapshot) {
21613 if (e2.data.source === IncrementalSource.Mutation && e2.data.isAttachIframe) {
21614 return;
21615 }
21616 incrementalSnapshotCount++;
21617 var exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
21618 var exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
21619 if (exceedCount || exceedTime) {
21620 takeFullSnapshot$1(true);
21621 }
21622 }
21623 };
21624 var wrappedMutationEmit = function(m) {
21625 wrappedEmit({
21626 type: EventType.IncrementalSnapshot,
21627 data: _extends({
21628 source: IncrementalSource.Mutation
21629 }, m)
21630 });
21631 };
21632 var wrappedScrollEmit = function(p) {
21633 return wrappedEmit({
21634 type: EventType.IncrementalSnapshot,
21635 data: _extends({
21636 source: IncrementalSource.Scroll
21637 }, p)
21638 });
21639 };
21640 var wrappedCanvasMutationEmit = function(p) {
21641 return wrappedEmit({
21642 type: EventType.IncrementalSnapshot,
21643 data: _extends({
21644 source: IncrementalSource.CanvasMutation
21645 }, p)
21646 });
21647 };
21648 var wrappedAdoptedStyleSheetEmit = function(a2) {
21649 return wrappedEmit({
21650 type: EventType.IncrementalSnapshot,
21651 data: _extends({
21652 source: IncrementalSource.AdoptedStyleSheet
21653 }, a2)
21654 });
21655 };
21656 var stylesheetManager = new StylesheetManager({
21657 mutationCb: wrappedMutationEmit,
21658 adoptedStyleSheetCb: wrappedAdoptedStyleSheetEmit
21659 });
21660 var iframeManager = new IframeManager({
21661 mirror: mirror,
21662 mutationCb: wrappedMutationEmit,
21663 stylesheetManager: stylesheetManager,
21664 recordCrossOriginIframes: recordCrossOriginIframes,
21665 wrappedEmit: wrappedEmit
21666 });
21667 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
21668 var plugin3 = _step.value;
21669 if (plugin3.getMirror) plugin3.getMirror({
21670 nodeMirror: mirror,
21671 crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,
21672 crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror
21673 });
21674 }
21675 var processedNodeManager = new ProcessedNodeManager();
21676 canvasManager = new CanvasManager({
21677 recordCanvas: recordCanvas,
21678 mutationCb: wrappedCanvasMutationEmit,
21679 win: window,
21680 blockClass: blockClass,
21681 blockSelector: blockSelector,
21682 mirror: mirror,
21683 sampling: sampling.canvas,
21684 dataURLOptions: dataURLOptions
21685 });
21686 var shadowDomManager = new ShadowDomManager({
21687 mutationCb: wrappedMutationEmit,
21688 scrollCb: wrappedScrollEmit,
21689 bypassOptions: {
21690 blockClass: blockClass,
21691 blockSelector: blockSelector,
21692 maskTextClass: maskTextClass,
21693 maskTextSelector: maskTextSelector,
21694 inlineStylesheet: inlineStylesheet,
21695 maskInputOptions: maskInputOptions,
21696 dataURLOptions: dataURLOptions,
21697 maskTextFn: maskTextFn,
21698 maskInputFn: maskInputFn,
21699 recordCanvas: recordCanvas,
21700 inlineImages: inlineImages,
21701 sampling: sampling,
21702 slimDOMOptions: slimDOMOptions,
21703 iframeManager: iframeManager,
21704 stylesheetManager: stylesheetManager,
21705 canvasManager: canvasManager,
21706 keepIframeSrcFn: keepIframeSrcFn,
21707 processedNodeManager: processedNodeManager
21708 },
21709 mirror: mirror
21710 });
21711 takeFullSnapshot$1 = function(isCheckout) {
21712 if (isCheckout === void 0) isCheckout = false;
21713 if (!recordDOM) {
21714 return;
21715 }
21716 wrappedEmit({
21717 type: EventType.Meta,
21718 data: {
21719 href: window.location.href,
21720 width: getWindowWidth(),
21721 height: getWindowHeight()
21722 }
21723 }, isCheckout);
21724 stylesheetManager.reset();
21725 shadowDomManager.init();
21726 mutationBuffers.forEach(function(buf) {
21727 return buf.lock();
21728 });
21729 var node2 = snapshot(document, {
21730 mirror: mirror,
21731 blockClass: blockClass,
21732 blockSelector: blockSelector,
21733 maskTextClass: maskTextClass,
21734 maskTextSelector: maskTextSelector,
21735 inlineStylesheet: inlineStylesheet,
21736 maskAllInputs: maskInputOptions,
21737 maskTextFn: maskTextFn,
21738 maskInputFn: maskInputFn,
21739 slimDOM: slimDOMOptions,
21740 dataURLOptions: dataURLOptions,
21741 recordCanvas: recordCanvas,
21742 inlineImages: inlineImages,
21743 onSerialize: function(n2) {
21744 if (isSerializedIframe(n2, mirror)) {
21745 iframeManager.addIframe(n2);
21746 }
21747 if (isSerializedStylesheet(n2, mirror)) {
21748 stylesheetManager.trackLinkElement(n2);
21749 }
21750 if (hasShadowRoot(n2)) {
21751 shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
21752 }
21753 },
21754 onIframeLoad: function(iframe, childSn) {
21755 iframeManager.attachIframe(iframe, childSn);
21756 shadowDomManager.observeAttachShadow(iframe);
21757 },
21758 onStylesheetLoad: function(linkEl, childSn) {
21759 stylesheetManager.attachLinkElement(linkEl, childSn);
21760 },
21761 keepIframeSrcFn: keepIframeSrcFn
21762 });
21763 if (!node2) {
21764 return console.warn("Failed to snapshot the document");
21765 }
21766 wrappedEmit({
21767 type: EventType.FullSnapshot,
21768 data: {
21769 node: node2,
21770 initialOffset: getWindowScroll(window)
21771 }
21772 }, isCheckout);
21773 mutationBuffers.forEach(function(buf) {
21774 return buf.unlock();
21775 });
21776 if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0) stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.getId(document));
21777 };
21778 try {
21779 var handlers = [];
21780 var observe = function(doc) {
21781 var _a2;
21782 return callbackWrapper(initObservers)({
21783 mutationCb: wrappedMutationEmit,
21784 mousemoveCb: function(positions, source) {
21785 return wrappedEmit({
21786 type: EventType.IncrementalSnapshot,
21787 data: {
21788 source: source,
21789 positions: positions
21790 }
21791 });
21792 },
21793 mouseInteractionCb: function(d) {
21794 return wrappedEmit({
21795 type: EventType.IncrementalSnapshot,
21796 data: _extends({
21797 source: IncrementalSource.MouseInteraction
21798 }, d)
21799 });
21800 },
21801 scrollCb: wrappedScrollEmit,
21802 viewportResizeCb: function(d) {
21803 return wrappedEmit({
21804 type: EventType.IncrementalSnapshot,
21805 data: _extends({
21806 source: IncrementalSource.ViewportResize
21807 }, d)
21808 });
21809 },
21810 inputCb: function(v2) {
21811 return wrappedEmit({
21812 type: EventType.IncrementalSnapshot,
21813 data: _extends({
21814 source: IncrementalSource.Input
21815 }, v2)
21816 });
21817 },
21818 mediaInteractionCb: function(p) {
21819 return wrappedEmit({
21820 type: EventType.IncrementalSnapshot,
21821 data: _extends({
21822 source: IncrementalSource.MediaInteraction
21823 }, p)
21824 });
21825 },
21826 styleSheetRuleCb: function(r2) {
21827 return wrappedEmit({
21828 type: EventType.IncrementalSnapshot,
21829 data: _extends({
21830 source: IncrementalSource.StyleSheetRule
21831 }, r2)
21832 });
21833 },
21834 styleDeclarationCb: function(r2) {
21835 return wrappedEmit({
21836 type: EventType.IncrementalSnapshot,
21837 data: _extends({
21838 source: IncrementalSource.StyleDeclaration
21839 }, r2)
21840 });
21841 },
21842 canvasMutationCb: wrappedCanvasMutationEmit,
21843 fontCb: function(p) {
21844 return wrappedEmit({
21845 type: EventType.IncrementalSnapshot,
21846 data: _extends({
21847 source: IncrementalSource.Font
21848 }, p)
21849 });
21850 },
21851 selectionCb: function(p) {
21852 wrappedEmit({
21853 type: EventType.IncrementalSnapshot,
21854 data: _extends({
21855 source: IncrementalSource.Selection
21856 }, p)
21857 });
21858 },
21859 customElementCb: function(c2) {
21860 wrappedEmit({
21861 type: EventType.IncrementalSnapshot,
21862 data: _extends({
21863 source: IncrementalSource.CustomElement
21864 }, c2)
21865 });
21866 },
21867 blockClass: blockClass,
21868 ignoreClass: ignoreClass,
21869 ignoreSelector: ignoreSelector,
21870 maskTextClass: maskTextClass,
21871 maskTextSelector: maskTextSelector,
21872 maskInputOptions: maskInputOptions,
21873 inlineStylesheet: inlineStylesheet,
21874 sampling: sampling,
21875 recordDOM: recordDOM,
21876 recordCanvas: recordCanvas,
21877 inlineImages: inlineImages,
21878 userTriggeredOnInput: userTriggeredOnInput,
21879 collectFonts: collectFonts,
21880 doc: doc,
21881 maskInputFn: maskInputFn,
21882 maskTextFn: maskTextFn,
21883 keepIframeSrcFn: keepIframeSrcFn,
21884 blockSelector: blockSelector,
21885 slimDOMOptions: slimDOMOptions,
21886 dataURLOptions: dataURLOptions,
21887 mirror: mirror,
21888 iframeManager: iframeManager,
21889 stylesheetManager: stylesheetManager,
21890 shadowDomManager: shadowDomManager,
21891 processedNodeManager: processedNodeManager,
21892 canvasManager: canvasManager,
21893 ignoreCSSAttributes: ignoreCSSAttributes,
21894 plugins: ((_a2 = plugins == null ? void 0 : plugins.filter(function(p) {
21895 return p.observer;
21896 })) == null ? void 0 : _a2.map(function(p) {
21897 return {
21898 observer: p.observer,
21899 options: p.options,
21900 callback: function(payload) {
21901 return wrappedEmit({
21902 type: EventType.Plugin,
21903 data: {
21904 plugin: p.name,
21905 payload: payload
21906 }
21907 });
21908 }
21909 };
21910 })) || []
21911 }, hooks);
21912 };
21913 iframeManager.addLoadListener(function(iframeEl) {
21914 try {
21915 handlers.push(observe(iframeEl.contentDocument));
21916 } catch (error) {
21917 console.warn(error);
21918 }
21919 });
21920 var init = function() {
21921 takeFullSnapshot$1();
21922 handlers.push(observe(document));
21923 recording = true;
21924 };
21925 if (document.readyState === "interactive" || document.readyState === "complete") {
21926 init();
21927 } else {
21928 handlers.push(on("DOMContentLoaded", function() {
21929 wrappedEmit({
21930 type: EventType.DomContentLoaded,
21931 data: {}
21932 });
21933 if (recordAfter === "DOMContentLoaded") init();
21934 }));
21935 handlers.push(on("load", function() {
21936 wrappedEmit({
21937 type: EventType.Load,
21938 data: {}
21939 });
21940 if (recordAfter === "load") init();
21941 }, window));
21942 }
21943 return function() {
21944 handlers.forEach(function(handler) {
21945 try {
21946 handler();
21947 } catch (error) {
21948 var msg = String(error).toLowerCase();
21949 if (!msg.includes("cross-origin")) {
21950 console.warn(error);
21951 }
21952 }
21953 });
21954 processedNodeManager.destroy();
21955 recording = false;
21956 unregisterErrorHandler();
21957 };
21958 } catch (error) {
21959 console.warn(error);
21960 }
21961 }
21962 record.addCustomEvent = function(tag, payload) {
21963 if (!recording) {
21964 throw new Error("please add custom event after start recording");
21965 }
21966 wrappedEmit({
21967 type: EventType.Custom,
21968 data: {
21969 tag: tag,
21970 payload: payload
21971 }
21972 });
21973 };
21974 record.freezePage = function() {
21975 mutationBuffers.forEach(function(buf) {
21976 return buf.freeze();
21977 });
21978 };
21979 record.takeFullSnapshot = function(isCheckout) {
21980 if (!recording) {
21981 throw new Error("please take full snapshot after start recording");
21982 }
21983 takeFullSnapshot$1(isCheckout);
21984 };
21985 record.mirror = mirror;
21986 var n;
21987 !function(t2) {
21988 t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
21989 }(n || (n = {}));
21990 record.addCustomEvent;
21991 record.freezePage;
21992 record.takeFullSnapshot;
21993
21994 var setImmediate = win['setImmediate'];
21995 var builtInProp, cycle, schedulingQueue,
21996 ToString = Object.prototype.toString,
21997 timer = (typeof setImmediate !== 'undefined') ?
21998 function timer(fn) { return setImmediate(fn); } :
21999 setTimeout;
22000
22001 // dammit, IE8.
22002 try {
22003 Object.defineProperty({},'x',{});
22004 builtInProp = function builtInProp(obj,name,val,config) {
22005 return Object.defineProperty(obj,name,{
22006 value: val,
22007 writable: true,
22008 configurable: config !== false
22009 });
22010 };
22011 }
22012 catch (err) {
22013 builtInProp = function builtInProp(obj,name,val) {
22014 obj[name] = val;
22015 return obj;
22016 };
22017 }
22018
22019 // Note: using a queue instead of array for efficiency
22020 schedulingQueue = (function Queue() {
22021 var first, last, item;
22022
22023 function Item(fn,self) {
22024 this.fn = fn;
22025 this.self = self;
22026 this.next = void 0;
22027 }
22028
22029 return {
22030 add: function add(fn,self) {
22031 item = new Item(fn,self);
22032 if (last) {
22033 last.next = item;
22034 }
22035 else {
22036 first = item;
22037 }
22038 last = item;
22039 item = void 0;
22040 },
22041 drain: function drain() {
22042 var f = first;
22043 first = last = cycle = void 0;
22044
22045 while (f) {
22046 f.fn.call(f.self);
22047 f = f.next;
22048 }
22049 }
22050 };
22051 })();
22052
22053 function schedule(fn,self) {
22054 schedulingQueue.add(fn,self);
22055 if (!cycle) {
22056 cycle = timer(schedulingQueue.drain);
22057 }
22058 }
22059
22060 // promise duck typing
22061 function isThenable(o) {
22062 var _then, oType = typeof o;
22063
22064 if (o !== null && (oType === 'object' || oType === 'function')) {
22065 _then = o.then;
22066 }
22067 return typeof _then === 'function' ? _then : false;
22068 }
22069
22070 function notify() {
22071 for (var i=0; i<this.chain.length; i++) {
22072 notifyIsolated(
22073 this,
22074 (this.state === 1) ? this.chain[i].success : this.chain[i].failure,
22075 this.chain[i]
22076 );
22077 }
22078 this.chain.length = 0;
22079 }
22080
22081 // NOTE: This is a separate function to isolate
22082 // the `try..catch` so that other code can be
22083 // optimized better
22084 function notifyIsolated(self,cb,chain) {
22085 var ret, _then;
22086 try {
22087 if (cb === false) {
22088 chain.reject(self.msg);
22089 }
22090 else {
22091 if (cb === true) {
22092 ret = self.msg;
22093 }
22094 else {
22095 ret = cb.call(void 0,self.msg);
22096 }
22097
22098 if (ret === chain.promise) {
22099 chain.reject(TypeError('Promise-chain cycle'));
22100 }
22101 // eslint-disable-next-line no-cond-assign
22102 else if (_then = isThenable(ret)) {
22103 _then.call(ret,chain.resolve,chain.reject);
22104 }
22105 else {
22106 chain.resolve(ret);
22107 }
22108 }
22109 }
22110 catch (err) {
22111 chain.reject(err);
22112 }
22113 }
22114
22115 function resolve(msg) {
22116 var _then, self = this;
22117
22118 // already triggered?
22119 if (self.triggered) { return; }
22120
22121 self.triggered = true;
22122
22123 // unwrap
22124 if (self.def) {
22125 self = self.def;
22126 }
22127
22128 try {
22129 // eslint-disable-next-line no-cond-assign
22130 if (_then = isThenable(msg)) {
22131 schedule(function(){
22132 var defWrapper = new MakeDefWrapper(self);
22133 try {
22134 _then.call(msg,
22135 function $resolve$(){ resolve.apply(defWrapper,arguments); },
22136 function $reject$(){ reject.apply(defWrapper,arguments); }
22137 );
22138 }
22139 catch (err) {
22140 reject.call(defWrapper,err);
22141 }
22142 });
22143 }
22144 else {
22145 self.msg = msg;
22146 self.state = 1;
22147 if (self.chain.length > 0) {
22148 schedule(notify,self);
22149 }
22150 }
22151 }
22152 catch (err) {
22153 reject.call(new MakeDefWrapper(self),err);
22154 }
22155 }
22156
22157 function reject(msg) {
22158 var self = this;
22159
22160 // already triggered?
22161 if (self.triggered) { return; }
22162
22163 self.triggered = true;
22164
22165 // unwrap
22166 if (self.def) {
22167 self = self.def;
22168 }
22169
22170 self.msg = msg;
22171 self.state = 2;
22172 if (self.chain.length > 0) {
22173 schedule(notify,self);
22174 }
22175 }
22176
22177 function iteratePromises(Constructor,arr,resolver,rejecter) {
22178 for (var idx=0; idx<arr.length; idx++) {
22179 (function IIFE(idx){
22180 Constructor.resolve(arr[idx])
22181 .then(
22182 function $resolver$(msg){
22183 resolver(idx,msg);
22184 },
22185 rejecter
22186 );
22187 })(idx);
22188 }
22189 }
22190
22191 function MakeDefWrapper(self) {
22192 this.def = self;
22193 this.triggered = false;
22194 }
22195
22196 function MakeDef(self) {
22197 this.promise = self;
22198 this.state = 0;
22199 this.triggered = false;
22200 this.chain = [];
22201 this.msg = void 0;
22202 }
22203
22204 function NpoPromise(executor) {
22205 if (typeof executor !== 'function') {
22206 throw TypeError('Not a function');
22207 }
22208
22209 if (this['__NPO__'] !== 0) {
22210 throw TypeError('Not a promise');
22211 }
22212
22213 // instance shadowing the inherited "brand"
22214 // to signal an already "initialized" promise
22215 this['__NPO__'] = 1;
22216
22217 var def = new MakeDef(this);
22218
22219 this['then'] = function then(success,failure) {
22220 var o = {
22221 success: typeof success === 'function' ? success : true,
22222 failure: typeof failure === 'function' ? failure : false
22223 };
22224 // Note: `then(..)` itself can be borrowed to be used against
22225 // a different promise constructor for making the chained promise,
22226 // by substituting a different `this` binding.
22227 o.promise = new this.constructor(function extractChain(resolve,reject) {
22228 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22229 throw TypeError('Not a function');
22230 }
22231
22232 o.resolve = resolve;
22233 o.reject = reject;
22234 });
22235 def.chain.push(o);
22236
22237 if (def.state !== 0) {
22238 schedule(notify,def);
22239 }
22240
22241 return o.promise;
22242 };
22243 this['catch'] = function $catch$(failure) {
22244 return this.then(void 0,failure);
22245 };
22246
22247 try {
22248 executor.call(
22249 void 0,
22250 function publicResolve(msg){
22251 resolve.call(def,msg);
22252 },
22253 function publicReject(msg) {
22254 reject.call(def,msg);
22255 }
22256 );
22257 }
22258 catch (err) {
22259 reject.call(def,err);
22260 }
22261 }
22262
22263 var PromisePrototype = builtInProp({},'constructor',NpoPromise,
22264 /*configurable=*/false
22265 );
22266
22267 // Note: Android 4 cannot use `Object.defineProperty(..)` here
22268 NpoPromise.prototype = PromisePrototype;
22269
22270 // built-in "brand" to signal an "uninitialized" promise
22271 builtInProp(PromisePrototype,'__NPO__',0,
22272 /*configurable=*/false
22273 );
22274
22275 builtInProp(NpoPromise,'resolve',function Promise$resolve(msg) {
22276 var Constructor = this;
22277
22278 // spec mandated checks
22279 // note: best "isPromise" check that's practical for now
22280 if (msg && typeof msg === 'object' && msg['__NPO__'] === 1) {
22281 return msg;
22282 }
22283
22284 return new Constructor(function executor(resolve,reject){
22285 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22286 throw TypeError('Not a function');
22287 }
22288
22289 resolve(msg);
22290 });
22291 });
22292
22293 builtInProp(NpoPromise,'reject',function Promise$reject(msg) {
22294 return new this(function executor(resolve,reject){
22295 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22296 throw TypeError('Not a function');
22297 }
22298
22299 reject(msg);
22300 });
22301 });
22302
22303 builtInProp(NpoPromise,'all',function Promise$all(arr) {
22304 var Constructor = this;
22305
22306 // spec mandated checks
22307 if (ToString.call(arr) !== '[object Array]') {
22308 return Constructor.reject(TypeError('Not an array'));
22309 }
22310 if (arr.length === 0) {
22311 return Constructor.resolve([]);
22312 }
22313
22314 return new Constructor(function executor(resolve,reject){
22315 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22316 throw TypeError('Not a function');
22317 }
22318
22319 var len = arr.length, msgs = Array(len), count = 0;
22320
22321 iteratePromises(Constructor,arr,function resolver(idx,msg) {
22322 msgs[idx] = msg;
22323 if (++count === len) {
22324 resolve(msgs);
22325 }
22326 },reject);
22327 });
22328 });
22329
22330 builtInProp(NpoPromise,'race',function Promise$race(arr) {
22331 var Constructor = this;
22332
22333 // spec mandated checks
22334 if (ToString.call(arr) !== '[object Array]') {
22335 return Constructor.reject(TypeError('Not an array'));
22336 }
22337
22338 return new Constructor(function executor(resolve,reject){
22339 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22340 throw TypeError('Not a function');
22341 }
22342
22343 iteratePromises(Constructor,arr,function resolver(idx,msg){
22344 resolve(msg);
22345 },reject);
22346 });
22347 });
22348
22349 var PromisePolyfill;
22350 if (typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]') !== -1) {
22351 PromisePolyfill = Promise;
22352 } else {
22353 PromisePolyfill = NpoPromise;
22354 }
22355
22356 var Config = {
22357 DEBUG: false,
22358 LIB_VERSION: '2.71.1'
22359 };
22360
22361 /* eslint camelcase: "off", eqeqeq: "off" */
22362
22363 // Maximum allowed session recording length
22364 var MAX_RECORDING_MS = 24 * 60 * 60 * 1000; // 24 hours
22365 // Maximum allowed value for minimum session recording length
22366 var MAX_VALUE_FOR_MIN_RECORDING_MS = 8 * 1000; // 8 seconds
22367
22368 /*
22369 * Saved references to long variable names, so that closure compiler can
22370 * minimize file size.
22371 */
22372
22373 var ArrayProto = Array.prototype,
22374 FuncProto = Function.prototype,
22375 ObjProto = Object.prototype,
22376 slice = ArrayProto.slice,
22377 toString = ObjProto.toString,
22378 hasOwnProperty = ObjProto.hasOwnProperty,
22379 windowConsole = win.console,
22380 navigator = win.navigator,
22381 document$1 = win.document,
22382 windowOpera = win.opera,
22383 screen = win.screen,
22384 userAgent = navigator.userAgent;
22385
22386 var nativeBind = FuncProto.bind,
22387 nativeForEach = ArrayProto.forEach,
22388 nativeIndexOf = ArrayProto.indexOf,
22389 nativeMap = ArrayProto.map,
22390 nativeIsArray = Array.isArray,
22391 breaker = {};
22392
22393 var _ = {
22394 trim: function(str) {
22395 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
22396 return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
22397 }
22398 };
22399
22400 // Console override
22401 var console$1 = {
22402 /** @type {function(...*)} */
22403 log: function() {
22404 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22405 try {
22406 windowConsole.log.apply(windowConsole, arguments);
22407 } catch (err) {
22408 _.each(arguments, function(arg) {
22409 windowConsole.log(arg);
22410 });
22411 }
22412 }
22413 },
22414 /** @type {function(...*)} */
22415 warn: function() {
22416 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22417 var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
22418 try {
22419 windowConsole.warn.apply(windowConsole, args);
22420 } catch (err) {
22421 _.each(args, function(arg) {
22422 windowConsole.warn(arg);
22423 });
22424 }
22425 }
22426 },
22427 /** @type {function(...*)} */
22428 error: function() {
22429 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22430 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22431 try {
22432 windowConsole.error.apply(windowConsole, args);
22433 } catch (err) {
22434 _.each(args, function(arg) {
22435 windowConsole.error(arg);
22436 });
22437 }
22438 }
22439 },
22440 /** @type {function(...*)} */
22441 critical: function() {
22442 if (!_.isUndefined(windowConsole) && windowConsole) {
22443 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22444 try {
22445 windowConsole.error.apply(windowConsole, args);
22446 } catch (err) {
22447 _.each(args, function(arg) {
22448 windowConsole.error(arg);
22449 });
22450 }
22451 }
22452 }
22453 };
22454
22455 var log_func_with_prefix = function(func, prefix) {
22456 return function() {
22457 arguments[0] = '[' + prefix + '] ' + arguments[0];
22458 return func.apply(console$1, arguments);
22459 };
22460 };
22461 var console_with_prefix = function(prefix) {
22462 return {
22463 log: log_func_with_prefix(console$1.log, prefix),
22464 error: log_func_with_prefix(console$1.error, prefix),
22465 critical: log_func_with_prefix(console$1.critical, prefix)
22466 };
22467 };
22468
22469
22470 var safewrap = function(f) {
22471 return function() {
22472 try {
22473 return f.apply(this, arguments);
22474 } catch (e) {
22475 console$1.critical('Implementation error. Please turn on debug and contact support@mixpanel.com.');
22476 if (Config.DEBUG){
22477 console$1.critical(e);
22478 }
22479 }
22480 };
22481 };
22482
22483 var safewrapClass = function(klass) {
22484 var proto = klass.prototype;
22485 for (var func in proto) {
22486 if (typeof(proto[func]) === 'function') {
22487 proto[func] = safewrap(proto[func]);
22488 }
22489 }
22490 };
22491
22492
22493 // UNDERSCORE
22494 // Embed part of the Underscore Library
22495 _.bind = function(func, context) {
22496 var args, bound;
22497 if (nativeBind && func.bind === nativeBind) {
22498 return nativeBind.apply(func, slice.call(arguments, 1));
22499 }
22500 if (!_.isFunction(func)) {
22501 throw new TypeError();
22502 }
22503 args = slice.call(arguments, 2);
22504 bound = function() {
22505 if (!(this instanceof bound)) {
22506 return func.apply(context, args.concat(slice.call(arguments)));
22507 }
22508 var ctor = {};
22509 ctor.prototype = func.prototype;
22510 var self = new ctor();
22511 ctor.prototype = null;
22512 var result = func.apply(self, args.concat(slice.call(arguments)));
22513 if (Object(result) === result) {
22514 return result;
22515 }
22516 return self;
22517 };
22518 return bound;
22519 };
22520
22521 /**
22522 * @param {*=} obj
22523 * @param {function(...*)=} iterator
22524 * @param {Object=} context
22525 */
22526 _.each = function(obj, iterator, context) {
22527 if (obj === null || obj === undefined) {
22528 return;
22529 }
22530 if (nativeForEach && obj.forEach === nativeForEach) {
22531 obj.forEach(iterator, context);
22532 } else if (obj.length === +obj.length) {
22533 for (var i = 0, l = obj.length; i < l; i++) {
22534 if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
22535 return;
22536 }
22537 }
22538 } else {
22539 for (var key in obj) {
22540 if (hasOwnProperty.call(obj, key)) {
22541 if (iterator.call(context, obj[key], key, obj) === breaker) {
22542 return;
22543 }
22544 }
22545 }
22546 }
22547 };
22548
22549 _.extend = function(obj) {
22550 _.each(slice.call(arguments, 1), function(source) {
22551 for (var prop in source) {
22552 if (source[prop] !== void 0) {
22553 obj[prop] = source[prop];
22554 }
22555 }
22556 });
22557 return obj;
22558 };
22559
22560 _.isArray = nativeIsArray || function(obj) {
22561 return toString.call(obj) === '[object Array]';
22562 };
22563
22564 // from a comment on http://dbj.org/dbj/?p=286
22565 // fails on only one very rare and deliberate custom object:
22566 // var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
22567 _.isFunction = function(f) {
22568 try {
22569 return /^\s*\bfunction\b/.test(f);
22570 } catch (x) {
22571 return false;
22572 }
22573 };
22574
22575 _.isArguments = function(obj) {
22576 return !!(obj && hasOwnProperty.call(obj, 'callee'));
22577 };
22578
22579 _.toArray = function(iterable) {
22580 if (!iterable) {
22581 return [];
22582 }
22583 if (iterable.toArray) {
22584 return iterable.toArray();
22585 }
22586 if (_.isArray(iterable)) {
22587 return slice.call(iterable);
22588 }
22589 if (_.isArguments(iterable)) {
22590 return slice.call(iterable);
22591 }
22592 return _.values(iterable);
22593 };
22594
22595 _.map = function(arr, callback, context) {
22596 if (nativeMap && arr.map === nativeMap) {
22597 return arr.map(callback, context);
22598 } else {
22599 var results = [];
22600 _.each(arr, function(item) {
22601 results.push(callback.call(context, item));
22602 });
22603 return results;
22604 }
22605 };
22606
22607 _.keys = function(obj) {
22608 var results = [];
22609 if (obj === null) {
22610 return results;
22611 }
22612 _.each(obj, function(value, key) {
22613 results[results.length] = key;
22614 });
22615 return results;
22616 };
22617
22618 _.values = function(obj) {
22619 var results = [];
22620 if (obj === null) {
22621 return results;
22622 }
22623 _.each(obj, function(value) {
22624 results[results.length] = value;
22625 });
22626 return results;
22627 };
22628
22629 _.include = function(obj, target) {
22630 var found = false;
22631 if (obj === null) {
22632 return found;
22633 }
22634 if (nativeIndexOf && obj.indexOf === nativeIndexOf) {
22635 return obj.indexOf(target) != -1;
22636 }
22637 _.each(obj, function(value) {
22638 if (found || (found = (value === target))) {
22639 return breaker;
22640 }
22641 });
22642 return found;
22643 };
22644
22645 _.includes = function(str, needle) {
22646 return str.indexOf(needle) !== -1;
22647 };
22648
22649 // Underscore Addons
22650 _.inherit = function(subclass, superclass) {
22651 subclass.prototype = new superclass();
22652 subclass.prototype.constructor = subclass;
22653 subclass.superclass = superclass.prototype;
22654 return subclass;
22655 };
22656
22657 _.isObject = function(obj) {
22658 return (obj === Object(obj) && !_.isArray(obj));
22659 };
22660
22661 _.isEmptyObject = function(obj) {
22662 if (_.isObject(obj)) {
22663 for (var key in obj) {
22664 if (hasOwnProperty.call(obj, key)) {
22665 return false;
22666 }
22667 }
22668 return true;
22669 }
22670 return false;
22671 };
22672
22673 _.isUndefined = function(obj) {
22674 return obj === void 0;
22675 };
22676
22677 _.isString = function(obj) {
22678 return toString.call(obj) == '[object String]';
22679 };
22680
22681 _.isDate = function(obj) {
22682 return toString.call(obj) == '[object Date]';
22683 };
22684
22685 _.isNumber = function(obj) {
22686 return toString.call(obj) == '[object Number]';
22687 };
22688
22689 _.isElement = function(obj) {
22690 return !!(obj && obj.nodeType === 1);
22691 };
22692
22693 _.encodeDates = function(obj) {
22694 _.each(obj, function(v, k) {
22695 if (_.isDate(v)) {
22696 obj[k] = _.formatDate(v);
22697 } else if (_.isObject(v)) {
22698 obj[k] = _.encodeDates(v); // recurse
22699 }
22700 });
22701 return obj;
22702 };
22703
22704 _.timestamp = function() {
22705 Date.now = Date.now || function() {
22706 return +new Date;
22707 };
22708 return Date.now();
22709 };
22710
22711 _.formatDate = function(d) {
22712 // YYYY-MM-DDTHH:MM:SS in UTC
22713 function pad(n) {
22714 return n < 10 ? '0' + n : n;
22715 }
22716 return d.getUTCFullYear() + '-' +
22717 pad(d.getUTCMonth() + 1) + '-' +
22718 pad(d.getUTCDate()) + 'T' +
22719 pad(d.getUTCHours()) + ':' +
22720 pad(d.getUTCMinutes()) + ':' +
22721 pad(d.getUTCSeconds());
22722 };
22723
22724 _.strip_empty_properties = function(p) {
22725 var ret = {};
22726 _.each(p, function(v, k) {
22727 if (_.isString(v) && v.length > 0) {
22728 ret[k] = v;
22729 }
22730 });
22731 return ret;
22732 };
22733
22734 /*
22735 * this function returns a copy of object after truncating it. If
22736 * passed an Array or Object it will iterate through obj and
22737 * truncate all the values recursively.
22738 */
22739 _.truncate = function(obj, length) {
22740 var ret;
22741
22742 if (typeof(obj) === 'string') {
22743 ret = obj.slice(0, length);
22744 } else if (_.isArray(obj)) {
22745 ret = [];
22746 _.each(obj, function(val) {
22747 ret.push(_.truncate(val, length));
22748 });
22749 } else if (_.isObject(obj)) {
22750 ret = {};
22751 _.each(obj, function(val, key) {
22752 ret[key] = _.truncate(val, length);
22753 });
22754 } else {
22755 ret = obj;
22756 }
22757
22758 return ret;
22759 };
22760
22761 _.JSONEncode = (function() {
22762 return function(mixed_val) {
22763 var value = mixed_val;
22764 var quote = function(string) {
22765 var escapable = /[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; // eslint-disable-line no-control-regex
22766 var meta = { // table of character substitutions
22767 '\b': '\\b',
22768 '\t': '\\t',
22769 '\n': '\\n',
22770 '\f': '\\f',
22771 '\r': '\\r',
22772 '"': '\\"',
22773 '\\': '\\\\'
22774 };
22775
22776 escapable.lastIndex = 0;
22777 return escapable.test(string) ?
22778 '"' + string.replace(escapable, function(a) {
22779 var c = meta[a];
22780 return typeof c === 'string' ? c :
22781 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
22782 }) + '"' :
22783 '"' + string + '"';
22784 };
22785
22786 var str = function(key, holder) {
22787 var gap = '';
22788 var indent = ' ';
22789 var i = 0; // The loop counter.
22790 var k = ''; // The member key.
22791 var v = ''; // The member value.
22792 var length = 0;
22793 var mind = gap;
22794 var partial = [];
22795 var value = holder[key];
22796
22797 // If the value has a toJSON method, call it to obtain a replacement value.
22798 if (value && typeof value === 'object' &&
22799 typeof value.toJSON === 'function') {
22800 value = value.toJSON(key);
22801 }
22802
22803 // What happens next depends on the value's type.
22804 switch (typeof value) {
22805 case 'string':
22806 return quote(value);
22807
22808 case 'number':
22809 // JSON numbers must be finite. Encode non-finite numbers as null.
22810 return isFinite(value) ? String(value) : 'null';
22811
22812 case 'boolean':
22813 case 'null':
22814 // If the value is a boolean or null, convert it to a string. Note:
22815 // typeof null does not produce 'null'. The case is included here in
22816 // the remote chance that this gets fixed someday.
22817
22818 return String(value);
22819
22820 case 'object':
22821 // If the type is 'object', we might be dealing with an object or an array or
22822 // null.
22823 // Due to a specification blunder in ECMAScript, typeof null is 'object',
22824 // so watch out for that case.
22825 if (!value) {
22826 return 'null';
22827 }
22828
22829 // Make an array to hold the partial results of stringifying this object value.
22830 gap += indent;
22831 partial = [];
22832
22833 // Is the value an array?
22834 if (toString.apply(value) === '[object Array]') {
22835 // The value is an array. Stringify every element. Use null as a placeholder
22836 // for non-JSON values.
22837
22838 length = value.length;
22839 for (i = 0; i < length; i += 1) {
22840 partial[i] = str(i, value) || 'null';
22841 }
22842
22843 // Join all of the elements together, separated with commas, and wrap them in
22844 // brackets.
22845 v = partial.length === 0 ? '[]' :
22846 gap ? '[\n' + gap +
22847 partial.join(',\n' + gap) + '\n' +
22848 mind + ']' :
22849 '[' + partial.join(',') + ']';
22850 gap = mind;
22851 return v;
22852 }
22853
22854 // Iterate through all of the keys in the object.
22855 for (k in value) {
22856 if (hasOwnProperty.call(value, k)) {
22857 v = str(k, value);
22858 if (v) {
22859 partial.push(quote(k) + (gap ? ': ' : ':') + v);
22860 }
22861 }
22862 }
22863
22864 // Join all of the member texts together, separated with commas,
22865 // and wrap them in braces.
22866 v = partial.length === 0 ? '{}' :
22867 gap ? '{' + partial.join(',') + '' +
22868 mind + '}' : '{' + partial.join(',') + '}';
22869 gap = mind;
22870 return v;
22871 }
22872 };
22873
22874 // Make a fake root object containing our value under the key of ''.
22875 // Return the result of stringifying the value.
22876 return str('', {
22877 '': value
22878 });
22879 };
22880 })();
22881
22882 /**
22883 * From https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
22884 * Slightly modified to throw a real Error rather than a POJO
22885 */
22886 _.JSONDecode = (function() {
22887 var at, // The index of the current character
22888 ch, // The current character
22889 escapee = {
22890 '"': '"',
22891 '\\': '\\',
22892 '/': '/',
22893 'b': '\b',
22894 'f': '\f',
22895 'n': '\n',
22896 'r': '\r',
22897 't': '\t'
22898 },
22899 text,
22900 error = function(m) {
22901 var e = new SyntaxError(m);
22902 e.at = at;
22903 e.text = text;
22904 throw e;
22905 },
22906 next = function(c) {
22907 // If a c parameter is provided, verify that it matches the current character.
22908 if (c && c !== ch) {
22909 error('Expected \'' + c + '\' instead of \'' + ch + '\'');
22910 }
22911 // Get the next character. When there are no more characters,
22912 // return the empty string.
22913 ch = text.charAt(at);
22914 at += 1;
22915 return ch;
22916 },
22917 number = function() {
22918 // Parse a number value.
22919 var number,
22920 string = '';
22921
22922 if (ch === '-') {
22923 string = '-';
22924 next('-');
22925 }
22926 while (ch >= '0' && ch <= '9') {
22927 string += ch;
22928 next();
22929 }
22930 if (ch === '.') {
22931 string += '.';
22932 while (next() && ch >= '0' && ch <= '9') {
22933 string += ch;
22934 }
22935 }
22936 if (ch === 'e' || ch === 'E') {
22937 string += ch;
22938 next();
22939 if (ch === '-' || ch === '+') {
22940 string += ch;
22941 next();
22942 }
22943 while (ch >= '0' && ch <= '9') {
22944 string += ch;
22945 next();
22946 }
22947 }
22948 number = +string;
22949 if (!isFinite(number)) {
22950 error('Bad number');
22951 } else {
22952 return number;
22953 }
22954 },
22955
22956 string = function() {
22957 // Parse a string value.
22958 var hex,
22959 i,
22960 string = '',
22961 uffff;
22962 // When parsing for string values, we must look for " and \ characters.
22963 if (ch === '"') {
22964 while (next()) {
22965 if (ch === '"') {
22966 next();
22967 return string;
22968 }
22969 if (ch === '\\') {
22970 next();
22971 if (ch === 'u') {
22972 uffff = 0;
22973 for (i = 0; i < 4; i += 1) {
22974 hex = parseInt(next(), 16);
22975 if (!isFinite(hex)) {
22976 break;
22977 }
22978 uffff = uffff * 16 + hex;
22979 }
22980 string += String.fromCharCode(uffff);
22981 } else if (typeof escapee[ch] === 'string') {
22982 string += escapee[ch];
22983 } else {
22984 break;
22985 }
22986 } else {
22987 string += ch;
22988 }
22989 }
22990 }
22991 error('Bad string');
22992 },
22993 white = function() {
22994 // Skip whitespace.
22995 while (ch && ch <= ' ') {
22996 next();
22997 }
22998 },
22999 word = function() {
23000 // true, false, or null.
23001 switch (ch) {
23002 case 't':
23003 next('t');
23004 next('r');
23005 next('u');
23006 next('e');
23007 return true;
23008 case 'f':
23009 next('f');
23010 next('a');
23011 next('l');
23012 next('s');
23013 next('e');
23014 return false;
23015 case 'n':
23016 next('n');
23017 next('u');
23018 next('l');
23019 next('l');
23020 return null;
23021 }
23022 error('Unexpected "' + ch + '"');
23023 },
23024 value, // Placeholder for the value function.
23025 array = function() {
23026 // Parse an array value.
23027 var array = [];
23028
23029 if (ch === '[') {
23030 next('[');
23031 white();
23032 if (ch === ']') {
23033 next(']');
23034 return array; // empty array
23035 }
23036 while (ch) {
23037 array.push(value());
23038 white();
23039 if (ch === ']') {
23040 next(']');
23041 return array;
23042 }
23043 next(',');
23044 white();
23045 }
23046 }
23047 error('Bad array');
23048 },
23049 object = function() {
23050 // Parse an object value.
23051 var key,
23052 object = {};
23053
23054 if (ch === '{') {
23055 next('{');
23056 white();
23057 if (ch === '}') {
23058 next('}');
23059 return object; // empty object
23060 }
23061 while (ch) {
23062 key = string();
23063 white();
23064 next(':');
23065 if (Object.hasOwnProperty.call(object, key)) {
23066 error('Duplicate key "' + key + '"');
23067 }
23068 object[key] = value();
23069 white();
23070 if (ch === '}') {
23071 next('}');
23072 return object;
23073 }
23074 next(',');
23075 white();
23076 }
23077 }
23078 error('Bad object');
23079 };
23080
23081 value = function() {
23082 // Parse a JSON value. It could be an object, an array, a string,
23083 // a number, or a word.
23084 white();
23085 switch (ch) {
23086 case '{':
23087 return object();
23088 case '[':
23089 return array();
23090 case '"':
23091 return string();
23092 case '-':
23093 return number();
23094 default:
23095 return ch >= '0' && ch <= '9' ? number() : word();
23096 }
23097 };
23098
23099 // Return the json_parse function. It will have access to all of the
23100 // above functions and variables.
23101 return function(source) {
23102 var result;
23103
23104 text = source;
23105 at = 0;
23106 ch = ' ';
23107 result = value();
23108 white();
23109 if (ch) {
23110 error('Syntax error');
23111 }
23112
23113 return result;
23114 };
23115 })();
23116
23117 _.base64Encode = function(data) {
23118 var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
23119 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
23120 ac = 0,
23121 enc = '',
23122 tmp_arr = [];
23123
23124 if (!data) {
23125 return data;
23126 }
23127
23128 data = _.utf8Encode(data);
23129
23130 do { // pack three octets into four hexets
23131 o1 = data.charCodeAt(i++);
23132 o2 = data.charCodeAt(i++);
23133 o3 = data.charCodeAt(i++);
23134
23135 bits = o1 << 16 | o2 << 8 | o3;
23136
23137 h1 = bits >> 18 & 0x3f;
23138 h2 = bits >> 12 & 0x3f;
23139 h3 = bits >> 6 & 0x3f;
23140 h4 = bits & 0x3f;
23141
23142 // use hexets to index into b64, and append result to encoded string
23143 tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
23144 } while (i < data.length);
23145
23146 enc = tmp_arr.join('');
23147
23148 switch (data.length % 3) {
23149 case 1:
23150 enc = enc.slice(0, -2) + '==';
23151 break;
23152 case 2:
23153 enc = enc.slice(0, -1) + '=';
23154 break;
23155 }
23156
23157 return enc;
23158 };
23159
23160 _.utf8Encode = function(string) {
23161 string = (string + '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
23162
23163 var utftext = '',
23164 start,
23165 end;
23166 var stringl = 0,
23167 n;
23168
23169 start = end = 0;
23170 stringl = string.length;
23171
23172 for (n = 0; n < stringl; n++) {
23173 var c1 = string.charCodeAt(n);
23174 var enc = null;
23175
23176 if (c1 < 128) {
23177 end++;
23178 } else if ((c1 > 127) && (c1 < 2048)) {
23179 enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128);
23180 } else {
23181 enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128);
23182 }
23183 if (enc !== null) {
23184 if (end > start) {
23185 utftext += string.substring(start, end);
23186 }
23187 utftext += enc;
23188 start = end = n + 1;
23189 }
23190 }
23191
23192 if (end > start) {
23193 utftext += string.substring(start, string.length);
23194 }
23195
23196 return utftext;
23197 };
23198
23199 _.UUID = function() {
23200 try {
23201 // use native Crypto API when available
23202 return win['crypto']['randomUUID']();
23203 } catch (err) {
23204 // fall back to generating our own UUID
23205 // based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
23206 var uuid = new Array(36);
23207 for (var i = 0; i < 36; i++) {
23208 uuid[i] = Math.floor(Math.random() * 16);
23209 }
23210 uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
23211 uuid[19] = uuid[19] &= -5; // set bit 6 of clock-seq-and-reserved to zero
23212 uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
23213 uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
23214
23215 return _.map(uuid, function(x) {
23216 return x.toString(16);
23217 }).join('');
23218 }
23219 };
23220
23221 // _.isBlockedUA()
23222 // This is to block various web spiders from executing our JS and
23223 // sending false tracking data
23224 var BLOCKED_UA_STRS = [
23225 'ahrefsbot',
23226 'ahrefssiteaudit',
23227 'amazonbot',
23228 'baiduspider',
23229 'bingbot',
23230 'bingpreview',
23231 'chrome-lighthouse',
23232 'facebookexternal',
23233 'petalbot',
23234 'pinterest',
23235 'screaming frog',
23236 'yahoo! slurp',
23237 'yandex',
23238
23239 // a whole bunch of goog-specific crawlers
23240 // https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
23241 'adsbot-google',
23242 'apis-google',
23243 'duplexweb-google',
23244 'feedfetcher-google',
23245 'google favicon',
23246 'google web preview',
23247 'google-read-aloud',
23248 'googlebot',
23249 'googleweblight',
23250 'mediapartners-google',
23251 'storebot-google'
23252 ];
23253 _.isBlockedUA = function(ua) {
23254 var i;
23255 ua = ua.toLowerCase();
23256 for (i = 0; i < BLOCKED_UA_STRS.length; i++) {
23257 if (ua.indexOf(BLOCKED_UA_STRS[i]) !== -1) {
23258 return true;
23259 }
23260 }
23261 return false;
23262 };
23263
23264 /**
23265 * @param {Object=} formdata
23266 * @param {string=} arg_separator
23267 */
23268 _.HTTPBuildQuery = function(formdata, arg_separator) {
23269 var use_val, use_key, tmp_arr = [];
23270
23271 if (_.isUndefined(arg_separator)) {
23272 arg_separator = '&';
23273 }
23274
23275 _.each(formdata, function(val, key) {
23276 use_val = encodeURIComponent(val.toString());
23277 use_key = encodeURIComponent(key);
23278 tmp_arr[tmp_arr.length] = use_key + '=' + use_val;
23279 });
23280
23281 return tmp_arr.join(arg_separator);
23282 };
23283
23284 _.getQueryParam = function(url, param) {
23285 // Expects a raw URL
23286
23287 param = param.replace(/[[]/g, '\\[').replace(/[\]]/g, '\\]');
23288 var regexS = '[\\?&]' + param + '=([^&#]*)',
23289 regex = new RegExp(regexS),
23290 results = regex.exec(url);
23291 if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
23292 return '';
23293 } else {
23294 var result = results[1];
23295 try {
23296 result = decodeURIComponent(result);
23297 } catch(err) {
23298 console$1.error('Skipping decoding for malformed query param: ' + result);
23299 }
23300 return result.replace(/\+/g, ' ');
23301 }
23302 };
23303
23304
23305 // _.cookie
23306 // Methods partially borrowed from quirksmode.org/js/cookies.html
23307 _.cookie = {
23308 get: function(name) {
23309 var nameEQ = name + '=';
23310 var ca = document$1.cookie.split(';');
23311 for (var i = 0; i < ca.length; i++) {
23312 var c = ca[i];
23313 while (c.charAt(0) == ' ') {
23314 c = c.substring(1, c.length);
23315 }
23316 if (c.indexOf(nameEQ) === 0) {
23317 return decodeURIComponent(c.substring(nameEQ.length, c.length));
23318 }
23319 }
23320 return null;
23321 },
23322
23323 parse: function(name) {
23324 var cookie;
23325 try {
23326 cookie = _.JSONDecode(_.cookie.get(name)) || {};
23327 } catch (err) {
23328 // noop
23329 }
23330 return cookie;
23331 },
23332
23333 set_seconds: function(name, value, seconds, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23334 var cdomain = '',
23335 expires = '',
23336 secure = '';
23337
23338 if (domain_override) {
23339 cdomain = '; domain=' + domain_override;
23340 } else if (is_cross_subdomain) {
23341 var domain = extract_domain(document$1.location.hostname);
23342 cdomain = domain ? '; domain=.' + domain : '';
23343 }
23344
23345 if (seconds) {
23346 var date = new Date();
23347 date.setTime(date.getTime() + (seconds * 1000));
23348 expires = '; expires=' + date.toGMTString();
23349 }
23350
23351 if (is_cross_site) {
23352 is_secure = true;
23353 secure = '; SameSite=None';
23354 }
23355 if (is_secure) {
23356 secure += '; secure';
23357 }
23358
23359 document$1.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23360 },
23361
23362 set: function(name, value, days, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23363 var cdomain = '', expires = '', secure = '';
23364
23365 if (domain_override) {
23366 cdomain = '; domain=' + domain_override;
23367 } else if (is_cross_subdomain) {
23368 var domain = extract_domain(document$1.location.hostname);
23369 cdomain = domain ? '; domain=.' + domain : '';
23370 }
23371
23372 if (days) {
23373 var date = new Date();
23374 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
23375 expires = '; expires=' + date.toGMTString();
23376 }
23377
23378 if (is_cross_site) {
23379 is_secure = true;
23380 secure = '; SameSite=None';
23381 }
23382 if (is_secure) {
23383 secure += '; secure';
23384 }
23385
23386 var new_cookie_val = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23387 document$1.cookie = new_cookie_val;
23388 return new_cookie_val;
23389 },
23390
23391 remove: function(name, is_cross_subdomain, domain_override) {
23392 _.cookie.set(name, '', -1, is_cross_subdomain, false, false, domain_override);
23393 }
23394 };
23395
23396 var _testStorageSupported = function (storage) {
23397 var supported = true;
23398 try {
23399 var key = '__mplss_' + cheap_guid(8),
23400 val = 'xyz';
23401 storage.setItem(key, val);
23402 if (storage.getItem(key) !== val) {
23403 supported = false;
23404 }
23405 storage.removeItem(key);
23406 } catch (err) {
23407 supported = false;
23408 }
23409 return supported;
23410 };
23411
23412 var _localStorageSupported = null;
23413 var localStorageSupported = function(storage, forceCheck) {
23414 if (_localStorageSupported !== null && !forceCheck) {
23415 return _localStorageSupported;
23416 }
23417 return _localStorageSupported = _testStorageSupported(storage || win.localStorage);
23418 };
23419
23420 var _sessionStorageSupported = null;
23421 var sessionStorageSupported = function(storage, forceCheck) {
23422 if (_sessionStorageSupported !== null && !forceCheck) {
23423 return _sessionStorageSupported;
23424 }
23425 return _sessionStorageSupported = _testStorageSupported(storage || win.sessionStorage);
23426 };
23427
23428 function _storageWrapper(storage, name, is_supported_fn) {
23429 var log_error = function(msg) {
23430 console$1.error(name + ' error: ' + msg);
23431 };
23432
23433 return {
23434 is_supported: function(forceCheck) {
23435 var supported = is_supported_fn(storage, forceCheck);
23436 if (!supported) {
23437 console$1.error(name + ' unsupported');
23438 }
23439 return supported;
23440 },
23441 error: log_error,
23442 get: function(key) {
23443 try {
23444 return storage.getItem(key);
23445 } catch (err) {
23446 log_error(err);
23447 }
23448 return null;
23449 },
23450 parse: function(key) {
23451 try {
23452 return _.JSONDecode(storage.getItem(key)) || {};
23453 } catch (err) {
23454 // noop
23455 }
23456 return null;
23457 },
23458 set: function(key, value) {
23459 try {
23460 storage.setItem(key, value);
23461 } catch (err) {
23462 log_error(err);
23463 }
23464 },
23465 remove: function(key) {
23466 try {
23467 storage.removeItem(key);
23468 } catch (err) {
23469 log_error(err);
23470 }
23471 }
23472 };
23473 }
23474
23475 _.localStorage = _storageWrapper(win.localStorage, 'localStorage', localStorageSupported);
23476 _.sessionStorage = _storageWrapper(win.sessionStorage, 'sessionStorage', sessionStorageSupported);
23477
23478 _.register_event = (function() {
23479 // written by Dean Edwards, 2005
23480 // with input from Tino Zijdel - crisp@xs4all.nl
23481 // with input from Carl Sverre - mail@carlsverre.com
23482 // with input from Mixpanel
23483 // http://dean.edwards.name/weblog/2005/10/add-event/
23484 // https://gist.github.com/1930440
23485
23486 /**
23487 * @param {Object} element
23488 * @param {string} type
23489 * @param {function(...*)} handler
23490 * @param {boolean=} oldSchool
23491 * @param {boolean=} useCapture
23492 */
23493 var register_event = function(element, type, handler, oldSchool, useCapture) {
23494 if (!element) {
23495 console$1.error('No valid element provided to register_event');
23496 return;
23497 }
23498
23499 if (element.addEventListener && !oldSchool) {
23500 element.addEventListener(type, handler, !!useCapture);
23501 } else {
23502 var ontype = 'on' + type;
23503 var old_handler = element[ontype]; // can be undefined
23504 element[ontype] = makeHandler(element, handler, old_handler);
23505 }
23506 };
23507
23508 function makeHandler(element, new_handler, old_handlers) {
23509 var handler = function(event) {
23510 event = event || fixEvent(win.event);
23511
23512 // this basically happens in firefox whenever another script
23513 // overwrites the onload callback and doesn't pass the event
23514 // object to previously defined callbacks. All the browsers
23515 // that don't define window.event implement addEventListener
23516 // so the dom_loaded handler will still be fired as usual.
23517 if (!event) {
23518 return undefined;
23519 }
23520
23521 var ret = true;
23522 var old_result, new_result;
23523
23524 if (_.isFunction(old_handlers)) {
23525 old_result = old_handlers(event);
23526 }
23527 new_result = new_handler.call(element, event);
23528
23529 if ((false === old_result) || (false === new_result)) {
23530 ret = false;
23531 }
23532
23533 return ret;
23534 };
23535
23536 return handler;
23537 }
23538
23539 function fixEvent(event) {
23540 if (event) {
23541 event.preventDefault = fixEvent.preventDefault;
23542 event.stopPropagation = fixEvent.stopPropagation;
23543 }
23544 return event;
23545 }
23546 fixEvent.preventDefault = function() {
23547 this.returnValue = false;
23548 };
23549 fixEvent.stopPropagation = function() {
23550 this.cancelBubble = true;
23551 };
23552
23553 return register_event;
23554 })();
23555
23556
23557 var TOKEN_MATCH_REGEX = new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');
23558
23559 _.dom_query = (function() {
23560 /* document.getElementsBySelector(selector)
23561 - returns an array of element objects from the current document
23562 matching the CSS selector. Selectors can contain element names,
23563 class names and ids and can be nested. For example:
23564
23565 elements = document.getElementsBySelector('div#main p a.external')
23566
23567 Will return an array of all 'a' elements with 'external' in their
23568 class attribute that are contained inside 'p' elements that are
23569 contained inside the 'div' element which has id="main"
23570
23571 New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
23572 See http://www.w3.org/TR/css3-selectors/#attribute-selectors
23573
23574 Version 0.4 - Simon Willison, March 25th 2003
23575 -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
23576 -- Opera 7 fails
23577
23578 Version 0.5 - Carl Sverre, Jan 7th 2013
23579 -- Now uses jQuery-esque `hasClass` for testing class name
23580 equality. This fixes a bug related to '-' characters being
23581 considered not part of a 'word' in regex.
23582 */
23583
23584 function getAllChildren(e) {
23585 // Returns all children of element. Workaround required for IE5/Windows. Ugh.
23586 return e.all ? e.all : e.getElementsByTagName('*');
23587 }
23588
23589 var bad_whitespace = /[\t\r\n]/g;
23590
23591 function hasClass(elem, selector) {
23592 var className = ' ' + selector + ' ';
23593 return ((' ' + elem.className + ' ').replace(bad_whitespace, ' ').indexOf(className) >= 0);
23594 }
23595
23596 function getElementsBySelector(selector) {
23597 // Attempt to fail gracefully in lesser browsers
23598 if (!document$1.getElementsByTagName) {
23599 return [];
23600 }
23601 // Split selector in to tokens
23602 var tokens = selector.split(' ');
23603 var token, bits, tagName, found, foundCount, i, j, k, elements, currentContextIndex;
23604 var currentContext = [document$1];
23605 for (i = 0; i < tokens.length; i++) {
23606 token = tokens[i].replace(/^\s+/, '').replace(/\s+$/, '');
23607 if (token.indexOf('#') > -1) {
23608 // Token is an ID selector
23609 bits = token.split('#');
23610 tagName = bits[0];
23611 var id = bits[1];
23612 var element = document$1.getElementById(id);
23613 if (!element || (tagName && element.nodeName.toLowerCase() != tagName)) {
23614 // element not found or tag with that ID not found, return false
23615 return [];
23616 }
23617 // Set currentContext to contain just this element
23618 currentContext = [element];
23619 continue; // Skip to next token
23620 }
23621 if (token.indexOf('.') > -1) {
23622 // Token contains a class selector
23623 bits = token.split('.');
23624 tagName = bits[0];
23625 var className = bits[1];
23626 if (!tagName) {
23627 tagName = '*';
23628 }
23629 // Get elements matching tag, filter them for class selector
23630 found = [];
23631 foundCount = 0;
23632 for (j = 0; j < currentContext.length; j++) {
23633 if (tagName == '*') {
23634 elements = getAllChildren(currentContext[j]);
23635 } else {
23636 elements = currentContext[j].getElementsByTagName(tagName);
23637 }
23638 for (k = 0; k < elements.length; k++) {
23639 found[foundCount++] = elements[k];
23640 }
23641 }
23642 currentContext = [];
23643 currentContextIndex = 0;
23644 for (j = 0; j < found.length; j++) {
23645 if (found[j].className &&
23646 _.isString(found[j].className) && // some SVG elements have classNames which are not strings
23647 hasClass(found[j], className)
23648 ) {
23649 currentContext[currentContextIndex++] = found[j];
23650 }
23651 }
23652 continue; // Skip to next token
23653 }
23654 // Code to deal with attribute selectors
23655 var token_match = token.match(TOKEN_MATCH_REGEX);
23656 if (token_match) {
23657 tagName = token_match[1];
23658 var attrName = token_match[2];
23659 var attrOperator = token_match[3];
23660 var attrValue = token_match[4];
23661 if (!tagName) {
23662 tagName = '*';
23663 }
23664 // Grab all of the tagName elements within current context
23665 found = [];
23666 foundCount = 0;
23667 for (j = 0; j < currentContext.length; j++) {
23668 if (tagName == '*') {
23669 elements = getAllChildren(currentContext[j]);
23670 } else {
23671 elements = currentContext[j].getElementsByTagName(tagName);
23672 }
23673 for (k = 0; k < elements.length; k++) {
23674 found[foundCount++] = elements[k];
23675 }
23676 }
23677 currentContext = [];
23678 currentContextIndex = 0;
23679 var checkFunction; // This function will be used to filter the elements
23680 switch (attrOperator) {
23681 case '=': // Equality
23682 checkFunction = function(e) {
23683 return (e.getAttribute(attrName) == attrValue);
23684 };
23685 break;
23686 case '~': // Match one of space seperated words
23687 checkFunction = function(e) {
23688 return (e.getAttribute(attrName).match(new RegExp('\\b' + attrValue + '\\b')));
23689 };
23690 break;
23691 case '|': // Match start with value followed by optional hyphen
23692 checkFunction = function(e) {
23693 return (e.getAttribute(attrName).match(new RegExp('^' + attrValue + '-?')));
23694 };
23695 break;
23696 case '^': // Match starts with value
23697 checkFunction = function(e) {
23698 return (e.getAttribute(attrName).indexOf(attrValue) === 0);
23699 };
23700 break;
23701 case '$': // Match ends with value - fails with "Warning" in Opera 7
23702 checkFunction = function(e) {
23703 return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length);
23704 };
23705 break;
23706 case '*': // Match ends with value
23707 checkFunction = function(e) {
23708 return (e.getAttribute(attrName).indexOf(attrValue) > -1);
23709 };
23710 break;
23711 default:
23712 // Just test for existence of attribute
23713 checkFunction = function(e) {
23714 return e.getAttribute(attrName);
23715 };
23716 }
23717 currentContext = [];
23718 currentContextIndex = 0;
23719 for (j = 0; j < found.length; j++) {
23720 if (checkFunction(found[j])) {
23721 currentContext[currentContextIndex++] = found[j];
23722 }
23723 }
23724 // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
23725 continue; // Skip to next token
23726 }
23727 // If we get here, token is JUST an element (not a class or ID selector)
23728 tagName = token;
23729 found = [];
23730 foundCount = 0;
23731 for (j = 0; j < currentContext.length; j++) {
23732 elements = currentContext[j].getElementsByTagName(tagName);
23733 for (k = 0; k < elements.length; k++) {
23734 found[foundCount++] = elements[k];
23735 }
23736 }
23737 currentContext = found;
23738 }
23739 return currentContext;
23740 }
23741
23742 return function(query) {
23743 if (_.isElement(query)) {
23744 return [query];
23745 } else if (_.isObject(query) && !_.isUndefined(query.length)) {
23746 return query;
23747 } else {
23748 return getElementsBySelector.call(this, query);
23749 }
23750 };
23751 })();
23752
23753 var CAMPAIGN_KEYWORDS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term', 'utm_id', 'utm_source_platform','utm_campaign_id', 'utm_creative_format', 'utm_marketing_tactic'];
23754 var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'sccid', 'ttclid', 'twclid', 'wbraid'];
23755
23756 _.info = {
23757 campaignParams: function(default_value) {
23758 var kw = '',
23759 params = {};
23760 _.each(CAMPAIGN_KEYWORDS, function(kwkey) {
23761 kw = _.getQueryParam(document$1.URL, kwkey);
23762 if (kw.length) {
23763 params[kwkey] = kw;
23764 } else if (default_value !== undefined) {
23765 params[kwkey] = default_value;
23766 }
23767 });
23768
23769 return params;
23770 },
23771
23772 clickParams: function() {
23773 var id = '',
23774 params = {};
23775 _.each(CLICK_IDS, function(idkey) {
23776 id = _.getQueryParam(document$1.URL, idkey);
23777 if (id.length) {
23778 params[idkey] = id;
23779 }
23780 });
23781
23782 return params;
23783 },
23784
23785 marketingParams: function() {
23786 return _.extend(_.info.campaignParams(), _.info.clickParams());
23787 },
23788
23789 searchEngine: function(referrer) {
23790 if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
23791 return 'google';
23792 } else if (referrer.search('https?://(.*)bing.com') === 0) {
23793 return 'bing';
23794 } else if (referrer.search('https?://(.*)yahoo.com') === 0) {
23795 return 'yahoo';
23796 } else if (referrer.search('https?://(.*)duckduckgo.com') === 0) {
23797 return 'duckduckgo';
23798 } else {
23799 return null;
23800 }
23801 },
23802
23803 searchInfo: function(referrer) {
23804 var search = _.info.searchEngine(referrer),
23805 param = (search != 'yahoo') ? 'q' : 'p',
23806 ret = {};
23807
23808 if (search !== null) {
23809 ret['$search_engine'] = search;
23810
23811 var keyword = _.getQueryParam(referrer, param);
23812 if (keyword.length) {
23813 ret['mp_keyword'] = keyword;
23814 }
23815 }
23816
23817 return ret;
23818 },
23819
23820 /**
23821 * This function detects which browser is running this script.
23822 * The order of the checks are important since many user agents
23823 * include key words used in later checks.
23824 */
23825 browser: function(user_agent, vendor, opera) {
23826 vendor = vendor || ''; // vendor is undefined for at least IE9
23827 if (opera || _.includes(user_agent, ' OPR/')) {
23828 if (_.includes(user_agent, 'Mini')) {
23829 return 'Opera Mini';
23830 }
23831 return 'Opera';
23832 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
23833 return 'BlackBerry';
23834 } else if (_.includes(user_agent, 'IEMobile') || _.includes(user_agent, 'WPDesktop')) {
23835 return 'Internet Explorer Mobile';
23836 } else if (_.includes(user_agent, 'SamsungBrowser/')) {
23837 // https://developer.samsung.com/internet/user-agent-string-format
23838 return 'Samsung Internet';
23839 } else if (_.includes(user_agent, 'Edge') || _.includes(user_agent, 'Edg/')) {
23840 return 'Microsoft Edge';
23841 } else if (_.includes(user_agent, 'FBIOS')) {
23842 return 'Facebook Mobile';
23843 } else if (_.includes(user_agent, 'Whale/')) {
23844 // https://user-agents.net/browsers/whale-browser
23845 return 'Whale Browser';
23846 } else if (_.includes(user_agent, 'Chrome')) {
23847 return 'Chrome';
23848 } else if (_.includes(user_agent, 'CriOS')) {
23849 return 'Chrome iOS';
23850 } else if (_.includes(user_agent, 'UCWEB') || _.includes(user_agent, 'UCBrowser')) {
23851 return 'UC Browser';
23852 } else if (_.includes(user_agent, 'FxiOS')) {
23853 return 'Firefox iOS';
23854 } else if (_.includes(vendor, 'Apple')) {
23855 if (_.includes(user_agent, 'Mobile')) {
23856 return 'Mobile Safari';
23857 }
23858 return 'Safari';
23859 } else if (_.includes(user_agent, 'Android')) {
23860 return 'Android Mobile';
23861 } else if (_.includes(user_agent, 'Konqueror')) {
23862 return 'Konqueror';
23863 } else if (_.includes(user_agent, 'Firefox')) {
23864 return 'Firefox';
23865 } else if (_.includes(user_agent, 'MSIE') || _.includes(user_agent, 'Trident/')) {
23866 return 'Internet Explorer';
23867 } else if (_.includes(user_agent, 'Gecko')) {
23868 return 'Mozilla';
23869 } else {
23870 return '';
23871 }
23872 },
23873
23874 /**
23875 * This function detects which browser version is running this script,
23876 * parsing major and minor version (e.g., 42.1). User agent strings from:
23877 * http://www.useragentstring.com/pages/useragentstring.php
23878 */
23879 browserVersion: function(userAgent, vendor, opera) {
23880 var browser = _.info.browser(userAgent, vendor, opera);
23881 var versionRegexs = {
23882 'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/,
23883 'Microsoft Edge': /Edge?\/(\d+(\.\d+)?)/,
23884 'Chrome': /Chrome\/(\d+(\.\d+)?)/,
23885 'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/,
23886 'UC Browser' : /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,
23887 'Safari': /Version\/(\d+(\.\d+)?)/,
23888 'Mobile Safari': /Version\/(\d+(\.\d+)?)/,
23889 'Opera': /(Opera|OPR)\/(\d+(\.\d+)?)/,
23890 'Firefox': /Firefox\/(\d+(\.\d+)?)/,
23891 'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/,
23892 'Konqueror': /Konqueror:(\d+(\.\d+)?)/,
23893 'BlackBerry': /BlackBerry (\d+(\.\d+)?)/,
23894 'Android Mobile': /android\s(\d+(\.\d+)?)/,
23895 'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
23896 'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
23897 'Mozilla': /rv:(\d+(\.\d+)?)/,
23898 'Whale Browser': /Whale\/(\d+(\.\d+)?)/
23899 };
23900 var regex = versionRegexs[browser];
23901 if (regex === undefined) {
23902 return null;
23903 }
23904 var matches = userAgent.match(regex);
23905 if (!matches) {
23906 return null;
23907 }
23908 return parseFloat(matches[matches.length - 2]);
23909 },
23910
23911 os: function() {
23912 var a = userAgent;
23913 if (/Windows/i.test(a)) {
23914 if (/Phone/.test(a) || /WPDesktop/.test(a)) {
23915 return 'Windows Phone';
23916 }
23917 return 'Windows';
23918 } else if (/(iPhone|iPad|iPod)/.test(a)) {
23919 return 'iOS';
23920 } else if (/Android/.test(a)) {
23921 return 'Android';
23922 } else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {
23923 return 'BlackBerry';
23924 } else if (/Mac/i.test(a)) {
23925 return 'Mac OS X';
23926 } else if (/Linux/.test(a)) {
23927 return 'Linux';
23928 } else if (/CrOS/.test(a)) {
23929 return 'Chrome OS';
23930 } else {
23931 return '';
23932 }
23933 },
23934
23935 device: function(user_agent) {
23936 if (/Windows Phone/i.test(user_agent) || /WPDesktop/.test(user_agent)) {
23937 return 'Windows Phone';
23938 } else if (/iPad/.test(user_agent)) {
23939 return 'iPad';
23940 } else if (/iPod/.test(user_agent)) {
23941 return 'iPod Touch';
23942 } else if (/iPhone/.test(user_agent)) {
23943 return 'iPhone';
23944 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
23945 return 'BlackBerry';
23946 } else if (/Android/.test(user_agent)) {
23947 return 'Android';
23948 } else {
23949 return '';
23950 }
23951 },
23952
23953 referringDomain: function(referrer) {
23954 var split = referrer.split('/');
23955 if (split.length >= 3) {
23956 return split[2];
23957 }
23958 return '';
23959 },
23960
23961 currentUrl: function() {
23962 return win.location.href;
23963 },
23964
23965 properties: function(extra_props) {
23966 if (typeof extra_props !== 'object') {
23967 extra_props = {};
23968 }
23969 return _.extend(_.strip_empty_properties({
23970 '$os': _.info.os(),
23971 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
23972 '$referrer': document$1.referrer,
23973 '$referring_domain': _.info.referringDomain(document$1.referrer),
23974 '$device': _.info.device(userAgent)
23975 }), {
23976 '$current_url': _.info.currentUrl(),
23977 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera),
23978 '$screen_height': screen.height,
23979 '$screen_width': screen.width,
23980 'mp_lib': 'web',
23981 '$lib_version': Config.LIB_VERSION,
23982 '$insert_id': cheap_guid(),
23983 'time': _.timestamp() / 1000 // epoch time in seconds
23984 }, _.strip_empty_properties(extra_props));
23985 },
23986
23987 people_properties: function() {
23988 return _.extend(_.strip_empty_properties({
23989 '$os': _.info.os(),
23990 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera)
23991 }), {
23992 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera)
23993 });
23994 },
23995
23996 mpPageViewProperties: function() {
23997 return _.strip_empty_properties({
23998 'current_page_title': document$1.title,
23999 'current_domain': win.location.hostname,
24000 'current_url_path': win.location.pathname,
24001 'current_url_protocol': win.location.protocol,
24002 'current_url_search': win.location.search
24003 });
24004 }
24005 };
24006
24007 /**
24008 * Returns a throttled function that will only run at most every `waitMs` and returns a promise that resolves with the next invocation.
24009 * Throttled calls will build up a batch of args and invoke the callback with all args since the last invocation.
24010 */
24011 var batchedThrottle = function (fn, waitMs) {
24012 var timeoutPromise = null;
24013 var throttledItems = [];
24014 return function (item) {
24015 var self = this;
24016 throttledItems.push(item);
24017
24018 if (!timeoutPromise) {
24019 timeoutPromise = new PromisePolyfill(function (resolve) {
24020 setTimeout(function () {
24021 var returnValue = fn.apply(self, [throttledItems]);
24022 timeoutPromise = null;
24023 throttledItems = [];
24024 resolve(returnValue);
24025 }, waitMs);
24026 });
24027 }
24028 return timeoutPromise;
24029 };
24030 };
24031
24032 var cheap_guid = function(maxlen) {
24033 var guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
24034 return maxlen ? guid.substring(0, maxlen) : guid;
24035 };
24036
24037 /**
24038 * Generates a W3C traceparent header for easy interop with distributed tracing systems i.e Open Telemetry
24039 * https://www.w3.org/TR/trace-context/#traceparent-header
24040 */
24041 var generateTraceparent = function() {
24042 var traceID = _.UUID().replace(/-/g, '');
24043 var parentID = _.UUID().replace(/-/g, '').substring(0, 16);
24044
24045 // Sampled trace
24046 var traceFlags = '01';
24047
24048 return '00-' + traceID + '-' + parentID + '-' + traceFlags;
24049 };
24050
24051 // naive way to extract domain name (example.com) from full hostname (my.sub.example.com)
24052 var SIMPLE_DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]*\.[a-z]+$/i;
24053 // this next one attempts to account for some ccSLDs, e.g. extracting oxford.ac.uk from www.oxford.ac.uk
24054 var DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;
24055 /**
24056 * Attempts to extract main domain name from full hostname, using a few blunt heuristics. For
24057 * common TLDs like .com/.org that always have a simple SLD.TLD structure (example.com), we
24058 * simply extract the last two .-separated parts of the hostname (SIMPLE_DOMAIN_MATCH_REGEX).
24059 * For others, we attempt to account for short ccSLD+TLD combos (.ac.uk) with the legacy
24060 * DOMAIN_MATCH_REGEX (kept to maintain backwards compatibility with existing Mixpanel
24061 * integrations). The only _reliable_ way to extract domain from hostname is with an up-to-date
24062 * list like at https://publicsuffix.org/ so for cases that this helper fails at, the SDK
24063 * offers the 'cookie_domain' config option to set it explicitly.
24064 * @example
24065 * extract_domain('my.sub.example.com')
24066 * // 'example.com'
24067 */
24068 var extract_domain = function(hostname) {
24069 var domain_regex = DOMAIN_MATCH_REGEX;
24070 var parts = hostname.split('.');
24071 var tld = parts[parts.length - 1];
24072 if (tld.length > 4 || tld === 'com' || tld === 'org') {
24073 domain_regex = SIMPLE_DOMAIN_MATCH_REGEX;
24074 }
24075 var matches = hostname.match(domain_regex);
24076 return matches ? matches[0] : '';
24077 };
24078
24079 /**
24080 * Check whether we have network connection. default to true for browsers that don't support navigator.onLine (IE)
24081 * @returns {boolean}
24082 */
24083 var isOnline = function() {
24084 var onLine = win.navigator['onLine'];
24085 return _.isUndefined(onLine) || onLine;
24086 };
24087
24088 var NOOP_FUNC = function () {};
24089
24090 var JSONStringify = null, JSONParse = null;
24091 if (typeof JSON !== 'undefined') {
24092 JSONStringify = JSON.stringify;
24093 JSONParse = JSON.parse;
24094 }
24095 JSONStringify = JSONStringify || _.JSONEncode;
24096 JSONParse = JSONParse || _.JSONDecode;
24097
24098 // UNMINIFIED EXPORTS (for closure compiler)
24099 _['info'] = _.info;
24100 _['info']['browser'] = _.info.browser;
24101 _['info']['browserVersion'] = _.info.browserVersion;
24102 _['info']['device'] = _.info.device;
24103 _['info']['properties'] = _.info.properties;
24104 _['isBlockedUA'] = _.isBlockedUA;
24105 _['isEmptyObject'] = _.isEmptyObject;
24106 _['isObject'] = _.isObject;
24107 _['JSONDecode'] = _.JSONDecode;
24108 _['JSONEncode'] = _.JSONEncode;
24109 _['toArray'] = _.toArray;
24110 _['NPO'] = NpoPromise;
24111
24112 var MIXPANEL_DB_NAME = 'mixpanelBrowserDb';
24113
24114 var RECORDING_EVENTS_STORE_NAME = 'mixpanelRecordingEvents';
24115 var RECORDING_REGISTRY_STORE_NAME = 'mixpanelRecordingRegistry';
24116
24117 // note: increment the version number when adding new object stores
24118 var DB_VERSION = 1;
24119 var OBJECT_STORES = [RECORDING_EVENTS_STORE_NAME, RECORDING_REGISTRY_STORE_NAME];
24120
24121 /**
24122 * @type {import('./wrapper').StorageWrapper}
24123 */
24124 var IDBStorageWrapper = function (storeName) {
24125 /**
24126 * @type {Promise<IDBDatabase>|null}
24127 */
24128 this.dbPromise = null;
24129 this.storeName = storeName;
24130 };
24131
24132 IDBStorageWrapper.prototype._openDb = function () {
24133 return new PromisePolyfill(function (resolve, reject) {
24134 var openRequest = win.indexedDB.open(MIXPANEL_DB_NAME, DB_VERSION);
24135 openRequest['onerror'] = function () {
24136 reject(openRequest.error);
24137 };
24138
24139 openRequest['onsuccess'] = function () {
24140 resolve(openRequest.result);
24141 };
24142
24143 openRequest['onupgradeneeded'] = function (ev) {
24144 var db = ev.target.result;
24145
24146 OBJECT_STORES.forEach(function (storeName) {
24147 db.createObjectStore(storeName);
24148 });
24149 };
24150 });
24151 };
24152
24153 IDBStorageWrapper.prototype.init = function () {
24154 if (!win.indexedDB) {
24155 return PromisePolyfill.reject('indexedDB is not supported in this browser');
24156 }
24157
24158 if (!this.dbPromise) {
24159 this.dbPromise = this._openDb();
24160 }
24161
24162 return this.dbPromise
24163 .then(function (dbOrError) {
24164 if (dbOrError instanceof win['IDBDatabase']) {
24165 return PromisePolyfill.resolve();
24166 } else {
24167 return PromisePolyfill.reject(dbOrError);
24168 }
24169 });
24170 };
24171
24172 IDBStorageWrapper.prototype.isInitialized = function () {
24173 return !!this.dbPromise;
24174 };
24175
24176 /**
24177 * @param {IDBTransactionMode} mode
24178 * @param {function(IDBObjectStore): void} storeCb
24179 */
24180 IDBStorageWrapper.prototype.makeTransaction = function (mode, storeCb) {
24181 var storeName = this.storeName;
24182 var doTransaction = function (db) {
24183 return new PromisePolyfill(function (resolve, reject) {
24184 var transaction = db.transaction(storeName, mode);
24185 transaction.oncomplete = function () {
24186 resolve(transaction);
24187 };
24188 transaction.onabort = transaction.onerror = function () {
24189 reject(transaction.error);
24190 };
24191
24192 storeCb(transaction.objectStore(storeName));
24193 });
24194 };
24195
24196 return this.dbPromise
24197 .then(doTransaction)
24198 .catch(function (err) {
24199 if (err && err['name'] === 'InvalidStateError') {
24200 // try reopening the DB if the connection is closed
24201 this.dbPromise = this._openDb();
24202 return this.dbPromise.then(doTransaction);
24203 } else {
24204 return PromisePolyfill.reject(err);
24205 }
24206 }.bind(this));
24207 };
24208
24209 IDBStorageWrapper.prototype.setItem = function (key, value) {
24210 return this.makeTransaction('readwrite', function (objectStore) {
24211 objectStore.put(value, key);
24212 });
24213 };
24214
24215 IDBStorageWrapper.prototype.getItem = function (key) {
24216 var req;
24217 return this.makeTransaction('readonly', function (objectStore) {
24218 req = objectStore.get(key);
24219 }).then(function () {
24220 return req.result;
24221 });
24222 };
24223
24224 IDBStorageWrapper.prototype.removeItem = function (key) {
24225 return this.makeTransaction('readwrite', function (objectStore) {
24226 objectStore.delete(key);
24227 });
24228 };
24229
24230 IDBStorageWrapper.prototype.getAll = function () {
24231 var req;
24232 return this.makeTransaction('readonly', function (objectStore) {
24233 req = objectStore.getAll();
24234 }).then(function () {
24235 return req.result;
24236 });
24237 };
24238
24239 /**
24240 * GDPR utils
24241 *
24242 * The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
24243 * and privacy for all individuals within the European Union. It addresses the export of personal
24244 * data outside the EU. The GDPR aims primarily to give control back to citizens and residents
24245 * over their personal data and to simplify the regulatory environment for international business
24246 * by unifying the regulation within the EU.
24247 *
24248 * This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
24249 * These functions are used internally by the SDK and are not intended to be publicly exposed.
24250 */
24251
24252
24253 /**
24254 * A function used to track a Mixpanel event (e.g. MixpanelLib.track)
24255 * @callback trackFunction
24256 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
24257 * @param {Object} [properties] A set of properties to include with the event you're sending. These describe the user who did the event or details about the event itself.
24258 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
24259 */
24260
24261 /** Public **/
24262
24263 var GDPR_DEFAULT_PERSISTENCE_PREFIX = '__mp_opt_in_out_';
24264
24265 /**
24266 * Opt the user in to data tracking and cookies/localstorage for the given token
24267 * @param {string} token - Mixpanel project tracking token
24268 * @param {Object} [options]
24269 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24270 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24271 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24272 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24273 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24274 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24275 * @param {string} [options.cookieDomain] - custom cookie domain
24276 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24277 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24278 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24279 */
24280 function optIn(token, options) {
24281 _optInOut(true, token, options);
24282 }
24283
24284 /**
24285 * Opt the user out of data tracking and cookies/localstorage for the given token
24286 * @param {string} token - Mixpanel project tracking token
24287 * @param {Object} [options]
24288 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24289 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24290 * @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires
24291 * @param {string} [options.cookieDomain] - custom cookie domain
24292 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24293 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not
24294 * @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not
24295 */
24296 function optOut(token, options) {
24297 _optInOut(false, token, options);
24298 }
24299
24300 /**
24301 * Check whether the user has opted in to data tracking and cookies/localstorage for the given token
24302 * @param {string} token - Mixpanel project tracking token
24303 * @param {Object} [options]
24304 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24305 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24306 * @returns {boolean} whether the user has opted in to the given opt type
24307 */
24308 function hasOptedIn(token, options) {
24309 return _getStorageValue(token, options) === '1';
24310 }
24311
24312 /**
24313 * Check whether the user has opted out of data tracking and cookies/localstorage for the given token
24314 * @param {string} token - Mixpanel project tracking token
24315 * @param {Object} [options]
24316 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24317 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24318 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24319 * @returns {boolean} whether the user has opted out of the given opt type
24320 */
24321 function hasOptedOut(token, options) {
24322 if (_hasDoNotTrackFlagOn(options)) {
24323 console$1.warn('This browser has "Do Not Track" enabled. This will prevent the Mixpanel SDK from sending any data. To ignore the "Do Not Track" browser setting, initialize the Mixpanel instance with the config "ignore_dnt: true"');
24324 return true;
24325 }
24326 var optedOut = _getStorageValue(token, options) === '0';
24327 if (optedOut) {
24328 console$1.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
24329 }
24330 return optedOut;
24331 }
24332
24333 /**
24334 * Wrap a MixpanelLib method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24335 * If the user has opted out, return early instead of executing the method.
24336 * If a callback argument was provided, execute it passing the 0 error code.
24337 * @param {function} method - wrapped method to be executed if the user has not opted out
24338 * @returns {*} the result of executing method OR undefined if the user has opted out
24339 */
24340 function addOptOutCheckMixpanelLib(method) {
24341 return _addOptOutCheck(method, function(name) {
24342 return this.get_config(name);
24343 });
24344 }
24345
24346 /**
24347 * Wrap a MixpanelPeople method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24348 * If the user has opted out, return early instead of executing the method.
24349 * If a callback argument was provided, execute it passing the 0 error code.
24350 * @param {function} method - wrapped method to be executed if the user has not opted out
24351 * @returns {*} the result of executing method OR undefined if the user has opted out
24352 */
24353 function addOptOutCheckMixpanelPeople(method) {
24354 return _addOptOutCheck(method, function(name) {
24355 return this._get_config(name);
24356 });
24357 }
24358
24359 /**
24360 * Wrap a MixpanelGroup method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24361 * If the user has opted out, return early instead of executing the method.
24362 * If a callback argument was provided, execute it passing the 0 error code.
24363 * @param {function} method - wrapped method to be executed if the user has not opted out
24364 * @returns {*} the result of executing method OR undefined if the user has opted out
24365 */
24366 function addOptOutCheckMixpanelGroup(method) {
24367 return _addOptOutCheck(method, function(name) {
24368 return this._get_config(name);
24369 });
24370 }
24371
24372 /**
24373 * Clear the user's opt in/out status of data tracking and cookies/localstorage for the given token
24374 * @param {string} token - Mixpanel project tracking token
24375 * @param {Object} [options]
24376 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24377 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24378 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24379 * @param {string} [options.cookieDomain] - custom cookie domain
24380 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24381 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24382 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24383 */
24384 function clearOptInOut(token, options) {
24385 options = options || {};
24386 _getStorage(options).remove(
24387 _getStorageKey(token, options), !!options.crossSubdomainCookie, options.cookieDomain
24388 );
24389 }
24390
24391 /** Private **/
24392
24393 /**
24394 * Get storage util
24395 * @param {Object} [options]
24396 * @param {string} [options.persistenceType]
24397 * @returns {object} either _.cookie or _.localstorage
24398 */
24399 function _getStorage(options) {
24400 options = options || {};
24401 return options.persistenceType === 'localStorage' ? _.localStorage : _.cookie;
24402 }
24403
24404 /**
24405 * Get the name of the cookie that is used for the given opt type (tracking, cookie, etc.)
24406 * @param {string} token - Mixpanel project tracking token
24407 * @param {Object} [options]
24408 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24409 * @returns {string} the name of the cookie for the given opt type
24410 */
24411 function _getStorageKey(token, options) {
24412 options = options || {};
24413 return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
24414 }
24415
24416 /**
24417 * Get the value of the cookie that is used for the given opt type (tracking, cookie, etc.)
24418 * @param {string} token - Mixpanel project tracking token
24419 * @param {Object} [options]
24420 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24421 * @returns {string} the value of the cookie for the given opt type
24422 */
24423 function _getStorageValue(token, options) {
24424 return _getStorage(options).get(_getStorageKey(token, options));
24425 }
24426
24427 /**
24428 * Check whether the user has set the DNT/doNotTrack setting to true in their browser
24429 * @param {Object} [options]
24430 * @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests
24431 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24432 * @returns {boolean} whether the DNT setting is true
24433 */
24434 function _hasDoNotTrackFlagOn(options) {
24435 if (options && options.ignoreDnt) {
24436 return false;
24437 }
24438 var win$1 = (options && options.window) || win;
24439 var nav = win$1['navigator'] || {};
24440 var hasDntOn = false;
24441
24442 _.each([
24443 nav['doNotTrack'], // standard
24444 nav['msDoNotTrack'],
24445 win$1['doNotTrack']
24446 ], function(dntValue) {
24447 if (_.includes([true, 1, '1', 'yes'], dntValue)) {
24448 hasDntOn = true;
24449 }
24450 });
24451
24452 return hasDntOn;
24453 }
24454
24455 /**
24456 * Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type
24457 * @param {boolean} optValue - whether to opt the user in or out for the given opt type
24458 * @param {string} token - Mixpanel project tracking token
24459 * @param {Object} [options]
24460 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24461 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24462 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24463 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24464 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24465 * @param {string} [options.cookieDomain] - custom cookie domain
24466 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24467 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24468 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24469 */
24470 function _optInOut(optValue, token, options) {
24471 if (!_.isString(token) || !token.length) {
24472 console$1.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token');
24473 return;
24474 }
24475
24476 options = options || {};
24477
24478 _getStorage(options).set(
24479 _getStorageKey(token, options),
24480 optValue ? 1 : 0,
24481 _.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
24482 !!options.crossSubdomainCookie,
24483 !!options.secureCookie,
24484 !!options.crossSiteCookie,
24485 options.cookieDomain
24486 );
24487
24488 if (options.track && optValue) { // only track event if opting in (optValue=true)
24489 options.track(options.trackEventName || '$opt_in', options.trackProperties, {
24490 'send_immediately': true
24491 });
24492 }
24493 }
24494
24495 /**
24496 * Wrap a method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24497 * If the user has opted out, return early instead of executing the method.
24498 * If a callback argument was provided, execute it passing the 0 error code.
24499 * @param {function} method - wrapped method to be executed if the user has not opted out
24500 * @param {function} getConfigValue - getter function for the Mixpanel API token and other options to be used with opt-out check
24501 * @returns {*} the result of executing method OR undefined if the user has opted out
24502 */
24503 function _addOptOutCheck(method, getConfigValue) {
24504 return function() {
24505 var optedOut = false;
24506
24507 try {
24508 var token = getConfigValue.call(this, 'token');
24509 var ignoreDnt = getConfigValue.call(this, 'ignore_dnt');
24510 var persistenceType = getConfigValue.call(this, 'opt_out_tracking_persistence_type');
24511 var persistencePrefix = getConfigValue.call(this, 'opt_out_tracking_cookie_prefix');
24512 var win = getConfigValue.call(this, 'window'); // used to override window during browser tests
24513
24514 if (token) { // if there was an issue getting the token, continue method execution as normal
24515 optedOut = hasOptedOut(token, {
24516 ignoreDnt: ignoreDnt,
24517 persistenceType: persistenceType,
24518 persistencePrefix: persistencePrefix,
24519 window: win
24520 });
24521 }
24522 } catch(err) {
24523 console$1.error('Unexpected error when checking tracking opt-out status: ' + err);
24524 }
24525
24526 if (!optedOut) {
24527 return method.apply(this, arguments);
24528 }
24529
24530 var callback = arguments[arguments.length - 1];
24531 if (typeof(callback) === 'function') {
24532 callback(0);
24533 }
24534
24535 return;
24536 };
24537 }
24538
24539 var logger$6 = console_with_prefix('lock');
24540
24541 /**
24542 * SharedLock: a mutex built on HTML5 localStorage, to ensure that only one browser
24543 * window/tab at a time will be able to access shared resources.
24544 *
24545 * Based on the Alur and Taubenfeld fast lock
24546 * (http://www.cs.rochester.edu/research/synchronization/pseudocode/fastlock.html)
24547 * with an added timeout to ensure there will be eventual progress in the event
24548 * that a window is closed in the middle of the callback.
24549 *
24550 * Implementation based on the original version by David Wolever (https://github.com/wolever)
24551 * at https://gist.github.com/wolever/5fd7573d1ef6166e8f8c4af286a69432.
24552 *
24553 * @example
24554 * const myLock = new SharedLock('some-key');
24555 * myLock.withLock(function() {
24556 * console.log('I hold the mutex!');
24557 * });
24558 *
24559 * @constructor
24560 */
24561 var SharedLock = function(key, options) {
24562 options = options || {};
24563
24564 this.storageKey = key;
24565 this.storage = options.storage || win.localStorage;
24566 this.pollIntervalMS = options.pollIntervalMS || 100;
24567 this.timeoutMS = options.timeoutMS || 2000;
24568
24569 // dependency-inject promise implementation for testing purposes
24570 this.promiseImpl = options.promiseImpl || PromisePolyfill;
24571 };
24572
24573 // pass in a specific pid to test contention scenarios; otherwise
24574 // it is chosen randomly for each acquisition attempt
24575 SharedLock.prototype.withLock = function(lockedCB, pid) {
24576 var Promise = this.promiseImpl;
24577 return new Promise(_.bind(function (resolve, reject) {
24578 var i = pid || (new Date().getTime() + '|' + Math.random());
24579 var startTime = new Date().getTime();
24580 var key = this.storageKey;
24581 var pollIntervalMS = this.pollIntervalMS;
24582 var timeoutMS = this.timeoutMS;
24583 var storage = this.storage;
24584
24585 var keyX = key + ':X';
24586 var keyY = key + ':Y';
24587 var keyZ = key + ':Z';
24588
24589 var delay = function(cb) {
24590 if (new Date().getTime() - startTime > timeoutMS) {
24591 logger$6.error('Timeout waiting for mutex on ' + key + '; clearing lock. [' + i + ']');
24592 storage.removeItem(keyZ);
24593 storage.removeItem(keyY);
24594 loop();
24595 return;
24596 }
24597 setTimeout(function() {
24598 try {
24599 cb();
24600 } catch(err) {
24601 reject(err);
24602 }
24603 }, pollIntervalMS * (Math.random() + 0.1));
24604 };
24605
24606 var waitFor = function(predicate, cb) {
24607 if (predicate()) {
24608 cb();
24609 } else {
24610 delay(function() {
24611 waitFor(predicate, cb);
24612 });
24613 }
24614 };
24615
24616 var getSetY = function() {
24617 var valY = storage.getItem(keyY);
24618 if (valY && valY !== i) { // if Y == i then this process already has the lock (useful for test cases)
24619 return false;
24620 } else {
24621 storage.setItem(keyY, i);
24622 if (storage.getItem(keyY) === i) {
24623 return true;
24624 } else {
24625 if (!localStorageSupported(storage, true)) {
24626 reject(new Error('localStorage support dropped while acquiring lock'));
24627 }
24628 return false;
24629 }
24630 }
24631 };
24632
24633 var loop = function() {
24634 storage.setItem(keyX, i);
24635
24636 waitFor(getSetY, function() {
24637 if (storage.getItem(keyX) === i) {
24638 criticalSection();
24639 return;
24640 }
24641
24642 delay(function() {
24643 if (storage.getItem(keyY) !== i) {
24644 loop();
24645 return;
24646 }
24647 waitFor(function() {
24648 return !storage.getItem(keyZ);
24649 }, criticalSection);
24650 });
24651 });
24652 };
24653
24654 var criticalSection = function() {
24655 storage.setItem(keyZ, '1');
24656 var removeLock = function () {
24657 storage.removeItem(keyZ);
24658 if (storage.getItem(keyY) === i) {
24659 storage.removeItem(keyY);
24660 }
24661 if (storage.getItem(keyX) === i) {
24662 storage.removeItem(keyX);
24663 }
24664 };
24665
24666 lockedCB()
24667 .then(function (ret) {
24668 removeLock();
24669 resolve(ret);
24670 })
24671 .catch(function (err) {
24672 removeLock();
24673 reject(err);
24674 });
24675 };
24676
24677 try {
24678 if (localStorageSupported(storage, true)) {
24679 loop();
24680 } else {
24681 throw new Error('localStorage support check failed');
24682 }
24683 } catch(err) {
24684 reject(err);
24685 }
24686 }, this));
24687 };
24688
24689 /**
24690 * @type {import('./wrapper').StorageWrapper}
24691 */
24692 var LocalStorageWrapper = function (storageOverride) {
24693 this.storage = storageOverride || win.localStorage;
24694 };
24695
24696 LocalStorageWrapper.prototype.init = function () {
24697 return PromisePolyfill.resolve();
24698 };
24699
24700 LocalStorageWrapper.prototype.isInitialized = function () {
24701 return true;
24702 };
24703
24704 LocalStorageWrapper.prototype.setItem = function (key, value) {
24705 return new PromisePolyfill(_.bind(function (resolve, reject) {
24706 try {
24707 this.storage.setItem(key, JSONStringify(value));
24708 } catch (e) {
24709 reject(e);
24710 }
24711 resolve();
24712 }, this));
24713 };
24714
24715 LocalStorageWrapper.prototype.getItem = function (key) {
24716 return new PromisePolyfill(_.bind(function (resolve, reject) {
24717 var item;
24718 try {
24719 item = JSONParse(this.storage.getItem(key));
24720 } catch (e) {
24721 reject(e);
24722 }
24723 resolve(item);
24724 }, this));
24725 };
24726
24727 LocalStorageWrapper.prototype.removeItem = function (key) {
24728 return new PromisePolyfill(_.bind(function (resolve, reject) {
24729 try {
24730 this.storage.removeItem(key);
24731 } catch (e) {
24732 reject(e);
24733 }
24734 resolve();
24735 }, this));
24736 };
24737
24738 var logger$5 = console_with_prefix('batch');
24739
24740 /**
24741 * RequestQueue: queue for batching API requests with localStorage backup for retries.
24742 * Maintains an in-memory queue which represents the source of truth for the current
24743 * page, but also writes all items out to a copy in the browser's localStorage, which
24744 * can be read on subsequent pageloads and retried. For batchability, all the request
24745 * items in the queue should be of the same type (events, people updates, group updates)
24746 * so they can be sent in a single request to the same API endpoint.
24747 *
24748 * LocalStorage keying and locking: In order for reloads and subsequent pageloads of
24749 * the same site to access the same persisted data, they must share the same localStorage
24750 * key (for instance based on project token and queue type). Therefore access to the
24751 * localStorage entry is guarded by an asynchronous mutex (SharedLock) to prevent
24752 * simultaneously open windows/tabs from overwriting each other's data (which would lead
24753 * to data loss in some situations).
24754 * @constructor
24755 */
24756 var RequestQueue = function (storageKey, options) {
24757 options = options || {};
24758 this.storageKey = storageKey;
24759 this.usePersistence = options.usePersistence;
24760 if (this.usePersistence) {
24761 this.queueStorage = options.queueStorage || new LocalStorageWrapper();
24762 this.lock = new SharedLock(storageKey, {
24763 storage: options.sharedLockStorage || win.localStorage,
24764 timeoutMS: options.sharedLockTimeoutMS,
24765 });
24766 }
24767 this.reportError = options.errorReporter || _.bind(logger$5.error, logger$5);
24768
24769 this.pid = options.pid || null; // pass pid to test out storage lock contention scenarios
24770
24771 this.memQueue = [];
24772 this.initialized = false;
24773
24774 if (options.enqueueThrottleMs) {
24775 this.enqueuePersisted = batchedThrottle(_.bind(this._enqueuePersisted, this), options.enqueueThrottleMs);
24776 } else {
24777 this.enqueuePersisted = _.bind(function (queueEntry) {
24778 return this._enqueuePersisted([queueEntry]);
24779 }, this);
24780 }
24781 };
24782
24783 RequestQueue.prototype.ensureInit = function () {
24784 if (this.initialized || !this.usePersistence) {
24785 return PromisePolyfill.resolve();
24786 }
24787
24788 return this.queueStorage
24789 .init()
24790 .then(_.bind(function () {
24791 this.initialized = true;
24792 }, this))
24793 .catch(_.bind(function (err) {
24794 this.reportError('Error initializing queue persistence. Disabling persistence', err);
24795 this.initialized = true;
24796 this.usePersistence = false;
24797 }, this));
24798 };
24799
24800 /**
24801 * Add one item to queues (memory and localStorage). The queued entry includes
24802 * the given item along with an auto-generated ID and a "flush-after" timestamp.
24803 * It is expected that the item will be sent over the network and dequeued
24804 * before the flush-after time; if this doesn't happen it is considered orphaned
24805 * (e.g., the original tab where it was enqueued got closed before it could be
24806 * sent) and the item can be sent by any tab that finds it in localStorage.
24807 *
24808 * The final callback param is called with a param indicating success or
24809 * failure of the enqueue operation; it is asynchronous because the localStorage
24810 * lock is asynchronous.
24811 */
24812 RequestQueue.prototype.enqueue = function (item, flushInterval) {
24813 var queueEntry = {
24814 'id': cheap_guid(),
24815 'flushAfter': new Date().getTime() + flushInterval * 2,
24816 'payload': item
24817 };
24818
24819 if (!this.usePersistence) {
24820 this.memQueue.push(queueEntry);
24821 return PromisePolyfill.resolve(true);
24822 } else {
24823 return this.enqueuePersisted(queueEntry);
24824 }
24825 };
24826
24827 RequestQueue.prototype._enqueuePersisted = function (queueEntries) {
24828 var enqueueItem = _.bind(function () {
24829 return this.ensureInit()
24830 .then(_.bind(function () {
24831 return this.readFromStorage();
24832 }, this))
24833 .then(_.bind(function (storedQueue) {
24834 return this.saveToStorage(storedQueue.concat(queueEntries));
24835 }, this))
24836 .then(_.bind(function (succeeded) {
24837 // only add to in-memory queue when storage succeeds
24838 if (succeeded) {
24839 this.memQueue = this.memQueue.concat(queueEntries);
24840 }
24841
24842 return succeeded;
24843 }, this))
24844 .catch(_.bind(function (err) {
24845 this.reportError('Error enqueueing items', err, queueEntries);
24846 return false;
24847 }, this));
24848 }, this);
24849
24850 return this.lock
24851 .withLock(enqueueItem, this.pid)
24852 .catch(_.bind(function (err) {
24853 this.reportError('Error acquiring storage lock', err);
24854 return false;
24855 }, this));
24856 };
24857
24858 /**
24859 * Read out the given number of queue entries. If this.memQueue
24860 * has fewer than batchSize items, then look for "orphaned" items
24861 * in the persisted queue (items where the 'flushAfter' time has
24862 * already passed).
24863 */
24864 RequestQueue.prototype.fillBatch = function (batchSize) {
24865 var batch = this.memQueue.slice(0, batchSize);
24866 if (this.usePersistence && batch.length < batchSize) {
24867 // don't need lock just to read events; localStorage is thread-safe
24868 // and the worst that could happen is a duplicate send of some
24869 // orphaned events, which will be deduplicated on the server side
24870 return this.ensureInit()
24871 .then(_.bind(function () {
24872 return this.readFromStorage();
24873 }, this))
24874 .then(_.bind(function (storedQueue) {
24875 if (storedQueue.length) {
24876 // item IDs already in batch; don't duplicate out of storage
24877 var idsInBatch = {}; // poor man's Set
24878 _.each(batch, function (item) {
24879 idsInBatch[item['id']] = true;
24880 });
24881
24882 for (var i = 0; i < storedQueue.length; i++) {
24883 var item = storedQueue[i];
24884 if (new Date().getTime() > item['flushAfter'] && !idsInBatch[item['id']]) {
24885 item.orphaned = true;
24886 batch.push(item);
24887 if (batch.length >= batchSize) {
24888 break;
24889 }
24890 }
24891 }
24892 }
24893
24894 return batch;
24895 }, this));
24896 } else {
24897 return PromisePolyfill.resolve(batch);
24898 }
24899 };
24900
24901 /**
24902 * Remove items with matching 'id' from array (immutably)
24903 * also remove any item without a valid id (e.g., malformed
24904 * storage entries).
24905 */
24906 var filterOutIDsAndInvalid = function (items, idSet) {
24907 var filteredItems = [];
24908 _.each(items, function (item) {
24909 if (item['id'] && !idSet[item['id']]) {
24910 filteredItems.push(item);
24911 }
24912 });
24913 return filteredItems;
24914 };
24915
24916 /**
24917 * Remove items with matching IDs from both in-memory queue
24918 * and persisted queue
24919 */
24920 RequestQueue.prototype.removeItemsByID = function (ids) {
24921 var idSet = {}; // poor man's Set
24922 _.each(ids, function (id) {
24923 idSet[id] = true;
24924 });
24925
24926 this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
24927 if (!this.usePersistence) {
24928 return PromisePolyfill.resolve(true);
24929 } else {
24930 var removeFromStorage = _.bind(function () {
24931 return this.ensureInit()
24932 .then(_.bind(function () {
24933 return this.readFromStorage();
24934 }, this))
24935 .then(_.bind(function (storedQueue) {
24936 storedQueue = filterOutIDsAndInvalid(storedQueue, idSet);
24937 return this.saveToStorage(storedQueue);
24938 }, this))
24939 .then(_.bind(function () {
24940 return this.readFromStorage();
24941 }, this))
24942 .then(_.bind(function (storedQueue) {
24943 // an extra check: did storage report success but somehow
24944 // the items are still there?
24945 for (var i = 0; i < storedQueue.length; i++) {
24946 var item = storedQueue[i];
24947 if (item['id'] && !!idSet[item['id']]) {
24948 throw new Error('Item not removed from storage');
24949 }
24950 }
24951 return true;
24952 }, this))
24953 .catch(_.bind(function (err) {
24954 this.reportError('Error removing items', err, ids);
24955 return false;
24956 }, this));
24957 }, this);
24958
24959 return this.lock
24960 .withLock(removeFromStorage, this.pid)
24961 .catch(_.bind(function (err) {
24962 this.reportError('Error acquiring storage lock', err);
24963 if (!localStorageSupported(this.lock.storage, true)) {
24964 // Looks like localStorage writes have stopped working sometime after
24965 // initialization (probably full), and so nobody can acquire locks
24966 // anymore. Consider it temporarily safe to remove items without the
24967 // lock, since nobody's writing successfully anyway.
24968 return removeFromStorage()
24969 .then(_.bind(function (success) {
24970 if (!success) {
24971 // OK, we couldn't even write out the smaller queue. Try clearing it
24972 // entirely.
24973 return this.queueStorage.removeItem(this.storageKey).then(function () {
24974 return success;
24975 });
24976 }
24977 return success;
24978 }, this))
24979 .catch(_.bind(function (err) {
24980 this.reportError('Error clearing queue', err);
24981 return false;
24982 }, this));
24983 } else {
24984 return false;
24985 }
24986 }, this));
24987 }
24988 };
24989
24990 // internal helper for RequestQueue.updatePayloads
24991 var updatePayloads = function (existingItems, itemsToUpdate) {
24992 var newItems = [];
24993 _.each(existingItems, function (item) {
24994 var id = item['id'];
24995 if (id in itemsToUpdate) {
24996 var newPayload = itemsToUpdate[id];
24997 if (newPayload !== null) {
24998 item['payload'] = newPayload;
24999 newItems.push(item);
25000 }
25001 } else {
25002 // no update
25003 newItems.push(item);
25004 }
25005 });
25006 return newItems;
25007 };
25008
25009 /**
25010 * Update payloads of given items in both in-memory queue and
25011 * persisted queue. Items set to null are removed from queues.
25012 */
25013 RequestQueue.prototype.updatePayloads = function (itemsToUpdate) {
25014 this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
25015 if (!this.usePersistence) {
25016 return PromisePolyfill.resolve(true);
25017 } else {
25018 return this.lock
25019 .withLock(_.bind(function lockAcquired() {
25020 return this.ensureInit()
25021 .then(_.bind(function () {
25022 return this.readFromStorage();
25023 }, this))
25024 .then(_.bind(function (storedQueue) {
25025 storedQueue = updatePayloads(storedQueue, itemsToUpdate);
25026 return this.saveToStorage(storedQueue);
25027 }, this))
25028 .catch(_.bind(function (err) {
25029 this.reportError('Error updating items', itemsToUpdate, err);
25030 return false;
25031 }, this));
25032 }, this), this.pid)
25033 .catch(_.bind(function (err) {
25034 this.reportError('Error acquiring storage lock', err);
25035 return false;
25036 }, this));
25037 }
25038 };
25039
25040 /**
25041 * Read and parse items array from localStorage entry, handling
25042 * malformed/missing data if necessary.
25043 */
25044 RequestQueue.prototype.readFromStorage = function () {
25045 return this.ensureInit()
25046 .then(_.bind(function () {
25047 return this.queueStorage.getItem(this.storageKey);
25048 }, this))
25049 .then(_.bind(function (storageEntry) {
25050 if (storageEntry) {
25051 if (!_.isArray(storageEntry)) {
25052 this.reportError('Invalid storage entry:', storageEntry);
25053 storageEntry = null;
25054 }
25055 }
25056 return storageEntry || [];
25057 }, this))
25058 .catch(_.bind(function (err) {
25059 this.reportError('Error retrieving queue', err);
25060 return [];
25061 }, this));
25062 };
25063
25064 /**
25065 * Serialize the given items array to localStorage.
25066 */
25067 RequestQueue.prototype.saveToStorage = function (queue) {
25068 return this.ensureInit()
25069 .then(_.bind(function () {
25070 return this.queueStorage.setItem(this.storageKey, queue);
25071 }, this))
25072 .then(function () {
25073 return true;
25074 })
25075 .catch(_.bind(function (err) {
25076 this.reportError('Error saving queue', err);
25077 return false;
25078 }, this));
25079 };
25080
25081 /**
25082 * Clear out queues (memory and localStorage).
25083 */
25084 RequestQueue.prototype.clear = function () {
25085 this.memQueue = [];
25086
25087 if (this.usePersistence) {
25088 return this.ensureInit()
25089 .then(_.bind(function () {
25090 return this.queueStorage.removeItem(this.storageKey);
25091 }, this));
25092 } else {
25093 return PromisePolyfill.resolve();
25094 }
25095 };
25096
25097 // maximum interval between request retries after exponential backoff
25098 var MAX_RETRY_INTERVAL_MS = 10 * 60 * 1000; // 10 minutes
25099
25100 var logger$4 = console_with_prefix('batch');
25101
25102 /**
25103 * RequestBatcher: manages the queueing, flushing, retry etc of requests of one
25104 * type (events, people, groups).
25105 * Uses RequestQueue to manage the backing store.
25106 * @constructor
25107 */
25108 var RequestBatcher = function(storageKey, options) {
25109 this.errorReporter = options.errorReporter;
25110 this.queue = new RequestQueue(storageKey, {
25111 errorReporter: _.bind(this.reportError, this),
25112 queueStorage: options.queueStorage,
25113 sharedLockStorage: options.sharedLockStorage,
25114 sharedLockTimeoutMS: options.sharedLockTimeoutMS,
25115 usePersistence: options.usePersistence,
25116 enqueueThrottleMs: options.enqueueThrottleMs
25117 });
25118
25119 this.libConfig = options.libConfig;
25120 this.sendRequest = options.sendRequestFunc;
25121 this.beforeSendHook = options.beforeSendHook;
25122 this.stopAllBatching = options.stopAllBatchingFunc;
25123
25124 // seed variable batch size + flush interval with configured values
25125 this.batchSize = this.libConfig['batch_size'];
25126 this.flushInterval = this.libConfig['batch_flush_interval_ms'];
25127
25128 this.stopped = !this.libConfig['batch_autostart'];
25129 this.consecutiveRemovalFailures = 0;
25130
25131 // extra client-side dedupe
25132 this.itemIdsSentSuccessfully = {};
25133
25134 // Make the flush occur at the interval specified by flushIntervalMs, default behavior will attempt consecutive flushes
25135 // as long as the queue is not empty. This is useful for high-frequency events like Session Replay where we might end up
25136 // in a request loop and get ratelimited by the server.
25137 this.flushOnlyOnInterval = options.flushOnlyOnInterval || false;
25138
25139 this._flushPromise = null;
25140 };
25141
25142 /**
25143 * Add one item to queue.
25144 */
25145 RequestBatcher.prototype.enqueue = function(item) {
25146 return this.queue.enqueue(item, this.flushInterval);
25147 };
25148
25149 /**
25150 * Start flushing batches at the configured time interval. Must call
25151 * this method upon SDK init in order to send anything over the network.
25152 */
25153 RequestBatcher.prototype.start = function() {
25154 this.stopped = false;
25155 this.consecutiveRemovalFailures = 0;
25156 return this.flush();
25157 };
25158
25159 /**
25160 * Stop flushing batches. Can be restarted by calling start().
25161 */
25162 RequestBatcher.prototype.stop = function() {
25163 this.stopped = true;
25164 if (this.timeoutID) {
25165 clearTimeout(this.timeoutID);
25166 this.timeoutID = null;
25167 }
25168 };
25169
25170 /**
25171 * Clear out queue.
25172 */
25173 RequestBatcher.prototype.clear = function() {
25174 return this.queue.clear();
25175 };
25176
25177 /**
25178 * Restore batch size configuration to whatever is set in the main SDK.
25179 */
25180 RequestBatcher.prototype.resetBatchSize = function() {
25181 this.batchSize = this.libConfig['batch_size'];
25182 };
25183
25184 /**
25185 * Restore flush interval time configuration to whatever is set in the main SDK.
25186 */
25187 RequestBatcher.prototype.resetFlush = function() {
25188 this.scheduleFlush(this.libConfig['batch_flush_interval_ms']);
25189 };
25190
25191 /**
25192 * Schedule the next flush in the given number of milliseconds.
25193 */
25194 RequestBatcher.prototype.scheduleFlush = function(flushMS) {
25195 this.flushInterval = flushMS;
25196 if (!this.stopped) { // don't schedule anymore if batching has been stopped
25197 this.timeoutID = setTimeout(_.bind(function() {
25198 if (!this.stopped) {
25199 this._flushPromise = this.flush();
25200 }
25201 }, this), this.flushInterval);
25202 }
25203 };
25204
25205 /**
25206 * Send a request using the sendRequest callback, but promisified.
25207 * TODO: sendRequest should be promisified in the first place.
25208 */
25209 RequestBatcher.prototype.sendRequestPromise = function(data, options) {
25210 return new PromisePolyfill(_.bind(function(resolve) {
25211 this.sendRequest(data, options, resolve);
25212 }, this));
25213 };
25214
25215
25216 /**
25217 * Flush one batch to network. Depending on success/failure modes, it will either
25218 * remove the batch from the queue or leave it in for retry, and schedule the next
25219 * flush. In cases of most network or API failures, it will back off exponentially
25220 * when retrying.
25221 * @param {Object} [options]
25222 * @param {boolean} [options.sendBeacon] - whether to send batch with
25223 * navigator.sendBeacon (only useful for sending batches before page unloads, as
25224 * sendBeacon offers no callbacks or status indications)
25225 */
25226 RequestBatcher.prototype.flush = function(options) {
25227 if (this.requestInProgress) {
25228 logger$4.log('Flush: Request already in progress');
25229 return PromisePolyfill.resolve();
25230 }
25231
25232 this.requestInProgress = true;
25233
25234 options = options || {};
25235 var timeoutMS = this.libConfig['batch_request_timeout_ms'];
25236 var startTime = new Date().getTime();
25237 var currentBatchSize = this.batchSize;
25238
25239 return this.queue.fillBatch(currentBatchSize)
25240 .then(_.bind(function(batch) {
25241
25242 // if there's more items in the queue than the batch size, attempt
25243 // to flush again after the current batch is done.
25244 var attemptSecondaryFlush = batch.length === currentBatchSize;
25245 var dataForRequest = [];
25246 var transformedItems = {};
25247 _.each(batch, function(item) {
25248 var payload = item['payload'];
25249 if (this.beforeSendHook && !item.orphaned) {
25250 payload = this.beforeSendHook(payload);
25251 }
25252 if (payload) {
25253 // mp_sent_by_lib_version prop captures which lib version actually
25254 // sends each event (regardless of which version originally queued
25255 // it for sending)
25256 if (payload['event'] && payload['properties']) {
25257 payload['properties'] = _.extend(
25258 {},
25259 payload['properties'],
25260 {'mp_sent_by_lib_version': Config.LIB_VERSION}
25261 );
25262 }
25263 var addPayload = true;
25264 var itemId = item['id'];
25265 if (itemId) {
25266 if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
25267 this.reportError('[dupe] item ID sent too many times, not sending', {
25268 item: item,
25269 batchSize: batch.length,
25270 timesSent: this.itemIdsSentSuccessfully[itemId]
25271 });
25272 addPayload = false;
25273 }
25274 } else {
25275 this.reportError('[dupe] found item with no ID', {item: item});
25276 }
25277
25278 if (addPayload) {
25279 dataForRequest.push(payload);
25280 }
25281 }
25282 transformedItems[item['id']] = payload;
25283 }, this);
25284
25285 if (dataForRequest.length < 1) {
25286 this.requestInProgress = false;
25287 this.resetFlush();
25288 return PromisePolyfill.resolve(); // nothing to do
25289 }
25290
25291 var removeItemsFromQueue = _.bind(function () {
25292 return this.queue
25293 .removeItemsByID(
25294 _.map(batch, function (item) {
25295 return item['id'];
25296 })
25297 )
25298 .then(_.bind(function (succeeded) {
25299 // client-side dedupe
25300 _.each(batch, _.bind(function(item) {
25301 var itemId = item['id'];
25302 if (itemId) {
25303 this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
25304 this.itemIdsSentSuccessfully[itemId]++;
25305 if (this.itemIdsSentSuccessfully[itemId] > 5) {
25306 this.reportError('[dupe] item ID sent too many times', {
25307 item: item,
25308 batchSize: batch.length,
25309 timesSent: this.itemIdsSentSuccessfully[itemId]
25310 });
25311 }
25312 } else {
25313 this.reportError('[dupe] found item with no ID while removing', {item: item});
25314 }
25315 }, this));
25316
25317 if (succeeded) {
25318 this.consecutiveRemovalFailures = 0;
25319 if (this.flushOnlyOnInterval && !attemptSecondaryFlush) {
25320 this.resetFlush(); // schedule next batch with a delay
25321 return PromisePolyfill.resolve();
25322 } else {
25323 return this.flush(); // handle next batch if the queue isn't empty
25324 }
25325 } else {
25326 if (++this.consecutiveRemovalFailures > 5) {
25327 this.reportError('Too many queue failures; disabling batching system.');
25328 this.stopAllBatching();
25329 } else {
25330 this.resetFlush();
25331 }
25332 return PromisePolyfill.resolve();
25333 }
25334 }, this));
25335 }, this);
25336
25337 var batchSendCallback = _.bind(function(res) {
25338 this.requestInProgress = false;
25339
25340 try {
25341
25342 // handle API response in a try-catch to make sure we can reset the
25343 // flush operation if something goes wrong
25344
25345 if (options.unloading) {
25346 // update persisted data to include hook transformations
25347 return this.queue.updatePayloads(transformedItems);
25348 } else if (
25349 _.isObject(res) &&
25350 res.error === 'timeout' &&
25351 new Date().getTime() - startTime >= timeoutMS
25352 ) {
25353 this.reportError('Network timeout; retrying');
25354 return this.flush();
25355 } else if (
25356 _.isObject(res) &&
25357 (
25358 res.httpStatusCode >= 500
25359 || res.httpStatusCode === 429
25360 || (res.httpStatusCode <= 0 && !isOnline())
25361 || res.error === 'timeout'
25362 )
25363 ) {
25364 // network or API error, or 429 Too Many Requests, retry
25365 var retryMS = this.flushInterval * 2;
25366 if (res.retryAfter) {
25367 retryMS = (parseInt(res.retryAfter, 10) * 1000) || retryMS;
25368 }
25369 retryMS = Math.min(MAX_RETRY_INTERVAL_MS, retryMS);
25370 this.reportError('Error; retry in ' + retryMS + ' ms');
25371 this.scheduleFlush(retryMS);
25372 return PromisePolyfill.resolve();
25373 } else if (_.isObject(res) && res.httpStatusCode === 413) {
25374 // 413 Payload Too Large
25375 if (batch.length > 1) {
25376 var halvedBatchSize = Math.max(1, Math.floor(currentBatchSize / 2));
25377 this.batchSize = Math.min(this.batchSize, halvedBatchSize, batch.length - 1);
25378 this.reportError('413 response; reducing batch size to ' + this.batchSize);
25379 this.resetFlush();
25380 return PromisePolyfill.resolve();
25381 } else {
25382 this.reportError('Single-event request too large; dropping', batch);
25383 this.resetBatchSize();
25384 return removeItemsFromQueue();
25385 }
25386 } else {
25387 // successful network request+response; remove each item in batch from queue
25388 // (even if it was e.g. a 400, in which case retrying won't help)
25389 return removeItemsFromQueue();
25390 }
25391 } catch(err) {
25392 this.reportError('Error handling API response', err);
25393 this.resetFlush();
25394 }
25395 }, this);
25396 var requestOptions = {
25397 method: 'POST',
25398 verbose: true,
25399 ignore_json_errors: true, // eslint-disable-line camelcase
25400 timeout_ms: timeoutMS // eslint-disable-line camelcase
25401 };
25402 if (options.unloading) {
25403 requestOptions.transport = 'sendBeacon';
25404 }
25405 logger$4.log('MIXPANEL REQUEST:', dataForRequest);
25406 return this.sendRequestPromise(dataForRequest, requestOptions).then(batchSendCallback);
25407 }, this))
25408 .catch(_.bind(function(err) {
25409 this.reportError('Error flushing request queue', err);
25410 this.resetFlush();
25411 }, this));
25412 };
25413
25414 /**
25415 * Log error to global logger and optional user-defined logger.
25416 */
25417 RequestBatcher.prototype.reportError = function(msg, err) {
25418 logger$4.error.apply(logger$4.error, arguments);
25419 if (this.errorReporter) {
25420 try {
25421 if (!(err instanceof Error)) {
25422 err = new Error(msg);
25423 }
25424 this.errorReporter(msg, err);
25425 } catch(err) {
25426 logger$4.error(err);
25427 }
25428 }
25429 };
25430
25431 /**
25432 * @param {import('./session-recording').SerializedRecording} serializedRecording
25433 * @returns {boolean}
25434 */
25435 var isRecordingExpired = function(serializedRecording) {
25436 var now = Date.now();
25437 return !serializedRecording || now > serializedRecording['maxExpires'] || now > serializedRecording['idleExpires'];
25438 };
25439
25440 var RECORD_ENQUEUE_THROTTLE_MS = 250;
25441
25442 var logger$3 = console_with_prefix('recorder');
25443 var CompressionStream = win['CompressionStream'];
25444
25445 var RECORDER_BATCHER_LIB_CONFIG = {
25446 'batch_size': 1000,
25447 'batch_flush_interval_ms': 10 * 1000,
25448 'batch_request_timeout_ms': 90 * 1000,
25449 'batch_autostart': true
25450 };
25451
25452 var ACTIVE_SOURCES = new Set([
25453 IncrementalSource.MouseMove,
25454 IncrementalSource.MouseInteraction,
25455 IncrementalSource.Scroll,
25456 IncrementalSource.ViewportResize,
25457 IncrementalSource.Input,
25458 IncrementalSource.TouchMove,
25459 IncrementalSource.MediaInteraction,
25460 IncrementalSource.Drag,
25461 IncrementalSource.Selection,
25462 ]);
25463
25464 function isUserEvent(ev) {
25465 return ev.type === EventType.IncrementalSnapshot && ACTIVE_SOURCES.has(ev.data.source);
25466 }
25467
25468 /**
25469 * @typedef {Object} SerializedRecording
25470 * @property {number} idleExpires
25471 * @property {number} maxExpires
25472 * @property {number} replayStartTime
25473 * @property {number} seqNo
25474 * @property {string} batchStartUrl
25475 * @property {string} replayId
25476 * @property {string} tabId
25477 * @property {string} replayStartUrl
25478 */
25479
25480 /**
25481 * @typedef {Object} SessionRecordingOptions
25482 * @property {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
25483 * @property {String} [options.replayId] - unique uuid for a single replay
25484 * @property {Function} [options.onIdleTimeout] - callback when a recording reaches idle timeout
25485 * @property {Function} [options.onMaxLengthReached] - callback when a recording reaches its maximum length
25486 * @property {Function} [options.rrwebRecord] - rrweb's `record` function
25487 * @property {Function} [options.onBatchSent] - callback when a batch of events is sent to the server
25488 * @property {Storage} [options.sharedLockStorage] - optional storage for shared lock, used for test dependency injection
25489 * optional properties for deserialization:
25490 * @property {number} idleExpires
25491 * @property {number} maxExpires
25492 * @property {number} replayStartTime
25493 * @property {number} seqNo
25494 * @property {string} batchStartUrl
25495 * @property {string} replayStartUrl
25496 */
25497
25498 /**
25499 * @typedef {Object} UserIdInfo
25500 * @property {string} distinct_id
25501 * @property {string} user_id
25502 * @property {string} device_id
25503 */
25504
25505
25506 /**
25507 * This class encapsulates a single session recording and its lifecycle.
25508 * @param {SessionRecordingOptions} options
25509 */
25510 var SessionRecording = function(options) {
25511 this._mixpanel = options.mixpanelInstance;
25512 this._onIdleTimeout = options.onIdleTimeout || NOOP_FUNC;
25513 this._onMaxLengthReached = options.onMaxLengthReached || NOOP_FUNC;
25514 this._onBatchSent = options.onBatchSent || NOOP_FUNC;
25515 this._rrwebRecord = options.rrwebRecord || null;
25516
25517 // internal rrweb stopRecording function
25518 this._stopRecording = null;
25519 this.replayId = options.replayId;
25520
25521 this.batchStartUrl = options.batchStartUrl || null;
25522 this.replayStartUrl = options.replayStartUrl || null;
25523 this.idleExpires = options.idleExpires || null;
25524 this.maxExpires = options.maxExpires || null;
25525 this.replayStartTime = options.replayStartTime || null;
25526 this.seqNo = options.seqNo || 0;
25527
25528 this.idleTimeoutId = null;
25529 this.maxTimeoutId = null;
25530
25531 this.recordMaxMs = MAX_RECORDING_MS;
25532 this.recordMinMs = 0;
25533
25534 // disable persistence if localStorage is not supported
25535 // request-queue will automatically disable persistence if indexedDB fails to initialize
25536 var usePersistence = localStorageSupported(options.sharedLockStorage, true) && !this.getConfig('disable_persistence');
25537
25538 // each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
25539 this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
25540 this.queueStorage = new IDBStorageWrapper(RECORDING_EVENTS_STORE_NAME);
25541 this.batcher = new RequestBatcher(this.batcherKey, {
25542 errorReporter: this.reportError.bind(this),
25543 flushOnlyOnInterval: true,
25544 libConfig: RECORDER_BATCHER_LIB_CONFIG,
25545 sendRequestFunc: this.flushEventsWithOptOut.bind(this),
25546 queueStorage: this.queueStorage,
25547 sharedLockStorage: options.sharedLockStorage,
25548 usePersistence: usePersistence,
25549 stopAllBatchingFunc: this.stopRecording.bind(this),
25550
25551 // increased throttle and shared lock timeout because recording events are very high frequency.
25552 // this will minimize the amount of lock contention between enqueued events.
25553 // for session recordings there is a lock for each tab anyway, so there's no risk of deadlock between tabs.
25554 enqueueThrottleMs: RECORD_ENQUEUE_THROTTLE_MS,
25555 sharedLockTimeoutMS: 10 * 1000,
25556 });
25557 };
25558
25559 /**
25560 * @returns {UserIdInfo}
25561 */
25562 SessionRecording.prototype.getUserIdInfo = function () {
25563 if (this.finalFlushUserIdInfo) {
25564 return this.finalFlushUserIdInfo;
25565 }
25566
25567 var userIdInfo = {
25568 'distinct_id': String(this._mixpanel.get_distinct_id()),
25569 };
25570
25571 // send ID management props if they exist
25572 var deviceId = this._mixpanel.get_property('$device_id');
25573 if (deviceId) {
25574 userIdInfo['$device_id'] = deviceId;
25575 }
25576 var userId = this._mixpanel.get_property('$user_id');
25577 if (userId) {
25578 userIdInfo['$user_id'] = userId;
25579 }
25580 return userIdInfo;
25581 };
25582
25583 SessionRecording.prototype.unloadPersistedData = function () {
25584 this.batcher.stop();
25585 return this.batcher.flush()
25586 .then(function () {
25587 return this.queueStorage.removeItem(this.batcherKey);
25588 }.bind(this));
25589 };
25590
25591 SessionRecording.prototype.getConfig = function(configVar) {
25592 return this._mixpanel.get_config(configVar);
25593 };
25594
25595 // Alias for getConfig, used by the common addOptOutCheckMixpanelLib function which
25596 // reaches into this class instance and expects the snake case version of the function.
25597 // eslint-disable-next-line camelcase
25598 SessionRecording.prototype.get_config = function(configVar) {
25599 return this.getConfig(configVar);
25600 };
25601
25602 SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
25603 if (this._rrwebRecord === null) {
25604 this.reportError('rrweb record function not provided. ');
25605 return;
25606 }
25607
25608 if (this._stopRecording !== null) {
25609 logger$3.log('Recording already in progress, skipping startRecording.');
25610 return;
25611 }
25612
25613 this.recordMaxMs = this.getConfig('record_max_ms');
25614 if (this.recordMaxMs > MAX_RECORDING_MS) {
25615 this.recordMaxMs = MAX_RECORDING_MS;
25616 logger$3.critical('record_max_ms cannot be greater than ' + MAX_RECORDING_MS + 'ms. Capping value.');
25617 }
25618
25619 if (!this.maxExpires) {
25620 this.maxExpires = new Date().getTime() + this.recordMaxMs;
25621 }
25622
25623 this.recordMinMs = this.getConfig('record_min_ms');
25624 if (this.recordMinMs > MAX_VALUE_FOR_MIN_RECORDING_MS) {
25625 this.recordMinMs = MAX_VALUE_FOR_MIN_RECORDING_MS;
25626 logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
25627 }
25628
25629 if (!this.replayStartTime) {
25630 this.replayStartTime = new Date().getTime();
25631 this.batchStartUrl = _.info.currentUrl();
25632 this.replayStartUrl = _.info.currentUrl();
25633 }
25634
25635 if (shouldStopBatcher || this.recordMinMs > 0) {
25636 // the primary case for shouldStopBatcher is when we're starting recording after a reset
25637 // and don't want to send anything over the network until there's
25638 // actual user activity
25639 // this also applies if the minimum recording length has not been hit yet
25640 // so that we don't send data until we know the recording will be long enough
25641 this.batcher.stop();
25642 } else {
25643 this.batcher.start();
25644 }
25645
25646 var resetIdleTimeout = function () {
25647 clearTimeout(this.idleTimeoutId);
25648 var idleTimeoutMs = this.getConfig('record_idle_timeout_ms');
25649 this.idleTimeoutId = setTimeout(this._onIdleTimeout, idleTimeoutMs);
25650 this.idleExpires = new Date().getTime() + idleTimeoutMs;
25651 }.bind(this);
25652 resetIdleTimeout();
25653
25654 var blockSelector = this.getConfig('record_block_selector');
25655 if (blockSelector === '' || blockSelector === null) {
25656 blockSelector = undefined;
25657 }
25658
25659 try {
25660 this._stopRecording = this._rrwebRecord({
25661 'emit': function (ev) {
25662 if (this.idleExpires && this.idleExpires < ev.timestamp) {
25663 this._onIdleTimeout();
25664 return;
25665 }
25666 if (isUserEvent(ev)) {
25667 if (this.batcher.stopped && new Date().getTime() - this.replayStartTime >= this.recordMinMs) {
25668 // start flushing again after user activity
25669 this.batcher.start();
25670 }
25671 resetIdleTimeout();
25672 }
25673 // promise only used to await during tests
25674 this.__enqueuePromise = this.batcher.enqueue(ev);
25675 }.bind(this),
25676 'blockClass': this.getConfig('record_block_class'),
25677 'blockSelector': blockSelector,
25678 'collectFonts': this.getConfig('record_collect_fonts'),
25679 'dataURLOptions': { // canvas image options (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL)
25680 'type': 'image/webp',
25681 'quality': 0.6
25682 },
25683 'maskAllInputs': true,
25684 'maskTextClass': this.getConfig('record_mask_text_class'),
25685 'maskTextSelector': this.getConfig('record_mask_text_selector'),
25686 'recordCanvas': this.getConfig('record_canvas'),
25687 'sampling': {
25688 'canvas': 15
25689 }
25690 });
25691 } catch (err) {
25692 this.reportError('Unexpected error when starting rrweb recording.', err);
25693 }
25694
25695 if (typeof this._stopRecording !== 'function') {
25696 this.reportError('rrweb failed to start, skipping this recording.');
25697 this._stopRecording = null;
25698 this.stopRecording(); // stop batcher looping and any timeouts
25699 return;
25700 }
25701
25702 var maxTimeoutMs = this.maxExpires - new Date().getTime();
25703 this.maxTimeoutId = setTimeout(this._onMaxLengthReached.bind(this), maxTimeoutMs);
25704 };
25705
25706 SessionRecording.prototype.stopRecording = function (skipFlush) {
25707 // store the user ID info in case this is getting called in mixpanel.reset()
25708 this.finalFlushUserIdInfo = this.getUserIdInfo();
25709
25710 if (!this.isRrwebStopped()) {
25711 try {
25712 this._stopRecording();
25713 } catch (err) {
25714 this.reportError('Error with rrweb stopRecording', err);
25715 }
25716 this._stopRecording = null;
25717 }
25718
25719 var flushPromise;
25720 if (this.batcher.stopped) {
25721 // never got user activity to flush after reset, so just clear the batcher
25722 flushPromise = this.batcher.clear();
25723 } else if (!skipFlush) {
25724 // flush any remaining events from running batcher
25725 flushPromise = this.batcher.flush();
25726 }
25727 this.batcher.stop();
25728
25729 clearTimeout(this.idleTimeoutId);
25730 clearTimeout(this.maxTimeoutId);
25731 return flushPromise;
25732 };
25733
25734 SessionRecording.prototype.isRrwebStopped = function () {
25735 return this._stopRecording === null;
25736 };
25737
25738
25739 /**
25740 * Flushes the current batch of events to the server, but passes an opt-out callback to make sure
25741 * we stop recording and dump any queued events if the user has opted out.
25742 */
25743 SessionRecording.prototype.flushEventsWithOptOut = function (data, options, cb) {
25744 var onOptOut = function (code) {
25745 // addOptOutCheckMixpanelLib invokes this function with code=0 when the user has opted out
25746 if (code === 0) {
25747 this.stopRecording();
25748 cb({error: 'Tracking has been opted out, stopping recording.'});
25749 }
25750 }.bind(this);
25751
25752 this._flushEvents(data, options, cb, onOptOut);
25753 };
25754
25755 /**
25756 * @returns {SerializedRecording}
25757 */
25758 SessionRecording.prototype.serialize = function () {
25759 // don't break if mixpanel instance was destroyed at some point
25760 var tabId;
25761 try {
25762 tabId = this._mixpanel.get_tab_id();
25763 } catch (e) {
25764 this.reportError('Error getting tab ID for serialization ', e);
25765 tabId = null;
25766 }
25767
25768 return {
25769 'replayId': this.replayId,
25770 'seqNo': this.seqNo,
25771 'replayStartTime': this.replayStartTime,
25772 'batchStartUrl': this.batchStartUrl,
25773 'replayStartUrl': this.replayStartUrl,
25774 'idleExpires': this.idleExpires,
25775 'maxExpires': this.maxExpires,
25776 'tabId': tabId,
25777 };
25778 };
25779
25780
25781 /**
25782 * @static
25783 * @param {SerializedRecording} serializedRecording
25784 * @param {SessionRecordingOptions} options
25785 * @returns {SessionRecording}
25786 */
25787 SessionRecording.deserialize = function (serializedRecording, options) {
25788 var recording = new SessionRecording(_.extend({}, options, {
25789 replayId: serializedRecording['replayId'],
25790 batchStartUrl: serializedRecording['batchStartUrl'],
25791 replayStartUrl: serializedRecording['replayStartUrl'],
25792 idleExpires: serializedRecording['idleExpires'],
25793 maxExpires: serializedRecording['maxExpires'],
25794 replayStartTime: serializedRecording['replayStartTime'],
25795 seqNo: serializedRecording['seqNo'],
25796 sharedLockStorage: options.sharedLockStorage,
25797 }));
25798
25799 return recording;
25800 };
25801
25802 SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, reqBody, callback) {
25803 var onSuccess = function (response, responseBody) {
25804 // Update batch specific props only if the request was successful to guarantee ordering.
25805 // RequestBatcher will always flush the next batch after the previous one succeeds.
25806 // extra check to see if the replay ID has changed so that we don't increment the seqNo on the wrong replay
25807 if (response.status === 200 && this.replayId === currentReplayId) {
25808 this.seqNo++;
25809 this.batchStartUrl = _.info.currentUrl();
25810 }
25811
25812 this._onBatchSent();
25813 callback({
25814 status: 0,
25815 httpStatusCode: response.status,
25816 responseBody: responseBody,
25817 retryAfter: response.headers.get('Retry-After')
25818 });
25819 }.bind(this);
25820 var apiHost = (this._mixpanel.get_api_host && this._mixpanel.get_api_host('record')) || this.getConfig('api_host');
25821 win['fetch'](apiHost + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
25822 'method': 'POST',
25823 'headers': {
25824 'Authorization': 'Basic ' + btoa(this.getConfig('token') + ':'),
25825 'Content-Type': 'application/octet-stream'
25826 },
25827 'body': reqBody,
25828 }).then(function (response) {
25829 response.json().then(function (responseBody) {
25830 onSuccess(response, responseBody);
25831 }).catch(function (error) {
25832 callback({error: error});
25833 });
25834 }).catch(function (error) {
25835 callback({error: error, httpStatusCode: 0});
25836 });
25837 };
25838
25839 SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (data, options, callback) {
25840 var numEvents = data.length;
25841
25842 if (numEvents > 0) {
25843 var replayId = this.replayId;
25844
25845 // each rrweb event has a timestamp - leverage those to get time properties
25846 var batchStartTime = Infinity;
25847 var batchEndTime = -Infinity;
25848 var hasFullSnapshot = false;
25849 for (var i = 0; i < numEvents; i++) {
25850 batchStartTime = Math.min(batchStartTime, data[i].timestamp);
25851 batchEndTime = Math.max(batchEndTime, data[i].timestamp);
25852 if (data[i].type === EventType.FullSnapshot) {
25853 hasFullSnapshot = true;
25854 }
25855 }
25856
25857 if (this.seqNo === 0) {
25858 if (!hasFullSnapshot) {
25859 callback({error: 'First batch does not contain a full snapshot. Aborting recording.'});
25860 this.stopRecording(true);
25861 return;
25862 }
25863 this.replayStartTime = batchStartTime;
25864 } else if (!this.replayStartTime) {
25865 this.reportError('Replay start time not set but seqNo is not 0. Using current batch start time as a fallback.');
25866 this.replayStartTime = batchStartTime;
25867 }
25868
25869 var replayLengthMs = batchEndTime - this.replayStartTime;
25870
25871 var reqParams = {
25872 '$current_url': this.batchStartUrl,
25873 '$lib_version': Config.LIB_VERSION,
25874 'batch_start_time': batchStartTime / 1000,
25875 'mp_lib': 'web',
25876 'replay_id': replayId,
25877 'replay_length_ms': replayLengthMs,
25878 'replay_start_time': this.replayStartTime / 1000,
25879 'replay_start_url': this.replayStartUrl,
25880 'seq': this.seqNo
25881 };
25882 var eventsJson = JSON.stringify(data);
25883 Object.assign(reqParams, this.getUserIdInfo());
25884
25885 if (CompressionStream) {
25886 var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
25887 var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
25888 new Response(gzipStream)
25889 .blob()
25890 .then(function(compressedBlob) {
25891 reqParams['format'] = 'gzip';
25892 this._sendRequest(replayId, reqParams, compressedBlob, callback);
25893 }.bind(this));
25894 } else {
25895 reqParams['format'] = 'body';
25896 this._sendRequest(replayId, reqParams, eventsJson, callback);
25897 }
25898 }
25899 });
25900
25901
25902 SessionRecording.prototype.reportError = function(msg, err) {
25903 logger$3.error.apply(logger$3.error, arguments);
25904 try {
25905 if (!err && !(msg instanceof Error)) {
25906 msg = new Error(msg);
25907 }
25908 this.getConfig('error_reporter')(msg, err);
25909 } catch(err) {
25910 logger$3.error(err);
25911 }
25912 };
25913
25914 /**
25915 * Module for handling the storage and retrieval of recording metadata as well as any active recordings.
25916 * Makes sure that only one tab can be recording at a time.
25917 */
25918 var RecordingRegistry = function (options) {
25919 /** @type {IDBStorageWrapper} */
25920 this.idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
25921 this.errorReporter = options.errorReporter;
25922 this.mixpanelInstance = options.mixpanelInstance;
25923 this.sharedLockStorage = options.sharedLockStorage;
25924 };
25925
25926 RecordingRegistry.prototype.isPersistenceEnabled = function() {
25927 return !this.mixpanelInstance.get_config('disable_persistence');
25928 };
25929
25930 RecordingRegistry.prototype.handleError = function (err) {
25931 this.errorReporter('IndexedDB error: ', err);
25932 };
25933
25934 /**
25935 * @param {import('./session-recording').SerializedRecording} serializedRecording
25936 */
25937 RecordingRegistry.prototype.setActiveRecording = function (serializedRecording) {
25938 if (!this.isPersistenceEnabled()) {
25939 return PromisePolyfill.resolve();
25940 }
25941
25942 var tabId = serializedRecording['tabId'];
25943 if (!tabId) {
25944 console.warn('No tab ID is set, cannot persist recording metadata.');
25945 return PromisePolyfill.resolve();
25946 }
25947
25948 return this.idb.init()
25949 .then(function () {
25950 return this.idb.setItem(tabId, serializedRecording);
25951 }.bind(this))
25952 .catch(this.handleError.bind(this));
25953 };
25954
25955 /**
25956 * @returns {Promise<import('./session-recording').SerializedRecording>}
25957 */
25958 RecordingRegistry.prototype.getActiveRecording = function () {
25959 if (!this.isPersistenceEnabled()) {
25960 return PromisePolyfill.resolve(null);
25961 }
25962
25963 return this.idb.init()
25964 .then(function () {
25965 return this.idb.getItem(this.mixpanelInstance.get_tab_id());
25966 }.bind(this))
25967 .then(function (serializedRecording) {
25968 return isRecordingExpired(serializedRecording) ? null : serializedRecording;
25969 }.bind(this))
25970 .catch(this.handleError.bind(this));
25971 };
25972
25973 RecordingRegistry.prototype.clearActiveRecording = function () {
25974 if (this.isPersistenceEnabled()) {
25975 // mark recording as expired instead of deleting it in case the page unloads mid-flush and doesn't make it to ingestion.
25976 // this will ensure the next pageload will flush the remaining events, but not try to continue the recording.
25977 return this.markActiveRecordingExpired();
25978 } else {
25979 return this.deleteActiveRecording();
25980 }
25981 };
25982
25983 RecordingRegistry.prototype.markActiveRecordingExpired = function () {
25984 return this.getActiveRecording()
25985 .then(function (serializedRecording) {
25986 if (serializedRecording) {
25987 serializedRecording['maxExpires'] = 0;
25988 return this.setActiveRecording(serializedRecording);
25989 }
25990 }.bind(this))
25991 .catch(this.handleError.bind(this));
25992 };
25993
25994 RecordingRegistry.prototype.deleteActiveRecording = function () {
25995 // avoid initializing IDB if this registry instance hasn't already written a recording
25996 if (this.idb.isInitialized()) {
25997 return this.idb.removeItem(this.mixpanelInstance.get_tab_id())
25998 .catch(this.handleError.bind(this));
25999 } else {
26000 return PromisePolyfill.resolve();
26001 }
26002 };
26003
26004 /**
26005 * Flush any inactive recordings from the registry to minimize data loss.
26006 * The main idea here is that we can flush remaining rrweb events on the next page load if a tab is closed mid-batch.
26007 */
26008 RecordingRegistry.prototype.flushInactiveRecordings = function () {
26009 if (!this.isPersistenceEnabled()) {
26010 return PromisePolyfill.resolve([]);
26011 }
26012
26013 return this.idb.init()
26014 .then(function() {
26015 return this.idb.getAll();
26016 }.bind(this))
26017 .then(function (serializedRecordings) {
26018 // clean up any expired recordings from the registry, non-expired ones may be active in other tabs
26019 var unloadPromises = serializedRecordings
26020 .filter(function (serializedRecording) {
26021 return isRecordingExpired(serializedRecording);
26022 })
26023 .map(function (serializedRecording) {
26024 var sessionRecording = SessionRecording.deserialize(serializedRecording, {
26025 mixpanelInstance: this.mixpanelInstance,
26026 sharedLockStorage: this.sharedLockStorage
26027 });
26028 return sessionRecording.unloadPersistedData()
26029 .then(function () {
26030 // expired recording was successfully flushed, we can clean it up from the registry
26031 return this.idb.removeItem(serializedRecording['tabId']);
26032 }.bind(this))
26033 .catch(this.handleError.bind(this));
26034 }.bind(this));
26035
26036 return PromisePolyfill.all(unloadPromises);
26037 }.bind(this))
26038 .catch(this.handleError.bind(this));
26039 };
26040
26041 var logger$2 = console_with_prefix('recorder');
26042
26043 /**
26044 * Recorder API: bundles rrweb and and exposes methods to start and stop recordings.
26045 * @param {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
26046 */
26047 var MixpanelRecorder = function(mixpanelInstance, rrwebRecord, sharedLockStorage) {
26048 this.mixpanelInstance = mixpanelInstance;
26049 this.rrwebRecord = rrwebRecord || record;
26050 this.sharedLockStorage = sharedLockStorage;
26051
26052 /**
26053 * @member {import('./registry').RecordingRegistry}
26054 */
26055 this.recordingRegistry = new RecordingRegistry({
26056 mixpanelInstance: this.mixpanelInstance,
26057 errorReporter: logger$2.error,
26058 sharedLockStorage: sharedLockStorage
26059 });
26060 this._flushInactivePromise = this.recordingRegistry.flushInactiveRecordings();
26061
26062 this.activeRecording = null;
26063 this.stopRecordingInProgress = false;
26064 };
26065
26066 MixpanelRecorder.prototype.startRecording = function(options) {
26067 options = options || {};
26068 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26069 logger$2.log('Recording already in progress, skipping startRecording.');
26070 return;
26071 }
26072
26073 var onIdleTimeout = function () {
26074 logger$2.log('Idle timeout reached, restarting recording.');
26075 this.resetRecording();
26076 }.bind(this);
26077
26078 var onMaxLengthReached = function () {
26079 logger$2.log('Max recording length reached, stopping recording.');
26080 this.resetRecording();
26081 }.bind(this);
26082
26083 var onBatchSent = function () {
26084 this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26085 this['__flushPromise'] = this.activeRecording.batcher._flushPromise;
26086 }.bind(this);
26087
26088 /**
26089 * @type {import('./session-recording').SessionRecordingOptions}
26090 */
26091 var sessionRecordingOptions = {
26092 mixpanelInstance: this.mixpanelInstance,
26093 onBatchSent: onBatchSent,
26094 onIdleTimeout: onIdleTimeout,
26095 onMaxLengthReached: onMaxLengthReached,
26096 replayId: _.UUID(),
26097 rrwebRecord: this.rrwebRecord,
26098 sharedLockStorage: this.sharedLockStorage
26099 };
26100
26101 if (options.activeSerializedRecording) {
26102 this.activeRecording = SessionRecording.deserialize(options.activeSerializedRecording, sessionRecordingOptions);
26103 } else {
26104 this.activeRecording = new SessionRecording(sessionRecordingOptions);
26105 }
26106
26107 this.activeRecording.startRecording(options.shouldStopBatcher);
26108 return this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26109 };
26110
26111 MixpanelRecorder.prototype.stopRecording = function() {
26112 // Prevents activeSerializedRecording from being reused when stopping the recording.
26113 this.stopRecordingInProgress = true;
26114 return this._stopCurrentRecording(false, true).then(function() {
26115 return this.recordingRegistry.clearActiveRecording();
26116 }.bind(this)).then(function() {
26117 this.stopRecordingInProgress = false;
26118 }.bind(this));
26119 };
26120
26121 MixpanelRecorder.prototype.pauseRecording = function() {
26122 return this._stopCurrentRecording(false);
26123 };
26124
26125 MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush, disableActiveRecording) {
26126 if (this.activeRecording) {
26127 var stopRecordingPromise = this.activeRecording.stopRecording(skipFlush);
26128 if (disableActiveRecording) {
26129 this.activeRecording = null;
26130 }
26131 return stopRecordingPromise;
26132 }
26133 return PromisePolyfill.resolve();
26134 };
26135
26136 MixpanelRecorder.prototype.resumeRecording = function (startNewIfInactive) {
26137 if (this.activeRecording && this.activeRecording.isRrwebStopped()) {
26138 this.activeRecording.startRecording(false);
26139 return PromisePolyfill.resolve(null);
26140 }
26141
26142 return this.recordingRegistry.getActiveRecording()
26143 .then(function (activeSerializedRecording) {
26144 if (activeSerializedRecording && !this.stopRecordingInProgress) {
26145 return this.startRecording({activeSerializedRecording: activeSerializedRecording});
26146 } else if (startNewIfInactive) {
26147 return this.startRecording({shouldStopBatcher: false});
26148 } else {
26149 logger$2.log('No resumable recording found.');
26150 return null;
26151 }
26152 }.bind(this));
26153 };
26154
26155
26156 MixpanelRecorder.prototype.resetRecording = function () {
26157 this.stopRecording();
26158 this.startRecording({shouldStopBatcher: true});
26159 };
26160
26161 MixpanelRecorder.prototype.getActiveReplayId = function () {
26162 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26163 return this.activeRecording.replayId;
26164 } else {
26165 return null;
26166 }
26167 };
26168
26169 // getter so that older mixpanel-core versions can still retrieve the replay ID
26170 // when pulling the latest recorder bundle from the CDN
26171 Object.defineProperty(MixpanelRecorder.prototype, 'replayId', {
26172 get: function () {
26173 return this.getActiveReplayId();
26174 }
26175 });
26176
26177 win['__mp_recorder'] = MixpanelRecorder;
26178
26179 // stateless utils
26180 // mostly from https://github.com/mixpanel/mixpanel-js/blob/989ada50f518edab47b9c4fd9535f9fbd5ec5fc0/src/autotrack-utils.js
26181
26182
26183 var EV_CHANGE = 'change';
26184 var EV_CLICK = 'click';
26185 var EV_HASHCHANGE = 'hashchange';
26186 var EV_INPUT = 'input';
26187 var EV_LOAD = 'load';
26188 var EV_MP_LOCATION_CHANGE = 'mp_locationchange';
26189 var EV_POPSTATE = 'popstate';
26190 // TODO scrollend isn't available in Safari: document or polyfill?
26191 var EV_SCROLLEND = 'scrollend';
26192 var EV_SCROLL = 'scroll';
26193 var EV_SELECT = 'select';
26194 var EV_SUBMIT = 'submit';
26195 var EV_TOGGLE = 'toggle';
26196 var EV_VISIBILITYCHANGE = 'visibilitychange';
26197
26198 var CLICK_EVENT_PROPS = [
26199 'clientX', 'clientY',
26200 'offsetX', 'offsetY',
26201 'pageX', 'pageY',
26202 'screenX', 'screenY',
26203 'x', 'y'
26204 ];
26205 var OPT_IN_CLASSES = ['mp-include'];
26206 var OPT_OUT_CLASSES = ['mp-no-track'];
26207 var SENSITIVE_DATA_CLASSES = OPT_OUT_CLASSES.concat(['mp-sensitive']);
26208 var TRACKED_ATTRS = [
26209 'aria-label', 'aria-labelledby', 'aria-describedby',
26210 'href', 'name', 'role', 'title', 'type'
26211 ];
26212
26213 var INTERACTIVE_ARIA_ROLES = {
26214 'button': true,
26215 'checkbox': true,
26216 'combobox': true,
26217 'grid': true,
26218 'link': true,
26219 'listbox': true,
26220 'menu': true,
26221 'menubar': true,
26222 'menuitem': true,
26223 'menuitemcheckbox': true,
26224 'menuitemradio': true,
26225 'navigation': true,
26226 'option': true,
26227 'radio': true,
26228 'radiogroup': true,
26229 'searchbox': true,
26230 'slider': true,
26231 'spinbutton': true,
26232 'switch': true,
26233 'tab': true,
26234 'tablist': true,
26235 'textbox': true,
26236 'tree': true,
26237 'treegrid': true,
26238 'treeitem': true
26239 };
26240
26241 var ALWAYS_NON_INTERACTIVE_TAGS = {
26242 // Document metadata
26243 'base': true,
26244 'head': true,
26245 'html': true,
26246 'link': true,
26247 'meta': true,
26248 'script': true,
26249 'style': true,
26250 'title': true,
26251 // Text formatting
26252 'br': true,
26253 'hr': true,
26254 'wbr': true,
26255 // Other
26256 'noscript': true,
26257 'picture': true,
26258 'source': true,
26259 'template': true,
26260 'track': true
26261 };
26262
26263 // Common container tags that need additional checks
26264 var TEXT_CONTAINER_TAGS = {
26265 'article': true,
26266 'div': true,
26267 'h1': true,
26268 'h2': true,
26269 'h3': true,
26270 'h4': true,
26271 'h5': true,
26272 'h6': true,
26273 'p': true,
26274 'section': true,
26275 'span': true
26276 };
26277
26278 var EVENT_HANDLER_ATTRIBUTES = [
26279 'onclick', 'onmousedown', 'onmouseup', 'onpointerdown', 'onpointerup', 'ontouchend', 'ontouchstart'
26280 ];
26281
26282 var MAX_DEPTH = 5;
26283
26284 var logger$1 = console_with_prefix('autocapture');
26285
26286
26287 function getClasses(el) {
26288 var classes = {};
26289 var classList = getClassName(el).split(' ');
26290 for (var i = 0; i < classList.length; i++) {
26291 var cls = classList[i];
26292 if (cls) {
26293 classes[cls] = true;
26294 }
26295 }
26296 return classes;
26297 }
26298
26299 /*
26300 * Get the className of an element, accounting for edge cases where element.className is an object
26301 * @param {Element} el - element to get the className of
26302 * @returns {string} the element's class
26303 */
26304 function getClassName(el) {
26305 switch(typeof el.className) {
26306 case 'string':
26307 return el.className;
26308 case 'object': // handle cases where className might be SVGAnimatedString or some other type
26309 return el.className.baseVal || el.getAttribute('class') || '';
26310 default: // future proof
26311 return '';
26312 }
26313 }
26314
26315 function getPreviousElementSibling(el) {
26316 if (el.previousElementSibling) {
26317 return el.previousElementSibling;
26318 } else {
26319 do {
26320 el = el.previousSibling;
26321 } while (el && !isElementNode(el));
26322 return el;
26323 }
26324 }
26325
26326 function getPropertiesFromElement(el, ev, blockAttrsSet, extraAttrs, allowElementCallback, allowSelectors) {
26327 var props = {
26328 '$classes': getClassName(el).split(' '),
26329 '$tag_name': el.tagName.toLowerCase()
26330 };
26331 var elId = el.id;
26332 if (elId) {
26333 props['$id'] = elId;
26334 }
26335
26336 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors)) {
26337 _.each(TRACKED_ATTRS.concat(extraAttrs), function(attr) {
26338 if (el.hasAttribute(attr) && !blockAttrsSet[attr]) {
26339 var attrVal = el.getAttribute(attr);
26340 if (shouldTrackValue(attrVal)) {
26341 props['$attr-' + attr] = attrVal;
26342 }
26343 }
26344 });
26345 }
26346
26347 var nthChild = 1;
26348 var nthOfType = 1;
26349 var currentElem = el;
26350 while (currentElem = getPreviousElementSibling(currentElem)) { // eslint-disable-line no-cond-assign
26351 nthChild++;
26352 if (currentElem.tagName === el.tagName) {
26353 nthOfType++;
26354 }
26355 }
26356 props['$nth_child'] = nthChild;
26357 props['$nth_of_type'] = nthOfType;
26358
26359 return props;
26360 }
26361
26362 function getPropsForDOMEvent(ev, config) {
26363 var allowElementCallback = config.allowElementCallback;
26364 var allowSelectors = config.allowSelectors || [];
26365 var blockAttrs = config.blockAttrs || [];
26366 var blockElementCallback = config.blockElementCallback;
26367 var blockSelectors = config.blockSelectors || [];
26368 var captureTextContent = config.captureTextContent || false;
26369 var captureExtraAttrs = config.captureExtraAttrs || [];
26370 var capturedForHeatMap = config.capturedForHeatMap || false;
26371
26372 // convert array to set every time, as the config may have changed
26373 var blockAttrsSet = {};
26374 _.each(blockAttrs, function(attr) {
26375 blockAttrsSet[attr] = true;
26376 });
26377
26378 var props = null;
26379
26380 var target = typeof ev.target === 'undefined' ? ev.srcElement : ev.target;
26381 if (isTextNode(target)) { // defeat Safari bug (see: http://www.quirksmode.org/js/events_properties.html)
26382 target = target.parentNode;
26383 }
26384
26385 if (
26386 shouldTrackDomEvent(target, ev) &&
26387 isElementAllowed(target, ev, allowElementCallback, allowSelectors) &&
26388 !isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26389 ) {
26390 var targetElementList = [target];
26391 var curEl = target;
26392 while (curEl.parentNode && !isTag(curEl, 'body')) {
26393 targetElementList.push(curEl.parentNode);
26394 curEl = curEl.parentNode;
26395 }
26396
26397 var elementsJson = [];
26398 var href, explicitNoTrack = false;
26399 _.each(targetElementList, function(el) {
26400 var shouldTrackDetails = shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors);
26401
26402 // if the element or a parent element is an anchor tag
26403 // include the href as a property
26404 if (!blockAttrsSet['href'] && el.tagName.toLowerCase() === 'a') {
26405 href = el.getAttribute('href');
26406 href = shouldTrackDetails && shouldTrackValue(href) && href;
26407 }
26408
26409 if (isElementBlocked(el, ev, blockElementCallback, blockSelectors)) {
26410 explicitNoTrack = true;
26411 }
26412
26413 elementsJson.push(getPropertiesFromElement(el, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors));
26414 }, this);
26415
26416 if (!explicitNoTrack) {
26417 var docElement = document$1['documentElement'];
26418 props = {
26419 '$event_type': ev.type,
26420 '$host': win.location.host,
26421 '$pathname': win.location.pathname,
26422 '$elements': elementsJson,
26423 '$el_attr__href': href,
26424 '$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
26425 '$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0),
26426 '$pageHeight': document$1['body']['offsetHeight'] || 0,
26427 '$pageWidth': document$1['body']['offsetWidth'] || 0,
26428 };
26429 _.each(captureExtraAttrs, function(attr) {
26430 if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
26431 var attrVal = target.getAttribute(attr);
26432 if (shouldTrackValue(attrVal)) {
26433 props['$el_attr__' + attr] = attrVal;
26434 }
26435 }
26436 });
26437
26438 if (captureTextContent) {
26439 elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26440 if (elementText && elementText.length) {
26441 props['$el_text'] = elementText;
26442 }
26443 }
26444
26445 if (ev.type === EV_CLICK) {
26446 _.each(CLICK_EVENT_PROPS, function(prop) {
26447 if (prop in ev) {
26448 props['$' + prop] = ev[prop];
26449 }
26450 });
26451 if (capturedForHeatMap) {
26452 props['$captured_for_heatmap'] = true;
26453 }
26454 target = guessRealClickTarget(ev);
26455 }
26456 // prioritize text content from "real" click target if different from original target
26457 if (captureTextContent) {
26458 var elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26459 if (elementText && elementText.length) {
26460 props['$el_text'] = elementText;
26461 }
26462 }
26463
26464 if (target) {
26465 // target may have been recalculated; check allowlists and blocklists again
26466 if (
26467 !isElementAllowed(target, ev, allowElementCallback, allowSelectors) ||
26468 isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26469 ) {
26470 return null;
26471 }
26472
26473 var targetProps = getPropertiesFromElement(target, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors);
26474 props['$target'] = targetProps;
26475 // pull up more props onto main event props
26476 props['$el_classes'] = targetProps['$classes'];
26477 _.extend(props, _.strip_empty_properties({
26478 '$el_id': targetProps['$id'],
26479 '$el_tag_name': targetProps['$tag_name']
26480 }));
26481 }
26482 }
26483 }
26484
26485 return props;
26486 }
26487
26488
26489 /**
26490 * Get the direct text content of an element, protecting against sensitive data collection.
26491 * Concats textContent of each of the element's text node children; this avoids potential
26492 * collection of sensitive data that could happen if we used element.textContent and the
26493 * element had sensitive child elements, since element.textContent includes child content.
26494 * Scrubs values that look like they could be sensitive (i.e. cc or ssn number).
26495 * @param {Element} el - element to get the text of
26496 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
26497 * @returns {string} the element's direct text content
26498 */
26499 function getSafeText(el, ev, allowElementCallback, allowSelectors) {
26500 var elText = '';
26501
26502 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) && el.childNodes && el.childNodes.length) {
26503 _.each(el.childNodes, function(child) {
26504 if (isTextNode(child) && child.textContent) {
26505 elText += _.trim(child.textContent)
26506 // scrub potentially sensitive values
26507 .split(/(\s+)/).filter(shouldTrackValue).join('')
26508 // normalize whitespace
26509 .replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ')
26510 // truncate
26511 .substring(0, 255);
26512 }
26513 });
26514 }
26515
26516 return _.trim(elText);
26517 }
26518
26519 function guessRealClickTarget(ev) {
26520 var target = ev.target;
26521 var composedPath = ev['composedPath']();
26522 for (var i = 0; i < composedPath.length; i++) {
26523 var node = composedPath[i];
26524 if (
26525 isTag(node, 'a') ||
26526 isTag(node, 'button') ||
26527 isTag(node, 'input') ||
26528 isTag(node, 'select') ||
26529 (node.getAttribute && node.getAttribute('role') === 'button')
26530 ) {
26531 target = node;
26532 break;
26533 }
26534 if (node === target) {
26535 break;
26536 }
26537 }
26538 return target;
26539 }
26540
26541 function isElementAllowed(el, ev, allowElementCallback, allowSelectors) {
26542 if (allowElementCallback) {
26543 try {
26544 if (!allowElementCallback(el, ev)) {
26545 return false;
26546 }
26547 } catch (err) {
26548 logger$1.critical('Error while checking element in allowElementCallback', err);
26549 return false;
26550 }
26551 }
26552
26553 if (!allowSelectors.length) {
26554 // no allowlist; all elements are fair game
26555 return true;
26556 }
26557
26558 for (var i = 0; i < allowSelectors.length; i++) {
26559 var sel = allowSelectors[i];
26560 try {
26561 if (el['matches'](sel)) {
26562 return true;
26563 }
26564 } catch (err) {
26565 logger$1.critical('Error while checking selector: ' + sel, err);
26566 }
26567 }
26568 return false;
26569 }
26570
26571 function isElementBlocked(el, ev, blockElementCallback, blockSelectors) {
26572 var i;
26573
26574 if (blockElementCallback) {
26575 try {
26576 if (blockElementCallback(el, ev)) {
26577 return true;
26578 }
26579 } catch (err) {
26580 logger$1.critical('Error while checking element in blockElementCallback', err);
26581 return true;
26582 }
26583 }
26584
26585 if (blockSelectors && blockSelectors.length) {
26586 // programmatically prevent tracking of elements that match CSS selectors
26587 for (i = 0; i < blockSelectors.length; i++) {
26588 var sel = blockSelectors[i];
26589 try {
26590 if (el['matches'](sel)) {
26591 return true;
26592 }
26593 } catch (err) {
26594 logger$1.critical('Error while checking selector: ' + sel, err);
26595 }
26596 }
26597 }
26598
26599 // allow users to programmatically prevent tracking of elements by adding default classes such as 'mp-no-track'
26600 var classes = getClasses(el);
26601 for (i = 0; i < OPT_OUT_CLASSES.length; i++) {
26602 if (classes[OPT_OUT_CLASSES[i]]) {
26603 return true;
26604 }
26605 }
26606
26607 return false;
26608 }
26609
26610 /*
26611 * Check whether a DOM node has nodeType Node.ELEMENT_NODE
26612 * @param {Node} node - node to check
26613 * @returns {boolean} whether node is of the correct nodeType
26614 */
26615 function isElementNode(node) {
26616 return node && node.nodeType === 1; // Node.ELEMENT_NODE - use integer constant for browser portability
26617 }
26618
26619 /*
26620 * Check whether an element is of a given tag type.
26621 * Due to potential reference discrepancies (such as the webcomponents.js polyfill),
26622 * we want to match tagNames instead of specific references because something like
26623 * element === document.body won't always work because element might not be a native
26624 * element.
26625 * @param {Element} el - element to check
26626 * @param {string} tag - tag name (e.g., "div")
26627 * @returns {boolean} whether el is of the given tag type
26628 */
26629 function isTag(el, tag) {
26630 return el && el.tagName && el.tagName.toLowerCase() === tag.toLowerCase();
26631 }
26632
26633 /*
26634 * Check whether a DOM node is a TEXT_NODE
26635 * @param {Node} node - node to check
26636 * @returns {boolean} whether node is of type Node.TEXT_NODE
26637 */
26638 function isTextNode(node) {
26639 return node && node.nodeType === 3; // Node.TEXT_NODE - use integer constant for browser portability
26640 }
26641
26642 function minDOMApisSupported() {
26643 try {
26644 var testEl = document$1.createElement('div');
26645 return !!testEl['matches'];
26646 } catch (err) {
26647 return false;
26648 }
26649 }
26650
26651 function weakSetSupported() {
26652 return typeof WeakSet !== 'undefined';
26653 }
26654
26655 /*
26656 * Check whether a DOM event should be "tracked" or if it may contain sensitive data
26657 * using a variety of heuristics.
26658 * @param {Element} el - element to check
26659 * @param {Event} ev - event to check
26660 * @returns {boolean} whether the event should be tracked
26661 */
26662 function shouldTrackDomEvent(el, ev) {
26663 if (!el || isTag(el, 'html') || !isElementNode(el)) {
26664 return false;
26665 }
26666 var tag = el.tagName.toLowerCase();
26667 switch (tag) {
26668 case 'form':
26669 return ev.type === EV_SUBMIT;
26670 case 'input':
26671 if (['button', 'submit'].indexOf(el.getAttribute('type')) === -1) {
26672 return ev.type === EV_CHANGE;
26673 } else {
26674 return ev.type === EV_CLICK;
26675 }
26676 case 'select':
26677 case 'textarea':
26678 return ev.type === EV_CHANGE;
26679 default:
26680 return ev.type === EV_CLICK;
26681 }
26682 }
26683
26684 /*
26685 * Check whether a DOM element should be "tracked" or if it may contain sensitive data
26686 * using a variety of heuristics.
26687 * @param {Element} el - element to check
26688 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
26689 * @returns {boolean} whether the element should be tracked
26690 */
26691 function shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) {
26692 var i;
26693
26694 if (!isElementAllowed(el, ev, allowElementCallback, allowSelectors)) {
26695 return false;
26696 }
26697
26698 for (var curEl = el; curEl.parentNode && !isTag(curEl, 'body'); curEl = curEl.parentNode) {
26699 var classes = getClasses(curEl);
26700 for (i = 0; i < SENSITIVE_DATA_CLASSES.length; i++) {
26701 if (classes[SENSITIVE_DATA_CLASSES[i]]) {
26702 return false;
26703 }
26704 }
26705 }
26706
26707 var elClasses = getClasses(el);
26708 for (i = 0; i < OPT_IN_CLASSES.length; i++) {
26709 if (elClasses[OPT_IN_CLASSES[i]]) {
26710 return true;
26711 }
26712 }
26713
26714 // don't send data from inputs or similar elements since there will always be
26715 // a risk of clientside javascript placing sensitive data in attributes
26716 if (
26717 isTag(el, 'input') ||
26718 isTag(el, 'select') ||
26719 isTag(el, 'textarea') ||
26720 el.getAttribute('contenteditable') === 'true'
26721 ) {
26722 return false;
26723 }
26724
26725 // don't include hidden or password fields
26726 var type = el.type || '';
26727 if (typeof type === 'string') { // it's possible for el.type to be a DOM element if el is a form with a child input[name="type"]
26728 switch(type.toLowerCase()) {
26729 case 'hidden':
26730 return false;
26731 case 'password':
26732 return false;
26733 }
26734 }
26735
26736 // filter out data from fields that look like sensitive fields
26737 var name = el.name || el.id || '';
26738 if (typeof name === 'string') { // it's possible for el.name or el.id to be a DOM element if el is a form with a child input[name="name"]
26739 var sensitiveNameRegex = /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i;
26740 if (sensitiveNameRegex.test(name.replace(/[^a-zA-Z0-9]/g, ''))) {
26741 return false;
26742 }
26743 }
26744
26745 return true;
26746 }
26747
26748
26749 /*
26750 * Check whether a string value should be "tracked" or if it may contain sensitive data
26751 * using a variety of heuristics.
26752 * @param {string} value - string value to check
26753 * @returns {boolean} whether the element should be tracked
26754 */
26755 function shouldTrackValue(value) {
26756 if (value === null || _.isUndefined(value)) {
26757 return false;
26758 }
26759
26760 if (typeof value === 'string') {
26761 value = _.trim(value);
26762
26763 // check to see if input value looks like a credit card number
26764 // see: https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch04s20.html
26765 var ccRegex = /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/;
26766 if (ccRegex.test((value || '').replace(/[- ]/g, ''))) {
26767 return false;
26768 }
26769
26770 // check to see if input value looks like a social security number
26771 var ssnRegex = /(^\d{3}-?\d{2}-?\d{4}$)/;
26772 if (ssnRegex.test(value)) {
26773 return false;
26774 }
26775 }
26776
26777 return true;
26778 }
26779
26780 /**
26781 * Creates a cross-browser compatible scroll end function with appropriate event listener.
26782 * For browsers that support scrollend, returns the original function with scrollend event.
26783 * For browsers without scrollend support, returns a debounced function that triggers
26784 * 100ms after the last scroll event to simulate scrollend behavior.
26785 * @param {Function} originalFunction - The function to call when scrolling ends
26786 * @returns {Object} Object containing listener function and eventType string
26787 * @returns {Function} returns.listener - The wrapped function to use as event listener
26788 * @returns {string} returns.eventType - The event type to listen for ('scrollend' or 'scroll')
26789 */
26790 function getPolyfillScrollEndFunction(originalFunction) {
26791 var supportsScrollEnd = 'onscrollend' in win;
26792 var polyfillFunction = safewrap(originalFunction);
26793 var polyfillEvent = EV_SCROLLEND;
26794 if (!supportsScrollEnd) {
26795 // Polyfill for browsers without scrollend support: wait 100ms after the last scroll event
26796 // https://developer.chrome.com/blog/scrollend-a-new-javascript-event
26797 var scrollTimer = null;
26798 var scrollDelayMs = 100;
26799
26800 polyfillFunction = safewrap(function() {
26801 clearTimeout(scrollTimer);
26802 scrollTimer = setTimeout(originalFunction, scrollDelayMs);
26803 });
26804
26805 polyfillEvent = EV_SCROLL;
26806 }
26807
26808 return {
26809 listener: polyfillFunction,
26810 eventType: polyfillEvent
26811 };
26812 }
26813
26814 function hasInlineEventHandlers(element) {
26815 for (var i = 0; i < EVENT_HANDLER_ATTRIBUTES.length; i++) {
26816 if (element.hasAttribute(EVENT_HANDLER_ATTRIBUTES[i])) {
26817 return true;
26818 }
26819 }
26820 return false;
26821 }
26822
26823 function hasInteractiveAriaRole(element) {
26824 var role = element.getAttribute('role');
26825 if (!role) return false;
26826
26827 // Handle invalid markup where multiple roles might be specified
26828 // Only the first token is recognized per ARIA spec
26829 var primaryRole = role.trim().split(/\s+/)[0].toLowerCase();
26830
26831 return INTERACTIVE_ARIA_ROLES[primaryRole];
26832 }
26833
26834 function hasAnyInteractivityIndicators(element) {
26835 var tagName = element.tagName.toLowerCase();
26836
26837 // Check for interactive HTML elements
26838 if (tagName === 'button' ||
26839 tagName === 'input' ||
26840 tagName === 'select' ||
26841 tagName === 'textarea' ||
26842 tagName === 'details' ||
26843 tagName === 'dialog') {
26844 return true;
26845 }
26846
26847 if (element.isContentEditable) {
26848 return true;
26849 }
26850
26851 if (element.onclick || element.onmousedown || element.onmouseup || element.ontouchstart || element.ontouchend) {
26852 return true;
26853 }
26854
26855 if (hasInlineEventHandlers(element)) {
26856 return true;
26857 }
26858
26859 if (hasInteractiveAriaRole(element)) {
26860 return true;
26861 }
26862
26863 if (tagName === 'a' && element.hasAttribute('href')) {
26864 return true;
26865 }
26866
26867 if (element.hasAttribute('tabindex')) {
26868 return true;
26869 }
26870
26871 return false;
26872 }
26873
26874
26875 function isDefinitelyNonInteractive(element) {
26876 if (!element || !element.tagName) {
26877 return true;
26878 }
26879
26880 var tagName = element.tagName.toLowerCase();
26881
26882 // These tags are definitely non-interactive
26883 if (ALWAYS_NON_INTERACTIVE_TAGS[tagName]) {
26884 return true;
26885 }
26886
26887 // For all other elements, we can only be certain they're non-interactive if they lack ALL indicators of interactivity
26888 // Check for any signs of interactivity
26889 if (hasAnyInteractivityIndicators(element)) {
26890 return false;
26891 }
26892
26893 // Check parent chain for interactive context
26894 var parent = element.parentElement;
26895 var depth = 0;
26896
26897 while (parent && depth < MAX_DEPTH) {
26898 if (hasAnyInteractivityIndicators(parent)) {
26899 return false; // Element is inside an interactive parent
26900 }
26901
26902 if (parent.getRootNode && parent.getRootNode() !== document$1) {
26903 var root = parent.getRootNode();
26904 if (root.host && hasAnyInteractivityIndicators(root.host)) {
26905 return false; // Inside an interactive shadow host
26906 }
26907 }
26908
26909 parent = parent.parentElement;
26910 depth++;
26911 }
26912
26913 // Pure text containers without any interactive context
26914 if (TEXT_CONTAINER_TAGS[tagName]) {
26915 // These are non-interactive ONLY if they have no interactive indicators (already checked as part of hasAnyInteractivityIndicators)
26916 return true;
26917 }
26918
26919 // Default: we can't be certain it's non-interactive
26920 return false;
26921 }
26922
26923 /** @const */ var DEFAULT_RAGE_CLICK_THRESHOLD_PX = 30;
26924 /** @const */ var DEFAULT_RAGE_CLICK_TIMEOUT_MS = 1000;
26925 /** @const */ var DEFAULT_RAGE_CLICK_CLICK_COUNT = 4;
26926
26927 function RageClickTracker() {
26928 this.clicks = [];
26929 }
26930
26931 RageClickTracker.prototype.isRageClick = function(x, y, options) {
26932 options = options || {};
26933 var thresholdPx = options['threshold_px'] || DEFAULT_RAGE_CLICK_THRESHOLD_PX;
26934 var timeoutMs = options['timeout_ms'] || DEFAULT_RAGE_CLICK_TIMEOUT_MS;
26935 var clickCount = options['click_count'] || DEFAULT_RAGE_CLICK_CLICK_COUNT;
26936 var timestamp = Date.now();
26937
26938 var lastClick = this.clicks[this.clicks.length - 1];
26939 if (
26940 lastClick &&
26941 timestamp - lastClick.timestamp < timeoutMs &&
26942 Math.sqrt(Math.pow(x - lastClick.x, 2) + Math.pow(y - lastClick.y, 2)) < thresholdPx
26943 ) {
26944 this.clicks.push({ x: x, y: y, timestamp: timestamp });
26945 if (this.clicks.length >= clickCount) {
26946 this.clicks = [];
26947 return true;
26948 }
26949 } else {
26950 this.clicks = [{ x: x, y: y, timestamp: timestamp }];
26951 }
26952 return false;
26953 };
26954
26955 function ShadowDOMObserver(changeCallback, observerConfig) {
26956 this.changeCallback = changeCallback || function() {};
26957 this.observerConfig = observerConfig;
26958
26959 this.observedShadowRoots = null;
26960 this.shadowObservers = [];
26961 }
26962
26963 ShadowDOMObserver.prototype.getEventTarget = function(event) {
26964 if (!this.observedShadowRoots) {
26965 return;
26966 }
26967 var path = this.getComposedPath(event);
26968 if (path && path.length) {
26969 return path[0];
26970 }
26971
26972 return event['target'] || event['srcElement'];
26973 };
26974
26975
26976 ShadowDOMObserver.prototype.getComposedPath = function(event) {
26977 if ('composedPath' in event) {
26978 return event['composedPath']();
26979 }
26980
26981 return [];
26982 };
26983 ShadowDOMObserver.prototype.observeFromEvent = function(event) {
26984 if (!this.observedShadowRoots) {
26985 return;
26986 }
26987
26988 var path = this.getComposedPath(event);
26989
26990 // Check each element in path for shadow roots
26991 for (var i = 0; i < path.length; i++) {
26992 var element = path[i];
26993
26994 if (element && element.shadowRoot) {
26995 this.observeShadowRoot(element.shadowRoot);
26996 }
26997 }
26998 };
26999
27000
27001 ShadowDOMObserver.prototype.observeShadowRoot = function(shadowRoot) {
27002 if (!this.observedShadowRoots || this.observedShadowRoots.has(shadowRoot)) {
27003 return;
27004 }
27005
27006 var self = this;
27007
27008 try {
27009 this.observedShadowRoots.add(shadowRoot);
27010
27011 var observer = new window.MutationObserver(function() {
27012 self.changeCallback();
27013 });
27014
27015 observer.observe(shadowRoot, this.observerConfig);
27016 this.shadowObservers.push(observer);
27017 } catch (e) {
27018 logger$1.critical('Error while observing shadow root', e);
27019 }
27020 };
27021
27022
27023 ShadowDOMObserver.prototype.start = function() {
27024 if (this.observedShadowRoots) {
27025 return;
27026 }
27027
27028 if (!weakSetSupported()) {
27029 logger$1.critical('Shadow DOM observation unavailable: WeakSet not supported');
27030 return;
27031 }
27032
27033 this.observedShadowRoots = new WeakSet();
27034 };
27035
27036 ShadowDOMObserver.prototype.stop = function() {
27037 if (!this.observedShadowRoots) {
27038 return;
27039 }
27040
27041 for (var i = 0; i < this.shadowObservers.length; i++) {
27042 try {
27043 this.shadowObservers[i].disconnect();
27044 } catch (e) {
27045 logger$1.critical('Error while disconnecting shadow DOM observer', e);
27046 }
27047 }
27048 this.shadowObservers = [];
27049 this.observedShadowRoots = null;
27050 };
27051
27052 /** @const */ var DEFAULT_DEAD_CLICK_TIMEOUT_MS = 500;
27053 /** @const */ var INTERACTION_EVENTS = [EV_CHANGE, EV_INPUT, EV_SUBMIT, EV_SELECT, EV_TOGGLE];
27054 /** @const */ var LAYOUT_EVENTS = [EV_SCROLLEND];
27055 /** @const */ var NAVIGATION_EVENTS = [EV_HASHCHANGE];
27056 /** @const */ var MUTATION_OBSERVER_CONFIG = {
27057 characterData: true,
27058 childList: true,
27059 subtree: true,
27060 attributes: true,
27061 attributeFilter: ['style', 'class', 'hidden', 'checked', 'selected', 'value', 'display', 'visibility']
27062 };
27063
27064
27065 function DeadClickTracker(onDeadClickCallback) {
27066 this.eventListeners = [];
27067 this.mutationObserver = null;
27068 this.shadowDOMObserver = null;
27069
27070 this.isTracking = false;
27071 this.lastChangeEventTimestamp = 0;
27072 this.pendingClicks = [];
27073 this.onDeadClickCallback = onDeadClickCallback;
27074 this.processingActive = false;
27075 this.processingTimeout = null;
27076 }
27077
27078
27079 DeadClickTracker.prototype.addClick = function(event) {
27080 var element = this.shadowDOMObserver && this.shadowDOMObserver.getEventTarget(event);
27081
27082 if (!element) {
27083 element = event['target'] || event['srcElement'];
27084 }
27085
27086 if (!element || isDefinitelyNonInteractive(element)) {
27087 return false;
27088 }
27089
27090 if (this.shadowDOMObserver) {
27091 this.shadowDOMObserver.observeFromEvent(event);
27092 }
27093 this.pendingClicks.push({
27094 element: element,
27095 event: event,
27096 timestamp: Date.now()
27097 });
27098 return true;
27099 };
27100
27101 DeadClickTracker.prototype.trackClick = function(event, config) {
27102 if (!this.isTracking) {
27103 return false;
27104 }
27105
27106 var added = this.addClick(event);
27107 if (added) {
27108 this.triggerProcessing(config);
27109 }
27110 return added;
27111 };
27112
27113 DeadClickTracker.prototype.getDeadClicks = function(config) {
27114 if (this.pendingClicks.length === 0) {
27115 return [];
27116 }
27117
27118 var timeoutMs = config['timeout_ms'];
27119 var now = Date.now();
27120 var clicksToEvaluate = this.pendingClicks.slice(); // Copy array
27121 this.pendingClicks = []; // Clear original
27122
27123 var deadClicks = [];
27124
27125 for (var i = 0; i < clicksToEvaluate.length; i++) {
27126 var click = clicksToEvaluate[i];
27127
27128 if (now - click.timestamp >= timeoutMs) {
27129 // Click has exceeded timeout, check if it's dead by looking for changes after this specific click
27130 if (!this.hasChangesAfter(click.timestamp)) {
27131 deadClicks.push(click);
27132 }
27133 } else {
27134 // Still pending - add back
27135 this.pendingClicks.push(click);
27136 }
27137 }
27138
27139 return deadClicks;
27140 };
27141
27142 DeadClickTracker.prototype.hasChangesAfter = function(timestamp) {
27143 // 100ms tolerance for race condition between when we record the click and the change event
27144 return this.lastChangeEventTimestamp >= (timestamp - 100);
27145 };
27146
27147 DeadClickTracker.prototype.recordChangeEvent = function() {
27148 this.lastChangeEventTimestamp = Date.now();
27149 };
27150
27151 DeadClickTracker.prototype.triggerProcessing = function(config) {
27152 // Prevent multiple concurrent processing chains
27153 if (this.processingActive) {
27154 return;
27155 }
27156 this.processingActive = true;
27157 this.processRecursively(config);
27158 };
27159
27160 DeadClickTracker.prototype.processRecursively = function(config) {
27161 if (!this.isTracking || !this.onDeadClickCallback) {
27162 this.processingActive = false;
27163 return;
27164 }
27165
27166 var timeoutMs = config['timeout_ms'];
27167 var self = this;
27168
27169 this.processingTimeout = setTimeout(function() {
27170 if (!self.processingActive) {
27171 return;
27172 }
27173
27174 var deadClicks = self.getDeadClicks(config);
27175
27176 for (var i = 0; i < deadClicks.length; i++) {
27177 self.onDeadClickCallback(deadClicks[i].event);
27178 }
27179
27180 if (self.pendingClicks.length > 0) {
27181 self.processRecursively(config);
27182 } else {
27183 self.processingActive = false;
27184 }
27185 }, timeoutMs);
27186 };
27187
27188 DeadClickTracker.prototype.startTracking = function() {
27189 if (this.isTracking) {
27190 return;
27191 }
27192
27193 this.isTracking = true;
27194
27195 var self = this;
27196
27197 INTERACTION_EVENTS.forEach(function(event) {
27198 var handler = function() {
27199 self.recordChangeEvent();
27200 };
27201 document.addEventListener(event, handler, { capture: true, passive: true });
27202 self.eventListeners.push({ target: document, event: event, handler: handler, options: { capture: true, passive: true } });
27203 });
27204 NAVIGATION_EVENTS.forEach(function(event) {
27205 var handler = function() {
27206 self.recordChangeEvent();
27207 };
27208 window.addEventListener(event, handler);
27209 self.eventListeners.push({ target: window, event: event, handler: handler });
27210 });
27211 LAYOUT_EVENTS.forEach(function(event) {
27212 var handler = function() {
27213 self.recordChangeEvent();
27214 };
27215 window.addEventListener(event, handler, { passive: true });
27216 self.eventListeners.push({ target: window, event: event, handler: handler, options: { passive: true } });
27217 });
27218 var selectionHandler = function() {
27219 self.recordChangeEvent();
27220 };
27221 document.addEventListener('selectionchange', selectionHandler);
27222 self.eventListeners.push({ target: document, event: 'selectionchange', handler: selectionHandler });
27223
27224 // Set up MutationObserver
27225 if (window.MutationObserver) {
27226 try {
27227 this.mutationObserver = new window.MutationObserver(function() {
27228 self.recordChangeEvent();
27229 });
27230
27231 this.mutationObserver.observe(document.body || document.documentElement, MUTATION_OBSERVER_CONFIG);
27232 } catch (e) {
27233 logger$1.critical('Error while setting up mutation observer', e);
27234 }
27235 }
27236
27237 // Set up Shadow DOM observer
27238 if (window.customElements) {
27239 try {
27240 this.shadowDOMObserver = new ShadowDOMObserver(
27241 function() {
27242 self.recordChangeEvent();
27243 },
27244 MUTATION_OBSERVER_CONFIG
27245 );
27246 this.shadowDOMObserver.start();
27247 } catch (e) {
27248 logger$1.critical('Error while setting up shadow DOM observer', e);
27249 this.shadowDOMObserver = null;
27250 }
27251 }
27252 };
27253
27254 DeadClickTracker.prototype.stopTracking = function() {
27255 if (!this.isTracking) {
27256 return;
27257 }
27258
27259 this.isTracking = false;
27260 this.pendingClicks = [];
27261 this.lastChangeEventTimestamp = 0;
27262 this.processingActive = false;
27263
27264 if (this.processingTimeout) {
27265 clearTimeout(this.processingTimeout);
27266 this.processingTimeout = null;
27267 }
27268
27269 // Remove all event listeners
27270 for (var i = 0; i < this.eventListeners.length; i++) {
27271 var listener = this.eventListeners[i];
27272 try {
27273 listener.target.removeEventListener(listener.event, listener.handler, listener.options);
27274 } catch (e) {
27275 logger$1.critical('Error while removing event listener', e);
27276 }
27277 }
27278 this.eventListeners = [];
27279
27280 if (this.mutationObserver) {
27281 try {
27282 this.mutationObserver.disconnect();
27283 } catch (e) {
27284 logger$1.critical('Error while disconnecting mutation observer', e);
27285 }
27286 this.mutationObserver = null;
27287 }
27288
27289 if (this.shadowDOMObserver) {
27290 try {
27291 this.shadowDOMObserver.stop();
27292 } catch (e) {
27293 logger$1.critical('Error while stopping shadow DOM observer', e);
27294 }
27295 this.shadowDOMObserver = null;
27296 }
27297 };
27298
27299 var AUTOCAPTURE_CONFIG_KEY = 'autocapture';
27300 var LEGACY_PAGEVIEW_CONFIG_KEY = 'track_pageview';
27301
27302 var PAGEVIEW_OPTION_FULL_URL = 'full-url';
27303 var PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING = 'url-with-path-and-query-string';
27304 var PAGEVIEW_OPTION_URL_WITH_PATH = 'url-with-path';
27305
27306 var CONFIG_ALLOW_ELEMENT_CALLBACK = 'allow_element_callback';
27307 var CONFIG_ALLOW_SELECTORS = 'allow_selectors';
27308 var CONFIG_ALLOW_URL_REGEXES = 'allow_url_regexes';
27309 var CONFIG_BLOCK_ATTRS = 'block_attrs';
27310 var CONFIG_BLOCK_ELEMENT_CALLBACK = 'block_element_callback';
27311 var CONFIG_BLOCK_SELECTORS = 'block_selectors';
27312 var CONFIG_BLOCK_URL_REGEXES = 'block_url_regexes';
27313 var CONFIG_CAPTURE_EXTRA_ATTRS = 'capture_extra_attrs';
27314 var CONFIG_CAPTURE_TEXT_CONTENT = 'capture_text_content';
27315 var CONFIG_SCROLL_CAPTURE_ALL = 'scroll_capture_all';
27316 var CONFIG_SCROLL_CHECKPOINTS = 'scroll_depth_percent_checkpoints';
27317 var CONFIG_TRACK_CLICK = 'click';
27318 var CONFIG_TRACK_DEAD_CLICK = 'dead_click';
27319 var CONFIG_TRACK_INPUT = 'input';
27320 var CONFIG_TRACK_PAGEVIEW = 'pageview';
27321 var CONFIG_TRACK_RAGE_CLICK = 'rage_click';
27322 var CONFIG_TRACK_SCROLL = 'scroll';
27323 var CONFIG_TRACK_PAGE_LEAVE = 'page_leave';
27324 var CONFIG_TRACK_SUBMIT = 'submit';
27325
27326 var CONFIG_DEFAULTS$1 = {};
27327 CONFIG_DEFAULTS$1[CONFIG_ALLOW_SELECTORS] = [];
27328 CONFIG_DEFAULTS$1[CONFIG_ALLOW_URL_REGEXES] = [];
27329 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ATTRS] = [];
27330 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ELEMENT_CALLBACK] = null;
27331 CONFIG_DEFAULTS$1[CONFIG_BLOCK_SELECTORS] = [];
27332 CONFIG_DEFAULTS$1[CONFIG_BLOCK_URL_REGEXES] = [];
27333 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_EXTRA_ATTRS] = [];
27334 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_TEXT_CONTENT] = false;
27335 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CAPTURE_ALL] = false;
27336 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CHECKPOINTS] = [25, 50, 75, 100];
27337 CONFIG_DEFAULTS$1[CONFIG_TRACK_CLICK] = true;
27338 CONFIG_DEFAULTS$1[CONFIG_TRACK_DEAD_CLICK] = true;
27339 CONFIG_DEFAULTS$1[CONFIG_TRACK_INPUT] = true;
27340 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGEVIEW] = PAGEVIEW_OPTION_FULL_URL;
27341 CONFIG_DEFAULTS$1[CONFIG_TRACK_RAGE_CLICK] = true;
27342 CONFIG_DEFAULTS$1[CONFIG_TRACK_SCROLL] = true;
27343 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGE_LEAVE] = false;
27344 CONFIG_DEFAULTS$1[CONFIG_TRACK_SUBMIT] = true;
27345
27346 var DEFAULT_PROPS = {
27347 '$mp_autocapture': true
27348 };
27349
27350 var MP_EV_CLICK = '$mp_click';
27351 var MP_EV_DEAD_CLICK = '$mp_dead_click';
27352 var MP_EV_INPUT = '$mp_input_change';
27353 var MP_EV_RAGE_CLICK = '$mp_rage_click';
27354 var MP_EV_SCROLL = '$mp_scroll';
27355 var MP_EV_SUBMIT = '$mp_submit';
27356 var MP_EV_PAGE_LEAVE = '$mp_page_leave';
27357
27358 /**
27359 * Autocapture: manages automatic event tracking
27360 * @constructor
27361 */
27362 var Autocapture = function(mp) {
27363 this.mp = mp;
27364 this.maxScrollViewDepth = 0;
27365 this.hasTrackedScrollSession = false;
27366 this.previousScrollHeight = 0;
27367 };
27368
27369 Autocapture.prototype.init = function() {
27370 if (!minDOMApisSupported()) {
27371 logger$1.critical('Autocapture unavailable: missing required DOM APIs');
27372 return;
27373 }
27374 this.initPageListeners();
27375 this.initPageviewTracking();
27376 this.initClickTracking();
27377 this.initDeadClickTracking();
27378 this.initInputTracking();
27379 this.initScrollTracking();
27380 this.initSubmitTracking();
27381 this.initRageClickTracking();
27382 this.initPageLeaveTracking();
27383 };
27384
27385 Autocapture.prototype.getFullConfig = function() {
27386 var autocaptureConfig = this.mp.get_config(AUTOCAPTURE_CONFIG_KEY);
27387 if (!autocaptureConfig) {
27388 // Autocapture is completely off
27389 return {};
27390 } else if (_.isObject(autocaptureConfig)) {
27391 return _.extend({}, CONFIG_DEFAULTS$1, autocaptureConfig);
27392 } else {
27393 // Autocapture config is non-object truthy value, return default
27394 return CONFIG_DEFAULTS$1;
27395 }
27396 };
27397
27398 Autocapture.prototype.getConfig = function(key) {
27399 return this.getFullConfig()[key];
27400 };
27401
27402 Autocapture.prototype.currentUrlBlocked = function() {
27403 var i;
27404 var currentUrl = _.info.currentUrl();
27405
27406 var allowUrlRegexes = this.getConfig(CONFIG_ALLOW_URL_REGEXES) || [];
27407 if (allowUrlRegexes.length) {
27408 // we're using an allowlist, only track if current URL matches
27409 var allowed = false;
27410 for (i = 0; i < allowUrlRegexes.length; i++) {
27411 var allowRegex = allowUrlRegexes[i];
27412 try {
27413 if (currentUrl.match(allowRegex)) {
27414 allowed = true;
27415 break;
27416 }
27417 } catch (err) {
27418 logger$1.critical('Error while checking block URL regex: ' + allowRegex, err);
27419 return true;
27420 }
27421 }
27422 if (!allowed) {
27423 // wasn't allowed by any regex
27424 return true;
27425 }
27426 }
27427
27428 var blockUrlRegexes = this.getConfig(CONFIG_BLOCK_URL_REGEXES) || [];
27429 if (!blockUrlRegexes || !blockUrlRegexes.length) {
27430 return false;
27431 }
27432
27433 for (i = 0; i < blockUrlRegexes.length; i++) {
27434 try {
27435 if (currentUrl.match(blockUrlRegexes[i])) {
27436 return true;
27437 }
27438 } catch (err) {
27439 logger$1.critical('Error while checking block URL regex: ' + blockUrlRegexes[i], err);
27440 return true;
27441 }
27442 }
27443 return false;
27444 };
27445
27446 Autocapture.prototype.pageviewTrackingConfig = function() {
27447 // supports both autocapture config and old track_pageview config
27448 if (this.mp.get_config(AUTOCAPTURE_CONFIG_KEY)) {
27449 return this.getConfig(CONFIG_TRACK_PAGEVIEW);
27450 } else {
27451 return this.mp.get_config(LEGACY_PAGEVIEW_CONFIG_KEY);
27452 }
27453 };
27454
27455 // helper for event handlers
27456 Autocapture.prototype.trackDomEvent = function(ev, mpEventName) {
27457 if (this.currentUrlBlocked()) {
27458 return;
27459 }
27460
27461 var isCapturedForHeatMap = this.mp.is_recording_heatmap_data() && (
27462 (mpEventName === MP_EV_CLICK && !this.getConfig(CONFIG_TRACK_CLICK)) ||
27463 (mpEventName === MP_EV_RAGE_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK)) ||
27464 (mpEventName === MP_EV_DEAD_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK))
27465 );
27466
27467 var props = getPropsForDOMEvent(ev, {
27468 allowElementCallback: this.getConfig(CONFIG_ALLOW_ELEMENT_CALLBACK),
27469 allowSelectors: this.getConfig(CONFIG_ALLOW_SELECTORS),
27470 blockAttrs: this.getConfig(CONFIG_BLOCK_ATTRS),
27471 blockElementCallback: this.getConfig(CONFIG_BLOCK_ELEMENT_CALLBACK),
27472 blockSelectors: this.getConfig(CONFIG_BLOCK_SELECTORS),
27473 captureExtraAttrs: this.getConfig(CONFIG_CAPTURE_EXTRA_ATTRS),
27474 captureTextContent: this.getConfig(CONFIG_CAPTURE_TEXT_CONTENT),
27475 capturedForHeatMap: isCapturedForHeatMap,
27476 });
27477 if (props) {
27478 _.extend(props, DEFAULT_PROPS);
27479 this.mp.track(mpEventName, props);
27480 }
27481 };
27482
27483 Autocapture.prototype.initPageListeners = function() {
27484 win.removeEventListener(EV_POPSTATE, this.listenerPopstate);
27485 win.removeEventListener(EV_HASHCHANGE, this.listenerHashchange);
27486
27487 if (!this.pageviewTrackingConfig() && !this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
27488 // These are all the configs that use these listeners
27489 return;
27490 }
27491
27492 this.listenerPopstate = function() {
27493 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27494 };
27495 this.listenerHashchange = function() {
27496 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27497 };
27498
27499 win.addEventListener(EV_POPSTATE, this.listenerPopstate);
27500 win.addEventListener(EV_HASHCHANGE, this.listenerHashchange);
27501 var nativePushState = win.history.pushState;
27502 if (typeof nativePushState === 'function') {
27503 win.history.pushState = function(state, unused, url) {
27504 nativePushState.call(win.history, state, unused, url);
27505 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27506 };
27507 }
27508 var nativeReplaceState = win.history.replaceState;
27509 if (typeof nativeReplaceState === 'function') {
27510 win.history.replaceState = function(state, unused, url) {
27511 nativeReplaceState.call(win.history, state, unused, url);
27512 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27513 };
27514 }
27515 };
27516
27517 Autocapture.prototype._getClickTrackingConfig = function(configKey) {
27518 var config = this.getConfig(configKey);
27519
27520 if (!config) {
27521 return null; // click tracking disabled
27522 }
27523
27524 if (config === true) {
27525 return {}; // use defaults
27526 }
27527
27528 if (typeof config === 'object') {
27529 return config; // use custom configuration
27530 }
27531
27532 return {}; // fallback to defaults for any other truthy value
27533 };
27534
27535 Autocapture.prototype._trackPageLeave = function(ev, currentUrl, currentScrollHeight) {
27536 if (this.hasTrackedScrollSession) {
27537 // User has navigated away already ending their impression.
27538 return;
27539 }
27540
27541 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.is_recording_heatmap_data()) {
27542 return;
27543 }
27544
27545 this.hasTrackedScrollSession = true;
27546 var viewportHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
27547 var scrollPercentage = Math.round(Math.max(this.maxScrollViewDepth - viewportHeight, 0) / (currentScrollHeight - viewportHeight) * 100);
27548 var foldLinePercentage = Math.round((viewportHeight / currentScrollHeight) * 100);
27549 if (currentScrollHeight <= viewportHeight) {
27550 // If the content fits within the viewport, consider it fully scrolled
27551 scrollPercentage = 100;
27552 foldLinePercentage = 100;
27553 }
27554
27555 var props = _.extend({
27556 '$max_scroll_view_depth': this.maxScrollViewDepth,
27557 '$max_scroll_percentage': scrollPercentage,
27558 '$fold_line_percentage': foldLinePercentage,
27559 '$scroll_height': currentScrollHeight,
27560 '$event_type': ev.type,
27561 '$current_url': currentUrl || _.info.currentUrl(),
27562 '$viewportHeight': viewportHeight, // This is the fold line
27563 '$viewportWidth': Math.max(document$1.documentElement.clientWidth, win.innerWidth || 0),
27564 '$captured_for_heatmap': this.mp.is_recording_heatmap_data()
27565 }, DEFAULT_PROPS);
27566
27567 // Send with beacon transport to ensure event is sent before unload
27568 this.mp.track(MP_EV_PAGE_LEAVE, props, {transport: 'sendBeacon'});
27569 };
27570
27571 Autocapture.prototype._initScrollDepthTracking = function() {
27572 win.removeEventListener(EV_SCROLL, this.listenerScrollDepth);
27573 win.removeEventListener(EV_SCROLLEND, this.listenerScrollDepth);
27574
27575 if (!this.mp.get_config('record_heatmap_data')) {
27576 return;
27577 }
27578
27579 logger$1.log('Initializing scroll depth tracking');
27580
27581 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
27582
27583 var updateScrollDepth = function() {
27584 if (this.currentUrlBlocked()) {
27585 return;
27586 }
27587 var scrollViewHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0) + win.scrollY;
27588 if (scrollViewHeight > this.maxScrollViewDepth) {
27589 this.maxScrollViewDepth = scrollViewHeight;
27590 }
27591 this.previousScrollHeight = document$1.body.scrollHeight;
27592 }.bind(this);
27593
27594 var scrollEndPolyfill = getPolyfillScrollEndFunction(updateScrollDepth);
27595 this.listenerScrollDepth = scrollEndPolyfill.listener;
27596 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScrollDepth);
27597 };
27598
27599 Autocapture.prototype.initClickTracking = function() {
27600 win.removeEventListener(EV_CLICK, this.listenerClick);
27601
27602 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.get_config('record_heatmap_data')) {
27603 return;
27604 }
27605 logger$1.log('Initializing click tracking');
27606
27607 this.listenerClick = function(ev) {
27608 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.is_recording_heatmap_data()) {
27609 return;
27610 }
27611 this.trackDomEvent(ev, MP_EV_CLICK);
27612 }.bind(this);
27613 win.addEventListener(EV_CLICK, this.listenerClick);
27614 };
27615
27616 Autocapture.prototype.initDeadClickTracking = function() {
27617 var deadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
27618
27619 if (!deadClickConfig && !this.mp.get_config('record_heatmap_data')) {
27620 this.stopDeadClickTracking();
27621 return;
27622 }
27623
27624 logger$1.log('Initializing dead click tracking');
27625 if (!this._deadClickTracker) {
27626 this._deadClickTracker = new DeadClickTracker(function(deadClickEvent) {
27627 this.trackDomEvent(deadClickEvent, MP_EV_DEAD_CLICK);
27628 }.bind(this));
27629 this._deadClickTracker.startTracking();
27630 }
27631
27632 if (!this.listenerDeadClick) {
27633 this.listenerDeadClick = function(ev) {
27634 var currentDeadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
27635 if (!currentDeadClickConfig && !this.mp.is_recording_heatmap_data()) {
27636 return;
27637 }
27638 if (this.currentUrlBlocked()) {
27639 return;
27640 }
27641 // Normalize config to ensure timeout_ms is always set
27642 var normalizedConfig = currentDeadClickConfig || {};
27643 if (!normalizedConfig['timeout_ms']) {
27644 normalizedConfig['timeout_ms'] = DEFAULT_DEAD_CLICK_TIMEOUT_MS;
27645 }
27646 this._deadClickTracker.trackClick(ev, normalizedConfig);
27647 }.bind(this);
27648 win.addEventListener(EV_CLICK, this.listenerDeadClick);
27649 }
27650 };
27651
27652 Autocapture.prototype.initInputTracking = function() {
27653 win.removeEventListener(EV_CHANGE, this.listenerChange);
27654
27655 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
27656 return;
27657 }
27658 logger$1.log('Initializing input tracking');
27659
27660 this.listenerChange = function(ev) {
27661 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
27662 return;
27663 }
27664 this.trackDomEvent(ev, MP_EV_INPUT);
27665 }.bind(this);
27666 win.addEventListener(EV_CHANGE, this.listenerChange);
27667 };
27668
27669 Autocapture.prototype.initPageviewTracking = function() {
27670 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
27671
27672 if (!this.pageviewTrackingConfig()) {
27673 return;
27674 }
27675 logger$1.log('Initializing pageview tracking');
27676
27677 var previousTrackedUrl = '';
27678 var tracked = false;
27679 if (!this.currentUrlBlocked()) {
27680 tracked = this.mp.track_pageview(DEFAULT_PROPS);
27681 }
27682 if (tracked) {
27683 previousTrackedUrl = _.info.currentUrl();
27684 }
27685
27686 this.listenerLocationchange = safewrap(function() {
27687 if (this.currentUrlBlocked()) {
27688 return;
27689 }
27690
27691 var currentUrl = _.info.currentUrl();
27692 var shouldTrack = false;
27693 var didPathChange = currentUrl.split('#')[0].split('?')[0] !== previousTrackedUrl.split('#')[0].split('?')[0];
27694 var trackPageviewOption = this.pageviewTrackingConfig();
27695 if (trackPageviewOption === PAGEVIEW_OPTION_FULL_URL) {
27696 shouldTrack = currentUrl !== previousTrackedUrl;
27697 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING) {
27698 shouldTrack = currentUrl.split('#')[0] !== previousTrackedUrl.split('#')[0];
27699 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH) {
27700 shouldTrack = didPathChange;
27701 }
27702
27703 if (shouldTrack) {
27704 var tracked = this.mp.track_pageview(DEFAULT_PROPS);
27705 if (tracked) {
27706 previousTrackedUrl = currentUrl;
27707 }
27708 if (didPathChange) {
27709 this.lastScrollCheckpoint = 0;
27710 logger$1.log('Path change: re-initializing scroll depth checkpoints');
27711 }
27712 }
27713 }.bind(this));
27714 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
27715 };
27716
27717 Autocapture.prototype.initRageClickTracking = function() {
27718 win.removeEventListener(EV_CLICK, this.listenerRageClick);
27719
27720 var rageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
27721 if (!rageClickConfig && !this.mp.get_config('record_heatmap_data')) {
27722 return;
27723 }
27724
27725 logger$1.log('Initializing rage click tracking');
27726 if (!this._rageClickTracker) {
27727 this._rageClickTracker = new RageClickTracker();
27728 }
27729
27730 this.listenerRageClick = function(ev) {
27731 var currentRageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
27732 if (!currentRageClickConfig && !this.mp.is_recording_heatmap_data()) {
27733 return;
27734 }
27735
27736 if (this.currentUrlBlocked()) {
27737 return;
27738 }
27739
27740 if (this._rageClickTracker.isRageClick(ev['pageX'], ev['pageY'], currentRageClickConfig)) {
27741 this.trackDomEvent(ev, MP_EV_RAGE_CLICK);
27742 }
27743 }.bind(this);
27744 win.addEventListener(EV_CLICK, this.listenerRageClick);
27745 };
27746
27747 Autocapture.prototype.initScrollTracking = function() {
27748 win.removeEventListener(EV_SCROLLEND, this.listenerScroll);
27749 win.removeEventListener(EV_SCROLL, this.listenerScroll);
27750
27751
27752 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
27753 return;
27754 }
27755 logger$1.log('Initializing scroll tracking');
27756 this.lastScrollCheckpoint = 0;
27757
27758 var scrollTrackFunction = function() {
27759 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
27760 return;
27761 }
27762 if (this.currentUrlBlocked()) {
27763 return;
27764 }
27765
27766 var shouldTrack = this.getConfig(CONFIG_SCROLL_CAPTURE_ALL);
27767 var scrollCheckpoints = (this.getConfig(CONFIG_SCROLL_CHECKPOINTS) || [])
27768 .slice()
27769 .sort(function(a, b) { return a - b; });
27770
27771 var scrollTop = win.scrollY;
27772 var props = _.extend({'$scroll_top': scrollTop}, DEFAULT_PROPS);
27773 try {
27774 var scrollHeight = document$1.body.scrollHeight;
27775 var scrollPercentage = Math.round((scrollTop / (scrollHeight - win.innerHeight)) * 100);
27776 props['$scroll_height'] = scrollHeight;
27777 props['$scroll_percentage'] = scrollPercentage;
27778 if (scrollPercentage > this.lastScrollCheckpoint) {
27779 for (var i = 0; i < scrollCheckpoints.length; i++) {
27780 var checkpoint = scrollCheckpoints[i];
27781 if (
27782 scrollPercentage >= checkpoint &&
27783 this.lastScrollCheckpoint < checkpoint
27784 ) {
27785 props['$scroll_checkpoint'] = checkpoint;
27786 this.lastScrollCheckpoint = checkpoint;
27787 shouldTrack = true;
27788 }
27789 }
27790 }
27791 } catch (err) {
27792 logger$1.critical('Error while calculating scroll percentage', err);
27793 }
27794 if (shouldTrack) {
27795 this.mp.track(MP_EV_SCROLL, props);
27796 }
27797 }.bind(this);
27798
27799 var scrollEndPolyfill = getPolyfillScrollEndFunction(scrollTrackFunction);
27800 this.listenerScroll = scrollEndPolyfill.listener;
27801 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScroll);
27802 };
27803
27804 Autocapture.prototype.initSubmitTracking = function() {
27805 win.removeEventListener(EV_SUBMIT, this.listenerSubmit);
27806
27807 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
27808 return;
27809 }
27810 logger$1.log('Initializing submit tracking');
27811
27812 this.listenerSubmit = function(ev) {
27813 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
27814 return;
27815 }
27816 this.trackDomEvent(ev, MP_EV_SUBMIT);
27817 }.bind(this);
27818 win.addEventListener(EV_SUBMIT, this.listenerSubmit);
27819 };
27820
27821 Autocapture.prototype.initPageLeaveTracking = function() {
27822 // Capture page_leave both when the user navigates away from the page (visibilitychange) as well
27823 // as when they navigate to a different page within the SPA (popstate/pushstate/hashchange).
27824 document$1.removeEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
27825 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
27826 win.removeEventListener(EV_LOAD, this.listenerPageLoad);
27827
27828 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
27829 return;
27830 }
27831
27832 logger$1.log('Initializing page visibility tracking.');
27833 this._initScrollDepthTracking();
27834 var previousTrackedUrl = _.info.currentUrl();
27835
27836 // Initialize previousScrollHeight on `load` which handles async loading
27837 // https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
27838 this.listenerPageLoad = function() {
27839 this.previousScrollHeight = document$1.body.scrollHeight;
27840 }.bind(this);
27841 win.addEventListener(EV_LOAD, this.listenerPageLoad);
27842
27843 // Track page navigation events similar to how initPageviewTracking does it
27844 this.listenerPageLeaveLocationchange = safewrap(function(ev) {
27845 if (this.currentUrlBlocked()) {
27846 return;
27847 }
27848
27849 var currentUrl = _.info.currentUrl();
27850 // Track all URL changes including query string or fragment changes as separate scroll sessions
27851 var shouldTrack = currentUrl !== previousTrackedUrl;
27852
27853 if (shouldTrack) {
27854 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
27855 previousTrackedUrl = currentUrl;
27856 // Fragment navigation should call scroll(end) and trigger listener, don't add window.scrollY here.
27857 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
27858 this.previousScrollHeight = document$1.body.scrollHeight;
27859 this.hasTrackedScrollSession = false;
27860 }
27861 }.bind(this));
27862 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
27863
27864 this.listenerPageLeaveVisibilitychange = function(ev) {
27865 if (document$1.hidden) {
27866 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
27867 }
27868 }.bind(this);
27869 document$1.addEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
27870 };
27871
27872 Autocapture.prototype.stopDeadClickTracking = function() {
27873 if (this.listenerDeadClick) {
27874 win.removeEventListener(EV_CLICK, this.listenerDeadClick);
27875 this.listenerDeadClick = null;
27876 }
27877
27878 if (this._deadClickTracker) {
27879 this._deadClickTracker.stopTracking();
27880 this._deadClickTracker = null;
27881 }
27882 };
27883
27884 // TODO integrate error_reporter from mixpanel instance
27885 safewrapClass(Autocapture);
27886
27887 var logger = console_with_prefix('flags');
27888
27889 var FLAGS_CONFIG_KEY = 'flags';
27890
27891 var CONFIG_CONTEXT = 'context';
27892 var CONFIG_DEFAULTS = {};
27893 CONFIG_DEFAULTS[CONFIG_CONTEXT] = {};
27894
27895 /**
27896 * FeatureFlagManager: support for Mixpanel's feature flagging product
27897 * @constructor
27898 */
27899 var FeatureFlagManager = function(initOptions) {
27900 this.fetch = win['fetch'];
27901 this.getFullApiRoute = initOptions.getFullApiRoute;
27902 this.getMpConfig = initOptions.getConfigFunc;
27903 this.setMpConfig = initOptions.setConfigFunc;
27904 this.getMpProperty = initOptions.getPropertyFunc;
27905 this.track = initOptions.trackingFunc;
27906 };
27907
27908 FeatureFlagManager.prototype.init = function() {
27909 if (!this.minApisSupported()) {
27910 logger.critical('Feature Flags unavailable: missing minimum required APIs');
27911 return;
27912 }
27913
27914 this.flags = null;
27915 this.fetchFlags();
27916
27917 this.trackedFeatures = new Set();
27918 };
27919
27920 FeatureFlagManager.prototype.getFullConfig = function() {
27921 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
27922 if (!ffConfig) {
27923 // flags are completely off
27924 return {};
27925 } else if (_.isObject(ffConfig)) {
27926 return _.extend({}, CONFIG_DEFAULTS, ffConfig);
27927 } else {
27928 // config is non-object truthy value, return default
27929 return CONFIG_DEFAULTS;
27930 }
27931 };
27932
27933 FeatureFlagManager.prototype.getConfig = function(key) {
27934 return this.getFullConfig()[key];
27935 };
27936
27937 FeatureFlagManager.prototype.isSystemEnabled = function() {
27938 return !!this.getMpConfig(FLAGS_CONFIG_KEY);
27939 };
27940
27941 FeatureFlagManager.prototype.updateContext = function(newContext, options) {
27942 if (!this.isSystemEnabled()) {
27943 logger.critical('Feature Flags not enabled, cannot update context');
27944 return Promise.resolve();
27945 }
27946
27947 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
27948 if (!_.isObject(ffConfig)) {
27949 ffConfig = {};
27950 }
27951 var oldContext = (options && options['replace']) ? {} : this.getConfig(CONFIG_CONTEXT);
27952 ffConfig[CONFIG_CONTEXT] = _.extend({}, oldContext, newContext);
27953
27954 this.setMpConfig(FLAGS_CONFIG_KEY, ffConfig);
27955 return this.fetchFlags();
27956 };
27957
27958 FeatureFlagManager.prototype.areFlagsReady = function() {
27959 if (!this.isSystemEnabled()) {
27960 logger.error('Feature Flags not enabled');
27961 }
27962 return !!this.flags;
27963 };
27964
27965 FeatureFlagManager.prototype.fetchFlags = function() {
27966 if (!this.isSystemEnabled()) {
27967 return Promise.resolve();
27968 }
27969
27970 var distinctId = this.getMpProperty('distinct_id');
27971 var deviceId = this.getMpProperty('$device_id');
27972 var traceparent = generateTraceparent();
27973 logger.log('Fetching flags for distinct ID: ' + distinctId);
27974
27975 var context = _.extend({'distinct_id': distinctId, 'device_id': deviceId}, this.getConfig(CONFIG_CONTEXT));
27976 var searchParams = new URLSearchParams();
27977 searchParams.set('context', JSON.stringify(context));
27978 searchParams.set('token', this.getMpConfig('token'));
27979 searchParams.set('mp_lib', 'web');
27980 searchParams.set('$lib_version', Config.LIB_VERSION);
27981 var url = this.getFullApiRoute() + '?' + searchParams.toString();
27982
27983 this._fetchInProgressStartTime = Date.now();
27984 this.fetchPromise = this.fetch.call(win, url, {
27985 'method': 'GET',
27986 'headers': {
27987 'Authorization': 'Basic ' + btoa(this.getMpConfig('token') + ':'),
27988 'traceparent': traceparent
27989 }
27990 }).then(function(response) {
27991 this.markFetchComplete();
27992 return response.json().then(function(responseBody) {
27993 var responseFlags = responseBody['flags'];
27994 if (!responseFlags) {
27995 throw new Error('No flags in API response');
27996 }
27997 var flags = new Map();
27998 _.each(responseFlags, function(data, key) {
27999 flags.set(key, {
28000 'key': data['variant_key'],
28001 'value': data['variant_value'],
28002 'experiment_id': data['experiment_id'],
28003 'is_experiment_active': data['is_experiment_active'],
28004 'is_qa_tester': data['is_qa_tester']
28005 });
28006 });
28007 this.flags = flags;
28008 this._traceparent = traceparent;
28009 }.bind(this)).catch(function(error) {
28010 this.markFetchComplete();
28011 logger.error(error);
28012 }.bind(this));
28013 }.bind(this)).catch(function(error) {
28014 this.markFetchComplete();
28015 logger.error(error);
28016 }.bind(this));
28017
28018 return this.fetchPromise;
28019 };
28020
28021 FeatureFlagManager.prototype.markFetchComplete = function() {
28022 if (!this._fetchInProgressStartTime) {
28023 logger.error('Fetch in progress started time not set, cannot mark fetch complete');
28024 return;
28025 }
28026 this._fetchStartTime = this._fetchInProgressStartTime;
28027 this._fetchCompleteTime = Date.now();
28028 this._fetchLatency = this._fetchCompleteTime - this._fetchStartTime;
28029 this._fetchInProgressStartTime = null;
28030 };
28031
28032 FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
28033 if (!this.fetchPromise) {
28034 return new Promise(function(resolve) {
28035 logger.critical('Feature Flags not initialized');
28036 resolve(fallback);
28037 });
28038 }
28039
28040 return this.fetchPromise.then(function() {
28041 return this.getVariantSync(featureName, fallback);
28042 }.bind(this)).catch(function(error) {
28043 logger.error(error);
28044 return fallback;
28045 });
28046 };
28047
28048 FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
28049 if (!this.areFlagsReady()) {
28050 logger.log('Flags not loaded yet');
28051 return fallback;
28052 }
28053 var feature = this.flags.get(featureName);
28054 if (!feature) {
28055 logger.log('No flag found: "' + featureName + '"');
28056 return fallback;
28057 }
28058 this.trackFeatureCheck(featureName, feature);
28059 return feature;
28060 };
28061
28062 FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
28063 return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
28064 return feature['value'];
28065 }).catch(function(error) {
28066 logger.error(error);
28067 return fallbackValue;
28068 });
28069 };
28070
28071 // TODO remove deprecated method
28072 FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
28073 logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
28074 return this.getVariantValue(featureName, fallbackValue);
28075 };
28076
28077 FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
28078 return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
28079 };
28080
28081 FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
28082 return this.getVariantValue(featureName).then(function() {
28083 return this.isEnabledSync(featureName, fallbackValue);
28084 }.bind(this)).catch(function(error) {
28085 logger.error(error);
28086 return fallbackValue;
28087 });
28088 };
28089
28090 FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
28091 fallbackValue = fallbackValue || false;
28092 var val = this.getVariantValueSync(featureName, fallbackValue);
28093 if (val !== true && val !== false) {
28094 logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
28095 val = fallbackValue;
28096 }
28097 return val;
28098 };
28099
28100 FeatureFlagManager.prototype.trackFeatureCheck = function(featureName, feature) {
28101 if (this.trackedFeatures.has(featureName)) {
28102 return;
28103 }
28104 this.trackedFeatures.add(featureName);
28105
28106 var trackingProperties = {
28107 'Experiment name': featureName,
28108 'Variant name': feature['key'],
28109 '$experiment_type': 'feature_flag',
28110 'Variant fetch start time': new Date(this._fetchStartTime).toISOString(),
28111 'Variant fetch complete time': new Date(this._fetchCompleteTime).toISOString(),
28112 'Variant fetch latency (ms)': this._fetchLatency,
28113 'Variant fetch traceparent': this._traceparent,
28114 };
28115
28116 if (feature['experiment_id'] !== 'undefined') {
28117 trackingProperties['$experiment_id'] = feature['experiment_id'];
28118 }
28119 if (feature['is_experiment_active'] !== 'undefined') {
28120 trackingProperties['$is_experiment_active'] = feature['is_experiment_active'];
28121 }
28122 if (feature['is_qa_tester'] !== 'undefined') {
28123 trackingProperties['$is_qa_tester'] = feature['is_qa_tester'];
28124 }
28125
28126 this.track('$experiment_started', trackingProperties);
28127 };
28128
28129 FeatureFlagManager.prototype.minApisSupported = function() {
28130 return !!this.fetch &&
28131 typeof Promise !== 'undefined' &&
28132 typeof Map !== 'undefined' &&
28133 typeof Set !== 'undefined';
28134 };
28135
28136 safewrapClass(FeatureFlagManager);
28137
28138 FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
28139 FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
28140 FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
28141 FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
28142 FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
28143 FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
28144 FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
28145 FeatureFlagManager.prototype['update_context'] = FeatureFlagManager.prototype.updateContext;
28146
28147 // Deprecated method
28148 FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
28149
28150 /* eslint camelcase: "off" */
28151
28152
28153 /**
28154 * DomTracker Object
28155 * @constructor
28156 */
28157 var DomTracker = function() {};
28158
28159
28160 // interface
28161 DomTracker.prototype.create_properties = function() {};
28162 DomTracker.prototype.event_handler = function() {};
28163 DomTracker.prototype.after_track_handler = function() {};
28164
28165 DomTracker.prototype.init = function(mixpanel_instance) {
28166 this.mp = mixpanel_instance;
28167 return this;
28168 };
28169
28170 /**
28171 * @param {Object|string} query
28172 * @param {string} event_name
28173 * @param {Object=} properties
28174 * @param {function=} user_callback
28175 */
28176 DomTracker.prototype.track = function(query, event_name, properties, user_callback) {
28177 var that = this;
28178 var elements = _.dom_query(query);
28179
28180 if (elements.length === 0) {
28181 console$1.error('The DOM query (' + query + ') returned 0 elements');
28182 return;
28183 }
28184
28185 _.each(elements, function(element) {
28186 _.register_event(element, this.override_event, function(e) {
28187 var options = {};
28188 var props = that.create_properties(properties, this);
28189 var timeout = that.mp.get_config('track_links_timeout');
28190
28191 that.event_handler(e, this, options);
28192
28193 // in case the mixpanel servers don't get back to us in time
28194 window.setTimeout(that.track_callback(user_callback, props, options, true), timeout);
28195
28196 // fire the tracking event
28197 that.mp.track(event_name, props, that.track_callback(user_callback, props, options));
28198 });
28199 }, this);
28200
28201 return true;
28202 };
28203
28204 /**
28205 * @param {function} user_callback
28206 * @param {Object} props
28207 * @param {boolean=} timeout_occured
28208 */
28209 DomTracker.prototype.track_callback = function(user_callback, props, options, timeout_occured) {
28210 timeout_occured = timeout_occured || false;
28211 var that = this;
28212
28213 return function() {
28214 // options is referenced from both callbacks, so we can have
28215 // a 'lock' of sorts to ensure only one fires
28216 if (options.callback_fired) { return; }
28217 options.callback_fired = true;
28218
28219 if (user_callback && user_callback(timeout_occured, props) === false) {
28220 // user can prevent the default functionality by
28221 // returning false from their callback
28222 return;
28223 }
28224
28225 that.after_track_handler(props, options, timeout_occured);
28226 };
28227 };
28228
28229 DomTracker.prototype.create_properties = function(properties, element) {
28230 var props;
28231
28232 if (typeof(properties) === 'function') {
28233 props = properties(element);
28234 } else {
28235 props = _.extend({}, properties);
28236 }
28237
28238 return props;
28239 };
28240
28241 /**
28242 * LinkTracker Object
28243 * @constructor
28244 * @extends DomTracker
28245 */
28246 var LinkTracker = function() {
28247 this.override_event = 'click';
28248 };
28249 _.inherit(LinkTracker, DomTracker);
28250
28251 LinkTracker.prototype.create_properties = function(properties, element) {
28252 var props = LinkTracker.superclass.create_properties.apply(this, arguments);
28253
28254 if (element.href) { props['url'] = element.href; }
28255
28256 return props;
28257 };
28258
28259 LinkTracker.prototype.event_handler = function(evt, element, options) {
28260 options.new_tab = (
28261 evt.which === 2 ||
28262 evt.metaKey ||
28263 evt.ctrlKey ||
28264 element.target === '_blank'
28265 );
28266 options.href = element.href;
28267
28268 if (!options.new_tab) {
28269 evt.preventDefault();
28270 }
28271 };
28272
28273 LinkTracker.prototype.after_track_handler = function(props, options) {
28274 if (options.new_tab) { return; }
28275
28276 setTimeout(function() {
28277 window.location = options.href;
28278 }, 0);
28279 };
28280
28281 /**
28282 * FormTracker Object
28283 * @constructor
28284 * @extends DomTracker
28285 */
28286 var FormTracker = function() {
28287 this.override_event = 'submit';
28288 };
28289 _.inherit(FormTracker, DomTracker);
28290
28291 FormTracker.prototype.event_handler = function(evt, element, options) {
28292 options.element = element;
28293 evt.preventDefault();
28294 };
28295
28296 FormTracker.prototype.after_track_handler = function(props, options) {
28297 setTimeout(function() {
28298 options.element.submit();
28299 }, 0);
28300 };
28301
28302 /* eslint camelcase: "off" */
28303
28304
28305 /** @const */ var SET_ACTION = '$set';
28306 /** @const */ var SET_ONCE_ACTION = '$set_once';
28307 /** @const */ var UNSET_ACTION = '$unset';
28308 /** @const */ var ADD_ACTION = '$add';
28309 /** @const */ var APPEND_ACTION = '$append';
28310 /** @const */ var UNION_ACTION = '$union';
28311 /** @const */ var REMOVE_ACTION = '$remove';
28312 /** @const */ var DELETE_ACTION = '$delete';
28313
28314 // Common internal methods for mixpanel.people and mixpanel.group APIs.
28315 // These methods shouldn't involve network I/O.
28316 var apiActions = {
28317 set_action: function(prop, to) {
28318 var data = {};
28319 var $set = {};
28320 if (_.isObject(prop)) {
28321 _.each(prop, function(v, k) {
28322 if (!this._is_reserved_property(k)) {
28323 $set[k] = v;
28324 }
28325 }, this);
28326 } else {
28327 $set[prop] = to;
28328 }
28329
28330 data[SET_ACTION] = $set;
28331 return data;
28332 },
28333
28334 unset_action: function(prop) {
28335 var data = {};
28336 var $unset = [];
28337 if (!_.isArray(prop)) {
28338 prop = [prop];
28339 }
28340
28341 _.each(prop, function(k) {
28342 if (!this._is_reserved_property(k)) {
28343 $unset.push(k);
28344 }
28345 }, this);
28346
28347 data[UNSET_ACTION] = $unset;
28348 return data;
28349 },
28350
28351 set_once_action: function(prop, to) {
28352 var data = {};
28353 var $set_once = {};
28354 if (_.isObject(prop)) {
28355 _.each(prop, function(v, k) {
28356 if (!this._is_reserved_property(k)) {
28357 $set_once[k] = v;
28358 }
28359 }, this);
28360 } else {
28361 $set_once[prop] = to;
28362 }
28363 data[SET_ONCE_ACTION] = $set_once;
28364 return data;
28365 },
28366
28367 union_action: function(list_name, values) {
28368 var data = {};
28369 var $union = {};
28370 if (_.isObject(list_name)) {
28371 _.each(list_name, function(v, k) {
28372 if (!this._is_reserved_property(k)) {
28373 $union[k] = _.isArray(v) ? v : [v];
28374 }
28375 }, this);
28376 } else {
28377 $union[list_name] = _.isArray(values) ? values : [values];
28378 }
28379 data[UNION_ACTION] = $union;
28380 return data;
28381 },
28382
28383 append_action: function(list_name, value) {
28384 var data = {};
28385 var $append = {};
28386 if (_.isObject(list_name)) {
28387 _.each(list_name, function(v, k) {
28388 if (!this._is_reserved_property(k)) {
28389 $append[k] = v;
28390 }
28391 }, this);
28392 } else {
28393 $append[list_name] = value;
28394 }
28395 data[APPEND_ACTION] = $append;
28396 return data;
28397 },
28398
28399 remove_action: function(list_name, value) {
28400 var data = {};
28401 var $remove = {};
28402 if (_.isObject(list_name)) {
28403 _.each(list_name, function(v, k) {
28404 if (!this._is_reserved_property(k)) {
28405 $remove[k] = v;
28406 }
28407 }, this);
28408 } else {
28409 $remove[list_name] = value;
28410 }
28411 data[REMOVE_ACTION] = $remove;
28412 return data;
28413 },
28414
28415 delete_action: function() {
28416 var data = {};
28417 data[DELETE_ACTION] = '';
28418 return data;
28419 }
28420 };
28421
28422 /* eslint camelcase: "off" */
28423
28424 /**
28425 * Mixpanel Group Object
28426 * @constructor
28427 */
28428 var MixpanelGroup = function() {};
28429
28430 _.extend(MixpanelGroup.prototype, apiActions);
28431
28432 MixpanelGroup.prototype._init = function(mixpanel_instance, group_key, group_id) {
28433 this._mixpanel = mixpanel_instance;
28434 this._group_key = group_key;
28435 this._group_id = group_id;
28436 };
28437
28438 /**
28439 * Set properties on a group.
28440 *
28441 * ### Usage:
28442 *
28443 * mixpanel.get_group('company', 'mixpanel').set('Location', '405 Howard');
28444 *
28445 * // or set multiple properties at once
28446 * mixpanel.get_group('company', 'mixpanel').set({
28447 * 'Location': '405 Howard',
28448 * 'Founded' : 2009,
28449 * });
28450 * // properties can be strings, integers, dates, or lists
28451 *
28452 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
28453 * @param {*} [to] A value to set on the given property name
28454 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28455 */
28456 MixpanelGroup.prototype.set = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28457 var data = this.set_action(prop, to);
28458 if (_.isObject(prop)) {
28459 callback = to;
28460 }
28461 return this._send_request(data, callback);
28462 });
28463
28464 /**
28465 * Set properties on a group, only if they do not yet exist.
28466 * This will not overwrite previous group property values, unlike
28467 * group.set().
28468 *
28469 * ### Usage:
28470 *
28471 * mixpanel.get_group('company', 'mixpanel').set_once('Location', '405 Howard');
28472 *
28473 * // or set multiple properties at once
28474 * mixpanel.get_group('company', 'mixpanel').set_once({
28475 * 'Location': '405 Howard',
28476 * 'Founded' : 2009,
28477 * });
28478 * // properties can be strings, integers, lists or dates
28479 *
28480 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
28481 * @param {*} [to] A value to set on the given property name
28482 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28483 */
28484 MixpanelGroup.prototype.set_once = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28485 var data = this.set_once_action(prop, to);
28486 if (_.isObject(prop)) {
28487 callback = to;
28488 }
28489 return this._send_request(data, callback);
28490 });
28491
28492 /**
28493 * Unset properties on a group permanently.
28494 *
28495 * ### Usage:
28496 *
28497 * mixpanel.get_group('company', 'mixpanel').unset('Founded');
28498 *
28499 * @param {String} prop The name of the property.
28500 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28501 */
28502 MixpanelGroup.prototype.unset = addOptOutCheckMixpanelGroup(function(prop, callback) {
28503 var data = this.unset_action(prop);
28504 return this._send_request(data, callback);
28505 });
28506
28507 /**
28508 * Merge a given list with a list-valued group property, excluding duplicate values.
28509 *
28510 * ### Usage:
28511 *
28512 * // merge a value to a list, creating it if needed
28513 * mixpanel.get_group('company', 'mixpanel').union('Location', ['San Francisco', 'London']);
28514 *
28515 * @param {String} list_name Name of the property.
28516 * @param {Array} values Values to merge with the given property
28517 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28518 */
28519 MixpanelGroup.prototype.union = addOptOutCheckMixpanelGroup(function(list_name, values, callback) {
28520 if (_.isObject(list_name)) {
28521 callback = values;
28522 }
28523 var data = this.union_action(list_name, values);
28524 return this._send_request(data, callback);
28525 });
28526
28527 /**
28528 * Permanently delete a group.
28529 *
28530 * ### Usage:
28531 *
28532 * mixpanel.get_group('company', 'mixpanel').delete();
28533 *
28534 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28535 */
28536 MixpanelGroup.prototype['delete'] = addOptOutCheckMixpanelGroup(function(callback) {
28537 // bracket notation above prevents a minification error related to reserved words
28538 var data = this.delete_action();
28539 return this._send_request(data, callback);
28540 });
28541
28542 /**
28543 * Remove a property from a group. The value will be ignored if doesn't exist.
28544 *
28545 * ### Usage:
28546 *
28547 * mixpanel.get_group('company', 'mixpanel').remove('Location', 'London');
28548 *
28549 * @param {String} list_name Name of the property.
28550 * @param {Object} value Value to remove from the given group property
28551 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28552 */
28553 MixpanelGroup.prototype.remove = addOptOutCheckMixpanelGroup(function(list_name, value, callback) {
28554 var data = this.remove_action(list_name, value);
28555 return this._send_request(data, callback);
28556 });
28557
28558 MixpanelGroup.prototype._send_request = function(data, callback) {
28559 data['$group_key'] = this._group_key;
28560 data['$group_id'] = this._group_id;
28561 data['$token'] = this._get_config('token');
28562
28563 var date_encoded_data = _.encodeDates(data);
28564 return this._mixpanel._track_or_batch({
28565 type: 'groups',
28566 data: date_encoded_data,
28567 endpoint: this._mixpanel.get_api_host('groups') + '/' + this._get_config('api_routes')['groups'],
28568 batcher: this._mixpanel.request_batchers.groups
28569 }, callback);
28570 };
28571
28572 MixpanelGroup.prototype._is_reserved_property = function(prop) {
28573 return prop === '$group_key' || prop === '$group_id';
28574 };
28575
28576 MixpanelGroup.prototype._get_config = function(conf) {
28577 return this._mixpanel.get_config(conf);
28578 };
28579
28580 MixpanelGroup.prototype.toString = function() {
28581 return this._mixpanel.toString() + '.group.' + this._group_key + '.' + this._group_id;
28582 };
28583
28584 // MixpanelGroup Exports
28585 MixpanelGroup.prototype['remove'] = MixpanelGroup.prototype.remove;
28586 MixpanelGroup.prototype['set'] = MixpanelGroup.prototype.set;
28587 MixpanelGroup.prototype['set_once'] = MixpanelGroup.prototype.set_once;
28588 MixpanelGroup.prototype['union'] = MixpanelGroup.prototype.union;
28589 MixpanelGroup.prototype['unset'] = MixpanelGroup.prototype.unset;
28590 MixpanelGroup.prototype['toString'] = MixpanelGroup.prototype.toString;
28591
28592 /* eslint camelcase: "off" */
28593
28594 /**
28595 * Mixpanel People Object
28596 * @constructor
28597 */
28598 var MixpanelPeople = function() {};
28599
28600 _.extend(MixpanelPeople.prototype, apiActions);
28601
28602 MixpanelPeople.prototype._init = function(mixpanel_instance) {
28603 this._mixpanel = mixpanel_instance;
28604 };
28605
28606 /*
28607 * Set properties on a user record.
28608 *
28609 * ### Usage:
28610 *
28611 * mixpanel.people.set('gender', 'm');
28612 *
28613 * // or set multiple properties at once
28614 * mixpanel.people.set({
28615 * 'Company': 'Acme',
28616 * 'Plan': 'Premium',
28617 * 'Upgrade date': new Date()
28618 * });
28619 * // properties can be strings, integers, dates, or lists
28620 *
28621 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
28622 * @param {*} [to] A value to set on the given property name
28623 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28624 */
28625 MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
28626 var data = this.set_action(prop, to);
28627 if (_.isObject(prop)) {
28628 callback = to;
28629 }
28630 // make sure that the referrer info has been updated and saved
28631 if (this._get_config('save_referrer')) {
28632 this._mixpanel['persistence'].update_referrer_info(document.referrer);
28633 }
28634
28635 // update $set object with default people properties
28636 data[SET_ACTION] = _.extend(
28637 {},
28638 _.info.people_properties(),
28639 data[SET_ACTION]
28640 );
28641 return this._send_request(data, callback);
28642 });
28643
28644 /*
28645 * Set properties on a user record, only if they do not yet exist.
28646 * This will not overwrite previous people property values, unlike
28647 * people.set().
28648 *
28649 * ### Usage:
28650 *
28651 * mixpanel.people.set_once('First Login Date', new Date());
28652 *
28653 * // or set multiple properties at once
28654 * mixpanel.people.set_once({
28655 * 'First Login Date': new Date(),
28656 * 'Starting Plan': 'Premium'
28657 * });
28658 *
28659 * // properties can be strings, integers or dates
28660 *
28661 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
28662 * @param {*} [to] A value to set on the given property name
28663 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28664 */
28665 MixpanelPeople.prototype.set_once = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
28666 var data = this.set_once_action(prop, to);
28667 if (_.isObject(prop)) {
28668 callback = to;
28669 }
28670 return this._send_request(data, callback);
28671 });
28672
28673 /*
28674 * Unset properties on a user record (permanently removes the properties and their values from a profile).
28675 *
28676 * ### Usage:
28677 *
28678 * mixpanel.people.unset('gender');
28679 *
28680 * // or unset multiple properties at once
28681 * mixpanel.people.unset(['gender', 'Company']);
28682 *
28683 * @param {Array|String} prop If a string, this is the name of the property. If an array, this is a list of property names.
28684 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28685 */
28686 MixpanelPeople.prototype.unset = addOptOutCheckMixpanelPeople(function(prop, callback) {
28687 var data = this.unset_action(prop);
28688 return this._send_request(data, callback);
28689 });
28690
28691 /*
28692 * Increment/decrement numeric people analytics properties.
28693 *
28694 * ### Usage:
28695 *
28696 * mixpanel.people.increment('page_views', 1);
28697 *
28698 * // or, for convenience, if you're just incrementing a counter by
28699 * // 1, you can simply do
28700 * mixpanel.people.increment('page_views');
28701 *
28702 * // to decrement a counter, pass a negative number
28703 * mixpanel.people.increment('credits_left', -1);
28704 *
28705 * // like mixpanel.people.set(), you can increment multiple
28706 * // properties at once:
28707 * mixpanel.people.increment({
28708 * counter1: 1,
28709 * counter2: 6
28710 * });
28711 *
28712 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and numeric values.
28713 * @param {Number} [by] An amount to increment the given property
28714 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28715 */
28716 MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop, by, callback) {
28717 var data = {};
28718 var $add = {};
28719 if (_.isObject(prop)) {
28720 _.each(prop, function(v, k) {
28721 if (!this._is_reserved_property(k)) {
28722 if (isNaN(parseFloat(v))) {
28723 console$1.error('Invalid increment value passed to mixpanel.people.increment - must be a number');
28724 return;
28725 } else {
28726 $add[k] = v;
28727 }
28728 }
28729 }, this);
28730 callback = by;
28731 } else {
28732 // convenience: mixpanel.people.increment('property'); will
28733 // increment 'property' by 1
28734 if (_.isUndefined(by)) {
28735 by = 1;
28736 }
28737 $add[prop] = by;
28738 }
28739 data[ADD_ACTION] = $add;
28740
28741 return this._send_request(data, callback);
28742 });
28743
28744 /*
28745 * Append a value to a list-valued people analytics property.
28746 *
28747 * ### Usage:
28748 *
28749 * // append a value to a list, creating it if needed
28750 * mixpanel.people.append('pages_visited', 'homepage');
28751 *
28752 * // like mixpanel.people.set(), you can append multiple
28753 * // properties at once:
28754 * mixpanel.people.append({
28755 * list1: 'bob',
28756 * list2: 123
28757 * });
28758 *
28759 * @param {Object|String} list_name If a string, this is the name of the property. If an object, this is an associative array of names and values.
28760 * @param {*} [value] value An item to append to the list
28761 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28762 */
28763 MixpanelPeople.prototype.append = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
28764 if (_.isObject(list_name)) {
28765 callback = value;
28766 }
28767 var data = this.append_action(list_name, value);
28768 return this._send_request(data, callback);
28769 });
28770
28771 /*
28772 * Remove a value from a list-valued people analytics property.
28773 *
28774 * ### Usage:
28775 *
28776 * mixpanel.people.remove('School', 'UCB');
28777 *
28778 * @param {Object|String} list_name If a string, this is the name of the property. If an object, this is an associative array of names and values.
28779 * @param {*} [value] value Item to remove from the list
28780 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28781 */
28782 MixpanelPeople.prototype.remove = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
28783 if (_.isObject(list_name)) {
28784 callback = value;
28785 }
28786 var data = this.remove_action(list_name, value);
28787 return this._send_request(data, callback);
28788 });
28789
28790 /*
28791 * Merge a given list with a list-valued people analytics property,
28792 * excluding duplicate values.
28793 *
28794 * ### Usage:
28795 *
28796 * // merge a value to a list, creating it if needed
28797 * mixpanel.people.union('pages_visited', 'homepage');
28798 *
28799 * // like mixpanel.people.set(), you can append multiple
28800 * // properties at once:
28801 * mixpanel.people.union({
28802 * list1: 'bob',
28803 * list2: 123
28804 * });
28805 *
28806 * // like mixpanel.people.append(), you can append multiple
28807 * // values to the same list:
28808 * mixpanel.people.union({
28809 * list1: ['bob', 'billy']
28810 * });
28811 *
28812 * @param {Object|String} list_name If a string, this is the name of the property. If an object, this is an associative array of names and values.
28813 * @param {*} [value] Value / values to merge with the given property
28814 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28815 */
28816 MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name, values, callback) {
28817 if (_.isObject(list_name)) {
28818 callback = values;
28819 }
28820 var data = this.union_action(list_name, values);
28821 return this._send_request(data, callback);
28822 });
28823
28824 /*
28825 * Record that you have charged the current user a certain amount
28826 * of money. Charges recorded with track_charge() will appear in the
28827 * Mixpanel revenue report.
28828 *
28829 * ### Usage:
28830 *
28831 * // charge a user $50
28832 * mixpanel.people.track_charge(50);
28833 *
28834 * // charge a user $30.50 on the 2nd of january
28835 * mixpanel.people.track_charge(30.50, {
28836 * '$time': new Date('jan 1 2012')
28837 * });
28838 *
28839 * @param {Number} amount The amount of money charged to the current user
28840 * @param {Object} [properties] An associative array of properties associated with the charge
28841 * @param {Function} [callback] If provided, the callback will be called when the server responds
28842 * @deprecated
28843 */
28844 MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
28845 console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
28846 });
28847
28848 /*
28849 * Permanently clear all revenue report transactions from the
28850 * current user's people analytics profile.
28851 *
28852 * ### Usage:
28853 *
28854 * mixpanel.people.clear_charges();
28855 *
28856 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28857 * @deprecated
28858 */
28859 MixpanelPeople.prototype.clear_charges = function(callback) {
28860 return this.set('$transactions', [], callback);
28861 };
28862
28863 /*
28864 * Permanently deletes the current people analytics profile from
28865 * Mixpanel (using the current distinct_id).
28866 *
28867 * ### Usage:
28868 *
28869 * // remove the all data you have stored about the current user
28870 * mixpanel.people.delete_user();
28871 *
28872 */
28873 MixpanelPeople.prototype.delete_user = function() {
28874 if (!this._identify_called()) {
28875 console$1.error('mixpanel.people.delete_user() requires you to call identify() first');
28876 return;
28877 }
28878 var data = {'$delete': this._mixpanel.get_distinct_id()};
28879 return this._send_request(data);
28880 };
28881
28882 MixpanelPeople.prototype.toString = function() {
28883 return this._mixpanel.toString() + '.people';
28884 };
28885
28886 MixpanelPeople.prototype._send_request = function(data, callback) {
28887 data['$token'] = this._get_config('token');
28888 data['$distinct_id'] = this._mixpanel.get_distinct_id();
28889 var device_id = this._mixpanel.get_property('$device_id');
28890 var user_id = this._mixpanel.get_property('$user_id');
28891 var had_persisted_distinct_id = this._mixpanel.get_property('$had_persisted_distinct_id');
28892 if (device_id) {
28893 data['$device_id'] = device_id;
28894 }
28895 if (user_id) {
28896 data['$user_id'] = user_id;
28897 }
28898 if (had_persisted_distinct_id) {
28899 data['$had_persisted_distinct_id'] = had_persisted_distinct_id;
28900 }
28901
28902 var date_encoded_data = _.encodeDates(data);
28903
28904 if (!this._identify_called()) {
28905 this._enqueue(data);
28906 if (!_.isUndefined(callback)) {
28907 if (this._get_config('verbose')) {
28908 callback({status: -1, error: null});
28909 } else {
28910 callback(-1);
28911 }
28912 }
28913 return _.truncate(date_encoded_data, 255);
28914 }
28915
28916 return this._mixpanel._track_or_batch({
28917 type: 'people',
28918 data: date_encoded_data,
28919 endpoint: this._mixpanel.get_api_host('people') + '/' + this._get_config('api_routes')['engage'],
28920 batcher: this._mixpanel.request_batchers.people
28921 }, callback);
28922 };
28923
28924 MixpanelPeople.prototype._get_config = function(conf_var) {
28925 return this._mixpanel.get_config(conf_var);
28926 };
28927
28928 MixpanelPeople.prototype._identify_called = function() {
28929 return this._mixpanel._flags.identify_called === true;
28930 };
28931
28932 // Queue up engage operations if identify hasn't been called yet.
28933 MixpanelPeople.prototype._enqueue = function(data) {
28934 if (SET_ACTION in data) {
28935 this._mixpanel['persistence']._add_to_people_queue(SET_ACTION, data);
28936 } else if (SET_ONCE_ACTION in data) {
28937 this._mixpanel['persistence']._add_to_people_queue(SET_ONCE_ACTION, data);
28938 } else if (UNSET_ACTION in data) {
28939 this._mixpanel['persistence']._add_to_people_queue(UNSET_ACTION, data);
28940 } else if (ADD_ACTION in data) {
28941 this._mixpanel['persistence']._add_to_people_queue(ADD_ACTION, data);
28942 } else if (APPEND_ACTION in data) {
28943 this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, data);
28944 } else if (REMOVE_ACTION in data) {
28945 this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, data);
28946 } else if (UNION_ACTION in data) {
28947 this._mixpanel['persistence']._add_to_people_queue(UNION_ACTION, data);
28948 } else {
28949 console$1.error('Invalid call to _enqueue():', data);
28950 }
28951 };
28952
28953 MixpanelPeople.prototype._flush_one_queue = function(action, action_method, callback, queue_to_params_fn) {
28954 var _this = this;
28955 var queued_data = _.extend({}, this._mixpanel['persistence'].load_queue(action));
28956 var action_params = queued_data;
28957
28958 if (!_.isUndefined(queued_data) && _.isObject(queued_data) && !_.isEmptyObject(queued_data)) {
28959 _this._mixpanel['persistence']._pop_from_people_queue(action, queued_data);
28960 _this._mixpanel['persistence'].save();
28961 if (queue_to_params_fn) {
28962 action_params = queue_to_params_fn(queued_data);
28963 }
28964 action_method.call(_this, action_params, function(response, data) {
28965 // on bad response, we want to add it back to the queue
28966 if (response === 0) {
28967 _this._mixpanel['persistence']._add_to_people_queue(action, queued_data);
28968 }
28969 if (!_.isUndefined(callback)) {
28970 callback(response, data);
28971 }
28972 });
28973 }
28974 };
28975
28976 // Flush queued engage operations - order does not matter,
28977 // and there are network level race conditions anyway
28978 MixpanelPeople.prototype._flush = function(
28979 _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
28980 ) {
28981 var _this = this;
28982
28983 this._flush_one_queue(SET_ACTION, this.set, _set_callback);
28984 this._flush_one_queue(SET_ONCE_ACTION, this.set_once, _set_once_callback);
28985 this._flush_one_queue(UNSET_ACTION, this.unset, _unset_callback, function(queue) { return _.keys(queue); });
28986 this._flush_one_queue(ADD_ACTION, this.increment, _add_callback);
28987 this._flush_one_queue(UNION_ACTION, this.union, _union_callback);
28988
28989 // we have to fire off each $append individually since there is
28990 // no concat method server side
28991 var $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
28992 if (!_.isUndefined($append_queue) && _.isArray($append_queue) && $append_queue.length) {
28993 var $append_item;
28994 var append_callback = function(response, data) {
28995 if (response === 0) {
28996 _this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, $append_item);
28997 }
28998 if (!_.isUndefined(_append_callback)) {
28999 _append_callback(response, data);
29000 }
29001 };
29002 for (var i = $append_queue.length - 1; i >= 0; i--) {
29003 $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29004 $append_item = $append_queue.pop();
29005 _this._mixpanel['persistence'].save();
29006 if (!_.isEmptyObject($append_item)) {
29007 _this.append($append_item, append_callback);
29008 }
29009 }
29010 }
29011
29012 // same for $remove
29013 var $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29014 if (!_.isUndefined($remove_queue) && _.isArray($remove_queue) && $remove_queue.length) {
29015 var $remove_item;
29016 var remove_callback = function(response, data) {
29017 if (response === 0) {
29018 _this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, $remove_item);
29019 }
29020 if (!_.isUndefined(_remove_callback)) {
29021 _remove_callback(response, data);
29022 }
29023 };
29024 for (var j = $remove_queue.length - 1; j >= 0; j--) {
29025 $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29026 $remove_item = $remove_queue.pop();
29027 _this._mixpanel['persistence'].save();
29028 if (!_.isEmptyObject($remove_item)) {
29029 _this.remove($remove_item, remove_callback);
29030 }
29031 }
29032 }
29033 };
29034
29035 MixpanelPeople.prototype._is_reserved_property = function(prop) {
29036 return prop === '$distinct_id' || prop === '$token' || prop === '$device_id' || prop === '$user_id' || prop === '$had_persisted_distinct_id';
29037 };
29038
29039 // MixpanelPeople Exports
29040 MixpanelPeople.prototype['set'] = MixpanelPeople.prototype.set;
29041 MixpanelPeople.prototype['set_once'] = MixpanelPeople.prototype.set_once;
29042 MixpanelPeople.prototype['unset'] = MixpanelPeople.prototype.unset;
29043 MixpanelPeople.prototype['increment'] = MixpanelPeople.prototype.increment;
29044 MixpanelPeople.prototype['append'] = MixpanelPeople.prototype.append;
29045 MixpanelPeople.prototype['remove'] = MixpanelPeople.prototype.remove;
29046 MixpanelPeople.prototype['union'] = MixpanelPeople.prototype.union;
29047 MixpanelPeople.prototype['track_charge'] = MixpanelPeople.prototype.track_charge;
29048 MixpanelPeople.prototype['clear_charges'] = MixpanelPeople.prototype.clear_charges;
29049 MixpanelPeople.prototype['delete_user'] = MixpanelPeople.prototype.delete_user;
29050 MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
29051
29052 /* eslint camelcase: "off" */
29053
29054
29055 /*
29056 * Constants
29057 */
29058 /** @const */ var SET_QUEUE_KEY = '__mps';
29059 /** @const */ var SET_ONCE_QUEUE_KEY = '__mpso';
29060 /** @const */ var UNSET_QUEUE_KEY = '__mpus';
29061 /** @const */ var ADD_QUEUE_KEY = '__mpa';
29062 /** @const */ var APPEND_QUEUE_KEY = '__mpap';
29063 /** @const */ var REMOVE_QUEUE_KEY = '__mpr';
29064 /** @const */ var UNION_QUEUE_KEY = '__mpu';
29065 // This key is deprecated, but we want to check for it to see whether aliasing is allowed.
29066 /** @const */ var PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id';
29067 /** @const */ var ALIAS_ID_KEY = '__alias';
29068 /** @const */ var EVENT_TIMERS_KEY = '__timers';
29069 /** @const */ var RESERVED_PROPERTIES = [
29070 SET_QUEUE_KEY,
29071 SET_ONCE_QUEUE_KEY,
29072 UNSET_QUEUE_KEY,
29073 ADD_QUEUE_KEY,
29074 APPEND_QUEUE_KEY,
29075 REMOVE_QUEUE_KEY,
29076 UNION_QUEUE_KEY,
29077 PEOPLE_DISTINCT_ID_KEY,
29078 ALIAS_ID_KEY,
29079 EVENT_TIMERS_KEY
29080 ];
29081
29082 /**
29083 * Mixpanel Persistence Object
29084 * @constructor
29085 */
29086 var MixpanelPersistence = function(config) {
29087 this['props'] = {};
29088 this.campaign_params_saved = false;
29089
29090 if (config['persistence_name']) {
29091 this.name = 'mp_' + config['persistence_name'];
29092 } else {
29093 this.name = 'mp_' + config['token'] + '_mixpanel';
29094 }
29095
29096 var storage_type = config['persistence'];
29097 if (storage_type !== 'cookie' && storage_type !== 'localStorage') {
29098 console$1.critical('Unknown persistence type ' + storage_type + '; falling back to cookie');
29099 storage_type = config['persistence'] = 'cookie';
29100 }
29101
29102 if (storage_type === 'localStorage' && _.localStorage.is_supported()) {
29103 this.storage = _.localStorage;
29104 } else {
29105 this.storage = _.cookie;
29106 }
29107
29108 this.load();
29109 this.update_config(config);
29110 this.upgrade();
29111 this.save();
29112 };
29113
29114 MixpanelPersistence.prototype.properties = function() {
29115 var p = {};
29116
29117 this.load();
29118
29119 // Filter out reserved properties
29120 _.each(this['props'], function(v, k) {
29121 if (!_.include(RESERVED_PROPERTIES, k)) {
29122 p[k] = v;
29123 }
29124 });
29125 return p;
29126 };
29127
29128 MixpanelPersistence.prototype.load = function() {
29129 if (this.disabled) { return; }
29130
29131 var entry = this.storage.parse(this.name);
29132
29133 if (entry) {
29134 this['props'] = _.extend({}, entry);
29135 }
29136 };
29137
29138 MixpanelPersistence.prototype.upgrade = function() {
29139 var old_cookie,
29140 old_localstorage;
29141
29142 // if transferring from cookie to localStorage or vice-versa, copy existing
29143 // super properties over to new storage mode
29144 if (this.storage === _.localStorage) {
29145 old_cookie = _.cookie.parse(this.name);
29146
29147 _.cookie.remove(this.name);
29148 _.cookie.remove(this.name, true);
29149
29150 if (old_cookie) {
29151 this.register_once(old_cookie);
29152 }
29153 } else if (this.storage === _.cookie) {
29154 old_localstorage = _.localStorage.parse(this.name);
29155
29156 _.localStorage.remove(this.name);
29157
29158 if (old_localstorage) {
29159 this.register_once(old_localstorage);
29160 }
29161 }
29162 };
29163
29164 MixpanelPersistence.prototype.save = function() {
29165 if (this.disabled) { return; }
29166
29167 this.storage.set(
29168 this.name,
29169 JSONStringify(this['props']),
29170 this.expire_days,
29171 this.cross_subdomain,
29172 this.secure,
29173 this.cross_site,
29174 this.cookie_domain
29175 );
29176 };
29177
29178 MixpanelPersistence.prototype.load_prop = function(key) {
29179 this.load();
29180 return this['props'][key];
29181 };
29182
29183 MixpanelPersistence.prototype.remove = function() {
29184 // remove both domain and subdomain cookies
29185 this.storage.remove(this.name, false, this.cookie_domain);
29186 this.storage.remove(this.name, true, this.cookie_domain);
29187 };
29188
29189 // removes the storage entry and deletes all loaded data
29190 // forced name for tests
29191 MixpanelPersistence.prototype.clear = function() {
29192 this.remove();
29193 this['props'] = {};
29194 };
29195
29196 /**
29197 * @param {Object} props
29198 * @param {*=} default_value
29199 * @param {number=} days
29200 */
29201 MixpanelPersistence.prototype.register_once = function(props, default_value, days) {
29202 if (_.isObject(props)) {
29203 if (typeof(default_value) === 'undefined') { default_value = 'None'; }
29204 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29205
29206 this.load();
29207
29208 _.each(props, function(val, prop) {
29209 if (!this['props'].hasOwnProperty(prop) || this['props'][prop] === default_value) {
29210 this['props'][prop] = val;
29211 }
29212 }, this);
29213
29214 this.save();
29215
29216 return true;
29217 }
29218 return false;
29219 };
29220
29221 /**
29222 * @param {Object} props
29223 * @param {number=} days
29224 */
29225 MixpanelPersistence.prototype.register = function(props, days) {
29226 if (_.isObject(props)) {
29227 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29228
29229 this.load();
29230 _.extend(this['props'], props);
29231 this.save();
29232
29233 return true;
29234 }
29235 return false;
29236 };
29237
29238 MixpanelPersistence.prototype.unregister = function(prop) {
29239 this.load();
29240 if (prop in this['props']) {
29241 delete this['props'][prop];
29242 this.save();
29243 }
29244 };
29245
29246 MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
29247 this.register(_.info.searchInfo(referrer));
29248 };
29249
29250 // EXPORTED METHOD, we test this directly.
29251 MixpanelPersistence.prototype.update_referrer_info = function(referrer) {
29252 // If referrer doesn't exist, we want to note the fact that it was type-in traffic.
29253 this.register_once({
29254 '$initial_referrer': referrer || '$direct',
29255 '$initial_referring_domain': _.info.referringDomain(referrer) || '$direct'
29256 }, '');
29257 };
29258
29259 MixpanelPersistence.prototype.get_referrer_info = function() {
29260 return _.strip_empty_properties({
29261 '$initial_referrer': this['props']['$initial_referrer'],
29262 '$initial_referring_domain': this['props']['$initial_referring_domain']
29263 });
29264 };
29265
29266 MixpanelPersistence.prototype.update_config = function(config) {
29267 this.default_expiry = this.expire_days = config['cookie_expiration'];
29268 this.set_disabled(config['disable_persistence']);
29269 this.set_cookie_domain(config['cookie_domain']);
29270 this.set_cross_site(config['cross_site_cookie']);
29271 this.set_cross_subdomain(config['cross_subdomain_cookie']);
29272 this.set_secure(config['secure_cookie']);
29273 };
29274
29275 MixpanelPersistence.prototype.set_disabled = function(disabled) {
29276 this.disabled = disabled;
29277 if (this.disabled) {
29278 this.remove();
29279 } else {
29280 this.save();
29281 }
29282 };
29283
29284 MixpanelPersistence.prototype.set_cookie_domain = function(cookie_domain) {
29285 if (cookie_domain !== this.cookie_domain) {
29286 this.remove();
29287 this.cookie_domain = cookie_domain;
29288 this.save();
29289 }
29290 };
29291
29292 MixpanelPersistence.prototype.set_cross_site = function(cross_site) {
29293 if (cross_site !== this.cross_site) {
29294 this.cross_site = cross_site;
29295 this.remove();
29296 this.save();
29297 }
29298 };
29299
29300 MixpanelPersistence.prototype.set_cross_subdomain = function(cross_subdomain) {
29301 if (cross_subdomain !== this.cross_subdomain) {
29302 this.cross_subdomain = cross_subdomain;
29303 this.remove();
29304 this.save();
29305 }
29306 };
29307
29308 MixpanelPersistence.prototype.get_cross_subdomain = function() {
29309 return this.cross_subdomain;
29310 };
29311
29312 MixpanelPersistence.prototype.set_secure = function(secure) {
29313 if (secure !== this.secure) {
29314 this.secure = secure ? true : false;
29315 this.remove();
29316 this.save();
29317 }
29318 };
29319
29320 MixpanelPersistence.prototype._add_to_people_queue = function(queue, data) {
29321 var q_key = this._get_queue_key(queue),
29322 q_data = data[queue],
29323 set_q = this._get_or_create_queue(SET_ACTION),
29324 set_once_q = this._get_or_create_queue(SET_ONCE_ACTION),
29325 unset_q = this._get_or_create_queue(UNSET_ACTION),
29326 add_q = this._get_or_create_queue(ADD_ACTION),
29327 union_q = this._get_or_create_queue(UNION_ACTION),
29328 remove_q = this._get_or_create_queue(REMOVE_ACTION, []),
29329 append_q = this._get_or_create_queue(APPEND_ACTION, []);
29330
29331 if (q_key === SET_QUEUE_KEY) {
29332 // Update the set queue - we can override any existing values
29333 _.extend(set_q, q_data);
29334 // if there was a pending increment, override it
29335 // with the set.
29336 this._pop_from_people_queue(ADD_ACTION, q_data);
29337 // if there was a pending union, override it
29338 // with the set.
29339 this._pop_from_people_queue(UNION_ACTION, q_data);
29340 this._pop_from_people_queue(UNSET_ACTION, q_data);
29341 } else if (q_key === SET_ONCE_QUEUE_KEY) {
29342 // only queue the data if there is not already a set_once call for it.
29343 _.each(q_data, function(v, k) {
29344 if (!(k in set_once_q)) {
29345 set_once_q[k] = v;
29346 }
29347 });
29348 this._pop_from_people_queue(UNSET_ACTION, q_data);
29349 } else if (q_key === UNSET_QUEUE_KEY) {
29350 _.each(q_data, function(prop) {
29351
29352 // undo previously-queued actions on this key
29353 _.each([set_q, set_once_q, add_q, union_q], function(enqueued_obj) {
29354 if (prop in enqueued_obj) {
29355 delete enqueued_obj[prop];
29356 }
29357 });
29358 _.each(append_q, function(append_obj) {
29359 if (prop in append_obj) {
29360 delete append_obj[prop];
29361 }
29362 });
29363
29364 unset_q[prop] = true;
29365
29366 });
29367 } else if (q_key === ADD_QUEUE_KEY) {
29368 _.each(q_data, function(v, k) {
29369 // If it exists in the set queue, increment
29370 // the value
29371 if (k in set_q) {
29372 set_q[k] += v;
29373 } else {
29374 // If it doesn't exist, update the add
29375 // queue
29376 if (!(k in add_q)) {
29377 add_q[k] = 0;
29378 }
29379 add_q[k] += v;
29380 }
29381 }, this);
29382 this._pop_from_people_queue(UNSET_ACTION, q_data);
29383 } else if (q_key === UNION_QUEUE_KEY) {
29384 _.each(q_data, function(v, k) {
29385 if (_.isArray(v)) {
29386 if (!(k in union_q)) {
29387 union_q[k] = [];
29388 }
29389 // Prevent duplicate values
29390 _.each(v, function(item) {
29391 if (!_.include(union_q[k], item)) {
29392 union_q[k].push(item);
29393 }
29394 });
29395 }
29396 });
29397 this._pop_from_people_queue(UNSET_ACTION, q_data);
29398 } else if (q_key === REMOVE_QUEUE_KEY) {
29399 remove_q.push(q_data);
29400 this._pop_from_people_queue(APPEND_ACTION, q_data);
29401 } else if (q_key === APPEND_QUEUE_KEY) {
29402 append_q.push(q_data);
29403 this._pop_from_people_queue(UNSET_ACTION, q_data);
29404 }
29405
29406 console$1.log('MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):');
29407 console$1.log(data);
29408
29409 this.save();
29410 };
29411
29412 MixpanelPersistence.prototype._pop_from_people_queue = function(queue, data) {
29413 var q = this['props'][this._get_queue_key(queue)];
29414 if (!_.isUndefined(q)) {
29415 _.each(data, function(v, k) {
29416 if (queue === APPEND_ACTION || queue === REMOVE_ACTION) {
29417 // list actions: only remove if both k+v match
29418 // e.g. remove should not override append in a case like
29419 // append({foo: 'bar'}); remove({foo: 'qux'})
29420 _.each(q, function(queued_action) {
29421 if (queued_action[k] === v) {
29422 delete queued_action[k];
29423 }
29424 });
29425 } else {
29426 delete q[k];
29427 }
29428 }, this);
29429 }
29430 };
29431
29432 MixpanelPersistence.prototype.load_queue = function(queue) {
29433 return this.load_prop(this._get_queue_key(queue));
29434 };
29435
29436 MixpanelPersistence.prototype._get_queue_key = function(queue) {
29437 if (queue === SET_ACTION) {
29438 return SET_QUEUE_KEY;
29439 } else if (queue === SET_ONCE_ACTION) {
29440 return SET_ONCE_QUEUE_KEY;
29441 } else if (queue === UNSET_ACTION) {
29442 return UNSET_QUEUE_KEY;
29443 } else if (queue === ADD_ACTION) {
29444 return ADD_QUEUE_KEY;
29445 } else if (queue === APPEND_ACTION) {
29446 return APPEND_QUEUE_KEY;
29447 } else if (queue === REMOVE_ACTION) {
29448 return REMOVE_QUEUE_KEY;
29449 } else if (queue === UNION_ACTION) {
29450 return UNION_QUEUE_KEY;
29451 } else {
29452 console$1.error('Invalid queue:', queue);
29453 }
29454 };
29455
29456 MixpanelPersistence.prototype._get_or_create_queue = function(queue, default_val) {
29457 var key = this._get_queue_key(queue);
29458 default_val = _.isUndefined(default_val) ? {} : default_val;
29459 return this['props'][key] || (this['props'][key] = default_val);
29460 };
29461
29462 MixpanelPersistence.prototype.set_event_timer = function(event_name, timestamp) {
29463 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29464 timers[event_name] = timestamp;
29465 this['props'][EVENT_TIMERS_KEY] = timers;
29466 this.save();
29467 };
29468
29469 MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
29470 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29471 var timestamp = timers[event_name];
29472 if (!_.isUndefined(timestamp)) {
29473 delete this['props'][EVENT_TIMERS_KEY][event_name];
29474 this.save();
29475 }
29476 return timestamp;
29477 };
29478
29479 /* eslint camelcase: "off" */
29480
29481 /*
29482 * Mixpanel JS Library
29483 *
29484 * Copyright 2012, Mixpanel, Inc. All Rights Reserved
29485 * http://mixpanel.com/
29486 *
29487 * Includes portions of Underscore.js
29488 * http://documentcloud.github.com/underscore/
29489 * (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
29490 * Released under the MIT License.
29491 */
29492
29493 /*
29494 SIMPLE STYLE GUIDE:
29495
29496 this.x === public function
29497 this._x === internal - only use within this file
29498 this.__x === private - only use within the class
29499
29500 Globals should be all caps
29501 */
29502
29503 var init_type; // MODULE or SNIPPET loader
29504 // allow bundlers to specify how extra code (recorder bundle) should be loaded
29505 // eslint-disable-next-line no-unused-vars
29506 var load_extra_bundle = function(src, _onload) {
29507 throw new Error(src + ' not available in this build.');
29508 };
29509
29510 var mixpanel_master; // main mixpanel instance / object
29511 var INIT_MODULE = 0;
29512 var INIT_SNIPPET = 1;
29513
29514 var IDENTITY_FUNC = function(x) {return x;};
29515
29516 /** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
29517 /** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
29518 /** @const */ var PAYLOAD_TYPE_JSON = 'json';
29519 /** @const */ var DEVICE_ID_PREFIX = '$device:';
29520
29521
29522 /*
29523 * Dynamic... constants? Is that an oxymoron?
29524 */
29525 // http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
29526 // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#withCredentials
29527 var USE_XHR = (win.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest());
29528
29529 // IE<10 does not support cross-origin XHR's but script tags
29530 // with defer won't block window.onload; ENQUEUE_REQUESTS
29531 // should only be true for Opera<12
29532 var ENQUEUE_REQUESTS = !USE_XHR && (userAgent.indexOf('MSIE') === -1) && (userAgent.indexOf('Mozilla') === -1);
29533
29534 // save reference to navigator.sendBeacon so it can be minified
29535 var sendBeacon = null;
29536 if (navigator['sendBeacon']) {
29537 sendBeacon = function() {
29538 // late reference to navigator.sendBeacon to allow patching/spying
29539 return navigator['sendBeacon'].apply(navigator, arguments);
29540 };
29541 }
29542
29543 var DEFAULT_API_ROUTES = {
29544 'track': 'track/',
29545 'engage': 'engage/',
29546 'groups': 'groups/',
29547 'record': 'record/',
29548 'flags': 'flags/'
29549 };
29550
29551 /*
29552 * Module-level globals
29553 */
29554 var DEFAULT_CONFIG = {
29555 'api_host': 'https://api-js.mixpanel.com',
29556 'api_hosts': {},
29557 'api_routes': DEFAULT_API_ROUTES,
29558 'api_extra_query_params': {},
29559 'api_method': 'POST',
29560 'api_transport': 'XHR',
29561 'api_payload_format': PAYLOAD_TYPE_BASE64,
29562 'app_host': 'https://mixpanel.com',
29563 'autocapture': false,
29564 'cdn': 'https://cdn.mxpnl.com',
29565 'cross_site_cookie': false,
29566 'cross_subdomain_cookie': true,
29567 'error_reporter': NOOP_FUNC,
29568 'flags': false,
29569 'persistence': 'cookie',
29570 'persistence_name': '',
29571 'cookie_domain': '',
29572 'cookie_name': '',
29573 'loaded': NOOP_FUNC,
29574 'mp_loader': null,
29575 'track_marketing': true,
29576 'track_pageview': false,
29577 'skip_first_touch_marketing': false,
29578 'store_google': true,
29579 'stop_utm_persistence': false,
29580 'save_referrer': true,
29581 'test': false,
29582 'verbose': false,
29583 'img': false,
29584 'debug': false,
29585 'track_links_timeout': 300,
29586 'cookie_expiration': 365,
29587 'upgrade': false,
29588 'disable_persistence': false,
29589 'disable_cookie': false,
29590 'secure_cookie': false,
29591 'ip': true,
29592 'opt_out_tracking_by_default': false,
29593 'opt_out_persistence_by_default': false,
29594 'opt_out_tracking_persistence_type': 'localStorage',
29595 'opt_out_tracking_cookie_prefix': null,
29596 'property_blacklist': [],
29597 'xhr_headers': {}, // { header: value, header2: value }
29598 'ignore_dnt': false,
29599 'batch_requests': true,
29600 'batch_size': 50,
29601 'batch_flush_interval_ms': 5000,
29602 'batch_request_timeout_ms': 90000,
29603 'batch_autostart': true,
29604 'hooks': {},
29605 'record_block_class': new RegExp('^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$'),
29606 'record_block_selector': 'img, video, audio',
29607 'record_canvas': false,
29608 'record_collect_fonts': false,
29609 'record_heatmap_data': false,
29610 'record_idle_timeout_ms': 30 * 60 * 1000, // 30 minutes
29611 'record_mask_text_class': new RegExp('^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$'),
29612 'record_mask_text_selector': '*',
29613 'record_max_ms': MAX_RECORDING_MS,
29614 'record_min_ms': 0,
29615 'record_sessions_percent': 0,
29616 'recorder_src': 'https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js'
29617 };
29618
29619 var DOM_LOADED = false;
29620
29621 /**
29622 * Mixpanel Library Object
29623 * @constructor
29624 */
29625 var MixpanelLib = function() {};
29626
29627
29628 /**
29629 * create_mplib(token:string, config:object, name:string)
29630 *
29631 * This function is used by the init method of MixpanelLib objects
29632 * as well as the main initializer at the end of the JSLib (that
29633 * initializes document.mixpanel as well as any additional instances
29634 * declared before this file has loaded).
29635 */
29636 var create_mplib = function(token, config, name) {
29637 var instance,
29638 target = (name === PRIMARY_INSTANCE_NAME) ? mixpanel_master : mixpanel_master[name];
29639
29640 if (target && init_type === INIT_MODULE) {
29641 instance = target;
29642 } else {
29643 if (target && !_.isArray(target)) {
29644 console$1.error('You have already initialized ' + name);
29645 return;
29646 }
29647 instance = new MixpanelLib();
29648 }
29649
29650 instance._cached_groups = {}; // cache groups in a pool
29651
29652 instance._init(token, config, name);
29653
29654 instance['people'] = new MixpanelPeople();
29655 instance['people']._init(instance);
29656
29657 if (!instance.get_config('skip_first_touch_marketing')) {
29658 // We need null UTM params in the object because
29659 // UTM parameters act as a tuple. If any UTM param
29660 // is present, then we set all UTM params including
29661 // empty ones together
29662 var utm_params = _.info.campaignParams(null);
29663 var initial_utm_params = {};
29664 var has_utm = false;
29665 _.each(utm_params, function(utm_value, utm_key) {
29666 initial_utm_params['initial_' + utm_key] = utm_value;
29667 if (utm_value) {
29668 has_utm = true;
29669 }
29670 });
29671 if (has_utm) {
29672 instance['people'].set_once(initial_utm_params);
29673 }
29674 }
29675
29676 // if any instance on the page has debug = true, we set the
29677 // global debug to be true
29678 Config.DEBUG = Config.DEBUG || instance.get_config('debug');
29679
29680 // if target is not defined, we called init after the lib already
29681 // loaded, so there won't be an array of things to execute
29682 if (!_.isUndefined(target) && _.isArray(target)) {
29683 // Crunch through the people queue first - we queue this data up &
29684 // flush on identify, so it's better to do all these operations first
29685 instance._execute_array.call(instance['people'], target['people']);
29686 instance._execute_array(target);
29687 }
29688
29689 return instance;
29690 };
29691
29692 // Initialization methods
29693
29694 /**
29695 * This function initializes a new instance of the Mixpanel tracking object.
29696 * All new instances are added to the main mixpanel object as sub properties (such as
29697 * mixpanel.library_name) and also returned by this function. To define a
29698 * second instance on the page, you would call:
29699 *
29700 * mixpanel.init('new token', { your: 'config' }, 'library_name');
29701 *
29702 * and use it like so:
29703 *
29704 * mixpanel.library_name.track(...);
29705 *
29706 * @param {String} token Your Mixpanel API token
29707 * @param {Object} [config] A dictionary of config options to override. <a href="https://github.com/mixpanel/mixpanel-js/blob/v2.46.0/src/mixpanel-core.js#L88-L127">See a list of default config options</a>.
29708 * @param {String} [name] The name for the new mixpanel instance that you want created
29709 */
29710 MixpanelLib.prototype.init = function (token, config, name) {
29711 if (_.isUndefined(name)) {
29712 this.report_error('You must name your new library: init(token, config, name)');
29713 return;
29714 }
29715 if (name === PRIMARY_INSTANCE_NAME) {
29716 this.report_error('You must initialize the main mixpanel object right after you include the Mixpanel js snippet');
29717 return;
29718 }
29719
29720 var instance = create_mplib(token, config, name);
29721 mixpanel_master[name] = instance;
29722 instance._loaded();
29723
29724 return instance;
29725 };
29726
29727 // mixpanel._init(token:string, config:object, name:string)
29728 //
29729 // This function sets up the current instance of the mixpanel
29730 // library. The difference between this method and the init(...)
29731 // method is this one initializes the actual instance, whereas the
29732 // init(...) method sets up a new library and calls _init on it.
29733 //
29734 MixpanelLib.prototype._init = function(token, config, name) {
29735 config = config || {};
29736
29737 this['__loaded'] = true;
29738 this['config'] = {};
29739
29740 var variable_features = {};
29741
29742 // default to JSON payload for standard mixpanel.com API hosts
29743 if (!('api_payload_format' in config)) {
29744 var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
29745 if (api_host.match(/\.mixpanel\.com/)) {
29746 variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
29747 }
29748 }
29749
29750 this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
29751 'name': name,
29752 'token': token,
29753 'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
29754 }));
29755
29756 this['_jsc'] = NOOP_FUNC;
29757
29758 this.__dom_loaded_queue = [];
29759 this.__request_queue = [];
29760 this.__disabled_events = [];
29761 this._flags = {
29762 'disable_all_events': false,
29763 'identify_called': false
29764 };
29765
29766 // set up request queueing/batching
29767 this.request_batchers = {};
29768 this._batch_requests = this.get_config('batch_requests');
29769 if (this._batch_requests) {
29770 if (!_.localStorage.is_supported(true) || !USE_XHR) {
29771 this._batch_requests = false;
29772 console$1.log('Turning off Mixpanel request-queueing; needs XHR and localStorage support');
29773 _.each(this.get_batcher_configs(), function(batcher_config) {
29774 console$1.log('Clearing batch queue ' + batcher_config.queue_key);
29775 _.localStorage.remove(batcher_config.queue_key);
29776 });
29777 } else {
29778 this.init_batchers();
29779 if (sendBeacon && win.addEventListener) {
29780 // Before page closes or hides (user tabs away etc), attempt to flush any events
29781 // queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
29782 // events will not be removed from the persistent store; if the site is loaded again,
29783 // the events will be flushed again on startup and deduplicated on the Mixpanel server
29784 // side.
29785 // There is no reliable way to capture only page close events, so we lean on the
29786 // visibilitychange and pagehide events as recommended at
29787 // https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event#usage_notes.
29788 // These events fire when the user clicks away from the current page/tab, so will occur
29789 // more frequently than page unload, but are the only mechanism currently for capturing
29790 // this scenario somewhat reliably.
29791 var flush_on_unload = _.bind(function() {
29792 if (!this.request_batchers.events.stopped) {
29793 this.request_batchers.events.flush({unloading: true});
29794 }
29795 }, this);
29796 win.addEventListener('pagehide', function(ev) {
29797 if (ev['persisted']) {
29798 flush_on_unload();
29799 }
29800 });
29801 win.addEventListener('visibilitychange', function() {
29802 if (document$1['visibilityState'] === 'hidden') {
29803 flush_on_unload();
29804 }
29805 });
29806 }
29807 }
29808 }
29809
29810 this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config']);
29811 this.unpersisted_superprops = {};
29812 this._gdpr_init();
29813
29814 var uuid = _.UUID();
29815 if (!this.get_distinct_id()) {
29816 // There is no need to set the distinct id
29817 // or the device id if something was already stored
29818 // in the persitence
29819 this.register_once({
29820 'distinct_id': DEVICE_ID_PREFIX + uuid,
29821 '$device_id': uuid
29822 }, '');
29823 }
29824
29825 this.flags = new FeatureFlagManager({
29826 getFullApiRoute: _.bind(function() {
29827 return this.get_api_host('flags') + '/' + this.get_config('api_routes')['flags'];
29828 }, this),
29829 getConfigFunc: _.bind(this.get_config, this),
29830 setConfigFunc: _.bind(this.set_config, this),
29831 getPropertyFunc: _.bind(this.get_property, this),
29832 trackingFunc: _.bind(this.track, this)
29833 });
29834 this.flags.init();
29835 this['flags'] = this.flags;
29836
29837 this.autocapture = new Autocapture(this);
29838 this.autocapture.init();
29839
29840 this._init_tab_id();
29841 this._check_and_start_session_recording();
29842 };
29843
29844 /**
29845 * Assigns a unique UUID to this tab / window by leveraging sessionStorage.
29846 * This is primarily used for session recording, where data must be isolated to the current tab.
29847 */
29848 MixpanelLib.prototype._init_tab_id = function() {
29849 if (this.get_config('disable_persistence')) {
29850 console$1.log('Tab ID initialization skipped due to disable_persistence config');
29851 } else if (_.sessionStorage.is_supported()) {
29852 try {
29853 var key_suffix = this.get_config('name') + '_' + this.get_config('token');
29854 var tab_id_key = 'mp_tab_id_' + key_suffix;
29855
29856 // A flag is used to determine if sessionStorage is copied over and we need to generate a new tab ID.
29857 // This enforces a unique ID in the cases like duplicated tab, window.open(...)
29858 var should_generate_new_tab_id_key = 'mp_gen_new_tab_id_' + key_suffix;
29859 if (_.sessionStorage.get(should_generate_new_tab_id_key) || !_.sessionStorage.get(tab_id_key)) {
29860 _.sessionStorage.set(tab_id_key, '$tab-' + _.UUID());
29861 }
29862
29863 _.sessionStorage.set(should_generate_new_tab_id_key, '1');
29864 this.tab_id = _.sessionStorage.get(tab_id_key);
29865
29866 // Remove the flag when the tab is unloaded to indicate the stored tab ID can be reused. This event is not reliable to detect all page unloads,
29867 // but reliable in cases where the user remains in the tab e.g. a refresh or href navigation.
29868 // If the flag is absent, this indicates to the next SDK instance that we can reuse the stored tab_id.
29869 win.addEventListener('beforeunload', function () {
29870 _.sessionStorage.remove(should_generate_new_tab_id_key);
29871 });
29872 } catch(err) {
29873 this.report_error('Error initializing tab id', err);
29874 }
29875 } else {
29876 this.report_error('Session storage is not supported, cannot keep track of unique tab ID.');
29877 }
29878 };
29879
29880 MixpanelLib.prototype.get_tab_id = function () {
29881 return this.tab_id || null;
29882 };
29883
29884 MixpanelLib.prototype._should_load_recorder = function () {
29885 if (this.get_config('disable_persistence')) {
29886 console$1.log('Load recorder check skipped due to disable_persistence config');
29887 return Promise.resolve(false);
29888 }
29889
29890 var recording_registry_idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
29891 var tab_id = this.get_tab_id();
29892 return recording_registry_idb.init()
29893 .then(function () {
29894 return recording_registry_idb.getAll();
29895 })
29896 .then(function (recordings) {
29897 for (var i = 0; i < recordings.length; i++) {
29898 // if there are expired recordings in the registry, we should load the recorder to flush them
29899 // if there's a recording for this tab id, we should load the recorder to continue the recording
29900 if (isRecordingExpired(recordings[i]) || recordings[i]['tabId'] === tab_id) {
29901 return true;
29902 }
29903 }
29904 return false;
29905 })
29906 .catch(_.bind(function (err) {
29907 this.report_error('Error checking recording registry', err);
29908 }, this));
29909 };
29910
29911 MixpanelLib.prototype._check_and_start_session_recording = addOptOutCheckMixpanelLib(function(force_start) {
29912 if (!win['MutationObserver']) {
29913 console$1.critical('Browser does not support MutationObserver; skipping session recording');
29914 return;
29915 }
29916
29917 var loadRecorder = _.bind(function(startNewIfInactive) {
29918 var handleLoadedRecorder = _.bind(function() {
29919 this._recorder = this._recorder || new win['__mp_recorder'](this);
29920 this._recorder['resumeRecording'](startNewIfInactive);
29921 }, this);
29922
29923 if (_.isUndefined(win['__mp_recorder'])) {
29924 load_extra_bundle(this.get_config('recorder_src'), handleLoadedRecorder);
29925 } else {
29926 handleLoadedRecorder();
29927 }
29928 }, this);
29929
29930 /**
29931 * If the user is sampled or start_session_recording is called, we always load the recorder since it's guaranteed a recording should start.
29932 * Otherwise, if the recording registry has any records then it's likely there's a recording in progress or orphaned data that needs to be flushed.
29933 */
29934 var is_sampled = this.get_config('record_sessions_percent') > 0 && Math.random() * 100 <= this.get_config('record_sessions_percent');
29935 if (force_start || is_sampled) {
29936 loadRecorder(true);
29937 } else {
29938 this._should_load_recorder()
29939 .then(function (shouldLoad) {
29940 if (shouldLoad) {
29941 loadRecorder(false);
29942 }
29943 });
29944 }
29945 });
29946
29947 MixpanelLib.prototype.start_session_recording = function () {
29948 this._check_and_start_session_recording(true);
29949 };
29950
29951 MixpanelLib.prototype.stop_session_recording = function () {
29952 if (this._recorder) {
29953 return this._recorder['stopRecording']();
29954 }
29955 return Promise.resolve();
29956 };
29957
29958 MixpanelLib.prototype.pause_session_recording = function () {
29959 if (this._recorder) {
29960 return this._recorder['pauseRecording']();
29961 }
29962 return Promise.resolve();
29963 };
29964
29965 MixpanelLib.prototype.resume_session_recording = function () {
29966 if (this._recorder) {
29967 return this._recorder['resumeRecording']();
29968 }
29969 return Promise.resolve();
29970 };
29971
29972 MixpanelLib.prototype.is_recording_heatmap_data = function () {
29973 return this._get_session_replay_id() && this.get_config('record_heatmap_data');
29974 };
29975
29976 MixpanelLib.prototype.get_session_recording_properties = function () {
29977 var props = {};
29978 var replay_id = this._get_session_replay_id();
29979 if (replay_id) {
29980 props['$mp_replay_id'] = replay_id;
29981 }
29982 return props;
29983 };
29984
29985 MixpanelLib.prototype.get_session_replay_url = function () {
29986 var replay_url = null;
29987 var replay_id = this._get_session_replay_id();
29988 if (replay_id) {
29989 var query_params = _.HTTPBuildQuery({
29990 'replay_id': replay_id,
29991 'distinct_id': this.get_distinct_id(),
29992 'token': this.get_config('token')
29993 });
29994 replay_url = 'https://mixpanel.com/projects/replay-redirect?' + query_params;
29995 }
29996 return replay_url;
29997 };
29998
29999 MixpanelLib.prototype._get_session_replay_id = function () {
30000 var replay_id = null;
30001 if (this._recorder) {
30002 replay_id = this._recorder['replayId'];
30003 }
30004 return replay_id || null;
30005 };
30006
30007 // "private" public method to reach into the recorder in test cases
30008 MixpanelLib.prototype.__get_recorder = function () {
30009 return this._recorder;
30010 };
30011
30012 // Private methods
30013
30014 MixpanelLib.prototype._loaded = function() {
30015 this.get_config('loaded')(this);
30016 this._set_default_superprops();
30017 this['people'].set_once(this['persistence'].get_referrer_info());
30018
30019 // `store_google` is now deprecated and previously stored UTM parameters are cleared
30020 // from persistence by default.
30021 if (this.get_config('store_google') && this.get_config('stop_utm_persistence')) {
30022 var utm_params = _.info.campaignParams(null);
30023 _.each(utm_params, function(_utm_value, utm_key) {
30024 // We need to unregister persisted UTM parameters so old values
30025 // are not mixed with the new UTM parameters
30026 this.unregister(utm_key);
30027 }.bind(this));
30028 }
30029 };
30030
30031 // update persistence with info on referrer, UTM params, etc
30032 MixpanelLib.prototype._set_default_superprops = function() {
30033 this['persistence'].update_search_keyword(document$1.referrer);
30034 // Registering super properties for UTM persistence by 'store_google' is deprecated.
30035 if (this.get_config('store_google') && !this.get_config('stop_utm_persistence')) {
30036 this.register(_.info.campaignParams());
30037 }
30038 if (this.get_config('save_referrer')) {
30039 this['persistence'].update_referrer_info(document$1.referrer);
30040 }
30041 };
30042
30043 MixpanelLib.prototype._dom_loaded = function() {
30044 _.each(this.__dom_loaded_queue, function(item) {
30045 this._track_dom.apply(this, item);
30046 }, this);
30047
30048 if (!this.has_opted_out_tracking()) {
30049 _.each(this.__request_queue, function(item) {
30050 this._send_request.apply(this, item);
30051 }, this);
30052 }
30053
30054 delete this.__dom_loaded_queue;
30055 delete this.__request_queue;
30056 };
30057
30058 MixpanelLib.prototype._track_dom = function(DomClass, args) {
30059 if (this.get_config('img')) {
30060 this.report_error('You can\'t use DOM tracking functions with img = true.');
30061 return false;
30062 }
30063
30064 if (!DOM_LOADED) {
30065 this.__dom_loaded_queue.push([DomClass, args]);
30066 return false;
30067 }
30068
30069 var dt = new DomClass().init(this);
30070 return dt.track.apply(dt, args);
30071 };
30072
30073 /**
30074 * _prepare_callback() should be called by callers of _send_request for use
30075 * as the callback argument.
30076 *
30077 * If there is no callback, this returns null.
30078 * If we are going to make XHR/XDR requests, this returns a function.
30079 * If we are going to use script tags, this returns a string to use as the
30080 * callback GET param.
30081 */
30082 MixpanelLib.prototype._prepare_callback = function(callback, data) {
30083 if (_.isUndefined(callback)) {
30084 return null;
30085 }
30086
30087 if (USE_XHR) {
30088 var callback_function = function(response) {
30089 callback(response, data);
30090 };
30091 return callback_function;
30092 } else {
30093 // if the user gives us a callback, we store as a random
30094 // property on this instances jsc function and update our
30095 // callback string to reflect that.
30096 var jsc = this['_jsc'];
30097 var randomized_cb = '' + Math.floor(Math.random() * 100000000);
30098 var callback_string = this.get_config('callback_fn') + '[' + randomized_cb + ']';
30099 jsc[randomized_cb] = function(response) {
30100 delete jsc[randomized_cb];
30101 callback(response, data);
30102 };
30103 return callback_string;
30104 }
30105 };
30106
30107 MixpanelLib.prototype._send_request = function(url, data, options, callback) {
30108 var succeeded = true;
30109
30110 if (ENQUEUE_REQUESTS) {
30111 this.__request_queue.push(arguments);
30112 return succeeded;
30113 }
30114
30115 var DEFAULT_OPTIONS = {
30116 method: this.get_config('api_method'),
30117 transport: this.get_config('api_transport'),
30118 verbose: this.get_config('verbose')
30119 };
30120 var body_data = null;
30121
30122 if (!callback && (_.isFunction(options) || typeof options === 'string')) {
30123 callback = options;
30124 options = null;
30125 }
30126 options = _.extend(DEFAULT_OPTIONS, options || {});
30127 if (!USE_XHR) {
30128 options.method = 'GET';
30129 }
30130 var use_post = options.method === 'POST';
30131 var use_sendBeacon = sendBeacon && use_post && options.transport.toLowerCase() === 'sendbeacon';
30132
30133 // needed to correctly format responses
30134 var verbose_mode = options.verbose;
30135 if (data['verbose']) { verbose_mode = true; }
30136
30137 if (this.get_config('test')) { data['test'] = 1; }
30138 if (verbose_mode) { data['verbose'] = 1; }
30139 if (this.get_config('img')) { data['img'] = 1; }
30140 if (!USE_XHR) {
30141 if (callback) {
30142 data['callback'] = callback;
30143 } else if (verbose_mode || this.get_config('test')) {
30144 // Verbose output (from verbose mode, or an error in test mode) is a json blob,
30145 // which by itself is not valid javascript. Without a callback, this verbose output will
30146 // cause an error when returned via jsonp, so we force a no-op callback param.
30147 // See the ECMA script spec: http://www.ecma-international.org/ecma-262/5.1/#sec-12.4
30148 data['callback'] = '(function(){})';
30149 }
30150 }
30151
30152 data['ip'] = this.get_config('ip')?1:0;
30153 data['_'] = new Date().getTime().toString();
30154
30155 if (use_post) {
30156 body_data = 'data=' + encodeURIComponent(data['data']);
30157 delete data['data'];
30158 }
30159
30160 _.extend(data, this.get_config('api_extra_query_params'));
30161
30162 url += '?' + _.HTTPBuildQuery(data);
30163
30164 var lib = this;
30165 if ('img' in data) {
30166 var img = document$1.createElement('img');
30167 img.src = url;
30168 document$1.body.appendChild(img);
30169 } else if (use_sendBeacon) {
30170 try {
30171 succeeded = sendBeacon(url, body_data);
30172 } catch (e) {
30173 lib.report_error(e);
30174 succeeded = false;
30175 }
30176 try {
30177 if (callback) {
30178 callback(succeeded ? 1 : 0);
30179 }
30180 } catch (e) {
30181 lib.report_error(e);
30182 }
30183 } else if (USE_XHR) {
30184 try {
30185 var req = new XMLHttpRequest();
30186 req.open(options.method, url, true);
30187
30188 var headers = this.get_config('xhr_headers');
30189 if (use_post) {
30190 headers['Content-Type'] = 'application/x-www-form-urlencoded';
30191 }
30192 _.each(headers, function(headerValue, headerName) {
30193 req.setRequestHeader(headerName, headerValue);
30194 });
30195
30196 if (options.timeout_ms && typeof req.timeout !== 'undefined') {
30197 req.timeout = options.timeout_ms;
30198 var start_time = new Date().getTime();
30199 }
30200
30201 // send the mp_optout cookie
30202 // withCredentials cannot be modified until after calling .open on Android and Mobile Safari
30203 req.withCredentials = true;
30204 req.onreadystatechange = function () {
30205 if (req.readyState === 4) { // XMLHttpRequest.DONE == 4, except in safari 4
30206 if (req.status === 200) {
30207 if (callback) {
30208 if (verbose_mode) {
30209 var response;
30210 try {
30211 response = _.JSONDecode(req.responseText);
30212 } catch (e) {
30213 lib.report_error(e);
30214 if (options.ignore_json_errors) {
30215 response = req.responseText;
30216 } else {
30217 return;
30218 }
30219 }
30220 callback(response);
30221 } else {
30222 callback(Number(req.responseText));
30223 }
30224 }
30225 } else {
30226 var error;
30227 if (
30228 req.timeout &&
30229 !req.status &&
30230 new Date().getTime() - start_time >= req.timeout
30231 ) {
30232 error = 'timeout';
30233 } else {
30234 error = 'Bad HTTP status: ' + req.status + ' ' + req.statusText;
30235 }
30236 lib.report_error(error);
30237 if (callback) {
30238 if (verbose_mode) {
30239 var response_headers = req['responseHeaders'] || {};
30240 callback({status: 0, httpStatusCode: req['status'], error: error, retryAfter: response_headers['Retry-After']});
30241 } else {
30242 callback(0);
30243 }
30244 }
30245 }
30246 }
30247 };
30248 req.send(body_data);
30249 } catch (e) {
30250 lib.report_error(e);
30251 succeeded = false;
30252 }
30253 } else {
30254 var script = document$1.createElement('script');
30255 script.type = 'text/javascript';
30256 script.async = true;
30257 script.defer = true;
30258 script.src = url;
30259 var s = document$1.getElementsByTagName('script')[0];
30260 s.parentNode.insertBefore(script, s);
30261 }
30262
30263 return succeeded;
30264 };
30265
30266 /**
30267 * _execute_array() deals with processing any mixpanel function
30268 * calls that were called before the Mixpanel library were loaded
30269 * (and are thus stored in an array so they can be called later)
30270 *
30271 * Note: we fire off all the mixpanel function calls && user defined
30272 * functions BEFORE we fire off mixpanel tracking calls. This is so
30273 * identify/register/set_config calls can properly modify early
30274 * tracking calls.
30275 *
30276 * @param {Array} array
30277 */
30278 MixpanelLib.prototype._execute_array = function(array) {
30279 var fn_name, alias_calls = [], other_calls = [], tracking_calls = [];
30280 _.each(array, function(item) {
30281 if (item) {
30282 fn_name = item[0];
30283 if (_.isArray(fn_name)) {
30284 tracking_calls.push(item); // chained call e.g. mixpanel.get_group().set()
30285 } else if (typeof(item) === 'function') {
30286 item.call(this);
30287 } else if (_.isArray(item) && fn_name === 'alias') {
30288 alias_calls.push(item);
30289 } else if (_.isArray(item) && fn_name.indexOf('track') !== -1 && typeof(this[fn_name]) === 'function') {
30290 tracking_calls.push(item);
30291 } else {
30292 other_calls.push(item);
30293 }
30294 }
30295 }, this);
30296
30297 var execute = function(calls, context) {
30298 _.each(calls, function(item) {
30299 if (_.isArray(item[0])) {
30300 // chained call
30301 var caller = context;
30302 _.each(item, function(call) {
30303 caller = caller[call[0]].apply(caller, call.slice(1));
30304 });
30305 } else {
30306 this[item[0]].apply(this, item.slice(1));
30307 }
30308 }, context);
30309 };
30310
30311 execute(alias_calls, this);
30312 execute(other_calls, this);
30313 execute(tracking_calls, this);
30314 };
30315
30316 // request queueing utils
30317
30318 MixpanelLib.prototype.are_batchers_initialized = function() {
30319 return !!this.request_batchers.events;
30320 };
30321
30322 MixpanelLib.prototype.get_batcher_configs = function() {
30323 var queue_prefix = '__mpq_' + this.get_config('token');
30324 this._batcher_configs = this._batcher_configs || {
30325 events: {type: 'events', api_name: 'track', queue_key: queue_prefix + '_ev'},
30326 people: {type: 'people', api_name: 'engage', queue_key: queue_prefix + '_pp'},
30327 groups: {type: 'groups', api_name: 'groups', queue_key: queue_prefix + '_gr'}
30328 };
30329 return this._batcher_configs;
30330 };
30331
30332 MixpanelLib.prototype.init_batchers = function() {
30333 if (!this.are_batchers_initialized()) {
30334 var batcher_for = _.bind(function(attrs) {
30335 return new RequestBatcher(
30336 attrs.queue_key,
30337 {
30338 libConfig: this['config'],
30339 errorReporter: this.get_config('error_reporter'),
30340 sendRequestFunc: _.bind(function(data, options, cb) {
30341 var api_routes = this.get_config('api_routes');
30342 this._send_request(
30343 this.get_api_host(attrs.api_name) + '/' + api_routes[attrs.api_name],
30344 this._encode_data_for_request(data),
30345 options,
30346 this._prepare_callback(cb, data)
30347 );
30348 }, this),
30349 beforeSendHook: _.bind(function(item) {
30350 return this._run_hook('before_send_' + attrs.type, item);
30351 }, this),
30352 stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
30353 usePersistence: true,
30354 }
30355 );
30356 }, this);
30357 var batcher_configs = this.get_batcher_configs();
30358 this.request_batchers = {
30359 events: batcher_for(batcher_configs.events),
30360 people: batcher_for(batcher_configs.people),
30361 groups: batcher_for(batcher_configs.groups)
30362 };
30363 }
30364 if (this.get_config('batch_autostart')) {
30365 this.start_batch_senders();
30366 }
30367 };
30368
30369 MixpanelLib.prototype.start_batch_senders = function() {
30370 this._batchers_were_started = true;
30371 if (this.are_batchers_initialized()) {
30372 this._batch_requests = true;
30373 _.each(this.request_batchers, function(batcher) {
30374 batcher.start();
30375 });
30376 }
30377 };
30378
30379 MixpanelLib.prototype.stop_batch_senders = function() {
30380 this._batch_requests = false;
30381 _.each(this.request_batchers, function(batcher) {
30382 batcher.stop();
30383 batcher.clear();
30384 });
30385 };
30386
30387 /**
30388 * push() keeps the standard async-array-push
30389 * behavior around after the lib is loaded.
30390 * This is only useful for external integrations that
30391 * do not wish to rely on our convenience methods
30392 * (created in the snippet).
30393 *
30394 * ### Usage:
30395 * mixpanel.push(['register', { a: 'b' }]);
30396 *
30397 * @param {Array} item A [function_name, args...] array to be executed
30398 */
30399 MixpanelLib.prototype.push = function(item) {
30400 this._execute_array([item]);
30401 };
30402
30403 /**
30404 * Disable events on the Mixpanel object. If passed no arguments,
30405 * this function disables tracking of any event. If passed an
30406 * array of event names, those events will be disabled, but other
30407 * events will continue to be tracked.
30408 *
30409 * Note: this function does not stop other mixpanel functions from
30410 * firing, such as register() or people.set().
30411 *
30412 * @param {Array} [events] An array of event names to disable
30413 */
30414 MixpanelLib.prototype.disable = function(events) {
30415 if (typeof(events) === 'undefined') {
30416 this._flags.disable_all_events = true;
30417 } else {
30418 this.__disabled_events = this.__disabled_events.concat(events);
30419 }
30420 };
30421
30422 MixpanelLib.prototype._encode_data_for_request = function(data) {
30423 var encoded_data = JSONStringify(data);
30424 if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
30425 encoded_data = _.base64Encode(encoded_data);
30426 }
30427 return {'data': encoded_data};
30428 };
30429
30430 // internal method for handling track vs batch-enqueue logic
30431 MixpanelLib.prototype._track_or_batch = function(options, callback) {
30432 var truncated_data = _.truncate(options.data, 255);
30433 var endpoint = options.endpoint;
30434 var batcher = options.batcher;
30435 var should_send_immediately = options.should_send_immediately;
30436 var send_request_options = options.send_request_options || {};
30437 callback = callback || NOOP_FUNC;
30438
30439 var request_enqueued_or_initiated = true;
30440 var send_request_immediately = _.bind(function() {
30441 if (!send_request_options.skip_hooks) {
30442 truncated_data = this._run_hook('before_send_' + options.type, truncated_data);
30443 }
30444 if (truncated_data) {
30445 console$1.log('MIXPANEL REQUEST:');
30446 console$1.log(truncated_data);
30447 return this._send_request(
30448 endpoint,
30449 this._encode_data_for_request(truncated_data),
30450 send_request_options,
30451 this._prepare_callback(callback, truncated_data)
30452 );
30453 } else {
30454 return null;
30455 }
30456 }, this);
30457
30458 if (this._batch_requests && !should_send_immediately) {
30459 batcher.enqueue(truncated_data).then(function(succeeded) {
30460 if (succeeded) {
30461 callback(1, truncated_data);
30462 } else {
30463 send_request_immediately();
30464 }
30465 });
30466 } else {
30467 request_enqueued_or_initiated = send_request_immediately();
30468 }
30469
30470 return request_enqueued_or_initiated && truncated_data;
30471 };
30472
30473 /**
30474 * Track an event. This is the most important and
30475 * frequently used Mixpanel function.
30476 *
30477 * ### Usage:
30478 *
30479 * // track an event named 'Registered'
30480 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
30481 *
30482 * // track an event using navigator.sendBeacon
30483 * mixpanel.track('Left page', {'duration_seconds': 35}, {transport: 'sendBeacon'});
30484 *
30485 * To track link clicks or form submissions, see track_links() or track_forms().
30486 *
30487 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
30488 * @param {Object} [properties] A set of properties to include with the event you're sending. These describe the user who did the event or details about the event itself.
30489 * @param {Object} [options] Optional configuration for this track request.
30490 * @param {String} [options.transport] Transport method for network request ('xhr' or 'sendBeacon').
30491 * @param {Boolean} [options.send_immediately] Whether to bypass batching/queueing and send track request immediately.
30492 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
30493 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
30494 * with the tracking payload sent to the API server is returned; otherwise false.
30495 */
30496 MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
30497 if (!callback && typeof options === 'function') {
30498 callback = options;
30499 options = null;
30500 }
30501 options = options || {};
30502 var transport = options['transport']; // external API, don't minify 'transport' prop
30503 if (transport) {
30504 options.transport = transport; // 'transport' prop name can be minified internally
30505 }
30506 var should_send_immediately = options['send_immediately'];
30507 if (typeof callback !== 'function') {
30508 callback = NOOP_FUNC;
30509 }
30510
30511 if (_.isUndefined(event_name)) {
30512 this.report_error('No event name provided to mixpanel.track');
30513 return;
30514 }
30515
30516 if (this._event_is_disabled(event_name)) {
30517 callback(0);
30518 return;
30519 }
30520
30521 // set defaults
30522 properties = _.extend({}, properties);
30523 properties['token'] = this.get_config('token');
30524
30525 // set $duration if time_event was previously called for this event
30526 var start_timestamp = this['persistence'].remove_event_timer(event_name);
30527 if (!_.isUndefined(start_timestamp)) {
30528 var duration_in_ms = new Date().getTime() - start_timestamp;
30529 properties['$duration'] = parseFloat((duration_in_ms / 1000).toFixed(3));
30530 }
30531
30532 this._set_default_superprops();
30533
30534 var marketing_properties = this.get_config('track_marketing')
30535 ? _.info.marketingParams()
30536 : {};
30537
30538 // note: extend writes to the first object, so lets make sure we
30539 // don't write to the persistence properties object and info
30540 // properties object by passing in a new object
30541
30542 // update properties with pageview info and super-properties
30543 properties = _.extend(
30544 {},
30545 _.info.properties({'mp_loader': this.get_config('mp_loader')}),
30546 marketing_properties,
30547 this['persistence'].properties(),
30548 this.unpersisted_superprops,
30549 this.get_session_recording_properties(),
30550 properties
30551 );
30552
30553 var property_blacklist = this.get_config('property_blacklist');
30554 if (_.isArray(property_blacklist)) {
30555 _.each(property_blacklist, function(blacklisted_prop) {
30556 delete properties[blacklisted_prop];
30557 });
30558 } else {
30559 this.report_error('Invalid value for property_blacklist config: ' + property_blacklist);
30560 }
30561
30562 var data = {
30563 'event': event_name,
30564 'properties': properties
30565 };
30566 var ret = this._track_or_batch({
30567 type: 'events',
30568 data: data,
30569 endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
30570 batcher: this.request_batchers.events,
30571 should_send_immediately: should_send_immediately,
30572 send_request_options: options
30573 }, callback);
30574
30575 return ret;
30576 });
30577
30578 /**
30579 * Register the current user into one/many groups.
30580 *
30581 * ### Usage:
30582 *
30583 * mixpanel.set_group('company', ['mixpanel', 'google']) // an array of IDs
30584 * mixpanel.set_group('company', 'mixpanel')
30585 * mixpanel.set_group('company', 128746312)
30586 *
30587 * @param {String} group_key Group key
30588 * @param {Array|String|Number} group_ids An array of group IDs, or a singular group ID
30589 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30590 *
30591 */
30592 MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key, group_ids, callback) {
30593 if (!_.isArray(group_ids)) {
30594 group_ids = [group_ids];
30595 }
30596 var prop = {};
30597 prop[group_key] = group_ids;
30598 this.register(prop);
30599 return this['people'].set(group_key, group_ids, callback);
30600 });
30601
30602 /**
30603 * Add a new group for this user.
30604 *
30605 * ### Usage:
30606 *
30607 * mixpanel.add_group('company', 'mixpanel')
30608 *
30609 * @param {String} group_key Group key
30610 * @param {*} group_id A valid Mixpanel property type
30611 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30612 */
30613 MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
30614 var old_values = this.get_property(group_key);
30615 var prop = {};
30616 if (old_values === undefined) {
30617 prop[group_key] = [group_id];
30618 this.register(prop);
30619 } else {
30620 if (old_values.indexOf(group_id) === -1) {
30621 old_values.push(group_id);
30622 prop[group_key] = old_values;
30623 this.register(prop);
30624 }
30625 }
30626 return this['people'].union(group_key, group_id, callback);
30627 });
30628
30629 /**
30630 * Remove a group from this user.
30631 *
30632 * ### Usage:
30633 *
30634 * mixpanel.remove_group('company', 'mixpanel')
30635 *
30636 * @param {String} group_key Group key
30637 * @param {*} group_id A valid Mixpanel property type
30638 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30639 */
30640 MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
30641 var old_value = this.get_property(group_key);
30642 // if the value doesn't exist, the persistent store is unchanged
30643 if (old_value !== undefined) {
30644 var idx = old_value.indexOf(group_id);
30645 if (idx > -1) {
30646 old_value.splice(idx, 1);
30647 this.register({group_key: old_value});
30648 }
30649 if (old_value.length === 0) {
30650 this.unregister(group_key);
30651 }
30652 }
30653 return this['people'].remove(group_key, group_id, callback);
30654 });
30655
30656 /**
30657 * Track an event with specific groups.
30658 *
30659 * ### Usage:
30660 *
30661 * mixpanel.track_with_groups('purchase', {'product': 'iphone'}, {'University': ['UCB', 'UCLA']})
30662 *
30663 * @param {String} event_name The name of the event (see `mixpanel.track()`)
30664 * @param {Object=} properties A set of properties to include with the event you're sending (see `mixpanel.track()`)
30665 * @param {Object=} groups An object mapping group name keys to one or more values
30666 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30667 */
30668 MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(event_name, properties, groups, callback) {
30669 var tracking_props = _.extend({}, properties || {});
30670 _.each(groups, function(v, k) {
30671 if (v !== null && v !== undefined) {
30672 tracking_props[k] = v;
30673 }
30674 });
30675 return this.track(event_name, tracking_props, callback);
30676 });
30677
30678 MixpanelLib.prototype._create_map_key = function (group_key, group_id) {
30679 return group_key + '_' + JSON.stringify(group_id);
30680 };
30681
30682 MixpanelLib.prototype._remove_group_from_cache = function (group_key, group_id) {
30683 delete this._cached_groups[this._create_map_key(group_key, group_id)];
30684 };
30685
30686 /**
30687 * Look up reference to a Mixpanel group
30688 *
30689 * ### Usage:
30690 *
30691 * mixpanel.get_group(group_key, group_id)
30692 *
30693 * @param {String} group_key Group key
30694 * @param {Object} group_id A valid Mixpanel property type
30695 * @returns {Object} A MixpanelGroup identifier
30696 */
30697 MixpanelLib.prototype.get_group = function (group_key, group_id) {
30698 var map_key = this._create_map_key(group_key, group_id);
30699 var group = this._cached_groups[map_key];
30700 if (group === undefined || group._group_key !== group_key || group._group_id !== group_id) {
30701 group = new MixpanelGroup();
30702 group._init(this, group_key, group_id);
30703 this._cached_groups[map_key] = group;
30704 }
30705 return group;
30706 };
30707
30708 /**
30709 * Track a default Mixpanel page view event, which includes extra default event properties to
30710 * improve page view data.
30711 *
30712 * ### Usage:
30713 *
30714 * // track a default $mp_web_page_view event
30715 * mixpanel.track_pageview();
30716 *
30717 * // track a page view event with additional event properties
30718 * mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
30719 *
30720 * // example approach to track page views on different page types as event properties
30721 * mixpanel.track_pageview({'page': 'pricing'});
30722 * mixpanel.track_pageview({'page': 'homepage'});
30723 *
30724 * // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
30725 * // individual pages on the same site or product. Use cases for custom event_name may be page
30726 * // views on different products or internal applications that are considered completely separate
30727 * mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
30728 *
30729 * ### Notes:
30730 *
30731 * The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
30732 * may be turned on for tracking page loads automatically.
30733 *
30734 * // track only page loads
30735 * mixpanel.init(PROJECT_TOKEN, {track_pageview: true});
30736 *
30737 * // track when the URL changes in any manner
30738 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'full-url'});
30739 *
30740 * // track when the URL changes, ignoring any changes in the hash part
30741 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path-and-query-string'});
30742 *
30743 * // track when the path changes, ignoring any query parameter or hash changes
30744 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path'});
30745 *
30746 * @param {Object} [properties] An optional set of additional properties to send with the page view event
30747 * @param {Object} [options] Page view tracking options
30748 * @param {String} [options.event_name] - Alternate name for the tracking event
30749 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
30750 * with the tracking payload sent to the API server is returned; otherwise false.
30751 */
30752 MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
30753 if (typeof properties !== 'object') {
30754 properties = {};
30755 }
30756 options = options || {};
30757 var event_name = options['event_name'] || '$mp_web_page_view';
30758
30759 var default_page_properties = _.extend(
30760 _.info.mpPageViewProperties(),
30761 _.info.campaignParams(),
30762 _.info.clickParams()
30763 );
30764
30765 var event_properties = _.extend(
30766 {},
30767 default_page_properties,
30768 properties
30769 );
30770
30771 return this.track(event_name, event_properties);
30772 });
30773
30774 /**
30775 * Track clicks on a set of document elements. Selector must be a
30776 * valid query. Elements must exist on the page at the time track_links is called.
30777 *
30778 * ### Usage:
30779 *
30780 * // track click for link id #nav
30781 * mixpanel.track_links('#nav', 'Clicked Nav Link');
30782 *
30783 * ### Notes:
30784 *
30785 * This function will wait up to 300 ms for the Mixpanel
30786 * servers to respond. If they have not responded by that time
30787 * it will head to the link without ensuring that your event
30788 * has been tracked. To configure this timeout please see the
30789 * set_config() documentation below.
30790 *
30791 * If you pass a function in as the properties argument, the
30792 * function will receive the DOMElement that triggered the
30793 * event as an argument. You are expected to return an object
30794 * from the function; any properties defined on this object
30795 * will be sent to mixpanel as event properties.
30796 *
30797 * @type {Function}
30798 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
30799 * @param {String} event_name The name of the event to track
30800 * @param {Object|Function} [properties] A properties object or function that returns a dictionary of properties when passed a DOMElement
30801 */
30802 MixpanelLib.prototype.track_links = function() {
30803 return this._track_dom.call(this, LinkTracker, arguments);
30804 };
30805
30806 /**
30807 * Track form submissions. Selector must be a valid query.
30808 *
30809 * ### Usage:
30810 *
30811 * // track submission for form id 'register'
30812 * mixpanel.track_forms('#register', 'Created Account');
30813 *
30814 * ### Notes:
30815 *
30816 * This function will wait up to 300 ms for the mixpanel
30817 * servers to respond, if they have not responded by that time
30818 * it will head to the link without ensuring that your event
30819 * has been tracked. To configure this timeout please see the
30820 * set_config() documentation below.
30821 *
30822 * If you pass a function in as the properties argument, the
30823 * function will receive the DOMElement that triggered the
30824 * event as an argument. You are expected to return an object
30825 * from the function; any properties defined on this object
30826 * will be sent to mixpanel as event properties.
30827 *
30828 * @type {Function}
30829 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
30830 * @param {String} event_name The name of the event to track
30831 * @param {Object|Function} [properties] This can be a set of properties, or a function that returns a set of properties after being passed a DOMElement
30832 */
30833 MixpanelLib.prototype.track_forms = function() {
30834 return this._track_dom.call(this, FormTracker, arguments);
30835 };
30836
30837 /**
30838 * Time an event by including the time between this call and a
30839 * later 'track' call for the same event in the properties sent
30840 * with the event.
30841 *
30842 * ### Usage:
30843 *
30844 * // time an event named 'Registered'
30845 * mixpanel.time_event('Registered');
30846 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
30847 *
30848 * When called for a particular event name, the next track call for that event
30849 * name will include the elapsed time between the 'time_event' and 'track'
30850 * calls. This value is stored as seconds in the '$duration' property.
30851 *
30852 * @param {String} event_name The name of the event.
30853 */
30854 MixpanelLib.prototype.time_event = function(event_name) {
30855 if (_.isUndefined(event_name)) {
30856 this.report_error('No event name provided to mixpanel.time_event');
30857 return;
30858 }
30859
30860 if (this._event_is_disabled(event_name)) {
30861 return;
30862 }
30863
30864 this['persistence'].set_event_timer(event_name, new Date().getTime());
30865 };
30866
30867 var REGISTER_DEFAULTS = {
30868 'persistent': true
30869 };
30870 /**
30871 * Helper to parse options param for register methods, maintaining
30872 * legacy support for plain "days" param instead of options object
30873 * @param {Number|Object} [days_or_options] 'days' option (Number), or Options object for register methods
30874 * @returns {Object} options object
30875 */
30876 var options_for_register = function(days_or_options) {
30877 var options;
30878 if (_.isObject(days_or_options)) {
30879 options = days_or_options;
30880 } else if (!_.isUndefined(days_or_options)) {
30881 options = {'days': days_or_options};
30882 } else {
30883 options = {};
30884 }
30885 return _.extend({}, REGISTER_DEFAULTS, options);
30886 };
30887
30888 /**
30889 * Register a set of super properties, which are included with all
30890 * events. This will overwrite previous super property values.
30891 *
30892 * ### Usage:
30893 *
30894 * // register 'Gender' as a super property
30895 * mixpanel.register({'Gender': 'Female'});
30896 *
30897 * // register several super properties when a user signs up
30898 * mixpanel.register({
30899 * 'Email': 'jdoe@example.com',
30900 * 'Account Type': 'Free'
30901 * });
30902 *
30903 * // register only for the current pageload
30904 * mixpanel.register({'Name': 'Pat'}, {persistent: false});
30905 *
30906 * @param {Object} properties An associative array of properties to store about the user
30907 * @param {Number|Object} [days_or_options] Options object or number of days since the user's last visit to store the super properties (only valid for persisted props)
30908 * @param {boolean} [days_or_options.days] - number of days since the user's last visit to store the super properties (only valid for persisted props)
30909 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
30910 */
30911 MixpanelLib.prototype.register = function(props, days_or_options) {
30912 var options = options_for_register(days_or_options);
30913 if (options['persistent']) {
30914 this['persistence'].register(props, options['days']);
30915 } else {
30916 _.extend(this.unpersisted_superprops, props);
30917 }
30918 };
30919
30920 /**
30921 * Register a set of super properties only once. This will not
30922 * overwrite previous super property values, unlike register().
30923 *
30924 * ### Usage:
30925 *
30926 * // register a super property for the first time only
30927 * mixpanel.register_once({
30928 * 'First Login Date': new Date().toISOString()
30929 * });
30930 *
30931 * // register once, only for the current pageload
30932 * mixpanel.register_once({
30933 * 'First interaction time': new Date().toISOString()
30934 * }, 'None', {persistent: false});
30935 *
30936 * ### Notes:
30937 *
30938 * If default_value is specified, current super properties
30939 * with that value will be overwritten.
30940 *
30941 * @param {Object} properties An associative array of properties to store about the user
30942 * @param {*} [default_value] Value to override if already set in super properties (ex: 'False') Default: 'None'
30943 * @param {Number|Object} [days_or_options] Options object or number of days since the user's last visit to store the super properties (only valid for persisted props)
30944 * @param {boolean} [days_or_options.days] - number of days since the user's last visit to store the super properties (only valid for persisted props)
30945 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
30946 */
30947 MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
30948 var options = options_for_register(days_or_options);
30949 if (options['persistent']) {
30950 this['persistence'].register_once(props, default_value, options['days']);
30951 } else {
30952 if (typeof(default_value) === 'undefined') {
30953 default_value = 'None';
30954 }
30955 _.each(props, function(val, prop) {
30956 if (!this.unpersisted_superprops.hasOwnProperty(prop) || this.unpersisted_superprops[prop] === default_value) {
30957 this.unpersisted_superprops[prop] = val;
30958 }
30959 }, this);
30960 }
30961 };
30962
30963 /**
30964 * Delete a super property stored with the current user.
30965 *
30966 * @param {String} property The name of the super property to remove
30967 * @param {Object} [options]
30968 * @param {boolean} [options.persistent=true] - whether to look in persistent storage (cookie/localStorage)
30969 */
30970 MixpanelLib.prototype.unregister = function(property, options) {
30971 options = options_for_register(options);
30972 if (options['persistent']) {
30973 this['persistence'].unregister(property);
30974 } else {
30975 delete this.unpersisted_superprops[property];
30976 }
30977 };
30978
30979 MixpanelLib.prototype._register_single = function(prop, value) {
30980 var props = {};
30981 props[prop] = value;
30982 this.register(props);
30983 };
30984
30985 /**
30986 * Identify a user with a unique ID to track user activity across
30987 * devices, tie a user to their events, and create a user profile.
30988 * If you never call this method, unique visitors are tracked using
30989 * a UUID generated the first time they visit the site.
30990 *
30991 * Call identify when you know the identity of the current user,
30992 * typically after login or signup. We recommend against using
30993 * identify for anonymous visitors to your site.
30994 *
30995 * ### Notes:
30996 * If your project has
30997 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
30998 * enabled, the identify method will connect pre- and
30999 * post-authentication events when appropriate.
31000 *
31001 * If your project does not have ID Merge enabled, identify will
31002 * change the user's local distinct_id to the unique ID you pass.
31003 * Events tracked prior to authentication will not be connected
31004 * to the same user identity. If ID Merge is disabled, alias can
31005 * be used to connect pre- and post-registration events.
31006 *
31007 * @param {String} [unique_id] A string that uniquely identifies a user. If not provided, the distinct_id currently in the persistent store (cookie or localStorage) will be used.
31008 */
31009 MixpanelLib.prototype.identify = function(
31010 new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
31011 ) {
31012 // Optional Parameters
31013 // _set_callback:function A callback to be run if and when the People set queue is flushed
31014 // _add_callback:function A callback to be run if and when the People add queue is flushed
31015 // _append_callback:function A callback to be run if and when the People append queue is flushed
31016 // _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
31017 // _union_callback:function A callback to be run if and when the People union queue is flushed
31018 // _unset_callback:function A callback to be run if and when the People unset queue is flushed
31019
31020 var previous_distinct_id = this.get_distinct_id();
31021 if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
31022 // we allow the following condition if previous distinct_id is same as new_distinct_id
31023 // so that you can force flush people updates for anonymous profiles.
31024 if (typeof new_distinct_id === 'string' && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
31025 this.report_error('distinct_id cannot have $device: prefix');
31026 return -1;
31027 }
31028 this.register({'$user_id': new_distinct_id});
31029 }
31030
31031 if (!this.get_property('$device_id')) {
31032 // The persisted distinct id might not actually be a device id at all
31033 // it might be a distinct id of the user from before
31034 var device_id = previous_distinct_id;
31035 this.register_once({
31036 '$had_persisted_distinct_id': true,
31037 '$device_id': device_id
31038 }, '');
31039 }
31040
31041 // identify only changes the distinct id if it doesn't match either the existing or the alias;
31042 // if it's new, blow away the alias as well.
31043 if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
31044 this.unregister(ALIAS_ID_KEY);
31045 this.register({'distinct_id': new_distinct_id});
31046 }
31047 this._flags.identify_called = true;
31048 // Flush any queued up people requests
31049 this['people']._flush(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback);
31050
31051 // send an $identify event any time the distinct_id is changing - logic on the server
31052 // will determine whether or not to do anything with it.
31053 if (new_distinct_id !== previous_distinct_id) {
31054 this.track('$identify', {
31055 'distinct_id': new_distinct_id,
31056 '$anon_distinct_id': previous_distinct_id
31057 }, {skip_hooks: true});
31058 }
31059
31060 // check feature flags again if distinct id has changed
31061 if (new_distinct_id !== previous_distinct_id) {
31062 this.flags.fetchFlags();
31063 }
31064 };
31065
31066 /**
31067 * Clears super properties and generates a new random distinct_id for this instance.
31068 * Useful for clearing data when a user logs out.
31069 */
31070 MixpanelLib.prototype.reset = function() {
31071 this.stop_session_recording();
31072 this['persistence'].clear();
31073 this._flags.identify_called = false;
31074 var uuid = _.UUID();
31075 this.register_once({
31076 'distinct_id': DEVICE_ID_PREFIX + uuid,
31077 '$device_id': uuid
31078 }, '');
31079 this._check_and_start_session_recording();
31080 };
31081
31082 /**
31083 * Returns the current distinct id of the user. This is either the id automatically
31084 * generated by the library or the id that has been passed by a call to identify().
31085 *
31086 * ### Notes:
31087 *
31088 * get_distinct_id() can only be called after the Mixpanel library has finished loading.
31089 * init() has a loaded function available to handle this automatically. For example:
31090 *
31091 * // set distinct_id after the mixpanel library has loaded
31092 * mixpanel.init('YOUR PROJECT TOKEN', {
31093 * loaded: function(mixpanel) {
31094 * distinct_id = mixpanel.get_distinct_id();
31095 * }
31096 * });
31097 */
31098 MixpanelLib.prototype.get_distinct_id = function() {
31099 return this.get_property('distinct_id');
31100 };
31101
31102 /**
31103 * The alias method creates an alias which Mixpanel will use to
31104 * remap one id to another. Multiple aliases can point to the
31105 * same identifier.
31106 *
31107 * The following is a valid use of alias:
31108 *
31109 * mixpanel.alias('new_id', 'existing_id');
31110 * // You can add multiple id aliases to the existing ID
31111 * mixpanel.alias('newer_id', 'existing_id');
31112 *
31113 * Aliases can also be chained - the following is a valid example:
31114 *
31115 * mixpanel.alias('new_id', 'existing_id');
31116 * // chain newer_id - new_id - existing_id
31117 * mixpanel.alias('newer_id', 'new_id');
31118 *
31119 * Aliases cannot point to multiple identifiers - the following
31120 * example will not work:
31121 *
31122 * mixpanel.alias('new_id', 'existing_id');
31123 * // this is invalid as 'new_id' already points to 'existing_id'
31124 * mixpanel.alias('new_id', 'newer_id');
31125 *
31126 * ### Notes:
31127 *
31128 * If your project does not have
31129 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31130 * enabled, the best practice is to call alias once when a unique
31131 * ID is first created for a user (e.g., when a user first registers
31132 * for an account). Do not use alias multiple times for a single
31133 * user without ID Merge enabled.
31134 *
31135 * @param {String} alias A unique identifier that you want to use for this user in the future.
31136 * @param {String} [original] The current identifier being used for this user.
31137 */
31138 MixpanelLib.prototype.alias = function(alias, original) {
31139 // If the $people_distinct_id key exists in persistence, there has been a previous
31140 // mixpanel.people.identify() call made for this user. It is VERY BAD to make an alias with
31141 // this ID, as it will duplicate users.
31142 if (alias === this.get_property(PEOPLE_DISTINCT_ID_KEY)) {
31143 this.report_error('Attempting to create alias for existing People user - aborting.');
31144 return -2;
31145 }
31146
31147 var _this = this;
31148 if (_.isUndefined(original)) {
31149 original = this.get_distinct_id();
31150 }
31151 if (alias !== original) {
31152 this._register_single(ALIAS_ID_KEY, alias);
31153 return this.track('$create_alias', {
31154 'alias': alias,
31155 'distinct_id': original
31156 }, {
31157 skip_hooks: true
31158 }, function() {
31159 // Flush the people queue
31160 _this.identify(alias);
31161 });
31162 } else {
31163 this.report_error('alias matches current distinct_id - skipping api call.');
31164 this.identify(alias);
31165 return -1;
31166 }
31167 };
31168
31169 /**
31170 * Provide a string to recognize the user by. The string passed to
31171 * this method will appear in the Mixpanel Streams product rather
31172 * than an automatically generated name. Name tags do not have to
31173 * be unique.
31174 *
31175 * This value will only be included in Streams data.
31176 *
31177 * @param {String} name_tag A human readable name for the user
31178 * @deprecated
31179 */
31180 MixpanelLib.prototype.name_tag = function(name_tag) {
31181 this._register_single('mp_name_tag', name_tag);
31182 };
31183
31184 /**
31185 * Update the configuration of a mixpanel library instance.
31186 *
31187 * The default config is:
31188 *
31189 * {
31190 * // host for requests (customizable for e.g. a local proxy)
31191 * api_host: 'https://api-js.mixpanel.com',
31192 *
31193 * // endpoints for different types of requests
31194 * api_routes: {
31195 * track: 'track/',
31196 * engage: 'engage/',
31197 * groups: 'groups/',
31198 * }
31199 *
31200 * // HTTP method for tracking requests
31201 * api_method: 'POST'
31202 *
31203 * // transport for sending requests ('XHR' or 'sendBeacon')
31204 * // NB: sendBeacon should only be used for scenarios such as
31205 * // page unload where a "best-effort" attempt to send is
31206 * // acceptable; the sendBeacon API does not support callbacks
31207 * // or any way to know the result of the request. Mixpanel
31208 * // tracking via sendBeacon will not support any event-
31209 * // batching or retry mechanisms.
31210 * api_transport: 'XHR'
31211 *
31212 * // request-batching/queueing/retry
31213 * batch_requests: true,
31214 *
31215 * // maximum number of events/updates to send in a single
31216 * // network request
31217 * batch_size: 50,
31218 *
31219 * // milliseconds to wait between sending batch requests
31220 * batch_flush_interval_ms: 5000,
31221 *
31222 * // milliseconds to wait for network responses to batch requests
31223 * // before they are considered timed-out and retried
31224 * batch_request_timeout_ms: 90000,
31225 *
31226 * // override value for cookie domain, only useful for ensuring
31227 * // correct cross-subdomain cookies on unusual domains like
31228 * // subdomain.mainsite.avocat.fr; NB this cannot be used to
31229 * // set cookies on a different domain than the current origin
31230 * cookie_domain: ''
31231 *
31232 * // super properties cookie expiration (in days)
31233 * cookie_expiration: 365
31234 *
31235 * // if true, cookie will be set with SameSite=None; Secure
31236 * // this is only useful in special situations, like embedded
31237 * // 3rd-party iframes that set up a Mixpanel instance
31238 * cross_site_cookie: false
31239 *
31240 * // super properties span subdomains
31241 * cross_subdomain_cookie: true
31242 *
31243 * // debug mode
31244 * debug: false
31245 *
31246 * // if this is true, the mixpanel cookie or localStorage entry
31247 * // will be deleted, and no user persistence will take place
31248 * disable_persistence: false
31249 *
31250 * // if this is true, Mixpanel will automatically determine
31251 * // City, Region and Country data using the IP address of
31252 * //the client
31253 * ip: true
31254 *
31255 * // opt users out of tracking by this Mixpanel instance by default
31256 * opt_out_tracking_by_default: false
31257 *
31258 * // opt users out of browser data storage by this Mixpanel instance by default
31259 * opt_out_persistence_by_default: false
31260 *
31261 * // persistence mechanism used by opt-in/opt-out methods - cookie
31262 * // or localStorage - falls back to cookie if localStorage is unavailable
31263 * opt_out_tracking_persistence_type: 'localStorage'
31264 *
31265 * // customize the name of cookie/localStorage set by opt-in/opt-out methods
31266 * opt_out_tracking_cookie_prefix: null
31267 *
31268 * // type of persistent store for super properties (cookie/
31269 * // localStorage) if set to 'localStorage', any existing
31270 * // mixpanel cookie value with the same persistence_name
31271 * // will be transferred to localStorage and deleted
31272 * persistence: 'cookie'
31273 *
31274 * // name for super properties persistent store
31275 * persistence_name: ''
31276 *
31277 * // names of properties/superproperties which should never
31278 * // be sent with track() calls
31279 * property_blacklist: []
31280 *
31281 * // if this is true, mixpanel cookies will be marked as
31282 * // secure, meaning they will only be transmitted over https
31283 * secure_cookie: false
31284 *
31285 * // disables enriching user profiles with first touch marketing data
31286 * skip_first_touch_marketing: false
31287 *
31288 * // the amount of time track_links will
31289 * // wait for Mixpanel's servers to respond
31290 * track_links_timeout: 300
31291 *
31292 * // adds any UTM parameters and click IDs present on the page to any events fired
31293 * track_marketing: true
31294 *
31295 * // enables automatic page view tracking using default page view events through
31296 * // the track_pageview() method
31297 * track_pageview: false
31298 *
31299 * // if you set upgrade to be true, the library will check for
31300 * // a cookie from our old js library and import super
31301 * // properties from it, then the old cookie is deleted
31302 * // The upgrade config option only works in the initialization,
31303 * // so make sure you set it when you create the library.
31304 * upgrade: false
31305 *
31306 * // extra HTTP request headers to set for each API request, in
31307 * // the format {'Header-Name': value}
31308 * xhr_headers: {}
31309 *
31310 * // whether to ignore or respect the web browser's Do Not Track setting
31311 * ignore_dnt: false
31312 * }
31313 *
31314 *
31315 * @param {Object} config A dictionary of new configuration values to update
31316 */
31317 MixpanelLib.prototype.set_config = function(config) {
31318 if (_.isObject(config)) {
31319 _.extend(this['config'], config);
31320
31321 var new_batch_size = config['batch_size'];
31322 if (new_batch_size) {
31323 _.each(this.request_batchers, function(batcher) {
31324 batcher.resetBatchSize();
31325 });
31326 }
31327
31328 if (!this.get_config('persistence_name')) {
31329 this['config']['persistence_name'] = this['config']['cookie_name'];
31330 }
31331 if (!this.get_config('disable_persistence')) {
31332 this['config']['disable_persistence'] = this['config']['disable_cookie'];
31333 }
31334
31335 if (this['persistence']) {
31336 this['persistence'].update_config(this['config']);
31337 }
31338 Config.DEBUG = Config.DEBUG || this.get_config('debug');
31339
31340 if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
31341 this.autocapture.init();
31342 }
31343 }
31344 };
31345
31346 /**
31347 * returns the current config object for the library.
31348 */
31349 MixpanelLib.prototype.get_config = function(prop_name) {
31350 return this['config'][prop_name];
31351 };
31352
31353 /**
31354 * Fetch a hook function from config, with safe default, and run it
31355 * against the given arguments
31356 * @param {string} hook_name which hook to retrieve
31357 * @returns {any|null} return value of user-provided hook, or null if nothing was returned
31358 */
31359 MixpanelLib.prototype._run_hook = function(hook_name) {
31360 var ret = (this['config']['hooks'][hook_name] || IDENTITY_FUNC).apply(this, slice.call(arguments, 1));
31361 if (typeof ret === 'undefined') {
31362 this.report_error(hook_name + ' hook did not return a value');
31363 ret = null;
31364 }
31365 return ret;
31366 };
31367
31368 /**
31369 * Returns the value of the super property named property_name. If no such
31370 * property is set, get_property() will return the undefined value.
31371 *
31372 * ### Notes:
31373 *
31374 * get_property() can only be called after the Mixpanel library has finished loading.
31375 * init() has a loaded function available to handle this automatically. For example:
31376 *
31377 * // grab value for 'user_id' after the mixpanel library has loaded
31378 * mixpanel.init('YOUR PROJECT TOKEN', {
31379 * loaded: function(mixpanel) {
31380 * user_id = mixpanel.get_property('user_id');
31381 * }
31382 * });
31383 *
31384 * @param {String} property_name The name of the super property you want to retrieve
31385 */
31386 MixpanelLib.prototype.get_property = function(property_name) {
31387 return this['persistence'].load_prop([property_name]);
31388 };
31389
31390 /**
31391 * Get the API host for a specific endpoint type, falling back to the default api_host if not specified
31392 *
31393 * @param {String} endpoint_type The type of endpoint (e.g., "events", "people", "groups")
31394 * @returns {String} The API host to use for this endpoint
31395 */
31396 MixpanelLib.prototype.get_api_host = function(endpoint_type) {
31397 return this.get_config('api_hosts')[endpoint_type] || this.get_config('api_host');
31398 };
31399
31400 MixpanelLib.prototype.toString = function() {
31401 var name = this.get_config('name');
31402 if (name !== PRIMARY_INSTANCE_NAME) {
31403 name = PRIMARY_INSTANCE_NAME + '.' + name;
31404 }
31405 return name;
31406 };
31407
31408 MixpanelLib.prototype._event_is_disabled = function(event_name) {
31409 return _.isBlockedUA(userAgent) ||
31410 this._flags.disable_all_events ||
31411 _.include(this.__disabled_events, event_name);
31412 };
31413
31414 // perform some housekeeping around GDPR opt-in/out state
31415 MixpanelLib.prototype._gdpr_init = function() {
31416 var is_localStorage_requested = this.get_config('opt_out_tracking_persistence_type') === 'localStorage';
31417
31418 // try to convert opt-in/out cookies to localStorage if possible
31419 if (is_localStorage_requested && _.localStorage.is_supported()) {
31420 if (!this.has_opted_in_tracking() && this.has_opted_in_tracking({'persistence_type': 'cookie'})) {
31421 this.opt_in_tracking({'enable_persistence': false});
31422 }
31423 if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({'persistence_type': 'cookie'})) {
31424 this.opt_out_tracking({'clear_persistence': false});
31425 }
31426 this.clear_opt_in_out_tracking({
31427 'persistence_type': 'cookie',
31428 'enable_persistence': false
31429 });
31430 }
31431
31432 // check whether the user has already opted out - if so, clear & disable persistence
31433 if (this.has_opted_out_tracking()) {
31434 this._gdpr_update_persistence({'clear_persistence': true});
31435
31436 // check whether we should opt out by default
31437 // note: we don't clear persistence here by default since opt-out default state is often
31438 // used as an initial state while GDPR information is being collected
31439 } else if (!this.has_opted_in_tracking() && (
31440 this.get_config('opt_out_tracking_by_default') || _.cookie.get('mp_optout')
31441 )) {
31442 _.cookie.remove('mp_optout');
31443 this.opt_out_tracking({
31444 'clear_persistence': this.get_config('opt_out_persistence_by_default')
31445 });
31446 }
31447 };
31448
31449 /**
31450 * Enable or disable persistence based on options
31451 * only enable/disable if persistence is not already in this state
31452 * @param {boolean} [options.clear_persistence] If true, will delete all data stored by the sdk in persistence and disable it
31453 * @param {boolean} [options.enable_persistence] If true, will re-enable sdk persistence
31454 */
31455 MixpanelLib.prototype._gdpr_update_persistence = function(options) {
31456 var disabled;
31457 if (options && options['clear_persistence']) {
31458 disabled = true;
31459 } else if (options && options['enable_persistence']) {
31460 disabled = false;
31461 } else {
31462 return;
31463 }
31464
31465 if (!this.get_config('disable_persistence') && this['persistence'].disabled !== disabled) {
31466 this['persistence'].set_disabled(disabled);
31467 }
31468
31469 if (disabled) {
31470 this.stop_batch_senders();
31471 this.stop_session_recording();
31472 } else {
31473 // only start batchers after opt-in if they have previously been started
31474 // in order to avoid unintentionally starting up batching for the first time
31475 if (this._batchers_were_started) {
31476 this.start_batch_senders();
31477 }
31478 }
31479 };
31480
31481 // call a base gdpr function after constructing the appropriate token and options args
31482 MixpanelLib.prototype._gdpr_call_func = function(func, options) {
31483 options = _.extend({
31484 'track': _.bind(this.track, this),
31485 'persistence_type': this.get_config('opt_out_tracking_persistence_type'),
31486 'cookie_prefix': this.get_config('opt_out_tracking_cookie_prefix'),
31487 'cookie_expiration': this.get_config('cookie_expiration'),
31488 'cross_site_cookie': this.get_config('cross_site_cookie'),
31489 'cross_subdomain_cookie': this.get_config('cross_subdomain_cookie'),
31490 'cookie_domain': this.get_config('cookie_domain'),
31491 'secure_cookie': this.get_config('secure_cookie'),
31492 'ignore_dnt': this.get_config('ignore_dnt')
31493 }, options);
31494
31495 // check if localStorage can be used for recording opt out status, fall back to cookie if not
31496 if (!_.localStorage.is_supported()) {
31497 options['persistence_type'] = 'cookie';
31498 }
31499
31500 return func(this.get_config('token'), {
31501 track: options['track'],
31502 trackEventName: options['track_event_name'],
31503 trackProperties: options['track_properties'],
31504 persistenceType: options['persistence_type'],
31505 persistencePrefix: options['cookie_prefix'],
31506 cookieDomain: options['cookie_domain'],
31507 cookieExpiration: options['cookie_expiration'],
31508 crossSiteCookie: options['cross_site_cookie'],
31509 crossSubdomainCookie: options['cross_subdomain_cookie'],
31510 secureCookie: options['secure_cookie'],
31511 ignoreDnt: options['ignore_dnt']
31512 });
31513 };
31514
31515 /**
31516 * Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
31517 *
31518 * ### Usage:
31519 *
31520 * // opt user in
31521 * mixpanel.opt_in_tracking();
31522 *
31523 * // opt user in with specific event name, properties, cookie configuration
31524 * mixpanel.opt_in_tracking({
31525 * track_event_name: 'User opted in',
31526 * track_event_properties: {
31527 * 'Email': 'jdoe@example.com'
31528 * },
31529 * cookie_expiration: 30,
31530 * secure_cookie: true
31531 * });
31532 *
31533 * @param {Object} [options] A dictionary of config options to override
31534 * @param {function} [options.track] Function used for tracking a Mixpanel event to record the opt-in action (default is this Mixpanel instance's track method)
31535 * @param {string} [options.track_event_name=$opt_in] Event name to be used for tracking the opt-in action
31536 * @param {Object} [options.track_properties] Set of properties to be tracked along with the opt-in action
31537 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
31538 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31539 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31540 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
31541 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
31542 * @param {boolean} [options.cross_site_cookie] Whether the opt-in cookie is set as cross-site-enabled (overrides value specified in this Mixpanel instance's config)
31543 * @param {boolean} [options.cross_subdomain_cookie] Whether the opt-in cookie is set as cross-subdomain or not (overrides value specified in this Mixpanel instance's config)
31544 * @param {boolean} [options.secure_cookie] Whether the opt-in cookie is set as secure or not (overrides value specified in this Mixpanel instance's config)
31545 */
31546 MixpanelLib.prototype.opt_in_tracking = function(options) {
31547 options = _.extend({
31548 'enable_persistence': true
31549 }, options);
31550
31551 this._gdpr_call_func(optIn, options);
31552 this._gdpr_update_persistence(options);
31553 };
31554
31555 /**
31556 * Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
31557 *
31558 * ### Usage:
31559 *
31560 * // opt user out
31561 * mixpanel.opt_out_tracking();
31562 *
31563 * // opt user out with different cookie configuration from Mixpanel instance
31564 * mixpanel.opt_out_tracking({
31565 * cookie_expiration: 30,
31566 * secure_cookie: true
31567 * });
31568 *
31569 * @param {Object} [options] A dictionary of config options to override
31570 * @param {boolean} [options.delete_user=true] If true, will delete the currently identified user's profile and clear all charges after opting the user out
31571 * @param {boolean} [options.clear_persistence=true] If true, will delete all data stored by the sdk in persistence
31572 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31573 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31574 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
31575 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
31576 * @param {boolean} [options.cross_site_cookie] Whether the opt-in cookie is set as cross-site-enabled (overrides value specified in this Mixpanel instance's config)
31577 * @param {boolean} [options.cross_subdomain_cookie] Whether the opt-in cookie is set as cross-subdomain or not (overrides value specified in this Mixpanel instance's config)
31578 * @param {boolean} [options.secure_cookie] Whether the opt-in cookie is set as secure or not (overrides value specified in this Mixpanel instance's config)
31579 */
31580 MixpanelLib.prototype.opt_out_tracking = function(options) {
31581 options = _.extend({
31582 'clear_persistence': true,
31583 'delete_user': true
31584 }, options);
31585
31586 // delete user and clear charges since these methods may be disabled by opt-out
31587 if (options['delete_user'] && this['people'] && this['people']._identify_called()) {
31588 this['people'].delete_user();
31589 this['people'].clear_charges();
31590 }
31591
31592 this._gdpr_call_func(optOut, options);
31593 this._gdpr_update_persistence(options);
31594 };
31595
31596 /**
31597 * Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
31598 *
31599 * ### Usage:
31600 *
31601 * var has_opted_in = mixpanel.has_opted_in_tracking();
31602 * // use has_opted_in value
31603 *
31604 * @param {Object} [options] A dictionary of config options to override
31605 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31606 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31607 * @returns {boolean} current opt-in status
31608 */
31609 MixpanelLib.prototype.has_opted_in_tracking = function(options) {
31610 return this._gdpr_call_func(hasOptedIn, options);
31611 };
31612
31613 /**
31614 * Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
31615 *
31616 * ### Usage:
31617 *
31618 * var has_opted_out = mixpanel.has_opted_out_tracking();
31619 * // use has_opted_out value
31620 *
31621 * @param {Object} [options] A dictionary of config options to override
31622 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31623 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31624 * @returns {boolean} current opt-out status
31625 */
31626 MixpanelLib.prototype.has_opted_out_tracking = function(options) {
31627 return this._gdpr_call_func(hasOptedOut, options);
31628 };
31629
31630 /**
31631 * Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
31632 *
31633 * ### Usage:
31634 *
31635 * // clear user's opt-in/out status
31636 * mixpanel.clear_opt_in_out_tracking();
31637 *
31638 * // clear user's opt-in/out status with specific cookie configuration - should match
31639 * // configuration used when opt_in_tracking/opt_out_tracking methods were called.
31640 * mixpanel.clear_opt_in_out_tracking({
31641 * cookie_expiration: 30,
31642 * secure_cookie: true
31643 * });
31644 *
31645 * @param {Object} [options] A dictionary of config options to override
31646 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
31647 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31648 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31649 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
31650 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
31651 * @param {boolean} [options.cross_site_cookie] Whether the opt-in cookie is set as cross-site-enabled (overrides value specified in this Mixpanel instance's config)
31652 * @param {boolean} [options.cross_subdomain_cookie] Whether the opt-in cookie is set as cross-subdomain or not (overrides value specified in this Mixpanel instance's config)
31653 * @param {boolean} [options.secure_cookie] Whether the opt-in cookie is set as secure or not (overrides value specified in this Mixpanel instance's config)
31654 */
31655 MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
31656 options = _.extend({
31657 'enable_persistence': true
31658 }, options);
31659
31660 this._gdpr_call_func(clearOptInOut, options);
31661 this._gdpr_update_persistence(options);
31662 };
31663
31664 MixpanelLib.prototype.report_error = function(msg, err) {
31665 console$1.error.apply(console$1.error, arguments);
31666 try {
31667 if (!err && !(msg instanceof Error)) {
31668 msg = new Error(msg);
31669 }
31670 this.get_config('error_reporter')(msg, err);
31671 } catch(err) {
31672 console$1.error(err);
31673 }
31674 };
31675
31676 // EXPORTS (for closure compiler)
31677
31678 // MixpanelLib Exports
31679 MixpanelLib.prototype['init'] = MixpanelLib.prototype.init;
31680 MixpanelLib.prototype['reset'] = MixpanelLib.prototype.reset;
31681 MixpanelLib.prototype['disable'] = MixpanelLib.prototype.disable;
31682 MixpanelLib.prototype['time_event'] = MixpanelLib.prototype.time_event;
31683 MixpanelLib.prototype['track'] = MixpanelLib.prototype.track;
31684 MixpanelLib.prototype['track_links'] = MixpanelLib.prototype.track_links;
31685 MixpanelLib.prototype['track_forms'] = MixpanelLib.prototype.track_forms;
31686 MixpanelLib.prototype['track_pageview'] = MixpanelLib.prototype.track_pageview;
31687 MixpanelLib.prototype['register'] = MixpanelLib.prototype.register;
31688 MixpanelLib.prototype['register_once'] = MixpanelLib.prototype.register_once;
31689 MixpanelLib.prototype['unregister'] = MixpanelLib.prototype.unregister;
31690 MixpanelLib.prototype['identify'] = MixpanelLib.prototype.identify;
31691 MixpanelLib.prototype['alias'] = MixpanelLib.prototype.alias;
31692 MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
31693 MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
31694 MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
31695 MixpanelLib.prototype['get_api_host'] = MixpanelLib.prototype.get_api_host;
31696 MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
31697 MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
31698 MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
31699 MixpanelLib.prototype['opt_out_tracking'] = MixpanelLib.prototype.opt_out_tracking;
31700 MixpanelLib.prototype['opt_in_tracking'] = MixpanelLib.prototype.opt_in_tracking;
31701 MixpanelLib.prototype['has_opted_out_tracking'] = MixpanelLib.prototype.has_opted_out_tracking;
31702 MixpanelLib.prototype['has_opted_in_tracking'] = MixpanelLib.prototype.has_opted_in_tracking;
31703 MixpanelLib.prototype['clear_opt_in_out_tracking'] = MixpanelLib.prototype.clear_opt_in_out_tracking;
31704 MixpanelLib.prototype['get_group'] = MixpanelLib.prototype.get_group;
31705 MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
31706 MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
31707 MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
31708 MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
31709 MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
31710 MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;
31711 MixpanelLib.prototype['start_session_recording'] = MixpanelLib.prototype.start_session_recording;
31712 MixpanelLib.prototype['stop_session_recording'] = MixpanelLib.prototype.stop_session_recording;
31713 MixpanelLib.prototype['pause_session_recording'] = MixpanelLib.prototype.pause_session_recording;
31714 MixpanelLib.prototype['resume_session_recording'] = MixpanelLib.prototype.resume_session_recording;
31715 MixpanelLib.prototype['get_session_recording_properties'] = MixpanelLib.prototype.get_session_recording_properties;
31716 MixpanelLib.prototype['get_session_replay_url'] = MixpanelLib.prototype.get_session_replay_url;
31717 MixpanelLib.prototype['get_tab_id'] = MixpanelLib.prototype.get_tab_id;
31718 MixpanelLib.prototype['DEFAULT_API_ROUTES'] = DEFAULT_API_ROUTES;
31719
31720 // Exports intended only for testing
31721 MixpanelLib.prototype['__get_recorder'] = MixpanelLib.prototype.__get_recorder;
31722
31723 // MixpanelPersistence Exports
31724 MixpanelPersistence.prototype['properties'] = MixpanelPersistence.prototype.properties;
31725 MixpanelPersistence.prototype['update_search_keyword'] = MixpanelPersistence.prototype.update_search_keyword;
31726 MixpanelPersistence.prototype['update_referrer_info'] = MixpanelPersistence.prototype.update_referrer_info;
31727 MixpanelPersistence.prototype['get_cross_subdomain'] = MixpanelPersistence.prototype.get_cross_subdomain;
31728 MixpanelPersistence.prototype['clear'] = MixpanelPersistence.prototype.clear;
31729
31730
31731 var instances = {};
31732 var extend_mp = function() {
31733 // add all the sub mixpanel instances
31734 _.each(instances, function(instance, name) {
31735 if (name !== PRIMARY_INSTANCE_NAME) { mixpanel_master[name] = instance; }
31736 });
31737
31738 // add private functions as _
31739 mixpanel_master['_'] = _;
31740 };
31741
31742 var override_mp_init_func = function() {
31743 // we override the snippets init function to handle the case where a
31744 // user initializes the mixpanel library after the script loads & runs
31745 mixpanel_master['init'] = function(token, config, name) {
31746 if (name) {
31747 // initialize a sub library
31748 if (!mixpanel_master[name]) {
31749 mixpanel_master[name] = instances[name] = create_mplib(token, config, name);
31750 mixpanel_master[name]._loaded();
31751 }
31752 return mixpanel_master[name];
31753 } else {
31754 var instance = mixpanel_master;
31755
31756 if (instances[PRIMARY_INSTANCE_NAME]) {
31757 // main mixpanel lib already initialized
31758 instance = instances[PRIMARY_INSTANCE_NAME];
31759 } else if (token) {
31760 // intialize the main mixpanel lib
31761 instance = create_mplib(token, config, PRIMARY_INSTANCE_NAME);
31762 instance._loaded();
31763 instances[PRIMARY_INSTANCE_NAME] = instance;
31764 }
31765
31766 mixpanel_master = instance;
31767 if (init_type === INIT_SNIPPET) {
31768 win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
31769 }
31770 extend_mp();
31771 }
31772 };
31773 };
31774
31775 var add_dom_loaded_handler = function() {
31776 // Cross browser DOM Loaded support
31777 function dom_loaded_handler() {
31778 // function flag since we only want to execute this once
31779 if (dom_loaded_handler.done) { return; }
31780 dom_loaded_handler.done = true;
31781
31782 DOM_LOADED = true;
31783 ENQUEUE_REQUESTS = false;
31784
31785 _.each(instances, function(inst) {
31786 inst._dom_loaded();
31787 });
31788 }
31789
31790 function do_scroll_check() {
31791 try {
31792 document$1.documentElement.doScroll('left');
31793 } catch(e) {
31794 setTimeout(do_scroll_check, 1);
31795 return;
31796 }
31797
31798 dom_loaded_handler();
31799 }
31800
31801 if (document$1.addEventListener) {
31802 if (document$1.readyState === 'complete') {
31803 // safari 4 can fire the DOMContentLoaded event before loading all
31804 // external JS (including this file). you will see some copypasta
31805 // on the internet that checks for 'complete' and 'loaded', but
31806 // 'loaded' is an IE thing
31807 dom_loaded_handler();
31808 } else {
31809 document$1.addEventListener('DOMContentLoaded', dom_loaded_handler, false);
31810 }
31811 } else if (document$1.attachEvent) {
31812 // IE
31813 document$1.attachEvent('onreadystatechange', dom_loaded_handler);
31814
31815 // check to make sure we arn't in a frame
31816 var toplevel = false;
31817 try {
31818 toplevel = win.frameElement === null;
31819 } catch(e) {
31820 // noop
31821 }
31822
31823 if (document$1.documentElement.doScroll && toplevel) {
31824 do_scroll_check();
31825 }
31826 }
31827
31828 // fallback handler, always will work
31829 _.register_event(win, 'load', dom_loaded_handler, true);
31830 };
31831
31832 function init_as_module(bundle_loader) {
31833 load_extra_bundle = bundle_loader;
31834 init_type = INIT_MODULE;
31835 mixpanel_master = new MixpanelLib();
31836
31837 override_mp_init_func();
31838 mixpanel_master['init']();
31839 add_dom_loaded_handler();
31840
31841 return mixpanel_master;
31842 }
31843
31844 // For loading separate bundles asynchronously via script tag
31845 // so that we don't load them until they are needed at runtime.
31846
31847 // For builds that have everything in one bundle, no extra work.
31848 function loadNoop (_src, onload) {
31849 onload();
31850 }
31851
31852 /* eslint camelcase: "off" */
31853
31854 var mixpanel = init_as_module(loadNoop);
31855
31856
31857
31858
31859 /***/ }),
31860
31861 /***/ "../node_modules/redux-thunk/es/index.js":
31862 /*!***********************************************!*\
31863 !*** ../node_modules/redux-thunk/es/index.js ***!
31864 \***********************************************/
31865 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
31866
31867 "use strict";
31868 __webpack_require__.r(__webpack_exports__);
31869 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
31870 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
31871 /* harmony export */ });
31872 /** A function that accepts a potential "extra argument" value to be injected later,
31873 * and returns an instance of the thunk middleware that uses that value
31874 */
31875 function createThunkMiddleware(extraArgument) {
31876 // Standard Redux middleware definition pattern:
31877 // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
31878 var middleware = function middleware(_ref) {
31879 var dispatch = _ref.dispatch,
31880 getState = _ref.getState;
31881 return function (next) {
31882 return function (action) {
31883 // The thunk middleware looks for any functions that were passed to `store.dispatch`.
31884 // If this "action" is really a function, call it and return the result.
31885 if (typeof action === 'function') {
31886 // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
31887 return action(dispatch, getState, extraArgument);
31888 } // Otherwise, pass the action down the middleware chain as usual
31889
31890
31891 return next(action);
31892 };
31893 };
31894 };
31895
31896 return middleware;
31897 }
31898
31899 var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
31900 // with whatever "extra arg" they want to inject into their thunks
31901
31902 thunk.withExtraArgument = createThunkMiddleware;
31903 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (thunk);
31904
31905 /***/ }),
31906
31907 /***/ "../node_modules/redux/es/redux.js":
31908 /*!*****************************************!*\
31909 !*** ../node_modules/redux/es/redux.js ***!
31910 \*****************************************/
31911 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
31912
31913 "use strict";
31914 __webpack_require__.r(__webpack_exports__);
31915 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
31916 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* binding */ ActionTypes),
31917 /* harmony export */ applyMiddleware: () => (/* binding */ applyMiddleware),
31918 /* harmony export */ bindActionCreators: () => (/* binding */ bindActionCreators),
31919 /* harmony export */ combineReducers: () => (/* binding */ combineReducers),
31920 /* harmony export */ compose: () => (/* binding */ compose),
31921 /* harmony export */ createStore: () => (/* binding */ createStore),
31922 /* harmony export */ legacy_createStore: () => (/* binding */ legacy_createStore)
31923 /* harmony export */ });
31924 /* harmony import */ var _babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/objectSpread2 */ "../node_modules/@babel/runtime/helpers/esm/objectSpread2.js");
31925
31926
31927 /**
31928 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
31929 *
31930 * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
31931 * during build.
31932 * @param {number} code
31933 */
31934 function formatProdErrorMessage(code) {
31935 return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
31936 }
31937
31938 // Inlined version of the `symbol-observable` polyfill
31939 var $$observable = (function () {
31940 return typeof Symbol === 'function' && Symbol.observable || '@@observable';
31941 })();
31942
31943 /**
31944 * These are private action types reserved by Redux.
31945 * For any unknown actions, you must return the current state.
31946 * If the current state is undefined, you must return the initial state.
31947 * Do not reference these action types directly in your code.
31948 */
31949 var randomString = function randomString() {
31950 return Math.random().toString(36).substring(7).split('').join('.');
31951 };
31952
31953 var ActionTypes = {
31954 INIT: "@@redux/INIT" + randomString(),
31955 REPLACE: "@@redux/REPLACE" + randomString(),
31956 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
31957 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
31958 }
31959 };
31960
31961 /**
31962 * @param {any} obj The object to inspect.
31963 * @returns {boolean} True if the argument appears to be a plain object.
31964 */
31965 function isPlainObject(obj) {
31966 if (typeof obj !== 'object' || obj === null) return false;
31967 var proto = obj;
31968
31969 while (Object.getPrototypeOf(proto) !== null) {
31970 proto = Object.getPrototypeOf(proto);
31971 }
31972
31973 return Object.getPrototypeOf(obj) === proto;
31974 }
31975
31976 // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
31977 function miniKindOf(val) {
31978 if (val === void 0) return 'undefined';
31979 if (val === null) return 'null';
31980 var type = typeof val;
31981
31982 switch (type) {
31983 case 'boolean':
31984 case 'string':
31985 case 'number':
31986 case 'symbol':
31987 case 'function':
31988 {
31989 return type;
31990 }
31991 }
31992
31993 if (Array.isArray(val)) return 'array';
31994 if (isDate(val)) return 'date';
31995 if (isError(val)) return 'error';
31996 var constructorName = ctorName(val);
31997
31998 switch (constructorName) {
31999 case 'Symbol':
32000 case 'Promise':
32001 case 'WeakMap':
32002 case 'WeakSet':
32003 case 'Map':
32004 case 'Set':
32005 return constructorName;
32006 } // other
32007
32008
32009 return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
32010 }
32011
32012 function ctorName(val) {
32013 return typeof val.constructor === 'function' ? val.constructor.name : null;
32014 }
32015
32016 function isError(val) {
32017 return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
32018 }
32019
32020 function isDate(val) {
32021 if (val instanceof Date) return true;
32022 return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
32023 }
32024
32025 function kindOf(val) {
32026 var typeOfVal = typeof val;
32027
32028 if (true) {
32029 typeOfVal = miniKindOf(val);
32030 }
32031
32032 return typeOfVal;
32033 }
32034
32035 /**
32036 * @deprecated
32037 *
32038 * **We recommend using the `configureStore` method
32039 * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
32040 *
32041 * Redux Toolkit is our recommended approach for writing Redux logic today,
32042 * including store setup, reducers, data fetching, and more.
32043 *
32044 * **For more details, please read this Redux docs page:**
32045 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32046 *
32047 * `configureStore` from Redux Toolkit is an improved version of `createStore` that
32048 * simplifies setup and helps avoid common bugs.
32049 *
32050 * You should not be using the `redux` core package by itself today, except for learning purposes.
32051 * The `createStore` method from the core `redux` package will not be removed, but we encourage
32052 * all users to migrate to using Redux Toolkit for all Redux code.
32053 *
32054 * If you want to use `createStore` without this visual deprecation warning, use
32055 * the `legacy_createStore` import instead:
32056 *
32057 * `import { legacy_createStore as createStore} from 'redux'`
32058 *
32059 */
32060
32061 function createStore(reducer, preloadedState, enhancer) {
32062 var _ref2;
32063
32064 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
32065 throw new Error( false ? 0 : 'It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.');
32066 }
32067
32068 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
32069 enhancer = preloadedState;
32070 preloadedState = undefined;
32071 }
32072
32073 if (typeof enhancer !== 'undefined') {
32074 if (typeof enhancer !== 'function') {
32075 throw new Error( false ? 0 : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
32076 }
32077
32078 return enhancer(createStore)(reducer, preloadedState);
32079 }
32080
32081 if (typeof reducer !== 'function') {
32082 throw new Error( false ? 0 : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
32083 }
32084
32085 var currentReducer = reducer;
32086 var currentState = preloadedState;
32087 var currentListeners = [];
32088 var nextListeners = currentListeners;
32089 var isDispatching = false;
32090 /**
32091 * This makes a shallow copy of currentListeners so we can use
32092 * nextListeners as a temporary list while dispatching.
32093 *
32094 * This prevents any bugs around consumers calling
32095 * subscribe/unsubscribe in the middle of a dispatch.
32096 */
32097
32098 function ensureCanMutateNextListeners() {
32099 if (nextListeners === currentListeners) {
32100 nextListeners = currentListeners.slice();
32101 }
32102 }
32103 /**
32104 * Reads the state tree managed by the store.
32105 *
32106 * @returns {any} The current state tree of your application.
32107 */
32108
32109
32110 function getState() {
32111 if (isDispatching) {
32112 throw new Error( false ? 0 : 'You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
32113 }
32114
32115 return currentState;
32116 }
32117 /**
32118 * Adds a change listener. It will be called any time an action is dispatched,
32119 * and some part of the state tree may potentially have changed. You may then
32120 * call `getState()` to read the current state tree inside the callback.
32121 *
32122 * You may call `dispatch()` from a change listener, with the following
32123 * caveats:
32124 *
32125 * 1. The subscriptions are snapshotted just before every `dispatch()` call.
32126 * If you subscribe or unsubscribe while the listeners are being invoked, this
32127 * will not have any effect on the `dispatch()` that is currently in progress.
32128 * However, the next `dispatch()` call, whether nested or not, will use a more
32129 * recent snapshot of the subscription list.
32130 *
32131 * 2. The listener should not expect to see all state changes, as the state
32132 * might have been updated multiple times during a nested `dispatch()` before
32133 * the listener is called. It is, however, guaranteed that all subscribers
32134 * registered before the `dispatch()` started will be called with the latest
32135 * state by the time it exits.
32136 *
32137 * @param {Function} listener A callback to be invoked on every dispatch.
32138 * @returns {Function} A function to remove this change listener.
32139 */
32140
32141
32142 function subscribe(listener) {
32143 if (typeof listener !== 'function') {
32144 throw new Error( false ? 0 : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
32145 }
32146
32147 if (isDispatching) {
32148 throw new Error( false ? 0 : 'You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
32149 }
32150
32151 var isSubscribed = true;
32152 ensureCanMutateNextListeners();
32153 nextListeners.push(listener);
32154 return function unsubscribe() {
32155 if (!isSubscribed) {
32156 return;
32157 }
32158
32159 if (isDispatching) {
32160 throw new Error( false ? 0 : 'You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
32161 }
32162
32163 isSubscribed = false;
32164 ensureCanMutateNextListeners();
32165 var index = nextListeners.indexOf(listener);
32166 nextListeners.splice(index, 1);
32167 currentListeners = null;
32168 };
32169 }
32170 /**
32171 * Dispatches an action. It is the only way to trigger a state change.
32172 *
32173 * The `reducer` function, used to create the store, will be called with the
32174 * current state tree and the given `action`. Its return value will
32175 * be considered the **next** state of the tree, and the change listeners
32176 * will be notified.
32177 *
32178 * The base implementation only supports plain object actions. If you want to
32179 * dispatch a Promise, an Observable, a thunk, or something else, you need to
32180 * wrap your store creating function into the corresponding middleware. For
32181 * example, see the documentation for the `redux-thunk` package. Even the
32182 * middleware will eventually dispatch plain object actions using this method.
32183 *
32184 * @param {Object} action A plain object representing “what changed”. It is
32185 * a good idea to keep actions serializable so you can record and replay user
32186 * sessions, or use the time travelling `redux-devtools`. An action must have
32187 * a `type` property which may not be `undefined`. It is a good idea to use
32188 * string constants for action types.
32189 *
32190 * @returns {Object} For convenience, the same action object you dispatched.
32191 *
32192 * Note that, if you use a custom middleware, it may wrap `dispatch()` to
32193 * return something else (for example, a Promise you can await).
32194 */
32195
32196
32197 function dispatch(action) {
32198 if (!isPlainObject(action)) {
32199 throw new Error( false ? 0 : "Actions must be plain objects. Instead, the actual type was: '" + kindOf(action) + "'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");
32200 }
32201
32202 if (typeof action.type === 'undefined') {
32203 throw new Error( false ? 0 : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
32204 }
32205
32206 if (isDispatching) {
32207 throw new Error( false ? 0 : 'Reducers may not dispatch actions.');
32208 }
32209
32210 try {
32211 isDispatching = true;
32212 currentState = currentReducer(currentState, action);
32213 } finally {
32214 isDispatching = false;
32215 }
32216
32217 var listeners = currentListeners = nextListeners;
32218
32219 for (var i = 0; i < listeners.length; i++) {
32220 var listener = listeners[i];
32221 listener();
32222 }
32223
32224 return action;
32225 }
32226 /**
32227 * Replaces the reducer currently used by the store to calculate the state.
32228 *
32229 * You might need this if your app implements code splitting and you want to
32230 * load some of the reducers dynamically. You might also need this if you
32231 * implement a hot reloading mechanism for Redux.
32232 *
32233 * @param {Function} nextReducer The reducer for the store to use instead.
32234 * @returns {void}
32235 */
32236
32237
32238 function replaceReducer(nextReducer) {
32239 if (typeof nextReducer !== 'function') {
32240 throw new Error( false ? 0 : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
32241 }
32242
32243 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
32244 // Any reducers that existed in both the new and old rootReducer
32245 // will receive the previous state. This effectively populates
32246 // the new state tree with any relevant data from the old one.
32247
32248 dispatch({
32249 type: ActionTypes.REPLACE
32250 });
32251 }
32252 /**
32253 * Interoperability point for observable/reactive libraries.
32254 * @returns {observable} A minimal observable of state changes.
32255 * For more information, see the observable proposal:
32256 * https://github.com/tc39/proposal-observable
32257 */
32258
32259
32260 function observable() {
32261 var _ref;
32262
32263 var outerSubscribe = subscribe;
32264 return _ref = {
32265 /**
32266 * The minimal observable subscription method.
32267 * @param {Object} observer Any object that can be used as an observer.
32268 * The observer object should have a `next` method.
32269 * @returns {subscription} An object with an `unsubscribe` method that can
32270 * be used to unsubscribe the observable from the store, and prevent further
32271 * emission of values from the observable.
32272 */
32273 subscribe: function subscribe(observer) {
32274 if (typeof observer !== 'object' || observer === null) {
32275 throw new Error( false ? 0 : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
32276 }
32277
32278 function observeState() {
32279 if (observer.next) {
32280 observer.next(getState());
32281 }
32282 }
32283
32284 observeState();
32285 var unsubscribe = outerSubscribe(observeState);
32286 return {
32287 unsubscribe: unsubscribe
32288 };
32289 }
32290 }, _ref[$$observable] = function () {
32291 return this;
32292 }, _ref;
32293 } // When a store is created, an "INIT" action is dispatched so that every
32294 // reducer returns their initial state. This effectively populates
32295 // the initial state tree.
32296
32297
32298 dispatch({
32299 type: ActionTypes.INIT
32300 });
32301 return _ref2 = {
32302 dispatch: dispatch,
32303 subscribe: subscribe,
32304 getState: getState,
32305 replaceReducer: replaceReducer
32306 }, _ref2[$$observable] = observable, _ref2;
32307 }
32308 /**
32309 * Creates a Redux store that holds the state tree.
32310 *
32311 * **We recommend using `configureStore` from the
32312 * `@reduxjs/toolkit` package**, which replaces `createStore`:
32313 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32314 *
32315 * The only way to change the data in the store is to call `dispatch()` on it.
32316 *
32317 * There should only be a single store in your app. To specify how different
32318 * parts of the state tree respond to actions, you may combine several reducers
32319 * into a single reducer function by using `combineReducers`.
32320 *
32321 * @param {Function} reducer A function that returns the next state tree, given
32322 * the current state tree and the action to handle.
32323 *
32324 * @param {any} [preloadedState] The initial state. You may optionally specify it
32325 * to hydrate the state from the server in universal apps, or to restore a
32326 * previously serialized user session.
32327 * If you use `combineReducers` to produce the root reducer function, this must be
32328 * an object with the same shape as `combineReducers` keys.
32329 *
32330 * @param {Function} [enhancer] The store enhancer. You may optionally specify it
32331 * to enhance the store with third-party capabilities such as middleware,
32332 * time travel, persistence, etc. The only store enhancer that ships with Redux
32333 * is `applyMiddleware()`.
32334 *
32335 * @returns {Store} A Redux store that lets you read the state, dispatch actions
32336 * and subscribe to changes.
32337 */
32338
32339 var legacy_createStore = createStore;
32340
32341 /**
32342 * Prints a warning in the console if it exists.
32343 *
32344 * @param {String} message The warning message.
32345 * @returns {void}
32346 */
32347 function warning(message) {
32348 /* eslint-disable no-console */
32349 if (typeof console !== 'undefined' && typeof console.error === 'function') {
32350 console.error(message);
32351 }
32352 /* eslint-enable no-console */
32353
32354
32355 try {
32356 // This error was thrown as a convenience so that if you enable
32357 // "break on all exceptions" in your console,
32358 // it would pause the execution at this line.
32359 throw new Error(message);
32360 } catch (e) {} // eslint-disable-line no-empty
32361
32362 }
32363
32364 function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
32365 var reducerKeys = Object.keys(reducers);
32366 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
32367
32368 if (reducerKeys.length === 0) {
32369 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
32370 }
32371
32372 if (!isPlainObject(inputState)) {
32373 return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
32374 }
32375
32376 var unexpectedKeys = Object.keys(inputState).filter(function (key) {
32377 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
32378 });
32379 unexpectedKeys.forEach(function (key) {
32380 unexpectedKeyCache[key] = true;
32381 });
32382 if (action && action.type === ActionTypes.REPLACE) return;
32383
32384 if (unexpectedKeys.length > 0) {
32385 return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored.");
32386 }
32387 }
32388
32389 function assertReducerShape(reducers) {
32390 Object.keys(reducers).forEach(function (key) {
32391 var reducer = reducers[key];
32392 var initialState = reducer(undefined, {
32393 type: ActionTypes.INIT
32394 });
32395
32396 if (typeof initialState === 'undefined') {
32397 throw new Error( false ? 0 : "The slice reducer for key \"" + key + "\" returned undefined during initialization. " + "If the state passed to the reducer is undefined, you must " + "explicitly return the initial state. The initial state may " + "not be undefined. If you don't want to set a value for this reducer, " + "you can use null instead of undefined.");
32398 }
32399
32400 if (typeof reducer(undefined, {
32401 type: ActionTypes.PROBE_UNKNOWN_ACTION()
32402 }) === 'undefined') {
32403 throw new Error( false ? 0 : "The slice reducer for key \"" + key + "\" returned undefined when probed with a random type. " + ("Don't try to handle '" + ActionTypes.INIT + "' or other actions in \"redux/*\" ") + "namespace. They are considered private. Instead, you must return the " + "current state for any unknown actions, unless it is undefined, " + "in which case you must return the initial state, regardless of the " + "action type. The initial state may not be undefined, but can be null.");
32404 }
32405 });
32406 }
32407 /**
32408 * Turns an object whose values are different reducer functions, into a single
32409 * reducer function. It will call every child reducer, and gather their results
32410 * into a single state object, whose keys correspond to the keys of the passed
32411 * reducer functions.
32412 *
32413 * @param {Object} reducers An object whose values correspond to different
32414 * reducer functions that need to be combined into one. One handy way to obtain
32415 * it is to use ES6 `import * as reducers` syntax. The reducers may never return
32416 * undefined for any action. Instead, they should return their initial state
32417 * if the state passed to them was undefined, and the current state for any
32418 * unrecognized action.
32419 *
32420 * @returns {Function} A reducer function that invokes every reducer inside the
32421 * passed object, and builds a state object with the same shape.
32422 */
32423
32424
32425 function combineReducers(reducers) {
32426 var reducerKeys = Object.keys(reducers);
32427 var finalReducers = {};
32428
32429 for (var i = 0; i < reducerKeys.length; i++) {
32430 var key = reducerKeys[i];
32431
32432 if (true) {
32433 if (typeof reducers[key] === 'undefined') {
32434 warning("No reducer provided for key \"" + key + "\"");
32435 }
32436 }
32437
32438 if (typeof reducers[key] === 'function') {
32439 finalReducers[key] = reducers[key];
32440 }
32441 }
32442
32443 var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
32444 // keys multiple times.
32445
32446 var unexpectedKeyCache;
32447
32448 if (true) {
32449 unexpectedKeyCache = {};
32450 }
32451
32452 var shapeAssertionError;
32453
32454 try {
32455 assertReducerShape(finalReducers);
32456 } catch (e) {
32457 shapeAssertionError = e;
32458 }
32459
32460 return function combination(state, action) {
32461 if (state === void 0) {
32462 state = {};
32463 }
32464
32465 if (shapeAssertionError) {
32466 throw shapeAssertionError;
32467 }
32468
32469 if (true) {
32470 var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
32471
32472 if (warningMessage) {
32473 warning(warningMessage);
32474 }
32475 }
32476
32477 var hasChanged = false;
32478 var nextState = {};
32479
32480 for (var _i = 0; _i < finalReducerKeys.length; _i++) {
32481 var _key = finalReducerKeys[_i];
32482 var reducer = finalReducers[_key];
32483 var previousStateForKey = state[_key];
32484 var nextStateForKey = reducer(previousStateForKey, action);
32485
32486 if (typeof nextStateForKey === 'undefined') {
32487 var actionType = action && action.type;
32488 throw new Error( false ? 0 : "When called with an action of type " + (actionType ? "\"" + String(actionType) + "\"" : '(unknown type)') + ", the slice reducer for key \"" + _key + "\" returned undefined. " + "To ignore an action, you must explicitly return the previous state. " + "If you want this reducer to hold no value, you can return null instead of undefined.");
32489 }
32490
32491 nextState[_key] = nextStateForKey;
32492 hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
32493 }
32494
32495 hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
32496 return hasChanged ? nextState : state;
32497 };
32498 }
32499
32500 function bindActionCreator(actionCreator, dispatch) {
32501 return function () {
32502 return dispatch(actionCreator.apply(this, arguments));
32503 };
32504 }
32505 /**
32506 * Turns an object whose values are action creators, into an object with the
32507 * same keys, but with every function wrapped into a `dispatch` call so they
32508 * may be invoked directly. This is just a convenience method, as you can call
32509 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
32510 *
32511 * For convenience, you can also pass an action creator as the first argument,
32512 * and get a dispatch wrapped function in return.
32513 *
32514 * @param {Function|Object} actionCreators An object whose values are action
32515 * creator functions. One handy way to obtain it is to use ES6 `import * as`
32516 * syntax. You may also pass a single function.
32517 *
32518 * @param {Function} dispatch The `dispatch` function available on your Redux
32519 * store.
32520 *
32521 * @returns {Function|Object} The object mimicking the original object, but with
32522 * every action creator wrapped into the `dispatch` call. If you passed a
32523 * function as `actionCreators`, the return value will also be a single
32524 * function.
32525 */
32526
32527
32528 function bindActionCreators(actionCreators, dispatch) {
32529 if (typeof actionCreators === 'function') {
32530 return bindActionCreator(actionCreators, dispatch);
32531 }
32532
32533 if (typeof actionCreators !== 'object' || actionCreators === null) {
32534 throw new Error( false ? 0 : "bindActionCreators expected an object or a function, but instead received: '" + kindOf(actionCreators) + "'. " + "Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?");
32535 }
32536
32537 var boundActionCreators = {};
32538
32539 for (var key in actionCreators) {
32540 var actionCreator = actionCreators[key];
32541
32542 if (typeof actionCreator === 'function') {
32543 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
32544 }
32545 }
32546
32547 return boundActionCreators;
32548 }
32549
32550 /**
32551 * Composes single-argument functions from right to left. The rightmost
32552 * function can take multiple arguments as it provides the signature for
32553 * the resulting composite function.
32554 *
32555 * @param {...Function} funcs The functions to compose.
32556 * @returns {Function} A function obtained by composing the argument functions
32557 * from right to left. For example, compose(f, g, h) is identical to doing
32558 * (...args) => f(g(h(...args))).
32559 */
32560 function compose() {
32561 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
32562 funcs[_key] = arguments[_key];
32563 }
32564
32565 if (funcs.length === 0) {
32566 return function (arg) {
32567 return arg;
32568 };
32569 }
32570
32571 if (funcs.length === 1) {
32572 return funcs[0];
32573 }
32574
32575 return funcs.reduce(function (a, b) {
32576 return function () {
32577 return a(b.apply(void 0, arguments));
32578 };
32579 });
32580 }
32581
32582 /**
32583 * Creates a store enhancer that applies middleware to the dispatch method
32584 * of the Redux store. This is handy for a variety of tasks, such as expressing
32585 * asynchronous actions in a concise manner, or logging every action payload.
32586 *
32587 * See `redux-thunk` package as an example of the Redux middleware.
32588 *
32589 * Because middleware is potentially asynchronous, this should be the first
32590 * store enhancer in the composition chain.
32591 *
32592 * Note that each middleware will be given the `dispatch` and `getState` functions
32593 * as named arguments.
32594 *
32595 * @param {...Function} middlewares The middleware chain to be applied.
32596 * @returns {Function} A store enhancer applying the middleware.
32597 */
32598
32599 function applyMiddleware() {
32600 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
32601 middlewares[_key] = arguments[_key];
32602 }
32603
32604 return function (createStore) {
32605 return function () {
32606 var store = createStore.apply(void 0, arguments);
32607
32608 var _dispatch = function dispatch() {
32609 throw new Error( false ? 0 : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
32610 };
32611
32612 var middlewareAPI = {
32613 getState: store.getState,
32614 dispatch: function dispatch() {
32615 return _dispatch.apply(void 0, arguments);
32616 }
32617 };
32618 var chain = middlewares.map(function (middleware) {
32619 return middleware(middlewareAPI);
32620 });
32621 _dispatch = compose.apply(void 0, chain)(store.dispatch);
32622 return (0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])((0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])({}, store), {}, {
32623 dispatch: _dispatch
32624 });
32625 };
32626 };
32627 }
32628
32629
32630
32631
32632 /***/ }),
32633
32634 /***/ "../node_modules/reselect/es/defaultMemoize.js":
32635 /*!*****************************************************!*\
32636 !*** ../node_modules/reselect/es/defaultMemoize.js ***!
32637 \*****************************************************/
32638 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32639
32640 "use strict";
32641 __webpack_require__.r(__webpack_exports__);
32642 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32643 /* harmony export */ createCacheKeyComparator: () => (/* binding */ createCacheKeyComparator),
32644 /* harmony export */ defaultEqualityCheck: () => (/* binding */ defaultEqualityCheck),
32645 /* harmony export */ defaultMemoize: () => (/* binding */ defaultMemoize)
32646 /* harmony export */ });
32647 // Cache implementation based on Erik Rasmussen's `lru-memoize`:
32648 // https://github.com/erikras/lru-memoize
32649 var NOT_FOUND = 'NOT_FOUND';
32650
32651 function createSingletonCache(equals) {
32652 var entry;
32653 return {
32654 get: function get(key) {
32655 if (entry && equals(entry.key, key)) {
32656 return entry.value;
32657 }
32658
32659 return NOT_FOUND;
32660 },
32661 put: function put(key, value) {
32662 entry = {
32663 key: key,
32664 value: value
32665 };
32666 },
32667 getEntries: function getEntries() {
32668 return entry ? [entry] : [];
32669 },
32670 clear: function clear() {
32671 entry = undefined;
32672 }
32673 };
32674 }
32675
32676 function createLruCache(maxSize, equals) {
32677 var entries = [];
32678
32679 function get(key) {
32680 var cacheIndex = entries.findIndex(function (entry) {
32681 return equals(key, entry.key);
32682 }); // We found a cached entry
32683
32684 if (cacheIndex > -1) {
32685 var entry = entries[cacheIndex]; // Cached entry not at top of cache, move it to the top
32686
32687 if (cacheIndex > 0) {
32688 entries.splice(cacheIndex, 1);
32689 entries.unshift(entry);
32690 }
32691
32692 return entry.value;
32693 } // No entry found in cache, return sentinel
32694
32695
32696 return NOT_FOUND;
32697 }
32698
32699 function put(key, value) {
32700 if (get(key) === NOT_FOUND) {
32701 // TODO Is unshift slow?
32702 entries.unshift({
32703 key: key,
32704 value: value
32705 });
32706
32707 if (entries.length > maxSize) {
32708 entries.pop();
32709 }
32710 }
32711 }
32712
32713 function getEntries() {
32714 return entries;
32715 }
32716
32717 function clear() {
32718 entries = [];
32719 }
32720
32721 return {
32722 get: get,
32723 put: put,
32724 getEntries: getEntries,
32725 clear: clear
32726 };
32727 }
32728
32729 var defaultEqualityCheck = function defaultEqualityCheck(a, b) {
32730 return a === b;
32731 };
32732 function createCacheKeyComparator(equalityCheck) {
32733 return function areArgumentsShallowlyEqual(prev, next) {
32734 if (prev === null || next === null || prev.length !== next.length) {
32735 return false;
32736 } // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
32737
32738
32739 var length = prev.length;
32740
32741 for (var i = 0; i < length; i++) {
32742 if (!equalityCheck(prev[i], next[i])) {
32743 return false;
32744 }
32745 }
32746
32747 return true;
32748 };
32749 }
32750 // defaultMemoize now supports a configurable cache size with LRU behavior,
32751 // and optional comparison of the result value with existing values
32752 function defaultMemoize(func, equalityCheckOrOptions) {
32753 var providedOptions = typeof equalityCheckOrOptions === 'object' ? equalityCheckOrOptions : {
32754 equalityCheck: equalityCheckOrOptions
32755 };
32756 var _providedOptions$equa = providedOptions.equalityCheck,
32757 equalityCheck = _providedOptions$equa === void 0 ? defaultEqualityCheck : _providedOptions$equa,
32758 _providedOptions$maxS = providedOptions.maxSize,
32759 maxSize = _providedOptions$maxS === void 0 ? 1 : _providedOptions$maxS,
32760 resultEqualityCheck = providedOptions.resultEqualityCheck;
32761 var comparator = createCacheKeyComparator(equalityCheck);
32762 var cache = maxSize === 1 ? createSingletonCache(comparator) : createLruCache(maxSize, comparator); // we reference arguments instead of spreading them for performance reasons
32763
32764 function memoized() {
32765 var value = cache.get(arguments);
32766
32767 if (value === NOT_FOUND) {
32768 // @ts-ignore
32769 value = func.apply(null, arguments);
32770
32771 if (resultEqualityCheck) {
32772 var entries = cache.getEntries();
32773 var matchingEntry = entries.find(function (entry) {
32774 return resultEqualityCheck(entry.value, value);
32775 });
32776
32777 if (matchingEntry) {
32778 value = matchingEntry.value;
32779 }
32780 }
32781
32782 cache.put(arguments, value);
32783 }
32784
32785 return value;
32786 }
32787
32788 memoized.clearCache = function () {
32789 return cache.clear();
32790 };
32791
32792 return memoized;
32793 }
32794
32795 /***/ }),
32796
32797 /***/ "../node_modules/reselect/es/index.js":
32798 /*!********************************************!*\
32799 !*** ../node_modules/reselect/es/index.js ***!
32800 \********************************************/
32801 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32802
32803 "use strict";
32804 __webpack_require__.r(__webpack_exports__);
32805 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32806 /* harmony export */ createSelector: () => (/* binding */ createSelector),
32807 /* harmony export */ createSelectorCreator: () => (/* binding */ createSelectorCreator),
32808 /* harmony export */ createStructuredSelector: () => (/* binding */ createStructuredSelector),
32809 /* harmony export */ defaultEqualityCheck: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultEqualityCheck),
32810 /* harmony export */ defaultMemoize: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize)
32811 /* harmony export */ });
32812 /* harmony import */ var _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultMemoize */ "../node_modules/reselect/es/defaultMemoize.js");
32813
32814
32815
32816 function getDependencies(funcs) {
32817 var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
32818
32819 if (!dependencies.every(function (dep) {
32820 return typeof dep === 'function';
32821 })) {
32822 var dependencyTypes = dependencies.map(function (dep) {
32823 return typeof dep === 'function' ? "function " + (dep.name || 'unnamed') + "()" : typeof dep;
32824 }).join(', ');
32825 throw new Error("createSelector expects all input-selectors to be functions, but received the following types: [" + dependencyTypes + "]");
32826 }
32827
32828 return dependencies;
32829 }
32830
32831 function createSelectorCreator(memoize) {
32832 for (var _len = arguments.length, memoizeOptionsFromArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
32833 memoizeOptionsFromArgs[_key - 1] = arguments[_key];
32834 }
32835
32836 var createSelector = function createSelector() {
32837 for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
32838 funcs[_key2] = arguments[_key2];
32839 }
32840
32841 var _recomputations = 0;
32842
32843 var _lastResult; // Due to the intricacies of rest params, we can't do an optional arg after `...funcs`.
32844 // So, start by declaring the default value here.
32845 // (And yes, the words 'memoize' and 'options' appear too many times in this next sequence.)
32846
32847
32848 var directlyPassedOptions = {
32849 memoizeOptions: undefined
32850 }; // Normally, the result func or "output selector" is the last arg
32851
32852 var resultFunc = funcs.pop(); // If the result func is actually an _object_, assume it's our options object
32853
32854 if (typeof resultFunc === 'object') {
32855 directlyPassedOptions = resultFunc; // and pop the real result func off
32856
32857 resultFunc = funcs.pop();
32858 }
32859
32860 if (typeof resultFunc !== 'function') {
32861 throw new Error("createSelector expects an output function after the inputs, but received: [" + typeof resultFunc + "]");
32862 } // Determine which set of options we're using. Prefer options passed directly,
32863 // but fall back to options given to createSelectorCreator.
32864
32865
32866 var _directlyPassedOption = directlyPassedOptions,
32867 _directlyPassedOption2 = _directlyPassedOption.memoizeOptions,
32868 memoizeOptions = _directlyPassedOption2 === void 0 ? memoizeOptionsFromArgs : _directlyPassedOption2; // Simplifying assumption: it's unlikely that the first options arg of the provided memoizer
32869 // is an array. In most libs I've looked at, it's an equality function or options object.
32870 // Based on that, if `memoizeOptions` _is_ an array, we assume it's a full
32871 // user-provided array of options. Otherwise, it must be just the _first_ arg, and so
32872 // we wrap it in an array so we can apply it.
32873
32874 var finalMemoizeOptions = Array.isArray(memoizeOptions) ? memoizeOptions : [memoizeOptions];
32875 var dependencies = getDependencies(funcs);
32876 var memoizedResultFunc = memoize.apply(void 0, [function recomputationWrapper() {
32877 _recomputations++; // apply arguments instead of spreading for performance.
32878
32879 return resultFunc.apply(null, arguments);
32880 }].concat(finalMemoizeOptions)); // If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
32881
32882 var selector = memoize(function dependenciesChecker() {
32883 var params = [];
32884 var length = dependencies.length;
32885
32886 for (var i = 0; i < length; i++) {
32887 // apply arguments instead of spreading and mutate a local list of params for performance.
32888 // @ts-ignore
32889 params.push(dependencies[i].apply(null, arguments));
32890 } // apply arguments instead of spreading for performance.
32891
32892
32893 _lastResult = memoizedResultFunc.apply(null, params);
32894 return _lastResult;
32895 });
32896 Object.assign(selector, {
32897 resultFunc: resultFunc,
32898 memoizedResultFunc: memoizedResultFunc,
32899 dependencies: dependencies,
32900 lastResult: function lastResult() {
32901 return _lastResult;
32902 },
32903 recomputations: function recomputations() {
32904 return _recomputations;
32905 },
32906 resetRecomputations: function resetRecomputations() {
32907 return _recomputations = 0;
32908 }
32909 });
32910 return selector;
32911 }; // @ts-ignore
32912
32913
32914 return createSelector;
32915 }
32916 var createSelector = /* #__PURE__ */createSelectorCreator(_defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize);
32917 // Manual definition of state and output arguments
32918 var createStructuredSelector = function createStructuredSelector(selectors, selectorCreator) {
32919 if (selectorCreator === void 0) {
32920 selectorCreator = createSelector;
32921 }
32922
32923 if (typeof selectors !== 'object') {
32924 throw new Error('createStructuredSelector expects first argument to be an object ' + ("where each property is a selector, instead received a " + typeof selectors));
32925 }
32926
32927 var objectKeys = Object.keys(selectors);
32928 var resultSelector = selectorCreator( // @ts-ignore
32929 objectKeys.map(function (key) {
32930 return selectors[key];
32931 }), function () {
32932 for (var _len3 = arguments.length, values = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
32933 values[_key3] = arguments[_key3];
32934 }
32935
32936 return values.reduce(function (composition, value, index) {
32937 composition[objectKeys[index]] = value;
32938 return composition;
32939 }, {});
32940 });
32941 return resultSelector;
32942 };
32943
32944 /***/ }),
32945
32946 /***/ "@wordpress/i18n":
32947 /*!**************************!*\
32948 !*** external "wp.i18n" ***!
32949 \**************************/
32950 /***/ ((module) => {
32951
32952 "use strict";
32953 module.exports = wp.i18n;
32954
32955 /***/ })
32956
32957 /******/ });
32958 /************************************************************************/
32959 /******/ // The module cache
32960 /******/ var __webpack_module_cache__ = {};
32961 /******/
32962 /******/ // The require function
32963 /******/ function __webpack_require__(moduleId) {
32964 /******/ // Check if module is in cache
32965 /******/ var cachedModule = __webpack_module_cache__[moduleId];
32966 /******/ if (cachedModule !== undefined) {
32967 /******/ return cachedModule.exports;
32968 /******/ }
32969 /******/ // Create a new module (and put it into the cache)
32970 /******/ var module = __webpack_module_cache__[moduleId] = {
32971 /******/ // no module.id needed
32972 /******/ // no module.loaded needed
32973 /******/ exports: {}
32974 /******/ };
32975 /******/
32976 /******/ // Execute the module function
32977 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
32978 /******/
32979 /******/ // Return the exports of the module
32980 /******/ return module.exports;
32981 /******/ }
32982 /******/
32983 /************************************************************************/
32984 /******/ /* webpack/runtime/define property getters */
32985 /******/ (() => {
32986 /******/ // define getter functions for harmony exports
32987 /******/ __webpack_require__.d = (exports, definition) => {
32988 /******/ for(var key in definition) {
32989 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
32990 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
32991 /******/ }
32992 /******/ }
32993 /******/ };
32994 /******/ })();
32995 /******/
32996 /******/ /* webpack/runtime/global */
32997 /******/ (() => {
32998 /******/ __webpack_require__.g = (function() {
32999 /******/ if (typeof globalThis === 'object') return globalThis;
33000 /******/ try {
33001 /******/ return this || new Function('return this')();
33002 /******/ } catch (e) {
33003 /******/ if (typeof window === 'object') return window;
33004 /******/ }
33005 /******/ })();
33006 /******/ })();
33007 /******/
33008 /******/ /* webpack/runtime/hasOwnProperty shorthand */
33009 /******/ (() => {
33010 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
33011 /******/ })();
33012 /******/
33013 /******/ /* webpack/runtime/make namespace object */
33014 /******/ (() => {
33015 /******/ // define __esModule on exports
33016 /******/ __webpack_require__.r = (exports) => {
33017 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
33018 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
33019 /******/ }
33020 /******/ Object.defineProperty(exports, '__esModule', { value: true });
33021 /******/ };
33022 /******/ })();
33023 /******/
33024 /************************************************************************/
33025 var __webpack_exports__ = {};
33026 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
33027 (() => {
33028 "use strict";
33029 /*!******************************************!*\
33030 !*** ../core/common/assets/js/common.js ***!
33031 \******************************************/
33032
33033
33034 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
33035 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
33036 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
33037 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
33038 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
33039 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
33040 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
33041 var _helpers = _interopRequireDefault(__webpack_require__(/*! ./utils/helpers */ "../core/common/assets/js/utils/helpers.js"));
33042 var _storage = _interopRequireDefault(__webpack_require__(/*! ./utils/storage */ "../core/common/assets/js/utils/storage.js"));
33043 var _debug = _interopRequireDefault(__webpack_require__(/*! ./utils/debug */ "../core/common/assets/js/utils/debug.js"));
33044 var _ajax = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/ajax/assets/js/ajax */ "../core/common/modules/ajax/assets/js/ajax.js"));
33045 var _finder = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/finder/assets/js/finder */ "../core/common/modules/finder/assets/js/finder.js"));
33046 var _connect = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/connect/assets/js/connect */ "../core/common/modules/connect/assets/js/connect.js"));
33047 var _component = _interopRequireDefault(__webpack_require__(/*! ./components/wordpress/component */ "../core/common/assets/js/components/wordpress/component.js"));
33048 var _component2 = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/data/component */ "../core/common/modules/event-tracker/assets/js/data/component.js"));
33049 var _events = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/events */ "../core/common/modules/event-tracker/assets/js/events.js"));
33050 var _module = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/events-manager/assets/js/module */ "../core/common/modules/events-manager/assets/js/module.js"));
33051 var _notifications = _interopRequireDefault(__webpack_require__(/*! elementor-utils/notifications */ "../assets/dev/js/utils/notifications.js"));
33052 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
33053 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
33054 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
33055 var ElementorCommonApp = /*#__PURE__*/function (_elementorModules$Vie) {
33056 function ElementorCommonApp() {
33057 (0, _classCallCheck2.default)(this, ElementorCommonApp);
33058 return _callSuper(this, ElementorCommonApp, arguments);
33059 }
33060 (0, _inherits2.default)(ElementorCommonApp, _elementorModules$Vie);
33061 return (0, _createClass2.default)(ElementorCommonApp, [{
33062 key: "setMarionetteTemplateCompiler",
33063 value: function setMarionetteTemplateCompiler() {
33064 Marionette.TemplateCache.prototype.compileTemplate = function (rawTemplate, options) {
33065 options = {
33066 evaluate: /<#([\s\S]+?)#>/g,
33067 interpolate: /{{{([\s\S]+?)}}}/g,
33068 escape: /{{([^}]+?)}}(?!})/g
33069 };
33070 return _.template(rawTemplate, options);
33071 };
33072 }
33073 }, {
33074 key: "getDefaultElements",
33075 value: function getDefaultElements() {
33076 return {
33077 $window: jQuery(window),
33078 $document: jQuery(document),
33079 $body: jQuery(document.body)
33080 };
33081 }
33082 }, {
33083 key: "initComponents",
33084 value: function initComponents() {
33085 this.events = new _events.default();
33086 this.eventsManager = new _module.default();
33087 this.debug = new _debug.default();
33088 this.helpers = new _helpers.default();
33089 this.storage = new _storage.default();
33090 this.dialogsManager = new DialogsManager.Instance();
33091 this.notifications = new _notifications.default();
33092 this.api = window.$e;
33093 $e.components.register(new _component2.default());
33094 elementorCommon.elements.$window.on('elementor:init-components', function () {
33095 $e.components.register(new _component.default());
33096 });
33097 this.initModules();
33098 }
33099 }, {
33100 key: "initModules",
33101 value: function initModules() {
33102 var _this = this;
33103 var activeModules = this.config.activeModules;
33104 var modules = {
33105 ajax: _ajax.default,
33106 finder: _finder.default,
33107 connect: _connect.default
33108 };
33109 activeModules.forEach(function (name) {
33110 if (modules[name]) {
33111 _this[name] = new modules[name](_this.config[name]);
33112 }
33113 });
33114 }
33115 }, {
33116 key: "compileArrayTemplateArgs",
33117 value: function compileArrayTemplateArgs(template, templateArgs) {
33118 return template.replace(/%(?:(\d+)\$)?s/g, function (match, number) {
33119 if (!number) {
33120 number = 1;
33121 }
33122 number--;
33123 return undefined !== templateArgs[number] ? templateArgs[number] : match;
33124 });
33125 }
33126 }, {
33127 key: "compileObjectTemplateArgs",
33128 value: function compileObjectTemplateArgs(template, templateArgs) {
33129 return template.replace(/{{(?:([ \w]+))}}/g, function (match, name) {
33130 return templateArgs[name] ? templateArgs[name] : match;
33131 });
33132 }
33133 }, {
33134 key: "compileTemplate",
33135 value: function compileTemplate(template, templateArgs) {
33136 return jQuery.isPlainObject(templateArgs) ? this.compileObjectTemplateArgs(template, templateArgs) : this.compileArrayTemplateArgs(template, templateArgs);
33137 }
33138 }, {
33139 key: "translate",
33140 value: function translate(stringKey, context, templateArgs, i18nStack) {
33141 if (context) {
33142 i18nStack = this.config[context].i18n;
33143 }
33144 if (!i18nStack) {
33145 i18nStack = this.config.i18n;
33146 }
33147 var string = i18nStack[stringKey];
33148 if (undefined === string) {
33149 string = stringKey;
33150 }
33151 if (templateArgs) {
33152 string = this.compileTemplate(string, templateArgs);
33153 }
33154 return string;
33155 }
33156 }, {
33157 key: "onInit",
33158 value: function onInit() {
33159 _superPropGet(ElementorCommonApp, "onInit", this, 3)([]);
33160 this.config = elementorCommonConfig;
33161 this.setMarionetteTemplateCompiler();
33162 }
33163 }]);
33164 }(elementorModules.ViewModule);
33165 window.elementorCommon = new ElementorCommonApp();
33166 elementorCommon.initComponents();
33167 })();
33168
33169 /******/ })()
33170 ;
33171 //# sourceMappingURL=common.js.map