PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.3
Elementor Website Builder – more than just a page builder v3.35.3
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.35.3, at assets/js/common.js

33,180 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 propertiesPanelOpened: 'component_properties_panel_opened',
1918 propertiesGroupCreated: 'component_properties_group_created',
1919 propertyExposed: 'component_property_exposed',
1920 propertyRemoved: 'component_property_removed'
1921 },
1922 global_classes: {
1923 classApplied: 'class_applied',
1924 classRemoved: 'class_removed',
1925 classManagerFilterCleared: 'class_manager_filter_cleared',
1926 classDeleted: 'class_deleted',
1927 classPublishConflict: 'class_publish_conflict',
1928 classRenamed: 'class_renamed',
1929 classCreated: 'class_created',
1930 classManagerSearched: 'class_manager_searched',
1931 classManagerFiltersOpened: 'class_manager_filters_opened',
1932 classManagerOpened: 'class_manager_opened',
1933 classManagerReorder: 'class_manager_reorder',
1934 classManagerFilterUsed: 'class_manager_filter_used',
1935 classUsageLocate: 'class_usage_locate',
1936 classUsageHovered: 'class_usage_hovered',
1937 classStyled: 'class_styled',
1938 classStateClicked: 'class_state_clicked',
1939 classUsageClicked: 'class_usage_clicked',
1940 classDuplicate: 'class_duplicate'
1941 }
1942 }
1943 };
1944 var _default = exports["default"] = eventsConfig;
1945
1946 /***/ }),
1947
1948 /***/ "../core/common/modules/events-manager/assets/js/module.js":
1949 /*!*****************************************************************!*\
1950 !*** ../core/common/modules/events-manager/assets/js/module.js ***!
1951 \*****************************************************************/
1952 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1953
1954 "use strict";
1955
1956
1957 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1958 Object.defineProperty(exports, "__esModule", ({
1959 value: true
1960 }));
1961 exports["default"] = void 0;
1962 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
1963 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
1964 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1965 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1966 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1967 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1968 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1969 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
1970 var _eventsConfig = _interopRequireDefault(__webpack_require__(/*! ./events-config */ "../core/common/modules/events-manager/assets/js/events-config.js"));
1971 var _mixpanelBrowser = _interopRequireDefault(__webpack_require__(/*! mixpanel-browser */ "../node_modules/mixpanel-browser/dist/mixpanel.module.js"));
1972 var _tiers = __webpack_require__(/*! elementor-utils/tiers */ "../assets/dev/js/utils/tiers.js");
1973 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; }
1974 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; }
1975 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)); }
1976 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1977 function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
1978 function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
1979 function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
1980 function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
1981 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"); }
1982 var _sessionRecordingInProgress = /*#__PURE__*/new WeakMap();
1983 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1984 function _default() {
1985 var _this;
1986 (0, _classCallCheck2.default)(this, _default);
1987 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1988 args[_key] = arguments[_key];
1989 }
1990 _this = _callSuper(this, _default, [].concat(args));
1991 (0, _defineProperty2.default)(_this, "trackingEnabled", false);
1992 _classPrivateFieldInitSpec(_this, _sessionRecordingInProgress, false);
1993 return _this;
1994 }
1995 (0, _inherits2.default)(_default, _elementorModules$Mod);
1996 return (0, _createClass2.default)(_default, [{
1997 key: "onInit",
1998 value: function onInit() {
1999 this.config = _eventsConfig.default;
2000 if (!this.canSendEvents()) {
2001 return;
2002 }
2003 this.initializeMixpanel();
2004 this.enableTracking();
2005 }
2006 }, {
2007 key: "initializeMixpanel",
2008 value: function initializeMixpanel() {
2009 var _elementorCommon$conf;
2010 _mixpanelBrowser.default.init((_elementorCommon$conf = elementorCommon.config.editor_events) === null || _elementorCommon$conf === void 0 ? void 0 : _elementorCommon$conf.token, {
2011 persistence: 'localStorage',
2012 autocapture: false,
2013 record_sessions_percent: 0,
2014 record_idle_timeout_ms: 60000,
2015 record_max_ms: 300000,
2016 record_mask_text_selector: '',
2017 flags: true,
2018 api_hosts: {
2019 flags: 'https://api-eu.mixpanel.com'
2020 }
2021 });
2022 }
2023 }, {
2024 key: "enableTracking",
2025 value: function enableTracking() {
2026 var _elementorCommon$conf2;
2027 var userId = (_elementorCommon$conf2 = elementorCommon.config.library_connect) === null || _elementorCommon$conf2 === void 0 ? void 0 : _elementorCommon$conf2.user_id;
2028 if (userId) {
2029 var _elementorCommon$conf3;
2030 _mixpanelBrowser.default.identify(userId);
2031 _mixpanelBrowser.default.register({
2032 appType: 'Editor'
2033 });
2034 _mixpanelBrowser.default.people.set_once({
2035 $user_id: userId,
2036 $last_login: new Date().toISOString(),
2037 $plan_type: ((_elementorCommon$conf3 = elementorCommon.config.library_connect) === null || _elementorCommon$conf3 === void 0 ? void 0 : _elementorCommon$conf3.plan_type) || _tiers.TIERS.free
2038 });
2039 }
2040 this.trackingEnabled = true;
2041 }
2042 }, {
2043 key: "dispatchEvent",
2044 value: function dispatchEvent(name, data) {
2045 var _elementorCommon$conf4, _elementorCommon$conf5, _elementorCommon$conf6, _elementorCommon$conf7, _elementorCommon$conf8, _elementorCommon$conf9, _elementorCommon$conf0, _elementorCommon$conf1, _elementorCommon$conf10;
2046 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2047 if (!this.canSendEvents()) {
2048 return;
2049 }
2050 if (!this.trackingEnabled) {
2051 this.enableTracking();
2052 }
2053 var eventData = _objectSpread({
2054 user_id: ((_elementorCommon$conf4 = elementorCommon.config.library_connect) === null || _elementorCommon$conf4 === void 0 ? void 0 : _elementorCommon$conf4.user_id) || null,
2055 user_roles: ((_elementorCommon$conf5 = elementorCommon.config.library_connect) === null || _elementorCommon$conf5 === void 0 ? void 0 : _elementorCommon$conf5.user_roles) || [],
2056 subscription_id: ((_elementorCommon$conf6 = elementorCommon.config.editor_events) === null || _elementorCommon$conf6 === void 0 ? void 0 : _elementorCommon$conf6.subscription_id) || null,
2057 user_tier: ((_elementorCommon$conf7 = elementorCommon.config.library_connect) === null || _elementorCommon$conf7 === void 0 ? void 0 : _elementorCommon$conf7.current_access_tier) || null,
2058 url: (_elementorCommon$conf8 = elementorCommon.config.editor_events) === null || _elementorCommon$conf8 === void 0 ? void 0 : _elementorCommon$conf8.site_url,
2059 wp_version: (_elementorCommon$conf9 = elementorCommon.config.editor_events) === null || _elementorCommon$conf9 === void 0 ? void 0 : _elementorCommon$conf9.wp_version,
2060 client_id: (_elementorCommon$conf0 = elementorCommon.config.editor_events) === null || _elementorCommon$conf0 === void 0 ? void 0 : _elementorCommon$conf0.site_key,
2061 app_version: (_elementorCommon$conf1 = elementorCommon.config.editor_events) === null || _elementorCommon$conf1 === void 0 ? void 0 : _elementorCommon$conf1.elementor_version,
2062 site_language: (_elementorCommon$conf10 = elementorCommon.config.editor_events) === null || _elementorCommon$conf10 === void 0 ? void 0 : _elementorCommon$conf10.site_language
2063 }, data);
2064 _mixpanelBrowser.default.track(name, eventData, options);
2065 }
2066 }, {
2067 key: "startSessionRecording",
2068 value: function startSessionRecording() {
2069 if (!this.canSendEvents() || this.isSessionRecordingInProgress()) {
2070 return;
2071 }
2072 if (!this.trackingEnabled) {
2073 this.enableTracking();
2074 }
2075 _mixpanelBrowser.default.start_session_recording();
2076 this.setSessionRecordingInProgress(true);
2077 }
2078 }, {
2079 key: "stopSessionRecording",
2080 value: function stopSessionRecording() {
2081 if (!this.canSendEvents() || !this.isSessionRecordingInProgress()) {
2082 return;
2083 }
2084 _mixpanelBrowser.default.stop_session_recording();
2085 this.setSessionRecordingInProgress(false);
2086 }
2087 }, {
2088 key: "setSessionRecordingInProgress",
2089 value: function setSessionRecordingInProgress(value) {
2090 if ('boolean' !== typeof value) {
2091 return;
2092 }
2093 _classPrivateFieldSet(_sessionRecordingInProgress, this, value);
2094 }
2095 }, {
2096 key: "isSessionRecordingInProgress",
2097 value: function isSessionRecordingInProgress() {
2098 return _classPrivateFieldGet(_sessionRecordingInProgress, this);
2099 }
2100 }, {
2101 key: "featureFlagIsActive",
2102 value: function () {
2103 var _featureFlagIsActive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(flagName) {
2104 var _mixpanel$flags;
2105 var isEnabled;
2106 return _regenerator.default.wrap(function (_context) {
2107 while (1) switch (_context.prev = _context.next) {
2108 case 0:
2109 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))) {
2110 _context.next = 1;
2111 break;
2112 }
2113 return _context.abrupt("return", false);
2114 case 1:
2115 _context.next = 2;
2116 return _mixpanelBrowser.default.flags.is_enabled(flagName, false);
2117 case 2:
2118 isEnabled = _context.sent;
2119 return _context.abrupt("return", true === isEnabled);
2120 case 3:
2121 case "end":
2122 return _context.stop();
2123 }
2124 }, _callee);
2125 }));
2126 function featureFlagIsActive(_x) {
2127 return _featureFlagIsActive.apply(this, arguments);
2128 }
2129 return featureFlagIsActive;
2130 }()
2131 }, {
2132 key: "getExperimentVariant",
2133 value: function () {
2134 var _getExperimentVariant = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(experimentName) {
2135 var defaultValue,
2136 _elementorCommon$conf11,
2137 _elementorCommon$conf12,
2138 isAbTestingEnabled,
2139 variant,
2140 _args2 = arguments,
2141 _t;
2142 return _regenerator.default.wrap(function (_context2) {
2143 while (1) switch (_context2.prev = _context2.next) {
2144 case 0:
2145 defaultValue = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 'control';
2146 _context2.prev = 1;
2147 if (this.canSendEvents()) {
2148 _context2.next = 2;
2149 break;
2150 }
2151 return _context2.abrupt("return", defaultValue);
2152 case 2:
2153 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;
2154 if (isAbTestingEnabled) {
2155 _context2.next = 3;
2156 break;
2157 }
2158 return _context2.abrupt("return", defaultValue);
2159 case 3:
2160 if (_mixpanelBrowser.default) {
2161 _context2.next = 4;
2162 break;
2163 }
2164 return _context2.abrupt("return", defaultValue);
2165 case 4:
2166 if (!this.trackingEnabled) {
2167 this.enableTracking();
2168 }
2169 if (_mixpanelBrowser.default.flags) {
2170 _context2.next = 5;
2171 break;
2172 }
2173 return _context2.abrupt("return", defaultValue);
2174 case 5:
2175 if (!('function' !== typeof _mixpanelBrowser.default.flags.get_variant_value)) {
2176 _context2.next = 6;
2177 break;
2178 }
2179 return _context2.abrupt("return", defaultValue);
2180 case 6:
2181 _context2.next = 7;
2182 return _mixpanelBrowser.default.flags.get_variant_value(experimentName, defaultValue);
2183 case 7:
2184 variant = _context2.sent;
2185 if (!(undefined === variant || null === variant)) {
2186 _context2.next = 8;
2187 break;
2188 }
2189 return _context2.abrupt("return", defaultValue);
2190 case 8:
2191 return _context2.abrupt("return", variant);
2192 case 9:
2193 _context2.prev = 9;
2194 _t = _context2["catch"](1);
2195 return _context2.abrupt("return", defaultValue);
2196 case 10:
2197 case "end":
2198 return _context2.stop();
2199 }
2200 }, _callee2, this, [[1, 9]]);
2201 }));
2202 function getExperimentVariant(_x2) {
2203 return _getExperimentVariant.apply(this, arguments);
2204 }
2205 return getExperimentVariant;
2206 }()
2207 }, {
2208 key: "startExperiment",
2209 value: function startExperiment(experimentName, experimentVariant) {
2210 if (!this.trackingEnabled) {
2211 return;
2212 }
2213 _mixpanelBrowser.default.track('$experiment_started', {
2214 'Experiment name': experimentName,
2215 'Variant name': experimentVariant
2216 });
2217 }
2218 }, {
2219 key: "canSendEvents",
2220 value: function canSendEvents() {
2221 var _elementorCommon;
2222 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);
2223 }
2224 }]);
2225 }(elementorModules.Module);
2226
2227 /***/ }),
2228
2229 /***/ "../core/common/modules/finder/assets/js/commands/index.js":
2230 /*!*****************************************************************!*\
2231 !*** ../core/common/modules/finder/assets/js/commands/index.js ***!
2232 \*****************************************************************/
2233 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2234
2235 "use strict";
2236
2237
2238 Object.defineProperty(exports, "__esModule", ({
2239 value: true
2240 }));
2241 Object.defineProperty(exports, "NavigateDown", ({
2242 enumerable: true,
2243 get: function get() {
2244 return _navigateDown.NavigateDown;
2245 }
2246 }));
2247 Object.defineProperty(exports, "NavigateSelect", ({
2248 enumerable: true,
2249 get: function get() {
2250 return _navigateSelect.NavigateSelect;
2251 }
2252 }));
2253 Object.defineProperty(exports, "NavigateUp", ({
2254 enumerable: true,
2255 get: function get() {
2256 return _navigateUp.NavigateUp;
2257 }
2258 }));
2259 var _navigateDown = __webpack_require__(/*! ./navigate-down */ "../core/common/modules/finder/assets/js/commands/navigate-down.js");
2260 var _navigateSelect = __webpack_require__(/*! ./navigate-select */ "../core/common/modules/finder/assets/js/commands/navigate-select.js");
2261 var _navigateUp = __webpack_require__(/*! ./navigate-up */ "../core/common/modules/finder/assets/js/commands/navigate-up.js");
2262
2263 /***/ }),
2264
2265 /***/ "../core/common/modules/finder/assets/js/commands/navigate-down.js":
2266 /*!*************************************************************************!*\
2267 !*** ../core/common/modules/finder/assets/js/commands/navigate-down.js ***!
2268 \*************************************************************************/
2269 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2270
2271 "use strict";
2272
2273
2274 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2275 Object.defineProperty(exports, "__esModule", ({
2276 value: true
2277 }));
2278 exports["default"] = exports.NavigateDown = void 0;
2279 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2280 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2281 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2282 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2283 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2284 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2285 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)); }
2286 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2287 var NavigateDown = exports.NavigateDown = /*#__PURE__*/function (_CommandBase) {
2288 function NavigateDown() {
2289 (0, _classCallCheck2.default)(this, NavigateDown);
2290 return _callSuper(this, NavigateDown, arguments);
2291 }
2292 (0, _inherits2.default)(NavigateDown, _CommandBase);
2293 return (0, _createClass2.default)(NavigateDown, [{
2294 key: "apply",
2295 value: function apply() {
2296 this.component.getItemsView().activateNextItem();
2297 }
2298 }]);
2299 }(_commandBase.default);
2300 var _default = exports["default"] = NavigateDown;
2301
2302 /***/ }),
2303
2304 /***/ "../core/common/modules/finder/assets/js/commands/navigate-select.js":
2305 /*!***************************************************************************!*\
2306 !*** ../core/common/modules/finder/assets/js/commands/navigate-select.js ***!
2307 \***************************************************************************/
2308 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2309
2310 "use strict";
2311
2312
2313 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2314 Object.defineProperty(exports, "__esModule", ({
2315 value: true
2316 }));
2317 exports["default"] = exports.NavigateSelect = void 0;
2318 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2319 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2320 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2321 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2322 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2323 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2324 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)); }
2325 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2326 var NavigateSelect = exports.NavigateSelect = /*#__PURE__*/function (_CommandBase) {
2327 function NavigateSelect() {
2328 (0, _classCallCheck2.default)(this, NavigateSelect);
2329 return _callSuper(this, NavigateSelect, arguments);
2330 }
2331 (0, _inherits2.default)(NavigateSelect, _CommandBase);
2332 return (0, _createClass2.default)(NavigateSelect, [{
2333 key: "apply",
2334 value: function apply(args) {
2335 this.component.getItemsView().goToActiveItem(args);
2336 }
2337 }]);
2338 }(_commandBase.default);
2339 var _default = exports["default"] = NavigateSelect;
2340
2341 /***/ }),
2342
2343 /***/ "../core/common/modules/finder/assets/js/commands/navigate-up.js":
2344 /*!***********************************************************************!*\
2345 !*** ../core/common/modules/finder/assets/js/commands/navigate-up.js ***!
2346 \***********************************************************************/
2347 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2348
2349 "use strict";
2350
2351
2352 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2353 Object.defineProperty(exports, "__esModule", ({
2354 value: true
2355 }));
2356 exports["default"] = exports.NavigateUp = void 0;
2357 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2358 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2359 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2360 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2361 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2362 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2363 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)); }
2364 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2365 var NavigateUp = exports.NavigateUp = /*#__PURE__*/function (_CommandBase) {
2366 function NavigateUp() {
2367 (0, _classCallCheck2.default)(this, NavigateUp);
2368 return _callSuper(this, NavigateUp, arguments);
2369 }
2370 (0, _inherits2.default)(NavigateUp, _CommandBase);
2371 return (0, _createClass2.default)(NavigateUp, [{
2372 key: "apply",
2373 value: function apply() {
2374 this.component.getItemsView().activateNextItem(true);
2375 }
2376 }]);
2377 }(_commandBase.default);
2378 var _default = exports["default"] = NavigateUp;
2379
2380 /***/ }),
2381
2382 /***/ "../core/common/modules/finder/assets/js/component.js":
2383 /*!************************************************************!*\
2384 !*** ../core/common/modules/finder/assets/js/component.js ***!
2385 \************************************************************/
2386 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2387
2388 "use strict";
2389
2390
2391 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2392 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2393 Object.defineProperty(exports, "__esModule", ({
2394 value: true
2395 }));
2396 exports["default"] = void 0;
2397 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2398 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2399 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2400 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2401 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2402 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2403 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2404 var _componentModalBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-modal-base */ "../modules/web-cli/assets/js/modules/component-modal-base.js"));
2405 var _layout = _interopRequireDefault(__webpack_require__(/*! ./modal/views/layout */ "../core/common/modules/finder/assets/js/modal/views/layout.js"));
2406 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../core/common/modules/finder/assets/js/commands/index.js"));
2407 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); }
2408 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; }
2409 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; }
2410 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)); }
2411 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2412 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; }
2413 var Component = exports["default"] = /*#__PURE__*/function (_ComponentModalBase) {
2414 function Component() {
2415 (0, _classCallCheck2.default)(this, Component);
2416 return _callSuper(this, Component, arguments);
2417 }
2418 (0, _inherits2.default)(Component, _ComponentModalBase);
2419 return (0, _createClass2.default)(Component, [{
2420 key: "getNamespace",
2421 value: function getNamespace() {
2422 return 'finder';
2423 }
2424 }, {
2425 key: "defaultShortcuts",
2426 value: function defaultShortcuts() {
2427 var _this = this;
2428 return {
2429 '': {
2430 keys: 'ctrl+e'
2431 },
2432 'navigate-down': {
2433 keys: 'down',
2434 scopes: [this.getNamespace()],
2435 dependency: function dependency() {
2436 return _this.getItemsView();
2437 }
2438 },
2439 'navigate-up': {
2440 keys: 'up',
2441 scopes: [this.getNamespace()],
2442 dependency: function dependency() {
2443 return _this.getItemsView();
2444 }
2445 },
2446 'navigate-select': {
2447 keys: 'enter',
2448 scopes: [this.getNamespace()],
2449 dependency: function dependency() {
2450 return _this.getItemsView().$activeItem;
2451 }
2452 }
2453 };
2454 }
2455 }, {
2456 key: "defaultCommands",
2457 value: function defaultCommands() {
2458 var modalCommands = _superPropGet(Component, "defaultCommands", this, 3)([]);
2459 return _objectSpread(_objectSpread({
2460 'navigate/down': function navigate_down() {
2461 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/down' )", '3.0.0', "$e.run( 'finder/navigate-down' )");
2462 $e.run('finder/navigate-down');
2463 },
2464 'navigate/up': function navigate_up() {
2465 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/up' )", '3.0.0', "$e.run( 'finder/navigate-up' )");
2466 $e.run('finder/navigate-up');
2467 },
2468 'navigate/select': function navigate_select(event) {
2469 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/select', event )", '3.0.0', "$e.run( 'finder/navigate-select', event )");
2470
2471 // TODO: Fix $e.shortcuts use args. ( args.event ).
2472 $e.run('finder/navigate-select', event);
2473 }
2474 }, modalCommands), this.importCommands(commands));
2475 }
2476 }, {
2477 key: "getModalLayout",
2478 value: function getModalLayout() {
2479 return _layout.default;
2480 }
2481 }, {
2482 key: "getItemsView",
2483 value: function getItemsView() {
2484 return this.layout.modalContent.currentView.content.currentView;
2485 }
2486 }]);
2487 }(_componentModalBase.default);
2488
2489 /***/ }),
2490
2491 /***/ "../core/common/modules/finder/assets/js/finder.js":
2492 /*!*********************************************************!*\
2493 !*** ../core/common/modules/finder/assets/js/finder.js ***!
2494 \*********************************************************/
2495 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2496
2497 "use strict";
2498
2499
2500 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2501 Object.defineProperty(exports, "__esModule", ({
2502 value: true
2503 }));
2504 exports["default"] = void 0;
2505 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2506 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2507 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2508 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2509 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2510 var _component = _interopRequireDefault(__webpack_require__(/*! ./component */ "../core/common/modules/finder/assets/js/component.js"));
2511 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)); }
2512 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2513 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2514 function _default() {
2515 (0, _classCallCheck2.default)(this, _default);
2516 return _callSuper(this, _default, arguments);
2517 }
2518 (0, _inherits2.default)(_default, _elementorModules$Mod);
2519 return (0, _createClass2.default)(_default, [{
2520 key: "onInit",
2521 value: function onInit() {
2522 // TODO: Temp fix, do not load finder in theme-builder.
2523 // Better to pass into '$e' constructor the app owner. ( admin, editor, preview, iframe ).
2524 if (window.top !== window) {
2525 return;
2526 }
2527 this.channel = Backbone.Radio.channel('ELEMENTOR:finder');
2528 $e.components.register(new _component.default({
2529 manager: this
2530 }));
2531 }
2532 }]);
2533 }(elementorModules.Module);
2534
2535 /***/ }),
2536
2537 /***/ "../core/common/modules/finder/assets/js/modal/model/item.js":
2538 /*!*******************************************************************!*\
2539 !*** ../core/common/modules/finder/assets/js/modal/model/item.js ***!
2540 \*******************************************************************/
2541 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2542
2543 "use strict";
2544
2545
2546 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2547 Object.defineProperty(exports, "__esModule", ({
2548 value: true
2549 }));
2550 exports["default"] = void 0;
2551 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2552 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2553 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2554 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2555 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2556 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)); }
2557 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2558 var _default = exports["default"] = /*#__PURE__*/function (_Backbone$Model) {
2559 function _default() {
2560 (0, _classCallCheck2.default)(this, _default);
2561 return _callSuper(this, _default, arguments);
2562 }
2563 (0, _inherits2.default)(_default, _Backbone$Model);
2564 return (0, _createClass2.default)(_default, [{
2565 key: "defaults",
2566 value: function defaults() {
2567 return {
2568 description: '',
2569 icon: 'settings',
2570 url: '',
2571 keywords: [],
2572 actions: [],
2573 lock: null
2574 };
2575 }
2576 }]);
2577 }(Backbone.Model);
2578
2579 /***/ }),
2580
2581 /***/ "../core/common/modules/finder/assets/js/modal/views/categories.js":
2582 /*!*************************************************************************!*\
2583 !*** ../core/common/modules/finder/assets/js/modal/views/categories.js ***!
2584 \*************************************************************************/
2585 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2586
2587 "use strict";
2588
2589
2590 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2591 Object.defineProperty(exports, "__esModule", ({
2592 value: true
2593 }));
2594 exports["default"] = void 0;
2595 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2596 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2597 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2598 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2599 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2600 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
2601 var _dynamicCategory = _interopRequireDefault(__webpack_require__(/*! ./dynamic-category */ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js"));
2602 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)); }
2603 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2604 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
2605 function _default() {
2606 (0, _classCallCheck2.default)(this, _default);
2607 return _callSuper(this, _default, arguments);
2608 }
2609 (0, _inherits2.default)(_default, _Marionette$Composite);
2610 return (0, _createClass2.default)(_default, [{
2611 key: "id",
2612 value: function id() {
2613 return 'elementor-finder__results-container';
2614 }
2615 }, {
2616 key: "ui",
2617 value: function ui() {
2618 this.selectors = {
2619 noResults: '#elementor-finder__no-results',
2620 categoryItem: '.elementor-finder__results__item'
2621 };
2622 return this.selectors;
2623 }
2624 }, {
2625 key: "events",
2626 value: function events() {
2627 return {
2628 'mouseenter @ui.categoryItem': 'onCategoryItemMouseEnter'
2629 };
2630 }
2631 }, {
2632 key: "getTemplate",
2633 value: function getTemplate() {
2634 return '#tmpl-elementor-finder-results-container';
2635 }
2636 }, {
2637 key: "getChildView",
2638 value: function getChildView(childModel) {
2639 return childModel.get('dynamic') ? _dynamicCategory.default : _category.default;
2640 }
2641 }, {
2642 key: "initialize",
2643 value: function initialize() {
2644 this.$activeItem = null;
2645 this.childViewContainer = '#elementor-finder__results';
2646 this.collection = new Backbone.Collection(Object.values(elementorCommon.finder.getSettings('data')));
2647 }
2648 }, {
2649 key: "activateItem",
2650 value: function activateItem($item) {
2651 if (this.$activeItem) {
2652 this.$activeItem.removeClass('elementor-active');
2653 }
2654 $item.addClass('elementor-active');
2655 this.$activeItem = $item;
2656 }
2657 }, {
2658 key: "activateNextItem",
2659 value: function activateNextItem(reverse) {
2660 var $allItems = jQuery(this.selectors.categoryItem);
2661 var nextItemIndex = 0;
2662 if (this.$activeItem) {
2663 nextItemIndex = $allItems.index(this.$activeItem) + (reverse ? -1 : 1);
2664 if (nextItemIndex >= $allItems.length) {
2665 nextItemIndex = 0;
2666 } else if (nextItemIndex < 0) {
2667 nextItemIndex = $allItems.length - 1;
2668 }
2669 }
2670 var $nextItem = $allItems.eq(nextItemIndex);
2671 this.activateItem($nextItem);
2672 $nextItem[0].scrollIntoView({
2673 block: 'nearest'
2674 });
2675 }
2676 }, {
2677 key: "goToActiveItem",
2678 value: function goToActiveItem(event) {
2679 var $a = this.$activeItem.children('a'),
2680 isControlClicked = $e.shortcuts.isControlEvent(event);
2681 if (isControlClicked) {
2682 $a.attr('target', '_blank');
2683 }
2684 $a[0].click();
2685 if (isControlClicked) {
2686 $a.removeAttr('target');
2687 }
2688 }
2689 }, {
2690 key: "onCategoryItemMouseEnter",
2691 value: function onCategoryItemMouseEnter(event) {
2692 this.activateItem(jQuery(event.currentTarget));
2693 }
2694 }, {
2695 key: "onChildviewToggleVisibility",
2696 value: function onChildviewToggleVisibility() {
2697 var allCategoriesAreEmpty = this.children.every(function (child) {
2698 return !child.isVisible;
2699 });
2700 this.ui.noResults.toggle(allCategoriesAreEmpty);
2701 }
2702 }]);
2703 }(Marionette.CompositeView);
2704
2705 /***/ }),
2706
2707 /***/ "../core/common/modules/finder/assets/js/modal/views/category.js":
2708 /*!***********************************************************************!*\
2709 !*** ../core/common/modules/finder/assets/js/modal/views/category.js ***!
2710 \***********************************************************************/
2711 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2712
2713 "use strict";
2714
2715
2716 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2717 Object.defineProperty(exports, "__esModule", ({
2718 value: true
2719 }));
2720 exports["default"] = void 0;
2721 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2722 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2723 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2724 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2725 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2726 var _item = _interopRequireDefault(__webpack_require__(/*! ./item */ "../core/common/modules/finder/assets/js/modal/views/item.js"));
2727 var _item2 = _interopRequireDefault(__webpack_require__(/*! ../model/item */ "../core/common/modules/finder/assets/js/modal/model/item.js"));
2728 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)); }
2729 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2730 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
2731 function _default() {
2732 (0, _classCallCheck2.default)(this, _default);
2733 return _callSuper(this, _default, arguments);
2734 }
2735 (0, _inherits2.default)(_default, _Marionette$Composite);
2736 return (0, _createClass2.default)(_default, [{
2737 key: "className",
2738 value: function className() {
2739 return 'elementor-finder__results__category';
2740 }
2741 }, {
2742 key: "getTemplate",
2743 value: function getTemplate() {
2744 return '#tmpl-elementor-finder__results__category';
2745 }
2746 }, {
2747 key: "getChildView",
2748 value: function getChildView() {
2749 return _item.default;
2750 }
2751 }, {
2752 key: "initialize",
2753 value: function initialize() {
2754 this.childViewContainer = '.elementor-finder__results__category__items';
2755 this.isVisible = true;
2756 var items = this.model.get('items');
2757 if (items) {
2758 items = Object.values(items);
2759 }
2760 this.collection = new Backbone.Collection(items, {
2761 model: _item2.default
2762 });
2763 }
2764 }, {
2765 key: "filter",
2766 value: function filter(childModel) {
2767 var textFilter = this.getTextFilter();
2768 if (childModel.get('title').toLowerCase().indexOf(textFilter) >= 0) {
2769 return true;
2770 }
2771 return childModel.get('keywords').some(function (keyword) {
2772 return keyword.indexOf(textFilter) >= 0;
2773 });
2774 }
2775 }, {
2776 key: "getTextFilter",
2777 value: function getTextFilter() {
2778 return elementorCommon.finder.channel.request('filter:text').trim().toLowerCase();
2779 }
2780 }, {
2781 key: "toggleElement",
2782 value: function toggleElement() {
2783 var isCurrentlyVisible = !!this.children.length;
2784 if (isCurrentlyVisible !== this.isVisible) {
2785 this.isVisible = isCurrentlyVisible;
2786 this.$el.toggle(isCurrentlyVisible);
2787 this.triggerMethod('toggle:visibility');
2788 }
2789 }
2790 }, {
2791 key: "onRender",
2792 value: function onRender() {
2793 this.listenTo(elementorCommon.finder.channel, 'filter:change', this.onFilterChange.bind(this));
2794 }
2795 }, {
2796 key: "onFilterChange",
2797 value: function onFilterChange() {
2798 this._renderChildren();
2799 }
2800 }, {
2801 key: "onRenderCollection",
2802 value: function onRenderCollection() {
2803 this.toggleElement();
2804 }
2805 }]);
2806 }(Marionette.CompositeView);
2807
2808 /***/ }),
2809
2810 /***/ "../core/common/modules/finder/assets/js/modal/views/content.js":
2811 /*!**********************************************************************!*\
2812 !*** ../core/common/modules/finder/assets/js/modal/views/content.js ***!
2813 \**********************************************************************/
2814 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2815
2816 "use strict";
2817
2818
2819 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2820 Object.defineProperty(exports, "__esModule", ({
2821 value: true
2822 }));
2823 exports["default"] = void 0;
2824 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2825 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2826 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2827 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2828 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2829 var _categories = _interopRequireDefault(__webpack_require__(/*! ./categories */ "../core/common/modules/finder/assets/js/modal/views/categories.js"));
2830 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)); }
2831 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2832 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$LayoutVie) {
2833 function _default() {
2834 (0, _classCallCheck2.default)(this, _default);
2835 return _callSuper(this, _default, arguments);
2836 }
2837 (0, _inherits2.default)(_default, _Marionette$LayoutVie);
2838 return (0, _createClass2.default)(_default, [{
2839 key: "id",
2840 value: function id() {
2841 return 'elementor-finder';
2842 }
2843 }, {
2844 key: "getTemplate",
2845 value: function getTemplate() {
2846 return '#tmpl-elementor-finder';
2847 }
2848 }, {
2849 key: "ui",
2850 value: function ui() {
2851 return {
2852 searchInput: '#elementor-finder__search__input'
2853 };
2854 }
2855 }, {
2856 key: "events",
2857 value: function events() {
2858 return {
2859 'input @ui.searchInput': 'onSearchInputInput'
2860 };
2861 }
2862 }, {
2863 key: "regions",
2864 value: function regions() {
2865 return {
2866 content: '#elementor-finder__content'
2867 };
2868 }
2869 }, {
2870 key: "showCategoriesView",
2871 value: function showCategoriesView() {
2872 this.content.show(new _categories.default());
2873 }
2874 }, {
2875 key: "onSearchInputInput",
2876 value: function onSearchInputInput() {
2877 var value = this.ui.searchInput.val();
2878 if (value) {
2879 elementorCommon.finder.channel.reply('filter:text', value).trigger('filter:change');
2880 if (!(this.content.currentView instanceof _categories.default)) {
2881 this.showCategoriesView();
2882 }
2883 }
2884 this.content.currentView.$el.toggle(!!value);
2885 }
2886 }]);
2887 }(Marionette.LayoutView);
2888
2889 /***/ }),
2890
2891 /***/ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js":
2892 /*!*******************************************************************************!*\
2893 !*** ../core/common/modules/finder/assets/js/modal/views/dynamic-category.js ***!
2894 \*******************************************************************************/
2895 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2896
2897 "use strict";
2898
2899
2900 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2901 Object.defineProperty(exports, "__esModule", ({
2902 value: true
2903 }));
2904 exports["default"] = void 0;
2905 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2906 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2907 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2908 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2909 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2910 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2911 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
2912 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)); }
2913 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2914 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; }
2915 var _default = exports["default"] = /*#__PURE__*/function (_Category) {
2916 function _default() {
2917 (0, _classCallCheck2.default)(this, _default);
2918 return _callSuper(this, _default, arguments);
2919 }
2920 (0, _inherits2.default)(_default, _Category);
2921 return (0, _createClass2.default)(_default, [{
2922 key: "className",
2923 value: function className() {
2924 return _superPropGet(_default, "className", this, 3)([]) + ' elementor-finder__results__category--dynamic';
2925 }
2926 }, {
2927 key: "ui",
2928 value: function ui() {
2929 return {
2930 title: '.elementor-finder__results__category__title'
2931 };
2932 }
2933 }, {
2934 key: "fetchData",
2935 value: function fetchData() {
2936 var _this = this;
2937 this.ui.loadingIcon.show();
2938 elementorCommon.ajax.addRequest('finder_get_category_items', {
2939 data: {
2940 category: this.model.get('name'),
2941 filter: this.getTextFilter()
2942 },
2943 success: function success(data) {
2944 if (_this.isDestroyed) {
2945 return;
2946 }
2947 _this.collection.set(data);
2948 _this.toggleElement();
2949 _this.ui.loadingIcon.hide();
2950 }
2951 });
2952 }
2953 }, {
2954 key: "filter",
2955 value: function filter() {
2956 return true;
2957 }
2958 }, {
2959 key: "onFilterChange",
2960 value: function onFilterChange() {
2961 this.fetchData();
2962 }
2963 }, {
2964 key: "onRender",
2965 value: function onRender() {
2966 _superPropGet(_default, "onRender", this, 3)([]);
2967 this.ui.loadingIcon = jQuery('<i>', {
2968 class: 'eicon-loading eicon-animation-spin'
2969 });
2970 this.ui.title.after(this.ui.loadingIcon);
2971 this.fetchData();
2972 }
2973 }]);
2974 }(_category.default);
2975
2976 /***/ }),
2977
2978 /***/ "../core/common/modules/finder/assets/js/modal/views/item.js":
2979 /*!*******************************************************************!*\
2980 !*** ../core/common/modules/finder/assets/js/modal/views/item.js ***!
2981 \*******************************************************************/
2982 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2983
2984 "use strict";
2985 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
2986
2987
2988 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2989 Object.defineProperty(exports, "__esModule", ({
2990 value: true
2991 }));
2992 exports["default"] = void 0;
2993 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2994 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2995 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2996 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2997 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2998 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)); }
2999 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3000 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$ItemView) {
3001 function _default() {
3002 (0, _classCallCheck2.default)(this, _default);
3003 return _callSuper(this, _default, arguments);
3004 }
3005 (0, _inherits2.default)(_default, _Marionette$ItemView);
3006 return (0, _createClass2.default)(_default, [{
3007 key: "className",
3008 value: function className() {
3009 return 'elementor-finder__results__item';
3010 }
3011 }, {
3012 key: "getTemplate",
3013 value: function getTemplate() {
3014 return '#tmpl-elementor-finder__results__item';
3015 }
3016 }, {
3017 key: "events",
3018 value: function events() {
3019 this.$el[0].addEventListener('click', this.onClick.bind(this), true);
3020 }
3021 }, {
3022 key: "onClick",
3023 value: function onClick(e) {
3024 var _this = this;
3025 var lockOptions = this.model.get('lock');
3026 if (!(lockOptions !== null && lockOptions !== void 0 && lockOptions.is_locked)) {
3027 return;
3028 }
3029 e.preventDefault();
3030 e.stopImmediatePropagation();
3031 elementorCommon.dialogsManager.createWidget('confirm', {
3032 id: 'elementor-finder__lock-dialog',
3033 headerMessage: lockOptions.content.heading,
3034 message: lockOptions.content.description,
3035 position: {
3036 my: 'center center',
3037 at: 'center center'
3038 },
3039 strings: {
3040 confirm: lockOptions.button.text,
3041 cancel: __('Cancel', 'elementor')
3042 },
3043 onConfirm: function onConfirm() {
3044 var link = _this.replaceLockLinkPlaceholders(lockOptions.button.url);
3045 window.open(link, '_blank');
3046 }
3047 }).show();
3048 }
3049 }, {
3050 key: "replaceLockLinkPlaceholders",
3051 value: function replaceLockLinkPlaceholders(link) {
3052 return link.replace(/%%utm_source%%/g, 'finder').replace(/%%utm_medium%%/g, 'wp-dash');
3053 }
3054 }]);
3055 }(Marionette.ItemView);
3056
3057 /***/ }),
3058
3059 /***/ "../core/common/modules/finder/assets/js/modal/views/layout.js":
3060 /*!*********************************************************************!*\
3061 !*** ../core/common/modules/finder/assets/js/modal/views/layout.js ***!
3062 \*********************************************************************/
3063 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3064
3065 "use strict";
3066 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3067
3068
3069 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3070 Object.defineProperty(exports, "__esModule", ({
3071 value: true
3072 }));
3073 exports["default"] = void 0;
3074 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3075 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3076 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3077 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3078 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3079 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3080 var _content = _interopRequireDefault(__webpack_require__(/*! ./content */ "../core/common/modules/finder/assets/js/modal/views/content.js"));
3081 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)); }
3082 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3083 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; }
3084 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$com) {
3085 function _default() {
3086 (0, _classCallCheck2.default)(this, _default);
3087 return _callSuper(this, _default, arguments);
3088 }
3089 (0, _inherits2.default)(_default, _elementorModules$com);
3090 return (0, _createClass2.default)(_default, [{
3091 key: "getModalOptions",
3092 value: function getModalOptions() {
3093 return {
3094 id: 'elementor-finder__modal',
3095 draggable: true,
3096 effects: {
3097 show: 'show',
3098 hide: 'hide'
3099 },
3100 position: {
3101 enable: false
3102 }
3103 };
3104 }
3105 }, {
3106 key: "getLogoOptions",
3107 value: function getLogoOptions() {
3108 return {
3109 title: __('Finder', 'elementor')
3110 };
3111 }
3112 }, {
3113 key: "initialize",
3114 value: function initialize() {
3115 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3116 args[_key] = arguments[_key];
3117 }
3118 _superPropGet(_default, "initialize", this, 3)(args);
3119 this.showLogo();
3120 this.showContentView();
3121 }
3122 }, {
3123 key: "showContentView",
3124 value: function showContentView() {
3125 this.modalContent.show(new _content.default());
3126 }
3127 }, {
3128 key: "showModal",
3129 value: function showModal() {
3130 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3131 args[_key2] = arguments[_key2];
3132 }
3133 _superPropGet(_default, "showModal", this, 3)(args);
3134 this.modalContent.currentView.ui.searchInput.focus();
3135 }
3136 }]);
3137 }(elementorModules.common.views.modal.Layout);
3138
3139 /***/ }),
3140
3141 /***/ "../modules/web-cli/assets/js/core/data/errors/base-error.js":
3142 /*!*******************************************************************!*\
3143 !*** ../modules/web-cli/assets/js/core/data/errors/base-error.js ***!
3144 \*******************************************************************/
3145 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3146
3147 "use strict";
3148
3149
3150 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3151 Object.defineProperty(exports, "__esModule", ({
3152 value: true
3153 }));
3154 exports["default"] = void 0;
3155 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3156 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3157 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3158 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3159 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3160 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
3161 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3162 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3163 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../../../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
3164 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; }
3165 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; }
3166 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)); }
3167 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3168 var BaseError = exports["default"] = /*#__PURE__*/function (_Error) {
3169 /**
3170 * Error constructor.
3171 *
3172 * @param {string} message
3173 * @param {string} code
3174 * @param {*} data
3175 */
3176 function BaseError() {
3177 var _this;
3178 var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
3179 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3180 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3181 (0, _classCallCheck2.default)(this, BaseError);
3182 _this = _callSuper(this, BaseError, [message]);
3183 /**
3184 * The server error code.
3185 *
3186 * @type {string}
3187 */
3188 (0, _defineProperty2.default)(_this, "code", '');
3189 /**
3190 * Additional data about the current error.
3191 *
3192 * @type {*[]}
3193 */
3194 (0, _defineProperty2.default)(_this, "data", []);
3195 _this.code = code;
3196 _this.data = data;
3197 return _this;
3198 }
3199
3200 /**
3201 * Notify a message when the error occurs.
3202 */
3203 (0, _inherits2.default)(BaseError, _Error);
3204 return (0, _createClass2.default)(BaseError, [{
3205 key: "notify",
3206 value: function notify() {
3207 _console.default.error(_objectSpread({
3208 message: this.message
3209 }, this));
3210 }
3211 }], [{
3212 key: "create",
3213 value:
3214 /**
3215 * Static helper function to create the error.
3216 *
3217 * @param {string} message
3218 * @param {string} code
3219 * @param {*} data
3220 * @return {BaseError} error
3221 */
3222 function create(message) {
3223 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3224 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3225 return new this(message, code, data);
3226 }
3227
3228 /**
3229 * Returns the status code of the error.
3230 */
3231 }, {
3232 key: "getHTTPErrorCode",
3233 value: function getHTTPErrorCode() {
3234 (0, _forceMethodImplementation.default)();
3235 }
3236 }]);
3237 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
3238
3239 /***/ }),
3240
3241 /***/ "../modules/web-cli/assets/js/core/data/errors/default-error.js":
3242 /*!**********************************************************************!*\
3243 !*** ../modules/web-cli/assets/js/core/data/errors/default-error.js ***!
3244 \**********************************************************************/
3245 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3246
3247 "use strict";
3248
3249
3250 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3251 Object.defineProperty(exports, "__esModule", ({
3252 value: true
3253 }));
3254 exports["default"] = exports.DefaultError = void 0;
3255 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3256 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3257 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3258 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3259 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3260 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3261 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)); }
3262 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3263 var DefaultError = exports.DefaultError = /*#__PURE__*/function (_BaseError) {
3264 function DefaultError() {
3265 (0, _classCallCheck2.default)(this, DefaultError);
3266 return _callSuper(this, DefaultError, arguments);
3267 }
3268 (0, _inherits2.default)(DefaultError, _BaseError);
3269 return (0, _createClass2.default)(DefaultError, null, [{
3270 key: "getHTTPErrorCode",
3271 value: function getHTTPErrorCode() {
3272 return 501;
3273 }
3274 }]);
3275 }(_baseError.default);
3276 var _default = exports["default"] = DefaultError;
3277
3278 /***/ }),
3279
3280 /***/ "../modules/web-cli/assets/js/core/data/errors/error-404.js":
3281 /*!******************************************************************!*\
3282 !*** ../modules/web-cli/assets/js/core/data/errors/error-404.js ***!
3283 \******************************************************************/
3284 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3285
3286 "use strict";
3287
3288
3289 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3290 Object.defineProperty(exports, "__esModule", ({
3291 value: true
3292 }));
3293 exports["default"] = exports.Error404 = void 0;
3294 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3295 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3296 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3297 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3298 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3299 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3300 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3301 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)); }
3302 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3303 var Error404 = exports.Error404 = /*#__PURE__*/function (_BaseError) {
3304 function Error404() {
3305 (0, _classCallCheck2.default)(this, Error404);
3306 return _callSuper(this, Error404, arguments);
3307 }
3308 (0, _inherits2.default)(Error404, _BaseError);
3309 return (0, _createClass2.default)(Error404, [{
3310 key: "notify",
3311 value: function notify() {
3312 _console.default.warn(this.message);
3313 }
3314 }], [{
3315 key: "getHTTPErrorCode",
3316 value: function getHTTPErrorCode() {
3317 return 404;
3318 }
3319 }]);
3320 }(_baseError.default);
3321 var _default = exports["default"] = Error404;
3322
3323 /***/ }),
3324
3325 /***/ "../modules/web-cli/assets/js/core/data/errors/index.js":
3326 /*!**************************************************************!*\
3327 !*** ../modules/web-cli/assets/js/core/data/errors/index.js ***!
3328 \**************************************************************/
3329 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3330
3331 "use strict";
3332
3333
3334 Object.defineProperty(exports, "__esModule", ({
3335 value: true
3336 }));
3337 Object.defineProperty(exports, "DefaultError", ({
3338 enumerable: true,
3339 get: function get() {
3340 return _defaultError.DefaultError;
3341 }
3342 }));
3343 Object.defineProperty(exports, "Error404", ({
3344 enumerable: true,
3345 get: function get() {
3346 return _error.Error404;
3347 }
3348 }));
3349 var _defaultError = __webpack_require__(/*! ./default-error */ "../modules/web-cli/assets/js/core/data/errors/default-error.js");
3350 var _error = __webpack_require__(/*! ./error-404 */ "../modules/web-cli/assets/js/core/data/errors/error-404.js");
3351
3352 /***/ }),
3353
3354 /***/ "../modules/web-cli/assets/js/modules/command-base.js":
3355 /*!************************************************************!*\
3356 !*** ../modules/web-cli/assets/js/modules/command-base.js ***!
3357 \************************************************************/
3358 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3359
3360 "use strict";
3361
3362
3363 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3364 Object.defineProperty(exports, "__esModule", ({
3365 value: true
3366 }));
3367 exports["default"] = void 0;
3368 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3369 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3370 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3371 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3372 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3373 var _commandInfra = _interopRequireDefault(__webpack_require__(/*! ./command-infra */ "../modules/web-cli/assets/js/modules/command-infra.js"));
3374 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3375 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)); }
3376 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3377 /**
3378 * @name $e.modules.CommandBase
3379 */
3380 var CommandBase = exports["default"] = /*#__PURE__*/function (_CommandInfra) {
3381 function CommandBase() {
3382 (0, _classCallCheck2.default)(this, CommandBase);
3383 return _callSuper(this, CommandBase, arguments);
3384 }
3385 (0, _inherits2.default)(CommandBase, _CommandInfra);
3386 return (0, _createClass2.default)(CommandBase, [{
3387 key: "onBeforeRun",
3388 value: function onBeforeRun() {
3389 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3390 $e.hooks.runUIBefore(this.command, args);
3391 }
3392 }, {
3393 key: "onAfterRun",
3394 value: function onAfterRun() {
3395 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3396 var result = arguments.length > 1 ? arguments[1] : undefined;
3397 $e.hooks.runUIAfter(this.command, args, result);
3398 }
3399 }, {
3400 key: "onBeforeApply",
3401 value: function onBeforeApply() {
3402 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3403 $e.hooks.runDataDependency(this.command, args);
3404 }
3405 }, {
3406 key: "onAfterApply",
3407 value: function onAfterApply() {
3408 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3409 var result = arguments.length > 1 ? arguments[1] : undefined;
3410 return $e.hooks.runDataAfter(this.command, args, result);
3411 }
3412 }, {
3413 key: "onCatchApply",
3414 value: function onCatchApply(e) {
3415 this.runCatchHooks(e);
3416 }
3417
3418 /**
3419 * Run all the catch hooks.
3420 *
3421 * @param {Error} e
3422 */
3423 }, {
3424 key: "runCatchHooks",
3425 value: function runCatchHooks(e) {
3426 $e.hooks.runDataCatch(this.command, this.args, e);
3427 $e.hooks.runUICatch(this.command, this.args, e);
3428 }
3429
3430 /**
3431 * TODO - Remove - Backwards compatibility.
3432 *
3433 * Function requireContainer().
3434 *
3435 * Validate `arg.container` & `arg.containers`.
3436 *
3437 * @param {{}} args
3438 * @deprecated since 3.7.0, extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase` instead.
3439 *
3440 * @throws {Error}
3441 */
3442 }, {
3443 key: "requireContainer",
3444 value: function requireContainer() {
3445 var _this = this;
3446 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
3447 _deprecation.default.deprecated('requireContainer()', '3.7.0', 'Extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase`');
3448 if (!args.container && !args.containers) {
3449 throw Error('container or containers are required.');
3450 }
3451 if (args.container && args.containers) {
3452 throw Error('container and containers cannot go together please select one of them.');
3453 }
3454 var containers = args.containers || [args.container];
3455 containers.forEach(function (container) {
3456 _this.requireArgumentInstance('container', elementorModules.editor.Container, {
3457 container: container
3458 });
3459 });
3460 }
3461 }], [{
3462 key: "getInstanceType",
3463 value: function getInstanceType() {
3464 return 'CommandBase';
3465 }
3466 }]);
3467 }(_commandInfra.default);
3468
3469 /***/ }),
3470
3471 /***/ "../modules/web-cli/assets/js/modules/command-callback-base.js":
3472 /*!*********************************************************************!*\
3473 !*** ../modules/web-cli/assets/js/modules/command-callback-base.js ***!
3474 \*********************************************************************/
3475 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3476
3477 "use strict";
3478
3479
3480 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3481 Object.defineProperty(exports, "__esModule", ({
3482 value: true
3483 }));
3484 exports["default"] = void 0;
3485 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3486 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3487 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3488 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3489 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3490 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3491 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)); }
3492 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3493 /**
3494 * To support pure callbacks in the API(commands.js), to ensure they have registered with the proper context.
3495 */
3496 var CommandCallbackBase = exports["default"] = /*#__PURE__*/function (_CommandBase) {
3497 function CommandCallbackBase() {
3498 (0, _classCallCheck2.default)(this, CommandCallbackBase);
3499 return _callSuper(this, CommandCallbackBase, arguments);
3500 }
3501 (0, _inherits2.default)(CommandCallbackBase, _CommandBase);
3502 return (0, _createClass2.default)(CommandCallbackBase, [{
3503 key: "apply",
3504 value: function apply() {
3505 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3506 return this.constructor.getCallback()(args);
3507 }
3508 }], [{
3509 key: "getInstanceType",
3510 value: function getInstanceType() {
3511 return 'CommandCallbackBase';
3512 }
3513
3514 /**
3515 * Get original callback of the command.
3516 *
3517 * Support pure callbacks ( Non command-base ).
3518 *
3519 * @return {()=>{}} Command Results.
3520 */
3521 }, {
3522 key: "getCallback",
3523 value: function getCallback() {
3524 return this.registerConfig.callback;
3525 }
3526 }]);
3527 }(_commandBase.default);
3528
3529 /***/ }),
3530
3531 /***/ "../modules/web-cli/assets/js/modules/command-data.js":
3532 /*!************************************************************!*\
3533 !*** ../modules/web-cli/assets/js/modules/command-data.js ***!
3534 \************************************************************/
3535 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3536
3537 "use strict";
3538
3539
3540 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3541 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
3542 Object.defineProperty(exports, "__esModule", ({
3543 value: true
3544 }));
3545 exports["default"] = void 0;
3546 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3547 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3548 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3549 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3550 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3551 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3552 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3553 var errors = _interopRequireWildcard(__webpack_require__(/*! ../core/data/errors/ */ "../modules/web-cli/assets/js/core/data/errors/index.js"));
3554 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); }
3555 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)); }
3556 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3557 /**
3558 * @name $e.modules.CommandData
3559 */
3560 /**
3561 * @typedef {('create'|'delete'|'get'|'update'|'options')} DataTypes
3562 */
3563 /**
3564 * @typedef {{}} RequestData
3565 */
3566 /**
3567 * @typedef {import('../core/data/errors/base-error')} BaseError
3568 */
3569 var CommandData = exports["default"] = /*#__PURE__*/function (_CommandBase) {
3570 function CommandData(args) {
3571 var _this$args$options;
3572 var _this;
3573 var commandsAPI = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $e.data;
3574 (0, _classCallCheck2.default)(this, CommandData);
3575 _this = _callSuper(this, CommandData, [args, commandsAPI]);
3576 /**
3577 * Data returned from remote.
3578 *
3579 * @type {*}
3580 */
3581 (0, _defineProperty2.default)(_this, "data", void 0);
3582 /**
3583 * Fetch type.
3584 *
3585 * @type {DataTypes}
3586 */
3587 (0, _defineProperty2.default)(_this, "type", void 0);
3588 if ((_this$args$options = _this.args.options) !== null && _this$args$options !== void 0 && _this$args$options.type) {
3589 _this.type = _this.args.options.type;
3590 }
3591 return _this;
3592 }
3593
3594 /**
3595 * Function getEndpointFormat().
3596 *
3597 * @return {null|string} endpoint format
3598 */
3599 (0, _inherits2.default)(CommandData, _CommandBase);
3600 return (0, _createClass2.default)(CommandData, [{
3601 key: "getApplyMethods",
3602 value:
3603 /**
3604 * @param {DataTypes} type
3605 *
3606 * @return {boolean|{before: (function(*=): {}), after: (function({}, *=): {})}} apply methods
3607 */
3608 function getApplyMethods() {
3609 var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.type;
3610 var before, after;
3611 switch (type) {
3612 case 'create':
3613 before = this.applyBeforeCreate;
3614 after = this.applyAfterCreate;
3615 break;
3616 case 'delete':
3617 before = this.applyBeforeDelete;
3618 after = this.applyAfterDelete;
3619 break;
3620 case 'get':
3621 before = this.applyBeforeGet;
3622 after = this.applyAfterGet;
3623 break;
3624 case 'update':
3625 before = this.applyBeforeUpdate;
3626 after = this.applyAfterUpdate;
3627 break;
3628 case 'options':
3629 before = this.applyBeforeOptions;
3630 after = this.applyAfterOptions;
3631 break;
3632 default:
3633 return false;
3634 }
3635 return {
3636 before: before.bind(this),
3637 after: after.bind(this)
3638 };
3639 }
3640
3641 /**
3642 * Function getRequestData().
3643 *
3644 * @return {RequestData} request data
3645 */
3646 }, {
3647 key: "getRequestData",
3648 value: function getRequestData() {
3649 return {
3650 type: this.type,
3651 args: this.args,
3652 timestamp: new Date().getTime(),
3653 component: this.component,
3654 command: this.command,
3655 endpoint: $e.data.commandToEndpoint(this.command, JSON.parse(JSON.stringify(this.args)), this.constructor.getEndpointFormat())
3656 };
3657 }
3658 }, {
3659 key: "apply",
3660 value: function apply() {
3661 var _this2 = this;
3662 var applyMethods = this.getApplyMethods();
3663
3664 // Run 'before' method.
3665 this.args = applyMethods.before(this.args);
3666 var requestData = this.getRequestData();
3667 return $e.data.fetch(requestData).then(function (data) {
3668 _this2.data = data;
3669
3670 // Run 'after' method.
3671 _this2.data = applyMethods.after(data, _this2.args);
3672 _this2.data = {
3673 data: _this2.data
3674 };
3675
3676 // Append requestData.
3677 _this2.data = Object.assign({
3678 __requestData__: requestData
3679 }, _this2.data);
3680 return _this2.data;
3681 });
3682 }
3683
3684 /**
3685 * @param {*} [args={}]
3686 * @return {{}} filtered args
3687 */
3688 }, {
3689 key: "applyBeforeCreate",
3690 value: function applyBeforeCreate() {
3691 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3692 return args;
3693 }
3694
3695 /**
3696 * @param {{}} data
3697 * @param {*} [args={}]
3698 * @return {{}} filtered result
3699 */
3700 }, {
3701 key: "applyAfterCreate",
3702 value: function applyAfterCreate(data) {
3703 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3704 // eslint-disable-line no-unused-vars
3705 return data;
3706 }
3707
3708 /**
3709 * @param {*} [args={}]
3710 * @return {{}} filtered args
3711 */
3712 }, {
3713 key: "applyBeforeDelete",
3714 value: function applyBeforeDelete() {
3715 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3716 return args;
3717 }
3718
3719 /**
3720 * @param {{}} data
3721 * @param {*} [args={}]
3722 * @return {{}} filtered result
3723 */
3724 }, {
3725 key: "applyAfterDelete",
3726 value: function applyAfterDelete(data) {
3727 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3728 // eslint-disable-line no-unused-vars
3729 return data;
3730 }
3731
3732 /**
3733 * @param {*} [args={}]
3734 * @return {{}} filtered args
3735 */
3736 }, {
3737 key: "applyBeforeGet",
3738 value: function applyBeforeGet() {
3739 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3740 return args;
3741 }
3742
3743 /**
3744 * @param {{}} data
3745 * @param {*} [args={}]
3746 * @return {{}} filtered result
3747 */
3748 }, {
3749 key: "applyAfterGet",
3750 value: function applyAfterGet(data) {
3751 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3752 // eslint-disable-line no-unused-vars
3753 return data;
3754 }
3755
3756 /**
3757 * @param {*} [args={}]
3758 * @return {{}} filtered args
3759 */
3760 }, {
3761 key: "applyBeforeUpdate",
3762 value: function applyBeforeUpdate() {
3763 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3764 return args;
3765 }
3766
3767 /**
3768 * @param {{}} data
3769 * @param {*} [args={}]
3770 * @return {{}} filtered result
3771 */
3772 }, {
3773 key: "applyAfterUpdate",
3774 value: function applyAfterUpdate(data) {
3775 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3776 // eslint-disable-line no-unused-vars
3777 return data;
3778 }
3779
3780 /**
3781 * @param {*} [args={}]
3782 * @return {{}} filtered args
3783 */
3784 }, {
3785 key: "applyBeforeOptions",
3786 value: function applyBeforeOptions() {
3787 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3788 return args;
3789 }
3790
3791 /**
3792 * @param {{}} data
3793 * @param {*} [args={}]
3794 * @return {{}} filtered result
3795 */
3796 }, {
3797 key: "applyAfterOptions",
3798 value: function applyAfterOptions(data) {
3799 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3800 // eslint-disable-line no-unused-vars
3801 return data;
3802 }
3803
3804 /**
3805 * @param {BaseError} e
3806 */
3807 }, {
3808 key: "applyAfterCatch",
3809 value: function applyAfterCatch(e) {
3810 e.notify();
3811 }
3812 }, {
3813 key: "onCatchApply",
3814 value: function onCatchApply(e) {
3815 var _e;
3816 // TODO: If the errors that returns from the server is consistent remove the '?' from 'e'
3817 var httpErrorCode = ((_e = e) === null || _e === void 0 || (_e = _e.data) === null || _e === void 0 ? void 0 : _e.status) || 501;
3818 var dataError = Object.values(errors).find(function (error) {
3819 return error.getHTTPErrorCode() === httpErrorCode;
3820 });
3821 if (!dataError) {
3822 dataError = errors.DefaultError;
3823 }
3824 e = dataError.create(e.message, e.code, e.data || []);
3825 this.runCatchHooks(e);
3826 this.applyAfterCatch(e);
3827 }
3828 }], [{
3829 key: "getInstanceType",
3830 value: function getInstanceType() {
3831 return 'CommandData';
3832 }
3833 }, {
3834 key: "getEndpointFormat",
3835 value: function getEndpointFormat() {
3836 return null;
3837 }
3838 }]);
3839 }(_commandBase.default);
3840
3841 /***/ }),
3842
3843 /***/ "../modules/web-cli/assets/js/modules/command-infra.js":
3844 /*!*************************************************************!*\
3845 !*** ../modules/web-cli/assets/js/modules/command-infra.js ***!
3846 \*************************************************************/
3847 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3848
3849 "use strict";
3850
3851
3852 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3853 Object.defineProperty(exports, "__esModule", ({
3854 value: true
3855 }));
3856 exports["default"] = void 0;
3857 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3858 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3859 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3860 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3861 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3862 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3863 var _argsObject = _interopRequireDefault(__webpack_require__(/*! elementor-assets-js/modules/imports/args-object */ "../assets/dev/js/modules/imports/args-object.js"));
3864 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3865 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)); }
3866 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3867 /**
3868 * @typedef {import('../modules/component-base')} ComponentBase
3869 */
3870 var CommandInfra = exports["default"] = /*#__PURE__*/function (_ArgsObject) {
3871 /**
3872 * Function constructor().
3873 *
3874 * Create Commands Base.
3875 *
3876 * @param {{}} args
3877 */
3878 function CommandInfra() {
3879 var _this;
3880 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3881 (0, _classCallCheck2.default)(this, CommandInfra);
3882 _this = _callSuper(this, CommandInfra, [args]);
3883 if (!_this.constructor.registerConfig) {
3884 throw RangeError('Doing it wrong: Each command type should have `registerConfig`.');
3885 }
3886
3887 // Acknowledge self about which command it run.
3888 _this.command = _this.constructor.getCommand();
3889
3890 // Assign instance of current component.
3891 _this.component = _this.constructor.getComponent();
3892
3893 // Who ever need do something before without `super` the constructor can use `initialize` method.
3894 _this.initialize(args);
3895
3896 // Refresh args, maybe the changed via `initialize`.
3897 args = _this.args;
3898
3899 // Validate args before run.
3900 _this.validateArgs(args);
3901 return _this;
3902 }
3903
3904 /**
3905 * Function initialize().
3906 *
3907 * Initialize command, called after construction.
3908 *
3909 * @param {{}} args
3910 */
3911 (0, _inherits2.default)(CommandInfra, _ArgsObject);
3912 return (0, _createClass2.default)(CommandInfra, [{
3913 key: "currentCommand",
3914 get:
3915 /**
3916 * @deprecated since 3.7.0, use `this.command` instead.
3917 */
3918 function get() {
3919 _deprecation.default.deprecated('this.currentCommand', '3.7.0', 'this.command');
3920 return this.command;
3921 }
3922 }, {
3923 key: "initialize",
3924 value: function initialize() {
3925 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3926 } // eslint-disable-line no-unused-vars
3927
3928 /**
3929 * Function validateArgs().
3930 *
3931 * Validate command arguments.
3932 *
3933 * @param {{}} args
3934 */
3935 }, {
3936 key: "validateArgs",
3937 value: function validateArgs() {
3938 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3939 } // eslint-disable-line no-unused-vars
3940
3941 // eslint-disable-next-line jsdoc/require-returns-check
3942 /**
3943 * Function apply().
3944 *
3945 * Do the actual command.
3946 *
3947 * @param {{}} args
3948 *
3949 * @return {*} Command results.
3950 */
3951 }, {
3952 key: "apply",
3953 value: function apply() {
3954 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3955 // eslint-disable-line no-unused-vars
3956 elementorModules.ForceMethodImplementation();
3957 }
3958
3959 /**
3960 * Function run().
3961 *
3962 * Run command with history & hooks.
3963 *
3964 * @return {*} Command results.
3965 */
3966 }, {
3967 key: "run",
3968 value: function run() {
3969 return this.apply(this.args);
3970 }
3971
3972 /**
3973 * Function onBeforeRun.
3974 *
3975 * Called before run().
3976 *
3977 * @param {{}} args
3978 */
3979 }, {
3980 key: "onBeforeRun",
3981 value: function onBeforeRun() {
3982 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3983 } // eslint-disable-line no-unused-vars
3984
3985 /**
3986 * Function onAfterRun.
3987 *
3988 * Called after run().
3989 *
3990 * @param {{}} args
3991 * @param {*} result
3992 */
3993 }, {
3994 key: "onAfterRun",
3995 value: function onAfterRun() {
3996 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3997 var result = arguments.length > 1 ? arguments[1] : undefined;
3998 } // eslint-disable-line no-unused-vars
3999
4000 /**
4001 * Function onBeforeApply.
4002 *
4003 * Called before apply().
4004 *
4005 * @param {{}} args
4006 */
4007 }, {
4008 key: "onBeforeApply",
4009 value: function onBeforeApply() {
4010 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4011 } // eslint-disable-line no-unused-vars
4012
4013 /**
4014 * Function onAfterApply.
4015 *
4016 * Called after apply().
4017 *
4018 * @param {{}} args
4019 * @param {*} result
4020 */
4021 }, {
4022 key: "onAfterApply",
4023 value: function onAfterApply() {
4024 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4025 var result = arguments.length > 1 ? arguments[1] : undefined;
4026 } // eslint-disable-line no-unused-vars
4027
4028 /**
4029 * Function onCatchApply.
4030 *
4031 * Called after apply() failed.
4032 *
4033 * @param {Error} e
4034 */
4035 }, {
4036 key: "onCatchApply",
4037 value: function onCatchApply(e) {} // eslint-disable-line no-unused-vars
4038 }], [{
4039 key: "getInstanceType",
4040 value: function getInstanceType() {
4041 return 'CommandInfra';
4042 }
4043
4044 /**
4045 * Get info of command.
4046 *
4047 * @return {Object} Extra information about the command.
4048 */
4049 }, {
4050 key: "getInfo",
4051 value: function getInfo() {
4052 return {};
4053 }
4054
4055 /**
4056 * @return {string} Self command name.
4057 */
4058 }, {
4059 key: "getCommand",
4060 value: function getCommand() {
4061 return this.registerConfig.command;
4062 }
4063
4064 /**
4065 * @return {ComponentBase} Self component
4066 */
4067 }, {
4068 key: "getComponent",
4069 value: function getComponent() {
4070 return this.registerConfig.component;
4071 }
4072 }, {
4073 key: "setRegisterConfig",
4074 value: function setRegisterConfig(config) {
4075 this.registerConfig = Object.freeze(config);
4076 }
4077 }]);
4078 }(_argsObject.default);
4079 /**
4080 * @type {Object}
4081 */
4082 (0, _defineProperty2.default)(CommandInfra, "registerConfig", null);
4083
4084 /***/ }),
4085
4086 /***/ "../modules/web-cli/assets/js/modules/commands/close.js":
4087 /*!**************************************************************!*\
4088 !*** ../modules/web-cli/assets/js/modules/commands/close.js ***!
4089 \**************************************************************/
4090 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4091
4092 "use strict";
4093
4094
4095 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4096 Object.defineProperty(exports, "__esModule", ({
4097 value: true
4098 }));
4099 exports["default"] = exports.Close = void 0;
4100 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4101 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4102 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4103 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4104 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4105 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4106 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)); }
4107 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4108 var Close = exports.Close = /*#__PURE__*/function (_CommandBase) {
4109 function Close() {
4110 (0, _classCallCheck2.default)(this, Close);
4111 return _callSuper(this, Close, arguments);
4112 }
4113 (0, _inherits2.default)(Close, _CommandBase);
4114 return (0, _createClass2.default)(Close, [{
4115 key: "apply",
4116 value: function apply() {
4117 this.component.close();
4118 }
4119 }]);
4120 }(_commandBase.default);
4121 var _default = exports["default"] = Close;
4122
4123 /***/ }),
4124
4125 /***/ "../modules/web-cli/assets/js/modules/commands/index.js":
4126 /*!**************************************************************!*\
4127 !*** ../modules/web-cli/assets/js/modules/commands/index.js ***!
4128 \**************************************************************/
4129 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4130
4131 "use strict";
4132
4133
4134 Object.defineProperty(exports, "__esModule", ({
4135 value: true
4136 }));
4137 Object.defineProperty(exports, "Close", ({
4138 enumerable: true,
4139 get: function get() {
4140 return _close.Close;
4141 }
4142 }));
4143 Object.defineProperty(exports, "Open", ({
4144 enumerable: true,
4145 get: function get() {
4146 return _open.Open;
4147 }
4148 }));
4149 Object.defineProperty(exports, "Toggle", ({
4150 enumerable: true,
4151 get: function get() {
4152 return _toggle.Toggle;
4153 }
4154 }));
4155 var _close = __webpack_require__(/*! ./close */ "../modules/web-cli/assets/js/modules/commands/close.js");
4156 var _open = __webpack_require__(/*! ./open */ "../modules/web-cli/assets/js/modules/commands/open.js");
4157 var _toggle = __webpack_require__(/*! ./toggle */ "../modules/web-cli/assets/js/modules/commands/toggle.js");
4158
4159 /***/ }),
4160
4161 /***/ "../modules/web-cli/assets/js/modules/commands/open.js":
4162 /*!*************************************************************!*\
4163 !*** ../modules/web-cli/assets/js/modules/commands/open.js ***!
4164 \*************************************************************/
4165 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4166
4167 "use strict";
4168
4169
4170 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4171 Object.defineProperty(exports, "__esModule", ({
4172 value: true
4173 }));
4174 exports["default"] = exports.Open = void 0;
4175 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4176 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4177 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4178 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4179 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4180 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4181 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)); }
4182 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4183 var Open = exports.Open = /*#__PURE__*/function (_CommandBase) {
4184 function Open() {
4185 (0, _classCallCheck2.default)(this, Open);
4186 return _callSuper(this, Open, arguments);
4187 }
4188 (0, _inherits2.default)(Open, _CommandBase);
4189 return (0, _createClass2.default)(Open, [{
4190 key: "apply",
4191 value: function apply() {
4192 $e.route(this.component.getNamespace());
4193 }
4194 }]);
4195 }(_commandBase.default);
4196 var _default = exports["default"] = Open;
4197
4198 /***/ }),
4199
4200 /***/ "../modules/web-cli/assets/js/modules/commands/toggle.js":
4201 /*!***************************************************************!*\
4202 !*** ../modules/web-cli/assets/js/modules/commands/toggle.js ***!
4203 \***************************************************************/
4204 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4205
4206 "use strict";
4207
4208
4209 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4210 Object.defineProperty(exports, "__esModule", ({
4211 value: true
4212 }));
4213 exports["default"] = exports.Toggle = void 0;
4214 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4215 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4216 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4217 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4218 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4219 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4220 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)); }
4221 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4222 var Toggle = exports.Toggle = /*#__PURE__*/function (_CommandBase) {
4223 function Toggle() {
4224 (0, _classCallCheck2.default)(this, Toggle);
4225 return _callSuper(this, Toggle, arguments);
4226 }
4227 (0, _inherits2.default)(Toggle, _CommandBase);
4228 return (0, _createClass2.default)(Toggle, [{
4229 key: "apply",
4230 value: function apply() {
4231 if (this.component.isOpen) {
4232 this.component.close();
4233 } else {
4234 $e.route(this.component.getNamespace());
4235 }
4236 }
4237 }]);
4238 }(_commandBase.default);
4239 var _default = exports["default"] = Toggle;
4240
4241 /***/ }),
4242
4243 /***/ "../modules/web-cli/assets/js/modules/component-base.js":
4244 /*!**************************************************************!*\
4245 !*** ../modules/web-cli/assets/js/modules/component-base.js ***!
4246 \**************************************************************/
4247 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4248
4249 "use strict";
4250
4251
4252 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4253 Object.defineProperty(exports, "__esModule", ({
4254 value: true
4255 }));
4256 exports["default"] = void 0;
4257 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4258 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4259 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4260 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4261 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4262 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4263 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4264 var _commandCallbackBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-callback-base */ "../modules/web-cli/assets/js/modules/command-callback-base.js"));
4265 var _toolkit = __webpack_require__(/*! @reduxjs/toolkit */ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js");
4266 var _module = _interopRequireDefault(__webpack_require__(/*! elementor/assets/dev/js/modules/imports/module.js */ "../assets/dev/js/modules/imports/module.js"));
4267 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4268 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4269 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; }
4270 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; }
4271 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)); }
4272 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4273 /**
4274 * @typedef {import('./command-infra')} CommandInfra
4275 * @typedef {import('./hook-base')} HookBase
4276 * @typedef {import('../core/states/ui-state-base')} UiStateBase
4277 */
4278 var ComponentBase = exports["default"] = /*#__PURE__*/function (_Module) {
4279 function ComponentBase() {
4280 (0, _classCallCheck2.default)(this, ComponentBase);
4281 return _callSuper(this, ComponentBase, arguments);
4282 }
4283 (0, _inherits2.default)(ComponentBase, _Module);
4284 return (0, _createClass2.default)(ComponentBase, [{
4285 key: "__construct",
4286 value: function __construct() {
4287 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4288 if (args.manager) {
4289 this.manager = args.manager;
4290 }
4291 this.commands = this.defaultCommands();
4292 this.commandsInternal = this.defaultCommandsInternal();
4293 this.hooks = this.defaultHooks();
4294 this.routes = this.defaultRoutes();
4295 this.tabs = this.defaultTabs();
4296 this.shortcuts = this.defaultShortcuts();
4297 this.utils = this.defaultUtils();
4298 this.data = this.defaultData();
4299 this.uiStates = this.defaultUiStates();
4300 this.states = this.defaultStates();
4301 this.defaultRoute = '';
4302 this.currentTab = '';
4303 }
4304 }, {
4305 key: "registerAPI",
4306 value: function registerAPI() {
4307 var _this = this;
4308 Object.entries(this.getTabs()).forEach(function (tab) {
4309 return _this.registerTabRoute(tab[0]);
4310 });
4311 Object.entries(this.getRoutes()).forEach(function (_ref) {
4312 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
4313 route = _ref2[0],
4314 callback = _ref2[1];
4315 return _this.registerRoute(route, callback);
4316 });
4317 Object.entries(this.getCommands()).forEach(function (_ref3) {
4318 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
4319 command = _ref4[0],
4320 callback = _ref4[1];
4321 return _this.registerCommand(command, callback);
4322 });
4323 Object.entries(this.getCommandsInternal()).forEach(function (_ref5) {
4324 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
4325 command = _ref6[0],
4326 callback = _ref6[1];
4327 return _this.registerCommandInternal(command, callback);
4328 });
4329 Object.values(this.getHooks()).forEach(function (instance) {
4330 return _this.registerHook(instance);
4331 });
4332 Object.entries(this.getData()).forEach(function (_ref7) {
4333 var _ref8 = (0, _slicedToArray2.default)(_ref7, 2),
4334 command = _ref8[0],
4335 callback = _ref8[1];
4336 return _this.registerData(command, callback);
4337 });
4338 Object.values(this.getUiStates()).forEach(function (instance) {
4339 return _this.registerUiState(instance);
4340 });
4341 Object.entries(this.getStates()).forEach(function (_ref9) {
4342 var _ref0 = (0, _slicedToArray2.default)(_ref9, 2),
4343 id = _ref0[0],
4344 state = _ref0[1];
4345 return _this.registerState(id, state);
4346 });
4347 }
4348
4349 // eslint-disable-next-line jsdoc/require-returns-check
4350 /**
4351 * @return {string} namespace
4352 */
4353 }, {
4354 key: "getNamespace",
4355 value: function getNamespace() {
4356 (0, _forceMethodImplementation.default)();
4357 }
4358
4359 /**
4360 * @deprecated since 3.7.0, use `getServiceName()` instead.
4361 */
4362 }, {
4363 key: "getRootContainer",
4364 value: function getRootContainer() {
4365 _deprecation.default.deprecated('getRootContainer()', '3.7.0', 'getServiceName()');
4366 return this.getServiceName();
4367 }
4368 }, {
4369 key: "getServiceName",
4370 value: function getServiceName() {
4371 return this.getNamespace().split('/')[0];
4372 }
4373 }, {
4374 key: "store",
4375 get: function get() {
4376 return $e.store.get(this.getNamespace());
4377 }
4378 }, {
4379 key: "defaultTabs",
4380 value: function defaultTabs() {
4381 return {};
4382 }
4383 }, {
4384 key: "defaultRoutes",
4385 value: function defaultRoutes() {
4386 return {};
4387 }
4388 }, {
4389 key: "defaultCommands",
4390 value: function defaultCommands() {
4391 return {};
4392 }
4393 }, {
4394 key: "defaultCommandsInternal",
4395 value: function defaultCommandsInternal() {
4396 return {};
4397 }
4398 }, {
4399 key: "defaultHooks",
4400 value: function defaultHooks() {
4401 return {};
4402 }
4403
4404 /**
4405 * Get the component's default UI states.
4406 *
4407 * @return {Object} default UI states
4408 */
4409 }, {
4410 key: "defaultUiStates",
4411 value: function defaultUiStates() {
4412 return {};
4413 }
4414
4415 /**
4416 * Get the component's Redux slice settings.
4417 *
4418 * @return {Object} Redux slice settings
4419 */
4420 }, {
4421 key: "defaultStates",
4422 value: function defaultStates() {
4423 return {};
4424 }
4425 }, {
4426 key: "defaultShortcuts",
4427 value: function defaultShortcuts() {
4428 return {};
4429 }
4430 }, {
4431 key: "defaultUtils",
4432 value: function defaultUtils() {
4433 return {};
4434 }
4435 }, {
4436 key: "defaultData",
4437 value: function defaultData() {
4438 return {};
4439 }
4440 }, {
4441 key: "getCommands",
4442 value: function getCommands() {
4443 return this.commands;
4444 }
4445 }, {
4446 key: "getCommandsInternal",
4447 value: function getCommandsInternal() {
4448 return this.commandsInternal;
4449 }
4450 }, {
4451 key: "getHooks",
4452 value: function getHooks() {
4453 return this.hooks;
4454 }
4455
4456 /**
4457 * Retrieve the component's UI states.
4458 *
4459 * @return {Object} UI states
4460 */
4461 }, {
4462 key: "getUiStates",
4463 value: function getUiStates() {
4464 return this.uiStates;
4465 }
4466
4467 /**
4468 * Retrieve the component's Redux Slice.
4469 *
4470 * @return {Object} Redux Slice
4471 */
4472 }, {
4473 key: "getStates",
4474 value: function getStates() {
4475 return this.states;
4476 }
4477 }, {
4478 key: "getRoutes",
4479 value: function getRoutes() {
4480 return this.routes;
4481 }
4482 }, {
4483 key: "getTabs",
4484 value: function getTabs() {
4485 return this.tabs;
4486 }
4487 }, {
4488 key: "getShortcuts",
4489 value: function getShortcuts() {
4490 return this.shortcuts;
4491 }
4492 }, {
4493 key: "getData",
4494 value: function getData() {
4495 return this.data;
4496 }
4497
4498 /**
4499 * @param {string} command
4500 * @param {(()=>{}|CommandInfra)} context
4501 * @param {'default'|'internal'|'data'} commandsType
4502 */
4503 }, {
4504 key: "registerCommand",
4505 value: function registerCommand(command, context) {
4506 var commandsType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'default';
4507 var commandsManager;
4508 switch (commandsType) {
4509 case 'default':
4510 commandsManager = $e.commands;
4511 break;
4512 case 'internal':
4513 commandsManager = $e.commandsInternal;
4514 break;
4515 case 'data':
4516 commandsManager = $e.data;
4517 break;
4518 default:
4519 throw new Error("Invalid commands type: '".concat(command, "'"));
4520 }
4521 var fullCommand = this.getNamespace() + '/' + command,
4522 instanceType = context.getInstanceType ? context.getInstanceType() : false,
4523 registerConfig = {
4524 command: fullCommand,
4525 component: this
4526 };
4527
4528 // Support pure callback.
4529 if (!instanceType) {
4530 if ($e.devTools) {
4531 $e.devTools.log.warn("Attach command-callback-base, on command: '".concat(fullCommand, "', context is unknown type."));
4532 }
4533 registerConfig.callback = context;
4534
4535 // Unique class.
4536 context = /*#__PURE__*/function (_CommandCallbackBase) {
4537 function context() {
4538 (0, _classCallCheck2.default)(this, context);
4539 return _callSuper(this, context, arguments);
4540 }
4541 (0, _inherits2.default)(context, _CommandCallbackBase);
4542 return (0, _createClass2.default)(context);
4543 }(_commandCallbackBase.default);
4544 }
4545 context.setRegisterConfig(registerConfig);
4546 commandsManager.register(this, command, context);
4547 }
4548
4549 /**
4550 * @param {HookBase} instance
4551 */
4552 }, {
4553 key: "registerHook",
4554 value: function registerHook(instance) {
4555 return instance.register();
4556 }
4557 }, {
4558 key: "registerCommandInternal",
4559 value: function registerCommandInternal(command, context) {
4560 this.registerCommand(command, context, 'internal');
4561 }
4562
4563 /**
4564 * Register a UI state.
4565 *
4566 * @param {UiStateBase} instance - UI state instance.
4567 *
4568 * @return {void}
4569 */
4570 }, {
4571 key: "registerUiState",
4572 value: function registerUiState(instance) {
4573 $e.uiStates.register(instance);
4574 }
4575
4576 /**
4577 * Register a Redux Slice.
4578 *
4579 * @param {string} id - State id.
4580 * @param {Object} stateConfig - The state config.
4581 *
4582 * @return {void}
4583 */
4584 }, {
4585 key: "registerState",
4586 value: function registerState(id, stateConfig) {
4587 id = this.getNamespace() + (id ? "/".concat(id) : '');
4588 var slice = (0, _toolkit.createSlice)(_objectSpread(_objectSpread({}, stateConfig), {}, {
4589 name: id
4590 }));
4591 $e.store.register(id, slice);
4592 }
4593 }, {
4594 key: "registerRoute",
4595 value: function registerRoute(route, callback) {
4596 $e.routes.register(this, route, callback);
4597 }
4598 }, {
4599 key: "registerData",
4600 value: function registerData(command, context) {
4601 this.registerCommand(command, context, 'data');
4602 }
4603 }, {
4604 key: "unregisterRoute",
4605 value: function unregisterRoute(route) {
4606 $e.routes.unregister(this, route);
4607 }
4608 }, {
4609 key: "registerTabRoute",
4610 value: function registerTabRoute(tab) {
4611 var _this2 = this;
4612 this.registerRoute(tab, function (args) {
4613 return _this2.activateTab(tab, args);
4614 });
4615 }
4616 }, {
4617 key: "dependency",
4618 value: function dependency() {
4619 return true;
4620 }
4621 }, {
4622 key: "open",
4623 value: function open() {
4624 return true;
4625 }
4626 }, {
4627 key: "close",
4628 value: function close() {
4629 if (!this.isOpen) {
4630 return false;
4631 }
4632 this.isOpen = false;
4633 this.inactivate();
4634 $e.routes.clearCurrent(this.getNamespace());
4635 $e.routes.clearHistory(this.getServiceName());
4636 return true;
4637 }
4638 }, {
4639 key: "activate",
4640 value: function activate() {
4641 $e.components.activate(this.getNamespace());
4642 }
4643 }, {
4644 key: "inactivate",
4645 value: function inactivate() {
4646 $e.components.inactivate(this.getNamespace());
4647 }
4648 }, {
4649 key: "isActive",
4650 value: function isActive() {
4651 return $e.components.isActive(this.getNamespace());
4652 }
4653 }, {
4654 key: "onRoute",
4655 value: function onRoute(route) {
4656 this.toggleRouteClass(route, true);
4657 this.toggleHistoryClass();
4658 this.activate();
4659 this.trigger('route/open', route);
4660 }
4661 }, {
4662 key: "onCloseRoute",
4663 value: function onCloseRoute(route) {
4664 this.toggleRouteClass(route, false);
4665 this.inactivate();
4666 this.trigger('route/close', route);
4667 }
4668 }, {
4669 key: "setDefaultRoute",
4670 value: function setDefaultRoute(route) {
4671 this.defaultRoute = this.getNamespace() + '/' + route;
4672 }
4673 }, {
4674 key: "getDefaultRoute",
4675 value: function getDefaultRoute() {
4676 return this.defaultRoute;
4677 }
4678 }, {
4679 key: "removeTab",
4680 value: function removeTab(tab) {
4681 delete this.tabs[tab];
4682 this.unregisterRoute(tab);
4683 }
4684 }, {
4685 key: "hasTab",
4686 value: function hasTab(tab) {
4687 return !!this.tabs[tab];
4688 }
4689 }, {
4690 key: "addTab",
4691 value: function addTab(tab, args, position) {
4692 var _this3 = this;
4693 this.tabs[tab] = args;
4694 // It can be 0.
4695 if ('undefined' !== typeof position) {
4696 var newTabs = {};
4697 var ids = Object.keys(this.tabs);
4698 // Remove new tab
4699 ids.pop();
4700
4701 // Add it to position.
4702 ids.splice(position, 0, tab);
4703 ids.forEach(function (id) {
4704 newTabs[id] = _this3.tabs[id];
4705 });
4706 this.tabs = newTabs;
4707 }
4708 this.registerTabRoute(tab);
4709 }
4710 }, {
4711 key: "getTabsWrapperSelector",
4712 value: function getTabsWrapperSelector() {
4713 return '';
4714 }
4715 }, {
4716 key: "getTabRoute",
4717 value: function getTabRoute(tab) {
4718 return this.getNamespace() + '/' + tab;
4719 }
4720 }, {
4721 key: "renderTab",
4722 value: function renderTab(tab) {} // eslint-disable-line
4723 }, {
4724 key: "activateTab",
4725 value: function activateTab(tab, args) {
4726 var _this4 = this;
4727 this.renderTab(tab, args);
4728 jQuery(this.getTabsWrapperSelector() + ' .elementor-component-tab').off('click').on('click', function (event) {
4729 $e.route(_this4.getTabRoute(event.currentTarget.dataset.tab), args);
4730 }).removeClass('elementor-active').filter('[data-tab="' + tab + '"]').addClass('elementor-active');
4731 }
4732 }, {
4733 key: "getActiveTabConfig",
4734 value: function getActiveTabConfig() {
4735 return this.tabs[this.currentTab] || {};
4736 }
4737 }, {
4738 key: "getBodyClass",
4739 value: function getBodyClass(route) {
4740 return 'e-route-' + route.replace(/\//g, '-');
4741 }
4742
4743 /**
4744 * If command includes uppercase character convert it to lowercase and add `-`.
4745 * e.g: `CopyAll` is converted to `copy-all`.
4746 *
4747 * @param {string} commandName
4748 */
4749 }, {
4750 key: "normalizeCommandName",
4751 value: function normalizeCommandName(commandName) {
4752 return commandName.replace(/[A-Z]/g, function (match, offset) {
4753 return (offset > 0 ? '-' : '') + match.toLowerCase();
4754 });
4755 }
4756
4757 /**
4758 * @param {{}} commandsFromImport
4759 * @return {{}} imported commands
4760 */
4761 }, {
4762 key: "importCommands",
4763 value: function importCommands(commandsFromImport) {
4764 var _this5 = this;
4765 var commands = {};
4766
4767 // Convert `Commands` to `ComponentBase` workable format.
4768 Object.entries(commandsFromImport).forEach(function (_ref1) {
4769 var _ref10 = (0, _slicedToArray2.default)(_ref1, 2),
4770 className = _ref10[0],
4771 Class = _ref10[1];
4772 var command = _this5.normalizeCommandName(className);
4773 commands[command] = Class;
4774 });
4775 return commands;
4776 }
4777 }, {
4778 key: "importHooks",
4779 value: function importHooks(hooksFromImport) {
4780 var hooks = {};
4781 for (var key in hooksFromImport) {
4782 var hook = new hooksFromImport[key]();
4783 hooks[hook.getId()] = hook;
4784 }
4785 return hooks;
4786 }
4787
4788 /**
4789 * Import & initialize the component's UI states.
4790 * Should be used inside `defaultUiState()`.
4791 *
4792 * @param {Object} statesFromImport - UI states from import.
4793 *
4794 * @return {Object} UI States
4795 */
4796 }, {
4797 key: "importUiStates",
4798 value: function importUiStates(statesFromImport) {
4799 var _this6 = this;
4800 var uiStates = {};
4801 Object.values(statesFromImport).forEach(function (className) {
4802 var uiState = new className(_this6);
4803 uiStates[uiState.getId()] = uiState;
4804 });
4805 return uiStates;
4806 }
4807
4808 /**
4809 * Set a UI state value.
4810 * TODO: Should we provide such function? Maybe the developer should implicitly pass the full state ID?
4811 *
4812 * @param {string} state - Non-prefixed state ID.
4813 * @param {*} value - New state value.
4814 *
4815 * @return {void}
4816 */
4817 }, {
4818 key: "setUiState",
4819 value: function setUiState(state, value) {
4820 $e.uiStates.set("".concat(this.getNamespace(), "/").concat(state), value);
4821 }
4822 }, {
4823 key: "toggleRouteClass",
4824 value: function toggleRouteClass(route, state) {
4825 document.body.classList.toggle(this.getBodyClass(route), state);
4826 }
4827 }, {
4828 key: "toggleHistoryClass",
4829 value: function toggleHistoryClass() {
4830 document.body.classList.toggle('e-routes-has-history', !!$e.routes.getHistory(this.getServiceName()).length);
4831 }
4832 }]);
4833 }(_module.default);
4834
4835 /***/ }),
4836
4837 /***/ "../modules/web-cli/assets/js/modules/component-modal-base.js":
4838 /*!********************************************************************!*\
4839 !*** ../modules/web-cli/assets/js/modules/component-modal-base.js ***!
4840 \********************************************************************/
4841 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4842
4843 "use strict";
4844
4845
4846 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4847 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
4848 Object.defineProperty(exports, "__esModule", ({
4849 value: true
4850 }));
4851 exports["default"] = void 0;
4852 var _readOnlyError2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/readOnlyError */ "../node_modules/@babel/runtime/helpers/readOnlyError.js"));
4853 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4854 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4855 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4856 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4857 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
4858 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4859 var _componentBase = _interopRequireDefault(__webpack_require__(/*! ./component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
4860 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../modules/web-cli/assets/js/modules/commands/index.js"));
4861 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4862 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); }
4863 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)); }
4864 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4865 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; }
4866 var ComponentModalBase = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
4867 function ComponentModalBase() {
4868 (0, _classCallCheck2.default)(this, ComponentModalBase);
4869 return _callSuper(this, ComponentModalBase, arguments);
4870 }
4871 (0, _inherits2.default)(ComponentModalBase, _ComponentBase);
4872 return (0, _createClass2.default)(ComponentModalBase, [{
4873 key: "registerAPI",
4874 value: function registerAPI() {
4875 var _this = this;
4876 _superPropGet(ComponentModalBase, "registerAPI", this, 3)([]);
4877 $e.shortcuts.register('esc', {
4878 scopes: [this.getNamespace()],
4879 callback: function callback() {
4880 return _this.close();
4881 }
4882 });
4883 }
4884 }, {
4885 key: "defaultCommands",
4886 value: function defaultCommands() {
4887 return this.importCommands(commands);
4888 }
4889 }, {
4890 key: "defaultRoutes",
4891 value: function defaultRoutes() {
4892 return {
4893 '': function _() {/* Nothing to do, it's already rendered. */}
4894 };
4895 }
4896 }, {
4897 key: "open",
4898 value: function open() {
4899 var _this2 = this;
4900 if (!this.layout) {
4901 var layout = this.getModalLayout();
4902 this.layout = new layout({
4903 component: this
4904 });
4905 this.layout.getModal().on('hide', function () {
4906 return _this2.close();
4907 });
4908 }
4909 this.layout.showModal();
4910 return true;
4911 }
4912 }, {
4913 key: "close",
4914 value: function close() {
4915 if (!_superPropGet(ComponentModalBase, "close", this, 3)([])) {
4916 return false;
4917 }
4918 var close = elementor.hooks.applyFilters('component/modal/close', this.layout.getModal().hide.bind(this.layout.getModal()), this);
4919 close();
4920 return true;
4921 }
4922 }, {
4923 key: "getModalLayout",
4924 value: function getModalLayout() {
4925 (0, _forceMethodImplementation.default)();
4926 }
4927 }]);
4928 }(_componentBase.default);
4929
4930 /***/ }),
4931
4932 /***/ "../modules/web-cli/assets/js/utils/console.js":
4933 /*!*****************************************************!*\
4934 !*** ../modules/web-cli/assets/js/utils/console.js ***!
4935 \*****************************************************/
4936 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4937
4938 "use strict";
4939
4940
4941 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4942 Object.defineProperty(exports, "__esModule", ({
4943 value: true
4944 }));
4945 exports["default"] = void 0;
4946 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4947 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4948 var Console = exports["default"] = /*#__PURE__*/function () {
4949 function Console() {
4950 (0, _classCallCheck2.default)(this, Console);
4951 }
4952 return (0, _createClass2.default)(Console, null, [{
4953 key: "error",
4954 value: function error(message) {
4955 // Show an error if devTools is available.
4956 if ($e.devTools) {
4957 $e.devTools.log.error(message);
4958 }
4959
4960 // If not a 'Hook-Break' then show error.
4961 if (!(message instanceof $e.modules.HookBreak)) {
4962 // eslint-disable-next-line no-console
4963 console.error(message);
4964 }
4965 }
4966 }, {
4967 key: "warn",
4968 value: function warn() {
4969 var _console;
4970 var style = "font-size: 12px; background-image: url(\"".concat(elementorWebCliConfig.urls.assets, "images/logo-icon.png\"); background-repeat: no-repeat; background-size: contain;");
4971 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4972 args[_key] = arguments[_key];
4973 }
4974 args.unshift('%c %c', style, '');
4975 (_console = console).warn.apply(_console, args); // eslint-disable-line no-console
4976 }
4977 }]);
4978 }();
4979
4980 /***/ }),
4981
4982 /***/ "../modules/web-cli/assets/js/utils/deprecation.js":
4983 /*!*********************************************************!*\
4984 !*** ../modules/web-cli/assets/js/utils/deprecation.js ***!
4985 \*********************************************************/
4986 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4987
4988 "use strict";
4989
4990
4991 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4992 Object.defineProperty(exports, "__esModule", ({
4993 value: true
4994 }));
4995 exports["default"] = void 0;
4996 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4997 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4998 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4999 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
5000 // Copied from `modules/dev-tools/assets/js/deprecation.js`
5001 /**
5002 * @typedef {Object} Version
5003 * @property {number} major1 The first number
5004 * @property {number} major2 The second number
5005 * @property {number} minor The third number
5006 * @property {string} build The fourth number
5007 */
5008
5009 var softDeprecated = function softDeprecated(name, version, replacement) {
5010 if (elementorWebCliConfig.isDebug) {
5011 deprecatedMessage('soft', name, version, replacement);
5012 }
5013 };
5014 var hardDeprecated = function hardDeprecated(name, version, replacement) {
5015 deprecatedMessage('hard', name, version, replacement);
5016 };
5017 var deprecatedMessage = function deprecatedMessage(type, name, version, replacement) {
5018 var message = "`".concat(name, "` is ").concat(type, " deprecated since ").concat(version);
5019 if (replacement) {
5020 message += " - Use `".concat(replacement, "` instead");
5021 }
5022 _console.default.warn(message);
5023 };
5024 var Deprecation = exports["default"] = /*#__PURE__*/function () {
5025 function Deprecation() {
5026 (0, _classCallCheck2.default)(this, Deprecation);
5027 }
5028 return (0, _createClass2.default)(Deprecation, null, [{
5029 key: "deprecated",
5030 value: function deprecated(name, version, replacement) {
5031 if (this.isHardDeprecated(version)) {
5032 hardDeprecated(name, version, replacement);
5033 } else {
5034 softDeprecated(name, version, replacement);
5035 }
5036 }
5037
5038 /**
5039 * @param {string} version
5040 *
5041 * @return {Version}
5042 */
5043 }, {
5044 key: "parseVersion",
5045 value: function parseVersion(version) {
5046 var versionParts = version.split('.');
5047 if (versionParts.length < 3 || versionParts.length > 4) {
5048 throw new RangeError('Invalid Semantic Version string provided');
5049 }
5050 var _versionParts = (0, _slicedToArray2.default)(versionParts, 4),
5051 major1 = _versionParts[0],
5052 major2 = _versionParts[1],
5053 minor = _versionParts[2],
5054 _versionParts$ = _versionParts[3],
5055 build = _versionParts$ === void 0 ? '' : _versionParts$;
5056 return {
5057 major1: parseInt(major1),
5058 major2: parseInt(major2),
5059 minor: parseInt(minor),
5060 build: build
5061 };
5062 }
5063
5064 /**
5065 * Get total of major.
5066 *
5067 * 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,
5068 * versions with major2 more then 9 will be added to total.
5069 *
5070 * @param {Version} versionObj
5071 *
5072 * @return {number}
5073 */
5074 }, {
5075 key: "getTotalMajor",
5076 value: function getTotalMajor(versionObj) {
5077 var total = parseInt("".concat(versionObj.major1).concat(versionObj.major2, "0"));
5078 total = Number((total / 10).toFixed(0));
5079 if (versionObj.major2 > 9) {
5080 total = versionObj.major2 - 9;
5081 }
5082 return total;
5083 }
5084
5085 /**
5086 * @param {string} version1
5087 * @param {string} version2
5088 *
5089 * @return {number}
5090 */
5091 }, {
5092 key: "compareVersion",
5093 value: function compareVersion(version1, version2) {
5094 var _this = this;
5095 return [this.parseVersion(version1), this.parseVersion(version2)].map(function (versionObj) {
5096 return _this.getTotalMajor(versionObj);
5097 }).reduce(function (acc, major) {
5098 return acc - major;
5099 });
5100 }
5101
5102 /**
5103 * @param {string} version
5104 *
5105 * @return {boolean}
5106 */
5107 }, {
5108 key: "isSoftDeprecated",
5109 value: function isSoftDeprecated(version) {
5110 var total = this.compareVersion(version, elementorWebCliConfig.version);
5111 return total <= 4;
5112 }
5113
5114 /**
5115 * @param {string} version
5116 * @return {boolean}
5117 */
5118 }, {
5119 key: "isHardDeprecated",
5120 value: function isHardDeprecated(version) {
5121 var total = this.compareVersion(version, elementorWebCliConfig.version);
5122 return total < 0 || total >= 8;
5123 }
5124 }]);
5125 }();
5126
5127 /***/ }),
5128
5129 /***/ "../modules/web-cli/assets/js/utils/force-method-implementation.js":
5130 /*!*************************************************************************!*\
5131 !*** ../modules/web-cli/assets/js/utils/force-method-implementation.js ***!
5132 \*************************************************************************/
5133 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5134
5135 "use strict";
5136
5137
5138 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5139 Object.defineProperty(exports, "__esModule", ({
5140 value: true
5141 }));
5142 exports["default"] = exports.ForceMethodImplementation = void 0;
5143 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5144 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5145 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5146 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5147 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5148 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
5149 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)); }
5150 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5151 // TODO: Copied from `assets/dev/js/modules/imports/force-method-implementation.js`;
5152 var ForceMethodImplementation = exports.ForceMethodImplementation = /*#__PURE__*/function (_Error) {
5153 function ForceMethodImplementation() {
5154 var _this;
5155 var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5156 (0, _classCallCheck2.default)(this, ForceMethodImplementation);
5157 _this = _callSuper(this, ForceMethodImplementation, ["".concat(info.isStatic ? 'static ' : '').concat(info.fullName, "() should be implemented, please provide '").concat(info.functionName || info.fullName, "' functionality.")]);
5158 Error.captureStackTrace(_this, ForceMethodImplementation);
5159 return _this;
5160 }
5161 (0, _inherits2.default)(ForceMethodImplementation, _Error);
5162 return (0, _createClass2.default)(ForceMethodImplementation);
5163 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
5164 var _default = exports["default"] = function _default() {
5165 var stack = Error().stack,
5166 caller = stack.split('\n')[2].trim(),
5167 callerName = caller.startsWith('at new') ? 'constructor' : caller.split(' ')[1],
5168 info = {};
5169 info.functionName = callerName;
5170 info.fullName = callerName;
5171 if (info.functionName.includes('.')) {
5172 var parts = info.functionName.split('.');
5173 info.className = parts[0];
5174 info.functionName = parts[1];
5175 } else {
5176 info.isStatic = true;
5177 }
5178 throw new ForceMethodImplementation(info);
5179 };
5180
5181 /***/ }),
5182
5183 /***/ "../node_modules/@babel/runtime/helpers/OverloadYield.js":
5184 /*!***************************************************************!*\
5185 !*** ../node_modules/@babel/runtime/helpers/OverloadYield.js ***!
5186 \***************************************************************/
5187 /***/ ((module) => {
5188
5189 function _OverloadYield(e, d) {
5190 this.v = e, this.k = d;
5191 }
5192 module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
5193
5194 /***/ }),
5195
5196 /***/ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
5197 /*!******************************************************************!*\
5198 !*** ../node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
5199 \******************************************************************/
5200 /***/ ((module) => {
5201
5202 function _arrayLikeToArray(r, a) {
5203 (null == a || a > r.length) && (a = r.length);
5204 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
5205 return n;
5206 }
5207 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
5208
5209 /***/ }),
5210
5211 /***/ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js":
5212 /*!****************************************************************!*\
5213 !*** ../node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
5214 \****************************************************************/
5215 /***/ ((module) => {
5216
5217 function _arrayWithHoles(r) {
5218 if (Array.isArray(r)) return r;
5219 }
5220 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
5221
5222 /***/ }),
5223
5224 /***/ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js":
5225 /*!***********************************************************************!*\
5226 !*** ../node_modules/@babel/runtime/helpers/assertThisInitialized.js ***!
5227 \***********************************************************************/
5228 /***/ ((module) => {
5229
5230 function _assertThisInitialized(e) {
5231 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5232 return e;
5233 }
5234 module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
5235
5236 /***/ }),
5237
5238 /***/ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js":
5239 /*!******************************************************************!*\
5240 !*** ../node_modules/@babel/runtime/helpers/asyncToGenerator.js ***!
5241 \******************************************************************/
5242 /***/ ((module) => {
5243
5244 function asyncGeneratorStep(n, t, e, r, o, a, c) {
5245 try {
5246 var i = n[a](c),
5247 u = i.value;
5248 } catch (n) {
5249 return void e(n);
5250 }
5251 i.done ? t(u) : Promise.resolve(u).then(r, o);
5252 }
5253 function _asyncToGenerator(n) {
5254 return function () {
5255 var t = this,
5256 e = arguments;
5257 return new Promise(function (r, o) {
5258 var a = n.apply(t, e);
5259 function _next(n) {
5260 asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
5261 }
5262 function _throw(n) {
5263 asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
5264 }
5265 _next(void 0);
5266 });
5267 };
5268 }
5269 module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5270
5271 /***/ }),
5272
5273 /***/ "../node_modules/@babel/runtime/helpers/classCallCheck.js":
5274 /*!****************************************************************!*\
5275 !*** ../node_modules/@babel/runtime/helpers/classCallCheck.js ***!
5276 \****************************************************************/
5277 /***/ ((module) => {
5278
5279 function _classCallCheck(a, n) {
5280 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
5281 }
5282 module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
5283
5284 /***/ }),
5285
5286 /***/ "../node_modules/@babel/runtime/helpers/construct.js":
5287 /*!***********************************************************!*\
5288 !*** ../node_modules/@babel/runtime/helpers/construct.js ***!
5289 \***********************************************************/
5290 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5291
5292 var isNativeReflectConstruct = __webpack_require__(/*! ./isNativeReflectConstruct.js */ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js");
5293 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5294 function _construct(t, e, r) {
5295 if (isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
5296 var o = [null];
5297 o.push.apply(o, e);
5298 var p = new (t.bind.apply(t, o))();
5299 return r && setPrototypeOf(p, r.prototype), p;
5300 }
5301 module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5302
5303 /***/ }),
5304
5305 /***/ "../node_modules/@babel/runtime/helpers/createClass.js":
5306 /*!*************************************************************!*\
5307 !*** ../node_modules/@babel/runtime/helpers/createClass.js ***!
5308 \*************************************************************/
5309 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5310
5311 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5312 function _defineProperties(e, r) {
5313 for (var t = 0; t < r.length; t++) {
5314 var o = r[t];
5315 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
5316 }
5317 }
5318 function _createClass(e, r, t) {
5319 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
5320 writable: !1
5321 }), e;
5322 }
5323 module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
5324
5325 /***/ }),
5326
5327 /***/ "../node_modules/@babel/runtime/helpers/defineProperty.js":
5328 /*!****************************************************************!*\
5329 !*** ../node_modules/@babel/runtime/helpers/defineProperty.js ***!
5330 \****************************************************************/
5331 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5332
5333 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5334 function _defineProperty(e, r, t) {
5335 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5336 value: t,
5337 enumerable: !0,
5338 configurable: !0,
5339 writable: !0
5340 }) : e[r] = t, e;
5341 }
5342 module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
5343
5344 /***/ }),
5345
5346 /***/ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js":
5347 /*!********************************************************************!*\
5348 !*** ../node_modules/@babel/runtime/helpers/esm/defineProperty.js ***!
5349 \********************************************************************/
5350 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5351
5352 "use strict";
5353 __webpack_require__.r(__webpack_exports__);
5354 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5355 /* harmony export */ "default": () => (/* binding */ _defineProperty)
5356 /* harmony export */ });
5357 /* harmony import */ var _toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js");
5358
5359 function _defineProperty(e, r, t) {
5360 return (r = (0,_toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r)) in e ? Object.defineProperty(e, r, {
5361 value: t,
5362 enumerable: !0,
5363 configurable: !0,
5364 writable: !0
5365 }) : e[r] = t, e;
5366 }
5367
5368
5369 /***/ }),
5370
5371 /***/ "../node_modules/@babel/runtime/helpers/esm/objectSpread2.js":
5372 /*!*******************************************************************!*\
5373 !*** ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js ***!
5374 \*******************************************************************/
5375 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5376
5377 "use strict";
5378 __webpack_require__.r(__webpack_exports__);
5379 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5380 /* harmony export */ "default": () => (/* binding */ _objectSpread2)
5381 /* harmony export */ });
5382 /* harmony import */ var _defineProperty_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defineProperty.js */ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js");
5383
5384 function ownKeys(e, r) {
5385 var t = Object.keys(e);
5386 if (Object.getOwnPropertySymbols) {
5387 var o = Object.getOwnPropertySymbols(e);
5388 r && (o = o.filter(function (r) {
5389 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5390 })), t.push.apply(t, o);
5391 }
5392 return t;
5393 }
5394 function _objectSpread2(e) {
5395 for (var r = 1; r < arguments.length; r++) {
5396 var t = null != arguments[r] ? arguments[r] : {};
5397 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
5398 (0,_defineProperty_js__WEBPACK_IMPORTED_MODULE_0__["default"])(e, r, t[r]);
5399 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
5400 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5401 });
5402 }
5403 return e;
5404 }
5405
5406
5407 /***/ }),
5408
5409 /***/ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js":
5410 /*!*****************************************************************!*\
5411 !*** ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js ***!
5412 \*****************************************************************/
5413 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5414
5415 "use strict";
5416 __webpack_require__.r(__webpack_exports__);
5417 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5418 /* harmony export */ "default": () => (/* binding */ toPrimitive)
5419 /* harmony export */ });
5420 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5421
5422 function toPrimitive(t, r) {
5423 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(t) || !t) return t;
5424 var e = t[Symbol.toPrimitive];
5425 if (void 0 !== e) {
5426 var i = e.call(t, r || "default");
5427 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i)) return i;
5428 throw new TypeError("@@toPrimitive must return a primitive value.");
5429 }
5430 return ("string" === r ? String : Number)(t);
5431 }
5432
5433
5434 /***/ }),
5435
5436 /***/ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js":
5437 /*!*******************************************************************!*\
5438 !*** ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js ***!
5439 \*******************************************************************/
5440 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5441
5442 "use strict";
5443 __webpack_require__.r(__webpack_exports__);
5444 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5445 /* harmony export */ "default": () => (/* binding */ toPropertyKey)
5446 /* harmony export */ });
5447 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5448 /* harmony import */ var _toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js");
5449
5450
5451 function toPropertyKey(t) {
5452 var i = (0,_toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__["default"])(t, "string");
5453 return "symbol" == (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i) ? i : i + "";
5454 }
5455
5456
5457 /***/ }),
5458
5459 /***/ "../node_modules/@babel/runtime/helpers/esm/typeof.js":
5460 /*!************************************************************!*\
5461 !*** ../node_modules/@babel/runtime/helpers/esm/typeof.js ***!
5462 \************************************************************/
5463 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5464
5465 "use strict";
5466 __webpack_require__.r(__webpack_exports__);
5467 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5468 /* harmony export */ "default": () => (/* binding */ _typeof)
5469 /* harmony export */ });
5470 function _typeof(o) {
5471 "@babel/helpers - typeof";
5472
5473 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
5474 return typeof o;
5475 } : function (o) {
5476 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
5477 }, _typeof(o);
5478 }
5479
5480
5481 /***/ }),
5482
5483 /***/ "../node_modules/@babel/runtime/helpers/get.js":
5484 /*!*****************************************************!*\
5485 !*** ../node_modules/@babel/runtime/helpers/get.js ***!
5486 \*****************************************************/
5487 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5488
5489 var superPropBase = __webpack_require__(/*! ./superPropBase.js */ "../node_modules/@babel/runtime/helpers/superPropBase.js");
5490 function _get() {
5491 return module.exports = _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
5492 var p = superPropBase(e, t);
5493 if (p) {
5494 var n = Object.getOwnPropertyDescriptor(p, t);
5495 return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
5496 }
5497 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _get.apply(null, arguments);
5498 }
5499 module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
5500
5501 /***/ }),
5502
5503 /***/ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js":
5504 /*!****************************************************************!*\
5505 !*** ../node_modules/@babel/runtime/helpers/getPrototypeOf.js ***!
5506 \****************************************************************/
5507 /***/ ((module) => {
5508
5509 function _getPrototypeOf(t) {
5510 return module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
5511 return t.__proto__ || Object.getPrototypeOf(t);
5512 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _getPrototypeOf(t);
5513 }
5514 module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
5515
5516 /***/ }),
5517
5518 /***/ "../node_modules/@babel/runtime/helpers/inherits.js":
5519 /*!**********************************************************!*\
5520 !*** ../node_modules/@babel/runtime/helpers/inherits.js ***!
5521 \**********************************************************/
5522 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5523
5524 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5525 function _inherits(t, e) {
5526 if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
5527 t.prototype = Object.create(e && e.prototype, {
5528 constructor: {
5529 value: t,
5530 writable: !0,
5531 configurable: !0
5532 }
5533 }), Object.defineProperty(t, "prototype", {
5534 writable: !1
5535 }), e && setPrototypeOf(t, e);
5536 }
5537 module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
5538
5539 /***/ }),
5540
5541 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
5542 /*!***********************************************************************!*\
5543 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
5544 \***********************************************************************/
5545 /***/ ((module) => {
5546
5547 function _interopRequireDefault(e) {
5548 return e && e.__esModule ? e : {
5549 "default": e
5550 };
5551 }
5552 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
5553
5554 /***/ }),
5555
5556 /***/ "../node_modules/@babel/runtime/helpers/isNativeFunction.js":
5557 /*!******************************************************************!*\
5558 !*** ../node_modules/@babel/runtime/helpers/isNativeFunction.js ***!
5559 \******************************************************************/
5560 /***/ ((module) => {
5561
5562 function _isNativeFunction(t) {
5563 try {
5564 return -1 !== Function.toString.call(t).indexOf("[native code]");
5565 } catch (n) {
5566 return "function" == typeof t;
5567 }
5568 }
5569 module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
5570
5571 /***/ }),
5572
5573 /***/ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js":
5574 /*!**************************************************************************!*\
5575 !*** ../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js ***!
5576 \**************************************************************************/
5577 /***/ ((module) => {
5578
5579 function _isNativeReflectConstruct() {
5580 try {
5581 var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
5582 } catch (t) {}
5583 return (module.exports = _isNativeReflectConstruct = function _isNativeReflectConstruct() {
5584 return !!t;
5585 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5586 }
5587 module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5588
5589 /***/ }),
5590
5591 /***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
5592 /*!**********************************************************************!*\
5593 !*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
5594 \**********************************************************************/
5595 /***/ ((module) => {
5596
5597 function _iterableToArrayLimit(r, l) {
5598 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
5599 if (null != t) {
5600 var e,
5601 n,
5602 i,
5603 u,
5604 a = [],
5605 f = !0,
5606 o = !1;
5607 try {
5608 if (i = (t = t.call(r)).next, 0 === l) {
5609 if (Object(t) !== t) return;
5610 f = !1;
5611 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
5612 } catch (r) {
5613 o = !0, n = r;
5614 } finally {
5615 try {
5616 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
5617 } finally {
5618 if (o) throw n;
5619 }
5620 }
5621 return a;
5622 }
5623 }
5624 module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
5625
5626 /***/ }),
5627
5628 /***/ "../node_modules/@babel/runtime/helpers/nonIterableRest.js":
5629 /*!*****************************************************************!*\
5630 !*** ../node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
5631 \*****************************************************************/
5632 /***/ ((module) => {
5633
5634 function _nonIterableRest() {
5635 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5636 }
5637 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
5638
5639 /***/ }),
5640
5641 /***/ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js":
5642 /*!***************************************************************************!*\
5643 !*** ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js ***!
5644 \***************************************************************************/
5645 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5646
5647 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5648 var assertThisInitialized = __webpack_require__(/*! ./assertThisInitialized.js */ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js");
5649 function _possibleConstructorReturn(t, e) {
5650 if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
5651 if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
5652 return assertThisInitialized(t);
5653 }
5654 module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
5655
5656 /***/ }),
5657
5658 /***/ "../node_modules/@babel/runtime/helpers/readOnlyError.js":
5659 /*!***************************************************************!*\
5660 !*** ../node_modules/@babel/runtime/helpers/readOnlyError.js ***!
5661 \***************************************************************/
5662 /***/ ((module) => {
5663
5664 function _readOnlyError(r) {
5665 throw new TypeError('"' + r + '" is read-only');
5666 }
5667 module.exports = _readOnlyError, module.exports.__esModule = true, module.exports["default"] = module.exports;
5668
5669 /***/ }),
5670
5671 /***/ "../node_modules/@babel/runtime/helpers/regenerator.js":
5672 /*!*************************************************************!*\
5673 !*** ../node_modules/@babel/runtime/helpers/regenerator.js ***!
5674 \*************************************************************/
5675 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5676
5677 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
5678 function _regenerator() {
5679 /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
5680 var e,
5681 t,
5682 r = "function" == typeof Symbol ? Symbol : {},
5683 n = r.iterator || "@@iterator",
5684 o = r.toStringTag || "@@toStringTag";
5685 function i(r, n, o, i) {
5686 var c = n && n.prototype instanceof Generator ? n : Generator,
5687 u = Object.create(c.prototype);
5688 return regeneratorDefine(u, "_invoke", function (r, n, o) {
5689 var i,
5690 c,
5691 u,
5692 f = 0,
5693 p = o || [],
5694 y = !1,
5695 G = {
5696 p: 0,
5697 n: 0,
5698 v: e,
5699 a: d,
5700 f: d.bind(e, 4),
5701 d: function d(t, r) {
5702 return i = t, c = 0, u = e, G.n = r, a;
5703 }
5704 };
5705 function d(r, n) {
5706 for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
5707 var o,
5708 i = p[t],
5709 d = G.p,
5710 l = i[2];
5711 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));
5712 }
5713 if (o || r > 1) return a;
5714 throw y = !0, n;
5715 }
5716 return function (o, p, l) {
5717 if (f > 1) throw TypeError("Generator is already running");
5718 for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
5719 i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
5720 try {
5721 if (f = 2, i) {
5722 if (c || (o = "next"), t = i[o]) {
5723 if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
5724 if (!t.done) return t;
5725 u = t.value, c < 2 && (c = 0);
5726 } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
5727 i = e;
5728 } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
5729 } catch (t) {
5730 i = e, c = 1, u = t;
5731 } finally {
5732 f = 1;
5733 }
5734 }
5735 return {
5736 value: t,
5737 done: y
5738 };
5739 };
5740 }(r, o, i), !0), u;
5741 }
5742 var a = {};
5743 function Generator() {}
5744 function GeneratorFunction() {}
5745 function GeneratorFunctionPrototype() {}
5746 t = Object.getPrototypeOf;
5747 var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
5748 return this;
5749 }), t),
5750 u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
5751 function f(e) {
5752 return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
5753 }
5754 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 () {
5755 return this;
5756 }), regeneratorDefine(u, "toString", function () {
5757 return "[object Generator]";
5758 }), (module.exports = _regenerator = function _regenerator() {
5759 return {
5760 w: i,
5761 m: f
5762 };
5763 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5764 }
5765 module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5766
5767 /***/ }),
5768
5769 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js":
5770 /*!******************************************************************!*\
5771 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsync.js ***!
5772 \******************************************************************/
5773 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5774
5775 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
5776 function _regeneratorAsync(n, e, r, t, o) {
5777 var a = regeneratorAsyncGen(n, e, r, t, o);
5778 return a.next().then(function (n) {
5779 return n.done ? n.value : a.next();
5780 });
5781 }
5782 module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
5783
5784 /***/ }),
5785
5786 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js":
5787 /*!*********************************************************************!*\
5788 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js ***!
5789 \*********************************************************************/
5790 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5791
5792 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
5793 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
5794 function _regeneratorAsyncGen(r, e, t, o, n) {
5795 return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
5796 }
5797 module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
5798
5799 /***/ }),
5800
5801 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js":
5802 /*!**************************************************************************!*\
5803 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js ***!
5804 \**************************************************************************/
5805 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5806
5807 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
5808 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
5809 function AsyncIterator(t, e) {
5810 function n(r, o, i, f) {
5811 try {
5812 var c = t[r](o),
5813 u = c.value;
5814 return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
5815 n("next", t, i, f);
5816 }, function (t) {
5817 n("throw", t, i, f);
5818 }) : e.resolve(u).then(function (t) {
5819 c.value = t, i(c);
5820 }, function (t) {
5821 return n("throw", t, i, f);
5822 });
5823 } catch (t) {
5824 f(t);
5825 }
5826 }
5827 var r;
5828 this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
5829 return this;
5830 })), regeneratorDefine(this, "_invoke", function (t, o, i) {
5831 function f() {
5832 return new e(function (e, r) {
5833 n(t, i, e, r);
5834 });
5835 }
5836 return r = r ? r.then(f, f) : f();
5837 }, !0);
5838 }
5839 module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5840
5841 /***/ }),
5842
5843 /***/ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js":
5844 /*!*******************************************************************!*\
5845 !*** ../node_modules/@babel/runtime/helpers/regeneratorDefine.js ***!
5846 \*******************************************************************/
5847 /***/ ((module) => {
5848
5849 function _regeneratorDefine(e, r, n, t) {
5850 var i = Object.defineProperty;
5851 try {
5852 i({}, "", {});
5853 } catch (e) {
5854 i = 0;
5855 }
5856 module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
5857 function o(r, n) {
5858 _regeneratorDefine(e, r, function (e) {
5859 return this._invoke(r, n, e);
5860 });
5861 }
5862 r ? i ? i(e, r, {
5863 value: n,
5864 enumerable: !t,
5865 configurable: !t,
5866 writable: !t
5867 }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
5868 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
5869 }
5870 module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
5871
5872 /***/ }),
5873
5874 /***/ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js":
5875 /*!*****************************************************************!*\
5876 !*** ../node_modules/@babel/runtime/helpers/regeneratorKeys.js ***!
5877 \*****************************************************************/
5878 /***/ ((module) => {
5879
5880 function _regeneratorKeys(e) {
5881 var n = Object(e),
5882 r = [];
5883 for (var t in n) r.unshift(t);
5884 return function e() {
5885 for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
5886 return e.done = !0, e;
5887 };
5888 }
5889 module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
5890
5891 /***/ }),
5892
5893 /***/ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js":
5894 /*!********************************************************************!*\
5895 !*** ../node_modules/@babel/runtime/helpers/regeneratorRuntime.js ***!
5896 \********************************************************************/
5897 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5898
5899 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
5900 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
5901 var regeneratorAsync = __webpack_require__(/*! ./regeneratorAsync.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js");
5902 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
5903 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
5904 var regeneratorKeys = __webpack_require__(/*! ./regeneratorKeys.js */ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js");
5905 var regeneratorValues = __webpack_require__(/*! ./regeneratorValues.js */ "../node_modules/@babel/runtime/helpers/regeneratorValues.js");
5906 function _regeneratorRuntime() {
5907 "use strict";
5908
5909 var r = regenerator(),
5910 e = r.m(_regeneratorRuntime),
5911 t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
5912 function n(r) {
5913 var e = "function" == typeof r && r.constructor;
5914 return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
5915 }
5916 var o = {
5917 "throw": 1,
5918 "return": 2,
5919 "break": 3,
5920 "continue": 3
5921 };
5922 function a(r) {
5923 var e, t;
5924 return function (n) {
5925 e || (e = {
5926 stop: function stop() {
5927 return t(n.a, 2);
5928 },
5929 "catch": function _catch() {
5930 return n.v;
5931 },
5932 abrupt: function abrupt(r, e) {
5933 return t(n.a, o[r], e);
5934 },
5935 delegateYield: function delegateYield(r, o, a) {
5936 return e.resultName = o, t(n.d, regeneratorValues(r), a);
5937 },
5938 finish: function finish(r) {
5939 return t(n.f, r);
5940 }
5941 }, t = function t(r, _t, o) {
5942 n.p = e.prev, n.n = e.next;
5943 try {
5944 return r(_t, o);
5945 } finally {
5946 e.next = n.n;
5947 }
5948 }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
5949 try {
5950 return r.call(this, e);
5951 } finally {
5952 n.p = e.prev, n.n = e.next;
5953 }
5954 };
5955 }
5956 return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
5957 return {
5958 wrap: function wrap(e, t, n, o) {
5959 return r.w(a(e), t, n, o && o.reverse());
5960 },
5961 isGeneratorFunction: n,
5962 mark: r.m,
5963 awrap: function awrap(r, e) {
5964 return new OverloadYield(r, e);
5965 },
5966 AsyncIterator: regeneratorAsyncIterator,
5967 async: function async(r, e, t, o, u) {
5968 return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
5969 },
5970 keys: regeneratorKeys,
5971 values: regeneratorValues
5972 };
5973 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5974 }
5975 module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
5976
5977 /***/ }),
5978
5979 /***/ "../node_modules/@babel/runtime/helpers/regeneratorValues.js":
5980 /*!*******************************************************************!*\
5981 !*** ../node_modules/@babel/runtime/helpers/regeneratorValues.js ***!
5982 \*******************************************************************/
5983 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5984
5985 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5986 function _regeneratorValues(e) {
5987 if (null != e) {
5988 var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
5989 r = 0;
5990 if (t) return t.call(e);
5991 if ("function" == typeof e.next) return e;
5992 if (!isNaN(e.length)) return {
5993 next: function next() {
5994 return e && r >= e.length && (e = void 0), {
5995 value: e && e[r++],
5996 done: !e
5997 };
5998 }
5999 };
6000 }
6001 throw new TypeError(_typeof(e) + " is not iterable");
6002 }
6003 module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
6004
6005 /***/ }),
6006
6007 /***/ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js":
6008 /*!****************************************************************!*\
6009 !*** ../node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
6010 \****************************************************************/
6011 /***/ ((module) => {
6012
6013 function _setPrototypeOf(t, e) {
6014 return module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
6015 return t.__proto__ = e, t;
6016 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _setPrototypeOf(t, e);
6017 }
6018 module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6019
6020 /***/ }),
6021
6022 /***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js":
6023 /*!***************************************************************!*\
6024 !*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***!
6025 \***************************************************************/
6026 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6027
6028 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js");
6029 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
6030 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
6031 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "../node_modules/@babel/runtime/helpers/nonIterableRest.js");
6032 function _slicedToArray(r, e) {
6033 return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();
6034 }
6035 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6036
6037 /***/ }),
6038
6039 /***/ "../node_modules/@babel/runtime/helpers/superPropBase.js":
6040 /*!***************************************************************!*\
6041 !*** ../node_modules/@babel/runtime/helpers/superPropBase.js ***!
6042 \***************************************************************/
6043 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6044
6045 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6046 function _superPropBase(t, o) {
6047 for (; !{}.hasOwnProperty.call(t, o) && null !== (t = getPrototypeOf(t)););
6048 return t;
6049 }
6050 module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
6051
6052 /***/ }),
6053
6054 /***/ "../node_modules/@babel/runtime/helpers/toPrimitive.js":
6055 /*!*************************************************************!*\
6056 !*** ../node_modules/@babel/runtime/helpers/toPrimitive.js ***!
6057 \*************************************************************/
6058 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6059
6060 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6061 function toPrimitive(t, r) {
6062 if ("object" != _typeof(t) || !t) return t;
6063 var e = t[Symbol.toPrimitive];
6064 if (void 0 !== e) {
6065 var i = e.call(t, r || "default");
6066 if ("object" != _typeof(i)) return i;
6067 throw new TypeError("@@toPrimitive must return a primitive value.");
6068 }
6069 return ("string" === r ? String : Number)(t);
6070 }
6071 module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
6072
6073 /***/ }),
6074
6075 /***/ "../node_modules/@babel/runtime/helpers/toPropertyKey.js":
6076 /*!***************************************************************!*\
6077 !*** ../node_modules/@babel/runtime/helpers/toPropertyKey.js ***!
6078 \***************************************************************/
6079 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6080
6081 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6082 var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/toPrimitive.js");
6083 function toPropertyKey(t) {
6084 var i = toPrimitive(t, "string");
6085 return "symbol" == _typeof(i) ? i : i + "";
6086 }
6087 module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
6088
6089 /***/ }),
6090
6091 /***/ "../node_modules/@babel/runtime/helpers/typeof.js":
6092 /*!********************************************************!*\
6093 !*** ../node_modules/@babel/runtime/helpers/typeof.js ***!
6094 \********************************************************/
6095 /***/ ((module) => {
6096
6097 function _typeof(o) {
6098 "@babel/helpers - typeof";
6099
6100 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
6101 return typeof o;
6102 } : function (o) {
6103 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
6104 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
6105 }
6106 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
6107
6108 /***/ }),
6109
6110 /***/ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
6111 /*!****************************************************************************!*\
6112 !*** ../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
6113 \****************************************************************************/
6114 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6115
6116 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
6117 function _unsupportedIterableToArray(r, a) {
6118 if (r) {
6119 if ("string" == typeof r) return arrayLikeToArray(r, a);
6120 var t = {}.toString.call(r).slice(8, -1);
6121 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;
6122 }
6123 }
6124 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6125
6126 /***/ }),
6127
6128 /***/ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js":
6129 /*!*****************************************************************!*\
6130 !*** ../node_modules/@babel/runtime/helpers/wrapNativeSuper.js ***!
6131 \*****************************************************************/
6132 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6133
6134 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6135 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6136 var isNativeFunction = __webpack_require__(/*! ./isNativeFunction.js */ "../node_modules/@babel/runtime/helpers/isNativeFunction.js");
6137 var construct = __webpack_require__(/*! ./construct.js */ "../node_modules/@babel/runtime/helpers/construct.js");
6138 function _wrapNativeSuper(t) {
6139 var r = "function" == typeof Map ? new Map() : void 0;
6140 return module.exports = _wrapNativeSuper = function _wrapNativeSuper(t) {
6141 if (null === t || !isNativeFunction(t)) return t;
6142 if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
6143 if (void 0 !== r) {
6144 if (r.has(t)) return r.get(t);
6145 r.set(t, Wrapper);
6146 }
6147 function Wrapper() {
6148 return construct(t, arguments, getPrototypeOf(this).constructor);
6149 }
6150 return Wrapper.prototype = Object.create(t.prototype, {
6151 constructor: {
6152 value: Wrapper,
6153 enumerable: !1,
6154 writable: !0,
6155 configurable: !0
6156 }
6157 }), setPrototypeOf(Wrapper, t);
6158 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _wrapNativeSuper(t);
6159 }
6160 module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
6161
6162 /***/ }),
6163
6164 /***/ "../node_modules/@babel/runtime/regenerator/index.js":
6165 /*!***********************************************************!*\
6166 !*** ../node_modules/@babel/runtime/regenerator/index.js ***!
6167 \***********************************************************/
6168 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6169
6170 // TODO(Babel 8): Remove this file.
6171
6172 var runtime = __webpack_require__(/*! ../helpers/regeneratorRuntime */ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js")();
6173 module.exports = runtime;
6174
6175 // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
6176 try {
6177 regeneratorRuntime = runtime;
6178 } catch (accidentalStrictMode) {
6179 if (typeof globalThis === "object") {
6180 globalThis.regeneratorRuntime = runtime;
6181 } else {
6182 Function("r", "regeneratorRuntime = r")(runtime);
6183 }
6184 }
6185
6186
6187 /***/ }),
6188
6189 /***/ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js":
6190 /*!******************************************************************!*\
6191 !*** ../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js ***!
6192 \******************************************************************/
6193 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6194
6195 "use strict";
6196 __webpack_require__.r(__webpack_exports__);
6197 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6198 /* harmony export */ EnhancerArray: () => (/* binding */ EnhancerArray),
6199 /* harmony export */ MiddlewareArray: () => (/* binding */ MiddlewareArray),
6200 /* harmony export */ SHOULD_AUTOBATCH: () => (/* binding */ SHOULD_AUTOBATCH),
6201 /* harmony export */ TaskAbortError: () => (/* binding */ TaskAbortError),
6202 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.__DO_NOT_USE__ActionTypes),
6203 /* harmony export */ addListener: () => (/* binding */ addListener),
6204 /* harmony export */ applyMiddleware: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware),
6205 /* harmony export */ autoBatchEnhancer: () => (/* binding */ autoBatchEnhancer),
6206 /* harmony export */ bindActionCreators: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.bindActionCreators),
6207 /* harmony export */ clearAllListeners: () => (/* binding */ clearAllListeners),
6208 /* harmony export */ combineReducers: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers),
6209 /* harmony export */ compose: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.compose),
6210 /* harmony export */ configureStore: () => (/* binding */ configureStore),
6211 /* harmony export */ createAction: () => (/* binding */ createAction),
6212 /* harmony export */ createActionCreatorInvariantMiddleware: () => (/* binding */ createActionCreatorInvariantMiddleware),
6213 /* harmony export */ createAsyncThunk: () => (/* binding */ createAsyncThunk),
6214 /* harmony export */ createDraftSafeSelector: () => (/* binding */ createDraftSafeSelector),
6215 /* harmony export */ createEntityAdapter: () => (/* binding */ createEntityAdapter),
6216 /* harmony export */ createImmutableStateInvariantMiddleware: () => (/* binding */ createImmutableStateInvariantMiddleware),
6217 /* harmony export */ createListenerMiddleware: () => (/* binding */ createListenerMiddleware),
6218 /* harmony export */ createNextState: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__["default"]),
6219 /* harmony export */ createReducer: () => (/* binding */ createReducer),
6220 /* harmony export */ createSelector: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector),
6221 /* harmony export */ createSerializableStateInvariantMiddleware: () => (/* binding */ createSerializableStateInvariantMiddleware),
6222 /* harmony export */ createSlice: () => (/* binding */ createSlice),
6223 /* harmony export */ createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.createStore),
6224 /* harmony export */ current: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.current),
6225 /* harmony export */ findNonSerializableValue: () => (/* binding */ findNonSerializableValue),
6226 /* harmony export */ freeze: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.freeze),
6227 /* harmony export */ getDefaultMiddleware: () => (/* binding */ getDefaultMiddleware),
6228 /* harmony export */ getType: () => (/* binding */ getType),
6229 /* harmony export */ isAction: () => (/* binding */ isAction),
6230 /* harmony export */ isActionCreator: () => (/* binding */ isActionCreator),
6231 /* harmony export */ isAllOf: () => (/* binding */ isAllOf),
6232 /* harmony export */ isAnyOf: () => (/* binding */ isAnyOf),
6233 /* harmony export */ isAsyncThunkAction: () => (/* binding */ isAsyncThunkAction),
6234 /* harmony export */ isDraft: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.isDraft),
6235 /* harmony export */ isFluxStandardAction: () => (/* binding */ isFSA),
6236 /* harmony export */ isFulfilled: () => (/* binding */ isFulfilled),
6237 /* harmony export */ isImmutableDefault: () => (/* binding */ isImmutableDefault),
6238 /* harmony export */ isPending: () => (/* binding */ isPending),
6239 /* harmony export */ isPlain: () => (/* binding */ isPlain),
6240 /* harmony export */ isPlainObject: () => (/* binding */ isPlainObject),
6241 /* harmony export */ isRejected: () => (/* binding */ isRejected),
6242 /* harmony export */ isRejectedWithValue: () => (/* binding */ isRejectedWithValue),
6243 /* harmony export */ legacy_createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.legacy_createStore),
6244 /* harmony export */ miniSerializeError: () => (/* binding */ miniSerializeError),
6245 /* harmony export */ nanoid: () => (/* binding */ nanoid),
6246 /* harmony export */ original: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.original),
6247 /* harmony export */ prepareAutoBatched: () => (/* binding */ prepareAutoBatched),
6248 /* harmony export */ removeListener: () => (/* binding */ removeListener),
6249 /* harmony export */ unwrapResult: () => (/* binding */ unwrapResult)
6250 /* harmony export */ });
6251 /* harmony import */ var immer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! immer */ "../node_modules/immer/dist/immer.esm.mjs");
6252 /* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! redux */ "../node_modules/redux/es/redux.js");
6253 /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! reselect */ "../node_modules/reselect/es/index.js");
6254 /* harmony import */ var redux_thunk__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! redux-thunk */ "../node_modules/redux-thunk/es/index.js");
6255 var __extends = (undefined && undefined.__extends) || (function () {
6256 var extendStatics = function (d, b) {
6257 extendStatics = Object.setPrototypeOf ||
6258 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6259 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6260 return extendStatics(d, b);
6261 };
6262 return function (d, b) {
6263 if (typeof b !== "function" && b !== null)
6264 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
6265 extendStatics(d, b);
6266 function __() { this.constructor = d; }
6267 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6268 };
6269 })();
6270 var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
6271 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6272 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6273 function verb(n) { return function (v) { return step([n, v]); }; }
6274 function step(op) {
6275 if (f) throw new TypeError("Generator is already executing.");
6276 while (_) try {
6277 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;
6278 if (y = 0, t) op = [op[0] & 2, t.value];
6279 switch (op[0]) {
6280 case 0: case 1: t = op; break;
6281 case 4: _.label++; return { value: op[1], done: false };
6282 case 5: _.label++; y = op[1]; op = [0]; continue;
6283 case 7: op = _.ops.pop(); _.trys.pop(); continue;
6284 default:
6285 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6286 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6287 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6288 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6289 if (t[2]) _.ops.pop();
6290 _.trys.pop(); continue;
6291 }
6292 op = body.call(thisArg, _);
6293 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6294 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6295 }
6296 };
6297 var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
6298 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
6299 to[j] = from[i];
6300 return to;
6301 };
6302 var __defProp = Object.defineProperty;
6303 var __defProps = Object.defineProperties;
6304 var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6305 var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6306 var __hasOwnProp = Object.prototype.hasOwnProperty;
6307 var __propIsEnum = Object.prototype.propertyIsEnumerable;
6308 var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
6309 var __spreadValues = function (a, b) {
6310 for (var prop in b || (b = {}))
6311 if (__hasOwnProp.call(b, prop))
6312 __defNormalProp(a, prop, b[prop]);
6313 if (__getOwnPropSymbols)
6314 for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
6315 var prop = _c[_i];
6316 if (__propIsEnum.call(b, prop))
6317 __defNormalProp(a, prop, b[prop]);
6318 }
6319 return a;
6320 };
6321 var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
6322 var __async = function (__this, __arguments, generator) {
6323 return new Promise(function (resolve, reject) {
6324 var fulfilled = function (value) {
6325 try {
6326 step(generator.next(value));
6327 }
6328 catch (e) {
6329 reject(e);
6330 }
6331 };
6332 var rejected = function (value) {
6333 try {
6334 step(generator.throw(value));
6335 }
6336 catch (e) {
6337 reject(e);
6338 }
6339 };
6340 var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
6341 step((generator = generator.apply(__this, __arguments)).next());
6342 });
6343 };
6344 // src/index.ts
6345
6346
6347
6348
6349 // src/createDraftSafeSelector.ts
6350
6351
6352 var createDraftSafeSelector = function () {
6353 var args = [];
6354 for (var _i = 0; _i < arguments.length; _i++) {
6355 args[_i] = arguments[_i];
6356 }
6357 var selector = reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector.apply(void 0, args);
6358 var wrappedSelector = function (value) {
6359 var rest = [];
6360 for (var _i = 1; _i < arguments.length; _i++) {
6361 rest[_i - 1] = arguments[_i];
6362 }
6363 return selector.apply(void 0, __spreadArray([(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(value) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__.current)(value) : value], rest));
6364 };
6365 return wrappedSelector;
6366 };
6367 // src/configureStore.ts
6368
6369 // src/devtoolsExtension.ts
6370
6371 var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
6372 if (arguments.length === 0)
6373 return void 0;
6374 if (typeof arguments[0] === "object")
6375 return redux__WEBPACK_IMPORTED_MODULE_1__.compose;
6376 return redux__WEBPACK_IMPORTED_MODULE_1__.compose.apply(null, arguments);
6377 };
6378 var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function () {
6379 return function (noop2) {
6380 return noop2;
6381 };
6382 };
6383 // src/isPlainObject.ts
6384 function isPlainObject(value) {
6385 if (typeof value !== "object" || value === null)
6386 return false;
6387 var proto = Object.getPrototypeOf(value);
6388 if (proto === null)
6389 return true;
6390 var baseProto = proto;
6391 while (Object.getPrototypeOf(baseProto) !== null) {
6392 baseProto = Object.getPrototypeOf(baseProto);
6393 }
6394 return proto === baseProto;
6395 }
6396 // src/getDefaultMiddleware.ts
6397
6398 // src/tsHelpers.ts
6399 var hasMatchFunction = function (v) {
6400 return v && typeof v.match === "function";
6401 };
6402 // src/createAction.ts
6403 function createAction(type, prepareAction) {
6404 function actionCreator() {
6405 var args = [];
6406 for (var _i = 0; _i < arguments.length; _i++) {
6407 args[_i] = arguments[_i];
6408 }
6409 if (prepareAction) {
6410 var prepared = prepareAction.apply(void 0, args);
6411 if (!prepared) {
6412 throw new Error("prepareAction did not return an object");
6413 }
6414 return __spreadValues(__spreadValues({
6415 type: type,
6416 payload: prepared.payload
6417 }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
6418 }
6419 return { type: type, payload: args[0] };
6420 }
6421 actionCreator.toString = function () { return "" + type; };
6422 actionCreator.type = type;
6423 actionCreator.match = function (action) { return action.type === type; };
6424 return actionCreator;
6425 }
6426 function isAction(action) {
6427 return isPlainObject(action) && "type" in action;
6428 }
6429 function isActionCreator(action) {
6430 return typeof action === "function" && "type" in action && hasMatchFunction(action);
6431 }
6432 function isFSA(action) {
6433 return isAction(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
6434 }
6435 function isValidKey(key) {
6436 return ["type", "payload", "error", "meta"].indexOf(key) > -1;
6437 }
6438 function getType(actionCreator) {
6439 return "" + actionCreator;
6440 }
6441 // src/actionCreatorInvariantMiddleware.ts
6442 function getMessage(type) {
6443 var splitType = type ? ("" + type).split("/") : [];
6444 var actionName = splitType[splitType.length - 1] || "actionCreator";
6445 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.";
6446 }
6447 function createActionCreatorInvariantMiddleware(options) {
6448 if (options === void 0) { options = {}; }
6449 if (false) // removed by dead control flow
6450 {}
6451 var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
6452 return function () { return function (next) { return function (action) {
6453 if (isActionCreator2(action)) {
6454 console.warn(getMessage(action.type));
6455 }
6456 return next(action);
6457 }; }; };
6458 }
6459 // src/utils.ts
6460
6461 function getTimeMeasureUtils(maxDelay, fnName) {
6462 var elapsed = 0;
6463 return {
6464 measureTime: function (fn) {
6465 var started = Date.now();
6466 try {
6467 return fn();
6468 }
6469 finally {
6470 var finished = Date.now();
6471 elapsed += finished - started;
6472 }
6473 },
6474 warnIfExceeded: function () {
6475 if (elapsed > maxDelay) {
6476 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.");
6477 }
6478 }
6479 };
6480 }
6481 var MiddlewareArray = /** @class */ (function (_super) {
6482 __extends(MiddlewareArray, _super);
6483 function MiddlewareArray() {
6484 var args = [];
6485 for (var _i = 0; _i < arguments.length; _i++) {
6486 args[_i] = arguments[_i];
6487 }
6488 var _this = _super.apply(this, args) || this;
6489 Object.setPrototypeOf(_this, MiddlewareArray.prototype);
6490 return _this;
6491 }
6492 Object.defineProperty(MiddlewareArray, Symbol.species, {
6493 get: function () {
6494 return MiddlewareArray;
6495 },
6496 enumerable: false,
6497 configurable: true
6498 });
6499 MiddlewareArray.prototype.concat = function () {
6500 var arr = [];
6501 for (var _i = 0; _i < arguments.length; _i++) {
6502 arr[_i] = arguments[_i];
6503 }
6504 return _super.prototype.concat.apply(this, arr);
6505 };
6506 MiddlewareArray.prototype.prepend = function () {
6507 var arr = [];
6508 for (var _i = 0; _i < arguments.length; _i++) {
6509 arr[_i] = arguments[_i];
6510 }
6511 if (arr.length === 1 && Array.isArray(arr[0])) {
6512 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
6513 }
6514 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
6515 };
6516 return MiddlewareArray;
6517 }(Array));
6518 var EnhancerArray = /** @class */ (function (_super) {
6519 __extends(EnhancerArray, _super);
6520 function EnhancerArray() {
6521 var args = [];
6522 for (var _i = 0; _i < arguments.length; _i++) {
6523 args[_i] = arguments[_i];
6524 }
6525 var _this = _super.apply(this, args) || this;
6526 Object.setPrototypeOf(_this, EnhancerArray.prototype);
6527 return _this;
6528 }
6529 Object.defineProperty(EnhancerArray, Symbol.species, {
6530 get: function () {
6531 return EnhancerArray;
6532 },
6533 enumerable: false,
6534 configurable: true
6535 });
6536 EnhancerArray.prototype.concat = function () {
6537 var arr = [];
6538 for (var _i = 0; _i < arguments.length; _i++) {
6539 arr[_i] = arguments[_i];
6540 }
6541 return _super.prototype.concat.apply(this, arr);
6542 };
6543 EnhancerArray.prototype.prepend = function () {
6544 var arr = [];
6545 for (var _i = 0; _i < arguments.length; _i++) {
6546 arr[_i] = arguments[_i];
6547 }
6548 if (arr.length === 1 && Array.isArray(arr[0])) {
6549 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
6550 }
6551 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
6552 };
6553 return EnhancerArray;
6554 }(Array));
6555 function freezeDraftable(val) {
6556 return (0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(val) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(val, function () {
6557 }) : val;
6558 }
6559 // src/immutableStateInvariantMiddleware.ts
6560 var isProduction = "development" === "production";
6561 var prefix = "Invariant failed";
6562 function invariant(condition, message) {
6563 if (condition) {
6564 return;
6565 }
6566 if (isProduction) {
6567 throw new Error(prefix);
6568 }
6569 throw new Error(prefix + ": " + (message || ""));
6570 }
6571 function stringify(obj, serializer, indent, decycler) {
6572 return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
6573 }
6574 function getSerialize(serializer, decycler) {
6575 var stack = [], keys = [];
6576 if (!decycler)
6577 decycler = function (_, value) {
6578 if (stack[0] === value)
6579 return "[Circular ~]";
6580 return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
6581 };
6582 return function (key, value) {
6583 if (stack.length > 0) {
6584 var thisPos = stack.indexOf(this);
6585 ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
6586 ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
6587 if (~stack.indexOf(value))
6588 value = decycler.call(this, key, value);
6589 }
6590 else
6591 stack.push(value);
6592 return serializer == null ? value : serializer.call(this, key, value);
6593 };
6594 }
6595 function isImmutableDefault(value) {
6596 return typeof value !== "object" || value == null || Object.isFrozen(value);
6597 }
6598 function trackForMutations(isImmutable, ignorePaths, obj) {
6599 var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
6600 return {
6601 detectMutations: function () {
6602 return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
6603 }
6604 };
6605 }
6606 function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
6607 if (ignorePaths === void 0) { ignorePaths = []; }
6608 if (path === void 0) { path = ""; }
6609 if (checkedObjects === void 0) { checkedObjects = new Set(); }
6610 var tracked = { value: obj };
6611 if (!isImmutable(obj) && !checkedObjects.has(obj)) {
6612 checkedObjects.add(obj);
6613 tracked.children = {};
6614 for (var key in obj) {
6615 var childPath = path ? path + "." + key : key;
6616 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
6617 continue;
6618 }
6619 tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
6620 }
6621 }
6622 return tracked;
6623 }
6624 function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
6625 if (ignoredPaths === void 0) { ignoredPaths = []; }
6626 if (sameParentRef === void 0) { sameParentRef = false; }
6627 if (path === void 0) { path = ""; }
6628 var prevObj = trackedProperty ? trackedProperty.value : void 0;
6629 var sameRef = prevObj === obj;
6630 if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
6631 return { wasMutated: true, path: path };
6632 }
6633 if (isImmutable(prevObj) || isImmutable(obj)) {
6634 return { wasMutated: false };
6635 }
6636 var keysToDetect = {};
6637 for (var key in trackedProperty.children) {
6638 keysToDetect[key] = true;
6639 }
6640 for (var key in obj) {
6641 keysToDetect[key] = true;
6642 }
6643 var hasIgnoredPaths = ignoredPaths.length > 0;
6644 var _loop_1 = function (key) {
6645 var nestedPath = path ? path + "." + key : key;
6646 if (hasIgnoredPaths) {
6647 var hasMatches = ignoredPaths.some(function (ignored) {
6648 if (ignored instanceof RegExp) {
6649 return ignored.test(nestedPath);
6650 }
6651 return nestedPath === ignored;
6652 });
6653 if (hasMatches) {
6654 return "continue";
6655 }
6656 }
6657 var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
6658 if (result.wasMutated) {
6659 return { value: result };
6660 }
6661 };
6662 for (var key in keysToDetect) {
6663 var state_1 = _loop_1(key);
6664 if (typeof state_1 === "object")
6665 return state_1.value;
6666 }
6667 return { wasMutated: false };
6668 }
6669 function createImmutableStateInvariantMiddleware(options) {
6670 if (options === void 0) { options = {}; }
6671 if (false) // removed by dead control flow
6672 {}
6673 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;
6674 ignoredPaths = ignoredPaths || ignore;
6675 var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
6676 return function (_c) {
6677 var getState = _c.getState;
6678 var state = getState();
6679 var tracker = track(state);
6680 var result;
6681 return function (next) { return function (action) {
6682 var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
6683 measureUtils.measureTime(function () {
6684 state = getState();
6685 result = tracker.detectMutations();
6686 tracker = track(state);
6687 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)");
6688 });
6689 var dispatchedAction = next(action);
6690 measureUtils.measureTime(function () {
6691 state = getState();
6692 result = tracker.detectMutations();
6693 tracker = track(state);
6694 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)");
6695 });
6696 measureUtils.warnIfExceeded();
6697 return dispatchedAction;
6698 }; };
6699 };
6700 }
6701 // src/serializableStateInvariantMiddleware.ts
6702 function isPlain(val) {
6703 var type = typeof val;
6704 return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
6705 }
6706 function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
6707 if (path === void 0) { path = ""; }
6708 if (isSerializable === void 0) { isSerializable = isPlain; }
6709 if (ignoredPaths === void 0) { ignoredPaths = []; }
6710 var foundNestedSerializable;
6711 if (!isSerializable(value)) {
6712 return {
6713 keyPath: path || "<root>",
6714 value: value
6715 };
6716 }
6717 if (typeof value !== "object" || value === null) {
6718 return false;
6719 }
6720 if (cache == null ? void 0 : cache.has(value))
6721 return false;
6722 var entries = getEntries != null ? getEntries(value) : Object.entries(value);
6723 var hasIgnoredPaths = ignoredPaths.length > 0;
6724 var _loop_2 = function (key, nestedValue) {
6725 var nestedPath = path ? path + "." + key : key;
6726 if (hasIgnoredPaths) {
6727 var hasMatches = ignoredPaths.some(function (ignored) {
6728 if (ignored instanceof RegExp) {
6729 return ignored.test(nestedPath);
6730 }
6731 return nestedPath === ignored;
6732 });
6733 if (hasMatches) {
6734 return "continue";
6735 }
6736 }
6737 if (!isSerializable(nestedValue)) {
6738 return { value: {
6739 keyPath: nestedPath,
6740 value: nestedValue
6741 } };
6742 }
6743 if (typeof nestedValue === "object") {
6744 foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
6745 if (foundNestedSerializable) {
6746 return { value: foundNestedSerializable };
6747 }
6748 }
6749 };
6750 for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
6751 var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
6752 var state_2 = _loop_2(key, nestedValue);
6753 if (typeof state_2 === "object")
6754 return state_2.value;
6755 }
6756 if (cache && isNestedFrozen(value))
6757 cache.add(value);
6758 return false;
6759 }
6760 function isNestedFrozen(value) {
6761 if (!Object.isFrozen(value))
6762 return false;
6763 for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
6764 var nestedValue = _c[_i];
6765 if (typeof nestedValue !== "object" || nestedValue === null)
6766 continue;
6767 if (!isNestedFrozen(nestedValue))
6768 return false;
6769 }
6770 return true;
6771 }
6772 function createSerializableStateInvariantMiddleware(options) {
6773 if (options === void 0) { options = {}; }
6774 if (false) // removed by dead control flow
6775 {}
6776 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;
6777 var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
6778 return function (storeAPI) { return function (next) { return function (action) {
6779 var result = next(action);
6780 var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
6781 if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
6782 measureUtils.measureTime(function () {
6783 var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
6784 if (foundActionNonSerializableValue) {
6785 var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
6786 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)");
6787 }
6788 });
6789 }
6790 if (!ignoreState) {
6791 measureUtils.measureTime(function () {
6792 var state = storeAPI.getState();
6793 var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
6794 if (foundStateNonSerializableValue) {
6795 var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
6796 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)");
6797 }
6798 });
6799 measureUtils.warnIfExceeded();
6800 }
6801 return result;
6802 }; }; };
6803 }
6804 // src/getDefaultMiddleware.ts
6805 function isBoolean(x) {
6806 return typeof x === "boolean";
6807 }
6808 function curryGetDefaultMiddleware() {
6809 return function curriedGetDefaultMiddleware(options) {
6810 return getDefaultMiddleware(options);
6811 };
6812 }
6813 function getDefaultMiddleware(options) {
6814 if (options === void 0) { options = {}; }
6815 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;
6816 var middlewareArray = new MiddlewareArray();
6817 if (thunk) {
6818 if (isBoolean(thunk)) {
6819 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"]);
6820 }
6821 else {
6822 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"].withExtraArgument(thunk.extraArgument));
6823 }
6824 }
6825 if (true) {
6826 if (immutableCheck) {
6827 var immutableOptions = {};
6828 if (!isBoolean(immutableCheck)) {
6829 immutableOptions = immutableCheck;
6830 }
6831 middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
6832 }
6833 if (serializableCheck) {
6834 var serializableOptions = {};
6835 if (!isBoolean(serializableCheck)) {
6836 serializableOptions = serializableCheck;
6837 }
6838 middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
6839 }
6840 if (actionCreatorCheck) {
6841 var actionCreatorOptions = {};
6842 if (!isBoolean(actionCreatorCheck)) {
6843 actionCreatorOptions = actionCreatorCheck;
6844 }
6845 middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
6846 }
6847 }
6848 return middlewareArray;
6849 }
6850 // src/configureStore.ts
6851 var IS_PRODUCTION = "development" === "production";
6852 function configureStore(options) {
6853 var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
6854 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;
6855 var rootReducer;
6856 if (typeof reducer === "function") {
6857 rootReducer = reducer;
6858 }
6859 else if (isPlainObject(reducer)) {
6860 rootReducer = (0,redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers)(reducer);
6861 }
6862 else {
6863 throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
6864 }
6865 var finalMiddleware = middleware;
6866 if (typeof finalMiddleware === "function") {
6867 finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
6868 if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
6869 throw new Error("when using a middleware builder function, an array of middleware must be returned");
6870 }
6871 }
6872 if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
6873 throw new Error("each middleware provided to configureStore must be a function");
6874 }
6875 var middlewareEnhancer = redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware.apply(void 0, finalMiddleware);
6876 var finalCompose = redux__WEBPACK_IMPORTED_MODULE_1__.compose;
6877 if (devTools) {
6878 finalCompose = composeWithDevTools(__spreadValues({
6879 trace: !IS_PRODUCTION
6880 }, typeof devTools === "object" && devTools));
6881 }
6882 var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
6883 var storeEnhancers = defaultEnhancers;
6884 if (Array.isArray(enhancers)) {
6885 storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
6886 }
6887 else if (typeof enhancers === "function") {
6888 storeEnhancers = enhancers(defaultEnhancers);
6889 }
6890 var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
6891 return (0,redux__WEBPACK_IMPORTED_MODULE_1__.createStore)(rootReducer, preloadedState, composedEnhancer);
6892 }
6893 // src/createReducer.ts
6894
6895 // src/mapBuilders.ts
6896 function executeReducerBuilderCallback(builderCallback) {
6897 var actionsMap = {};
6898 var actionMatchers = [];
6899 var defaultCaseReducer;
6900 var builder = {
6901 addCase: function (typeOrActionCreator, reducer) {
6902 if (true) {
6903 if (actionMatchers.length > 0) {
6904 throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
6905 }
6906 if (defaultCaseReducer) {
6907 throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
6908 }
6909 }
6910 var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
6911 if (!type) {
6912 throw new Error("`builder.addCase` cannot be called with an empty action type");
6913 }
6914 if (type in actionsMap) {
6915 throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");
6916 }
6917 actionsMap[type] = reducer;
6918 return builder;
6919 },
6920 addMatcher: function (matcher, reducer) {
6921 if (true) {
6922 if (defaultCaseReducer) {
6923 throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
6924 }
6925 }
6926 actionMatchers.push({ matcher: matcher, reducer: reducer });
6927 return builder;
6928 },
6929 addDefaultCase: function (reducer) {
6930 if (true) {
6931 if (defaultCaseReducer) {
6932 throw new Error("`builder.addDefaultCase` can only be called once");
6933 }
6934 }
6935 defaultCaseReducer = reducer;
6936 return builder;
6937 }
6938 };
6939 builderCallback(builder);
6940 return [actionsMap, actionMatchers, defaultCaseReducer];
6941 }
6942 // src/createReducer.ts
6943 function isStateFunction(x) {
6944 return typeof x === "function";
6945 }
6946 var hasWarnedAboutObjectNotation = false;
6947 function createReducer(initialState, mapOrBuilderCallback, actionMatchers, defaultCaseReducer) {
6948 if (actionMatchers === void 0) { actionMatchers = []; }
6949 if (true) {
6950 if (typeof mapOrBuilderCallback === "object") {
6951 if (!hasWarnedAboutObjectNotation) {
6952 hasWarnedAboutObjectNotation = true;
6953 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");
6954 }
6955 }
6956 }
6957 var _c = typeof mapOrBuilderCallback === "function" ? executeReducerBuilderCallback(mapOrBuilderCallback) : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer], actionsMap = _c[0], finalActionMatchers = _c[1], finalDefaultCaseReducer = _c[2];
6958 var getInitialState;
6959 if (isStateFunction(initialState)) {
6960 getInitialState = function () { return freezeDraftable(initialState()); };
6961 }
6962 else {
6963 var frozenInitialState_1 = freezeDraftable(initialState);
6964 getInitialState = function () { return frozenInitialState_1; };
6965 }
6966 function reducer(state, action) {
6967 if (state === void 0) { state = getInitialState(); }
6968 var caseReducers = __spreadArray([
6969 actionsMap[action.type]
6970 ], finalActionMatchers.filter(function (_c) {
6971 var matcher = _c.matcher;
6972 return matcher(action);
6973 }).map(function (_c) {
6974 var reducer2 = _c.reducer;
6975 return reducer2;
6976 }));
6977 if (caseReducers.filter(function (cr) { return !!cr; }).length === 0) {
6978 caseReducers = [finalDefaultCaseReducer];
6979 }
6980 return caseReducers.reduce(function (previousState, caseReducer) {
6981 if (caseReducer) {
6982 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(previousState)) {
6983 var draft = previousState;
6984 var result = caseReducer(draft, action);
6985 if (result === void 0) {
6986 return previousState;
6987 }
6988 return result;
6989 }
6990 else if (!(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(previousState)) {
6991 var result = caseReducer(previousState, action);
6992 if (result === void 0) {
6993 if (previousState === null) {
6994 return previousState;
6995 }
6996 throw Error("A case reducer on a non-draftable value must not return undefined");
6997 }
6998 return result;
6999 }
7000 else {
7001 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(previousState, function (draft) {
7002 return caseReducer(draft, action);
7003 });
7004 }
7005 }
7006 return previousState;
7007 }, state);
7008 }
7009 reducer.getInitialState = getInitialState;
7010 return reducer;
7011 }
7012 // src/createSlice.ts
7013 var hasWarnedAboutObjectNotation2 = false;
7014 function getType2(slice, actionKey) {
7015 return slice + "/" + actionKey;
7016 }
7017 function createSlice(options) {
7018 var name = options.name;
7019 if (!name) {
7020 throw new Error("`name` is a required option for createSlice");
7021 }
7022 if (typeof process !== "undefined" && "development" === "development") {
7023 if (options.initialState === void 0) {
7024 console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
7025 }
7026 }
7027 var initialState = typeof options.initialState == "function" ? options.initialState : freezeDraftable(options.initialState);
7028 var reducers = options.reducers || {};
7029 var reducerNames = Object.keys(reducers);
7030 var sliceCaseReducersByName = {};
7031 var sliceCaseReducersByType = {};
7032 var actionCreators = {};
7033 reducerNames.forEach(function (reducerName) {
7034 var maybeReducerWithPrepare = reducers[reducerName];
7035 var type = getType2(name, reducerName);
7036 var caseReducer;
7037 var prepareCallback;
7038 if ("reducer" in maybeReducerWithPrepare) {
7039 caseReducer = maybeReducerWithPrepare.reducer;
7040 prepareCallback = maybeReducerWithPrepare.prepare;
7041 }
7042 else {
7043 caseReducer = maybeReducerWithPrepare;
7044 }
7045 sliceCaseReducersByName[reducerName] = caseReducer;
7046 sliceCaseReducersByType[type] = caseReducer;
7047 actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type);
7048 });
7049 function buildReducer() {
7050 if (true) {
7051 if (typeof options.extraReducers === "object") {
7052 if (!hasWarnedAboutObjectNotation2) {
7053 hasWarnedAboutObjectNotation2 = true;
7054 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");
7055 }
7056 }
7057 }
7058 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;
7059 var finalCaseReducers = __spreadValues(__spreadValues({}, extraReducers), sliceCaseReducersByType);
7060 return createReducer(initialState, function (builder) {
7061 for (var key in finalCaseReducers) {
7062 builder.addCase(key, finalCaseReducers[key]);
7063 }
7064 for (var _i = 0, actionMatchers_1 = actionMatchers; _i < actionMatchers_1.length; _i++) {
7065 var m = actionMatchers_1[_i];
7066 builder.addMatcher(m.matcher, m.reducer);
7067 }
7068 if (defaultCaseReducer) {
7069 builder.addDefaultCase(defaultCaseReducer);
7070 }
7071 });
7072 }
7073 var _reducer;
7074 return {
7075 name: name,
7076 reducer: function (state, action) {
7077 if (!_reducer)
7078 _reducer = buildReducer();
7079 return _reducer(state, action);
7080 },
7081 actions: actionCreators,
7082 caseReducers: sliceCaseReducersByName,
7083 getInitialState: function () {
7084 if (!_reducer)
7085 _reducer = buildReducer();
7086 return _reducer.getInitialState();
7087 }
7088 };
7089 }
7090 // src/entities/entity_state.ts
7091 function getInitialEntityState() {
7092 return {
7093 ids: [],
7094 entities: {}
7095 };
7096 }
7097 function createInitialStateFactory() {
7098 function getInitialState(additionalState) {
7099 if (additionalState === void 0) { additionalState = {}; }
7100 return Object.assign(getInitialEntityState(), additionalState);
7101 }
7102 return { getInitialState: getInitialState };
7103 }
7104 // src/entities/state_selectors.ts
7105 function createSelectorsFactory() {
7106 function getSelectors(selectState) {
7107 var selectIds = function (state) { return state.ids; };
7108 var selectEntities = function (state) { return state.entities; };
7109 var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) { return ids.map(function (id) { return entities[id]; }); });
7110 var selectId = function (_, id) { return id; };
7111 var selectById = function (entities, id) { return entities[id]; };
7112 var selectTotal = createDraftSafeSelector(selectIds, function (ids) { return ids.length; });
7113 if (!selectState) {
7114 return {
7115 selectIds: selectIds,
7116 selectEntities: selectEntities,
7117 selectAll: selectAll,
7118 selectTotal: selectTotal,
7119 selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
7120 };
7121 }
7122 var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
7123 return {
7124 selectIds: createDraftSafeSelector(selectState, selectIds),
7125 selectEntities: selectGlobalizedEntities,
7126 selectAll: createDraftSafeSelector(selectState, selectAll),
7127 selectTotal: createDraftSafeSelector(selectState, selectTotal),
7128 selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
7129 };
7130 }
7131 return { getSelectors: getSelectors };
7132 }
7133 // src/entities/state_adapter.ts
7134
7135 function createSingleArgumentStateOperator(mutator) {
7136 var operator = createStateOperator(function (_, state) { return mutator(state); });
7137 return function operation(state) {
7138 return operator(state, void 0);
7139 };
7140 }
7141 function createStateOperator(mutator) {
7142 return function operation(state, arg) {
7143 function isPayloadActionArgument(arg2) {
7144 return isFSA(arg2);
7145 }
7146 var runMutator = function (draft) {
7147 if (isPayloadActionArgument(arg)) {
7148 mutator(arg.payload, draft);
7149 }
7150 else {
7151 mutator(arg, draft);
7152 }
7153 };
7154 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(state)) {
7155 runMutator(state);
7156 return state;
7157 }
7158 else {
7159 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(state, runMutator);
7160 }
7161 };
7162 }
7163 // src/entities/utils.ts
7164 function selectIdValue(entity, selectId) {
7165 var key = selectId(entity);
7166 if ( true && key === void 0) {
7167 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());
7168 }
7169 return key;
7170 }
7171 function ensureEntitiesArray(entities) {
7172 if (!Array.isArray(entities)) {
7173 entities = Object.values(entities);
7174 }
7175 return entities;
7176 }
7177 function splitAddedUpdatedEntities(newEntities, selectId, state) {
7178 newEntities = ensureEntitiesArray(newEntities);
7179 var added = [];
7180 var updated = [];
7181 for (var _i = 0, newEntities_1 = newEntities; _i < newEntities_1.length; _i++) {
7182 var entity = newEntities_1[_i];
7183 var id = selectIdValue(entity, selectId);
7184 if (id in state.entities) {
7185 updated.push({ id: id, changes: entity });
7186 }
7187 else {
7188 added.push(entity);
7189 }
7190 }
7191 return [added, updated];
7192 }
7193 // src/entities/unsorted_state_adapter.ts
7194 function createUnsortedStateAdapter(selectId) {
7195 function addOneMutably(entity, state) {
7196 var key = selectIdValue(entity, selectId);
7197 if (key in state.entities) {
7198 return;
7199 }
7200 state.ids.push(key);
7201 state.entities[key] = entity;
7202 }
7203 function addManyMutably(newEntities, state) {
7204 newEntities = ensureEntitiesArray(newEntities);
7205 for (var _i = 0, newEntities_2 = newEntities; _i < newEntities_2.length; _i++) {
7206 var entity = newEntities_2[_i];
7207 addOneMutably(entity, state);
7208 }
7209 }
7210 function setOneMutably(entity, state) {
7211 var key = selectIdValue(entity, selectId);
7212 if (!(key in state.entities)) {
7213 state.ids.push(key);
7214 }
7215 state.entities[key] = entity;
7216 }
7217 function setManyMutably(newEntities, state) {
7218 newEntities = ensureEntitiesArray(newEntities);
7219 for (var _i = 0, newEntities_3 = newEntities; _i < newEntities_3.length; _i++) {
7220 var entity = newEntities_3[_i];
7221 setOneMutably(entity, state);
7222 }
7223 }
7224 function setAllMutably(newEntities, state) {
7225 newEntities = ensureEntitiesArray(newEntities);
7226 state.ids = [];
7227 state.entities = {};
7228 addManyMutably(newEntities, state);
7229 }
7230 function removeOneMutably(key, state) {
7231 return removeManyMutably([key], state);
7232 }
7233 function removeManyMutably(keys, state) {
7234 var didMutate = false;
7235 keys.forEach(function (key) {
7236 if (key in state.entities) {
7237 delete state.entities[key];
7238 didMutate = true;
7239 }
7240 });
7241 if (didMutate) {
7242 state.ids = state.ids.filter(function (id) { return id in state.entities; });
7243 }
7244 }
7245 function removeAllMutably(state) {
7246 Object.assign(state, {
7247 ids: [],
7248 entities: {}
7249 });
7250 }
7251 function takeNewKey(keys, update, state) {
7252 var original2 = state.entities[update.id];
7253 var updated = Object.assign({}, original2, update.changes);
7254 var newKey = selectIdValue(updated, selectId);
7255 var hasNewKey = newKey !== update.id;
7256 if (hasNewKey) {
7257 keys[update.id] = newKey;
7258 delete state.entities[update.id];
7259 }
7260 state.entities[newKey] = updated;
7261 return hasNewKey;
7262 }
7263 function updateOneMutably(update, state) {
7264 return updateManyMutably([update], state);
7265 }
7266 function updateManyMutably(updates, state) {
7267 var newKeys = {};
7268 var updatesPerEntity = {};
7269 updates.forEach(function (update) {
7270 if (update.id in state.entities) {
7271 updatesPerEntity[update.id] = {
7272 id: update.id,
7273 changes: __spreadValues(__spreadValues({}, updatesPerEntity[update.id] ? updatesPerEntity[update.id].changes : null), update.changes)
7274 };
7275 }
7276 });
7277 updates = Object.values(updatesPerEntity);
7278 var didMutateEntities = updates.length > 0;
7279 if (didMutateEntities) {
7280 var didMutateIds = updates.filter(function (update) { return takeNewKey(newKeys, update, state); }).length > 0;
7281 if (didMutateIds) {
7282 state.ids = Object.keys(state.entities);
7283 }
7284 }
7285 }
7286 function upsertOneMutably(entity, state) {
7287 return upsertManyMutably([entity], state);
7288 }
7289 function upsertManyMutably(newEntities, state) {
7290 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7291 updateManyMutably(updated, state);
7292 addManyMutably(added, state);
7293 }
7294 return {
7295 removeAll: createSingleArgumentStateOperator(removeAllMutably),
7296 addOne: createStateOperator(addOneMutably),
7297 addMany: createStateOperator(addManyMutably),
7298 setOne: createStateOperator(setOneMutably),
7299 setMany: createStateOperator(setManyMutably),
7300 setAll: createStateOperator(setAllMutably),
7301 updateOne: createStateOperator(updateOneMutably),
7302 updateMany: createStateOperator(updateManyMutably),
7303 upsertOne: createStateOperator(upsertOneMutably),
7304 upsertMany: createStateOperator(upsertManyMutably),
7305 removeOne: createStateOperator(removeOneMutably),
7306 removeMany: createStateOperator(removeManyMutably)
7307 };
7308 }
7309 // src/entities/sorted_state_adapter.ts
7310 function createSortedStateAdapter(selectId, sort) {
7311 var _c = createUnsortedStateAdapter(selectId), removeOne = _c.removeOne, removeMany = _c.removeMany, removeAll = _c.removeAll;
7312 function addOneMutably(entity, state) {
7313 return addManyMutably([entity], state);
7314 }
7315 function addManyMutably(newEntities, state) {
7316 newEntities = ensureEntitiesArray(newEntities);
7317 var models = newEntities.filter(function (model) { return !(selectIdValue(model, selectId) in state.entities); });
7318 if (models.length !== 0) {
7319 merge(models, state);
7320 }
7321 }
7322 function setOneMutably(entity, state) {
7323 return setManyMutably([entity], state);
7324 }
7325 function setManyMutably(newEntities, state) {
7326 newEntities = ensureEntitiesArray(newEntities);
7327 if (newEntities.length !== 0) {
7328 merge(newEntities, state);
7329 }
7330 }
7331 function setAllMutably(newEntities, state) {
7332 newEntities = ensureEntitiesArray(newEntities);
7333 state.entities = {};
7334 state.ids = [];
7335 addManyMutably(newEntities, state);
7336 }
7337 function updateOneMutably(update, state) {
7338 return updateManyMutably([update], state);
7339 }
7340 function updateManyMutably(updates, state) {
7341 var appliedUpdates = false;
7342 for (var _i = 0, updates_1 = updates; _i < updates_1.length; _i++) {
7343 var update = updates_1[_i];
7344 var entity = state.entities[update.id];
7345 if (!entity) {
7346 continue;
7347 }
7348 appliedUpdates = true;
7349 Object.assign(entity, update.changes);
7350 var newId = selectId(entity);
7351 if (update.id !== newId) {
7352 delete state.entities[update.id];
7353 state.entities[newId] = entity;
7354 }
7355 }
7356 if (appliedUpdates) {
7357 resortEntities(state);
7358 }
7359 }
7360 function upsertOneMutably(entity, state) {
7361 return upsertManyMutably([entity], state);
7362 }
7363 function upsertManyMutably(newEntities, state) {
7364 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7365 updateManyMutably(updated, state);
7366 addManyMutably(added, state);
7367 }
7368 function areArraysEqual(a, b) {
7369 if (a.length !== b.length) {
7370 return false;
7371 }
7372 for (var i = 0; i < a.length && i < b.length; i++) {
7373 if (a[i] === b[i]) {
7374 continue;
7375 }
7376 return false;
7377 }
7378 return true;
7379 }
7380 function merge(models, state) {
7381 models.forEach(function (model) {
7382 state.entities[selectId(model)] = model;
7383 });
7384 resortEntities(state);
7385 }
7386 function resortEntities(state) {
7387 var allEntities = Object.values(state.entities);
7388 allEntities.sort(sort);
7389 var newSortedIds = allEntities.map(selectId);
7390 var ids = state.ids;
7391 if (!areArraysEqual(ids, newSortedIds)) {
7392 state.ids = newSortedIds;
7393 }
7394 }
7395 return {
7396 removeOne: removeOne,
7397 removeMany: removeMany,
7398 removeAll: removeAll,
7399 addOne: createStateOperator(addOneMutably),
7400 updateOne: createStateOperator(updateOneMutably),
7401 upsertOne: createStateOperator(upsertOneMutably),
7402 setOne: createStateOperator(setOneMutably),
7403 setMany: createStateOperator(setManyMutably),
7404 setAll: createStateOperator(setAllMutably),
7405 addMany: createStateOperator(addManyMutably),
7406 updateMany: createStateOperator(updateManyMutably),
7407 upsertMany: createStateOperator(upsertManyMutably)
7408 };
7409 }
7410 // src/entities/create_adapter.ts
7411 function createEntityAdapter(options) {
7412 if (options === void 0) { options = {}; }
7413 var _c = __spreadValues({
7414 sortComparer: false,
7415 selectId: function (instance) { return instance.id; }
7416 }, options), selectId = _c.selectId, sortComparer = _c.sortComparer;
7417 var stateFactory = createInitialStateFactory();
7418 var selectorsFactory = createSelectorsFactory();
7419 var stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
7420 return __spreadValues(__spreadValues(__spreadValues({
7421 selectId: selectId,
7422 sortComparer: sortComparer
7423 }, stateFactory), selectorsFactory), stateAdapter);
7424 }
7425 // src/nanoid.ts
7426 var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
7427 var nanoid = function (size) {
7428 if (size === void 0) { size = 21; }
7429 var id = "";
7430 var i = size;
7431 while (i--) {
7432 id += urlAlphabet[Math.random() * 64 | 0];
7433 }
7434 return id;
7435 };
7436 // src/createAsyncThunk.ts
7437 var commonProperties = [
7438 "name",
7439 "message",
7440 "stack",
7441 "code"
7442 ];
7443 var RejectWithValue = /** @class */ (function () {
7444 function RejectWithValue(payload, meta) {
7445 this.payload = payload;
7446 this.meta = meta;
7447 }
7448 return RejectWithValue;
7449 }());
7450 var FulfillWithMeta = /** @class */ (function () {
7451 function FulfillWithMeta(payload, meta) {
7452 this.payload = payload;
7453 this.meta = meta;
7454 }
7455 return FulfillWithMeta;
7456 }());
7457 var miniSerializeError = function (value) {
7458 if (typeof value === "object" && value !== null) {
7459 var simpleError = {};
7460 for (var _i = 0, commonProperties_1 = commonProperties; _i < commonProperties_1.length; _i++) {
7461 var property = commonProperties_1[_i];
7462 if (typeof value[property] === "string") {
7463 simpleError[property] = value[property];
7464 }
7465 }
7466 return simpleError;
7467 }
7468 return { message: String(value) };
7469 };
7470 var createAsyncThunk = (function () {
7471 function createAsyncThunk2(typePrefix, payloadCreator, options) {
7472 var fulfilled = createAction(typePrefix + "/fulfilled", function (payload, requestId, arg, meta) { return ({
7473 payload: payload,
7474 meta: __spreadProps(__spreadValues({}, meta || {}), {
7475 arg: arg,
7476 requestId: requestId,
7477 requestStatus: "fulfilled"
7478 })
7479 }); });
7480 var pending = createAction(typePrefix + "/pending", function (requestId, arg, meta) { return ({
7481 payload: void 0,
7482 meta: __spreadProps(__spreadValues({}, meta || {}), {
7483 arg: arg,
7484 requestId: requestId,
7485 requestStatus: "pending"
7486 })
7487 }); });
7488 var rejected = createAction(typePrefix + "/rejected", function (error, requestId, arg, payload, meta) { return ({
7489 payload: payload,
7490 error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
7491 meta: __spreadProps(__spreadValues({}, meta || {}), {
7492 arg: arg,
7493 requestId: requestId,
7494 rejectedWithValue: !!payload,
7495 requestStatus: "rejected",
7496 aborted: (error == null ? void 0 : error.name) === "AbortError",
7497 condition: (error == null ? void 0 : error.name) === "ConditionError"
7498 })
7499 }); });
7500 var displayedWarning = false;
7501 var AC = typeof AbortController !== "undefined" ? AbortController : /** @class */ (function () {
7502 function class_1() {
7503 this.signal = {
7504 aborted: false,
7505 addEventListener: function () {
7506 },
7507 dispatchEvent: function () {
7508 return false;
7509 },
7510 onabort: function () {
7511 },
7512 removeEventListener: function () {
7513 },
7514 reason: void 0,
7515 throwIfAborted: function () {
7516 }
7517 };
7518 }
7519 class_1.prototype.abort = function () {
7520 if (true) {
7521 if (!displayedWarning) {
7522 displayedWarning = true;
7523 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'.");
7524 }
7525 }
7526 };
7527 return class_1;
7528 }());
7529 function actionCreator(arg) {
7530 return function (dispatch, getState, extra) {
7531 var requestId = (options == null ? void 0 : options.idGenerator) ? options.idGenerator(arg) : nanoid();
7532 var abortController = new AC();
7533 var abortReason;
7534 var started = false;
7535 function abort(reason) {
7536 abortReason = reason;
7537 abortController.abort();
7538 }
7539 var promise2 = function () {
7540 return __async(this, null, function () {
7541 var _a, _b, finalAction, conditionResult, abortedPromise, err_1, skipDispatch;
7542 return __generator(this, function (_c) {
7543 switch (_c.label) {
7544 case 0:
7545 _c.trys.push([0, 4, , 5]);
7546 conditionResult = (_a = options == null ? void 0 : options.condition) == null ? void 0 : _a.call(options, arg, { getState: getState, extra: extra });
7547 if (!isThenable(conditionResult)) return [3 /*break*/, 2];
7548 return [4 /*yield*/, conditionResult];
7549 case 1:
7550 conditionResult = _c.sent();
7551 _c.label = 2;
7552 case 2:
7553 if (conditionResult === false || abortController.signal.aborted) {
7554 throw {
7555 name: "ConditionError",
7556 message: "Aborted due to condition callback returning false."
7557 };
7558 }
7559 started = true;
7560 abortedPromise = new Promise(function (_, reject) { return abortController.signal.addEventListener("abort", function () { return reject({
7561 name: "AbortError",
7562 message: abortReason || "Aborted"
7563 }); }); });
7564 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 })));
7565 return [4 /*yield*/, Promise.race([
7566 abortedPromise,
7567 Promise.resolve(payloadCreator(arg, {
7568 dispatch: dispatch,
7569 getState: getState,
7570 extra: extra,
7571 requestId: requestId,
7572 signal: abortController.signal,
7573 abort: abort,
7574 rejectWithValue: function (value, meta) {
7575 return new RejectWithValue(value, meta);
7576 },
7577 fulfillWithValue: function (value, meta) {
7578 return new FulfillWithMeta(value, meta);
7579 }
7580 })).then(function (result) {
7581 if (result instanceof RejectWithValue) {
7582 throw result;
7583 }
7584 if (result instanceof FulfillWithMeta) {
7585 return fulfilled(result.payload, requestId, arg, result.meta);
7586 }
7587 return fulfilled(result, requestId, arg);
7588 })
7589 ])];
7590 case 3:
7591 finalAction = _c.sent();
7592 return [3 /*break*/, 5];
7593 case 4:
7594 err_1 = _c.sent();
7595 finalAction = err_1 instanceof RejectWithValue ? rejected(null, requestId, arg, err_1.payload, err_1.meta) : rejected(err_1, requestId, arg);
7596 return [3 /*break*/, 5];
7597 case 5:
7598 skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
7599 if (!skipDispatch) {
7600 dispatch(finalAction);
7601 }
7602 return [2 /*return*/, finalAction];
7603 }
7604 });
7605 });
7606 }();
7607 return Object.assign(promise2, {
7608 abort: abort,
7609 requestId: requestId,
7610 arg: arg,
7611 unwrap: function () {
7612 return promise2.then(unwrapResult);
7613 }
7614 });
7615 };
7616 }
7617 return Object.assign(actionCreator, {
7618 pending: pending,
7619 rejected: rejected,
7620 fulfilled: fulfilled,
7621 typePrefix: typePrefix
7622 });
7623 }
7624 createAsyncThunk2.withTypes = function () { return createAsyncThunk2; };
7625 return createAsyncThunk2;
7626 })();
7627 function unwrapResult(action) {
7628 if (action.meta && action.meta.rejectedWithValue) {
7629 throw action.payload;
7630 }
7631 if (action.error) {
7632 throw action.error;
7633 }
7634 return action.payload;
7635 }
7636 function isThenable(value) {
7637 return value !== null && typeof value === "object" && typeof value.then === "function";
7638 }
7639 // src/matchers.ts
7640 var matches = function (matcher, action) {
7641 if (hasMatchFunction(matcher)) {
7642 return matcher.match(action);
7643 }
7644 else {
7645 return matcher(action);
7646 }
7647 };
7648 function isAnyOf() {
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.some(function (matcher) { return matches(matcher, action); });
7655 };
7656 }
7657 function isAllOf() {
7658 var matchers = [];
7659 for (var _i = 0; _i < arguments.length; _i++) {
7660 matchers[_i] = arguments[_i];
7661 }
7662 return function (action) {
7663 return matchers.every(function (matcher) { return matches(matcher, action); });
7664 };
7665 }
7666 function hasExpectedRequestMetadata(action, validStatus) {
7667 if (!action || !action.meta)
7668 return false;
7669 var hasValidRequestId = typeof action.meta.requestId === "string";
7670 var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
7671 return hasValidRequestId && hasValidRequestStatus;
7672 }
7673 function isAsyncThunkArray(a) {
7674 return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
7675 }
7676 function isPending() {
7677 var asyncThunks = [];
7678 for (var _i = 0; _i < arguments.length; _i++) {
7679 asyncThunks[_i] = arguments[_i];
7680 }
7681 if (asyncThunks.length === 0) {
7682 return function (action) { return hasExpectedRequestMetadata(action, ["pending"]); };
7683 }
7684 if (!isAsyncThunkArray(asyncThunks)) {
7685 return isPending()(asyncThunks[0]);
7686 }
7687 return function (action) {
7688 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.pending; });
7689 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7690 return combinedMatcher(action);
7691 };
7692 }
7693 function isRejected() {
7694 var asyncThunks = [];
7695 for (var _i = 0; _i < arguments.length; _i++) {
7696 asyncThunks[_i] = arguments[_i];
7697 }
7698 if (asyncThunks.length === 0) {
7699 return function (action) { return hasExpectedRequestMetadata(action, ["rejected"]); };
7700 }
7701 if (!isAsyncThunkArray(asyncThunks)) {
7702 return isRejected()(asyncThunks[0]);
7703 }
7704 return function (action) {
7705 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.rejected; });
7706 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7707 return combinedMatcher(action);
7708 };
7709 }
7710 function isRejectedWithValue() {
7711 var asyncThunks = [];
7712 for (var _i = 0; _i < arguments.length; _i++) {
7713 asyncThunks[_i] = arguments[_i];
7714 }
7715 var hasFlag = function (action) {
7716 return action && action.meta && action.meta.rejectedWithValue;
7717 };
7718 if (asyncThunks.length === 0) {
7719 return function (action) {
7720 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
7721 return combinedMatcher(action);
7722 };
7723 }
7724 if (!isAsyncThunkArray(asyncThunks)) {
7725 return isRejectedWithValue()(asyncThunks[0]);
7726 }
7727 return function (action) {
7728 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
7729 return combinedMatcher(action);
7730 };
7731 }
7732 function isFulfilled() {
7733 var asyncThunks = [];
7734 for (var _i = 0; _i < arguments.length; _i++) {
7735 asyncThunks[_i] = arguments[_i];
7736 }
7737 if (asyncThunks.length === 0) {
7738 return function (action) { return hasExpectedRequestMetadata(action, ["fulfilled"]); };
7739 }
7740 if (!isAsyncThunkArray(asyncThunks)) {
7741 return isFulfilled()(asyncThunks[0]);
7742 }
7743 return function (action) {
7744 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.fulfilled; });
7745 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7746 return combinedMatcher(action);
7747 };
7748 }
7749 function isAsyncThunkAction() {
7750 var asyncThunks = [];
7751 for (var _i = 0; _i < arguments.length; _i++) {
7752 asyncThunks[_i] = arguments[_i];
7753 }
7754 if (asyncThunks.length === 0) {
7755 return function (action) { return hasExpectedRequestMetadata(action, ["pending", "fulfilled", "rejected"]); };
7756 }
7757 if (!isAsyncThunkArray(asyncThunks)) {
7758 return isAsyncThunkAction()(asyncThunks[0]);
7759 }
7760 return function (action) {
7761 var matchers = [];
7762 for (var _i = 0, asyncThunks_1 = asyncThunks; _i < asyncThunks_1.length; _i++) {
7763 var asyncThunk = asyncThunks_1[_i];
7764 matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
7765 }
7766 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7767 return combinedMatcher(action);
7768 };
7769 }
7770 // src/listenerMiddleware/utils.ts
7771 var assertFunction = function (func, expected) {
7772 if (typeof func !== "function") {
7773 throw new TypeError(expected + " is not a function");
7774 }
7775 };
7776 var noop = function () {
7777 };
7778 var catchRejection = function (promise2, onError) {
7779 if (onError === void 0) { onError = noop; }
7780 promise2.catch(onError);
7781 return promise2;
7782 };
7783 var addAbortSignalListener = function (abortSignal, callback) {
7784 abortSignal.addEventListener("abort", callback, { once: true });
7785 return function () { return abortSignal.removeEventListener("abort", callback); };
7786 };
7787 var abortControllerWithReason = function (abortController, reason) {
7788 var signal = abortController.signal;
7789 if (signal.aborted) {
7790 return;
7791 }
7792 if (!("reason" in signal)) {
7793 Object.defineProperty(signal, "reason", {
7794 enumerable: true,
7795 value: reason,
7796 configurable: true,
7797 writable: true
7798 });
7799 }
7800 ;
7801 abortController.abort(reason);
7802 };
7803 // src/listenerMiddleware/exceptions.ts
7804 var task = "task";
7805 var listener = "listener";
7806 var completed = "completed";
7807 var cancelled = "cancelled";
7808 var taskCancelled = "task-" + cancelled;
7809 var taskCompleted = "task-" + completed;
7810 var listenerCancelled = listener + "-" + cancelled;
7811 var listenerCompleted = listener + "-" + completed;
7812 var TaskAbortError = /** @class */ (function () {
7813 function TaskAbortError(code) {
7814 this.code = code;
7815 this.name = "TaskAbortError";
7816 this.message = task + " " + cancelled + " (reason: " + code + ")";
7817 }
7818 return TaskAbortError;
7819 }());
7820 // src/listenerMiddleware/task.ts
7821 var validateActive = function (signal) {
7822 if (signal.aborted) {
7823 throw new TaskAbortError(signal.reason);
7824 }
7825 };
7826 function raceWithSignal(signal, promise2) {
7827 var cleanup = noop;
7828 return new Promise(function (resolve, reject) {
7829 var notifyRejection = function () { return reject(new TaskAbortError(signal.reason)); };
7830 if (signal.aborted) {
7831 notifyRejection();
7832 return;
7833 }
7834 cleanup = addAbortSignalListener(signal, notifyRejection);
7835 promise2.finally(function () { return cleanup(); }).then(resolve, reject);
7836 }).finally(function () {
7837 cleanup = noop;
7838 });
7839 }
7840 var runTask = function (task2, cleanUp) { return __async(void 0, null, function () {
7841 var value, error_1;
7842 return __generator(this, function (_c) {
7843 switch (_c.label) {
7844 case 0:
7845 _c.trys.push([0, 3, 4, 5]);
7846 return [4 /*yield*/, Promise.resolve()];
7847 case 1:
7848 _c.sent();
7849 return [4 /*yield*/, task2()];
7850 case 2:
7851 value = _c.sent();
7852 return [2 /*return*/, {
7853 status: "ok",
7854 value: value
7855 }];
7856 case 3:
7857 error_1 = _c.sent();
7858 return [2 /*return*/, {
7859 status: error_1 instanceof TaskAbortError ? "cancelled" : "rejected",
7860 error: error_1
7861 }];
7862 case 4:
7863 cleanUp == null ? void 0 : cleanUp();
7864 return [7 /*endfinally*/];
7865 case 5: return [2 /*return*/];
7866 }
7867 });
7868 }); };
7869 var createPause = function (signal) {
7870 return function (promise2) {
7871 return catchRejection(raceWithSignal(signal, promise2).then(function (output) {
7872 validateActive(signal);
7873 return output;
7874 }));
7875 };
7876 };
7877 var createDelay = function (signal) {
7878 var pause = createPause(signal);
7879 return function (timeoutMs) {
7880 return pause(new Promise(function (resolve) { return setTimeout(resolve, timeoutMs); }));
7881 };
7882 };
7883 // src/listenerMiddleware/index.ts
7884 var assign = Object.assign;
7885 var INTERNAL_NIL_TOKEN = {};
7886 var alm = "listenerMiddleware";
7887 var createFork = function (parentAbortSignal, parentBlockingPromises) {
7888 var linkControllers = function (controller) { return addAbortSignalListener(parentAbortSignal, function () { return abortControllerWithReason(controller, parentAbortSignal.reason); }); };
7889 return function (taskExecutor, opts) {
7890 assertFunction(taskExecutor, "taskExecutor");
7891 var childAbortController = new AbortController();
7892 linkControllers(childAbortController);
7893 var result = runTask(function () { return __async(void 0, null, function () {
7894 var result2;
7895 return __generator(this, function (_c) {
7896 switch (_c.label) {
7897 case 0:
7898 validateActive(parentAbortSignal);
7899 validateActive(childAbortController.signal);
7900 return [4 /*yield*/, taskExecutor({
7901 pause: createPause(childAbortController.signal),
7902 delay: createDelay(childAbortController.signal),
7903 signal: childAbortController.signal
7904 })];
7905 case 1:
7906 result2 = _c.sent();
7907 validateActive(childAbortController.signal);
7908 return [2 /*return*/, result2];
7909 }
7910 });
7911 }); }, function () { return abortControllerWithReason(childAbortController, taskCompleted); });
7912 if (opts == null ? void 0 : opts.autoJoin) {
7913 parentBlockingPromises.push(result);
7914 }
7915 return {
7916 result: createPause(parentAbortSignal)(result),
7917 cancel: function () {
7918 abortControllerWithReason(childAbortController, taskCancelled);
7919 }
7920 };
7921 };
7922 };
7923 var createTakePattern = function (startListening, signal) {
7924 var take = function (predicate, timeout) { return __async(void 0, null, function () {
7925 var unsubscribe, tuplePromise, promises, output;
7926 return __generator(this, function (_c) {
7927 switch (_c.label) {
7928 case 0:
7929 validateActive(signal);
7930 unsubscribe = function () {
7931 };
7932 tuplePromise = new Promise(function (resolve, reject) {
7933 var stopListening = startListening({
7934 predicate: predicate,
7935 effect: function (action, listenerApi) {
7936 listenerApi.unsubscribe();
7937 resolve([
7938 action,
7939 listenerApi.getState(),
7940 listenerApi.getOriginalState()
7941 ]);
7942 }
7943 });
7944 unsubscribe = function () {
7945 stopListening();
7946 reject();
7947 };
7948 });
7949 promises = [
7950 tuplePromise
7951 ];
7952 if (timeout != null) {
7953 promises.push(new Promise(function (resolve) { return setTimeout(resolve, timeout, null); }));
7954 }
7955 _c.label = 1;
7956 case 1:
7957 _c.trys.push([1, , 3, 4]);
7958 return [4 /*yield*/, raceWithSignal(signal, Promise.race(promises))];
7959 case 2:
7960 output = _c.sent();
7961 validateActive(signal);
7962 return [2 /*return*/, output];
7963 case 3:
7964 unsubscribe();
7965 return [7 /*endfinally*/];
7966 case 4: return [2 /*return*/];
7967 }
7968 });
7969 }); };
7970 return function (predicate, timeout) { return catchRejection(take(predicate, timeout)); };
7971 };
7972 var getListenerEntryPropsFrom = function (options) {
7973 var type = options.type, actionCreator = options.actionCreator, matcher = options.matcher, predicate = options.predicate, effect = options.effect;
7974 if (type) {
7975 predicate = createAction(type).match;
7976 }
7977 else if (actionCreator) {
7978 type = actionCreator.type;
7979 predicate = actionCreator.match;
7980 }
7981 else if (matcher) {
7982 predicate = matcher;
7983 }
7984 else if (predicate) {
7985 }
7986 else {
7987 throw new Error("Creating or removing a listener requires one of the known fields for matching an action");
7988 }
7989 assertFunction(effect, "options.listener");
7990 return { predicate: predicate, type: type, effect: effect };
7991 };
7992 var createListenerEntry = function (options) {
7993 var _c = getListenerEntryPropsFrom(options), type = _c.type, predicate = _c.predicate, effect = _c.effect;
7994 var id = nanoid();
7995 var entry = {
7996 id: id,
7997 effect: effect,
7998 type: type,
7999 predicate: predicate,
8000 pending: new Set(),
8001 unsubscribe: function () {
8002 throw new Error("Unsubscribe not initialized");
8003 }
8004 };
8005 return entry;
8006 };
8007 var cancelActiveListeners = function (entry) {
8008 entry.pending.forEach(function (controller) {
8009 abortControllerWithReason(controller, listenerCancelled);
8010 });
8011 };
8012 var createClearListenerMiddleware = function (listenerMap) {
8013 return function () {
8014 listenerMap.forEach(cancelActiveListeners);
8015 listenerMap.clear();
8016 };
8017 };
8018 var safelyNotifyError = function (errorHandler, errorToNotify, errorInfo) {
8019 try {
8020 errorHandler(errorToNotify, errorInfo);
8021 }
8022 catch (errorHandlerError) {
8023 setTimeout(function () {
8024 throw errorHandlerError;
8025 }, 0);
8026 }
8027 };
8028 var addListener = createAction(alm + "/add");
8029 var clearAllListeners = createAction(alm + "/removeAll");
8030 var removeListener = createAction(alm + "/remove");
8031 var defaultErrorHandler = function () {
8032 var args = [];
8033 for (var _i = 0; _i < arguments.length; _i++) {
8034 args[_i] = arguments[_i];
8035 }
8036 console.error.apply(console, __spreadArray([alm + "/error"], args));
8037 };
8038 function createListenerMiddleware(middlewareOptions) {
8039 var _this = this;
8040 if (middlewareOptions === void 0) { middlewareOptions = {}; }
8041 var listenerMap = new Map();
8042 var extra = middlewareOptions.extra, _c = middlewareOptions.onError, onError = _c === void 0 ? defaultErrorHandler : _c;
8043 assertFunction(onError, "onError");
8044 var insertEntry = function (entry) {
8045 entry.unsubscribe = function () { return listenerMap.delete(entry.id); };
8046 listenerMap.set(entry.id, entry);
8047 return function (cancelOptions) {
8048 entry.unsubscribe();
8049 if (cancelOptions == null ? void 0 : cancelOptions.cancelActive) {
8050 cancelActiveListeners(entry);
8051 }
8052 };
8053 };
8054 var findListenerEntry = function (comparator) {
8055 for (var _i = 0, _c = Array.from(listenerMap.values()); _i < _c.length; _i++) {
8056 var entry = _c[_i];
8057 if (comparator(entry)) {
8058 return entry;
8059 }
8060 }
8061 return void 0;
8062 };
8063 var startListening = function (options) {
8064 var entry = findListenerEntry(function (existingEntry) { return existingEntry.effect === options.effect; });
8065 if (!entry) {
8066 entry = createListenerEntry(options);
8067 }
8068 return insertEntry(entry);
8069 };
8070 var stopListening = function (options) {
8071 var _c = getListenerEntryPropsFrom(options), type = _c.type, effect = _c.effect, predicate = _c.predicate;
8072 var entry = findListenerEntry(function (entry2) {
8073 var matchPredicateOrType = typeof type === "string" ? entry2.type === type : entry2.predicate === predicate;
8074 return matchPredicateOrType && entry2.effect === effect;
8075 });
8076 if (entry) {
8077 entry.unsubscribe();
8078 if (options.cancelActive) {
8079 cancelActiveListeners(entry);
8080 }
8081 }
8082 return !!entry;
8083 };
8084 var notifyListener = function (entry, action, api, getOriginalState) { return __async(_this, null, function () {
8085 var internalTaskController, take, autoJoinPromises, listenerError_1;
8086 return __generator(this, function (_c) {
8087 switch (_c.label) {
8088 case 0:
8089 internalTaskController = new AbortController();
8090 take = createTakePattern(startListening, internalTaskController.signal);
8091 autoJoinPromises = [];
8092 _c.label = 1;
8093 case 1:
8094 _c.trys.push([1, 3, 4, 6]);
8095 entry.pending.add(internalTaskController);
8096 return [4 /*yield*/, Promise.resolve(entry.effect(action, assign({}, api, {
8097 getOriginalState: getOriginalState,
8098 condition: function (predicate, timeout) { return take(predicate, timeout).then(Boolean); },
8099 take: take,
8100 delay: createDelay(internalTaskController.signal),
8101 pause: createPause(internalTaskController.signal),
8102 extra: extra,
8103 signal: internalTaskController.signal,
8104 fork: createFork(internalTaskController.signal, autoJoinPromises),
8105 unsubscribe: entry.unsubscribe,
8106 subscribe: function () {
8107 listenerMap.set(entry.id, entry);
8108 },
8109 cancelActiveListeners: function () {
8110 entry.pending.forEach(function (controller, _, set) {
8111 if (controller !== internalTaskController) {
8112 abortControllerWithReason(controller, listenerCancelled);
8113 set.delete(controller);
8114 }
8115 });
8116 }
8117 })))];
8118 case 2:
8119 _c.sent();
8120 return [3 /*break*/, 6];
8121 case 3:
8122 listenerError_1 = _c.sent();
8123 if (!(listenerError_1 instanceof TaskAbortError)) {
8124 safelyNotifyError(onError, listenerError_1, {
8125 raisedBy: "effect"
8126 });
8127 }
8128 return [3 /*break*/, 6];
8129 case 4: return [4 /*yield*/, Promise.allSettled(autoJoinPromises)];
8130 case 5:
8131 _c.sent();
8132 abortControllerWithReason(internalTaskController, listenerCompleted);
8133 entry.pending.delete(internalTaskController);
8134 return [7 /*endfinally*/];
8135 case 6: return [2 /*return*/];
8136 }
8137 });
8138 }); };
8139 var clearListenerMiddleware = createClearListenerMiddleware(listenerMap);
8140 var middleware = function (api) { return function (next) { return function (action) {
8141 if (!isAction(action)) {
8142 return next(action);
8143 }
8144 if (addListener.match(action)) {
8145 return startListening(action.payload);
8146 }
8147 if (clearAllListeners.match(action)) {
8148 clearListenerMiddleware();
8149 return;
8150 }
8151 if (removeListener.match(action)) {
8152 return stopListening(action.payload);
8153 }
8154 var originalState = api.getState();
8155 var getOriginalState = function () {
8156 if (originalState === INTERNAL_NIL_TOKEN) {
8157 throw new Error(alm + ": getOriginalState can only be called synchronously");
8158 }
8159 return originalState;
8160 };
8161 var result;
8162 try {
8163 result = next(action);
8164 if (listenerMap.size > 0) {
8165 var currentState = api.getState();
8166 var listenerEntries = Array.from(listenerMap.values());
8167 for (var _i = 0, listenerEntries_1 = listenerEntries; _i < listenerEntries_1.length; _i++) {
8168 var entry = listenerEntries_1[_i];
8169 var runListener = false;
8170 try {
8171 runListener = entry.predicate(action, currentState, originalState);
8172 }
8173 catch (predicateError) {
8174 runListener = false;
8175 safelyNotifyError(onError, predicateError, {
8176 raisedBy: "predicate"
8177 });
8178 }
8179 if (!runListener) {
8180 continue;
8181 }
8182 notifyListener(entry, action, api, getOriginalState);
8183 }
8184 }
8185 }
8186 finally {
8187 originalState = INTERNAL_NIL_TOKEN;
8188 }
8189 return result;
8190 }; }; };
8191 return {
8192 middleware: middleware,
8193 startListening: startListening,
8194 stopListening: stopListening,
8195 clearListeners: clearListenerMiddleware
8196 };
8197 }
8198 // src/autoBatchEnhancer.ts
8199 var SHOULD_AUTOBATCH = "RTK_autoBatch";
8200 var prepareAutoBatched = function () { return function (payload) {
8201 var _c;
8202 return ({
8203 payload: payload,
8204 meta: (_c = {}, _c[SHOULD_AUTOBATCH] = true, _c)
8205 });
8206 }; };
8207 var promise;
8208 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 () {
8209 throw err;
8210 }, 0); }); };
8211 var createQueueWithTimer = function (timeout) {
8212 return function (notify) {
8213 setTimeout(notify, timeout);
8214 };
8215 };
8216 var rAF = typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10);
8217 var autoBatchEnhancer = function (options) {
8218 if (options === void 0) { options = { type: "raf" }; }
8219 return function (next) { return function () {
8220 var args = [];
8221 for (var _i = 0; _i < arguments.length; _i++) {
8222 args[_i] = arguments[_i];
8223 }
8224 var store = next.apply(void 0, args);
8225 var notifying = true;
8226 var shouldNotifyAtEndOfTick = false;
8227 var notificationQueued = false;
8228 var listeners = new Set();
8229 var queueCallback = options.type === "tick" ? queueMicrotaskShim : options.type === "raf" ? rAF : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
8230 var notifyListeners = function () {
8231 notificationQueued = false;
8232 if (shouldNotifyAtEndOfTick) {
8233 shouldNotifyAtEndOfTick = false;
8234 listeners.forEach(function (l) { return l(); });
8235 }
8236 };
8237 return Object.assign({}, store, {
8238 subscribe: function (listener2) {
8239 var wrappedListener = function () { return notifying && listener2(); };
8240 var unsubscribe = store.subscribe(wrappedListener);
8241 listeners.add(listener2);
8242 return function () {
8243 unsubscribe();
8244 listeners.delete(listener2);
8245 };
8246 },
8247 dispatch: function (action) {
8248 var _a;
8249 try {
8250 notifying = !((_a = action == null ? void 0 : action.meta) == null ? void 0 : _a[SHOULD_AUTOBATCH]);
8251 shouldNotifyAtEndOfTick = !notifying;
8252 if (shouldNotifyAtEndOfTick) {
8253 if (!notificationQueued) {
8254 notificationQueued = true;
8255 queueCallback(notifyListeners);
8256 }
8257 }
8258 return store.dispatch(action);
8259 }
8260 finally {
8261 notifying = true;
8262 }
8263 }
8264 });
8265 }; };
8266 };
8267 // src/index.ts
8268 (0,immer__WEBPACK_IMPORTED_MODULE_0__.enableES5)();
8269
8270 //# sourceMappingURL=redux-toolkit.esm.js.map
8271
8272 /***/ }),
8273
8274 /***/ "../node_modules/immer/dist/immer.esm.mjs":
8275 /*!************************************************!*\
8276 !*** ../node_modules/immer/dist/immer.esm.mjs ***!
8277 \************************************************/
8278 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8279
8280 "use strict";
8281 __webpack_require__.r(__webpack_exports__);
8282 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8283 /* harmony export */ Immer: () => (/* binding */ un),
8284 /* harmony export */ applyPatches: () => (/* binding */ pn),
8285 /* harmony export */ castDraft: () => (/* binding */ K),
8286 /* harmony export */ castImmutable: () => (/* binding */ $),
8287 /* harmony export */ createDraft: () => (/* binding */ ln),
8288 /* harmony export */ current: () => (/* binding */ R),
8289 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
8290 /* harmony export */ enableAllPlugins: () => (/* binding */ J),
8291 /* harmony export */ enableES5: () => (/* binding */ F),
8292 /* harmony export */ enableMapSet: () => (/* binding */ C),
8293 /* harmony export */ enablePatches: () => (/* binding */ T),
8294 /* harmony export */ finishDraft: () => (/* binding */ dn),
8295 /* harmony export */ freeze: () => (/* binding */ d),
8296 /* harmony export */ immerable: () => (/* binding */ L),
8297 /* harmony export */ isDraft: () => (/* binding */ r),
8298 /* harmony export */ isDraftable: () => (/* binding */ t),
8299 /* harmony export */ nothing: () => (/* binding */ H),
8300 /* harmony export */ original: () => (/* binding */ e),
8301 /* harmony export */ produce: () => (/* binding */ fn),
8302 /* harmony export */ produceWithPatches: () => (/* binding */ cn),
8303 /* harmony export */ setAutoFreeze: () => (/* binding */ sn),
8304 /* harmony export */ setUseProxies: () => (/* binding */ vn)
8305 /* harmony export */ });
8306 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
8307 }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);
8308 //# sourceMappingURL=immer.esm.js.map
8309
8310
8311 /***/ }),
8312
8313 /***/ "../node_modules/mixpanel-browser/dist/mixpanel.module.js":
8314 /*!****************************************************************!*\
8315 !*** ../node_modules/mixpanel-browser/dist/mixpanel.module.js ***!
8316 \****************************************************************/
8317 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8318
8319 "use strict";
8320 __webpack_require__.r(__webpack_exports__);
8321 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8322 /* harmony export */ "default": () => (/* binding */ mixpanel)
8323 /* harmony export */ });
8324 // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
8325 var win;
8326 if (typeof(window) === 'undefined') {
8327 var loc = {
8328 hostname: ''
8329 };
8330 win = {
8331 crypto: {randomUUID: function() {throw Error('unsupported');}},
8332 navigator: { userAgent: '', onLine: true },
8333 document: {
8334 createElement: function() { return {}; },
8335 location: loc,
8336 referrer: ''
8337 },
8338 screen: { width: 0, height: 0 },
8339 location: loc,
8340 addEventListener: function() {},
8341 removeEventListener: function() {}
8342 };
8343 } else {
8344 win = window;
8345 }
8346
8347 function _array_like_to_array(arr, len) {
8348 if (len == null || len > arr.length) len = arr.length;
8349 for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8350 return arr2;
8351 }
8352 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8353 try {
8354 var info = gen[key](arg);
8355 var value = info.value;
8356 } catch (error) {
8357 reject(error);
8358 return;
8359 }
8360 if (info.done) {
8361 resolve(value);
8362 } else {
8363 Promise.resolve(value).then(_next, _throw);
8364 }
8365 }
8366 function _async_to_generator(fn) {
8367 return function() {
8368 var self = this, args = arguments;
8369 return new Promise(function(resolve, reject) {
8370 var gen = fn.apply(self, args);
8371 function _next(value) {
8372 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8373 }
8374 function _throw(err) {
8375 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8376 }
8377 _next(undefined);
8378 });
8379 };
8380 }
8381 function _construct(Parent, args, Class) {
8382 if (_is_native_reflect_construct()) {
8383 _construct = Reflect.construct;
8384 } else {
8385 _construct = function construct(Parent, args, Class) {
8386 var a = [
8387 null
8388 ];
8389 a.push.apply(a, args);
8390 var Constructor = Function.bind.apply(Parent, a);
8391 var instance = new Constructor();
8392 if (Class) _set_prototype_of(instance, Class.prototype);
8393 return instance;
8394 };
8395 }
8396 return _construct.apply(null, arguments);
8397 }
8398 function _defineProperties(target, props) {
8399 for(var i = 0; i < props.length; i++){
8400 var descriptor = props[i];
8401 descriptor.enumerable = descriptor.enumerable || false;
8402 descriptor.configurable = true;
8403 if ("value" in descriptor) descriptor.writable = true;
8404 Object.defineProperty(target, descriptor.key, descriptor);
8405 }
8406 }
8407 function _create_class(Constructor, protoProps, staticProps) {
8408 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
8409 return Constructor;
8410 }
8411 function _extends() {
8412 _extends = Object.assign || function(target) {
8413 for(var i = 1; i < arguments.length; i++){
8414 var source = arguments[i];
8415 for(var key in source){
8416 if (Object.prototype.hasOwnProperty.call(source, key)) {
8417 target[key] = source[key];
8418 }
8419 }
8420 }
8421 return target;
8422 };
8423 return _extends.apply(this, arguments);
8424 }
8425 function _get_prototype_of(o) {
8426 _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
8427 return o.__proto__ || Object.getPrototypeOf(o);
8428 };
8429 return _get_prototype_of(o);
8430 }
8431 function _inherits(subClass, superClass) {
8432 if (typeof superClass !== "function" && superClass !== null) {
8433 throw new TypeError("Super expression must either be null or a function");
8434 }
8435 subClass.prototype = Object.create(superClass && superClass.prototype, {
8436 constructor: {
8437 value: subClass,
8438 writable: true,
8439 configurable: true
8440 }
8441 });
8442 if (superClass) _set_prototype_of(subClass, superClass);
8443 }
8444 function _instanceof(left, right) {
8445 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
8446 return !!right[Symbol.hasInstance](left);
8447 } else {
8448 return left instanceof right;
8449 }
8450 }
8451 function _is_native_function(fn) {
8452 return Function.toString.call(fn).indexOf("[native code]") !== -1;
8453 }
8454 function _object_without_properties_loose(source, excluded) {
8455 if (source == null) return {};
8456 var target = {};
8457 var sourceKeys = Object.keys(source);
8458 var key, i;
8459 for(i = 0; i < sourceKeys.length; i++){
8460 key = sourceKeys[i];
8461 if (excluded.indexOf(key) >= 0) continue;
8462 target[key] = source[key];
8463 }
8464 return target;
8465 }
8466 function _set_prototype_of(o, p) {
8467 _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
8468 o.__proto__ = p;
8469 return o;
8470 };
8471 return _set_prototype_of(o, p);
8472 }
8473 function _type_of(obj) {
8474 "@swc/helpers - typeof";
8475 return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
8476 }
8477 function _unsupported_iterable_to_array(o, minLen) {
8478 if (!o) return;
8479 if (typeof o === "string") return _array_like_to_array(o, minLen);
8480 var n = Object.prototype.toString.call(o).slice(8, -1);
8481 if (n === "Object" && o.constructor) n = o.constructor.name;
8482 if (n === "Map" || n === "Set") return Array.from(n);
8483 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
8484 }
8485 function _wrap_native_super(Class) {
8486 var _cache = typeof Map === "function" ? new Map() : undefined;
8487 _wrap_native_super = function wrapNativeSuper(Class) {
8488 if (Class === null || !_is_native_function(Class)) return Class;
8489 if (typeof Class !== "function") {
8490 throw new TypeError("Super expression must either be null or a function");
8491 }
8492 if (typeof _cache !== "undefined") {
8493 if (_cache.has(Class)) return _cache.get(Class);
8494 _cache.set(Class, Wrapper);
8495 }
8496 function Wrapper() {
8497 return _construct(Class, arguments, _get_prototype_of(this).constructor);
8498 }
8499 Wrapper.prototype = Object.create(Class.prototype, {
8500 constructor: {
8501 value: Wrapper,
8502 enumerable: false,
8503 writable: true,
8504 configurable: true
8505 }
8506 });
8507 return _set_prototype_of(Wrapper, Class);
8508 };
8509 return _wrap_native_super(Class);
8510 }
8511 function _is_native_reflect_construct() {
8512 try {
8513 var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
8514 } catch (_) {}
8515 return (_is_native_reflect_construct = function() {
8516 return !!result;
8517 })();
8518 }
8519 function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
8520 var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
8521 if (it) return (it = it.call(o)).next.bind(it);
8522 if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike) {
8523 if (it) o = it;
8524 var i = 0;
8525 return function() {
8526 if (i >= o.length) {
8527 return {
8528 done: true
8529 };
8530 }
8531 return {
8532 done: false,
8533 value: o[i++]
8534 };
8535 };
8536 }
8537 throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8538 }
8539 function _ts_generator(thisArg, body) {
8540 var f, y, t, g, _ = {
8541 label: 0,
8542 sent: function() {
8543 if (t[0] & 1) throw t[1];
8544 return t[1];
8545 },
8546 trys: [],
8547 ops: []
8548 };
8549 return g = {
8550 next: verb(0),
8551 "throw": verb(1),
8552 "return": verb(2)
8553 }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
8554 return this;
8555 }), g;
8556 function verb(n) {
8557 return function(v) {
8558 return step([
8559 n,
8560 v
8561 ]);
8562 };
8563 }
8564 function step(op) {
8565 if (f) throw new TypeError("Generator is already executing.");
8566 while(_)try {
8567 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;
8568 if (y = 0, t) op = [
8569 op[0] & 2,
8570 t.value
8571 ];
8572 switch(op[0]){
8573 case 0:
8574 case 1:
8575 t = op;
8576 break;
8577 case 4:
8578 _.label++;
8579 return {
8580 value: op[1],
8581 done: false
8582 };
8583 case 5:
8584 _.label++;
8585 y = op[1];
8586 op = [
8587 0
8588 ];
8589 continue;
8590 case 7:
8591 op = _.ops.pop();
8592 _.trys.pop();
8593 continue;
8594 default:
8595 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
8596 _ = 0;
8597 continue;
8598 }
8599 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
8600 _.label = op[1];
8601 break;
8602 }
8603 if (op[0] === 6 && _.label < t[1]) {
8604 _.label = t[1];
8605 t = op;
8606 break;
8607 }
8608 if (t && _.label < t[2]) {
8609 _.label = t[2];
8610 _.ops.push(op);
8611 break;
8612 }
8613 if (t[2]) _.ops.pop();
8614 _.trys.pop();
8615 continue;
8616 }
8617 op = body.call(thisArg, _);
8618 } catch (e) {
8619 op = [
8620 6,
8621 e
8622 ];
8623 y = 0;
8624 } finally{
8625 f = t = 0;
8626 }
8627 if (op[0] & 5) throw op[1];
8628 return {
8629 value: op[0] ? op[1] : void 0,
8630 done: true
8631 };
8632 }
8633 }
8634 function _ts_values(o) {
8635 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
8636 if (m) return m.call(o);
8637 if (o && typeof o.length === "number") return {
8638 next: function() {
8639 if (o && i >= o.length) o = void 0;
8640 return {
8641 value: o && o[i++],
8642 done: !o
8643 };
8644 }
8645 };
8646 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
8647 }
8648 var __defProp = Object.defineProperty;
8649 var __defNormalProp = function(obj, key, value) {
8650 return key in obj ? __defProp(obj, key, {
8651 enumerable: true,
8652 configurable: true,
8653 writable: true,
8654 value: value
8655 }) : obj[key] = value;
8656 };
8657 var __publicField = function(obj, key, value) {
8658 return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
8659 };
8660 var _a;
8661 var __defProp$1 = Object.defineProperty;
8662 var __defNormalProp$1 = function(obj, key, value) {
8663 return key in obj ? __defProp$1(obj, key, {
8664 enumerable: true,
8665 configurable: true,
8666 writable: true,
8667 value: value
8668 }) : obj[key] = value;
8669 };
8670 var __publicField$1 = function(obj, key, value) {
8671 return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
8672 };
8673 var NodeType$3 = /* @__PURE__ */ function(NodeType2) {
8674 NodeType2[NodeType2["Document"] = 0] = "Document";
8675 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
8676 NodeType2[NodeType2["Element"] = 2] = "Element";
8677 NodeType2[NodeType2["Text"] = 3] = "Text";
8678 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
8679 NodeType2[NodeType2["Comment"] = 5] = "Comment";
8680 return NodeType2;
8681 }(NodeType$3 || {});
8682 var testableAccessors$1 = {
8683 Node: [
8684 "childNodes",
8685 "parentNode",
8686 "parentElement",
8687 "textContent"
8688 ],
8689 ShadowRoot: [
8690 "host",
8691 "styleSheets"
8692 ],
8693 Element: [
8694 "shadowRoot",
8695 "querySelector",
8696 "querySelectorAll"
8697 ],
8698 MutationObserver: []
8699 };
8700 var testableMethods$1 = {
8701 Node: [
8702 "contains",
8703 "getRootNode"
8704 ],
8705 ShadowRoot: [
8706 "getSelection"
8707 ],
8708 Element: [],
8709 MutationObserver: [
8710 "constructor"
8711 ]
8712 };
8713 var untaintedBasePrototype$1 = {};
8714 var isAngularZonePresent$1 = function() {
8715 return !!globalThis.Zone;
8716 };
8717 function getUntaintedPrototype$1(key) {
8718 if (untaintedBasePrototype$1[key]) return untaintedBasePrototype$1[key];
8719 var defaultObj = globalThis[key];
8720 var defaultPrototype = defaultObj.prototype;
8721 var accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
8722 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
8723 accessorNames.every(function(accessor) {
8724 var _a2, _b;
8725 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
8726 }));
8727 var methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
8728 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
8729 function(method) {
8730 var _a2;
8731 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
8732 }));
8733 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent$1()) {
8734 untaintedBasePrototype$1[key] = defaultObj.prototype;
8735 return defaultObj.prototype;
8736 }
8737 try {
8738 var iframeEl = document.createElement("iframe");
8739 document.body.appendChild(iframeEl);
8740 var win = iframeEl.contentWindow;
8741 if (!win) return defaultObj.prototype;
8742 var untaintedObject = win[key].prototype;
8743 document.body.removeChild(iframeEl);
8744 if (!untaintedObject) return defaultPrototype;
8745 return untaintedBasePrototype$1[key] = untaintedObject;
8746 } catch (e) {
8747 return defaultPrototype;
8748 }
8749 }
8750 var untaintedAccessorCache$1 = {};
8751 function getUntaintedAccessor$1(key, instance, accessor) {
8752 var _a2;
8753 var cacheKey = key + "." + String(accessor);
8754 if (untaintedAccessorCache$1[cacheKey]) return untaintedAccessorCache$1[cacheKey].call(instance);
8755 var untaintedPrototype = getUntaintedPrototype$1(key);
8756 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
8757 if (!untaintedAccessor) return instance[accessor];
8758 untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
8759 return untaintedAccessor.call(instance);
8760 }
8761 var untaintedMethodCache$1 = {};
8762 function getUntaintedMethod$1(key, instance, method) {
8763 var cacheKey = key + "." + String(method);
8764 if (untaintedMethodCache$1[cacheKey]) return untaintedMethodCache$1[cacheKey].bind(instance);
8765 var untaintedPrototype = getUntaintedPrototype$1(key);
8766 var untaintedMethod = untaintedPrototype[method];
8767 if (typeof untaintedMethod !== "function") return instance[method];
8768 untaintedMethodCache$1[cacheKey] = untaintedMethod;
8769 return untaintedMethod.bind(instance);
8770 }
8771 function childNodes$1(n2) {
8772 return getUntaintedAccessor$1("Node", n2, "childNodes");
8773 }
8774 function parentNode$1(n2) {
8775 return getUntaintedAccessor$1("Node", n2, "parentNode");
8776 }
8777 function parentElement$1(n2) {
8778 return getUntaintedAccessor$1("Node", n2, "parentElement");
8779 }
8780 function textContent$1(n2) {
8781 return getUntaintedAccessor$1("Node", n2, "textContent");
8782 }
8783 function contains$1(n2, other) {
8784 return getUntaintedMethod$1("Node", n2, "contains")(other);
8785 }
8786 function getRootNode$1(n2) {
8787 return getUntaintedMethod$1("Node", n2, "getRootNode")();
8788 }
8789 function host$1(n2) {
8790 if (!n2 || !("host" in n2)) return null;
8791 return getUntaintedAccessor$1("ShadowRoot", n2, "host");
8792 }
8793 function styleSheets$1(n2) {
8794 return n2.styleSheets;
8795 }
8796 function shadowRoot$1(n2) {
8797 if (!n2 || !("shadowRoot" in n2)) return null;
8798 return getUntaintedAccessor$1("Element", n2, "shadowRoot");
8799 }
8800 function querySelector$1(n2, selectors) {
8801 return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
8802 }
8803 function querySelectorAll$1(n2, selectors) {
8804 return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
8805 }
8806 function mutationObserverCtor$1() {
8807 return getUntaintedPrototype$1("MutationObserver").constructor;
8808 }
8809 function patch$1(source, name, replacement) {
8810 try {
8811 if (!(name in source)) {
8812 return function() {};
8813 }
8814 var original = source[name];
8815 var wrapped = replacement(original);
8816 if (typeof wrapped === "function") {
8817 wrapped.prototype = wrapped.prototype || {};
8818 Object.defineProperties(wrapped, {
8819 __rrweb_original__: {
8820 enumerable: false,
8821 value: original
8822 }
8823 });
8824 }
8825 source[name] = wrapped;
8826 return function() {
8827 source[name] = original;
8828 };
8829 } catch (e) {
8830 return function() {};
8831 }
8832 }
8833 var index$1 = {
8834 childNodes: childNodes$1,
8835 parentNode: parentNode$1,
8836 parentElement: parentElement$1,
8837 textContent: textContent$1,
8838 contains: contains$1,
8839 getRootNode: getRootNode$1,
8840 host: host$1,
8841 styleSheets: styleSheets$1,
8842 shadowRoot: shadowRoot$1,
8843 querySelector: querySelector$1,
8844 querySelectorAll: querySelectorAll$1,
8845 mutationObserver: mutationObserverCtor$1,
8846 patch: patch$1
8847 };
8848 function isElement(n2) {
8849 return n2.nodeType === n2.ELEMENT_NODE;
8850 }
8851 function isShadowRoot(n2) {
8852 var hostEl = // anchor and textarea elements also have a `host` property
8853 // but only shadow roots have a `mode` property
8854 n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null;
8855 return Boolean(hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2);
8856 }
8857 function isNativeShadowDom(shadowRoot2) {
8858 return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
8859 }
8860 function fixBrowserCompatibilityIssuesInCSS(cssText) {
8861 if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
8862 cssText = cssText.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;");
8863 }
8864 return cssText;
8865 }
8866 function escapeImportStatement(rule2) {
8867 var cssText = rule2.cssText;
8868 if (cssText.split('"').length < 3) return cssText;
8869 var statement = [
8870 "@import",
8871 "url(" + JSON.stringify(rule2.href) + ")"
8872 ];
8873 if (rule2.layerName === "") {
8874 statement.push("layer");
8875 } else if (rule2.layerName) {
8876 statement.push("layer(" + rule2.layerName + ")");
8877 }
8878 if (rule2.supportsText) {
8879 statement.push("supports(" + rule2.supportsText + ")");
8880 }
8881 if (rule2.media.length) {
8882 statement.push(rule2.media.mediaText);
8883 }
8884 return statement.join(" ") + ";";
8885 }
8886 function stringifyStylesheet(s2) {
8887 try {
8888 var rules2 = s2.rules || s2.cssRules;
8889 if (!rules2) {
8890 return null;
8891 }
8892 var sheetHref = s2.href;
8893 if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
8894 sheetHref = s2.ownerNode.ownerDocument.location.href;
8895 }
8896 var stringifiedRules = Array.from(rules2, function(rule2) {
8897 return stringifyRule(rule2, sheetHref);
8898 }).join("");
8899 return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
8900 } catch (error) {
8901 return null;
8902 }
8903 }
8904 function stringifyRule(rule2, sheetHref) {
8905 if (isCSSImportRule(rule2)) {
8906 var importStringified;
8907 try {
8908 importStringified = // we can access the imported stylesheet rules directly
8909 stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
8910 escapeImportStatement(rule2);
8911 } catch (error) {
8912 importStringified = rule2.cssText;
8913 }
8914 if (rule2.styleSheet.href) {
8915 return absolutifyURLs(importStringified, rule2.styleSheet.href);
8916 }
8917 return importStringified;
8918 } else {
8919 var ruleStringified = rule2.cssText;
8920 if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
8921 ruleStringified = fixSafariColons(ruleStringified);
8922 }
8923 if (sheetHref) {
8924 return absolutifyURLs(ruleStringified, sheetHref);
8925 }
8926 return ruleStringified;
8927 }
8928 }
8929 function fixSafariColons(cssStringified) {
8930 var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
8931 return cssStringified.replace(regex, "$1\\$2");
8932 }
8933 function isCSSImportRule(rule2) {
8934 return "styleSheet" in rule2;
8935 }
8936 function isCSSStyleRule(rule2) {
8937 return "selectorText" in rule2;
8938 }
8939 var Mirror = /*#__PURE__*/ function() {
8940 function Mirror() {
8941 __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
8942 __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
8943 }
8944 var _proto = Mirror.prototype;
8945 _proto.getId = function getId(n2) {
8946 var _a2;
8947 if (!n2) return -1;
8948 var id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id;
8949 return id != null ? id : -1;
8950 };
8951 _proto.getNode = function getNode(id) {
8952 return this.idNodeMap.get(id) || null;
8953 };
8954 _proto.getIds = function getIds() {
8955 return Array.from(this.idNodeMap.keys());
8956 };
8957 _proto.getMeta = function getMeta(n2) {
8958 return this.nodeMetaMap.get(n2) || null;
8959 };
8960 // removes the node from idNodeMap
8961 // doesn't remove the node from nodeMetaMap
8962 _proto.removeNodeFromMap = function removeNodeFromMap(n2) {
8963 var _this = this;
8964 var id = this.getId(n2);
8965 this.idNodeMap.delete(id);
8966 if (n2.childNodes) {
8967 n2.childNodes.forEach(function(childNode) {
8968 return _this.removeNodeFromMap(childNode);
8969 });
8970 }
8971 };
8972 _proto.has = function has(id) {
8973 return this.idNodeMap.has(id);
8974 };
8975 _proto.hasNode = function hasNode(node2) {
8976 return this.nodeMetaMap.has(node2);
8977 };
8978 _proto.add = function add(n2, meta) {
8979 var id = meta.id;
8980 this.idNodeMap.set(id, n2);
8981 this.nodeMetaMap.set(n2, meta);
8982 };
8983 _proto.replace = function replace(id, n2) {
8984 var oldNode = this.getNode(id);
8985 if (oldNode) {
8986 var meta = this.nodeMetaMap.get(oldNode);
8987 if (meta) this.nodeMetaMap.set(n2, meta);
8988 }
8989 this.idNodeMap.set(id, n2);
8990 };
8991 _proto.reset = function reset() {
8992 this.idNodeMap = /* @__PURE__ */ new Map();
8993 this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
8994 };
8995 return Mirror;
8996 }();
8997 function createMirror$2() {
8998 return new Mirror();
8999 }
9000 function maskInputValue(param) {
9001 var element = param.element, maskInputOptions = param.maskInputOptions, tagName = param.tagName, type = param.type, value = param.value, maskInputFn = param.maskInputFn;
9002 var text = value || "";
9003 var actualType = type && toLowerCase(type);
9004 if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
9005 if (maskInputFn) {
9006 text = maskInputFn(text, element);
9007 } else {
9008 text = "*".repeat(text.length);
9009 }
9010 }
9011 return text;
9012 }
9013 function toLowerCase(str) {
9014 return str.toLowerCase();
9015 }
9016 var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
9017 function is2DCanvasBlank(canvas) {
9018 var ctx = canvas.getContext("2d");
9019 if (!ctx) return true;
9020 var chunkSize = 50;
9021 for(var x2 = 0; x2 < canvas.width; x2 += chunkSize){
9022 for(var y = 0; y < canvas.height; y += chunkSize){
9023 var getImageData = ctx.getImageData;
9024 var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
9025 var pixelBuffer = new Uint32Array(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
9026 originalGetImageData.call(ctx, x2, y, Math.min(chunkSize, canvas.width - x2), Math.min(chunkSize, canvas.height - y)).data.buffer);
9027 if (pixelBuffer.some(function(pixel) {
9028 return pixel !== 0;
9029 })) return false;
9030 }
9031 }
9032 return true;
9033 }
9034 function getInputType(element) {
9035 var type = element.type;
9036 return element.hasAttribute("data-rr-is-password") ? "password" : type ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
9037 toLowerCase(type) : null;
9038 }
9039 function extractFileExtension(path, baseURL) {
9040 var url;
9041 try {
9042 url = new URL(path, baseURL != null ? baseURL : window.location.href);
9043 } catch (err) {
9044 return null;
9045 }
9046 var regex = /\.([0-9a-z]+)(?:$)/i;
9047 var match = url.pathname.match(regex);
9048 var _ref;
9049 return (_ref = match == null ? void 0 : match[1]) != null ? _ref : null;
9050 }
9051 function extractOrigin(url) {
9052 var origin = "";
9053 if (url.indexOf("//") > -1) {
9054 origin = url.split("/").slice(0, 3).join("/");
9055 } else {
9056 origin = url.split("/")[0];
9057 }
9058 origin = origin.split("?")[0];
9059 return origin;
9060 }
9061 var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
9062 var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
9063 var URL_WWW_MATCH = /^www\..*/i;
9064 var DATA_URI = /^(data:)([^,]*),(.*)/i;
9065 function absolutifyURLs(cssText, href) {
9066 return (cssText || "").replace(URL_IN_CSS_REF, function(origin, quote1, path1, quote2, path2, path3) {
9067 var filePath = path1 || path2 || path3;
9068 var maybeQuote = quote1 || quote2 || "";
9069 if (!filePath) {
9070 return origin;
9071 }
9072 if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
9073 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9074 }
9075 if (DATA_URI.test(filePath)) {
9076 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9077 }
9078 if (filePath[0] === "/") {
9079 return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
9080 }
9081 var stack = href.split("/");
9082 var parts = filePath.split("/");
9083 stack.pop();
9084 for(var _iterator = _create_for_of_iterator_helper_loose(parts), _step; !(_step = _iterator()).done;){
9085 var part = _step.value;
9086 if (part === ".") {
9087 continue;
9088 } else if (part === "..") {
9089 stack.pop();
9090 } else {
9091 stack.push(part);
9092 }
9093 }
9094 return "url(" + maybeQuote + stack.join("/") + maybeQuote + ")";
9095 });
9096 }
9097 function normalizeCssString(cssText, _testNoPxNorm) {
9098 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9099 if (_testNoPxNorm) {
9100 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
9101 } else {
9102 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
9103 }
9104 }
9105 function splitCssText(cssText, style, _testNoPxNorm) {
9106 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9107 var childNodes2 = Array.from(style.childNodes);
9108 var splits = [];
9109 var iterCount = 0;
9110 if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
9111 var cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
9112 var normFactor = cssTextNorm.length / cssText.length;
9113 for(var i2 = 1; i2 < childNodes2.length; i2++){
9114 if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
9115 var textContentNorm = normalizeCssString(childNodes2[i2].textContent, _testNoPxNorm);
9116 var jLimit = 100;
9117 var j = 3;
9118 for(; j < textContentNorm.length; j++){
9119 if (// keep consuming css identifiers (to get a decent chunk more quickly)
9120 textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
9121 textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1) {
9122 continue;
9123 }
9124 break;
9125 }
9126 for(; j < textContentNorm.length; j++){
9127 var startSubstring = textContentNorm.substring(0, j);
9128 var cssNormSplits = cssTextNorm.split(startSubstring);
9129 var splitNorm = -1;
9130 if (cssNormSplits.length === 2) {
9131 splitNorm = cssNormSplits[0].length;
9132 } else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
9133 splitNorm = cssTextNorm.indexOf(startSubstring, 1);
9134 } else if (cssNormSplits.length === 1) {
9135 startSubstring = startSubstring.substring(0, startSubstring.length - 1);
9136 cssNormSplits = cssTextNorm.split(startSubstring);
9137 if (cssNormSplits.length <= 1) {
9138 splits.push(cssText);
9139 return splits;
9140 }
9141 j = jLimit + 1;
9142 } else if (j === textContentNorm.length - 1) {
9143 splitNorm = cssTextNorm.indexOf(startSubstring);
9144 }
9145 if (cssNormSplits.length >= 2 && j > jLimit) {
9146 var prevTextContent = childNodes2[i2 - 1].textContent;
9147 if (prevTextContent && typeof prevTextContent === "string") {
9148 var prevMinLength = normalizeCssString(prevTextContent).length;
9149 splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
9150 }
9151 if (splitNorm === -1) {
9152 splitNorm = cssNormSplits[0].length;
9153 }
9154 }
9155 if (splitNorm !== -1) {
9156 var k = Math.floor(splitNorm / normFactor);
9157 for(; k > 0 && k < cssText.length;){
9158 iterCount += 1;
9159 if (iterCount > 50 * childNodes2.length) {
9160 splits.push(cssText);
9161 return splits;
9162 }
9163 var normPart = normalizeCssString(cssText.substring(0, k), _testNoPxNorm);
9164 if (normPart.length === splitNorm) {
9165 splits.push(cssText.substring(0, k));
9166 cssText = cssText.substring(k);
9167 cssTextNorm = cssTextNorm.substring(splitNorm);
9168 break;
9169 } else if (normPart.length < splitNorm) {
9170 k += Math.max(1, Math.floor((splitNorm - normPart.length) / normFactor));
9171 } else {
9172 k -= Math.max(1, Math.floor((normPart.length - splitNorm) * normFactor));
9173 }
9174 }
9175 break;
9176 }
9177 }
9178 }
9179 }
9180 }
9181 splits.push(cssText);
9182 return splits;
9183 }
9184 function markCssSplits(cssText, style) {
9185 return splitCssText(cssText, style).join("/* rr_split */");
9186 }
9187 var _id = 1;
9188 var tagNameRegex = new RegExp("[^a-z0-9-_:]");
9189 var IGNORED_NODE = -2;
9190 function genId() {
9191 return _id++;
9192 }
9193 function getValidTagName$1(element) {
9194 if (_instanceof(element, HTMLFormElement)) {
9195 return "form";
9196 }
9197 var processedTagName = toLowerCase(element.tagName);
9198 if (tagNameRegex.test(processedTagName)) {
9199 return "div";
9200 }
9201 return processedTagName;
9202 }
9203 var canvasService;
9204 var canvasCtx;
9205 var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
9206 var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
9207 function getAbsoluteSrcsetString(doc, attributeValue) {
9208 if (attributeValue.trim() === "") {
9209 return attributeValue;
9210 }
9211 var pos = 0;
9212 function collectCharacters(regEx) {
9213 var chars2;
9214 var match = regEx.exec(attributeValue.substring(pos));
9215 if (match) {
9216 chars2 = match[0];
9217 pos += chars2.length;
9218 return chars2;
9219 }
9220 return "";
9221 }
9222 var output = [];
9223 while(true){
9224 collectCharacters(SRCSET_COMMAS_OR_SPACES);
9225 if (pos >= attributeValue.length) {
9226 break;
9227 }
9228 var url = collectCharacters(SRCSET_NOT_SPACES);
9229 if (url.slice(-1) === ",") {
9230 url = absoluteToDoc(doc, url.substring(0, url.length - 1));
9231 output.push(url);
9232 } else {
9233 var descriptorsStr = "";
9234 url = absoluteToDoc(doc, url);
9235 var inParens = false;
9236 while(true){
9237 var c2 = attributeValue.charAt(pos);
9238 if (c2 === "") {
9239 output.push((url + descriptorsStr).trim());
9240 break;
9241 } else if (!inParens) {
9242 if (c2 === ",") {
9243 pos += 1;
9244 output.push((url + descriptorsStr).trim());
9245 break;
9246 } else if (c2 === "(") {
9247 inParens = true;
9248 }
9249 } else {
9250 if (c2 === ")") {
9251 inParens = false;
9252 }
9253 }
9254 descriptorsStr += c2;
9255 pos += 1;
9256 }
9257 }
9258 }
9259 return output.join(", ");
9260 }
9261 var cachedDocument = /* @__PURE__ */ new WeakMap();
9262 function absoluteToDoc(doc, attributeValue) {
9263 if (!attributeValue || attributeValue.trim() === "") {
9264 return attributeValue;
9265 }
9266 return getHref(doc, attributeValue);
9267 }
9268 function isSVGElement(el) {
9269 return Boolean(el.tagName === "svg" || el.ownerSVGElement);
9270 }
9271 function getHref(doc, customHref) {
9272 var a2 = cachedDocument.get(doc);
9273 if (!a2) {
9274 a2 = doc.createElement("a");
9275 cachedDocument.set(doc, a2);
9276 }
9277 if (!customHref) {
9278 customHref = "";
9279 } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
9280 return customHref;
9281 }
9282 a2.setAttribute("href", customHref);
9283 return a2.href;
9284 }
9285 function transformAttribute(doc, tagName, name, value) {
9286 if (!value) {
9287 return value;
9288 }
9289 if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
9290 return absoluteToDoc(doc, value);
9291 } else if (name === "xlink:href" && value[0] !== "#") {
9292 return absoluteToDoc(doc, value);
9293 } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
9294 return absoluteToDoc(doc, value);
9295 } else if (name === "srcset") {
9296 return getAbsoluteSrcsetString(doc, value);
9297 } else if (name === "style") {
9298 return absolutifyURLs(value, getHref(doc));
9299 } else if (tagName === "object" && name === "data") {
9300 return absoluteToDoc(doc, value);
9301 }
9302 return value;
9303 }
9304 function ignoreAttribute(tagName, name, _value) {
9305 return (tagName === "video" || tagName === "audio") && name === "autoplay";
9306 }
9307 function _isBlockedElement(element, blockClass, blockSelector) {
9308 try {
9309 if (typeof blockClass === "string") {
9310 if (element.classList.contains(blockClass)) {
9311 return true;
9312 }
9313 } else {
9314 for(var eIndex = element.classList.length; eIndex--;){
9315 var className = element.classList[eIndex];
9316 if (blockClass.test(className)) {
9317 return true;
9318 }
9319 }
9320 }
9321 if (blockSelector) {
9322 return element.matches(blockSelector);
9323 }
9324 } catch (e2) {}
9325 return false;
9326 }
9327 function classMatchesRegex(node2, regex, checkAncestors) {
9328 if (!node2) return false;
9329 if (node2.nodeType !== node2.ELEMENT_NODE) {
9330 if (!checkAncestors) return false;
9331 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9332 }
9333 for(var eIndex = node2.classList.length; eIndex--;){
9334 var className = node2.classList[eIndex];
9335 if (regex.test(className)) {
9336 return true;
9337 }
9338 }
9339 if (!checkAncestors) return false;
9340 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9341 }
9342 function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
9343 var el;
9344 if (isElement(node2)) {
9345 el = node2;
9346 if (!index$1.childNodes(el).length) {
9347 return false;
9348 }
9349 } else if (index$1.parentElement(node2) === null) {
9350 return false;
9351 } else {
9352 el = index$1.parentElement(node2);
9353 }
9354 try {
9355 if (typeof maskTextClass === "string") {
9356 if (checkAncestors) {
9357 if (el.closest("." + maskTextClass)) return true;
9358 } else {
9359 if (el.classList.contains(maskTextClass)) return true;
9360 }
9361 } else {
9362 if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
9363 }
9364 if (maskTextSelector) {
9365 if (checkAncestors) {
9366 if (el.closest(maskTextSelector)) return true;
9367 } else {
9368 if (el.matches(maskTextSelector)) return true;
9369 }
9370 }
9371 } catch (e2) {}
9372 return false;
9373 }
9374 function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
9375 var win = iframeEl.contentWindow;
9376 if (!win) {
9377 return;
9378 }
9379 var fired = false;
9380 var readyState;
9381 try {
9382 readyState = win.document.readyState;
9383 } catch (error) {
9384 return;
9385 }
9386 if (readyState !== "complete") {
9387 var timer = setTimeout(function() {
9388 if (!fired) {
9389 listener();
9390 fired = true;
9391 }
9392 }, iframeLoadTimeout);
9393 iframeEl.addEventListener("load", function() {
9394 clearTimeout(timer);
9395 fired = true;
9396 listener();
9397 });
9398 return;
9399 }
9400 var blankUrl = "about:blank";
9401 if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
9402 setTimeout(listener, 0);
9403 return iframeEl.addEventListener("load", listener);
9404 }
9405 iframeEl.addEventListener("load", listener);
9406 }
9407 function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
9408 var fired = false;
9409 var styleSheetLoaded;
9410 try {
9411 styleSheetLoaded = link.sheet;
9412 } catch (error) {
9413 return;
9414 }
9415 if (styleSheetLoaded) return;
9416 var timer = setTimeout(function() {
9417 if (!fired) {
9418 listener();
9419 fired = true;
9420 }
9421 }, styleSheetLoadTimeout);
9422 link.addEventListener("load", function() {
9423 clearTimeout(timer);
9424 fired = true;
9425 listener();
9426 });
9427 }
9428 function serializeNode(n2, options) {
9429 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;
9430 var rootId = getRootId(doc, mirror2);
9431 switch(n2.nodeType){
9432 case n2.DOCUMENT_NODE:
9433 if (n2.compatMode !== "CSS1Compat") {
9434 return {
9435 type: NodeType$3.Document,
9436 childNodes: [],
9437 compatMode: n2.compatMode
9438 };
9439 } else {
9440 return {
9441 type: NodeType$3.Document,
9442 childNodes: []
9443 };
9444 }
9445 case n2.DOCUMENT_TYPE_NODE:
9446 return {
9447 type: NodeType$3.DocumentType,
9448 name: n2.name,
9449 publicId: n2.publicId,
9450 systemId: n2.systemId,
9451 rootId: rootId
9452 };
9453 case n2.ELEMENT_NODE:
9454 return serializeElementNode(n2, {
9455 doc: doc,
9456 blockClass: blockClass,
9457 blockSelector: blockSelector,
9458 inlineStylesheet: inlineStylesheet,
9459 maskInputOptions: maskInputOptions,
9460 maskInputFn: maskInputFn,
9461 dataURLOptions: dataURLOptions,
9462 inlineImages: inlineImages,
9463 recordCanvas: recordCanvas,
9464 keepIframeSrcFn: keepIframeSrcFn,
9465 newlyAddedElement: newlyAddedElement,
9466 rootId: rootId
9467 });
9468 case n2.TEXT_NODE:
9469 return serializeTextNode(n2, {
9470 doc: doc,
9471 needsMask: needsMask,
9472 maskTextFn: maskTextFn,
9473 rootId: rootId,
9474 cssCaptured: cssCaptured
9475 });
9476 case n2.CDATA_SECTION_NODE:
9477 return {
9478 type: NodeType$3.CDATA,
9479 textContent: "",
9480 rootId: rootId
9481 };
9482 case n2.COMMENT_NODE:
9483 return {
9484 type: NodeType$3.Comment,
9485 textContent: index$1.textContent(n2) || "",
9486 rootId: rootId
9487 };
9488 default:
9489 return false;
9490 }
9491 }
9492 function getRootId(doc, mirror2) {
9493 if (!mirror2.hasNode(doc)) return void 0;
9494 var docId = mirror2.getId(doc);
9495 return docId === 1 ? void 0 : docId;
9496 }
9497 function serializeTextNode(n2, options) {
9498 var needsMask = options.needsMask, maskTextFn = options.maskTextFn, rootId = options.rootId, cssCaptured = options.cssCaptured;
9499 var parent = index$1.parentNode(n2);
9500 var parentTagName = parent && parent.tagName;
9501 var textContent2 = "";
9502 var isStyle = parentTagName === "STYLE" ? true : void 0;
9503 var isScript = parentTagName === "SCRIPT" ? true : void 0;
9504 if (isScript) {
9505 textContent2 = "SCRIPT_PLACEHOLDER";
9506 } else if (!cssCaptured) {
9507 textContent2 = index$1.textContent(n2);
9508 if (isStyle && textContent2) {
9509 textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
9510 }
9511 }
9512 if (!isStyle && !isScript && textContent2 && needsMask) {
9513 textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
9514 }
9515 return {
9516 type: NodeType$3.Text,
9517 textContent: textContent2 || "",
9518 rootId: rootId
9519 };
9520 }
9521 function serializeElementNode(n2, options) {
9522 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;
9523 var needBlock = _isBlockedElement(n2, blockClass, blockSelector);
9524 var tagName = getValidTagName$1(n2);
9525 var attributes = {};
9526 var len = n2.attributes.length;
9527 for(var i2 = 0; i2 < len; i2++){
9528 var attr = n2.attributes[i2];
9529 if (!ignoreAttribute(tagName, attr.name, attr.value)) {
9530 attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
9531 }
9532 }
9533 if (tagName === "link" && inlineStylesheet) {
9534 var stylesheet = Array.from(doc.styleSheets).find(function(s2) {
9535 return s2.href === n2.href;
9536 });
9537 var cssText = null;
9538 if (stylesheet) {
9539 cssText = stringifyStylesheet(stylesheet);
9540 }
9541 if (cssText) {
9542 delete attributes.rel;
9543 delete attributes.href;
9544 attributes._cssText = cssText;
9545 }
9546 }
9547 if (tagName === "style" && n2.sheet) {
9548 var cssText1 = stringifyStylesheet(n2.sheet);
9549 if (cssText1) {
9550 if (n2.childNodes.length > 1) {
9551 cssText1 = markCssSplits(cssText1, n2);
9552 }
9553 attributes._cssText = cssText1;
9554 }
9555 }
9556 if (tagName === "input" || tagName === "textarea" || tagName === "select") {
9557 var value = n2.value;
9558 var checked = n2.checked;
9559 if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
9560 attributes.value = maskInputValue({
9561 element: n2,
9562 type: getInputType(n2),
9563 tagName: tagName,
9564 value: value,
9565 maskInputOptions: maskInputOptions,
9566 maskInputFn: maskInputFn
9567 });
9568 } else if (checked) {
9569 attributes.checked = checked;
9570 }
9571 }
9572 if (tagName === "option") {
9573 if (n2.selected && !maskInputOptions["select"]) {
9574 attributes.selected = true;
9575 } else {
9576 delete attributes.selected;
9577 }
9578 }
9579 if (tagName === "dialog" && n2.open) {
9580 attributes.rr_open_mode = n2.matches("dialog:modal") ? "modal" : "non-modal";
9581 }
9582 if (tagName === "canvas" && recordCanvas) {
9583 if (n2.__context === "2d") {
9584 if (!is2DCanvasBlank(n2)) {
9585 attributes.rr_dataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9586 }
9587 } else if (!("__context" in n2)) {
9588 var canvasDataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9589 var blankCanvas = doc.createElement("canvas");
9590 blankCanvas.width = n2.width;
9591 blankCanvas.height = n2.height;
9592 var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9593 if (canvasDataURL !== blankCanvasDataURL) {
9594 attributes.rr_dataURL = canvasDataURL;
9595 }
9596 }
9597 }
9598 if (tagName === "img" && inlineImages) {
9599 if (!canvasService) {
9600 canvasService = doc.createElement("canvas");
9601 canvasCtx = canvasService.getContext("2d");
9602 }
9603 var image = n2;
9604 var imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
9605 var priorCrossOrigin = image.crossOrigin;
9606 var recordInlineImage = function() {
9607 image.removeEventListener("load", recordInlineImage);
9608 try {
9609 canvasService.width = image.naturalWidth;
9610 canvasService.height = image.naturalHeight;
9611 canvasCtx.drawImage(image, 0, 0);
9612 attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9613 } catch (err) {
9614 if (image.crossOrigin !== "anonymous") {
9615 image.crossOrigin = "anonymous";
9616 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
9617 else image.addEventListener("load", recordInlineImage);
9618 return;
9619 } else {
9620 console.warn("Cannot inline img src=" + imageSrc + "! Error: " + err);
9621 }
9622 }
9623 if (image.crossOrigin === "anonymous") {
9624 priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
9625 }
9626 };
9627 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
9628 else image.addEventListener("load", recordInlineImage);
9629 }
9630 if (tagName === "audio" || tagName === "video") {
9631 var mediaAttributes = attributes;
9632 mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
9633 mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
9634 mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
9635 mediaAttributes.rr_mediaMuted = n2.muted;
9636 mediaAttributes.rr_mediaLoop = n2.loop;
9637 mediaAttributes.rr_mediaVolume = n2.volume;
9638 }
9639 if (!newlyAddedElement) {
9640 if (n2.scrollLeft) {
9641 attributes.rr_scrollLeft = n2.scrollLeft;
9642 }
9643 if (n2.scrollTop) {
9644 attributes.rr_scrollTop = n2.scrollTop;
9645 }
9646 }
9647 if (needBlock) {
9648 var _n2_getBoundingClientRect = n2.getBoundingClientRect(), width = _n2_getBoundingClientRect.width, height = _n2_getBoundingClientRect.height;
9649 attributes = {
9650 class: attributes.class,
9651 rr_width: "" + width + "px",
9652 rr_height: "" + height + "px"
9653 };
9654 }
9655 if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
9656 if (!n2.contentDocument) {
9657 attributes.rr_src = attributes.src;
9658 }
9659 delete attributes.src;
9660 }
9661 var isCustomElement;
9662 try {
9663 if (customElements.get(tagName)) isCustomElement = true;
9664 } catch (e2) {}
9665 return {
9666 type: NodeType$3.Element,
9667 tagName: tagName,
9668 attributes: attributes,
9669 childNodes: [],
9670 isSVG: isSVGElement(n2) || void 0,
9671 needBlock: needBlock,
9672 rootId: rootId,
9673 isCustom: isCustomElement
9674 };
9675 }
9676 function lowerIfExists(maybeAttr) {
9677 if (maybeAttr === void 0 || maybeAttr === null) {
9678 return "";
9679 } else {
9680 return maybeAttr.toLowerCase();
9681 }
9682 }
9683 function slimDOMExcluded(sn, slimDOMOptions) {
9684 if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
9685 return true;
9686 } else if (sn.type === NodeType$3.Element) {
9687 if (slimDOMOptions.script && // script tag
9688 (sn.tagName === "script" || // (module)preload link
9689 sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
9690 sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
9691 return true;
9692 } 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"))) {
9693 return true;
9694 } else if (sn.tagName === "meta") {
9695 if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
9696 return true;
9697 } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
9698 lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
9699 return true;
9700 } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
9701 return true;
9702 } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
9703 return true;
9704 } 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:/))) {
9705 return true;
9706 } 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")) {
9707 return true;
9708 }
9709 }
9710 }
9711 return false;
9712 }
9713 function serializeNodeWithId(n2, options) {
9714 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() {
9715 return false;
9716 } : _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;
9717 var needsMask = options.needsMask;
9718 var _options_preserveWhiteSpace = options.preserveWhiteSpace, preserveWhiteSpace = _options_preserveWhiteSpace === void 0 ? true : _options_preserveWhiteSpace;
9719 if (!needsMask) {
9720 var checkAncestors = needsMask === void 0;
9721 needsMask = needMaskingText(n2, maskTextClass, maskTextSelector, checkAncestors);
9722 }
9723 var _serializedNode = serializeNode(n2, {
9724 doc: doc,
9725 mirror: mirror2,
9726 blockClass: blockClass,
9727 blockSelector: blockSelector,
9728 needsMask: needsMask,
9729 inlineStylesheet: inlineStylesheet,
9730 maskInputOptions: maskInputOptions,
9731 maskTextFn: maskTextFn,
9732 maskInputFn: maskInputFn,
9733 dataURLOptions: dataURLOptions,
9734 inlineImages: inlineImages,
9735 recordCanvas: recordCanvas,
9736 keepIframeSrcFn: keepIframeSrcFn,
9737 newlyAddedElement: newlyAddedElement,
9738 cssCaptured: cssCaptured
9739 });
9740 if (!_serializedNode) {
9741 console.warn(n2, "not serialized");
9742 return null;
9743 }
9744 var id;
9745 if (mirror2.hasNode(n2)) {
9746 id = mirror2.getId(n2);
9747 } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
9748 id = IGNORED_NODE;
9749 } else {
9750 id = genId();
9751 }
9752 var serializedNode = Object.assign(_serializedNode, {
9753 id: id
9754 });
9755 mirror2.add(n2, serializedNode);
9756 if (id === IGNORED_NODE) {
9757 return null;
9758 }
9759 if (onSerialize) {
9760 onSerialize(n2);
9761 }
9762 var recordChild = !skipChild;
9763 if (serializedNode.type === NodeType$3.Element) {
9764 recordChild = recordChild && !serializedNode.needBlock;
9765 delete serializedNode.needBlock;
9766 var shadowRootEl = index$1.shadowRoot(n2);
9767 if (shadowRootEl && isNativeShadowDom(shadowRootEl)) serializedNode.isShadowHost = true;
9768 }
9769 if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
9770 if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
9771 preserveWhiteSpace = false;
9772 }
9773 var bypassOptions = {
9774 doc: doc,
9775 mirror: mirror2,
9776 blockClass: blockClass,
9777 blockSelector: blockSelector,
9778 needsMask: needsMask,
9779 maskTextClass: maskTextClass,
9780 maskTextSelector: maskTextSelector,
9781 skipChild: skipChild,
9782 inlineStylesheet: inlineStylesheet,
9783 maskInputOptions: maskInputOptions,
9784 maskTextFn: maskTextFn,
9785 maskInputFn: maskInputFn,
9786 slimDOMOptions: slimDOMOptions,
9787 dataURLOptions: dataURLOptions,
9788 inlineImages: inlineImages,
9789 recordCanvas: recordCanvas,
9790 preserveWhiteSpace: preserveWhiteSpace,
9791 onSerialize: onSerialize,
9792 onIframeLoad: onIframeLoad,
9793 iframeLoadTimeout: iframeLoadTimeout,
9794 onStylesheetLoad: onStylesheetLoad,
9795 stylesheetLoadTimeout: stylesheetLoadTimeout,
9796 keepIframeSrcFn: keepIframeSrcFn,
9797 cssCaptured: false
9798 };
9799 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
9800 else {
9801 if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
9802 bypassOptions.cssCaptured = true;
9803 }
9804 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(n2))), _step; !(_step = _iterator()).done;){
9805 var childN = _step.value;
9806 var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
9807 if (serializedChildNode) {
9808 serializedNode.childNodes.push(serializedChildNode);
9809 }
9810 }
9811 }
9812 var shadowRootEl1 = null;
9813 if (isElement(n2) && (shadowRootEl1 = index$1.shadowRoot(n2))) {
9814 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(shadowRootEl1))), _step1; !(_step1 = _iterator1()).done;){
9815 var childN1 = _step1.value;
9816 var serializedChildNode1 = serializeNodeWithId(childN1, bypassOptions);
9817 if (serializedChildNode1) {
9818 isNativeShadowDom(shadowRootEl1) && (serializedChildNode1.isShadow = true);
9819 serializedNode.childNodes.push(serializedChildNode1);
9820 }
9821 }
9822 }
9823 }
9824 var parent = index$1.parentNode(n2);
9825 if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
9826 serializedNode.isShadow = true;
9827 }
9828 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
9829 onceIframeLoaded(n2, function() {
9830 var iframeDoc = n2.contentDocument;
9831 if (iframeDoc && onIframeLoad) {
9832 var serializedIframeNode = serializeNodeWithId(iframeDoc, {
9833 doc: iframeDoc,
9834 mirror: mirror2,
9835 blockClass: blockClass,
9836 blockSelector: blockSelector,
9837 needsMask: needsMask,
9838 maskTextClass: maskTextClass,
9839 maskTextSelector: maskTextSelector,
9840 skipChild: false,
9841 inlineStylesheet: inlineStylesheet,
9842 maskInputOptions: maskInputOptions,
9843 maskTextFn: maskTextFn,
9844 maskInputFn: maskInputFn,
9845 slimDOMOptions: slimDOMOptions,
9846 dataURLOptions: dataURLOptions,
9847 inlineImages: inlineImages,
9848 recordCanvas: recordCanvas,
9849 preserveWhiteSpace: preserveWhiteSpace,
9850 onSerialize: onSerialize,
9851 onIframeLoad: onIframeLoad,
9852 iframeLoadTimeout: iframeLoadTimeout,
9853 onStylesheetLoad: onStylesheetLoad,
9854 stylesheetLoadTimeout: stylesheetLoadTimeout,
9855 keepIframeSrcFn: keepIframeSrcFn
9856 });
9857 if (serializedIframeNode) {
9858 onIframeLoad(n2, serializedIframeNode);
9859 }
9860 }
9861 }, iframeLoadTimeout);
9862 }
9863 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")) {
9864 onceStylesheetLoaded(n2, function() {
9865 if (onStylesheetLoad) {
9866 var serializedLinkNode = serializeNodeWithId(n2, {
9867 doc: doc,
9868 mirror: mirror2,
9869 blockClass: blockClass,
9870 blockSelector: blockSelector,
9871 needsMask: needsMask,
9872 maskTextClass: maskTextClass,
9873 maskTextSelector: maskTextSelector,
9874 skipChild: false,
9875 inlineStylesheet: inlineStylesheet,
9876 maskInputOptions: maskInputOptions,
9877 maskTextFn: maskTextFn,
9878 maskInputFn: maskInputFn,
9879 slimDOMOptions: slimDOMOptions,
9880 dataURLOptions: dataURLOptions,
9881 inlineImages: inlineImages,
9882 recordCanvas: recordCanvas,
9883 preserveWhiteSpace: preserveWhiteSpace,
9884 onSerialize: onSerialize,
9885 onIframeLoad: onIframeLoad,
9886 iframeLoadTimeout: iframeLoadTimeout,
9887 onStylesheetLoad: onStylesheetLoad,
9888 stylesheetLoadTimeout: stylesheetLoadTimeout,
9889 keepIframeSrcFn: keepIframeSrcFn
9890 });
9891 if (serializedLinkNode) {
9892 onStylesheetLoad(n2, serializedLinkNode);
9893 }
9894 }
9895 }, stylesheetLoadTimeout);
9896 }
9897 return serializedNode;
9898 }
9899 function snapshot(n2, options) {
9900 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() {
9901 return false;
9902 } : _ref_keepIframeSrcFn;
9903 var maskInputOptions = maskAllInputs === true ? {
9904 color: true,
9905 date: true,
9906 "datetime-local": true,
9907 email: true,
9908 month: true,
9909 number: true,
9910 range: true,
9911 search: true,
9912 tel: true,
9913 text: true,
9914 time: true,
9915 url: true,
9916 week: true,
9917 textarea: true,
9918 select: true,
9919 password: true,
9920 hidden: true
9921 } : maskAllInputs === false ? {
9922 password: true
9923 } : maskAllInputs;
9924 var slimDOMOptions = slimDOM === true || slimDOM === "all" ? // if true: set of sensible options that should not throw away any information
9925 {
9926 script: true,
9927 comment: true,
9928 headFavicon: true,
9929 headWhitespace: true,
9930 headMetaDescKeywords: slimDOM === "all",
9931 // destructive
9932 headMetaSocial: true,
9933 headMetaRobots: true,
9934 headMetaHttpEquiv: true,
9935 headMetaAuthorship: true,
9936 headMetaVerification: true
9937 } : slimDOM === false ? {} : slimDOM;
9938 return serializeNodeWithId(n2, {
9939 doc: n2,
9940 mirror: mirror2,
9941 blockClass: blockClass,
9942 blockSelector: blockSelector,
9943 maskTextClass: maskTextClass,
9944 maskTextSelector: maskTextSelector,
9945 skipChild: false,
9946 inlineStylesheet: inlineStylesheet,
9947 maskInputOptions: maskInputOptions,
9948 maskTextFn: maskTextFn,
9949 maskInputFn: maskInputFn,
9950 slimDOMOptions: slimDOMOptions,
9951 dataURLOptions: dataURLOptions,
9952 inlineImages: inlineImages,
9953 recordCanvas: recordCanvas,
9954 preserveWhiteSpace: preserveWhiteSpace,
9955 onSerialize: onSerialize,
9956 onIframeLoad: onIframeLoad,
9957 iframeLoadTimeout: iframeLoadTimeout,
9958 onStylesheetLoad: onStylesheetLoad,
9959 stylesheetLoadTimeout: stylesheetLoadTimeout,
9960 keepIframeSrcFn: keepIframeSrcFn,
9961 newlyAddedElement: false
9962 });
9963 }
9964 function getDefaultExportFromCjs$1(x2) {
9965 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
9966 }
9967 function getAugmentedNamespace$1(n2) {
9968 if (n2.__esModule) return n2;
9969 var f2 = n2.default;
9970 if (typeof f2 == "function") {
9971 var a2 = function a22() {
9972 if (_instanceof(this, a22)) {
9973 return Reflect.construct(f2, arguments, this.constructor);
9974 }
9975 return f2.apply(this, arguments);
9976 };
9977 a2.prototype = f2.prototype;
9978 } else a2 = {};
9979 Object.defineProperty(a2, "__esModule", {
9980 value: true
9981 });
9982 Object.keys(n2).forEach(function(k) {
9983 var d = Object.getOwnPropertyDescriptor(n2, k);
9984 Object.defineProperty(a2, k, d.get ? d : {
9985 enumerable: true,
9986 get: function get() {
9987 return n2[k];
9988 }
9989 });
9990 });
9991 return a2;
9992 }
9993 var picocolors_browser$1 = {
9994 exports: {}
9995 };
9996 var x$1 = String;
9997 var create$1 = function create$1() {
9998 return {
9999 isColorSupported: false,
10000 reset: x$1,
10001 bold: x$1,
10002 dim: x$1,
10003 italic: x$1,
10004 underline: x$1,
10005 inverse: x$1,
10006 hidden: x$1,
10007 strikethrough: x$1,
10008 black: x$1,
10009 red: x$1,
10010 green: x$1,
10011 yellow: x$1,
10012 blue: x$1,
10013 magenta: x$1,
10014 cyan: x$1,
10015 white: x$1,
10016 gray: x$1,
10017 bgBlack: x$1,
10018 bgRed: x$1,
10019 bgGreen: x$1,
10020 bgYellow: x$1,
10021 bgBlue: x$1,
10022 bgMagenta: x$1,
10023 bgCyan: x$1,
10024 bgWhite: x$1
10025 };
10026 };
10027 picocolors_browser$1.exports = create$1();
10028 picocolors_browser$1.exports.createColors = create$1;
10029 var picocolors_browserExports$1 = picocolors_browser$1.exports;
10030 var __viteBrowserExternal$2 = {};
10031 var __viteBrowserExternal$1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10032 __proto__: null,
10033 default: __viteBrowserExternal$2
10034 }, Symbol.toStringTag, {
10035 value: "Module"
10036 }));
10037 var require$$2$1 = /* @__PURE__ */ getAugmentedNamespace$1(__viteBrowserExternal$1$1);
10038 var pico$1 = picocolors_browserExports$1;
10039 var terminalHighlight$1$1 = require$$2$1;
10040 var CssSyntaxError$3$1 = /*#__PURE__*/ function(Error1) {
10041 _inherits(CssSyntaxError, Error1);
10042 function CssSyntaxError(message, line, column, source, file, plugin22) {
10043 var _this;
10044 _this = Error1.call(this, message) || this;
10045 _this.name = "CssSyntaxError";
10046 _this.reason = message;
10047 if (file) {
10048 _this.file = file;
10049 }
10050 if (source) {
10051 _this.source = source;
10052 }
10053 if (plugin22) {
10054 _this.plugin = plugin22;
10055 }
10056 if (typeof line !== "undefined" && typeof column !== "undefined") {
10057 if (typeof line === "number") {
10058 _this.line = line;
10059 _this.column = column;
10060 } else {
10061 _this.line = line.line;
10062 _this.column = line.column;
10063 _this.endLine = column.line;
10064 _this.endColumn = column.column;
10065 }
10066 }
10067 _this.setMessage();
10068 if (Error.captureStackTrace) {
10069 Error.captureStackTrace(_this, CssSyntaxError);
10070 }
10071 return _this;
10072 }
10073 var _proto = CssSyntaxError.prototype;
10074 _proto.setMessage = function setMessage() {
10075 this.message = this.plugin ? this.plugin + ": " : "";
10076 this.message += this.file ? this.file : "<css input>";
10077 if (typeof this.line !== "undefined") {
10078 this.message += ":" + this.line + ":" + this.column;
10079 }
10080 this.message += ": " + this.reason;
10081 };
10082 _proto.showSourceCode = function showSourceCode(color) {
10083 var _this = this;
10084 if (!this.source) return "";
10085 var css = this.source;
10086 if (color == null) color = pico$1.isColorSupported;
10087 if (terminalHighlight$1$1) {
10088 if (color) css = terminalHighlight$1$1(css);
10089 }
10090 var lines = css.split(/\r?\n/);
10091 var start = Math.max(this.line - 3, 0);
10092 var end = Math.min(this.line + 2, lines.length);
10093 var maxWidth = String(end).length;
10094 var mark, aside;
10095 if (color) {
10096 var _pico$1_createColors = pico$1.createColors(true), bold = _pico$1_createColors.bold, gray = _pico$1_createColors.gray, red = _pico$1_createColors.red;
10097 mark = function(text) {
10098 return bold(red(text));
10099 };
10100 aside = function(text) {
10101 return gray(text);
10102 };
10103 } else {
10104 mark = aside = function(str) {
10105 return str;
10106 };
10107 }
10108 return lines.slice(start, end).map(function(line, index2) {
10109 var number = start + 1 + index2;
10110 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
10111 if (number === _this.line) {
10112 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
10113 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
10114 }
10115 return " " + aside(gutter) + line;
10116 }).join("\n");
10117 };
10118 _proto.toString = function toString() {
10119 var code = this.showSourceCode();
10120 if (code) {
10121 code = "\n\n" + code + "\n";
10122 }
10123 return this.name + ": " + this.message + code;
10124 };
10125 return CssSyntaxError;
10126 }(_wrap_native_super(Error));
10127 var cssSyntaxError$1 = CssSyntaxError$3$1;
10128 CssSyntaxError$3$1.default = CssSyntaxError$3$1;
10129 var symbols$1 = {};
10130 symbols$1.isClean = Symbol("isClean");
10131 symbols$1.my = Symbol("my");
10132 var DEFAULT_RAW$1 = {
10133 after: "\n",
10134 beforeClose: "\n",
10135 beforeComment: "\n",
10136 beforeDecl: "\n",
10137 beforeOpen: " ",
10138 beforeRule: "\n",
10139 colon: ": ",
10140 commentLeft: " ",
10141 commentRight: " ",
10142 emptyBody: "",
10143 indent: " ",
10144 semicolon: false
10145 };
10146 function capitalize$1(str) {
10147 return str[0].toUpperCase() + str.slice(1);
10148 }
10149 var Stringifier$2$1 = /*#__PURE__*/ function() {
10150 function Stringifier(builder) {
10151 this.builder = builder;
10152 }
10153 var _proto = Stringifier.prototype;
10154 _proto.atrule = function atrule(node2, semicolon) {
10155 var name = "@" + node2.name;
10156 var params = node2.params ? this.rawValue(node2, "params") : "";
10157 if (typeof node2.raws.afterName !== "undefined") {
10158 name += node2.raws.afterName;
10159 } else if (params) {
10160 name += " ";
10161 }
10162 if (node2.nodes) {
10163 this.block(node2, name + params);
10164 } else {
10165 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
10166 this.builder(name + params + end, node2);
10167 }
10168 };
10169 _proto.beforeAfter = function beforeAfter(node2, detect) {
10170 var value;
10171 if (node2.type === "decl") {
10172 value = this.raw(node2, null, "beforeDecl");
10173 } else if (node2.type === "comment") {
10174 value = this.raw(node2, null, "beforeComment");
10175 } else if (detect === "before") {
10176 value = this.raw(node2, null, "beforeRule");
10177 } else {
10178 value = this.raw(node2, null, "beforeClose");
10179 }
10180 var buf = node2.parent;
10181 var depth = 0;
10182 while(buf && buf.type !== "root"){
10183 depth += 1;
10184 buf = buf.parent;
10185 }
10186 if (value.includes("\n")) {
10187 var indent = this.raw(node2, null, "indent");
10188 if (indent.length) {
10189 for(var step = 0; step < depth; step++)value += indent;
10190 }
10191 }
10192 return value;
10193 };
10194 _proto.block = function block(node2, start) {
10195 var between = this.raw(node2, "between", "beforeOpen");
10196 this.builder(start + between + "{", node2, "start");
10197 var after;
10198 if (node2.nodes && node2.nodes.length) {
10199 this.body(node2);
10200 after = this.raw(node2, "after");
10201 } else {
10202 after = this.raw(node2, "after", "emptyBody");
10203 }
10204 if (after) this.builder(after);
10205 this.builder("}", node2, "end");
10206 };
10207 _proto.body = function body(node2) {
10208 var last = node2.nodes.length - 1;
10209 while(last > 0){
10210 if (node2.nodes[last].type !== "comment") break;
10211 last -= 1;
10212 }
10213 var semicolon = this.raw(node2, "semicolon");
10214 for(var i2 = 0; i2 < node2.nodes.length; i2++){
10215 var child = node2.nodes[i2];
10216 var before = this.raw(child, "before");
10217 if (before) this.builder(before);
10218 this.stringify(child, last !== i2 || semicolon);
10219 }
10220 };
10221 _proto.comment = function comment(node2) {
10222 var left = this.raw(node2, "left", "commentLeft");
10223 var right = this.raw(node2, "right", "commentRight");
10224 this.builder("/*" + left + node2.text + right + "*/", node2);
10225 };
10226 _proto.decl = function decl(node2, semicolon) {
10227 var between = this.raw(node2, "between", "colon");
10228 var string = node2.prop + between + this.rawValue(node2, "value");
10229 if (node2.important) {
10230 string += node2.raws.important || " !important";
10231 }
10232 if (semicolon) string += ";";
10233 this.builder(string, node2);
10234 };
10235 _proto.document = function document1(node2) {
10236 this.body(node2);
10237 };
10238 _proto.raw = function raw(node2, own, detect) {
10239 var value;
10240 if (!detect) detect = own;
10241 if (own) {
10242 value = node2.raws[own];
10243 if (typeof value !== "undefined") return value;
10244 }
10245 var parent = node2.parent;
10246 if (detect === "before") {
10247 if (!parent || parent.type === "root" && parent.first === node2) {
10248 return "";
10249 }
10250 if (parent && parent.type === "document") {
10251 return "";
10252 }
10253 }
10254 if (!parent) return DEFAULT_RAW$1[detect];
10255 var root2 = node2.root();
10256 if (!root2.rawCache) root2.rawCache = {};
10257 if (typeof root2.rawCache[detect] !== "undefined") {
10258 return root2.rawCache[detect];
10259 }
10260 if (detect === "before" || detect === "after") {
10261 return this.beforeAfter(node2, detect);
10262 } else {
10263 var method = "raw" + capitalize$1(detect);
10264 if (this[method]) {
10265 value = this[method](root2, node2);
10266 } else {
10267 root2.walk(function(i2) {
10268 value = i2.raws[own];
10269 if (typeof value !== "undefined") return false;
10270 });
10271 }
10272 }
10273 if (typeof value === "undefined") value = DEFAULT_RAW$1[detect];
10274 root2.rawCache[detect] = value;
10275 return value;
10276 };
10277 _proto.rawBeforeClose = function rawBeforeClose(root2) {
10278 var value;
10279 root2.walk(function(i2) {
10280 if (i2.nodes && i2.nodes.length > 0) {
10281 if (typeof i2.raws.after !== "undefined") {
10282 value = i2.raws.after;
10283 if (value.includes("\n")) {
10284 value = value.replace(/[^\n]+$/, "");
10285 }
10286 return false;
10287 }
10288 }
10289 });
10290 if (value) value = value.replace(/\S/g, "");
10291 return value;
10292 };
10293 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
10294 var value;
10295 root2.walkComments(function(i2) {
10296 if (typeof i2.raws.before !== "undefined") {
10297 value = i2.raws.before;
10298 if (value.includes("\n")) {
10299 value = value.replace(/[^\n]+$/, "");
10300 }
10301 return false;
10302 }
10303 });
10304 if (typeof value === "undefined") {
10305 value = this.raw(node2, null, "beforeDecl");
10306 } else if (value) {
10307 value = value.replace(/\S/g, "");
10308 }
10309 return value;
10310 };
10311 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
10312 var value;
10313 root2.walkDecls(function(i2) {
10314 if (typeof i2.raws.before !== "undefined") {
10315 value = i2.raws.before;
10316 if (value.includes("\n")) {
10317 value = value.replace(/[^\n]+$/, "");
10318 }
10319 return false;
10320 }
10321 });
10322 if (typeof value === "undefined") {
10323 value = this.raw(node2, null, "beforeRule");
10324 } else if (value) {
10325 value = value.replace(/\S/g, "");
10326 }
10327 return value;
10328 };
10329 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
10330 var value;
10331 root2.walk(function(i2) {
10332 if (i2.type !== "decl") {
10333 value = i2.raws.between;
10334 if (typeof value !== "undefined") return false;
10335 }
10336 });
10337 return value;
10338 };
10339 _proto.rawBeforeRule = function rawBeforeRule(root2) {
10340 var value;
10341 root2.walk(function(i2) {
10342 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
10343 if (typeof i2.raws.before !== "undefined") {
10344 value = i2.raws.before;
10345 if (value.includes("\n")) {
10346 value = value.replace(/[^\n]+$/, "");
10347 }
10348 return false;
10349 }
10350 }
10351 });
10352 if (value) value = value.replace(/\S/g, "");
10353 return value;
10354 };
10355 _proto.rawColon = function rawColon(root2) {
10356 var value;
10357 root2.walkDecls(function(i2) {
10358 if (typeof i2.raws.between !== "undefined") {
10359 value = i2.raws.between.replace(/[^\s:]/g, "");
10360 return false;
10361 }
10362 });
10363 return value;
10364 };
10365 _proto.rawEmptyBody = function rawEmptyBody(root2) {
10366 var value;
10367 root2.walk(function(i2) {
10368 if (i2.nodes && i2.nodes.length === 0) {
10369 value = i2.raws.after;
10370 if (typeof value !== "undefined") return false;
10371 }
10372 });
10373 return value;
10374 };
10375 _proto.rawIndent = function rawIndent(root2) {
10376 if (root2.raws.indent) return root2.raws.indent;
10377 var value;
10378 root2.walk(function(i2) {
10379 var p = i2.parent;
10380 if (p && p !== root2 && p.parent && p.parent === root2) {
10381 if (typeof i2.raws.before !== "undefined") {
10382 var parts = i2.raws.before.split("\n");
10383 value = parts[parts.length - 1];
10384 value = value.replace(/\S/g, "");
10385 return false;
10386 }
10387 }
10388 });
10389 return value;
10390 };
10391 _proto.rawSemicolon = function rawSemicolon(root2) {
10392 var value;
10393 root2.walk(function(i2) {
10394 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
10395 value = i2.raws.semicolon;
10396 if (typeof value !== "undefined") return false;
10397 }
10398 });
10399 return value;
10400 };
10401 _proto.rawValue = function rawValue(node2, prop) {
10402 var value = node2[prop];
10403 var raw = node2.raws[prop];
10404 if (raw && raw.value === value) {
10405 return raw.raw;
10406 }
10407 return value;
10408 };
10409 _proto.root = function root(node2) {
10410 this.body(node2);
10411 if (node2.raws.after) this.builder(node2.raws.after);
10412 };
10413 _proto.rule = function rule(node2) {
10414 this.block(node2, this.rawValue(node2, "selector"));
10415 if (node2.raws.ownSemicolon) {
10416 this.builder(node2.raws.ownSemicolon, node2, "end");
10417 }
10418 };
10419 _proto.stringify = function stringify(node2, semicolon) {
10420 if (!this[node2.type]) {
10421 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
10422 }
10423 this[node2.type](node2, semicolon);
10424 };
10425 return Stringifier;
10426 }();
10427 var stringifier$1 = Stringifier$2$1;
10428 Stringifier$2$1.default = Stringifier$2$1;
10429 var Stringifier$1$1 = stringifier$1;
10430 function stringify$4$1(node2, builder) {
10431 var str = new Stringifier$1$1(builder);
10432 str.stringify(node2);
10433 }
10434 var stringify_1$1 = stringify$4$1;
10435 stringify$4$1.default = stringify$4$1;
10436 var isClean$2$1 = symbols$1.isClean, my$2$1 = symbols$1.my;
10437 var CssSyntaxError$2$1 = cssSyntaxError$1;
10438 var Stringifier2$1 = stringifier$1;
10439 var stringify$3$1 = stringify_1$1;
10440 function cloneNode$1(obj, parent) {
10441 var cloned = new obj.constructor();
10442 for(var i2 in obj){
10443 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
10444 continue;
10445 }
10446 if (i2 === "proxyCache") continue;
10447 var value = obj[i2];
10448 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
10449 if (i2 === "parent" && type === "object") {
10450 if (parent) cloned[i2] = parent;
10451 } else if (i2 === "source") {
10452 cloned[i2] = value;
10453 } else if (Array.isArray(value)) {
10454 cloned[i2] = value.map(function(j) {
10455 return cloneNode$1(j, cloned);
10456 });
10457 } else {
10458 if (type === "object" && value !== null) value = cloneNode$1(value);
10459 cloned[i2] = value;
10460 }
10461 }
10462 return cloned;
10463 }
10464 var Node$4$1 = /*#__PURE__*/ function() {
10465 function Node2(defaults) {
10466 if (defaults === void 0) defaults = {};
10467 this.raws = {};
10468 this[isClean$2$1] = false;
10469 this[my$2$1] = true;
10470 for(var name in defaults){
10471 if (name === "nodes") {
10472 this.nodes = [];
10473 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
10474 var node2 = _step.value;
10475 if (typeof node2.clone === "function") {
10476 this.append(node2.clone());
10477 } else {
10478 this.append(node2);
10479 }
10480 }
10481 } else {
10482 this[name] = defaults[name];
10483 }
10484 }
10485 }
10486 var _proto = Node2.prototype;
10487 _proto.addToError = function addToError(error) {
10488 error.postcssNode = this;
10489 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
10490 var s2 = this.source;
10491 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
10492 }
10493 return error;
10494 };
10495 _proto.after = function after(add) {
10496 this.parent.insertAfter(this, add);
10497 return this;
10498 };
10499 _proto.assign = function assign(overrides) {
10500 if (overrides === void 0) overrides = {};
10501 for(var name in overrides){
10502 this[name] = overrides[name];
10503 }
10504 return this;
10505 };
10506 _proto.before = function before(add) {
10507 this.parent.insertBefore(this, add);
10508 return this;
10509 };
10510 _proto.cleanRaws = function cleanRaws(keepBetween) {
10511 delete this.raws.before;
10512 delete this.raws.after;
10513 if (!keepBetween) delete this.raws.between;
10514 };
10515 _proto.clone = function clone(overrides) {
10516 if (overrides === void 0) overrides = {};
10517 var cloned = cloneNode$1(this);
10518 for(var name in overrides){
10519 cloned[name] = overrides[name];
10520 }
10521 return cloned;
10522 };
10523 _proto.cloneAfter = function cloneAfter(overrides) {
10524 if (overrides === void 0) overrides = {};
10525 var cloned = this.clone(overrides);
10526 this.parent.insertAfter(this, cloned);
10527 return cloned;
10528 };
10529 _proto.cloneBefore = function cloneBefore(overrides) {
10530 if (overrides === void 0) overrides = {};
10531 var cloned = this.clone(overrides);
10532 this.parent.insertBefore(this, cloned);
10533 return cloned;
10534 };
10535 _proto.error = function error(message, opts) {
10536 if (opts === void 0) opts = {};
10537 if (this.source) {
10538 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
10539 return this.source.input.error(message, {
10540 column: start.column,
10541 line: start.line
10542 }, {
10543 column: end.column,
10544 line: end.line
10545 }, opts);
10546 }
10547 return new CssSyntaxError$2$1(message);
10548 };
10549 _proto.getProxyProcessor = function getProxyProcessor() {
10550 return {
10551 get: function get(node2, prop) {
10552 if (prop === "proxyOf") {
10553 return node2;
10554 } else if (prop === "root") {
10555 return function() {
10556 return node2.root().toProxy();
10557 };
10558 } else {
10559 return node2[prop];
10560 }
10561 },
10562 set: function set(node2, prop, value) {
10563 if (node2[prop] === value) return true;
10564 node2[prop] = value;
10565 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
10566 node2.markDirty();
10567 }
10568 return true;
10569 }
10570 };
10571 };
10572 _proto.markDirty = function markDirty() {
10573 if (this[isClean$2$1]) {
10574 this[isClean$2$1] = false;
10575 var next = this;
10576 while(next = next.parent){
10577 next[isClean$2$1] = false;
10578 }
10579 }
10580 };
10581 _proto.next = function next() {
10582 if (!this.parent) return void 0;
10583 var index2 = this.parent.index(this);
10584 return this.parent.nodes[index2 + 1];
10585 };
10586 _proto.positionBy = function positionBy(opts, stringRepresentation) {
10587 var pos = this.source.start;
10588 if (opts.index) {
10589 pos = this.positionInside(opts.index, stringRepresentation);
10590 } else if (opts.word) {
10591 stringRepresentation = this.toString();
10592 var index2 = stringRepresentation.indexOf(opts.word);
10593 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
10594 }
10595 return pos;
10596 };
10597 _proto.positionInside = function positionInside(index2, stringRepresentation) {
10598 var string = stringRepresentation || this.toString();
10599 var column = this.source.start.column;
10600 var line = this.source.start.line;
10601 for(var i2 = 0; i2 < index2; i2++){
10602 if (string[i2] === "\n") {
10603 column = 1;
10604 line += 1;
10605 } else {
10606 column += 1;
10607 }
10608 }
10609 return {
10610 column: column,
10611 line: line
10612 };
10613 };
10614 _proto.prev = function prev() {
10615 if (!this.parent) return void 0;
10616 var index2 = this.parent.index(this);
10617 return this.parent.nodes[index2 - 1];
10618 };
10619 _proto.rangeBy = function rangeBy(opts) {
10620 var start = {
10621 column: this.source.start.column,
10622 line: this.source.start.line
10623 };
10624 var end = this.source.end ? {
10625 column: this.source.end.column + 1,
10626 line: this.source.end.line
10627 } : {
10628 column: start.column + 1,
10629 line: start.line
10630 };
10631 if (opts.word) {
10632 var stringRepresentation = this.toString();
10633 var index2 = stringRepresentation.indexOf(opts.word);
10634 if (index2 !== -1) {
10635 start = this.positionInside(index2, stringRepresentation);
10636 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
10637 }
10638 } else {
10639 if (opts.start) {
10640 start = {
10641 column: opts.start.column,
10642 line: opts.start.line
10643 };
10644 } else if (opts.index) {
10645 start = this.positionInside(opts.index);
10646 }
10647 if (opts.end) {
10648 end = {
10649 column: opts.end.column,
10650 line: opts.end.line
10651 };
10652 } else if (typeof opts.endIndex === "number") {
10653 end = this.positionInside(opts.endIndex);
10654 } else if (opts.index) {
10655 end = this.positionInside(opts.index + 1);
10656 }
10657 }
10658 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
10659 end = {
10660 column: start.column + 1,
10661 line: start.line
10662 };
10663 }
10664 return {
10665 end: end,
10666 start: start
10667 };
10668 };
10669 _proto.raw = function raw(prop, defaultType) {
10670 var str = new Stringifier2$1();
10671 return str.raw(this, prop, defaultType);
10672 };
10673 _proto.remove = function remove() {
10674 if (this.parent) {
10675 this.parent.removeChild(this);
10676 }
10677 this.parent = void 0;
10678 return this;
10679 };
10680 _proto.replaceWith = function replaceWith() {
10681 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
10682 nodes[_key] = arguments[_key];
10683 }
10684 if (this.parent) {
10685 var bookmark = this;
10686 var foundSelf = false;
10687 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
10688 var node2 = _step.value;
10689 if (node2 === this) {
10690 foundSelf = true;
10691 } else if (foundSelf) {
10692 this.parent.insertAfter(bookmark, node2);
10693 bookmark = node2;
10694 } else {
10695 this.parent.insertBefore(bookmark, node2);
10696 }
10697 }
10698 if (!foundSelf) {
10699 this.remove();
10700 }
10701 }
10702 return this;
10703 };
10704 _proto.root = function root() {
10705 var result2 = this;
10706 while(result2.parent && result2.parent.type !== "document"){
10707 result2 = result2.parent;
10708 }
10709 return result2;
10710 };
10711 _proto.toJSON = function toJSON(_, inputs) {
10712 var fixed = {};
10713 var emitInputs = inputs == null;
10714 inputs = inputs || /* @__PURE__ */ new Map();
10715 var inputsNextIndex = 0;
10716 for(var name in this){
10717 if (!Object.prototype.hasOwnProperty.call(this, name)) {
10718 continue;
10719 }
10720 if (name === "parent" || name === "proxyCache") continue;
10721 var value = this[name];
10722 if (Array.isArray(value)) {
10723 fixed[name] = value.map(function(i2) {
10724 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
10725 return i2.toJSON(null, inputs);
10726 } else {
10727 return i2;
10728 }
10729 });
10730 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
10731 fixed[name] = value.toJSON(null, inputs);
10732 } else if (name === "source") {
10733 var inputId = inputs.get(value.input);
10734 if (inputId == null) {
10735 inputId = inputsNextIndex;
10736 inputs.set(value.input, inputsNextIndex);
10737 inputsNextIndex++;
10738 }
10739 fixed[name] = {
10740 end: value.end,
10741 inputId: inputId,
10742 start: value.start
10743 };
10744 } else {
10745 fixed[name] = value;
10746 }
10747 }
10748 if (emitInputs) {
10749 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
10750 return input2.toJSON();
10751 });
10752 }
10753 return fixed;
10754 };
10755 _proto.toProxy = function toProxy() {
10756 if (!this.proxyCache) {
10757 this.proxyCache = new Proxy(this, this.getProxyProcessor());
10758 }
10759 return this.proxyCache;
10760 };
10761 _proto.toString = function toString(stringifier2) {
10762 if (stringifier2 === void 0) stringifier2 = stringify$3$1;
10763 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
10764 var result2 = "";
10765 stringifier2(this, function(i2) {
10766 result2 += i2;
10767 });
10768 return result2;
10769 };
10770 _proto.warn = function warn(result2, text, opts) {
10771 var data = {
10772 node: this
10773 };
10774 for(var i2 in opts)data[i2] = opts[i2];
10775 return result2.warn(text, data);
10776 };
10777 _create_class(Node2, [
10778 {
10779 key: "proxyOf",
10780 get: function get() {
10781 return this;
10782 }
10783 }
10784 ]);
10785 return Node2;
10786 }();
10787 var node$1 = Node$4$1;
10788 Node$4$1.default = Node$4$1;
10789 var Node$3$1 = node$1;
10790 var Declaration$4$1 = /*#__PURE__*/ function(Node$3$1) {
10791 _inherits(Declaration, Node$3$1);
10792 function Declaration(defaults) {
10793 var _this;
10794 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
10795 defaults = _extends({}, defaults, {
10796 value: String(defaults.value)
10797 });
10798 }
10799 _this = Node$3$1.call(this, defaults) || this;
10800 _this.type = "decl";
10801 return _this;
10802 }
10803 _create_class(Declaration, [
10804 {
10805 key: "variable",
10806 get: function get() {
10807 return this.prop.startsWith("--") || this.prop[0] === "$";
10808 }
10809 }
10810 ]);
10811 return Declaration;
10812 }(Node$3$1);
10813 var declaration$1 = Declaration$4$1;
10814 Declaration$4$1.default = Declaration$4$1;
10815 var urlAlphabet$1 = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
10816 var nanoid$1$1 = function(size) {
10817 if (size === void 0) size = 21;
10818 var id = "";
10819 var i2 = size;
10820 while(i2--){
10821 id += urlAlphabet$1[Math.random() * 64 | 0];
10822 }
10823 return id;
10824 };
10825 var nonSecure$1 = {
10826 nanoid: nanoid$1$1};
10827 var SourceMapConsumer$2$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$2$1 = require$$2$1.SourceMapGenerator;
10828 var existsSync$1 = require$$2$1.existsSync, readFileSync$1 = require$$2$1.readFileSync;
10829 var dirname$1$1 = require$$2$1.dirname, join$1 = require$$2$1.join;
10830 function fromBase64$1(str) {
10831 if (Buffer) {
10832 return Buffer.from(str, "base64").toString();
10833 } else {
10834 return window.atob(str);
10835 }
10836 }
10837 var PreviousMap$2$1 = /*#__PURE__*/ function() {
10838 function PreviousMap(css, opts) {
10839 if (opts.map === false) return;
10840 this.loadAnnotation(css);
10841 this.inline = this.startWith(this.annotation, "data:");
10842 var prev = opts.map ? opts.map.prev : void 0;
10843 var text = this.loadMap(opts.from, prev);
10844 if (!this.mapFile && opts.from) {
10845 this.mapFile = opts.from;
10846 }
10847 if (this.mapFile) this.root = dirname$1$1(this.mapFile);
10848 if (text) this.text = text;
10849 }
10850 var _proto = PreviousMap.prototype;
10851 _proto.consumer = function consumer() {
10852 if (!this.consumerCache) {
10853 this.consumerCache = new SourceMapConsumer$2$1(this.text);
10854 }
10855 return this.consumerCache;
10856 };
10857 _proto.decodeInline = function decodeInline(text) {
10858 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
10859 var baseUri = /^data:application\/json;base64,/;
10860 var charsetUri = /^data:application\/json;charset=utf-?8,/;
10861 var uri = /^data:application\/json,/;
10862 if (charsetUri.test(text) || uri.test(text)) {
10863 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
10864 }
10865 if (baseCharsetUri.test(text) || baseUri.test(text)) {
10866 return fromBase64$1(text.substr(RegExp.lastMatch.length));
10867 }
10868 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
10869 throw new Error("Unsupported source map encoding " + encoding);
10870 };
10871 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
10872 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
10873 };
10874 _proto.isMap = function isMap(map) {
10875 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
10876 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
10877 };
10878 _proto.loadAnnotation = function loadAnnotation(css) {
10879 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
10880 if (!comments) return;
10881 var start = css.lastIndexOf(comments.pop());
10882 var end = css.indexOf("*/", start);
10883 if (start > -1 && end > -1) {
10884 this.annotation = this.getAnnotationURL(css.substring(start, end));
10885 }
10886 };
10887 _proto.loadFile = function loadFile(path) {
10888 this.root = dirname$1$1(path);
10889 if (existsSync$1(path)) {
10890 this.mapFile = path;
10891 return readFileSync$1(path, "utf-8").toString().trim();
10892 }
10893 };
10894 _proto.loadMap = function loadMap(file, prev) {
10895 if (prev === false) return false;
10896 if (prev) {
10897 if (typeof prev === "string") {
10898 return prev;
10899 } else if (typeof prev === "function") {
10900 var prevPath = prev(file);
10901 if (prevPath) {
10902 var map = this.loadFile(prevPath);
10903 if (!map) {
10904 throw new Error("Unable to load previous source map: " + prevPath.toString());
10905 }
10906 return map;
10907 }
10908 } else if (_instanceof(prev, SourceMapConsumer$2$1)) {
10909 return SourceMapGenerator$2$1.fromSourceMap(prev).toString();
10910 } else if (_instanceof(prev, SourceMapGenerator$2$1)) {
10911 return prev.toString();
10912 } else if (this.isMap(prev)) {
10913 return JSON.stringify(prev);
10914 } else {
10915 throw new Error("Unsupported previous source map format: " + prev.toString());
10916 }
10917 } else if (this.inline) {
10918 return this.decodeInline(this.annotation);
10919 } else if (this.annotation) {
10920 var map1 = this.annotation;
10921 if (file) map1 = join$1(dirname$1$1(file), map1);
10922 return this.loadFile(map1);
10923 }
10924 };
10925 _proto.startWith = function startWith(string, start) {
10926 if (!string) return false;
10927 return string.substr(0, start.length) === start;
10928 };
10929 _proto.withContent = function withContent() {
10930 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
10931 };
10932 return PreviousMap;
10933 }();
10934 var previousMap$1 = PreviousMap$2$1;
10935 PreviousMap$2$1.default = PreviousMap$2$1;
10936 var SourceMapConsumer$1$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$1$1 = require$$2$1.SourceMapGenerator;
10937 var fileURLToPath$1 = require$$2$1.fileURLToPath, pathToFileURL$1$1 = require$$2$1.pathToFileURL;
10938 var isAbsolute$1 = require$$2$1.isAbsolute, resolve$1$1 = require$$2$1.resolve;
10939 var nanoid$2 = nonSecure$1.nanoid;
10940 var terminalHighlight$2 = require$$2$1;
10941 var CssSyntaxError$1$1 = cssSyntaxError$1;
10942 var PreviousMap$1$1 = previousMap$1;
10943 var fromOffsetCache$1 = Symbol("fromOffsetCache");
10944 var sourceMapAvailable$1$1 = Boolean(SourceMapConsumer$1$1 && SourceMapGenerator$1$1);
10945 var pathAvailable$1$1 = Boolean(resolve$1$1 && isAbsolute$1);
10946 var Input$4$1 = /*#__PURE__*/ function() {
10947 function Input(css, opts) {
10948 if (opts === void 0) opts = {};
10949 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
10950 throw new Error("PostCSS received " + css + " instead of CSS string");
10951 }
10952 this.css = css.toString();
10953 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
10954 this.hasBOM = true;
10955 this.css = this.css.slice(1);
10956 } else {
10957 this.hasBOM = false;
10958 }
10959 if (opts.from) {
10960 if (!pathAvailable$1$1 || /^\w+:\/\//.test(opts.from) || isAbsolute$1(opts.from)) {
10961 this.file = opts.from;
10962 } else {
10963 this.file = resolve$1$1(opts.from);
10964 }
10965 }
10966 if (pathAvailable$1$1 && sourceMapAvailable$1$1) {
10967 var map = new PreviousMap$1$1(this.css, opts);
10968 if (map.text) {
10969 this.map = map;
10970 var file = map.consumer().file;
10971 if (!this.file && file) this.file = this.mapResolve(file);
10972 }
10973 }
10974 if (!this.file) {
10975 this.id = "<input css " + nanoid$2(6) + ">";
10976 }
10977 if (this.map) this.map.file = this.from;
10978 }
10979 var _proto = Input.prototype;
10980 _proto.error = function error(message, line, column, opts) {
10981 if (opts === void 0) opts = {};
10982 var result2, endLine, endColumn;
10983 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
10984 var start = line;
10985 var end = column;
10986 if (typeof start.offset === "number") {
10987 var pos = this.fromOffset(start.offset);
10988 line = pos.line;
10989 column = pos.col;
10990 } else {
10991 line = start.line;
10992 column = start.column;
10993 }
10994 if (typeof end.offset === "number") {
10995 var pos1 = this.fromOffset(end.offset);
10996 endLine = pos1.line;
10997 endColumn = pos1.col;
10998 } else {
10999 endLine = end.line;
11000 endColumn = end.column;
11001 }
11002 } else if (!column) {
11003 var pos2 = this.fromOffset(line);
11004 line = pos2.line;
11005 column = pos2.col;
11006 }
11007 var origin = this.origin(line, column, endLine, endColumn);
11008 if (origin) {
11009 result2 = new CssSyntaxError$1$1(message, origin.endLine === void 0 ? origin.line : {
11010 column: origin.column,
11011 line: origin.line
11012 }, origin.endLine === void 0 ? origin.column : {
11013 column: origin.endColumn,
11014 line: origin.endLine
11015 }, origin.source, origin.file, opts.plugin);
11016 } else {
11017 result2 = new CssSyntaxError$1$1(message, endLine === void 0 ? line : {
11018 column: column,
11019 line: line
11020 }, endLine === void 0 ? column : {
11021 column: endColumn,
11022 line: endLine
11023 }, this.css, this.file, opts.plugin);
11024 }
11025 result2.input = {
11026 column: column,
11027 endColumn: endColumn,
11028 endLine: endLine,
11029 line: line,
11030 source: this.css
11031 };
11032 if (this.file) {
11033 if (pathToFileURL$1$1) {
11034 result2.input.url = pathToFileURL$1$1(this.file).toString();
11035 }
11036 result2.input.file = this.file;
11037 }
11038 return result2;
11039 };
11040 _proto.fromOffset = function fromOffset(offset) {
11041 var lastLine, lineToIndex;
11042 if (!this[fromOffsetCache$1]) {
11043 var lines = this.css.split("\n");
11044 lineToIndex = new Array(lines.length);
11045 var prevIndex = 0;
11046 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
11047 lineToIndex[i2] = prevIndex;
11048 prevIndex += lines[i2].length + 1;
11049 }
11050 this[fromOffsetCache$1] = lineToIndex;
11051 } else {
11052 lineToIndex = this[fromOffsetCache$1];
11053 }
11054 lastLine = lineToIndex[lineToIndex.length - 1];
11055 var min = 0;
11056 if (offset >= lastLine) {
11057 min = lineToIndex.length - 1;
11058 } else {
11059 var max = lineToIndex.length - 2;
11060 var mid;
11061 while(min < max){
11062 mid = min + (max - min >> 1);
11063 if (offset < lineToIndex[mid]) {
11064 max = mid - 1;
11065 } else if (offset >= lineToIndex[mid + 1]) {
11066 min = mid + 1;
11067 } else {
11068 min = mid;
11069 break;
11070 }
11071 }
11072 }
11073 return {
11074 col: offset - lineToIndex[min] + 1,
11075 line: min + 1
11076 };
11077 };
11078 _proto.mapResolve = function mapResolve(file) {
11079 if (/^\w+:\/\//.test(file)) {
11080 return file;
11081 }
11082 return resolve$1$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
11083 };
11084 _proto.origin = function origin(line, column, endLine, endColumn) {
11085 if (!this.map) return false;
11086 var consumer = this.map.consumer();
11087 var from = consumer.originalPositionFor({
11088 column: column,
11089 line: line
11090 });
11091 if (!from.source) return false;
11092 var to;
11093 if (typeof endLine === "number") {
11094 to = consumer.originalPositionFor({
11095 column: endColumn,
11096 line: endLine
11097 });
11098 }
11099 var fromUrl;
11100 if (isAbsolute$1(from.source)) {
11101 fromUrl = pathToFileURL$1$1(from.source);
11102 } else {
11103 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1$1(this.map.mapFile));
11104 }
11105 var result2 = {
11106 column: from.column,
11107 endColumn: to && to.column,
11108 endLine: to && to.line,
11109 line: from.line,
11110 url: fromUrl.toString()
11111 };
11112 if (fromUrl.protocol === "file:") {
11113 if (fileURLToPath$1) {
11114 result2.file = fileURLToPath$1(fromUrl);
11115 } else {
11116 throw new Error("file: protocol is not available in this PostCSS build");
11117 }
11118 }
11119 var source = consumer.sourceContentFor(from.source);
11120 if (source) result2.source = source;
11121 return result2;
11122 };
11123 _proto.toJSON = function toJSON() {
11124 var json = {};
11125 for(var _i = 0, _iter = [
11126 "hasBOM",
11127 "css",
11128 "file",
11129 "id"
11130 ]; _i < _iter.length; _i++){
11131 var name = _iter[_i];
11132 if (this[name] != null) {
11133 json[name] = this[name];
11134 }
11135 }
11136 if (this.map) {
11137 json.map = _extends({}, this.map);
11138 if (json.map.consumerCache) {
11139 json.map.consumerCache = void 0;
11140 }
11141 }
11142 return json;
11143 };
11144 _create_class(Input, [
11145 {
11146 key: "from",
11147 get: function get() {
11148 return this.file || this.id;
11149 }
11150 }
11151 ]);
11152 return Input;
11153 }();
11154 var input$1 = Input$4$1;
11155 Input$4$1.default = Input$4$1;
11156 if (terminalHighlight$2 && terminalHighlight$2.registerInput) {
11157 terminalHighlight$2.registerInput(Input$4$1);
11158 }
11159 var SourceMapConsumer$3 = require$$2$1.SourceMapConsumer, SourceMapGenerator$3 = require$$2$1.SourceMapGenerator;
11160 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;
11161 var pathToFileURL$2 = require$$2$1.pathToFileURL;
11162 var Input$3$1 = input$1;
11163 var sourceMapAvailable$2 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$3);
11164 var pathAvailable$2 = Boolean(dirname$2 && resolve$2 && relative$1 && sep$1);
11165 var MapGenerator$2$1 = /*#__PURE__*/ function() {
11166 function MapGenerator(stringify2, root2, opts, cssString) {
11167 this.stringify = stringify2;
11168 this.mapOpts = opts.map || {};
11169 this.root = root2;
11170 this.opts = opts;
11171 this.css = cssString;
11172 this.originalCSS = cssString;
11173 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
11174 this.memoizedFileURLs = /* @__PURE__ */ new Map();
11175 this.memoizedPaths = /* @__PURE__ */ new Map();
11176 this.memoizedURLs = /* @__PURE__ */ new Map();
11177 }
11178 var _proto = MapGenerator.prototype;
11179 _proto.addAnnotation = function addAnnotation() {
11180 var content;
11181 if (this.isInline()) {
11182 content = "data:application/json;base64," + this.toBase64(this.map.toString());
11183 } else if (typeof this.mapOpts.annotation === "string") {
11184 content = this.mapOpts.annotation;
11185 } else if (typeof this.mapOpts.annotation === "function") {
11186 content = this.mapOpts.annotation(this.opts.to, this.root);
11187 } else {
11188 content = this.outputFile() + ".map";
11189 }
11190 var eol = "\n";
11191 if (this.css.includes("\r\n")) eol = "\r\n";
11192 this.css += eol + "/*# sourceMappingURL=" + content + " */";
11193 };
11194 _proto.applyPrevMaps = function applyPrevMaps() {
11195 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
11196 var prev = _step.value;
11197 var from = this.toUrl(this.path(prev.file));
11198 var root2 = prev.root || dirname$2(prev.file);
11199 var map = void 0;
11200 if (this.mapOpts.sourcesContent === false) {
11201 map = new SourceMapConsumer$3(prev.text);
11202 if (map.sourcesContent) {
11203 map.sourcesContent = null;
11204 }
11205 } else {
11206 map = prev.consumer();
11207 }
11208 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
11209 }
11210 };
11211 _proto.clearAnnotation = function clearAnnotation() {
11212 if (this.mapOpts.annotation === false) return;
11213 if (this.root) {
11214 var node2;
11215 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
11216 node2 = this.root.nodes[i2];
11217 if (node2.type !== "comment") continue;
11218 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
11219 this.root.removeChild(i2);
11220 }
11221 }
11222 } else if (this.css) {
11223 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
11224 }
11225 };
11226 _proto.generate = function generate() {
11227 this.clearAnnotation();
11228 if (pathAvailable$2 && sourceMapAvailable$2 && this.isMap()) {
11229 return this.generateMap();
11230 } else {
11231 var result2 = "";
11232 this.stringify(this.root, function(i2) {
11233 result2 += i2;
11234 });
11235 return [
11236 result2
11237 ];
11238 }
11239 };
11240 _proto.generateMap = function generateMap() {
11241 if (this.root) {
11242 this.generateString();
11243 } else if (this.previous().length === 1) {
11244 var prev = this.previous()[0].consumer();
11245 prev.file = this.outputFile();
11246 this.map = SourceMapGenerator$3.fromSourceMap(prev, {
11247 ignoreInvalidMapping: true
11248 });
11249 } else {
11250 this.map = new SourceMapGenerator$3({
11251 file: this.outputFile(),
11252 ignoreInvalidMapping: true
11253 });
11254 this.map.addMapping({
11255 generated: {
11256 column: 0,
11257 line: 1
11258 },
11259 original: {
11260 column: 0,
11261 line: 1
11262 },
11263 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
11264 });
11265 }
11266 if (this.isSourcesContent()) this.setSourcesContent();
11267 if (this.root && this.previous().length > 0) this.applyPrevMaps();
11268 if (this.isAnnotation()) this.addAnnotation();
11269 if (this.isInline()) {
11270 return [
11271 this.css
11272 ];
11273 } else {
11274 return [
11275 this.css,
11276 this.map
11277 ];
11278 }
11279 };
11280 _proto.generateString = function generateString() {
11281 var _this = this;
11282 this.css = "";
11283 this.map = new SourceMapGenerator$3({
11284 file: this.outputFile(),
11285 ignoreInvalidMapping: true
11286 });
11287 var line = 1;
11288 var column = 1;
11289 var noSource = "<no source>";
11290 var mapping = {
11291 generated: {
11292 column: 0,
11293 line: 0
11294 },
11295 original: {
11296 column: 0,
11297 line: 0
11298 },
11299 source: ""
11300 };
11301 var lines, last;
11302 this.stringify(this.root, function(str, node2, type) {
11303 _this.css += str;
11304 if (node2 && type !== "end") {
11305 mapping.generated.line = line;
11306 mapping.generated.column = column - 1;
11307 if (node2.source && node2.source.start) {
11308 mapping.source = _this.sourcePath(node2);
11309 mapping.original.line = node2.source.start.line;
11310 mapping.original.column = node2.source.start.column - 1;
11311 _this.map.addMapping(mapping);
11312 } else {
11313 mapping.source = noSource;
11314 mapping.original.line = 1;
11315 mapping.original.column = 0;
11316 _this.map.addMapping(mapping);
11317 }
11318 }
11319 lines = str.match(/\n/g);
11320 if (lines) {
11321 line += lines.length;
11322 last = str.lastIndexOf("\n");
11323 column = str.length - last;
11324 } else {
11325 column += str.length;
11326 }
11327 if (node2 && type !== "start") {
11328 var p = node2.parent || {
11329 raws: {}
11330 };
11331 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
11332 if (!childless || node2 !== p.last || p.raws.semicolon) {
11333 if (node2.source && node2.source.end) {
11334 mapping.source = _this.sourcePath(node2);
11335 mapping.original.line = node2.source.end.line;
11336 mapping.original.column = node2.source.end.column - 1;
11337 mapping.generated.line = line;
11338 mapping.generated.column = column - 2;
11339 _this.map.addMapping(mapping);
11340 } else {
11341 mapping.source = noSource;
11342 mapping.original.line = 1;
11343 mapping.original.column = 0;
11344 mapping.generated.line = line;
11345 mapping.generated.column = column - 1;
11346 _this.map.addMapping(mapping);
11347 }
11348 }
11349 }
11350 });
11351 };
11352 _proto.isAnnotation = function isAnnotation() {
11353 if (this.isInline()) {
11354 return true;
11355 }
11356 if (typeof this.mapOpts.annotation !== "undefined") {
11357 return this.mapOpts.annotation;
11358 }
11359 if (this.previous().length) {
11360 return this.previous().some(function(i2) {
11361 return i2.annotation;
11362 });
11363 }
11364 return true;
11365 };
11366 _proto.isInline = function isInline() {
11367 if (typeof this.mapOpts.inline !== "undefined") {
11368 return this.mapOpts.inline;
11369 }
11370 var annotation = this.mapOpts.annotation;
11371 if (typeof annotation !== "undefined" && annotation !== true) {
11372 return false;
11373 }
11374 if (this.previous().length) {
11375 return this.previous().some(function(i2) {
11376 return i2.inline;
11377 });
11378 }
11379 return true;
11380 };
11381 _proto.isMap = function isMap() {
11382 if (typeof this.opts.map !== "undefined") {
11383 return !!this.opts.map;
11384 }
11385 return this.previous().length > 0;
11386 };
11387 _proto.isSourcesContent = function isSourcesContent() {
11388 if (typeof this.mapOpts.sourcesContent !== "undefined") {
11389 return this.mapOpts.sourcesContent;
11390 }
11391 if (this.previous().length) {
11392 return this.previous().some(function(i2) {
11393 return i2.withContent();
11394 });
11395 }
11396 return true;
11397 };
11398 _proto.outputFile = function outputFile() {
11399 if (this.opts.to) {
11400 return this.path(this.opts.to);
11401 } else if (this.opts.from) {
11402 return this.path(this.opts.from);
11403 } else {
11404 return "to.css";
11405 }
11406 };
11407 _proto.path = function path(file) {
11408 if (this.mapOpts.absolute) return file;
11409 if (file.charCodeAt(0) === 60) return file;
11410 if (/^\w+:\/\//.test(file)) return file;
11411 var cached = this.memoizedPaths.get(file);
11412 if (cached) return cached;
11413 var from = this.opts.to ? dirname$2(this.opts.to) : ".";
11414 if (typeof this.mapOpts.annotation === "string") {
11415 from = dirname$2(resolve$2(from, this.mapOpts.annotation));
11416 }
11417 var path = relative$1(from, file);
11418 this.memoizedPaths.set(file, path);
11419 return path;
11420 };
11421 _proto.previous = function previous() {
11422 var _this = this;
11423 if (!this.previousMaps) {
11424 this.previousMaps = [];
11425 if (this.root) {
11426 this.root.walk(function(node2) {
11427 if (node2.source && node2.source.input.map) {
11428 var map = node2.source.input.map;
11429 if (!_this.previousMaps.includes(map)) {
11430 _this.previousMaps.push(map);
11431 }
11432 }
11433 });
11434 } else {
11435 var input2 = new Input$3$1(this.originalCSS, this.opts);
11436 if (input2.map) this.previousMaps.push(input2.map);
11437 }
11438 }
11439 return this.previousMaps;
11440 };
11441 _proto.setSourcesContent = function setSourcesContent() {
11442 var _this = this;
11443 var already = {};
11444 if (this.root) {
11445 this.root.walk(function(node2) {
11446 if (node2.source) {
11447 var from = node2.source.input.from;
11448 if (from && !already[from]) {
11449 already[from] = true;
11450 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
11451 _this.map.setSourceContent(fromUrl, node2.source.input.css);
11452 }
11453 }
11454 });
11455 } else if (this.css) {
11456 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
11457 this.map.setSourceContent(from, this.css);
11458 }
11459 };
11460 _proto.sourcePath = function sourcePath(node2) {
11461 if (this.mapOpts.from) {
11462 return this.toUrl(this.mapOpts.from);
11463 } else if (this.usesFileUrls) {
11464 return this.toFileUrl(node2.source.input.from);
11465 } else {
11466 return this.toUrl(this.path(node2.source.input.from));
11467 }
11468 };
11469 _proto.toBase64 = function toBase64(str) {
11470 if (Buffer) {
11471 return Buffer.from(str).toString("base64");
11472 } else {
11473 return window.btoa(unescape(encodeURIComponent(str)));
11474 }
11475 };
11476 _proto.toFileUrl = function toFileUrl(path) {
11477 var cached = this.memoizedFileURLs.get(path);
11478 if (cached) return cached;
11479 if (pathToFileURL$2) {
11480 var fileURL = pathToFileURL$2(path).toString();
11481 this.memoizedFileURLs.set(path, fileURL);
11482 return fileURL;
11483 } else {
11484 throw new Error("`map.absolute` option is not available in this PostCSS build");
11485 }
11486 };
11487 _proto.toUrl = function toUrl(path) {
11488 var cached = this.memoizedURLs.get(path);
11489 if (cached) return cached;
11490 if (sep$1 === "\\") {
11491 path = path.replace(/\\/g, "/");
11492 }
11493 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
11494 this.memoizedURLs.set(path, url);
11495 return url;
11496 };
11497 return MapGenerator;
11498 }();
11499 var mapGenerator$1 = MapGenerator$2$1;
11500 var Node$2$1 = node$1;
11501 var Comment$4$1 = /*#__PURE__*/ function(Node$2$1) {
11502 _inherits(Comment, Node$2$1);
11503 function Comment(defaults) {
11504 var _this;
11505 _this = Node$2$1.call(this, defaults) || this;
11506 _this.type = "comment";
11507 return _this;
11508 }
11509 return Comment;
11510 }(Node$2$1);
11511 var comment$1 = Comment$4$1;
11512 Comment$4$1.default = Comment$4$1;
11513 var isClean$1$1 = symbols$1.isClean, my$1$1 = symbols$1.my;
11514 var Declaration$3$1 = declaration$1;
11515 var Comment$3$1 = comment$1;
11516 var Node$1$1 = node$1;
11517 var parse$4$1, Rule$4$1, AtRule$4$1, Root$6$1;
11518 function cleanSource$1(nodes) {
11519 return nodes.map(function(i2) {
11520 if (i2.nodes) i2.nodes = cleanSource$1(i2.nodes);
11521 delete i2.source;
11522 return i2;
11523 });
11524 }
11525 function markDirtyUp$1(node2) {
11526 node2[isClean$1$1] = false;
11527 if (node2.proxyOf.nodes) {
11528 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
11529 var i2 = _step.value;
11530 markDirtyUp$1(i2);
11531 }
11532 }
11533 }
11534 var Container$7$1 = /*#__PURE__*/ function(Node$1$1) {
11535 _inherits(Container, Node$1$1);
11536 function Container() {
11537 return Node$1$1.apply(this, arguments) || this;
11538 }
11539 var _proto = Container.prototype;
11540 _proto.append = function append() {
11541 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
11542 children[_key] = arguments[_key];
11543 }
11544 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
11545 var child = _step.value;
11546 var nodes = this.normalize(child, this.last);
11547 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11548 var node2 = _step1.value;
11549 this.proxyOf.nodes.push(node2);
11550 }
11551 }
11552 this.markDirty();
11553 return this;
11554 };
11555 _proto.cleanRaws = function cleanRaws(keepBetween) {
11556 Node$1$1.prototype.cleanRaws.call(this, keepBetween);
11557 if (this.nodes) {
11558 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
11559 var node2 = _step.value;
11560 node2.cleanRaws(keepBetween);
11561 }
11562 }
11563 };
11564 _proto.each = function each(callback) {
11565 if (!this.proxyOf.nodes) return void 0;
11566 var iterator = this.getIterator();
11567 var index2, result2;
11568 while(this.indexes[iterator] < this.proxyOf.nodes.length){
11569 index2 = this.indexes[iterator];
11570 result2 = callback(this.proxyOf.nodes[index2], index2);
11571 if (result2 === false) break;
11572 this.indexes[iterator] += 1;
11573 }
11574 delete this.indexes[iterator];
11575 return result2;
11576 };
11577 _proto.every = function every(condition) {
11578 return this.nodes.every(condition);
11579 };
11580 _proto.getIterator = function getIterator() {
11581 if (!this.lastEach) this.lastEach = 0;
11582 if (!this.indexes) this.indexes = {};
11583 this.lastEach += 1;
11584 var iterator = this.lastEach;
11585 this.indexes[iterator] = 0;
11586 return iterator;
11587 };
11588 _proto.getProxyProcessor = function getProxyProcessor() {
11589 return {
11590 get: function get(node2, prop) {
11591 if (prop === "proxyOf") {
11592 return node2;
11593 } else if (!node2[prop]) {
11594 return node2[prop];
11595 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
11596 return function() {
11597 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
11598 args[_key] = arguments[_key];
11599 }
11600 var _node2;
11601 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
11602 if (typeof i2 === "function") {
11603 return function(child, index2) {
11604 return i2(child.toProxy(), index2);
11605 };
11606 } else {
11607 return i2;
11608 }
11609 })));
11610 };
11611 } else if (prop === "every" || prop === "some") {
11612 return function(cb) {
11613 return node2[prop](function(child) {
11614 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
11615 other[_key - 1] = arguments[_key];
11616 }
11617 return cb.apply(void 0, [].concat([
11618 child.toProxy()
11619 ], other));
11620 });
11621 };
11622 } else if (prop === "root") {
11623 return function() {
11624 return node2.root().toProxy();
11625 };
11626 } else if (prop === "nodes") {
11627 return node2.nodes.map(function(i2) {
11628 return i2.toProxy();
11629 });
11630 } else if (prop === "first" || prop === "last") {
11631 return node2[prop].toProxy();
11632 } else {
11633 return node2[prop];
11634 }
11635 },
11636 set: function set(node2, prop, value) {
11637 if (node2[prop] === value) return true;
11638 node2[prop] = value;
11639 if (prop === "name" || prop === "params" || prop === "selector") {
11640 node2.markDirty();
11641 }
11642 return true;
11643 }
11644 };
11645 };
11646 _proto.index = function index(child) {
11647 if (typeof child === "number") return child;
11648 if (child.proxyOf) child = child.proxyOf;
11649 return this.proxyOf.nodes.indexOf(child);
11650 };
11651 _proto.insertAfter = function insertAfter(exist, add) {
11652 var existIndex = this.index(exist);
11653 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
11654 existIndex = this.index(exist);
11655 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11656 var node2 = _step.value;
11657 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
11658 }
11659 var index2;
11660 for(var id in this.indexes){
11661 index2 = this.indexes[id];
11662 if (existIndex < index2) {
11663 this.indexes[id] = index2 + nodes.length;
11664 }
11665 }
11666 this.markDirty();
11667 return this;
11668 };
11669 _proto.insertBefore = function insertBefore(exist, add) {
11670 var existIndex = this.index(exist);
11671 var type = existIndex === 0 ? "prepend" : false;
11672 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
11673 existIndex = this.index(exist);
11674 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11675 var node2 = _step.value;
11676 this.proxyOf.nodes.splice(existIndex, 0, node2);
11677 }
11678 var index2;
11679 for(var id in this.indexes){
11680 index2 = this.indexes[id];
11681 if (existIndex <= index2) {
11682 this.indexes[id] = index2 + nodes.length;
11683 }
11684 }
11685 this.markDirty();
11686 return this;
11687 };
11688 _proto.normalize = function normalize(nodes, sample) {
11689 var _this = this;
11690 if (typeof nodes === "string") {
11691 nodes = cleanSource$1(parse$4$1(nodes).nodes);
11692 } else if (typeof nodes === "undefined") {
11693 nodes = [];
11694 } else if (Array.isArray(nodes)) {
11695 nodes = nodes.slice(0);
11696 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11697 var i2 = _step.value;
11698 if (i2.parent) i2.parent.removeChild(i2, "ignore");
11699 }
11700 } else if (nodes.type === "root" && this.type !== "document") {
11701 nodes = nodes.nodes.slice(0);
11702 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11703 var i21 = _step1.value;
11704 if (i21.parent) i21.parent.removeChild(i21, "ignore");
11705 }
11706 } else if (nodes.type) {
11707 nodes = [
11708 nodes
11709 ];
11710 } else if (nodes.prop) {
11711 if (typeof nodes.value === "undefined") {
11712 throw new Error("Value field is missed in node creation");
11713 } else if (typeof nodes.value !== "string") {
11714 nodes.value = String(nodes.value);
11715 }
11716 nodes = [
11717 new Declaration$3$1(nodes)
11718 ];
11719 } else if (nodes.selector) {
11720 nodes = [
11721 new Rule$4$1(nodes)
11722 ];
11723 } else if (nodes.name) {
11724 nodes = [
11725 new AtRule$4$1(nodes)
11726 ];
11727 } else if (nodes.text) {
11728 nodes = [
11729 new Comment$3$1(nodes)
11730 ];
11731 } else {
11732 throw new Error("Unknown node type in node creation");
11733 }
11734 var processed = nodes.map(function(i2) {
11735 if (!i2[my$1$1]) Container.rebuild(i2);
11736 i2 = i2.proxyOf;
11737 if (i2.parent) i2.parent.removeChild(i2);
11738 if (i2[isClean$1$1]) markDirtyUp$1(i2);
11739 if (typeof i2.raws.before === "undefined") {
11740 if (sample && typeof sample.raws.before !== "undefined") {
11741 i2.raws.before = sample.raws.before.replace(/\S/g, "");
11742 }
11743 }
11744 i2.parent = _this.proxyOf;
11745 return i2;
11746 });
11747 return processed;
11748 };
11749 _proto.prepend = function prepend() {
11750 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
11751 children[_key] = arguments[_key];
11752 }
11753 children = children.reverse();
11754 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
11755 var child = _step.value;
11756 var nodes = this.normalize(child, this.first, "prepend").reverse();
11757 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11758 var node2 = _step1.value;
11759 this.proxyOf.nodes.unshift(node2);
11760 }
11761 for(var id in this.indexes){
11762 this.indexes[id] = this.indexes[id] + nodes.length;
11763 }
11764 }
11765 this.markDirty();
11766 return this;
11767 };
11768 _proto.push = function push(child) {
11769 child.parent = this;
11770 this.proxyOf.nodes.push(child);
11771 return this;
11772 };
11773 _proto.removeAll = function removeAll() {
11774 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
11775 var node2 = _step.value;
11776 node2.parent = void 0;
11777 }
11778 this.proxyOf.nodes = [];
11779 this.markDirty();
11780 return this;
11781 };
11782 _proto.removeChild = function removeChild(child) {
11783 child = this.index(child);
11784 this.proxyOf.nodes[child].parent = void 0;
11785 this.proxyOf.nodes.splice(child, 1);
11786 var index2;
11787 for(var id in this.indexes){
11788 index2 = this.indexes[id];
11789 if (index2 >= child) {
11790 this.indexes[id] = index2 - 1;
11791 }
11792 }
11793 this.markDirty();
11794 return this;
11795 };
11796 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
11797 if (!callback) {
11798 callback = opts;
11799 opts = {};
11800 }
11801 this.walkDecls(function(decl) {
11802 if (opts.props && !opts.props.includes(decl.prop)) return;
11803 if (opts.fast && !decl.value.includes(opts.fast)) return;
11804 decl.value = decl.value.replace(pattern, callback);
11805 });
11806 this.markDirty();
11807 return this;
11808 };
11809 _proto.some = function some(condition) {
11810 return this.nodes.some(condition);
11811 };
11812 _proto.walk = function walk(callback) {
11813 return this.each(function(child, i2) {
11814 var result2;
11815 try {
11816 result2 = callback(child, i2);
11817 } catch (e2) {
11818 throw child.addToError(e2);
11819 }
11820 if (result2 !== false && child.walk) {
11821 result2 = child.walk(callback);
11822 }
11823 return result2;
11824 });
11825 };
11826 _proto.walkAtRules = function walkAtRules(name, callback) {
11827 if (!callback) {
11828 callback = name;
11829 return this.walk(function(child, i2) {
11830 if (child.type === "atrule") {
11831 return callback(child, i2);
11832 }
11833 });
11834 }
11835 if (_instanceof(name, RegExp)) {
11836 return this.walk(function(child, i2) {
11837 if (child.type === "atrule" && name.test(child.name)) {
11838 return callback(child, i2);
11839 }
11840 });
11841 }
11842 return this.walk(function(child, i2) {
11843 if (child.type === "atrule" && child.name === name) {
11844 return callback(child, i2);
11845 }
11846 });
11847 };
11848 _proto.walkComments = function walkComments(callback) {
11849 return this.walk(function(child, i2) {
11850 if (child.type === "comment") {
11851 return callback(child, i2);
11852 }
11853 });
11854 };
11855 _proto.walkDecls = function walkDecls(prop, callback) {
11856 if (!callback) {
11857 callback = prop;
11858 return this.walk(function(child, i2) {
11859 if (child.type === "decl") {
11860 return callback(child, i2);
11861 }
11862 });
11863 }
11864 if (_instanceof(prop, RegExp)) {
11865 return this.walk(function(child, i2) {
11866 if (child.type === "decl" && prop.test(child.prop)) {
11867 return callback(child, i2);
11868 }
11869 });
11870 }
11871 return this.walk(function(child, i2) {
11872 if (child.type === "decl" && child.prop === prop) {
11873 return callback(child, i2);
11874 }
11875 });
11876 };
11877 _proto.walkRules = function walkRules(selector, callback) {
11878 if (!callback) {
11879 callback = selector;
11880 return this.walk(function(child, i2) {
11881 if (child.type === "rule") {
11882 return callback(child, i2);
11883 }
11884 });
11885 }
11886 if (_instanceof(selector, RegExp)) {
11887 return this.walk(function(child, i2) {
11888 if (child.type === "rule" && selector.test(child.selector)) {
11889 return callback(child, i2);
11890 }
11891 });
11892 }
11893 return this.walk(function(child, i2) {
11894 if (child.type === "rule" && child.selector === selector) {
11895 return callback(child, i2);
11896 }
11897 });
11898 };
11899 _create_class(Container, [
11900 {
11901 key: "first",
11902 get: function get() {
11903 if (!this.proxyOf.nodes) return void 0;
11904 return this.proxyOf.nodes[0];
11905 }
11906 },
11907 {
11908 key: "last",
11909 get: function get() {
11910 if (!this.proxyOf.nodes) return void 0;
11911 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
11912 }
11913 }
11914 ]);
11915 return Container;
11916 }(Node$1$1);
11917 Container$7$1.registerParse = function(dependant) {
11918 parse$4$1 = dependant;
11919 };
11920 Container$7$1.registerRule = function(dependant) {
11921 Rule$4$1 = dependant;
11922 };
11923 Container$7$1.registerAtRule = function(dependant) {
11924 AtRule$4$1 = dependant;
11925 };
11926 Container$7$1.registerRoot = function(dependant) {
11927 Root$6$1 = dependant;
11928 };
11929 var container$1 = Container$7$1;
11930 Container$7$1.default = Container$7$1;
11931 Container$7$1.rebuild = function(node2) {
11932 if (node2.type === "atrule") {
11933 Object.setPrototypeOf(node2, AtRule$4$1.prototype);
11934 } else if (node2.type === "rule") {
11935 Object.setPrototypeOf(node2, Rule$4$1.prototype);
11936 } else if (node2.type === "decl") {
11937 Object.setPrototypeOf(node2, Declaration$3$1.prototype);
11938 } else if (node2.type === "comment") {
11939 Object.setPrototypeOf(node2, Comment$3$1.prototype);
11940 } else if (node2.type === "root") {
11941 Object.setPrototypeOf(node2, Root$6$1.prototype);
11942 }
11943 node2[my$1$1] = true;
11944 if (node2.nodes) {
11945 node2.nodes.forEach(function(child) {
11946 Container$7$1.rebuild(child);
11947 });
11948 }
11949 };
11950 var Container$6$1 = container$1;
11951 var LazyResult$4$1, Processor$3$1;
11952 var Document$3$1 = /*#__PURE__*/ function(Container$6$1) {
11953 _inherits(Document2, Container$6$1);
11954 function Document2(defaults) {
11955 var _this;
11956 _this = Container$6$1.call(this, _extends({
11957 type: "document"
11958 }, defaults)) || this;
11959 if (!_this.nodes) {
11960 _this.nodes = [];
11961 }
11962 return _this;
11963 }
11964 var _proto = Document2.prototype;
11965 _proto.toResult = function toResult(opts) {
11966 if (opts === void 0) opts = {};
11967 var lazy = new LazyResult$4$1(new Processor$3$1(), this, opts);
11968 return lazy.stringify();
11969 };
11970 return Document2;
11971 }(Container$6$1);
11972 Document$3$1.registerLazyResult = function(dependant) {
11973 LazyResult$4$1 = dependant;
11974 };
11975 Document$3$1.registerProcessor = function(dependant) {
11976 Processor$3$1 = dependant;
11977 };
11978 var document$1$1 = Document$3$1;
11979 Document$3$1.default = Document$3$1;
11980 var printed$1 = {};
11981 var warnOnce$2$1 = function warnOnce(message) {
11982 if (printed$1[message]) return;
11983 printed$1[message] = true;
11984 if (typeof console !== "undefined" && console.warn) {
11985 console.warn(message);
11986 }
11987 };
11988 var Warning$2$1 = /*#__PURE__*/ function() {
11989 function Warning(text, opts) {
11990 if (opts === void 0) opts = {};
11991 this.type = "warning";
11992 this.text = text;
11993 if (opts.node && opts.node.source) {
11994 var range = opts.node.rangeBy(opts);
11995 this.line = range.start.line;
11996 this.column = range.start.column;
11997 this.endLine = range.end.line;
11998 this.endColumn = range.end.column;
11999 }
12000 for(var opt in opts)this[opt] = opts[opt];
12001 }
12002 var _proto = Warning.prototype;
12003 _proto.toString = function toString() {
12004 if (this.node) {
12005 return this.node.error(this.text, {
12006 index: this.index,
12007 plugin: this.plugin,
12008 word: this.word
12009 }).message;
12010 }
12011 if (this.plugin) {
12012 return this.plugin + ": " + this.text;
12013 }
12014 return this.text;
12015 };
12016 return Warning;
12017 }();
12018 var warning$1 = Warning$2$1;
12019 Warning$2$1.default = Warning$2$1;
12020 var Warning$1$1 = warning$1;
12021 var Result$3$1 = /*#__PURE__*/ function() {
12022 function Result(processor2, root2, opts) {
12023 this.processor = processor2;
12024 this.messages = [];
12025 this.root = root2;
12026 this.opts = opts;
12027 this.css = void 0;
12028 this.map = void 0;
12029 }
12030 var _proto = Result.prototype;
12031 _proto.toString = function toString() {
12032 return this.css;
12033 };
12034 _proto.warn = function warn(text, opts) {
12035 if (opts === void 0) opts = {};
12036 if (!opts.plugin) {
12037 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
12038 opts.plugin = this.lastPlugin.postcssPlugin;
12039 }
12040 }
12041 var warning2 = new Warning$1$1(text, opts);
12042 this.messages.push(warning2);
12043 return warning2;
12044 };
12045 _proto.warnings = function warnings() {
12046 return this.messages.filter(function(i2) {
12047 return i2.type === "warning";
12048 });
12049 };
12050 _create_class(Result, [
12051 {
12052 key: "content",
12053 get: function get() {
12054 return this.css;
12055 }
12056 }
12057 ]);
12058 return Result;
12059 }();
12060 var result$1 = Result$3$1;
12061 Result$3$1.default = Result$3$1;
12062 var SINGLE_QUOTE$1 = "'".charCodeAt(0);
12063 var DOUBLE_QUOTE$1 = '"'.charCodeAt(0);
12064 var BACKSLASH$1 = "\\".charCodeAt(0);
12065 var SLASH$1 = "/".charCodeAt(0);
12066 var NEWLINE$1 = "\n".charCodeAt(0);
12067 var SPACE$1 = " ".charCodeAt(0);
12068 var FEED$1 = "\f".charCodeAt(0);
12069 var TAB$1 = " ".charCodeAt(0);
12070 var CR$1 = "\r".charCodeAt(0);
12071 var OPEN_SQUARE$1 = "[".charCodeAt(0);
12072 var CLOSE_SQUARE$1 = "]".charCodeAt(0);
12073 var OPEN_PARENTHESES$1 = "(".charCodeAt(0);
12074 var CLOSE_PARENTHESES$1 = ")".charCodeAt(0);
12075 var OPEN_CURLY$1 = "{".charCodeAt(0);
12076 var CLOSE_CURLY$1 = "}".charCodeAt(0);
12077 var SEMICOLON$1 = ";".charCodeAt(0);
12078 var ASTERISK$1 = "*".charCodeAt(0);
12079 var COLON$1 = ":".charCodeAt(0);
12080 var AT$1 = "@".charCodeAt(0);
12081 var RE_AT_END$1 = /[\t\n\f\r "#'()/;[\\\]{}]/g;
12082 var RE_WORD_END$1 = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
12083 var RE_BAD_BRACKET$1 = /.[\r\n"'(/\\]/;
12084 var RE_HEX_ESCAPE$1 = /[\da-f]/i;
12085 var tokenize$1 = function tokenizer(input2, options) {
12086 if (options === void 0) options = {};
12087 var css = input2.css.valueOf();
12088 var ignore = options.ignoreErrors;
12089 var code, next, quote, content, escape;
12090 var escaped, escapePos, prev, n2, currentToken;
12091 var length = css.length;
12092 var pos = 0;
12093 var buffer = [];
12094 var returned = [];
12095 function position() {
12096 return pos;
12097 }
12098 function unclosed(what) {
12099 throw input2.error("Unclosed " + what, pos);
12100 }
12101 function endOfFile() {
12102 return returned.length === 0 && pos >= length;
12103 }
12104 function nextToken(opts) {
12105 if (returned.length) return returned.pop();
12106 if (pos >= length) return;
12107 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
12108 code = css.charCodeAt(pos);
12109 switch(code){
12110 case NEWLINE$1:
12111 case SPACE$1:
12112 case TAB$1:
12113 case CR$1:
12114 case FEED$1:
12115 {
12116 next = pos;
12117 do {
12118 next += 1;
12119 code = css.charCodeAt(next);
12120 }while (code === SPACE$1 || code === NEWLINE$1 || code === TAB$1 || code === CR$1 || code === FEED$1);
12121 currentToken = [
12122 "space",
12123 css.slice(pos, next)
12124 ];
12125 pos = next - 1;
12126 break;
12127 }
12128 case OPEN_SQUARE$1:
12129 case CLOSE_SQUARE$1:
12130 case OPEN_CURLY$1:
12131 case CLOSE_CURLY$1:
12132 case COLON$1:
12133 case SEMICOLON$1:
12134 case CLOSE_PARENTHESES$1:
12135 {
12136 var controlChar = String.fromCharCode(code);
12137 currentToken = [
12138 controlChar,
12139 controlChar,
12140 pos
12141 ];
12142 break;
12143 }
12144 case OPEN_PARENTHESES$1:
12145 {
12146 prev = buffer.length ? buffer.pop()[1] : "";
12147 n2 = css.charCodeAt(pos + 1);
12148 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) {
12149 next = pos;
12150 do {
12151 escaped = false;
12152 next = css.indexOf(")", next + 1);
12153 if (next === -1) {
12154 if (ignore || ignoreUnclosed) {
12155 next = pos;
12156 break;
12157 } else {
12158 unclosed("bracket");
12159 }
12160 }
12161 escapePos = next;
12162 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12163 escapePos -= 1;
12164 escaped = !escaped;
12165 }
12166 }while (escaped);
12167 currentToken = [
12168 "brackets",
12169 css.slice(pos, next + 1),
12170 pos,
12171 next
12172 ];
12173 pos = next;
12174 } else {
12175 next = css.indexOf(")", pos + 1);
12176 content = css.slice(pos, next + 1);
12177 if (next === -1 || RE_BAD_BRACKET$1.test(content)) {
12178 currentToken = [
12179 "(",
12180 "(",
12181 pos
12182 ];
12183 } else {
12184 currentToken = [
12185 "brackets",
12186 content,
12187 pos,
12188 next
12189 ];
12190 pos = next;
12191 }
12192 }
12193 break;
12194 }
12195 case SINGLE_QUOTE$1:
12196 case DOUBLE_QUOTE$1:
12197 {
12198 quote = code === SINGLE_QUOTE$1 ? "'" : '"';
12199 next = pos;
12200 do {
12201 escaped = false;
12202 next = css.indexOf(quote, next + 1);
12203 if (next === -1) {
12204 if (ignore || ignoreUnclosed) {
12205 next = pos + 1;
12206 break;
12207 } else {
12208 unclosed("string");
12209 }
12210 }
12211 escapePos = next;
12212 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12213 escapePos -= 1;
12214 escaped = !escaped;
12215 }
12216 }while (escaped);
12217 currentToken = [
12218 "string",
12219 css.slice(pos, next + 1),
12220 pos,
12221 next
12222 ];
12223 pos = next;
12224 break;
12225 }
12226 case AT$1:
12227 {
12228 RE_AT_END$1.lastIndex = pos + 1;
12229 RE_AT_END$1.test(css);
12230 if (RE_AT_END$1.lastIndex === 0) {
12231 next = css.length - 1;
12232 } else {
12233 next = RE_AT_END$1.lastIndex - 2;
12234 }
12235 currentToken = [
12236 "at-word",
12237 css.slice(pos, next + 1),
12238 pos,
12239 next
12240 ];
12241 pos = next;
12242 break;
12243 }
12244 case BACKSLASH$1:
12245 {
12246 next = pos;
12247 escape = true;
12248 while(css.charCodeAt(next + 1) === BACKSLASH$1){
12249 next += 1;
12250 escape = !escape;
12251 }
12252 code = css.charCodeAt(next + 1);
12253 if (escape && code !== SLASH$1 && code !== SPACE$1 && code !== NEWLINE$1 && code !== TAB$1 && code !== CR$1 && code !== FEED$1) {
12254 next += 1;
12255 if (RE_HEX_ESCAPE$1.test(css.charAt(next))) {
12256 while(RE_HEX_ESCAPE$1.test(css.charAt(next + 1))){
12257 next += 1;
12258 }
12259 if (css.charCodeAt(next + 1) === SPACE$1) {
12260 next += 1;
12261 }
12262 }
12263 }
12264 currentToken = [
12265 "word",
12266 css.slice(pos, next + 1),
12267 pos,
12268 next
12269 ];
12270 pos = next;
12271 break;
12272 }
12273 default:
12274 {
12275 if (code === SLASH$1 && css.charCodeAt(pos + 1) === ASTERISK$1) {
12276 next = css.indexOf("*/", pos + 2) + 1;
12277 if (next === 0) {
12278 if (ignore || ignoreUnclosed) {
12279 next = css.length;
12280 } else {
12281 unclosed("comment");
12282 }
12283 }
12284 currentToken = [
12285 "comment",
12286 css.slice(pos, next + 1),
12287 pos,
12288 next
12289 ];
12290 pos = next;
12291 } else {
12292 RE_WORD_END$1.lastIndex = pos + 1;
12293 RE_WORD_END$1.test(css);
12294 if (RE_WORD_END$1.lastIndex === 0) {
12295 next = css.length - 1;
12296 } else {
12297 next = RE_WORD_END$1.lastIndex - 2;
12298 }
12299 currentToken = [
12300 "word",
12301 css.slice(pos, next + 1),
12302 pos,
12303 next
12304 ];
12305 buffer.push(currentToken);
12306 pos = next;
12307 }
12308 break;
12309 }
12310 }
12311 pos++;
12312 return currentToken;
12313 }
12314 function back(token) {
12315 returned.push(token);
12316 }
12317 return {
12318 back: back,
12319 endOfFile: endOfFile,
12320 nextToken: nextToken,
12321 position: position
12322 };
12323 };
12324 var Container$5$1 = container$1;
12325 var AtRule$3$1 = /*#__PURE__*/ function(Container$5$1) {
12326 _inherits(AtRule, Container$5$1);
12327 function AtRule(defaults) {
12328 var _this;
12329 _this = Container$5$1.call(this, defaults) || this;
12330 _this.type = "atrule";
12331 return _this;
12332 }
12333 var _proto = AtRule.prototype;
12334 _proto.append = function append() {
12335 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12336 children[_key] = arguments[_key];
12337 }
12338 var _Container$5$1_prototype_append;
12339 if (!this.proxyOf.nodes) this.nodes = [];
12340 return (_Container$5$1_prototype_append = Container$5$1.prototype.append).call.apply(_Container$5$1_prototype_append, [].concat([
12341 this
12342 ], children));
12343 };
12344 _proto.prepend = function prepend() {
12345 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12346 children[_key] = arguments[_key];
12347 }
12348 var _Container$5$1_prototype_prepend;
12349 if (!this.proxyOf.nodes) this.nodes = [];
12350 return (_Container$5$1_prototype_prepend = Container$5$1.prototype.prepend).call.apply(_Container$5$1_prototype_prepend, [].concat([
12351 this
12352 ], children));
12353 };
12354 return AtRule;
12355 }(Container$5$1);
12356 var atRule$1 = AtRule$3$1;
12357 AtRule$3$1.default = AtRule$3$1;
12358 Container$5$1.registerAtRule(AtRule$3$1);
12359 var Container$4$1 = container$1;
12360 var LazyResult$3$1, Processor$2$1;
12361 var Root$5$1 = /*#__PURE__*/ function(Container$4$1) {
12362 _inherits(Root, Container$4$1);
12363 function Root(defaults) {
12364 var _this;
12365 _this = Container$4$1.call(this, defaults) || this;
12366 _this.type = "root";
12367 if (!_this.nodes) _this.nodes = [];
12368 return _this;
12369 }
12370 var _proto = Root.prototype;
12371 _proto.normalize = function normalize(child, sample, type) {
12372 var nodes = Container$4$1.prototype.normalize.call(this, child);
12373 if (sample) {
12374 if (type === "prepend") {
12375 if (this.nodes.length > 1) {
12376 sample.raws.before = this.nodes[1].raws.before;
12377 } else {
12378 delete sample.raws.before;
12379 }
12380 } else if (this.first !== sample) {
12381 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12382 var node2 = _step.value;
12383 node2.raws.before = sample.raws.before;
12384 }
12385 }
12386 }
12387 return nodes;
12388 };
12389 _proto.removeChild = function removeChild(child, ignore) {
12390 var index2 = this.index(child);
12391 if (!ignore && index2 === 0 && this.nodes.length > 1) {
12392 this.nodes[1].raws.before = this.nodes[index2].raws.before;
12393 }
12394 return Container$4$1.prototype.removeChild.call(this, child);
12395 };
12396 _proto.toResult = function toResult(opts) {
12397 if (opts === void 0) opts = {};
12398 var lazy = new LazyResult$3$1(new Processor$2$1(), this, opts);
12399 return lazy.stringify();
12400 };
12401 return Root;
12402 }(Container$4$1);
12403 Root$5$1.registerLazyResult = function(dependant) {
12404 LazyResult$3$1 = dependant;
12405 };
12406 Root$5$1.registerProcessor = function(dependant) {
12407 Processor$2$1 = dependant;
12408 };
12409 var root$1 = Root$5$1;
12410 Root$5$1.default = Root$5$1;
12411 Container$4$1.registerRoot(Root$5$1);
12412 var list$2$1 = {
12413 comma: function comma(string) {
12414 return list$2$1.split(string, [
12415 ","
12416 ], true);
12417 },
12418 space: function space(string) {
12419 var spaces = [
12420 " ",
12421 "\n",
12422 " "
12423 ];
12424 return list$2$1.split(string, spaces);
12425 },
12426 split: function split(string, separators, last) {
12427 var array = [];
12428 var current = "";
12429 var split = false;
12430 var func = 0;
12431 var inQuote = false;
12432 var prevQuote = "";
12433 var escape = false;
12434 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
12435 var letter = _step.value;
12436 if (escape) {
12437 escape = false;
12438 } else if (letter === "\\") {
12439 escape = true;
12440 } else if (inQuote) {
12441 if (letter === prevQuote) {
12442 inQuote = false;
12443 }
12444 } else if (letter === '"' || letter === "'") {
12445 inQuote = true;
12446 prevQuote = letter;
12447 } else if (letter === "(") {
12448 func += 1;
12449 } else if (letter === ")") {
12450 if (func > 0) func -= 1;
12451 } else if (func === 0) {
12452 if (separators.includes(letter)) split = true;
12453 }
12454 if (split) {
12455 if (current !== "") array.push(current.trim());
12456 current = "";
12457 split = false;
12458 } else {
12459 current += letter;
12460 }
12461 }
12462 if (last || current !== "") array.push(current.trim());
12463 return array;
12464 }
12465 };
12466 var list_1$1 = list$2$1;
12467 list$2$1.default = list$2$1;
12468 var Container$3$1 = container$1;
12469 var list$1$1 = list_1$1;
12470 var Rule$3$1 = /*#__PURE__*/ function(Container$3$1) {
12471 _inherits(Rule, Container$3$1);
12472 function Rule(defaults) {
12473 var _this;
12474 _this = Container$3$1.call(this, defaults) || this;
12475 _this.type = "rule";
12476 if (!_this.nodes) _this.nodes = [];
12477 return _this;
12478 }
12479 _create_class(Rule, [
12480 {
12481 key: "selectors",
12482 get: function get() {
12483 return list$1$1.comma(this.selector);
12484 },
12485 set: function set(values) {
12486 var match = this.selector ? this.selector.match(/,\s*/) : null;
12487 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
12488 this.selector = values.join(sep2);
12489 }
12490 }
12491 ]);
12492 return Rule;
12493 }(Container$3$1);
12494 var rule$1 = Rule$3$1;
12495 Rule$3$1.default = Rule$3$1;
12496 Container$3$1.registerRule(Rule$3$1);
12497 var Declaration$2$1 = declaration$1;
12498 var tokenizer2$1 = tokenize$1;
12499 var Comment$2$1 = comment$1;
12500 var AtRule$2$1 = atRule$1;
12501 var Root$4$1 = root$1;
12502 var Rule$2$1 = rule$1;
12503 var SAFE_COMMENT_NEIGHBOR$1 = {
12504 empty: true,
12505 space: true
12506 };
12507 function findLastWithPosition$1(tokens) {
12508 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
12509 var token = tokens[i2];
12510 var pos = token[3] || token[2];
12511 if (pos) return pos;
12512 }
12513 }
12514 var Parser$1$1 = /*#__PURE__*/ function() {
12515 function Parser(input2) {
12516 this.input = input2;
12517 this.root = new Root$4$1();
12518 this.current = this.root;
12519 this.spaces = "";
12520 this.semicolon = false;
12521 this.createTokenizer();
12522 this.root.source = {
12523 input: input2,
12524 start: {
12525 column: 1,
12526 line: 1,
12527 offset: 0
12528 }
12529 };
12530 }
12531 var _proto = Parser.prototype;
12532 _proto.atrule = function atrule(token) {
12533 var node2 = new AtRule$2$1();
12534 node2.name = token[1].slice(1);
12535 if (node2.name === "") {
12536 this.unnamedAtrule(node2, token);
12537 }
12538 this.init(node2, token[2]);
12539 var type;
12540 var prev;
12541 var shift;
12542 var last = false;
12543 var open = false;
12544 var params = [];
12545 var brackets = [];
12546 while(!this.tokenizer.endOfFile()){
12547 token = this.tokenizer.nextToken();
12548 type = token[0];
12549 if (type === "(" || type === "[") {
12550 brackets.push(type === "(" ? ")" : "]");
12551 } else if (type === "{" && brackets.length > 0) {
12552 brackets.push("}");
12553 } else if (type === brackets[brackets.length - 1]) {
12554 brackets.pop();
12555 }
12556 if (brackets.length === 0) {
12557 if (type === ";") {
12558 node2.source.end = this.getPosition(token[2]);
12559 node2.source.end.offset++;
12560 this.semicolon = true;
12561 break;
12562 } else if (type === "{") {
12563 open = true;
12564 break;
12565 } else if (type === "}") {
12566 if (params.length > 0) {
12567 shift = params.length - 1;
12568 prev = params[shift];
12569 while(prev && prev[0] === "space"){
12570 prev = params[--shift];
12571 }
12572 if (prev) {
12573 node2.source.end = this.getPosition(prev[3] || prev[2]);
12574 node2.source.end.offset++;
12575 }
12576 }
12577 this.end(token);
12578 break;
12579 } else {
12580 params.push(token);
12581 }
12582 } else {
12583 params.push(token);
12584 }
12585 if (this.tokenizer.endOfFile()) {
12586 last = true;
12587 break;
12588 }
12589 }
12590 node2.raws.between = this.spacesAndCommentsFromEnd(params);
12591 if (params.length) {
12592 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
12593 this.raw(node2, "params", params);
12594 if (last) {
12595 token = params[params.length - 1];
12596 node2.source.end = this.getPosition(token[3] || token[2]);
12597 node2.source.end.offset++;
12598 this.spaces = node2.raws.between;
12599 node2.raws.between = "";
12600 }
12601 } else {
12602 node2.raws.afterName = "";
12603 node2.params = "";
12604 }
12605 if (open) {
12606 node2.nodes = [];
12607 this.current = node2;
12608 }
12609 };
12610 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
12611 var colon = this.colon(tokens);
12612 if (colon === false) return;
12613 var founded = 0;
12614 var token;
12615 for(var j = colon - 1; j >= 0; j--){
12616 token = tokens[j];
12617 if (token[0] !== "space") {
12618 founded += 1;
12619 if (founded === 2) break;
12620 }
12621 }
12622 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
12623 };
12624 _proto.colon = function colon(tokens) {
12625 var brackets = 0;
12626 var token, type, prev;
12627 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
12628 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
12629 token = element;
12630 type = token[0];
12631 if (type === "(") {
12632 brackets += 1;
12633 }
12634 if (type === ")") {
12635 brackets -= 1;
12636 }
12637 if (brackets === 0 && type === ":") {
12638 if (!prev) {
12639 this.doubleColon(token);
12640 } else if (prev[0] === "word" && prev[1] === "progid") {
12641 continue;
12642 } else {
12643 return i2;
12644 }
12645 }
12646 prev = token;
12647 }
12648 return false;
12649 };
12650 _proto.comment = function comment(token) {
12651 var node2 = new Comment$2$1();
12652 this.init(node2, token[2]);
12653 node2.source.end = this.getPosition(token[3] || token[2]);
12654 node2.source.end.offset++;
12655 var text = token[1].slice(2, -2);
12656 if (/^\s*$/.test(text)) {
12657 node2.text = "";
12658 node2.raws.left = text;
12659 node2.raws.right = "";
12660 } else {
12661 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
12662 node2.text = match[2];
12663 node2.raws.left = match[1];
12664 node2.raws.right = match[3];
12665 }
12666 };
12667 _proto.createTokenizer = function createTokenizer() {
12668 this.tokenizer = tokenizer2$1(this.input);
12669 };
12670 _proto.decl = function decl(tokens, customProperty) {
12671 var node2 = new Declaration$2$1();
12672 this.init(node2, tokens[0][2]);
12673 var last = tokens[tokens.length - 1];
12674 if (last[0] === ";") {
12675 this.semicolon = true;
12676 tokens.pop();
12677 }
12678 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition$1(tokens));
12679 node2.source.end.offset++;
12680 while(tokens[0][0] !== "word"){
12681 if (tokens.length === 1) this.unknownWord(tokens);
12682 node2.raws.before += tokens.shift()[1];
12683 }
12684 node2.source.start = this.getPosition(tokens[0][2]);
12685 node2.prop = "";
12686 while(tokens.length){
12687 var type = tokens[0][0];
12688 if (type === ":" || type === "space" || type === "comment") {
12689 break;
12690 }
12691 node2.prop += tokens.shift()[1];
12692 }
12693 node2.raws.between = "";
12694 var token;
12695 while(tokens.length){
12696 token = tokens.shift();
12697 if (token[0] === ":") {
12698 node2.raws.between += token[1];
12699 break;
12700 } else {
12701 if (token[0] === "word" && /\w/.test(token[1])) {
12702 this.unknownWord([
12703 token
12704 ]);
12705 }
12706 node2.raws.between += token[1];
12707 }
12708 }
12709 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
12710 node2.raws.before += node2.prop[0];
12711 node2.prop = node2.prop.slice(1);
12712 }
12713 var firstSpaces = [];
12714 var next;
12715 while(tokens.length){
12716 next = tokens[0][0];
12717 if (next !== "space" && next !== "comment") break;
12718 firstSpaces.push(tokens.shift());
12719 }
12720 this.precheckMissedSemicolon(tokens);
12721 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
12722 token = tokens[i2];
12723 if (token[1].toLowerCase() === "!important") {
12724 node2.important = true;
12725 var string = this.stringFrom(tokens, i2);
12726 string = this.spacesFromEnd(tokens) + string;
12727 if (string !== " !important") node2.raws.important = string;
12728 break;
12729 } else if (token[1].toLowerCase() === "important") {
12730 var cache = tokens.slice(0);
12731 var str = "";
12732 for(var j = i2; j > 0; j--){
12733 var type1 = cache[j][0];
12734 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
12735 break;
12736 }
12737 str = cache.pop()[1] + str;
12738 }
12739 if (str.trim().indexOf("!") === 0) {
12740 node2.important = true;
12741 node2.raws.important = str;
12742 tokens = cache;
12743 }
12744 }
12745 if (token[0] !== "space" && token[0] !== "comment") {
12746 break;
12747 }
12748 }
12749 var hasWord = tokens.some(function(i2) {
12750 return i2[0] !== "space" && i2[0] !== "comment";
12751 });
12752 if (hasWord) {
12753 node2.raws.between += firstSpaces.map(function(i2) {
12754 return i2[1];
12755 }).join("");
12756 firstSpaces = [];
12757 }
12758 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
12759 if (node2.value.includes(":") && !customProperty) {
12760 this.checkMissedSemicolon(tokens);
12761 }
12762 };
12763 _proto.doubleColon = function doubleColon(token) {
12764 throw this.input.error("Double colon", {
12765 offset: token[2]
12766 }, {
12767 offset: token[2] + token[1].length
12768 });
12769 };
12770 _proto.emptyRule = function emptyRule(token) {
12771 var node2 = new Rule$2$1();
12772 this.init(node2, token[2]);
12773 node2.selector = "";
12774 node2.raws.between = "";
12775 this.current = node2;
12776 };
12777 _proto.end = function end(token) {
12778 if (this.current.nodes && this.current.nodes.length) {
12779 this.current.raws.semicolon = this.semicolon;
12780 }
12781 this.semicolon = false;
12782 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
12783 this.spaces = "";
12784 if (this.current.parent) {
12785 this.current.source.end = this.getPosition(token[2]);
12786 this.current.source.end.offset++;
12787 this.current = this.current.parent;
12788 } else {
12789 this.unexpectedClose(token);
12790 }
12791 };
12792 _proto.endFile = function endFile() {
12793 if (this.current.parent) this.unclosedBlock();
12794 if (this.current.nodes && this.current.nodes.length) {
12795 this.current.raws.semicolon = this.semicolon;
12796 }
12797 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
12798 this.root.source.end = this.getPosition(this.tokenizer.position());
12799 };
12800 _proto.freeSemicolon = function freeSemicolon(token) {
12801 this.spaces += token[1];
12802 if (this.current.nodes) {
12803 var prev = this.current.nodes[this.current.nodes.length - 1];
12804 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
12805 prev.raws.ownSemicolon = this.spaces;
12806 this.spaces = "";
12807 }
12808 }
12809 };
12810 // Helpers
12811 _proto.getPosition = function getPosition(offset) {
12812 var pos = this.input.fromOffset(offset);
12813 return {
12814 column: pos.col,
12815 line: pos.line,
12816 offset: offset
12817 };
12818 };
12819 _proto.init = function init(node2, offset) {
12820 this.current.push(node2);
12821 node2.source = {
12822 input: this.input,
12823 start: this.getPosition(offset)
12824 };
12825 node2.raws.before = this.spaces;
12826 this.spaces = "";
12827 if (node2.type !== "comment") this.semicolon = false;
12828 };
12829 _proto.other = function other(start) {
12830 var end = false;
12831 var type = null;
12832 var colon = false;
12833 var bracket = null;
12834 var brackets = [];
12835 var customProperty = start[1].startsWith("--");
12836 var tokens = [];
12837 var token = start;
12838 while(token){
12839 type = token[0];
12840 tokens.push(token);
12841 if (type === "(" || type === "[") {
12842 if (!bracket) bracket = token;
12843 brackets.push(type === "(" ? ")" : "]");
12844 } else if (customProperty && colon && type === "{") {
12845 if (!bracket) bracket = token;
12846 brackets.push("}");
12847 } else if (brackets.length === 0) {
12848 if (type === ";") {
12849 if (colon) {
12850 this.decl(tokens, customProperty);
12851 return;
12852 } else {
12853 break;
12854 }
12855 } else if (type === "{") {
12856 this.rule(tokens);
12857 return;
12858 } else if (type === "}") {
12859 this.tokenizer.back(tokens.pop());
12860 end = true;
12861 break;
12862 } else if (type === ":") {
12863 colon = true;
12864 }
12865 } else if (type === brackets[brackets.length - 1]) {
12866 brackets.pop();
12867 if (brackets.length === 0) bracket = null;
12868 }
12869 token = this.tokenizer.nextToken();
12870 }
12871 if (this.tokenizer.endOfFile()) end = true;
12872 if (brackets.length > 0) this.unclosedBracket(bracket);
12873 if (end && colon) {
12874 if (!customProperty) {
12875 while(tokens.length){
12876 token = tokens[tokens.length - 1][0];
12877 if (token !== "space" && token !== "comment") break;
12878 this.tokenizer.back(tokens.pop());
12879 }
12880 }
12881 this.decl(tokens, customProperty);
12882 } else {
12883 this.unknownWord(tokens);
12884 }
12885 };
12886 _proto.parse = function parse() {
12887 var token;
12888 while(!this.tokenizer.endOfFile()){
12889 token = this.tokenizer.nextToken();
12890 switch(token[0]){
12891 case "space":
12892 this.spaces += token[1];
12893 break;
12894 case ";":
12895 this.freeSemicolon(token);
12896 break;
12897 case "}":
12898 this.end(token);
12899 break;
12900 case "comment":
12901 this.comment(token);
12902 break;
12903 case "at-word":
12904 this.atrule(token);
12905 break;
12906 case "{":
12907 this.emptyRule(token);
12908 break;
12909 default:
12910 this.other(token);
12911 break;
12912 }
12913 }
12914 this.endFile();
12915 };
12916 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
12917 _proto.raw = function raw(node2, prop, tokens, customProperty) {
12918 var token, type;
12919 var length = tokens.length;
12920 var value = "";
12921 var clean = true;
12922 var next, prev;
12923 for(var i2 = 0; i2 < length; i2 += 1){
12924 token = tokens[i2];
12925 type = token[0];
12926 if (type === "space" && i2 === length - 1 && !customProperty) {
12927 clean = false;
12928 } else if (type === "comment") {
12929 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
12930 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
12931 if (!SAFE_COMMENT_NEIGHBOR$1[prev] && !SAFE_COMMENT_NEIGHBOR$1[next]) {
12932 if (value.slice(-1) === ",") {
12933 clean = false;
12934 } else {
12935 value += token[1];
12936 }
12937 } else {
12938 clean = false;
12939 }
12940 } else {
12941 value += token[1];
12942 }
12943 }
12944 if (!clean) {
12945 var raw = tokens.reduce(function(all, i2) {
12946 return all + i2[1];
12947 }, "");
12948 node2.raws[prop] = {
12949 raw: raw,
12950 value: value
12951 };
12952 }
12953 node2[prop] = value;
12954 };
12955 _proto.rule = function rule(tokens) {
12956 tokens.pop();
12957 var node2 = new Rule$2$1();
12958 this.init(node2, tokens[0][2]);
12959 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
12960 this.raw(node2, "selector", tokens);
12961 this.current = node2;
12962 };
12963 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
12964 var lastTokenType;
12965 var spaces = "";
12966 while(tokens.length){
12967 lastTokenType = tokens[tokens.length - 1][0];
12968 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
12969 spaces = tokens.pop()[1] + spaces;
12970 }
12971 return spaces;
12972 };
12973 // Errors
12974 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
12975 var next;
12976 var spaces = "";
12977 while(tokens.length){
12978 next = tokens[0][0];
12979 if (next !== "space" && next !== "comment") break;
12980 spaces += tokens.shift()[1];
12981 }
12982 return spaces;
12983 };
12984 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
12985 var lastTokenType;
12986 var spaces = "";
12987 while(tokens.length){
12988 lastTokenType = tokens[tokens.length - 1][0];
12989 if (lastTokenType !== "space") break;
12990 spaces = tokens.pop()[1] + spaces;
12991 }
12992 return spaces;
12993 };
12994 _proto.stringFrom = function stringFrom(tokens, from) {
12995 var result2 = "";
12996 for(var i2 = from; i2 < tokens.length; i2++){
12997 result2 += tokens[i2][1];
12998 }
12999 tokens.splice(from, tokens.length - from);
13000 return result2;
13001 };
13002 _proto.unclosedBlock = function unclosedBlock() {
13003 var pos = this.current.source.start;
13004 throw this.input.error("Unclosed block", pos.line, pos.column);
13005 };
13006 _proto.unclosedBracket = function unclosedBracket(bracket) {
13007 throw this.input.error("Unclosed bracket", {
13008 offset: bracket[2]
13009 }, {
13010 offset: bracket[2] + 1
13011 });
13012 };
13013 _proto.unexpectedClose = function unexpectedClose(token) {
13014 throw this.input.error("Unexpected }", {
13015 offset: token[2]
13016 }, {
13017 offset: token[2] + 1
13018 });
13019 };
13020 _proto.unknownWord = function unknownWord(tokens) {
13021 throw this.input.error("Unknown word", {
13022 offset: tokens[0][2]
13023 }, {
13024 offset: tokens[0][2] + tokens[0][1].length
13025 });
13026 };
13027 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
13028 throw this.input.error("At-rule without name", {
13029 offset: token[2]
13030 }, {
13031 offset: token[2] + token[1].length
13032 });
13033 };
13034 return Parser;
13035 }();
13036 var parser$1 = Parser$1$1;
13037 var Container$2$1 = container$1;
13038 var Parser2$1 = parser$1;
13039 var Input$2$1 = input$1;
13040 function parse$3$1(css, opts) {
13041 var input2 = new Input$2$1(css, opts);
13042 var parser2 = new Parser2$1(input2);
13043 try {
13044 parser2.parse();
13045 } catch (e2) {
13046 if (true) {
13047 if (e2.name === "CssSyntaxError" && opts && opts.from) {
13048 if (/\.scss$/i.test(opts.from)) {
13049 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
13050 } else if (/\.sass/i.test(opts.from)) {
13051 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
13052 } else if (/\.less$/i.test(opts.from)) {
13053 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
13054 }
13055 }
13056 }
13057 throw e2;
13058 }
13059 return parser2.root;
13060 }
13061 var parse_1$1 = parse$3$1;
13062 parse$3$1.default = parse$3$1;
13063 Container$2$1.registerParse(parse$3$1);
13064 var isClean$3 = symbols$1.isClean, my$3 = symbols$1.my;
13065 var MapGenerator$1$1 = mapGenerator$1;
13066 var stringify$2$1 = stringify_1$1;
13067 var Container$1$1 = container$1;
13068 var Document$2$1 = document$1$1;
13069 var warnOnce$1$1 = warnOnce$2$1;
13070 var Result$2$1 = result$1;
13071 var parse$2$1 = parse_1$1;
13072 var Root$3$1 = root$1;
13073 var TYPE_TO_CLASS_NAME$1 = {
13074 atrule: "AtRule",
13075 comment: "Comment",
13076 decl: "Declaration",
13077 document: "Document",
13078 root: "Root",
13079 rule: "Rule"
13080 };
13081 var PLUGIN_PROPS$1 = {
13082 AtRule: true,
13083 AtRuleExit: true,
13084 Comment: true,
13085 CommentExit: true,
13086 Declaration: true,
13087 DeclarationExit: true,
13088 Document: true,
13089 DocumentExit: true,
13090 Once: true,
13091 OnceExit: true,
13092 postcssPlugin: true,
13093 prepare: true,
13094 Root: true,
13095 RootExit: true,
13096 Rule: true,
13097 RuleExit: true
13098 };
13099 var NOT_VISITORS$1 = {
13100 Once: true,
13101 postcssPlugin: true,
13102 prepare: true
13103 };
13104 var CHILDREN$1 = 0;
13105 function isPromise$1(obj) {
13106 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
13107 }
13108 function getEvents$1(node2) {
13109 var key = false;
13110 var type = TYPE_TO_CLASS_NAME$1[node2.type];
13111 if (node2.type === "decl") {
13112 key = node2.prop.toLowerCase();
13113 } else if (node2.type === "atrule") {
13114 key = node2.name.toLowerCase();
13115 }
13116 if (key && node2.append) {
13117 return [
13118 type,
13119 type + "-" + key,
13120 CHILDREN$1,
13121 type + "Exit",
13122 type + "Exit-" + key
13123 ];
13124 } else if (key) {
13125 return [
13126 type,
13127 type + "-" + key,
13128 type + "Exit",
13129 type + "Exit-" + key
13130 ];
13131 } else if (node2.append) {
13132 return [
13133 type,
13134 CHILDREN$1,
13135 type + "Exit"
13136 ];
13137 } else {
13138 return [
13139 type,
13140 type + "Exit"
13141 ];
13142 }
13143 }
13144 function toStack$1(node2) {
13145 var events;
13146 if (node2.type === "document") {
13147 events = [
13148 "Document",
13149 CHILDREN$1,
13150 "DocumentExit"
13151 ];
13152 } else if (node2.type === "root") {
13153 events = [
13154 "Root",
13155 CHILDREN$1,
13156 "RootExit"
13157 ];
13158 } else {
13159 events = getEvents$1(node2);
13160 }
13161 return {
13162 eventIndex: 0,
13163 events: events,
13164 iterator: 0,
13165 node: node2,
13166 visitorIndex: 0,
13167 visitors: []
13168 };
13169 }
13170 function cleanMarks$1(node2) {
13171 node2[isClean$3] = false;
13172 if (node2.nodes) node2.nodes.forEach(function(i2) {
13173 return cleanMarks$1(i2);
13174 });
13175 return node2;
13176 }
13177 var postcss$2$1 = {};
13178 var LazyResult$2$1 = /*#__PURE__*/ function() {
13179 function LazyResult(processor2, css, opts) {
13180 var _this = this;
13181 this.stringified = false;
13182 this.processed = false;
13183 var root2;
13184 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
13185 root2 = cleanMarks$1(css);
13186 } else if (_instanceof(css, LazyResult) || _instanceof(css, Result$2$1)) {
13187 root2 = cleanMarks$1(css.root);
13188 if (css.map) {
13189 if (typeof opts.map === "undefined") opts.map = {};
13190 if (!opts.map.inline) opts.map.inline = false;
13191 opts.map.prev = css.map;
13192 }
13193 } else {
13194 var parser2 = parse$2$1;
13195 if (opts.syntax) parser2 = opts.syntax.parse;
13196 if (opts.parser) parser2 = opts.parser;
13197 if (parser2.parse) parser2 = parser2.parse;
13198 try {
13199 root2 = parser2(css, opts);
13200 } catch (error) {
13201 this.processed = true;
13202 this.error = error;
13203 }
13204 if (root2 && !root2[my$3]) {
13205 Container$1$1.rebuild(root2);
13206 }
13207 }
13208 this.result = new Result$2$1(processor2, root2, opts);
13209 this.helpers = _extends({}, postcss$2$1, {
13210 postcss: postcss$2$1,
13211 result: this.result
13212 });
13213 this.plugins = this.processor.plugins.map(function(plugin22) {
13214 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
13215 return _extends({}, plugin22, plugin22.prepare(_this.result));
13216 } else {
13217 return plugin22;
13218 }
13219 });
13220 }
13221 var _proto = LazyResult.prototype;
13222 _proto.async = function async() {
13223 if (this.error) return Promise.reject(this.error);
13224 if (this.processed) return Promise.resolve(this.result);
13225 if (!this.processing) {
13226 this.processing = this.runAsync();
13227 }
13228 return this.processing;
13229 };
13230 _proto.catch = function _catch(onRejected) {
13231 return this.async().catch(onRejected);
13232 };
13233 _proto.finally = function _finally(onFinally) {
13234 return this.async().then(onFinally, onFinally);
13235 };
13236 _proto.getAsyncError = function getAsyncError() {
13237 throw new Error("Use process(css).then(cb) to work with async plugins");
13238 };
13239 _proto.handleError = function handleError(error, node2) {
13240 var plugin22 = this.result.lastPlugin;
13241 try {
13242 if (node2) node2.addToError(error);
13243 this.error = error;
13244 if (error.name === "CssSyntaxError" && !error.plugin) {
13245 error.plugin = plugin22.postcssPlugin;
13246 error.setMessage();
13247 } else if (plugin22.postcssVersion) {
13248 if (true) {
13249 var pluginName = plugin22.postcssPlugin;
13250 var pluginVer = plugin22.postcssVersion;
13251 var runtimeVer = this.result.processor.version;
13252 var a2 = pluginVer.split(".");
13253 var b = runtimeVer.split(".");
13254 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
13255 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.");
13256 }
13257 }
13258 }
13259 } catch (err) {
13260 if (console && console.error) console.error(err);
13261 }
13262 return error;
13263 };
13264 _proto.prepareVisitors = function prepareVisitors() {
13265 var _this = this;
13266 this.listeners = {};
13267 var add = function(plugin22, type, cb) {
13268 if (!_this.listeners[type]) _this.listeners[type] = [];
13269 _this.listeners[type].push([
13270 plugin22,
13271 cb
13272 ]);
13273 };
13274 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13275 var plugin22 = _step.value;
13276 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
13277 for(var event in plugin22){
13278 if (!PLUGIN_PROPS$1[event] && /^[A-Z]/.test(event)) {
13279 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
13280 }
13281 if (!NOT_VISITORS$1[event]) {
13282 if (_type_of(plugin22[event]) === "object") {
13283 for(var filter in plugin22[event]){
13284 if (filter === "*") {
13285 add(plugin22, event, plugin22[event][filter]);
13286 } else {
13287 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
13288 }
13289 }
13290 } else if (typeof plugin22[event] === "function") {
13291 add(plugin22, event, plugin22[event]);
13292 }
13293 }
13294 }
13295 }
13296 }
13297 this.hasListener = Object.keys(this.listeners).length > 0;
13298 };
13299 _proto.runAsync = function runAsync() {
13300 var _this = this;
13301 return _async_to_generator(function() {
13302 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
13303 return _ts_generator(this, function(_state) {
13304 switch(_state.label){
13305 case 0:
13306 _this.plugin = 0;
13307 i2 = 0;
13308 _state.label = 1;
13309 case 1:
13310 if (!(i2 < _this.plugins.length)) return [
13311 3,
13312 6
13313 ];
13314 plugin22 = _this.plugins[i2];
13315 promise = _this.runOnRoot(plugin22);
13316 if (!isPromise$1(promise)) return [
13317 3,
13318 5
13319 ];
13320 _state.label = 2;
13321 case 2:
13322 _state.trys.push([
13323 2,
13324 4,
13325 ,
13326 5
13327 ]);
13328 return [
13329 4,
13330 promise
13331 ];
13332 case 3:
13333 _state.sent();
13334 return [
13335 3,
13336 5
13337 ];
13338 case 4:
13339 error = _state.sent();
13340 throw _this.handleError(error);
13341 case 5:
13342 i2++;
13343 return [
13344 3,
13345 1
13346 ];
13347 case 6:
13348 _this.prepareVisitors();
13349 if (!_this.hasListener) return [
13350 3,
13351 18
13352 ];
13353 root2 = _this.result.root;
13354 _state.label = 7;
13355 case 7:
13356 if (!!root2[isClean$3]) return [
13357 3,
13358 14
13359 ];
13360 root2[isClean$3] = true;
13361 stack = [
13362 toStack$1(root2)
13363 ];
13364 _state.label = 8;
13365 case 8:
13366 if (!(stack.length > 0)) return [
13367 3,
13368 13
13369 ];
13370 promise1 = _this.visitTick(stack);
13371 if (!isPromise$1(promise1)) return [
13372 3,
13373 12
13374 ];
13375 _state.label = 9;
13376 case 9:
13377 _state.trys.push([
13378 9,
13379 11,
13380 ,
13381 12
13382 ]);
13383 return [
13384 4,
13385 promise1
13386 ];
13387 case 10:
13388 _state.sent();
13389 return [
13390 3,
13391 12
13392 ];
13393 case 11:
13394 e2 = _state.sent();
13395 node2 = stack[stack.length - 1].node;
13396 throw _this.handleError(e2, node2);
13397 case 12:
13398 return [
13399 3,
13400 8
13401 ];
13402 case 13:
13403 return [
13404 3,
13405 7
13406 ];
13407 case 14:
13408 if (!_this.listeners.OnceExit) return [
13409 3,
13410 18
13411 ];
13412 _loop = function() {
13413 var _step_value, plugin22, visitor, roots, e2;
13414 return _ts_generator(this, function(_state) {
13415 switch(_state.label){
13416 case 0:
13417 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13418 _this.result.lastPlugin = plugin22;
13419 _state.label = 1;
13420 case 1:
13421 _state.trys.push([
13422 1,
13423 6,
13424 ,
13425 7
13426 ]);
13427 if (!(root2.type === "document")) return [
13428 3,
13429 3
13430 ];
13431 roots = root2.nodes.map(function(subRoot) {
13432 return visitor(subRoot, _this.helpers);
13433 });
13434 return [
13435 4,
13436 Promise.all(roots)
13437 ];
13438 case 2:
13439 _state.sent();
13440 return [
13441 3,
13442 5
13443 ];
13444 case 3:
13445 return [
13446 4,
13447 visitor(root2, _this.helpers)
13448 ];
13449 case 4:
13450 _state.sent();
13451 _state.label = 5;
13452 case 5:
13453 return [
13454 3,
13455 7
13456 ];
13457 case 6:
13458 e2 = _state.sent();
13459 throw _this.handleError(e2);
13460 case 7:
13461 return [
13462 2
13463 ];
13464 }
13465 });
13466 };
13467 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
13468 _state.label = 15;
13469 case 15:
13470 if (!!(_step = _iterator()).done) return [
13471 3,
13472 18
13473 ];
13474 return [
13475 5,
13476 _ts_values(_loop())
13477 ];
13478 case 16:
13479 _state.sent();
13480 _state.label = 17;
13481 case 17:
13482 return [
13483 3,
13484 15
13485 ];
13486 case 18:
13487 _this.processed = true;
13488 return [
13489 2,
13490 _this.stringify()
13491 ];
13492 }
13493 });
13494 })();
13495 };
13496 _proto.runOnRoot = function runOnRoot(plugin22) {
13497 var _this = this;
13498 this.result.lastPlugin = plugin22;
13499 try {
13500 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
13501 if (this.result.root.type === "document") {
13502 var roots = this.result.root.nodes.map(function(root2) {
13503 return plugin22.Once(root2, _this.helpers);
13504 });
13505 if (isPromise$1(roots[0])) {
13506 return Promise.all(roots);
13507 }
13508 return roots;
13509 }
13510 return plugin22.Once(this.result.root, this.helpers);
13511 } else if (typeof plugin22 === "function") {
13512 return plugin22(this.result.root, this.result);
13513 }
13514 } catch (error) {
13515 throw this.handleError(error);
13516 }
13517 };
13518 _proto.stringify = function stringify() {
13519 if (this.error) throw this.error;
13520 if (this.stringified) return this.result;
13521 this.stringified = true;
13522 this.sync();
13523 var opts = this.result.opts;
13524 var str = stringify$2$1;
13525 if (opts.syntax) str = opts.syntax.stringify;
13526 if (opts.stringifier) str = opts.stringifier;
13527 if (str.stringify) str = str.stringify;
13528 var map = new MapGenerator$1$1(str, this.result.root, this.result.opts);
13529 var data = map.generate();
13530 this.result.css = data[0];
13531 this.result.map = data[1];
13532 return this.result;
13533 };
13534 _proto.sync = function sync() {
13535 if (this.error) throw this.error;
13536 if (this.processed) return this.result;
13537 this.processed = true;
13538 if (this.processing) {
13539 throw this.getAsyncError();
13540 }
13541 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13542 var plugin22 = _step.value;
13543 var promise = this.runOnRoot(plugin22);
13544 if (isPromise$1(promise)) {
13545 throw this.getAsyncError();
13546 }
13547 }
13548 this.prepareVisitors();
13549 if (this.hasListener) {
13550 var root2 = this.result.root;
13551 while(!root2[isClean$3]){
13552 root2[isClean$3] = true;
13553 this.walkSync(root2);
13554 }
13555 if (this.listeners.OnceExit) {
13556 if (root2.type === "document") {
13557 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
13558 var subRoot = _step1.value;
13559 this.visitSync(this.listeners.OnceExit, subRoot);
13560 }
13561 } else {
13562 this.visitSync(this.listeners.OnceExit, root2);
13563 }
13564 }
13565 }
13566 return this.result;
13567 };
13568 _proto.then = function then(onFulfilled, onRejected) {
13569 if (true) {
13570 if (!("from" in this.opts)) {
13571 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.");
13572 }
13573 }
13574 return this.async().then(onFulfilled, onRejected);
13575 };
13576 _proto.toString = function toString() {
13577 return this.css;
13578 };
13579 _proto.visitSync = function visitSync(visitors, node2) {
13580 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
13581 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13582 this.result.lastPlugin = plugin22;
13583 var promise = void 0;
13584 try {
13585 promise = visitor(node2, this.helpers);
13586 } catch (e2) {
13587 throw this.handleError(e2, node2.proxyOf);
13588 }
13589 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
13590 return true;
13591 }
13592 if (isPromise$1(promise)) {
13593 throw this.getAsyncError();
13594 }
13595 }
13596 };
13597 _proto.visitTick = function visitTick(stack) {
13598 var visit2 = stack[stack.length - 1];
13599 var node2 = visit2.node, visitors = visit2.visitors;
13600 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
13601 stack.pop();
13602 return;
13603 }
13604 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
13605 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
13606 visit2.visitorIndex += 1;
13607 if (visit2.visitorIndex === visitors.length) {
13608 visit2.visitors = [];
13609 visit2.visitorIndex = 0;
13610 }
13611 this.result.lastPlugin = plugin22;
13612 try {
13613 return visitor(node2.toProxy(), this.helpers);
13614 } catch (e2) {
13615 throw this.handleError(e2, node2);
13616 }
13617 }
13618 if (visit2.iterator !== 0) {
13619 var iterator = visit2.iterator;
13620 var child;
13621 while(child = node2.nodes[node2.indexes[iterator]]){
13622 node2.indexes[iterator] += 1;
13623 if (!child[isClean$3]) {
13624 child[isClean$3] = true;
13625 stack.push(toStack$1(child));
13626 return;
13627 }
13628 }
13629 visit2.iterator = 0;
13630 delete node2.indexes[iterator];
13631 }
13632 var events = visit2.events;
13633 while(visit2.eventIndex < events.length){
13634 var event = events[visit2.eventIndex];
13635 visit2.eventIndex += 1;
13636 if (event === CHILDREN$1) {
13637 if (node2.nodes && node2.nodes.length) {
13638 node2[isClean$3] = true;
13639 visit2.iterator = node2.getIterator();
13640 }
13641 return;
13642 } else if (this.listeners[event]) {
13643 visit2.visitors = this.listeners[event];
13644 return;
13645 }
13646 }
13647 stack.pop();
13648 };
13649 _proto.walkSync = function walkSync(node2) {
13650 var _this = this;
13651 node2[isClean$3] = true;
13652 var events = getEvents$1(node2);
13653 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
13654 var event = _step.value;
13655 if (event === CHILDREN$1) {
13656 if (node2.nodes) {
13657 node2.each(function(child) {
13658 if (!child[isClean$3]) _this.walkSync(child);
13659 });
13660 }
13661 } else {
13662 var visitors = this.listeners[event];
13663 if (visitors) {
13664 if (this.visitSync(visitors, node2.toProxy())) return;
13665 }
13666 }
13667 }
13668 };
13669 _proto.warnings = function warnings() {
13670 return this.sync().warnings();
13671 };
13672 _create_class(LazyResult, [
13673 {
13674 key: "content",
13675 get: function get() {
13676 return this.stringify().content;
13677 }
13678 },
13679 {
13680 key: "css",
13681 get: function get() {
13682 return this.stringify().css;
13683 }
13684 },
13685 {
13686 key: "map",
13687 get: function get() {
13688 return this.stringify().map;
13689 }
13690 },
13691 {
13692 key: "messages",
13693 get: function get() {
13694 return this.sync().messages;
13695 }
13696 },
13697 {
13698 key: "opts",
13699 get: function get() {
13700 return this.result.opts;
13701 }
13702 },
13703 {
13704 key: "processor",
13705 get: function get() {
13706 return this.result.processor;
13707 }
13708 },
13709 {
13710 key: "root",
13711 get: function get() {
13712 return this.sync().root;
13713 }
13714 },
13715 {
13716 key: Symbol.toStringTag,
13717 get: function get() {
13718 return "LazyResult";
13719 }
13720 }
13721 ]);
13722 return LazyResult;
13723 }();
13724 LazyResult$2$1.registerPostcss = function(dependant) {
13725 postcss$2$1 = dependant;
13726 };
13727 var lazyResult$1 = LazyResult$2$1;
13728 LazyResult$2$1.default = LazyResult$2$1;
13729 Root$3$1.registerLazyResult(LazyResult$2$1);
13730 Document$2$1.registerLazyResult(LazyResult$2$1);
13731 var MapGenerator2$1 = mapGenerator$1;
13732 var stringify$1$1 = stringify_1$1;
13733 var warnOnce2$1 = warnOnce$2$1;
13734 var parse$1$1 = parse_1$1;
13735 var Result$1$1 = result$1;
13736 var NoWorkResult$1$1 = /*#__PURE__*/ function() {
13737 function NoWorkResult(processor2, css, opts) {
13738 css = css.toString();
13739 this.stringified = false;
13740 this._processor = processor2;
13741 this._css = css;
13742 this._opts = opts;
13743 this._map = void 0;
13744 var root2;
13745 var str = stringify$1$1;
13746 this.result = new Result$1$1(this._processor, root2, this._opts);
13747 this.result.css = css;
13748 var self = this;
13749 Object.defineProperty(this.result, "root", {
13750 get: function get() {
13751 return self.root;
13752 }
13753 });
13754 var map = new MapGenerator2$1(str, root2, this._opts, css);
13755 if (map.isMap()) {
13756 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
13757 if (generatedCSS) {
13758 this.result.css = generatedCSS;
13759 }
13760 if (generatedMap) {
13761 this.result.map = generatedMap;
13762 }
13763 } else {
13764 map.clearAnnotation();
13765 this.result.css = map.css;
13766 }
13767 }
13768 var _proto = NoWorkResult.prototype;
13769 _proto.async = function async() {
13770 if (this.error) return Promise.reject(this.error);
13771 return Promise.resolve(this.result);
13772 };
13773 _proto.catch = function _catch(onRejected) {
13774 return this.async().catch(onRejected);
13775 };
13776 _proto.finally = function _finally(onFinally) {
13777 return this.async().then(onFinally, onFinally);
13778 };
13779 _proto.sync = function sync() {
13780 if (this.error) throw this.error;
13781 return this.result;
13782 };
13783 _proto.then = function then(onFulfilled, onRejected) {
13784 if (true) {
13785 if (!("from" in this._opts)) {
13786 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.");
13787 }
13788 }
13789 return this.async().then(onFulfilled, onRejected);
13790 };
13791 _proto.toString = function toString() {
13792 return this._css;
13793 };
13794 _proto.warnings = function warnings() {
13795 return [];
13796 };
13797 _create_class(NoWorkResult, [
13798 {
13799 key: "content",
13800 get: function get() {
13801 return this.result.css;
13802 }
13803 },
13804 {
13805 key: "css",
13806 get: function get() {
13807 return this.result.css;
13808 }
13809 },
13810 {
13811 key: "map",
13812 get: function get() {
13813 return this.result.map;
13814 }
13815 },
13816 {
13817 key: "messages",
13818 get: function get() {
13819 return [];
13820 }
13821 },
13822 {
13823 key: "opts",
13824 get: function get() {
13825 return this.result.opts;
13826 }
13827 },
13828 {
13829 key: "processor",
13830 get: function get() {
13831 return this.result.processor;
13832 }
13833 },
13834 {
13835 key: "root",
13836 get: function get() {
13837 if (this._root) {
13838 return this._root;
13839 }
13840 var root2;
13841 var parser2 = parse$1$1;
13842 try {
13843 root2 = parser2(this._css, this._opts);
13844 } catch (error) {
13845 this.error = error;
13846 }
13847 if (this.error) {
13848 throw this.error;
13849 } else {
13850 this._root = root2;
13851 return root2;
13852 }
13853 }
13854 },
13855 {
13856 key: Symbol.toStringTag,
13857 get: function get() {
13858 return "NoWorkResult";
13859 }
13860 }
13861 ]);
13862 return NoWorkResult;
13863 }();
13864 var noWorkResult$1 = NoWorkResult$1$1;
13865 NoWorkResult$1$1.default = NoWorkResult$1$1;
13866 var NoWorkResult2$1 = noWorkResult$1;
13867 var LazyResult$1$1 = lazyResult$1;
13868 var Document$1$1 = document$1$1;
13869 var Root$2$1 = root$1;
13870 var Processor$1$1 = /*#__PURE__*/ function() {
13871 function Processor(plugins) {
13872 if (plugins === void 0) plugins = [];
13873 this.version = "8.4.38";
13874 this.plugins = this.normalize(plugins);
13875 }
13876 var _proto = Processor.prototype;
13877 _proto.normalize = function normalize(plugins) {
13878 var normalized = [];
13879 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
13880 var i2 = _step.value;
13881 if (i2.postcss === true) {
13882 i2 = i2();
13883 } else if (i2.postcss) {
13884 i2 = i2.postcss;
13885 }
13886 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
13887 normalized = normalized.concat(i2.plugins);
13888 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
13889 normalized.push(i2);
13890 } else if (typeof i2 === "function") {
13891 normalized.push(i2);
13892 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
13893 if (true) {
13894 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.");
13895 }
13896 } else {
13897 throw new Error(i2 + " is not a PostCSS plugin");
13898 }
13899 }
13900 return normalized;
13901 };
13902 _proto.process = function process1(css, opts) {
13903 if (opts === void 0) opts = {};
13904 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
13905 return new NoWorkResult2$1(this, css, opts);
13906 } else {
13907 return new LazyResult$1$1(this, css, opts);
13908 }
13909 };
13910 _proto.use = function use(plugin22) {
13911 this.plugins = this.plugins.concat(this.normalize([
13912 plugin22
13913 ]));
13914 return this;
13915 };
13916 return Processor;
13917 }();
13918 var processor$1 = Processor$1$1;
13919 Processor$1$1.default = Processor$1$1;
13920 Root$2$1.registerProcessor(Processor$1$1);
13921 Document$1$1.registerProcessor(Processor$1$1);
13922 var Declaration$1$1 = declaration$1;
13923 var PreviousMap2$1 = previousMap$1;
13924 var Comment$1$1 = comment$1;
13925 var AtRule$1$1 = atRule$1;
13926 var Input$1$1 = input$1;
13927 var Root$1$1 = root$1;
13928 var Rule$1$1 = rule$1;
13929 function fromJSON$1$1(json, inputs) {
13930 if (Array.isArray(json)) return json.map(function(n2) {
13931 return fromJSON$1$1(n2);
13932 });
13933 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
13934 "inputs"
13935 ]);
13936 if (ownInputs) {
13937 inputs = [];
13938 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
13939 var input2 = _step.value;
13940 var inputHydrated = _extends({}, input2, {
13941 __proto__: Input$1$1.prototype
13942 });
13943 if (inputHydrated.map) {
13944 inputHydrated.map = _extends({}, inputHydrated.map, {
13945 __proto__: PreviousMap2$1.prototype
13946 });
13947 }
13948 inputs.push(inputHydrated);
13949 }
13950 }
13951 if (defaults.nodes) {
13952 defaults.nodes = json.nodes.map(function(n2) {
13953 return fromJSON$1$1(n2, inputs);
13954 });
13955 }
13956 if (defaults.source) {
13957 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
13958 "inputId"
13959 ]);
13960 defaults.source = source;
13961 if (inputId != null) {
13962 defaults.source.input = inputs[inputId];
13963 }
13964 }
13965 if (defaults.type === "root") {
13966 return new Root$1$1(defaults);
13967 } else if (defaults.type === "decl") {
13968 return new Declaration$1$1(defaults);
13969 } else if (defaults.type === "rule") {
13970 return new Rule$1$1(defaults);
13971 } else if (defaults.type === "comment") {
13972 return new Comment$1$1(defaults);
13973 } else if (defaults.type === "atrule") {
13974 return new AtRule$1$1(defaults);
13975 } else {
13976 throw new Error("Unknown node type: " + json.type);
13977 }
13978 }
13979 var fromJSON_1$1 = fromJSON$1$1;
13980 fromJSON$1$1.default = fromJSON$1$1;
13981 var CssSyntaxError2$1 = cssSyntaxError$1;
13982 var Declaration2$1 = declaration$1;
13983 var LazyResult2$1 = lazyResult$1;
13984 var Container2$1 = container$1;
13985 var Processor2$1 = processor$1;
13986 var stringify$5 = stringify_1$1;
13987 var fromJSON$2 = fromJSON_1$1;
13988 var Document22 = document$1$1;
13989 var Warning2$1 = warning$1;
13990 var Comment2$1 = comment$1;
13991 var AtRule2$1 = atRule$1;
13992 var Result2$1 = result$1;
13993 var Input2$1 = input$1;
13994 var parse$5 = parse_1$1;
13995 var list$3 = list_1$1;
13996 var Rule2$1 = rule$1;
13997 var Root2$1 = root$1;
13998 var Node2$1 = node$1;
13999 function postcss$3() {
14000 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
14001 plugins[_key] = arguments[_key];
14002 }
14003 if (plugins.length === 1 && Array.isArray(plugins[0])) {
14004 plugins = plugins[0];
14005 }
14006 return new Processor2$1(plugins);
14007 }
14008 postcss$3.plugin = function plugin(name, initializer) {
14009 var warningPrinted = false;
14010 function creator() {
14011 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
14012 args[_key] = arguments[_key];
14013 }
14014 if (console && console.warn && !warningPrinted) {
14015 warningPrinted = true;
14016 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
14017 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
14018 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
14019 }
14020 }
14021 var transformer = initializer.apply(void 0, [].concat(args));
14022 transformer.postcssPlugin = name;
14023 transformer.postcssVersion = new Processor2$1().version;
14024 return transformer;
14025 }
14026 var cache;
14027 Object.defineProperty(creator, "postcss", {
14028 get: function get() {
14029 if (!cache) cache = creator();
14030 return cache;
14031 }
14032 });
14033 creator.process = function(css, processOpts, pluginOpts) {
14034 return postcss$3([
14035 creator(pluginOpts)
14036 ]).process(css, processOpts);
14037 };
14038 return creator;
14039 };
14040 postcss$3.stringify = stringify$5;
14041 postcss$3.parse = parse$5;
14042 postcss$3.fromJSON = fromJSON$2;
14043 postcss$3.list = list$3;
14044 postcss$3.comment = function(defaults) {
14045 return new Comment2$1(defaults);
14046 };
14047 postcss$3.atRule = function(defaults) {
14048 return new AtRule2$1(defaults);
14049 };
14050 postcss$3.decl = function(defaults) {
14051 return new Declaration2$1(defaults);
14052 };
14053 postcss$3.rule = function(defaults) {
14054 return new Rule2$1(defaults);
14055 };
14056 postcss$3.root = function(defaults) {
14057 return new Root2$1(defaults);
14058 };
14059 postcss$3.document = function(defaults) {
14060 return new Document22(defaults);
14061 };
14062 postcss$3.CssSyntaxError = CssSyntaxError2$1;
14063 postcss$3.Declaration = Declaration2$1;
14064 postcss$3.Container = Container2$1;
14065 postcss$3.Processor = Processor2$1;
14066 postcss$3.Document = Document22;
14067 postcss$3.Comment = Comment2$1;
14068 postcss$3.Warning = Warning2$1;
14069 postcss$3.AtRule = AtRule2$1;
14070 postcss$3.Result = Result2$1;
14071 postcss$3.Input = Input2$1;
14072 postcss$3.Rule = Rule2$1;
14073 postcss$3.Root = Root2$1;
14074 postcss$3.Node = Node2$1;
14075 LazyResult2$1.registerPostcss(postcss$3);
14076 var postcss_1$1 = postcss$3;
14077 postcss$3.default = postcss$3;
14078 var postcss$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(postcss_1$1);
14079 postcss$1$1.stringify;
14080 postcss$1$1.fromJSON;
14081 postcss$1$1.plugin;
14082 postcss$1$1.parse;
14083 postcss$1$1.list;
14084 postcss$1$1.document;
14085 postcss$1$1.comment;
14086 postcss$1$1.atRule;
14087 postcss$1$1.rule;
14088 postcss$1$1.decl;
14089 postcss$1$1.root;
14090 postcss$1$1.CssSyntaxError;
14091 postcss$1$1.Declaration;
14092 postcss$1$1.Container;
14093 postcss$1$1.Processor;
14094 postcss$1$1.Document;
14095 postcss$1$1.Comment;
14096 postcss$1$1.Warning;
14097 postcss$1$1.AtRule;
14098 postcss$1$1.Result;
14099 postcss$1$1.Input;
14100 postcss$1$1.Rule;
14101 postcss$1$1.Root;
14102 postcss$1$1.Node;
14103 var __defProp2 = Object.defineProperty;
14104 var __defNormalProp2 = function(obj, key, value) {
14105 return key in obj ? __defProp2(obj, key, {
14106 enumerable: true,
14107 configurable: true,
14108 writable: true,
14109 value: value
14110 }) : obj[key] = value;
14111 };
14112 var __publicField2 = function(obj, key, value) {
14113 return __defNormalProp2(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
14114 };
14115 function getDefaultExportFromCjs(x2) {
14116 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
14117 }
14118 function getAugmentedNamespace(n2) {
14119 if (n2.__esModule) return n2;
14120 var f2 = n2.default;
14121 if (typeof f2 == "function") {
14122 var a2 = function a22() {
14123 if (_instanceof(this, a22)) {
14124 return Reflect.construct(f2, arguments, this.constructor);
14125 }
14126 return f2.apply(this, arguments);
14127 };
14128 a2.prototype = f2.prototype;
14129 } else a2 = {};
14130 Object.defineProperty(a2, "__esModule", {
14131 value: true
14132 });
14133 Object.keys(n2).forEach(function(k) {
14134 var d = Object.getOwnPropertyDescriptor(n2, k);
14135 Object.defineProperty(a2, k, d.get ? d : {
14136 enumerable: true,
14137 get: function get() {
14138 return n2[k];
14139 }
14140 });
14141 });
14142 return a2;
14143 }
14144 var picocolors_browser = {
14145 exports: {}
14146 };
14147 var x = String;
14148 var create = function create() {
14149 return {
14150 isColorSupported: false,
14151 reset: x,
14152 bold: x,
14153 dim: x,
14154 italic: x,
14155 underline: x,
14156 inverse: x,
14157 hidden: x,
14158 strikethrough: x,
14159 black: x,
14160 red: x,
14161 green: x,
14162 yellow: x,
14163 blue: x,
14164 magenta: x,
14165 cyan: x,
14166 white: x,
14167 gray: x,
14168 bgBlack: x,
14169 bgRed: x,
14170 bgGreen: x,
14171 bgYellow: x,
14172 bgBlue: x,
14173 bgMagenta: x,
14174 bgCyan: x,
14175 bgWhite: x
14176 };
14177 };
14178 picocolors_browser.exports = create();
14179 picocolors_browser.exports.createColors = create;
14180 var picocolors_browserExports = picocolors_browser.exports;
14181 var __viteBrowserExternal = {};
14182 var __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
14183 __proto__: null,
14184 default: __viteBrowserExternal
14185 }, Symbol.toStringTag, {
14186 value: "Module"
14187 }));
14188 var require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
14189 var pico = picocolors_browserExports;
14190 var terminalHighlight$1 = require$$2;
14191 var CssSyntaxError$3 = /*#__PURE__*/ function(Error1) {
14192 _inherits(CssSyntaxError2, Error1);
14193 function CssSyntaxError2(message, line, column, source, file, plugin22) {
14194 var _this;
14195 _this = Error1.call(this, message) || this;
14196 _this.name = "CssSyntaxError";
14197 _this.reason = message;
14198 if (file) {
14199 _this.file = file;
14200 }
14201 if (source) {
14202 _this.source = source;
14203 }
14204 if (plugin22) {
14205 _this.plugin = plugin22;
14206 }
14207 if (typeof line !== "undefined" && typeof column !== "undefined") {
14208 if (typeof line === "number") {
14209 _this.line = line;
14210 _this.column = column;
14211 } else {
14212 _this.line = line.line;
14213 _this.column = line.column;
14214 _this.endLine = column.line;
14215 _this.endColumn = column.column;
14216 }
14217 }
14218 _this.setMessage();
14219 if (Error.captureStackTrace) {
14220 Error.captureStackTrace(_this, CssSyntaxError2);
14221 }
14222 return _this;
14223 }
14224 var _proto = CssSyntaxError2.prototype;
14225 _proto.setMessage = function setMessage() {
14226 this.message = this.plugin ? this.plugin + ": " : "";
14227 this.message += this.file ? this.file : "<css input>";
14228 if (typeof this.line !== "undefined") {
14229 this.message += ":" + this.line + ":" + this.column;
14230 }
14231 this.message += ": " + this.reason;
14232 };
14233 _proto.showSourceCode = function showSourceCode(color) {
14234 var _this = this;
14235 if (!this.source) return "";
14236 var css = this.source;
14237 if (color == null) color = pico.isColorSupported;
14238 if (terminalHighlight$1) {
14239 if (color) css = terminalHighlight$1(css);
14240 }
14241 var lines = css.split(/\r?\n/);
14242 var start = Math.max(this.line - 3, 0);
14243 var end = Math.min(this.line + 2, lines.length);
14244 var maxWidth = String(end).length;
14245 var mark, aside;
14246 if (color) {
14247 var _pico_createColors = pico.createColors(true), bold = _pico_createColors.bold, gray = _pico_createColors.gray, red = _pico_createColors.red;
14248 mark = function(text) {
14249 return bold(red(text));
14250 };
14251 aside = function(text) {
14252 return gray(text);
14253 };
14254 } else {
14255 mark = aside = function(str) {
14256 return str;
14257 };
14258 }
14259 return lines.slice(start, end).map(function(line, index2) {
14260 var number = start + 1 + index2;
14261 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
14262 if (number === _this.line) {
14263 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
14264 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
14265 }
14266 return " " + aside(gutter) + line;
14267 }).join("\n");
14268 };
14269 _proto.toString = function toString() {
14270 var code = this.showSourceCode();
14271 if (code) {
14272 code = "\n\n" + code + "\n";
14273 }
14274 return this.name + ": " + this.message + code;
14275 };
14276 return CssSyntaxError2;
14277 }(_wrap_native_super(Error));
14278 var cssSyntaxError = CssSyntaxError$3;
14279 CssSyntaxError$3.default = CssSyntaxError$3;
14280 var symbols = {};
14281 symbols.isClean = Symbol("isClean");
14282 symbols.my = Symbol("my");
14283 var DEFAULT_RAW = {
14284 after: "\n",
14285 beforeClose: "\n",
14286 beforeComment: "\n",
14287 beforeDecl: "\n",
14288 beforeOpen: " ",
14289 beforeRule: "\n",
14290 colon: ": ",
14291 commentLeft: " ",
14292 commentRight: " ",
14293 emptyBody: "",
14294 indent: " ",
14295 semicolon: false
14296 };
14297 function capitalize(str) {
14298 return str[0].toUpperCase() + str.slice(1);
14299 }
14300 var Stringifier$2 = /*#__PURE__*/ function() {
14301 function Stringifier2(builder) {
14302 this.builder = builder;
14303 }
14304 var _proto = Stringifier2.prototype;
14305 _proto.atrule = function atrule(node2, semicolon) {
14306 var name = "@" + node2.name;
14307 var params = node2.params ? this.rawValue(node2, "params") : "";
14308 if (typeof node2.raws.afterName !== "undefined") {
14309 name += node2.raws.afterName;
14310 } else if (params) {
14311 name += " ";
14312 }
14313 if (node2.nodes) {
14314 this.block(node2, name + params);
14315 } else {
14316 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
14317 this.builder(name + params + end, node2);
14318 }
14319 };
14320 _proto.beforeAfter = function beforeAfter(node2, detect) {
14321 var value;
14322 if (node2.type === "decl") {
14323 value = this.raw(node2, null, "beforeDecl");
14324 } else if (node2.type === "comment") {
14325 value = this.raw(node2, null, "beforeComment");
14326 } else if (detect === "before") {
14327 value = this.raw(node2, null, "beforeRule");
14328 } else {
14329 value = this.raw(node2, null, "beforeClose");
14330 }
14331 var buf = node2.parent;
14332 var depth = 0;
14333 while(buf && buf.type !== "root"){
14334 depth += 1;
14335 buf = buf.parent;
14336 }
14337 if (value.includes("\n")) {
14338 var indent = this.raw(node2, null, "indent");
14339 if (indent.length) {
14340 for(var step = 0; step < depth; step++)value += indent;
14341 }
14342 }
14343 return value;
14344 };
14345 _proto.block = function block(node2, start) {
14346 var between = this.raw(node2, "between", "beforeOpen");
14347 this.builder(start + between + "{", node2, "start");
14348 var after;
14349 if (node2.nodes && node2.nodes.length) {
14350 this.body(node2);
14351 after = this.raw(node2, "after");
14352 } else {
14353 after = this.raw(node2, "after", "emptyBody");
14354 }
14355 if (after) this.builder(after);
14356 this.builder("}", node2, "end");
14357 };
14358 _proto.body = function body(node2) {
14359 var last = node2.nodes.length - 1;
14360 while(last > 0){
14361 if (node2.nodes[last].type !== "comment") break;
14362 last -= 1;
14363 }
14364 var semicolon = this.raw(node2, "semicolon");
14365 for(var i2 = 0; i2 < node2.nodes.length; i2++){
14366 var child = node2.nodes[i2];
14367 var before = this.raw(child, "before");
14368 if (before) this.builder(before);
14369 this.stringify(child, last !== i2 || semicolon);
14370 }
14371 };
14372 _proto.comment = function comment(node2) {
14373 var left = this.raw(node2, "left", "commentLeft");
14374 var right = this.raw(node2, "right", "commentRight");
14375 this.builder("/*" + left + node2.text + right + "*/", node2);
14376 };
14377 _proto.decl = function decl(node2, semicolon) {
14378 var between = this.raw(node2, "between", "colon");
14379 var string = node2.prop + between + this.rawValue(node2, "value");
14380 if (node2.important) {
14381 string += node2.raws.important || " !important";
14382 }
14383 if (semicolon) string += ";";
14384 this.builder(string, node2);
14385 };
14386 _proto.document = function document1(node2) {
14387 this.body(node2);
14388 };
14389 _proto.raw = function raw(node2, own, detect) {
14390 var value;
14391 if (!detect) detect = own;
14392 if (own) {
14393 value = node2.raws[own];
14394 if (typeof value !== "undefined") return value;
14395 }
14396 var parent = node2.parent;
14397 if (detect === "before") {
14398 if (!parent || parent.type === "root" && parent.first === node2) {
14399 return "";
14400 }
14401 if (parent && parent.type === "document") {
14402 return "";
14403 }
14404 }
14405 if (!parent) return DEFAULT_RAW[detect];
14406 var root2 = node2.root();
14407 if (!root2.rawCache) root2.rawCache = {};
14408 if (typeof root2.rawCache[detect] !== "undefined") {
14409 return root2.rawCache[detect];
14410 }
14411 if (detect === "before" || detect === "after") {
14412 return this.beforeAfter(node2, detect);
14413 } else {
14414 var method = "raw" + capitalize(detect);
14415 if (this[method]) {
14416 value = this[method](root2, node2);
14417 } else {
14418 root2.walk(function(i2) {
14419 value = i2.raws[own];
14420 if (typeof value !== "undefined") return false;
14421 });
14422 }
14423 }
14424 if (typeof value === "undefined") value = DEFAULT_RAW[detect];
14425 root2.rawCache[detect] = value;
14426 return value;
14427 };
14428 _proto.rawBeforeClose = function rawBeforeClose(root2) {
14429 var value;
14430 root2.walk(function(i2) {
14431 if (i2.nodes && i2.nodes.length > 0) {
14432 if (typeof i2.raws.after !== "undefined") {
14433 value = i2.raws.after;
14434 if (value.includes("\n")) {
14435 value = value.replace(/[^\n]+$/, "");
14436 }
14437 return false;
14438 }
14439 }
14440 });
14441 if (value) value = value.replace(/\S/g, "");
14442 return value;
14443 };
14444 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
14445 var value;
14446 root2.walkComments(function(i2) {
14447 if (typeof i2.raws.before !== "undefined") {
14448 value = i2.raws.before;
14449 if (value.includes("\n")) {
14450 value = value.replace(/[^\n]+$/, "");
14451 }
14452 return false;
14453 }
14454 });
14455 if (typeof value === "undefined") {
14456 value = this.raw(node2, null, "beforeDecl");
14457 } else if (value) {
14458 value = value.replace(/\S/g, "");
14459 }
14460 return value;
14461 };
14462 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
14463 var value;
14464 root2.walkDecls(function(i2) {
14465 if (typeof i2.raws.before !== "undefined") {
14466 value = i2.raws.before;
14467 if (value.includes("\n")) {
14468 value = value.replace(/[^\n]+$/, "");
14469 }
14470 return false;
14471 }
14472 });
14473 if (typeof value === "undefined") {
14474 value = this.raw(node2, null, "beforeRule");
14475 } else if (value) {
14476 value = value.replace(/\S/g, "");
14477 }
14478 return value;
14479 };
14480 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
14481 var value;
14482 root2.walk(function(i2) {
14483 if (i2.type !== "decl") {
14484 value = i2.raws.between;
14485 if (typeof value !== "undefined") return false;
14486 }
14487 });
14488 return value;
14489 };
14490 _proto.rawBeforeRule = function rawBeforeRule(root2) {
14491 var value;
14492 root2.walk(function(i2) {
14493 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
14494 if (typeof i2.raws.before !== "undefined") {
14495 value = i2.raws.before;
14496 if (value.includes("\n")) {
14497 value = value.replace(/[^\n]+$/, "");
14498 }
14499 return false;
14500 }
14501 }
14502 });
14503 if (value) value = value.replace(/\S/g, "");
14504 return value;
14505 };
14506 _proto.rawColon = function rawColon(root2) {
14507 var value;
14508 root2.walkDecls(function(i2) {
14509 if (typeof i2.raws.between !== "undefined") {
14510 value = i2.raws.between.replace(/[^\s:]/g, "");
14511 return false;
14512 }
14513 });
14514 return value;
14515 };
14516 _proto.rawEmptyBody = function rawEmptyBody(root2) {
14517 var value;
14518 root2.walk(function(i2) {
14519 if (i2.nodes && i2.nodes.length === 0) {
14520 value = i2.raws.after;
14521 if (typeof value !== "undefined") return false;
14522 }
14523 });
14524 return value;
14525 };
14526 _proto.rawIndent = function rawIndent(root2) {
14527 if (root2.raws.indent) return root2.raws.indent;
14528 var value;
14529 root2.walk(function(i2) {
14530 var p = i2.parent;
14531 if (p && p !== root2 && p.parent && p.parent === root2) {
14532 if (typeof i2.raws.before !== "undefined") {
14533 var parts = i2.raws.before.split("\n");
14534 value = parts[parts.length - 1];
14535 value = value.replace(/\S/g, "");
14536 return false;
14537 }
14538 }
14539 });
14540 return value;
14541 };
14542 _proto.rawSemicolon = function rawSemicolon(root2) {
14543 var value;
14544 root2.walk(function(i2) {
14545 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
14546 value = i2.raws.semicolon;
14547 if (typeof value !== "undefined") return false;
14548 }
14549 });
14550 return value;
14551 };
14552 _proto.rawValue = function rawValue(node2, prop) {
14553 var value = node2[prop];
14554 var raw = node2.raws[prop];
14555 if (raw && raw.value === value) {
14556 return raw.raw;
14557 }
14558 return value;
14559 };
14560 _proto.root = function root(node2) {
14561 this.body(node2);
14562 if (node2.raws.after) this.builder(node2.raws.after);
14563 };
14564 _proto.rule = function rule(node2) {
14565 this.block(node2, this.rawValue(node2, "selector"));
14566 if (node2.raws.ownSemicolon) {
14567 this.builder(node2.raws.ownSemicolon, node2, "end");
14568 }
14569 };
14570 _proto.stringify = function stringify(node2, semicolon) {
14571 if (!this[node2.type]) {
14572 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
14573 }
14574 this[node2.type](node2, semicolon);
14575 };
14576 return Stringifier2;
14577 }();
14578 var stringifier = Stringifier$2;
14579 Stringifier$2.default = Stringifier$2;
14580 var Stringifier$1 = stringifier;
14581 function stringify$4(node2, builder) {
14582 var str = new Stringifier$1(builder);
14583 str.stringify(node2);
14584 }
14585 var stringify_1 = stringify$4;
14586 stringify$4.default = stringify$4;
14587 var isClean$2 = symbols.isClean, my$2 = symbols.my;
14588 var CssSyntaxError$2 = cssSyntaxError;
14589 var Stringifier22 = stringifier;
14590 var stringify$3 = stringify_1;
14591 function cloneNode(obj, parent) {
14592 var cloned = new obj.constructor();
14593 for(var i2 in obj){
14594 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
14595 continue;
14596 }
14597 if (i2 === "proxyCache") continue;
14598 var value = obj[i2];
14599 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
14600 if (i2 === "parent" && type === "object") {
14601 if (parent) cloned[i2] = parent;
14602 } else if (i2 === "source") {
14603 cloned[i2] = value;
14604 } else if (Array.isArray(value)) {
14605 cloned[i2] = value.map(function(j) {
14606 return cloneNode(j, cloned);
14607 });
14608 } else {
14609 if (type === "object" && value !== null) value = cloneNode(value);
14610 cloned[i2] = value;
14611 }
14612 }
14613 return cloned;
14614 }
14615 var Node$4 = /*#__PURE__*/ function() {
14616 function Node3(defaults) {
14617 if (defaults === void 0) defaults = {};
14618 this.raws = {};
14619 this[isClean$2] = false;
14620 this[my$2] = true;
14621 for(var name in defaults){
14622 if (name === "nodes") {
14623 this.nodes = [];
14624 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
14625 var node2 = _step.value;
14626 if (typeof node2.clone === "function") {
14627 this.append(node2.clone());
14628 } else {
14629 this.append(node2);
14630 }
14631 }
14632 } else {
14633 this[name] = defaults[name];
14634 }
14635 }
14636 }
14637 var _proto = Node3.prototype;
14638 _proto.addToError = function addToError(error) {
14639 error.postcssNode = this;
14640 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
14641 var s2 = this.source;
14642 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
14643 }
14644 return error;
14645 };
14646 _proto.after = function after(add) {
14647 this.parent.insertAfter(this, add);
14648 return this;
14649 };
14650 _proto.assign = function assign(overrides) {
14651 if (overrides === void 0) overrides = {};
14652 for(var name in overrides){
14653 this[name] = overrides[name];
14654 }
14655 return this;
14656 };
14657 _proto.before = function before(add) {
14658 this.parent.insertBefore(this, add);
14659 return this;
14660 };
14661 _proto.cleanRaws = function cleanRaws(keepBetween) {
14662 delete this.raws.before;
14663 delete this.raws.after;
14664 if (!keepBetween) delete this.raws.between;
14665 };
14666 _proto.clone = function clone(overrides) {
14667 if (overrides === void 0) overrides = {};
14668 var cloned = cloneNode(this);
14669 for(var name in overrides){
14670 cloned[name] = overrides[name];
14671 }
14672 return cloned;
14673 };
14674 _proto.cloneAfter = function cloneAfter(overrides) {
14675 if (overrides === void 0) overrides = {};
14676 var cloned = this.clone(overrides);
14677 this.parent.insertAfter(this, cloned);
14678 return cloned;
14679 };
14680 _proto.cloneBefore = function cloneBefore(overrides) {
14681 if (overrides === void 0) overrides = {};
14682 var cloned = this.clone(overrides);
14683 this.parent.insertBefore(this, cloned);
14684 return cloned;
14685 };
14686 _proto.error = function error(message, opts) {
14687 if (opts === void 0) opts = {};
14688 if (this.source) {
14689 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
14690 return this.source.input.error(message, {
14691 column: start.column,
14692 line: start.line
14693 }, {
14694 column: end.column,
14695 line: end.line
14696 }, opts);
14697 }
14698 return new CssSyntaxError$2(message);
14699 };
14700 _proto.getProxyProcessor = function getProxyProcessor() {
14701 return {
14702 get: function get(node2, prop) {
14703 if (prop === "proxyOf") {
14704 return node2;
14705 } else if (prop === "root") {
14706 return function() {
14707 return node2.root().toProxy();
14708 };
14709 } else {
14710 return node2[prop];
14711 }
14712 },
14713 set: function set(node2, prop, value) {
14714 if (node2[prop] === value) return true;
14715 node2[prop] = value;
14716 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
14717 node2.markDirty();
14718 }
14719 return true;
14720 }
14721 };
14722 };
14723 _proto.markDirty = function markDirty() {
14724 if (this[isClean$2]) {
14725 this[isClean$2] = false;
14726 var next = this;
14727 while(next = next.parent){
14728 next[isClean$2] = false;
14729 }
14730 }
14731 };
14732 _proto.next = function next() {
14733 if (!this.parent) return void 0;
14734 var index2 = this.parent.index(this);
14735 return this.parent.nodes[index2 + 1];
14736 };
14737 _proto.positionBy = function positionBy(opts, stringRepresentation) {
14738 var pos = this.source.start;
14739 if (opts.index) {
14740 pos = this.positionInside(opts.index, stringRepresentation);
14741 } else if (opts.word) {
14742 stringRepresentation = this.toString();
14743 var index2 = stringRepresentation.indexOf(opts.word);
14744 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
14745 }
14746 return pos;
14747 };
14748 _proto.positionInside = function positionInside(index2, stringRepresentation) {
14749 var string = stringRepresentation || this.toString();
14750 var column = this.source.start.column;
14751 var line = this.source.start.line;
14752 for(var i2 = 0; i2 < index2; i2++){
14753 if (string[i2] === "\n") {
14754 column = 1;
14755 line += 1;
14756 } else {
14757 column += 1;
14758 }
14759 }
14760 return {
14761 column: column,
14762 line: line
14763 };
14764 };
14765 _proto.prev = function prev() {
14766 if (!this.parent) return void 0;
14767 var index2 = this.parent.index(this);
14768 return this.parent.nodes[index2 - 1];
14769 };
14770 _proto.rangeBy = function rangeBy(opts) {
14771 var start = {
14772 column: this.source.start.column,
14773 line: this.source.start.line
14774 };
14775 var end = this.source.end ? {
14776 column: this.source.end.column + 1,
14777 line: this.source.end.line
14778 } : {
14779 column: start.column + 1,
14780 line: start.line
14781 };
14782 if (opts.word) {
14783 var stringRepresentation = this.toString();
14784 var index2 = stringRepresentation.indexOf(opts.word);
14785 if (index2 !== -1) {
14786 start = this.positionInside(index2, stringRepresentation);
14787 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
14788 }
14789 } else {
14790 if (opts.start) {
14791 start = {
14792 column: opts.start.column,
14793 line: opts.start.line
14794 };
14795 } else if (opts.index) {
14796 start = this.positionInside(opts.index);
14797 }
14798 if (opts.end) {
14799 end = {
14800 column: opts.end.column,
14801 line: opts.end.line
14802 };
14803 } else if (typeof opts.endIndex === "number") {
14804 end = this.positionInside(opts.endIndex);
14805 } else if (opts.index) {
14806 end = this.positionInside(opts.index + 1);
14807 }
14808 }
14809 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
14810 end = {
14811 column: start.column + 1,
14812 line: start.line
14813 };
14814 }
14815 return {
14816 end: end,
14817 start: start
14818 };
14819 };
14820 _proto.raw = function raw(prop, defaultType) {
14821 var str = new Stringifier22();
14822 return str.raw(this, prop, defaultType);
14823 };
14824 _proto.remove = function remove() {
14825 if (this.parent) {
14826 this.parent.removeChild(this);
14827 }
14828 this.parent = void 0;
14829 return this;
14830 };
14831 _proto.replaceWith = function replaceWith() {
14832 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
14833 nodes[_key] = arguments[_key];
14834 }
14835 if (this.parent) {
14836 var bookmark = this;
14837 var foundSelf = false;
14838 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
14839 var node2 = _step.value;
14840 if (node2 === this) {
14841 foundSelf = true;
14842 } else if (foundSelf) {
14843 this.parent.insertAfter(bookmark, node2);
14844 bookmark = node2;
14845 } else {
14846 this.parent.insertBefore(bookmark, node2);
14847 }
14848 }
14849 if (!foundSelf) {
14850 this.remove();
14851 }
14852 }
14853 return this;
14854 };
14855 _proto.root = function root() {
14856 var result2 = this;
14857 while(result2.parent && result2.parent.type !== "document"){
14858 result2 = result2.parent;
14859 }
14860 return result2;
14861 };
14862 _proto.toJSON = function toJSON(_, inputs) {
14863 var fixed = {};
14864 var emitInputs = inputs == null;
14865 inputs = inputs || /* @__PURE__ */ new Map();
14866 var inputsNextIndex = 0;
14867 for(var name in this){
14868 if (!Object.prototype.hasOwnProperty.call(this, name)) {
14869 continue;
14870 }
14871 if (name === "parent" || name === "proxyCache") continue;
14872 var value = this[name];
14873 if (Array.isArray(value)) {
14874 fixed[name] = value.map(function(i2) {
14875 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
14876 return i2.toJSON(null, inputs);
14877 } else {
14878 return i2;
14879 }
14880 });
14881 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
14882 fixed[name] = value.toJSON(null, inputs);
14883 } else if (name === "source") {
14884 var inputId = inputs.get(value.input);
14885 if (inputId == null) {
14886 inputId = inputsNextIndex;
14887 inputs.set(value.input, inputsNextIndex);
14888 inputsNextIndex++;
14889 }
14890 fixed[name] = {
14891 end: value.end,
14892 inputId: inputId,
14893 start: value.start
14894 };
14895 } else {
14896 fixed[name] = value;
14897 }
14898 }
14899 if (emitInputs) {
14900 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
14901 return input2.toJSON();
14902 });
14903 }
14904 return fixed;
14905 };
14906 _proto.toProxy = function toProxy() {
14907 if (!this.proxyCache) {
14908 this.proxyCache = new Proxy(this, this.getProxyProcessor());
14909 }
14910 return this.proxyCache;
14911 };
14912 _proto.toString = function toString(stringifier2) {
14913 if (stringifier2 === void 0) stringifier2 = stringify$3;
14914 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
14915 var result2 = "";
14916 stringifier2(this, function(i2) {
14917 result2 += i2;
14918 });
14919 return result2;
14920 };
14921 _proto.warn = function warn(result2, text, opts) {
14922 var data = {
14923 node: this
14924 };
14925 for(var i2 in opts)data[i2] = opts[i2];
14926 return result2.warn(text, data);
14927 };
14928 _create_class(Node3, [
14929 {
14930 key: "proxyOf",
14931 get: function get() {
14932 return this;
14933 }
14934 }
14935 ]);
14936 return Node3;
14937 }();
14938 var node = Node$4;
14939 Node$4.default = Node$4;
14940 var Node$3 = node;
14941 var Declaration$4 = /*#__PURE__*/ function(Node$3) {
14942 _inherits(Declaration2, Node$3);
14943 function Declaration2(defaults) {
14944 var _this;
14945 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
14946 defaults = _extends({}, defaults, {
14947 value: String(defaults.value)
14948 });
14949 }
14950 _this = Node$3.call(this, defaults) || this;
14951 _this.type = "decl";
14952 return _this;
14953 }
14954 _create_class(Declaration2, [
14955 {
14956 key: "variable",
14957 get: function get() {
14958 return this.prop.startsWith("--") || this.prop[0] === "$";
14959 }
14960 }
14961 ]);
14962 return Declaration2;
14963 }(Node$3);
14964 var declaration = Declaration$4;
14965 Declaration$4.default = Declaration$4;
14966 var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
14967 var nanoid$1 = function(size) {
14968 if (size === void 0) size = 21;
14969 var id = "";
14970 var i2 = size;
14971 while(i2--){
14972 id += urlAlphabet[Math.random() * 64 | 0];
14973 }
14974 return id;
14975 };
14976 var nonSecure = {
14977 nanoid: nanoid$1};
14978 var SourceMapConsumer$2 = require$$2.SourceMapConsumer, SourceMapGenerator$2 = require$$2.SourceMapGenerator;
14979 var existsSync = require$$2.existsSync, readFileSync = require$$2.readFileSync;
14980 var dirname$1 = require$$2.dirname, join = require$$2.join;
14981 function fromBase64(str) {
14982 if (Buffer) {
14983 return Buffer.from(str, "base64").toString();
14984 } else {
14985 return window.atob(str);
14986 }
14987 }
14988 var PreviousMap$2 = /*#__PURE__*/ function() {
14989 function PreviousMap2(css, opts) {
14990 if (opts.map === false) return;
14991 this.loadAnnotation(css);
14992 this.inline = this.startWith(this.annotation, "data:");
14993 var prev = opts.map ? opts.map.prev : void 0;
14994 var text = this.loadMap(opts.from, prev);
14995 if (!this.mapFile && opts.from) {
14996 this.mapFile = opts.from;
14997 }
14998 if (this.mapFile) this.root = dirname$1(this.mapFile);
14999 if (text) this.text = text;
15000 }
15001 var _proto = PreviousMap2.prototype;
15002 _proto.consumer = function consumer() {
15003 if (!this.consumerCache) {
15004 this.consumerCache = new SourceMapConsumer$2(this.text);
15005 }
15006 return this.consumerCache;
15007 };
15008 _proto.decodeInline = function decodeInline(text) {
15009 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
15010 var baseUri = /^data:application\/json;base64,/;
15011 var charsetUri = /^data:application\/json;charset=utf-?8,/;
15012 var uri = /^data:application\/json,/;
15013 if (charsetUri.test(text) || uri.test(text)) {
15014 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
15015 }
15016 if (baseCharsetUri.test(text) || baseUri.test(text)) {
15017 return fromBase64(text.substr(RegExp.lastMatch.length));
15018 }
15019 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
15020 throw new Error("Unsupported source map encoding " + encoding);
15021 };
15022 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
15023 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
15024 };
15025 _proto.isMap = function isMap(map) {
15026 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
15027 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
15028 };
15029 _proto.loadAnnotation = function loadAnnotation(css) {
15030 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
15031 if (!comments) return;
15032 var start = css.lastIndexOf(comments.pop());
15033 var end = css.indexOf("*/", start);
15034 if (start > -1 && end > -1) {
15035 this.annotation = this.getAnnotationURL(css.substring(start, end));
15036 }
15037 };
15038 _proto.loadFile = function loadFile(path) {
15039 this.root = dirname$1(path);
15040 if (existsSync(path)) {
15041 this.mapFile = path;
15042 return readFileSync(path, "utf-8").toString().trim();
15043 }
15044 };
15045 _proto.loadMap = function loadMap(file, prev) {
15046 if (prev === false) return false;
15047 if (prev) {
15048 if (typeof prev === "string") {
15049 return prev;
15050 } else if (typeof prev === "function") {
15051 var prevPath = prev(file);
15052 if (prevPath) {
15053 var map = this.loadFile(prevPath);
15054 if (!map) {
15055 throw new Error("Unable to load previous source map: " + prevPath.toString());
15056 }
15057 return map;
15058 }
15059 } else if (_instanceof(prev, SourceMapConsumer$2)) {
15060 return SourceMapGenerator$2.fromSourceMap(prev).toString();
15061 } else if (_instanceof(prev, SourceMapGenerator$2)) {
15062 return prev.toString();
15063 } else if (this.isMap(prev)) {
15064 return JSON.stringify(prev);
15065 } else {
15066 throw new Error("Unsupported previous source map format: " + prev.toString());
15067 }
15068 } else if (this.inline) {
15069 return this.decodeInline(this.annotation);
15070 } else if (this.annotation) {
15071 var map1 = this.annotation;
15072 if (file) map1 = join(dirname$1(file), map1);
15073 return this.loadFile(map1);
15074 }
15075 };
15076 _proto.startWith = function startWith(string, start) {
15077 if (!string) return false;
15078 return string.substr(0, start.length) === start;
15079 };
15080 _proto.withContent = function withContent() {
15081 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
15082 };
15083 return PreviousMap2;
15084 }();
15085 var previousMap = PreviousMap$2;
15086 PreviousMap$2.default = PreviousMap$2;
15087 var SourceMapConsumer$1 = require$$2.SourceMapConsumer, SourceMapGenerator$1 = require$$2.SourceMapGenerator;
15088 var fileURLToPath = require$$2.fileURLToPath, pathToFileURL$1 = require$$2.pathToFileURL;
15089 var isAbsolute = require$$2.isAbsolute, resolve$1 = require$$2.resolve;
15090 var nanoid = nonSecure.nanoid;
15091 var terminalHighlight = require$$2;
15092 var CssSyntaxError$1 = cssSyntaxError;
15093 var PreviousMap$1 = previousMap;
15094 var fromOffsetCache = Symbol("fromOffsetCache");
15095 var sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
15096 var pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
15097 var Input$4 = /*#__PURE__*/ function() {
15098 function Input2(css, opts) {
15099 if (opts === void 0) opts = {};
15100 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
15101 throw new Error("PostCSS received " + css + " instead of CSS string");
15102 }
15103 this.css = css.toString();
15104 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
15105 this.hasBOM = true;
15106 this.css = this.css.slice(1);
15107 } else {
15108 this.hasBOM = false;
15109 }
15110 if (opts.from) {
15111 if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
15112 this.file = opts.from;
15113 } else {
15114 this.file = resolve$1(opts.from);
15115 }
15116 }
15117 if (pathAvailable$1 && sourceMapAvailable$1) {
15118 var map = new PreviousMap$1(this.css, opts);
15119 if (map.text) {
15120 this.map = map;
15121 var file = map.consumer().file;
15122 if (!this.file && file) this.file = this.mapResolve(file);
15123 }
15124 }
15125 if (!this.file) {
15126 this.id = "<input css " + nanoid(6) + ">";
15127 }
15128 if (this.map) this.map.file = this.from;
15129 }
15130 var _proto = Input2.prototype;
15131 _proto.error = function error(message, line, column, opts) {
15132 if (opts === void 0) opts = {};
15133 var result2, endLine, endColumn;
15134 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
15135 var start = line;
15136 var end = column;
15137 if (typeof start.offset === "number") {
15138 var pos = this.fromOffset(start.offset);
15139 line = pos.line;
15140 column = pos.col;
15141 } else {
15142 line = start.line;
15143 column = start.column;
15144 }
15145 if (typeof end.offset === "number") {
15146 var pos1 = this.fromOffset(end.offset);
15147 endLine = pos1.line;
15148 endColumn = pos1.col;
15149 } else {
15150 endLine = end.line;
15151 endColumn = end.column;
15152 }
15153 } else if (!column) {
15154 var pos2 = this.fromOffset(line);
15155 line = pos2.line;
15156 column = pos2.col;
15157 }
15158 var origin = this.origin(line, column, endLine, endColumn);
15159 if (origin) {
15160 result2 = new CssSyntaxError$1(message, origin.endLine === void 0 ? origin.line : {
15161 column: origin.column,
15162 line: origin.line
15163 }, origin.endLine === void 0 ? origin.column : {
15164 column: origin.endColumn,
15165 line: origin.endLine
15166 }, origin.source, origin.file, opts.plugin);
15167 } else {
15168 result2 = new CssSyntaxError$1(message, endLine === void 0 ? line : {
15169 column: column,
15170 line: line
15171 }, endLine === void 0 ? column : {
15172 column: endColumn,
15173 line: endLine
15174 }, this.css, this.file, opts.plugin);
15175 }
15176 result2.input = {
15177 column: column,
15178 endColumn: endColumn,
15179 endLine: endLine,
15180 line: line,
15181 source: this.css
15182 };
15183 if (this.file) {
15184 if (pathToFileURL$1) {
15185 result2.input.url = pathToFileURL$1(this.file).toString();
15186 }
15187 result2.input.file = this.file;
15188 }
15189 return result2;
15190 };
15191 _proto.fromOffset = function fromOffset(offset) {
15192 var lastLine, lineToIndex;
15193 if (!this[fromOffsetCache]) {
15194 var lines = this.css.split("\n");
15195 lineToIndex = new Array(lines.length);
15196 var prevIndex = 0;
15197 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
15198 lineToIndex[i2] = prevIndex;
15199 prevIndex += lines[i2].length + 1;
15200 }
15201 this[fromOffsetCache] = lineToIndex;
15202 } else {
15203 lineToIndex = this[fromOffsetCache];
15204 }
15205 lastLine = lineToIndex[lineToIndex.length - 1];
15206 var min = 0;
15207 if (offset >= lastLine) {
15208 min = lineToIndex.length - 1;
15209 } else {
15210 var max = lineToIndex.length - 2;
15211 var mid;
15212 while(min < max){
15213 mid = min + (max - min >> 1);
15214 if (offset < lineToIndex[mid]) {
15215 max = mid - 1;
15216 } else if (offset >= lineToIndex[mid + 1]) {
15217 min = mid + 1;
15218 } else {
15219 min = mid;
15220 break;
15221 }
15222 }
15223 }
15224 return {
15225 col: offset - lineToIndex[min] + 1,
15226 line: min + 1
15227 };
15228 };
15229 _proto.mapResolve = function mapResolve(file) {
15230 if (/^\w+:\/\//.test(file)) {
15231 return file;
15232 }
15233 return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
15234 };
15235 _proto.origin = function origin(line, column, endLine, endColumn) {
15236 if (!this.map) return false;
15237 var consumer = this.map.consumer();
15238 var from = consumer.originalPositionFor({
15239 column: column,
15240 line: line
15241 });
15242 if (!from.source) return false;
15243 var to;
15244 if (typeof endLine === "number") {
15245 to = consumer.originalPositionFor({
15246 column: endColumn,
15247 line: endLine
15248 });
15249 }
15250 var fromUrl;
15251 if (isAbsolute(from.source)) {
15252 fromUrl = pathToFileURL$1(from.source);
15253 } else {
15254 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile));
15255 }
15256 var result2 = {
15257 column: from.column,
15258 endColumn: to && to.column,
15259 endLine: to && to.line,
15260 line: from.line,
15261 url: fromUrl.toString()
15262 };
15263 if (fromUrl.protocol === "file:") {
15264 if (fileURLToPath) {
15265 result2.file = fileURLToPath(fromUrl);
15266 } else {
15267 throw new Error("file: protocol is not available in this PostCSS build");
15268 }
15269 }
15270 var source = consumer.sourceContentFor(from.source);
15271 if (source) result2.source = source;
15272 return result2;
15273 };
15274 _proto.toJSON = function toJSON() {
15275 var json = {};
15276 for(var _i = 0, _iter = [
15277 "hasBOM",
15278 "css",
15279 "file",
15280 "id"
15281 ]; _i < _iter.length; _i++){
15282 var name = _iter[_i];
15283 if (this[name] != null) {
15284 json[name] = this[name];
15285 }
15286 }
15287 if (this.map) {
15288 json.map = _extends({}, this.map);
15289 if (json.map.consumerCache) {
15290 json.map.consumerCache = void 0;
15291 }
15292 }
15293 return json;
15294 };
15295 _create_class(Input2, [
15296 {
15297 key: "from",
15298 get: function get() {
15299 return this.file || this.id;
15300 }
15301 }
15302 ]);
15303 return Input2;
15304 }();
15305 var input = Input$4;
15306 Input$4.default = Input$4;
15307 if (terminalHighlight && terminalHighlight.registerInput) {
15308 terminalHighlight.registerInput(Input$4);
15309 }
15310 var SourceMapConsumer = require$$2.SourceMapConsumer, SourceMapGenerator = require$$2.SourceMapGenerator;
15311 var dirname = require$$2.dirname, relative = require$$2.relative, resolve$3 = require$$2.resolve, sep = require$$2.sep;
15312 var pathToFileURL = require$$2.pathToFileURL;
15313 var Input$3 = input;
15314 var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
15315 var pathAvailable = Boolean(dirname && resolve$3 && relative && sep);
15316 var MapGenerator$2 = /*#__PURE__*/ function() {
15317 function MapGenerator2(stringify2, root2, opts, cssString) {
15318 this.stringify = stringify2;
15319 this.mapOpts = opts.map || {};
15320 this.root = root2;
15321 this.opts = opts;
15322 this.css = cssString;
15323 this.originalCSS = cssString;
15324 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
15325 this.memoizedFileURLs = /* @__PURE__ */ new Map();
15326 this.memoizedPaths = /* @__PURE__ */ new Map();
15327 this.memoizedURLs = /* @__PURE__ */ new Map();
15328 }
15329 var _proto = MapGenerator2.prototype;
15330 _proto.addAnnotation = function addAnnotation() {
15331 var content;
15332 if (this.isInline()) {
15333 content = "data:application/json;base64," + this.toBase64(this.map.toString());
15334 } else if (typeof this.mapOpts.annotation === "string") {
15335 content = this.mapOpts.annotation;
15336 } else if (typeof this.mapOpts.annotation === "function") {
15337 content = this.mapOpts.annotation(this.opts.to, this.root);
15338 } else {
15339 content = this.outputFile() + ".map";
15340 }
15341 var eol = "\n";
15342 if (this.css.includes("\r\n")) eol = "\r\n";
15343 this.css += eol + "/*# sourceMappingURL=" + content + " */";
15344 };
15345 _proto.applyPrevMaps = function applyPrevMaps() {
15346 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
15347 var prev = _step.value;
15348 var from = this.toUrl(this.path(prev.file));
15349 var root2 = prev.root || dirname(prev.file);
15350 var map = void 0;
15351 if (this.mapOpts.sourcesContent === false) {
15352 map = new SourceMapConsumer(prev.text);
15353 if (map.sourcesContent) {
15354 map.sourcesContent = null;
15355 }
15356 } else {
15357 map = prev.consumer();
15358 }
15359 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
15360 }
15361 };
15362 _proto.clearAnnotation = function clearAnnotation() {
15363 if (this.mapOpts.annotation === false) return;
15364 if (this.root) {
15365 var node2;
15366 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
15367 node2 = this.root.nodes[i2];
15368 if (node2.type !== "comment") continue;
15369 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
15370 this.root.removeChild(i2);
15371 }
15372 }
15373 } else if (this.css) {
15374 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
15375 }
15376 };
15377 _proto.generate = function generate() {
15378 this.clearAnnotation();
15379 if (pathAvailable && sourceMapAvailable && this.isMap()) {
15380 return this.generateMap();
15381 } else {
15382 var result2 = "";
15383 this.stringify(this.root, function(i2) {
15384 result2 += i2;
15385 });
15386 return [
15387 result2
15388 ];
15389 }
15390 };
15391 _proto.generateMap = function generateMap() {
15392 if (this.root) {
15393 this.generateString();
15394 } else if (this.previous().length === 1) {
15395 var prev = this.previous()[0].consumer();
15396 prev.file = this.outputFile();
15397 this.map = SourceMapGenerator.fromSourceMap(prev, {
15398 ignoreInvalidMapping: true
15399 });
15400 } else {
15401 this.map = new SourceMapGenerator({
15402 file: this.outputFile(),
15403 ignoreInvalidMapping: true
15404 });
15405 this.map.addMapping({
15406 generated: {
15407 column: 0,
15408 line: 1
15409 },
15410 original: {
15411 column: 0,
15412 line: 1
15413 },
15414 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
15415 });
15416 }
15417 if (this.isSourcesContent()) this.setSourcesContent();
15418 if (this.root && this.previous().length > 0) this.applyPrevMaps();
15419 if (this.isAnnotation()) this.addAnnotation();
15420 if (this.isInline()) {
15421 return [
15422 this.css
15423 ];
15424 } else {
15425 return [
15426 this.css,
15427 this.map
15428 ];
15429 }
15430 };
15431 _proto.generateString = function generateString() {
15432 var _this = this;
15433 this.css = "";
15434 this.map = new SourceMapGenerator({
15435 file: this.outputFile(),
15436 ignoreInvalidMapping: true
15437 });
15438 var line = 1;
15439 var column = 1;
15440 var noSource = "<no source>";
15441 var mapping = {
15442 generated: {
15443 column: 0,
15444 line: 0
15445 },
15446 original: {
15447 column: 0,
15448 line: 0
15449 },
15450 source: ""
15451 };
15452 var lines, last;
15453 this.stringify(this.root, function(str, node2, type) {
15454 _this.css += str;
15455 if (node2 && type !== "end") {
15456 mapping.generated.line = line;
15457 mapping.generated.column = column - 1;
15458 if (node2.source && node2.source.start) {
15459 mapping.source = _this.sourcePath(node2);
15460 mapping.original.line = node2.source.start.line;
15461 mapping.original.column = node2.source.start.column - 1;
15462 _this.map.addMapping(mapping);
15463 } else {
15464 mapping.source = noSource;
15465 mapping.original.line = 1;
15466 mapping.original.column = 0;
15467 _this.map.addMapping(mapping);
15468 }
15469 }
15470 lines = str.match(/\n/g);
15471 if (lines) {
15472 line += lines.length;
15473 last = str.lastIndexOf("\n");
15474 column = str.length - last;
15475 } else {
15476 column += str.length;
15477 }
15478 if (node2 && type !== "start") {
15479 var p = node2.parent || {
15480 raws: {}
15481 };
15482 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
15483 if (!childless || node2 !== p.last || p.raws.semicolon) {
15484 if (node2.source && node2.source.end) {
15485 mapping.source = _this.sourcePath(node2);
15486 mapping.original.line = node2.source.end.line;
15487 mapping.original.column = node2.source.end.column - 1;
15488 mapping.generated.line = line;
15489 mapping.generated.column = column - 2;
15490 _this.map.addMapping(mapping);
15491 } else {
15492 mapping.source = noSource;
15493 mapping.original.line = 1;
15494 mapping.original.column = 0;
15495 mapping.generated.line = line;
15496 mapping.generated.column = column - 1;
15497 _this.map.addMapping(mapping);
15498 }
15499 }
15500 }
15501 });
15502 };
15503 _proto.isAnnotation = function isAnnotation() {
15504 if (this.isInline()) {
15505 return true;
15506 }
15507 if (typeof this.mapOpts.annotation !== "undefined") {
15508 return this.mapOpts.annotation;
15509 }
15510 if (this.previous().length) {
15511 return this.previous().some(function(i2) {
15512 return i2.annotation;
15513 });
15514 }
15515 return true;
15516 };
15517 _proto.isInline = function isInline() {
15518 if (typeof this.mapOpts.inline !== "undefined") {
15519 return this.mapOpts.inline;
15520 }
15521 var annotation = this.mapOpts.annotation;
15522 if (typeof annotation !== "undefined" && annotation !== true) {
15523 return false;
15524 }
15525 if (this.previous().length) {
15526 return this.previous().some(function(i2) {
15527 return i2.inline;
15528 });
15529 }
15530 return true;
15531 };
15532 _proto.isMap = function isMap() {
15533 if (typeof this.opts.map !== "undefined") {
15534 return !!this.opts.map;
15535 }
15536 return this.previous().length > 0;
15537 };
15538 _proto.isSourcesContent = function isSourcesContent() {
15539 if (typeof this.mapOpts.sourcesContent !== "undefined") {
15540 return this.mapOpts.sourcesContent;
15541 }
15542 if (this.previous().length) {
15543 return this.previous().some(function(i2) {
15544 return i2.withContent();
15545 });
15546 }
15547 return true;
15548 };
15549 _proto.outputFile = function outputFile() {
15550 if (this.opts.to) {
15551 return this.path(this.opts.to);
15552 } else if (this.opts.from) {
15553 return this.path(this.opts.from);
15554 } else {
15555 return "to.css";
15556 }
15557 };
15558 _proto.path = function path(file) {
15559 if (this.mapOpts.absolute) return file;
15560 if (file.charCodeAt(0) === 60) return file;
15561 if (/^\w+:\/\//.test(file)) return file;
15562 var cached = this.memoizedPaths.get(file);
15563 if (cached) return cached;
15564 var from = this.opts.to ? dirname(this.opts.to) : ".";
15565 if (typeof this.mapOpts.annotation === "string") {
15566 from = dirname(resolve$3(from, this.mapOpts.annotation));
15567 }
15568 var path = relative(from, file);
15569 this.memoizedPaths.set(file, path);
15570 return path;
15571 };
15572 _proto.previous = function previous() {
15573 var _this = this;
15574 if (!this.previousMaps) {
15575 this.previousMaps = [];
15576 if (this.root) {
15577 this.root.walk(function(node2) {
15578 if (node2.source && node2.source.input.map) {
15579 var map = node2.source.input.map;
15580 if (!_this.previousMaps.includes(map)) {
15581 _this.previousMaps.push(map);
15582 }
15583 }
15584 });
15585 } else {
15586 var input2 = new Input$3(this.originalCSS, this.opts);
15587 if (input2.map) this.previousMaps.push(input2.map);
15588 }
15589 }
15590 return this.previousMaps;
15591 };
15592 _proto.setSourcesContent = function setSourcesContent() {
15593 var _this = this;
15594 var already = {};
15595 if (this.root) {
15596 this.root.walk(function(node2) {
15597 if (node2.source) {
15598 var from = node2.source.input.from;
15599 if (from && !already[from]) {
15600 already[from] = true;
15601 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
15602 _this.map.setSourceContent(fromUrl, node2.source.input.css);
15603 }
15604 }
15605 });
15606 } else if (this.css) {
15607 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
15608 this.map.setSourceContent(from, this.css);
15609 }
15610 };
15611 _proto.sourcePath = function sourcePath(node2) {
15612 if (this.mapOpts.from) {
15613 return this.toUrl(this.mapOpts.from);
15614 } else if (this.usesFileUrls) {
15615 return this.toFileUrl(node2.source.input.from);
15616 } else {
15617 return this.toUrl(this.path(node2.source.input.from));
15618 }
15619 };
15620 _proto.toBase64 = function toBase64(str) {
15621 if (Buffer) {
15622 return Buffer.from(str).toString("base64");
15623 } else {
15624 return window.btoa(unescape(encodeURIComponent(str)));
15625 }
15626 };
15627 _proto.toFileUrl = function toFileUrl(path) {
15628 var cached = this.memoizedFileURLs.get(path);
15629 if (cached) return cached;
15630 if (pathToFileURL) {
15631 var fileURL = pathToFileURL(path).toString();
15632 this.memoizedFileURLs.set(path, fileURL);
15633 return fileURL;
15634 } else {
15635 throw new Error("`map.absolute` option is not available in this PostCSS build");
15636 }
15637 };
15638 _proto.toUrl = function toUrl(path) {
15639 var cached = this.memoizedURLs.get(path);
15640 if (cached) return cached;
15641 if (sep === "\\") {
15642 path = path.replace(/\\/g, "/");
15643 }
15644 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
15645 this.memoizedURLs.set(path, url);
15646 return url;
15647 };
15648 return MapGenerator2;
15649 }();
15650 var mapGenerator = MapGenerator$2;
15651 var Node$2 = node;
15652 var Comment$4 = /*#__PURE__*/ function(Node$2) {
15653 _inherits(Comment2, Node$2);
15654 function Comment2(defaults) {
15655 var _this;
15656 _this = Node$2.call(this, defaults) || this;
15657 _this.type = "comment";
15658 return _this;
15659 }
15660 return Comment2;
15661 }(Node$2);
15662 var comment = Comment$4;
15663 Comment$4.default = Comment$4;
15664 var isClean$1 = symbols.isClean, my$1 = symbols.my;
15665 var Declaration$3 = declaration;
15666 var Comment$3 = comment;
15667 var Node$1 = node;
15668 var parse$4, Rule$4, AtRule$4, Root$6;
15669 function cleanSource(nodes) {
15670 return nodes.map(function(i2) {
15671 if (i2.nodes) i2.nodes = cleanSource(i2.nodes);
15672 delete i2.source;
15673 return i2;
15674 });
15675 }
15676 function markDirtyUp(node2) {
15677 node2[isClean$1] = false;
15678 if (node2.proxyOf.nodes) {
15679 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
15680 var i2 = _step.value;
15681 markDirtyUp(i2);
15682 }
15683 }
15684 }
15685 var Container$7 = /*#__PURE__*/ function(Node$1) {
15686 _inherits(Container2, Node$1);
15687 function Container2() {
15688 return Node$1.apply(this, arguments) || this;
15689 }
15690 var _proto = Container2.prototype;
15691 _proto.append = function append() {
15692 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
15693 children[_key] = arguments[_key];
15694 }
15695 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
15696 var child = _step.value;
15697 var nodes = this.normalize(child, this.last);
15698 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15699 var node2 = _step1.value;
15700 this.proxyOf.nodes.push(node2);
15701 }
15702 }
15703 this.markDirty();
15704 return this;
15705 };
15706 _proto.cleanRaws = function cleanRaws(keepBetween) {
15707 Node$1.prototype.cleanRaws.call(this, keepBetween);
15708 if (this.nodes) {
15709 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
15710 var node2 = _step.value;
15711 node2.cleanRaws(keepBetween);
15712 }
15713 }
15714 };
15715 _proto.each = function each(callback) {
15716 if (!this.proxyOf.nodes) return void 0;
15717 var iterator = this.getIterator();
15718 var index2, result2;
15719 while(this.indexes[iterator] < this.proxyOf.nodes.length){
15720 index2 = this.indexes[iterator];
15721 result2 = callback(this.proxyOf.nodes[index2], index2);
15722 if (result2 === false) break;
15723 this.indexes[iterator] += 1;
15724 }
15725 delete this.indexes[iterator];
15726 return result2;
15727 };
15728 _proto.every = function every(condition) {
15729 return this.nodes.every(condition);
15730 };
15731 _proto.getIterator = function getIterator() {
15732 if (!this.lastEach) this.lastEach = 0;
15733 if (!this.indexes) this.indexes = {};
15734 this.lastEach += 1;
15735 var iterator = this.lastEach;
15736 this.indexes[iterator] = 0;
15737 return iterator;
15738 };
15739 _proto.getProxyProcessor = function getProxyProcessor() {
15740 return {
15741 get: function get(node2, prop) {
15742 if (prop === "proxyOf") {
15743 return node2;
15744 } else if (!node2[prop]) {
15745 return node2[prop];
15746 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
15747 return function() {
15748 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
15749 args[_key] = arguments[_key];
15750 }
15751 var _node2;
15752 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
15753 if (typeof i2 === "function") {
15754 return function(child, index2) {
15755 return i2(child.toProxy(), index2);
15756 };
15757 } else {
15758 return i2;
15759 }
15760 })));
15761 };
15762 } else if (prop === "every" || prop === "some") {
15763 return function(cb) {
15764 return node2[prop](function(child) {
15765 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
15766 other[_key - 1] = arguments[_key];
15767 }
15768 return cb.apply(void 0, [].concat([
15769 child.toProxy()
15770 ], other));
15771 });
15772 };
15773 } else if (prop === "root") {
15774 return function() {
15775 return node2.root().toProxy();
15776 };
15777 } else if (prop === "nodes") {
15778 return node2.nodes.map(function(i2) {
15779 return i2.toProxy();
15780 });
15781 } else if (prop === "first" || prop === "last") {
15782 return node2[prop].toProxy();
15783 } else {
15784 return node2[prop];
15785 }
15786 },
15787 set: function set(node2, prop, value) {
15788 if (node2[prop] === value) return true;
15789 node2[prop] = value;
15790 if (prop === "name" || prop === "params" || prop === "selector") {
15791 node2.markDirty();
15792 }
15793 return true;
15794 }
15795 };
15796 };
15797 _proto.index = function index(child) {
15798 if (typeof child === "number") return child;
15799 if (child.proxyOf) child = child.proxyOf;
15800 return this.proxyOf.nodes.indexOf(child);
15801 };
15802 _proto.insertAfter = function insertAfter(exist, add) {
15803 var existIndex = this.index(exist);
15804 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
15805 existIndex = this.index(exist);
15806 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15807 var node2 = _step.value;
15808 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
15809 }
15810 var index2;
15811 for(var id in this.indexes){
15812 index2 = this.indexes[id];
15813 if (existIndex < index2) {
15814 this.indexes[id] = index2 + nodes.length;
15815 }
15816 }
15817 this.markDirty();
15818 return this;
15819 };
15820 _proto.insertBefore = function insertBefore(exist, add) {
15821 var existIndex = this.index(exist);
15822 var type = existIndex === 0 ? "prepend" : false;
15823 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
15824 existIndex = this.index(exist);
15825 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15826 var node2 = _step.value;
15827 this.proxyOf.nodes.splice(existIndex, 0, node2);
15828 }
15829 var index2;
15830 for(var id in this.indexes){
15831 index2 = this.indexes[id];
15832 if (existIndex <= index2) {
15833 this.indexes[id] = index2 + nodes.length;
15834 }
15835 }
15836 this.markDirty();
15837 return this;
15838 };
15839 _proto.normalize = function normalize(nodes, sample) {
15840 var _this = this;
15841 if (typeof nodes === "string") {
15842 nodes = cleanSource(parse$4(nodes).nodes);
15843 } else if (typeof nodes === "undefined") {
15844 nodes = [];
15845 } else if (Array.isArray(nodes)) {
15846 nodes = nodes.slice(0);
15847 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15848 var i2 = _step.value;
15849 if (i2.parent) i2.parent.removeChild(i2, "ignore");
15850 }
15851 } else if (nodes.type === "root" && this.type !== "document") {
15852 nodes = nodes.nodes.slice(0);
15853 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15854 var i21 = _step1.value;
15855 if (i21.parent) i21.parent.removeChild(i21, "ignore");
15856 }
15857 } else if (nodes.type) {
15858 nodes = [
15859 nodes
15860 ];
15861 } else if (nodes.prop) {
15862 if (typeof nodes.value === "undefined") {
15863 throw new Error("Value field is missed in node creation");
15864 } else if (typeof nodes.value !== "string") {
15865 nodes.value = String(nodes.value);
15866 }
15867 nodes = [
15868 new Declaration$3(nodes)
15869 ];
15870 } else if (nodes.selector) {
15871 nodes = [
15872 new Rule$4(nodes)
15873 ];
15874 } else if (nodes.name) {
15875 nodes = [
15876 new AtRule$4(nodes)
15877 ];
15878 } else if (nodes.text) {
15879 nodes = [
15880 new Comment$3(nodes)
15881 ];
15882 } else {
15883 throw new Error("Unknown node type in node creation");
15884 }
15885 var processed = nodes.map(function(i2) {
15886 if (!i2[my$1]) Container2.rebuild(i2);
15887 i2 = i2.proxyOf;
15888 if (i2.parent) i2.parent.removeChild(i2);
15889 if (i2[isClean$1]) markDirtyUp(i2);
15890 if (typeof i2.raws.before === "undefined") {
15891 if (sample && typeof sample.raws.before !== "undefined") {
15892 i2.raws.before = sample.raws.before.replace(/\S/g, "");
15893 }
15894 }
15895 i2.parent = _this.proxyOf;
15896 return i2;
15897 });
15898 return processed;
15899 };
15900 _proto.prepend = function prepend() {
15901 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
15902 children[_key] = arguments[_key];
15903 }
15904 children = children.reverse();
15905 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
15906 var child = _step.value;
15907 var nodes = this.normalize(child, this.first, "prepend").reverse();
15908 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15909 var node2 = _step1.value;
15910 this.proxyOf.nodes.unshift(node2);
15911 }
15912 for(var id in this.indexes){
15913 this.indexes[id] = this.indexes[id] + nodes.length;
15914 }
15915 }
15916 this.markDirty();
15917 return this;
15918 };
15919 _proto.push = function push(child) {
15920 child.parent = this;
15921 this.proxyOf.nodes.push(child);
15922 return this;
15923 };
15924 _proto.removeAll = function removeAll() {
15925 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
15926 var node2 = _step.value;
15927 node2.parent = void 0;
15928 }
15929 this.proxyOf.nodes = [];
15930 this.markDirty();
15931 return this;
15932 };
15933 _proto.removeChild = function removeChild(child) {
15934 child = this.index(child);
15935 this.proxyOf.nodes[child].parent = void 0;
15936 this.proxyOf.nodes.splice(child, 1);
15937 var index2;
15938 for(var id in this.indexes){
15939 index2 = this.indexes[id];
15940 if (index2 >= child) {
15941 this.indexes[id] = index2 - 1;
15942 }
15943 }
15944 this.markDirty();
15945 return this;
15946 };
15947 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
15948 if (!callback) {
15949 callback = opts;
15950 opts = {};
15951 }
15952 this.walkDecls(function(decl) {
15953 if (opts.props && !opts.props.includes(decl.prop)) return;
15954 if (opts.fast && !decl.value.includes(opts.fast)) return;
15955 decl.value = decl.value.replace(pattern, callback);
15956 });
15957 this.markDirty();
15958 return this;
15959 };
15960 _proto.some = function some(condition) {
15961 return this.nodes.some(condition);
15962 };
15963 _proto.walk = function walk(callback) {
15964 return this.each(function(child, i2) {
15965 var result2;
15966 try {
15967 result2 = callback(child, i2);
15968 } catch (e2) {
15969 throw child.addToError(e2);
15970 }
15971 if (result2 !== false && child.walk) {
15972 result2 = child.walk(callback);
15973 }
15974 return result2;
15975 });
15976 };
15977 _proto.walkAtRules = function walkAtRules(name, callback) {
15978 if (!callback) {
15979 callback = name;
15980 return this.walk(function(child, i2) {
15981 if (child.type === "atrule") {
15982 return callback(child, i2);
15983 }
15984 });
15985 }
15986 if (_instanceof(name, RegExp)) {
15987 return this.walk(function(child, i2) {
15988 if (child.type === "atrule" && name.test(child.name)) {
15989 return callback(child, i2);
15990 }
15991 });
15992 }
15993 return this.walk(function(child, i2) {
15994 if (child.type === "atrule" && child.name === name) {
15995 return callback(child, i2);
15996 }
15997 });
15998 };
15999 _proto.walkComments = function walkComments(callback) {
16000 return this.walk(function(child, i2) {
16001 if (child.type === "comment") {
16002 return callback(child, i2);
16003 }
16004 });
16005 };
16006 _proto.walkDecls = function walkDecls(prop, callback) {
16007 if (!callback) {
16008 callback = prop;
16009 return this.walk(function(child, i2) {
16010 if (child.type === "decl") {
16011 return callback(child, i2);
16012 }
16013 });
16014 }
16015 if (_instanceof(prop, RegExp)) {
16016 return this.walk(function(child, i2) {
16017 if (child.type === "decl" && prop.test(child.prop)) {
16018 return callback(child, i2);
16019 }
16020 });
16021 }
16022 return this.walk(function(child, i2) {
16023 if (child.type === "decl" && child.prop === prop) {
16024 return callback(child, i2);
16025 }
16026 });
16027 };
16028 _proto.walkRules = function walkRules(selector, callback) {
16029 if (!callback) {
16030 callback = selector;
16031 return this.walk(function(child, i2) {
16032 if (child.type === "rule") {
16033 return callback(child, i2);
16034 }
16035 });
16036 }
16037 if (_instanceof(selector, RegExp)) {
16038 return this.walk(function(child, i2) {
16039 if (child.type === "rule" && selector.test(child.selector)) {
16040 return callback(child, i2);
16041 }
16042 });
16043 }
16044 return this.walk(function(child, i2) {
16045 if (child.type === "rule" && child.selector === selector) {
16046 return callback(child, i2);
16047 }
16048 });
16049 };
16050 _create_class(Container2, [
16051 {
16052 key: "first",
16053 get: function get() {
16054 if (!this.proxyOf.nodes) return void 0;
16055 return this.proxyOf.nodes[0];
16056 }
16057 },
16058 {
16059 key: "last",
16060 get: function get() {
16061 if (!this.proxyOf.nodes) return void 0;
16062 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
16063 }
16064 }
16065 ]);
16066 return Container2;
16067 }(Node$1);
16068 Container$7.registerParse = function(dependant) {
16069 parse$4 = dependant;
16070 };
16071 Container$7.registerRule = function(dependant) {
16072 Rule$4 = dependant;
16073 };
16074 Container$7.registerAtRule = function(dependant) {
16075 AtRule$4 = dependant;
16076 };
16077 Container$7.registerRoot = function(dependant) {
16078 Root$6 = dependant;
16079 };
16080 var container = Container$7;
16081 Container$7.default = Container$7;
16082 Container$7.rebuild = function(node2) {
16083 if (node2.type === "atrule") {
16084 Object.setPrototypeOf(node2, AtRule$4.prototype);
16085 } else if (node2.type === "rule") {
16086 Object.setPrototypeOf(node2, Rule$4.prototype);
16087 } else if (node2.type === "decl") {
16088 Object.setPrototypeOf(node2, Declaration$3.prototype);
16089 } else if (node2.type === "comment") {
16090 Object.setPrototypeOf(node2, Comment$3.prototype);
16091 } else if (node2.type === "root") {
16092 Object.setPrototypeOf(node2, Root$6.prototype);
16093 }
16094 node2[my$1] = true;
16095 if (node2.nodes) {
16096 node2.nodes.forEach(function(child) {
16097 Container$7.rebuild(child);
16098 });
16099 }
16100 };
16101 var Container$6 = container;
16102 var LazyResult$4, Processor$3;
16103 var Document$3 = /*#__PURE__*/ function(Container$6) {
16104 _inherits(Document23, Container$6);
16105 function Document23(defaults) {
16106 var _this;
16107 _this = Container$6.call(this, _extends({
16108 type: "document"
16109 }, defaults)) || this;
16110 if (!_this.nodes) {
16111 _this.nodes = [];
16112 }
16113 return _this;
16114 }
16115 var _proto = Document23.prototype;
16116 _proto.toResult = function toResult(opts) {
16117 if (opts === void 0) opts = {};
16118 var lazy = new LazyResult$4(new Processor$3(), this, opts);
16119 return lazy.stringify();
16120 };
16121 return Document23;
16122 }(Container$6);
16123 Document$3.registerLazyResult = function(dependant) {
16124 LazyResult$4 = dependant;
16125 };
16126 Document$3.registerProcessor = function(dependant) {
16127 Processor$3 = dependant;
16128 };
16129 var document$1$2 = Document$3;
16130 Document$3.default = Document$3;
16131 var printed = {};
16132 var warnOnce$2 = function warnOnce2(message) {
16133 if (printed[message]) return;
16134 printed[message] = true;
16135 if (typeof console !== "undefined" && console.warn) {
16136 console.warn(message);
16137 }
16138 };
16139 var Warning$2 = /*#__PURE__*/ function() {
16140 function Warning2(text, opts) {
16141 if (opts === void 0) opts = {};
16142 this.type = "warning";
16143 this.text = text;
16144 if (opts.node && opts.node.source) {
16145 var range = opts.node.rangeBy(opts);
16146 this.line = range.start.line;
16147 this.column = range.start.column;
16148 this.endLine = range.end.line;
16149 this.endColumn = range.end.column;
16150 }
16151 for(var opt in opts)this[opt] = opts[opt];
16152 }
16153 var _proto = Warning2.prototype;
16154 _proto.toString = function toString() {
16155 if (this.node) {
16156 return this.node.error(this.text, {
16157 index: this.index,
16158 plugin: this.plugin,
16159 word: this.word
16160 }).message;
16161 }
16162 if (this.plugin) {
16163 return this.plugin + ": " + this.text;
16164 }
16165 return this.text;
16166 };
16167 return Warning2;
16168 }();
16169 var warning = Warning$2;
16170 Warning$2.default = Warning$2;
16171 var Warning$1 = warning;
16172 var Result$3 = /*#__PURE__*/ function() {
16173 function Result2(processor2, root2, opts) {
16174 this.processor = processor2;
16175 this.messages = [];
16176 this.root = root2;
16177 this.opts = opts;
16178 this.css = void 0;
16179 this.map = void 0;
16180 }
16181 var _proto = Result2.prototype;
16182 _proto.toString = function toString() {
16183 return this.css;
16184 };
16185 _proto.warn = function warn(text, opts) {
16186 if (opts === void 0) opts = {};
16187 if (!opts.plugin) {
16188 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
16189 opts.plugin = this.lastPlugin.postcssPlugin;
16190 }
16191 }
16192 var warning2 = new Warning$1(text, opts);
16193 this.messages.push(warning2);
16194 return warning2;
16195 };
16196 _proto.warnings = function warnings() {
16197 return this.messages.filter(function(i2) {
16198 return i2.type === "warning";
16199 });
16200 };
16201 _create_class(Result2, [
16202 {
16203 key: "content",
16204 get: function get() {
16205 return this.css;
16206 }
16207 }
16208 ]);
16209 return Result2;
16210 }();
16211 var result = Result$3;
16212 Result$3.default = Result$3;
16213 var SINGLE_QUOTE = "'".charCodeAt(0);
16214 var DOUBLE_QUOTE = '"'.charCodeAt(0);
16215 var BACKSLASH = "\\".charCodeAt(0);
16216 var SLASH = "/".charCodeAt(0);
16217 var NEWLINE = "\n".charCodeAt(0);
16218 var SPACE = " ".charCodeAt(0);
16219 var FEED = "\f".charCodeAt(0);
16220 var TAB = " ".charCodeAt(0);
16221 var CR = "\r".charCodeAt(0);
16222 var OPEN_SQUARE = "[".charCodeAt(0);
16223 var CLOSE_SQUARE = "]".charCodeAt(0);
16224 var OPEN_PARENTHESES = "(".charCodeAt(0);
16225 var CLOSE_PARENTHESES = ")".charCodeAt(0);
16226 var OPEN_CURLY = "{".charCodeAt(0);
16227 var CLOSE_CURLY = "}".charCodeAt(0);
16228 var SEMICOLON = ";".charCodeAt(0);
16229 var ASTERISK = "*".charCodeAt(0);
16230 var COLON = ":".charCodeAt(0);
16231 var AT = "@".charCodeAt(0);
16232 var RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
16233 var RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
16234 var RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
16235 var RE_HEX_ESCAPE = /[\da-f]/i;
16236 var tokenize = function tokenizer2(input2, options) {
16237 if (options === void 0) options = {};
16238 var css = input2.css.valueOf();
16239 var ignore = options.ignoreErrors;
16240 var code, next, quote, content, escape;
16241 var escaped, escapePos, prev, n2, currentToken;
16242 var length = css.length;
16243 var pos = 0;
16244 var buffer = [];
16245 var returned = [];
16246 function position() {
16247 return pos;
16248 }
16249 function unclosed(what) {
16250 throw input2.error("Unclosed " + what, pos);
16251 }
16252 function endOfFile() {
16253 return returned.length === 0 && pos >= length;
16254 }
16255 function nextToken(opts) {
16256 if (returned.length) return returned.pop();
16257 if (pos >= length) return;
16258 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
16259 code = css.charCodeAt(pos);
16260 switch(code){
16261 case NEWLINE:
16262 case SPACE:
16263 case TAB:
16264 case CR:
16265 case FEED:
16266 {
16267 next = pos;
16268 do {
16269 next += 1;
16270 code = css.charCodeAt(next);
16271 }while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED);
16272 currentToken = [
16273 "space",
16274 css.slice(pos, next)
16275 ];
16276 pos = next - 1;
16277 break;
16278 }
16279 case OPEN_SQUARE:
16280 case CLOSE_SQUARE:
16281 case OPEN_CURLY:
16282 case CLOSE_CURLY:
16283 case COLON:
16284 case SEMICOLON:
16285 case CLOSE_PARENTHESES:
16286 {
16287 var controlChar = String.fromCharCode(code);
16288 currentToken = [
16289 controlChar,
16290 controlChar,
16291 pos
16292 ];
16293 break;
16294 }
16295 case OPEN_PARENTHESES:
16296 {
16297 prev = buffer.length ? buffer.pop()[1] : "";
16298 n2 = css.charCodeAt(pos + 1);
16299 if (prev === "url" && n2 !== SINGLE_QUOTE && n2 !== DOUBLE_QUOTE && n2 !== SPACE && n2 !== NEWLINE && n2 !== TAB && n2 !== FEED && n2 !== CR) {
16300 next = pos;
16301 do {
16302 escaped = false;
16303 next = css.indexOf(")", next + 1);
16304 if (next === -1) {
16305 if (ignore || ignoreUnclosed) {
16306 next = pos;
16307 break;
16308 } else {
16309 unclosed("bracket");
16310 }
16311 }
16312 escapePos = next;
16313 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16314 escapePos -= 1;
16315 escaped = !escaped;
16316 }
16317 }while (escaped);
16318 currentToken = [
16319 "brackets",
16320 css.slice(pos, next + 1),
16321 pos,
16322 next
16323 ];
16324 pos = next;
16325 } else {
16326 next = css.indexOf(")", pos + 1);
16327 content = css.slice(pos, next + 1);
16328 if (next === -1 || RE_BAD_BRACKET.test(content)) {
16329 currentToken = [
16330 "(",
16331 "(",
16332 pos
16333 ];
16334 } else {
16335 currentToken = [
16336 "brackets",
16337 content,
16338 pos,
16339 next
16340 ];
16341 pos = next;
16342 }
16343 }
16344 break;
16345 }
16346 case SINGLE_QUOTE:
16347 case DOUBLE_QUOTE:
16348 {
16349 quote = code === SINGLE_QUOTE ? "'" : '"';
16350 next = pos;
16351 do {
16352 escaped = false;
16353 next = css.indexOf(quote, next + 1);
16354 if (next === -1) {
16355 if (ignore || ignoreUnclosed) {
16356 next = pos + 1;
16357 break;
16358 } else {
16359 unclosed("string");
16360 }
16361 }
16362 escapePos = next;
16363 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16364 escapePos -= 1;
16365 escaped = !escaped;
16366 }
16367 }while (escaped);
16368 currentToken = [
16369 "string",
16370 css.slice(pos, next + 1),
16371 pos,
16372 next
16373 ];
16374 pos = next;
16375 break;
16376 }
16377 case AT:
16378 {
16379 RE_AT_END.lastIndex = pos + 1;
16380 RE_AT_END.test(css);
16381 if (RE_AT_END.lastIndex === 0) {
16382 next = css.length - 1;
16383 } else {
16384 next = RE_AT_END.lastIndex - 2;
16385 }
16386 currentToken = [
16387 "at-word",
16388 css.slice(pos, next + 1),
16389 pos,
16390 next
16391 ];
16392 pos = next;
16393 break;
16394 }
16395 case BACKSLASH:
16396 {
16397 next = pos;
16398 escape = true;
16399 while(css.charCodeAt(next + 1) === BACKSLASH){
16400 next += 1;
16401 escape = !escape;
16402 }
16403 code = css.charCodeAt(next + 1);
16404 if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
16405 next += 1;
16406 if (RE_HEX_ESCAPE.test(css.charAt(next))) {
16407 while(RE_HEX_ESCAPE.test(css.charAt(next + 1))){
16408 next += 1;
16409 }
16410 if (css.charCodeAt(next + 1) === SPACE) {
16411 next += 1;
16412 }
16413 }
16414 }
16415 currentToken = [
16416 "word",
16417 css.slice(pos, next + 1),
16418 pos,
16419 next
16420 ];
16421 pos = next;
16422 break;
16423 }
16424 default:
16425 {
16426 if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
16427 next = css.indexOf("*/", pos + 2) + 1;
16428 if (next === 0) {
16429 if (ignore || ignoreUnclosed) {
16430 next = css.length;
16431 } else {
16432 unclosed("comment");
16433 }
16434 }
16435 currentToken = [
16436 "comment",
16437 css.slice(pos, next + 1),
16438 pos,
16439 next
16440 ];
16441 pos = next;
16442 } else {
16443 RE_WORD_END.lastIndex = pos + 1;
16444 RE_WORD_END.test(css);
16445 if (RE_WORD_END.lastIndex === 0) {
16446 next = css.length - 1;
16447 } else {
16448 next = RE_WORD_END.lastIndex - 2;
16449 }
16450 currentToken = [
16451 "word",
16452 css.slice(pos, next + 1),
16453 pos,
16454 next
16455 ];
16456 buffer.push(currentToken);
16457 pos = next;
16458 }
16459 break;
16460 }
16461 }
16462 pos++;
16463 return currentToken;
16464 }
16465 function back(token) {
16466 returned.push(token);
16467 }
16468 return {
16469 back: back,
16470 endOfFile: endOfFile,
16471 nextToken: nextToken,
16472 position: position
16473 };
16474 };
16475 var Container$5 = container;
16476 var AtRule$3 = /*#__PURE__*/ function(Container$5) {
16477 _inherits(AtRule2, Container$5);
16478 function AtRule2(defaults) {
16479 var _this;
16480 _this = Container$5.call(this, defaults) || this;
16481 _this.type = "atrule";
16482 return _this;
16483 }
16484 var _proto = AtRule2.prototype;
16485 _proto.append = function append() {
16486 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16487 children[_key] = arguments[_key];
16488 }
16489 var _Container$5_prototype_append;
16490 if (!this.proxyOf.nodes) this.nodes = [];
16491 return (_Container$5_prototype_append = Container$5.prototype.append).call.apply(_Container$5_prototype_append, [].concat([
16492 this
16493 ], children));
16494 };
16495 _proto.prepend = function prepend() {
16496 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16497 children[_key] = arguments[_key];
16498 }
16499 var _Container$5_prototype_prepend;
16500 if (!this.proxyOf.nodes) this.nodes = [];
16501 return (_Container$5_prototype_prepend = Container$5.prototype.prepend).call.apply(_Container$5_prototype_prepend, [].concat([
16502 this
16503 ], children));
16504 };
16505 return AtRule2;
16506 }(Container$5);
16507 var atRule = AtRule$3;
16508 AtRule$3.default = AtRule$3;
16509 Container$5.registerAtRule(AtRule$3);
16510 var Container$4 = container;
16511 var LazyResult$3, Processor$2;
16512 var Root$5 = /*#__PURE__*/ function(Container$4) {
16513 _inherits(Root2, Container$4);
16514 function Root2(defaults) {
16515 var _this;
16516 _this = Container$4.call(this, defaults) || this;
16517 _this.type = "root";
16518 if (!_this.nodes) _this.nodes = [];
16519 return _this;
16520 }
16521 var _proto = Root2.prototype;
16522 _proto.normalize = function normalize(child, sample, type) {
16523 var nodes = Container$4.prototype.normalize.call(this, child);
16524 if (sample) {
16525 if (type === "prepend") {
16526 if (this.nodes.length > 1) {
16527 sample.raws.before = this.nodes[1].raws.before;
16528 } else {
16529 delete sample.raws.before;
16530 }
16531 } else if (this.first !== sample) {
16532 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16533 var node2 = _step.value;
16534 node2.raws.before = sample.raws.before;
16535 }
16536 }
16537 }
16538 return nodes;
16539 };
16540 _proto.removeChild = function removeChild(child, ignore) {
16541 var index2 = this.index(child);
16542 if (!ignore && index2 === 0 && this.nodes.length > 1) {
16543 this.nodes[1].raws.before = this.nodes[index2].raws.before;
16544 }
16545 return Container$4.prototype.removeChild.call(this, child);
16546 };
16547 _proto.toResult = function toResult(opts) {
16548 if (opts === void 0) opts = {};
16549 var lazy = new LazyResult$3(new Processor$2(), this, opts);
16550 return lazy.stringify();
16551 };
16552 return Root2;
16553 }(Container$4);
16554 Root$5.registerLazyResult = function(dependant) {
16555 LazyResult$3 = dependant;
16556 };
16557 Root$5.registerProcessor = function(dependant) {
16558 Processor$2 = dependant;
16559 };
16560 var root = Root$5;
16561 Root$5.default = Root$5;
16562 Container$4.registerRoot(Root$5);
16563 var list$2 = {
16564 comma: function comma(string) {
16565 return list$2.split(string, [
16566 ","
16567 ], true);
16568 },
16569 space: function space(string) {
16570 var spaces = [
16571 " ",
16572 "\n",
16573 " "
16574 ];
16575 return list$2.split(string, spaces);
16576 },
16577 split: function split(string, separators, last) {
16578 var array = [];
16579 var current = "";
16580 var split = false;
16581 var func = 0;
16582 var inQuote = false;
16583 var prevQuote = "";
16584 var escape = false;
16585 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
16586 var letter = _step.value;
16587 if (escape) {
16588 escape = false;
16589 } else if (letter === "\\") {
16590 escape = true;
16591 } else if (inQuote) {
16592 if (letter === prevQuote) {
16593 inQuote = false;
16594 }
16595 } else if (letter === '"' || letter === "'") {
16596 inQuote = true;
16597 prevQuote = letter;
16598 } else if (letter === "(") {
16599 func += 1;
16600 } else if (letter === ")") {
16601 if (func > 0) func -= 1;
16602 } else if (func === 0) {
16603 if (separators.includes(letter)) split = true;
16604 }
16605 if (split) {
16606 if (current !== "") array.push(current.trim());
16607 current = "";
16608 split = false;
16609 } else {
16610 current += letter;
16611 }
16612 }
16613 if (last || current !== "") array.push(current.trim());
16614 return array;
16615 }
16616 };
16617 var list_1 = list$2;
16618 list$2.default = list$2;
16619 var Container$3 = container;
16620 var list$1 = list_1;
16621 var Rule$3 = /*#__PURE__*/ function(Container$3) {
16622 _inherits(Rule2, Container$3);
16623 function Rule2(defaults) {
16624 var _this;
16625 _this = Container$3.call(this, defaults) || this;
16626 _this.type = "rule";
16627 if (!_this.nodes) _this.nodes = [];
16628 return _this;
16629 }
16630 _create_class(Rule2, [
16631 {
16632 key: "selectors",
16633 get: function get() {
16634 return list$1.comma(this.selector);
16635 },
16636 set: function set(values) {
16637 var match = this.selector ? this.selector.match(/,\s*/) : null;
16638 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
16639 this.selector = values.join(sep2);
16640 }
16641 }
16642 ]);
16643 return Rule2;
16644 }(Container$3);
16645 var rule = Rule$3;
16646 Rule$3.default = Rule$3;
16647 Container$3.registerRule(Rule$3);
16648 var Declaration$2 = declaration;
16649 var tokenizer22 = tokenize;
16650 var Comment$2 = comment;
16651 var AtRule$2 = atRule;
16652 var Root$4 = root;
16653 var Rule$2 = rule;
16654 var SAFE_COMMENT_NEIGHBOR = {
16655 empty: true,
16656 space: true
16657 };
16658 function findLastWithPosition(tokens) {
16659 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
16660 var token = tokens[i2];
16661 var pos = token[3] || token[2];
16662 if (pos) return pos;
16663 }
16664 }
16665 var Parser$1 = /*#__PURE__*/ function() {
16666 function Parser2(input2) {
16667 this.input = input2;
16668 this.root = new Root$4();
16669 this.current = this.root;
16670 this.spaces = "";
16671 this.semicolon = false;
16672 this.createTokenizer();
16673 this.root.source = {
16674 input: input2,
16675 start: {
16676 column: 1,
16677 line: 1,
16678 offset: 0
16679 }
16680 };
16681 }
16682 var _proto = Parser2.prototype;
16683 _proto.atrule = function atrule(token) {
16684 var node2 = new AtRule$2();
16685 node2.name = token[1].slice(1);
16686 if (node2.name === "") {
16687 this.unnamedAtrule(node2, token);
16688 }
16689 this.init(node2, token[2]);
16690 var type;
16691 var prev;
16692 var shift;
16693 var last = false;
16694 var open = false;
16695 var params = [];
16696 var brackets = [];
16697 while(!this.tokenizer.endOfFile()){
16698 token = this.tokenizer.nextToken();
16699 type = token[0];
16700 if (type === "(" || type === "[") {
16701 brackets.push(type === "(" ? ")" : "]");
16702 } else if (type === "{" && brackets.length > 0) {
16703 brackets.push("}");
16704 } else if (type === brackets[brackets.length - 1]) {
16705 brackets.pop();
16706 }
16707 if (brackets.length === 0) {
16708 if (type === ";") {
16709 node2.source.end = this.getPosition(token[2]);
16710 node2.source.end.offset++;
16711 this.semicolon = true;
16712 break;
16713 } else if (type === "{") {
16714 open = true;
16715 break;
16716 } else if (type === "}") {
16717 if (params.length > 0) {
16718 shift = params.length - 1;
16719 prev = params[shift];
16720 while(prev && prev[0] === "space"){
16721 prev = params[--shift];
16722 }
16723 if (prev) {
16724 node2.source.end = this.getPosition(prev[3] || prev[2]);
16725 node2.source.end.offset++;
16726 }
16727 }
16728 this.end(token);
16729 break;
16730 } else {
16731 params.push(token);
16732 }
16733 } else {
16734 params.push(token);
16735 }
16736 if (this.tokenizer.endOfFile()) {
16737 last = true;
16738 break;
16739 }
16740 }
16741 node2.raws.between = this.spacesAndCommentsFromEnd(params);
16742 if (params.length) {
16743 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
16744 this.raw(node2, "params", params);
16745 if (last) {
16746 token = params[params.length - 1];
16747 node2.source.end = this.getPosition(token[3] || token[2]);
16748 node2.source.end.offset++;
16749 this.spaces = node2.raws.between;
16750 node2.raws.between = "";
16751 }
16752 } else {
16753 node2.raws.afterName = "";
16754 node2.params = "";
16755 }
16756 if (open) {
16757 node2.nodes = [];
16758 this.current = node2;
16759 }
16760 };
16761 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
16762 var colon = this.colon(tokens);
16763 if (colon === false) return;
16764 var founded = 0;
16765 var token;
16766 for(var j = colon - 1; j >= 0; j--){
16767 token = tokens[j];
16768 if (token[0] !== "space") {
16769 founded += 1;
16770 if (founded === 2) break;
16771 }
16772 }
16773 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
16774 };
16775 _proto.colon = function colon(tokens) {
16776 var brackets = 0;
16777 var token, type, prev;
16778 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
16779 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
16780 token = element;
16781 type = token[0];
16782 if (type === "(") {
16783 brackets += 1;
16784 }
16785 if (type === ")") {
16786 brackets -= 1;
16787 }
16788 if (brackets === 0 && type === ":") {
16789 if (!prev) {
16790 this.doubleColon(token);
16791 } else if (prev[0] === "word" && prev[1] === "progid") {
16792 continue;
16793 } else {
16794 return i2;
16795 }
16796 }
16797 prev = token;
16798 }
16799 return false;
16800 };
16801 _proto.comment = function comment(token) {
16802 var node2 = new Comment$2();
16803 this.init(node2, token[2]);
16804 node2.source.end = this.getPosition(token[3] || token[2]);
16805 node2.source.end.offset++;
16806 var text = token[1].slice(2, -2);
16807 if (/^\s*$/.test(text)) {
16808 node2.text = "";
16809 node2.raws.left = text;
16810 node2.raws.right = "";
16811 } else {
16812 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
16813 node2.text = match[2];
16814 node2.raws.left = match[1];
16815 node2.raws.right = match[3];
16816 }
16817 };
16818 _proto.createTokenizer = function createTokenizer() {
16819 this.tokenizer = tokenizer22(this.input);
16820 };
16821 _proto.decl = function decl(tokens, customProperty) {
16822 var node2 = new Declaration$2();
16823 this.init(node2, tokens[0][2]);
16824 var last = tokens[tokens.length - 1];
16825 if (last[0] === ";") {
16826 this.semicolon = true;
16827 tokens.pop();
16828 }
16829 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition(tokens));
16830 node2.source.end.offset++;
16831 while(tokens[0][0] !== "word"){
16832 if (tokens.length === 1) this.unknownWord(tokens);
16833 node2.raws.before += tokens.shift()[1];
16834 }
16835 node2.source.start = this.getPosition(tokens[0][2]);
16836 node2.prop = "";
16837 while(tokens.length){
16838 var type = tokens[0][0];
16839 if (type === ":" || type === "space" || type === "comment") {
16840 break;
16841 }
16842 node2.prop += tokens.shift()[1];
16843 }
16844 node2.raws.between = "";
16845 var token;
16846 while(tokens.length){
16847 token = tokens.shift();
16848 if (token[0] === ":") {
16849 node2.raws.between += token[1];
16850 break;
16851 } else {
16852 if (token[0] === "word" && /\w/.test(token[1])) {
16853 this.unknownWord([
16854 token
16855 ]);
16856 }
16857 node2.raws.between += token[1];
16858 }
16859 }
16860 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
16861 node2.raws.before += node2.prop[0];
16862 node2.prop = node2.prop.slice(1);
16863 }
16864 var firstSpaces = [];
16865 var next;
16866 while(tokens.length){
16867 next = tokens[0][0];
16868 if (next !== "space" && next !== "comment") break;
16869 firstSpaces.push(tokens.shift());
16870 }
16871 this.precheckMissedSemicolon(tokens);
16872 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
16873 token = tokens[i2];
16874 if (token[1].toLowerCase() === "!important") {
16875 node2.important = true;
16876 var string = this.stringFrom(tokens, i2);
16877 string = this.spacesFromEnd(tokens) + string;
16878 if (string !== " !important") node2.raws.important = string;
16879 break;
16880 } else if (token[1].toLowerCase() === "important") {
16881 var cache = tokens.slice(0);
16882 var str = "";
16883 for(var j = i2; j > 0; j--){
16884 var type1 = cache[j][0];
16885 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
16886 break;
16887 }
16888 str = cache.pop()[1] + str;
16889 }
16890 if (str.trim().indexOf("!") === 0) {
16891 node2.important = true;
16892 node2.raws.important = str;
16893 tokens = cache;
16894 }
16895 }
16896 if (token[0] !== "space" && token[0] !== "comment") {
16897 break;
16898 }
16899 }
16900 var hasWord = tokens.some(function(i2) {
16901 return i2[0] !== "space" && i2[0] !== "comment";
16902 });
16903 if (hasWord) {
16904 node2.raws.between += firstSpaces.map(function(i2) {
16905 return i2[1];
16906 }).join("");
16907 firstSpaces = [];
16908 }
16909 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
16910 if (node2.value.includes(":") && !customProperty) {
16911 this.checkMissedSemicolon(tokens);
16912 }
16913 };
16914 _proto.doubleColon = function doubleColon(token) {
16915 throw this.input.error("Double colon", {
16916 offset: token[2]
16917 }, {
16918 offset: token[2] + token[1].length
16919 });
16920 };
16921 _proto.emptyRule = function emptyRule(token) {
16922 var node2 = new Rule$2();
16923 this.init(node2, token[2]);
16924 node2.selector = "";
16925 node2.raws.between = "";
16926 this.current = node2;
16927 };
16928 _proto.end = function end(token) {
16929 if (this.current.nodes && this.current.nodes.length) {
16930 this.current.raws.semicolon = this.semicolon;
16931 }
16932 this.semicolon = false;
16933 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
16934 this.spaces = "";
16935 if (this.current.parent) {
16936 this.current.source.end = this.getPosition(token[2]);
16937 this.current.source.end.offset++;
16938 this.current = this.current.parent;
16939 } else {
16940 this.unexpectedClose(token);
16941 }
16942 };
16943 _proto.endFile = function endFile() {
16944 if (this.current.parent) this.unclosedBlock();
16945 if (this.current.nodes && this.current.nodes.length) {
16946 this.current.raws.semicolon = this.semicolon;
16947 }
16948 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
16949 this.root.source.end = this.getPosition(this.tokenizer.position());
16950 };
16951 _proto.freeSemicolon = function freeSemicolon(token) {
16952 this.spaces += token[1];
16953 if (this.current.nodes) {
16954 var prev = this.current.nodes[this.current.nodes.length - 1];
16955 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
16956 prev.raws.ownSemicolon = this.spaces;
16957 this.spaces = "";
16958 }
16959 }
16960 };
16961 // Helpers
16962 _proto.getPosition = function getPosition(offset) {
16963 var pos = this.input.fromOffset(offset);
16964 return {
16965 column: pos.col,
16966 line: pos.line,
16967 offset: offset
16968 };
16969 };
16970 _proto.init = function init(node2, offset) {
16971 this.current.push(node2);
16972 node2.source = {
16973 input: this.input,
16974 start: this.getPosition(offset)
16975 };
16976 node2.raws.before = this.spaces;
16977 this.spaces = "";
16978 if (node2.type !== "comment") this.semicolon = false;
16979 };
16980 _proto.other = function other(start) {
16981 var end = false;
16982 var type = null;
16983 var colon = false;
16984 var bracket = null;
16985 var brackets = [];
16986 var customProperty = start[1].startsWith("--");
16987 var tokens = [];
16988 var token = start;
16989 while(token){
16990 type = token[0];
16991 tokens.push(token);
16992 if (type === "(" || type === "[") {
16993 if (!bracket) bracket = token;
16994 brackets.push(type === "(" ? ")" : "]");
16995 } else if (customProperty && colon && type === "{") {
16996 if (!bracket) bracket = token;
16997 brackets.push("}");
16998 } else if (brackets.length === 0) {
16999 if (type === ";") {
17000 if (colon) {
17001 this.decl(tokens, customProperty);
17002 return;
17003 } else {
17004 break;
17005 }
17006 } else if (type === "{") {
17007 this.rule(tokens);
17008 return;
17009 } else if (type === "}") {
17010 this.tokenizer.back(tokens.pop());
17011 end = true;
17012 break;
17013 } else if (type === ":") {
17014 colon = true;
17015 }
17016 } else if (type === brackets[brackets.length - 1]) {
17017 brackets.pop();
17018 if (brackets.length === 0) bracket = null;
17019 }
17020 token = this.tokenizer.nextToken();
17021 }
17022 if (this.tokenizer.endOfFile()) end = true;
17023 if (brackets.length > 0) this.unclosedBracket(bracket);
17024 if (end && colon) {
17025 if (!customProperty) {
17026 while(tokens.length){
17027 token = tokens[tokens.length - 1][0];
17028 if (token !== "space" && token !== "comment") break;
17029 this.tokenizer.back(tokens.pop());
17030 }
17031 }
17032 this.decl(tokens, customProperty);
17033 } else {
17034 this.unknownWord(tokens);
17035 }
17036 };
17037 _proto.parse = function parse() {
17038 var token;
17039 while(!this.tokenizer.endOfFile()){
17040 token = this.tokenizer.nextToken();
17041 switch(token[0]){
17042 case "space":
17043 this.spaces += token[1];
17044 break;
17045 case ";":
17046 this.freeSemicolon(token);
17047 break;
17048 case "}":
17049 this.end(token);
17050 break;
17051 case "comment":
17052 this.comment(token);
17053 break;
17054 case "at-word":
17055 this.atrule(token);
17056 break;
17057 case "{":
17058 this.emptyRule(token);
17059 break;
17060 default:
17061 this.other(token);
17062 break;
17063 }
17064 }
17065 this.endFile();
17066 };
17067 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
17068 _proto.raw = function raw(node2, prop, tokens, customProperty) {
17069 var token, type;
17070 var length = tokens.length;
17071 var value = "";
17072 var clean = true;
17073 var next, prev;
17074 for(var i2 = 0; i2 < length; i2 += 1){
17075 token = tokens[i2];
17076 type = token[0];
17077 if (type === "space" && i2 === length - 1 && !customProperty) {
17078 clean = false;
17079 } else if (type === "comment") {
17080 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
17081 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
17082 if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
17083 if (value.slice(-1) === ",") {
17084 clean = false;
17085 } else {
17086 value += token[1];
17087 }
17088 } else {
17089 clean = false;
17090 }
17091 } else {
17092 value += token[1];
17093 }
17094 }
17095 if (!clean) {
17096 var raw = tokens.reduce(function(all, i2) {
17097 return all + i2[1];
17098 }, "");
17099 node2.raws[prop] = {
17100 raw: raw,
17101 value: value
17102 };
17103 }
17104 node2[prop] = value;
17105 };
17106 _proto.rule = function rule(tokens) {
17107 tokens.pop();
17108 var node2 = new Rule$2();
17109 this.init(node2, tokens[0][2]);
17110 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
17111 this.raw(node2, "selector", tokens);
17112 this.current = node2;
17113 };
17114 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
17115 var lastTokenType;
17116 var spaces = "";
17117 while(tokens.length){
17118 lastTokenType = tokens[tokens.length - 1][0];
17119 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
17120 spaces = tokens.pop()[1] + spaces;
17121 }
17122 return spaces;
17123 };
17124 // Errors
17125 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
17126 var next;
17127 var spaces = "";
17128 while(tokens.length){
17129 next = tokens[0][0];
17130 if (next !== "space" && next !== "comment") break;
17131 spaces += tokens.shift()[1];
17132 }
17133 return spaces;
17134 };
17135 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
17136 var lastTokenType;
17137 var spaces = "";
17138 while(tokens.length){
17139 lastTokenType = tokens[tokens.length - 1][0];
17140 if (lastTokenType !== "space") break;
17141 spaces = tokens.pop()[1] + spaces;
17142 }
17143 return spaces;
17144 };
17145 _proto.stringFrom = function stringFrom(tokens, from) {
17146 var result2 = "";
17147 for(var i2 = from; i2 < tokens.length; i2++){
17148 result2 += tokens[i2][1];
17149 }
17150 tokens.splice(from, tokens.length - from);
17151 return result2;
17152 };
17153 _proto.unclosedBlock = function unclosedBlock() {
17154 var pos = this.current.source.start;
17155 throw this.input.error("Unclosed block", pos.line, pos.column);
17156 };
17157 _proto.unclosedBracket = function unclosedBracket(bracket) {
17158 throw this.input.error("Unclosed bracket", {
17159 offset: bracket[2]
17160 }, {
17161 offset: bracket[2] + 1
17162 });
17163 };
17164 _proto.unexpectedClose = function unexpectedClose(token) {
17165 throw this.input.error("Unexpected }", {
17166 offset: token[2]
17167 }, {
17168 offset: token[2] + 1
17169 });
17170 };
17171 _proto.unknownWord = function unknownWord(tokens) {
17172 throw this.input.error("Unknown word", {
17173 offset: tokens[0][2]
17174 }, {
17175 offset: tokens[0][2] + tokens[0][1].length
17176 });
17177 };
17178 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
17179 throw this.input.error("At-rule without name", {
17180 offset: token[2]
17181 }, {
17182 offset: token[2] + token[1].length
17183 });
17184 };
17185 return Parser2;
17186 }();
17187 var parser = Parser$1;
17188 var Container$2 = container;
17189 var Parser22 = parser;
17190 var Input$2 = input;
17191 function parse$3(css, opts) {
17192 var input2 = new Input$2(css, opts);
17193 var parser2 = new Parser22(input2);
17194 try {
17195 parser2.parse();
17196 } catch (e2) {
17197 if (true) {
17198 if (e2.name === "CssSyntaxError" && opts && opts.from) {
17199 if (/\.scss$/i.test(opts.from)) {
17200 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
17201 } else if (/\.sass/i.test(opts.from)) {
17202 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
17203 } else if (/\.less$/i.test(opts.from)) {
17204 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
17205 }
17206 }
17207 }
17208 throw e2;
17209 }
17210 return parser2.root;
17211 }
17212 var parse_1 = parse$3;
17213 parse$3.default = parse$3;
17214 Container$2.registerParse(parse$3);
17215 var isClean = symbols.isClean, my = symbols.my;
17216 var MapGenerator$1 = mapGenerator;
17217 var stringify$2 = stringify_1;
17218 var Container$1 = container;
17219 var Document$2 = document$1$2;
17220 var warnOnce$1 = warnOnce$2;
17221 var Result$2 = result;
17222 var parse$2 = parse_1;
17223 var Root$3 = root;
17224 var TYPE_TO_CLASS_NAME = {
17225 atrule: "AtRule",
17226 comment: "Comment",
17227 decl: "Declaration",
17228 document: "Document",
17229 root: "Root",
17230 rule: "Rule"
17231 };
17232 var PLUGIN_PROPS = {
17233 AtRule: true,
17234 AtRuleExit: true,
17235 Comment: true,
17236 CommentExit: true,
17237 Declaration: true,
17238 DeclarationExit: true,
17239 Document: true,
17240 DocumentExit: true,
17241 Once: true,
17242 OnceExit: true,
17243 postcssPlugin: true,
17244 prepare: true,
17245 Root: true,
17246 RootExit: true,
17247 Rule: true,
17248 RuleExit: true
17249 };
17250 var NOT_VISITORS = {
17251 Once: true,
17252 postcssPlugin: true,
17253 prepare: true
17254 };
17255 var CHILDREN = 0;
17256 function isPromise(obj) {
17257 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
17258 }
17259 function getEvents(node2) {
17260 var key = false;
17261 var type = TYPE_TO_CLASS_NAME[node2.type];
17262 if (node2.type === "decl") {
17263 key = node2.prop.toLowerCase();
17264 } else if (node2.type === "atrule") {
17265 key = node2.name.toLowerCase();
17266 }
17267 if (key && node2.append) {
17268 return [
17269 type,
17270 type + "-" + key,
17271 CHILDREN,
17272 type + "Exit",
17273 type + "Exit-" + key
17274 ];
17275 } else if (key) {
17276 return [
17277 type,
17278 type + "-" + key,
17279 type + "Exit",
17280 type + "Exit-" + key
17281 ];
17282 } else if (node2.append) {
17283 return [
17284 type,
17285 CHILDREN,
17286 type + "Exit"
17287 ];
17288 } else {
17289 return [
17290 type,
17291 type + "Exit"
17292 ];
17293 }
17294 }
17295 function toStack(node2) {
17296 var events;
17297 if (node2.type === "document") {
17298 events = [
17299 "Document",
17300 CHILDREN,
17301 "DocumentExit"
17302 ];
17303 } else if (node2.type === "root") {
17304 events = [
17305 "Root",
17306 CHILDREN,
17307 "RootExit"
17308 ];
17309 } else {
17310 events = getEvents(node2);
17311 }
17312 return {
17313 eventIndex: 0,
17314 events: events,
17315 iterator: 0,
17316 node: node2,
17317 visitorIndex: 0,
17318 visitors: []
17319 };
17320 }
17321 function cleanMarks(node2) {
17322 node2[isClean] = false;
17323 if (node2.nodes) node2.nodes.forEach(function(i2) {
17324 return cleanMarks(i2);
17325 });
17326 return node2;
17327 }
17328 var postcss$2 = {};
17329 var LazyResult$2 = /*#__PURE__*/ function() {
17330 function LazyResult2(processor2, css, opts) {
17331 var _this = this;
17332 this.stringified = false;
17333 this.processed = false;
17334 var root2;
17335 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
17336 root2 = cleanMarks(css);
17337 } else if (_instanceof(css, LazyResult2) || _instanceof(css, Result$2)) {
17338 root2 = cleanMarks(css.root);
17339 if (css.map) {
17340 if (typeof opts.map === "undefined") opts.map = {};
17341 if (!opts.map.inline) opts.map.inline = false;
17342 opts.map.prev = css.map;
17343 }
17344 } else {
17345 var parser2 = parse$2;
17346 if (opts.syntax) parser2 = opts.syntax.parse;
17347 if (opts.parser) parser2 = opts.parser;
17348 if (parser2.parse) parser2 = parser2.parse;
17349 try {
17350 root2 = parser2(css, opts);
17351 } catch (error) {
17352 this.processed = true;
17353 this.error = error;
17354 }
17355 if (root2 && !root2[my]) {
17356 Container$1.rebuild(root2);
17357 }
17358 }
17359 this.result = new Result$2(processor2, root2, opts);
17360 this.helpers = _extends({}, postcss$2, {
17361 postcss: postcss$2,
17362 result: this.result
17363 });
17364 this.plugins = this.processor.plugins.map(function(plugin22) {
17365 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
17366 return _extends({}, plugin22, plugin22.prepare(_this.result));
17367 } else {
17368 return plugin22;
17369 }
17370 });
17371 }
17372 var _proto = LazyResult2.prototype;
17373 _proto.async = function async() {
17374 if (this.error) return Promise.reject(this.error);
17375 if (this.processed) return Promise.resolve(this.result);
17376 if (!this.processing) {
17377 this.processing = this.runAsync();
17378 }
17379 return this.processing;
17380 };
17381 _proto.catch = function _catch(onRejected) {
17382 return this.async().catch(onRejected);
17383 };
17384 _proto.finally = function _finally(onFinally) {
17385 return this.async().then(onFinally, onFinally);
17386 };
17387 _proto.getAsyncError = function getAsyncError() {
17388 throw new Error("Use process(css).then(cb) to work with async plugins");
17389 };
17390 _proto.handleError = function handleError(error, node2) {
17391 var plugin22 = this.result.lastPlugin;
17392 try {
17393 if (node2) node2.addToError(error);
17394 this.error = error;
17395 if (error.name === "CssSyntaxError" && !error.plugin) {
17396 error.plugin = plugin22.postcssPlugin;
17397 error.setMessage();
17398 } else if (plugin22.postcssVersion) {
17399 if (true) {
17400 var pluginName = plugin22.postcssPlugin;
17401 var pluginVer = plugin22.postcssVersion;
17402 var runtimeVer = this.result.processor.version;
17403 var a2 = pluginVer.split(".");
17404 var b = runtimeVer.split(".");
17405 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
17406 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.");
17407 }
17408 }
17409 }
17410 } catch (err) {
17411 if (console && console.error) console.error(err);
17412 }
17413 return error;
17414 };
17415 _proto.prepareVisitors = function prepareVisitors() {
17416 var _this = this;
17417 this.listeners = {};
17418 var add = function(plugin22, type, cb) {
17419 if (!_this.listeners[type]) _this.listeners[type] = [];
17420 _this.listeners[type].push([
17421 plugin22,
17422 cb
17423 ]);
17424 };
17425 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17426 var plugin22 = _step.value;
17427 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
17428 for(var event in plugin22){
17429 if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
17430 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
17431 }
17432 if (!NOT_VISITORS[event]) {
17433 if (_type_of(plugin22[event]) === "object") {
17434 for(var filter in plugin22[event]){
17435 if (filter === "*") {
17436 add(plugin22, event, plugin22[event][filter]);
17437 } else {
17438 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
17439 }
17440 }
17441 } else if (typeof plugin22[event] === "function") {
17442 add(plugin22, event, plugin22[event]);
17443 }
17444 }
17445 }
17446 }
17447 }
17448 this.hasListener = Object.keys(this.listeners).length > 0;
17449 };
17450 _proto.runAsync = function runAsync() {
17451 var _this = this;
17452 return _async_to_generator(function() {
17453 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
17454 return _ts_generator(this, function(_state) {
17455 switch(_state.label){
17456 case 0:
17457 _this.plugin = 0;
17458 i2 = 0;
17459 _state.label = 1;
17460 case 1:
17461 if (!(i2 < _this.plugins.length)) return [
17462 3,
17463 6
17464 ];
17465 plugin22 = _this.plugins[i2];
17466 promise = _this.runOnRoot(plugin22);
17467 if (!isPromise(promise)) return [
17468 3,
17469 5
17470 ];
17471 _state.label = 2;
17472 case 2:
17473 _state.trys.push([
17474 2,
17475 4,
17476 ,
17477 5
17478 ]);
17479 return [
17480 4,
17481 promise
17482 ];
17483 case 3:
17484 _state.sent();
17485 return [
17486 3,
17487 5
17488 ];
17489 case 4:
17490 error = _state.sent();
17491 throw _this.handleError(error);
17492 case 5:
17493 i2++;
17494 return [
17495 3,
17496 1
17497 ];
17498 case 6:
17499 _this.prepareVisitors();
17500 if (!_this.hasListener) return [
17501 3,
17502 18
17503 ];
17504 root2 = _this.result.root;
17505 _state.label = 7;
17506 case 7:
17507 if (!!root2[isClean]) return [
17508 3,
17509 14
17510 ];
17511 root2[isClean] = true;
17512 stack = [
17513 toStack(root2)
17514 ];
17515 _state.label = 8;
17516 case 8:
17517 if (!(stack.length > 0)) return [
17518 3,
17519 13
17520 ];
17521 promise1 = _this.visitTick(stack);
17522 if (!isPromise(promise1)) return [
17523 3,
17524 12
17525 ];
17526 _state.label = 9;
17527 case 9:
17528 _state.trys.push([
17529 9,
17530 11,
17531 ,
17532 12
17533 ]);
17534 return [
17535 4,
17536 promise1
17537 ];
17538 case 10:
17539 _state.sent();
17540 return [
17541 3,
17542 12
17543 ];
17544 case 11:
17545 e2 = _state.sent();
17546 node2 = stack[stack.length - 1].node;
17547 throw _this.handleError(e2, node2);
17548 case 12:
17549 return [
17550 3,
17551 8
17552 ];
17553 case 13:
17554 return [
17555 3,
17556 7
17557 ];
17558 case 14:
17559 if (!_this.listeners.OnceExit) return [
17560 3,
17561 18
17562 ];
17563 _loop = function() {
17564 var _step_value, plugin22, visitor, roots, e2;
17565 return _ts_generator(this, function(_state) {
17566 switch(_state.label){
17567 case 0:
17568 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
17569 _this.result.lastPlugin = plugin22;
17570 _state.label = 1;
17571 case 1:
17572 _state.trys.push([
17573 1,
17574 6,
17575 ,
17576 7
17577 ]);
17578 if (!(root2.type === "document")) return [
17579 3,
17580 3
17581 ];
17582 roots = root2.nodes.map(function(subRoot) {
17583 return visitor(subRoot, _this.helpers);
17584 });
17585 return [
17586 4,
17587 Promise.all(roots)
17588 ];
17589 case 2:
17590 _state.sent();
17591 return [
17592 3,
17593 5
17594 ];
17595 case 3:
17596 return [
17597 4,
17598 visitor(root2, _this.helpers)
17599 ];
17600 case 4:
17601 _state.sent();
17602 _state.label = 5;
17603 case 5:
17604 return [
17605 3,
17606 7
17607 ];
17608 case 6:
17609 e2 = _state.sent();
17610 throw _this.handleError(e2);
17611 case 7:
17612 return [
17613 2
17614 ];
17615 }
17616 });
17617 };
17618 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
17619 _state.label = 15;
17620 case 15:
17621 if (!!(_step = _iterator()).done) return [
17622 3,
17623 18
17624 ];
17625 return [
17626 5,
17627 _ts_values(_loop())
17628 ];
17629 case 16:
17630 _state.sent();
17631 _state.label = 17;
17632 case 17:
17633 return [
17634 3,
17635 15
17636 ];
17637 case 18:
17638 _this.processed = true;
17639 return [
17640 2,
17641 _this.stringify()
17642 ];
17643 }
17644 });
17645 })();
17646 };
17647 _proto.runOnRoot = function runOnRoot(plugin22) {
17648 var _this = this;
17649 this.result.lastPlugin = plugin22;
17650 try {
17651 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
17652 if (this.result.root.type === "document") {
17653 var roots = this.result.root.nodes.map(function(root2) {
17654 return plugin22.Once(root2, _this.helpers);
17655 });
17656 if (isPromise(roots[0])) {
17657 return Promise.all(roots);
17658 }
17659 return roots;
17660 }
17661 return plugin22.Once(this.result.root, this.helpers);
17662 } else if (typeof plugin22 === "function") {
17663 return plugin22(this.result.root, this.result);
17664 }
17665 } catch (error) {
17666 throw this.handleError(error);
17667 }
17668 };
17669 _proto.stringify = function stringify() {
17670 if (this.error) throw this.error;
17671 if (this.stringified) return this.result;
17672 this.stringified = true;
17673 this.sync();
17674 var opts = this.result.opts;
17675 var str = stringify$2;
17676 if (opts.syntax) str = opts.syntax.stringify;
17677 if (opts.stringifier) str = opts.stringifier;
17678 if (str.stringify) str = str.stringify;
17679 var map = new MapGenerator$1(str, this.result.root, this.result.opts);
17680 var data = map.generate();
17681 this.result.css = data[0];
17682 this.result.map = data[1];
17683 return this.result;
17684 };
17685 _proto.sync = function sync() {
17686 if (this.error) throw this.error;
17687 if (this.processed) return this.result;
17688 this.processed = true;
17689 if (this.processing) {
17690 throw this.getAsyncError();
17691 }
17692 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17693 var plugin22 = _step.value;
17694 var promise = this.runOnRoot(plugin22);
17695 if (isPromise(promise)) {
17696 throw this.getAsyncError();
17697 }
17698 }
17699 this.prepareVisitors();
17700 if (this.hasListener) {
17701 var root2 = this.result.root;
17702 while(!root2[isClean]){
17703 root2[isClean] = true;
17704 this.walkSync(root2);
17705 }
17706 if (this.listeners.OnceExit) {
17707 if (root2.type === "document") {
17708 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
17709 var subRoot = _step1.value;
17710 this.visitSync(this.listeners.OnceExit, subRoot);
17711 }
17712 } else {
17713 this.visitSync(this.listeners.OnceExit, root2);
17714 }
17715 }
17716 }
17717 return this.result;
17718 };
17719 _proto.then = function then(onFulfilled, onRejected) {
17720 if (true) {
17721 if (!("from" in this.opts)) {
17722 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.");
17723 }
17724 }
17725 return this.async().then(onFulfilled, onRejected);
17726 };
17727 _proto.toString = function toString() {
17728 return this.css;
17729 };
17730 _proto.visitSync = function visitSync(visitors, node2) {
17731 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
17732 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
17733 this.result.lastPlugin = plugin22;
17734 var promise = void 0;
17735 try {
17736 promise = visitor(node2, this.helpers);
17737 } catch (e2) {
17738 throw this.handleError(e2, node2.proxyOf);
17739 }
17740 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
17741 return true;
17742 }
17743 if (isPromise(promise)) {
17744 throw this.getAsyncError();
17745 }
17746 }
17747 };
17748 _proto.visitTick = function visitTick(stack) {
17749 var visit2 = stack[stack.length - 1];
17750 var node2 = visit2.node, visitors = visit2.visitors;
17751 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
17752 stack.pop();
17753 return;
17754 }
17755 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
17756 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
17757 visit2.visitorIndex += 1;
17758 if (visit2.visitorIndex === visitors.length) {
17759 visit2.visitors = [];
17760 visit2.visitorIndex = 0;
17761 }
17762 this.result.lastPlugin = plugin22;
17763 try {
17764 return visitor(node2.toProxy(), this.helpers);
17765 } catch (e2) {
17766 throw this.handleError(e2, node2);
17767 }
17768 }
17769 if (visit2.iterator !== 0) {
17770 var iterator = visit2.iterator;
17771 var child;
17772 while(child = node2.nodes[node2.indexes[iterator]]){
17773 node2.indexes[iterator] += 1;
17774 if (!child[isClean]) {
17775 child[isClean] = true;
17776 stack.push(toStack(child));
17777 return;
17778 }
17779 }
17780 visit2.iterator = 0;
17781 delete node2.indexes[iterator];
17782 }
17783 var events = visit2.events;
17784 while(visit2.eventIndex < events.length){
17785 var event = events[visit2.eventIndex];
17786 visit2.eventIndex += 1;
17787 if (event === CHILDREN) {
17788 if (node2.nodes && node2.nodes.length) {
17789 node2[isClean] = true;
17790 visit2.iterator = node2.getIterator();
17791 }
17792 return;
17793 } else if (this.listeners[event]) {
17794 visit2.visitors = this.listeners[event];
17795 return;
17796 }
17797 }
17798 stack.pop();
17799 };
17800 _proto.walkSync = function walkSync(node2) {
17801 var _this = this;
17802 node2[isClean] = true;
17803 var events = getEvents(node2);
17804 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
17805 var event = _step.value;
17806 if (event === CHILDREN) {
17807 if (node2.nodes) {
17808 node2.each(function(child) {
17809 if (!child[isClean]) _this.walkSync(child);
17810 });
17811 }
17812 } else {
17813 var visitors = this.listeners[event];
17814 if (visitors) {
17815 if (this.visitSync(visitors, node2.toProxy())) return;
17816 }
17817 }
17818 }
17819 };
17820 _proto.warnings = function warnings() {
17821 return this.sync().warnings();
17822 };
17823 _create_class(LazyResult2, [
17824 {
17825 key: "content",
17826 get: function get() {
17827 return this.stringify().content;
17828 }
17829 },
17830 {
17831 key: "css",
17832 get: function get() {
17833 return this.stringify().css;
17834 }
17835 },
17836 {
17837 key: "map",
17838 get: function get() {
17839 return this.stringify().map;
17840 }
17841 },
17842 {
17843 key: "messages",
17844 get: function get() {
17845 return this.sync().messages;
17846 }
17847 },
17848 {
17849 key: "opts",
17850 get: function get() {
17851 return this.result.opts;
17852 }
17853 },
17854 {
17855 key: "processor",
17856 get: function get() {
17857 return this.result.processor;
17858 }
17859 },
17860 {
17861 key: "root",
17862 get: function get() {
17863 return this.sync().root;
17864 }
17865 },
17866 {
17867 key: Symbol.toStringTag,
17868 get: function get() {
17869 return "LazyResult";
17870 }
17871 }
17872 ]);
17873 return LazyResult2;
17874 }();
17875 LazyResult$2.registerPostcss = function(dependant) {
17876 postcss$2 = dependant;
17877 };
17878 var lazyResult = LazyResult$2;
17879 LazyResult$2.default = LazyResult$2;
17880 Root$3.registerLazyResult(LazyResult$2);
17881 Document$2.registerLazyResult(LazyResult$2);
17882 var MapGenerator22 = mapGenerator;
17883 var stringify$1 = stringify_1;
17884 var warnOnce22 = warnOnce$2;
17885 var parse$1 = parse_1;
17886 var Result$1 = result;
17887 var NoWorkResult$1 = /*#__PURE__*/ function() {
17888 function NoWorkResult2(processor2, css, opts) {
17889 css = css.toString();
17890 this.stringified = false;
17891 this._processor = processor2;
17892 this._css = css;
17893 this._opts = opts;
17894 this._map = void 0;
17895 var root2;
17896 var str = stringify$1;
17897 this.result = new Result$1(this._processor, root2, this._opts);
17898 this.result.css = css;
17899 var self = this;
17900 Object.defineProperty(this.result, "root", {
17901 get: function get() {
17902 return self.root;
17903 }
17904 });
17905 var map = new MapGenerator22(str, root2, this._opts, css);
17906 if (map.isMap()) {
17907 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
17908 if (generatedCSS) {
17909 this.result.css = generatedCSS;
17910 }
17911 if (generatedMap) {
17912 this.result.map = generatedMap;
17913 }
17914 } else {
17915 map.clearAnnotation();
17916 this.result.css = map.css;
17917 }
17918 }
17919 var _proto = NoWorkResult2.prototype;
17920 _proto.async = function async() {
17921 if (this.error) return Promise.reject(this.error);
17922 return Promise.resolve(this.result);
17923 };
17924 _proto.catch = function _catch(onRejected) {
17925 return this.async().catch(onRejected);
17926 };
17927 _proto.finally = function _finally(onFinally) {
17928 return this.async().then(onFinally, onFinally);
17929 };
17930 _proto.sync = function sync() {
17931 if (this.error) throw this.error;
17932 return this.result;
17933 };
17934 _proto.then = function then(onFulfilled, onRejected) {
17935 if (true) {
17936 if (!("from" in this._opts)) {
17937 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.");
17938 }
17939 }
17940 return this.async().then(onFulfilled, onRejected);
17941 };
17942 _proto.toString = function toString() {
17943 return this._css;
17944 };
17945 _proto.warnings = function warnings() {
17946 return [];
17947 };
17948 _create_class(NoWorkResult2, [
17949 {
17950 key: "content",
17951 get: function get() {
17952 return this.result.css;
17953 }
17954 },
17955 {
17956 key: "css",
17957 get: function get() {
17958 return this.result.css;
17959 }
17960 },
17961 {
17962 key: "map",
17963 get: function get() {
17964 return this.result.map;
17965 }
17966 },
17967 {
17968 key: "messages",
17969 get: function get() {
17970 return [];
17971 }
17972 },
17973 {
17974 key: "opts",
17975 get: function get() {
17976 return this.result.opts;
17977 }
17978 },
17979 {
17980 key: "processor",
17981 get: function get() {
17982 return this.result.processor;
17983 }
17984 },
17985 {
17986 key: "root",
17987 get: function get() {
17988 if (this._root) {
17989 return this._root;
17990 }
17991 var root2;
17992 var parser2 = parse$1;
17993 try {
17994 root2 = parser2(this._css, this._opts);
17995 } catch (error) {
17996 this.error = error;
17997 }
17998 if (this.error) {
17999 throw this.error;
18000 } else {
18001 this._root = root2;
18002 return root2;
18003 }
18004 }
18005 },
18006 {
18007 key: Symbol.toStringTag,
18008 get: function get() {
18009 return "NoWorkResult";
18010 }
18011 }
18012 ]);
18013 return NoWorkResult2;
18014 }();
18015 var noWorkResult = NoWorkResult$1;
18016 NoWorkResult$1.default = NoWorkResult$1;
18017 var NoWorkResult22 = noWorkResult;
18018 var LazyResult$1 = lazyResult;
18019 var Document$1 = document$1$2;
18020 var Root$2 = root;
18021 var Processor$1 = /*#__PURE__*/ function() {
18022 function Processor2(plugins) {
18023 if (plugins === void 0) plugins = [];
18024 this.version = "8.4.38";
18025 this.plugins = this.normalize(plugins);
18026 }
18027 var _proto = Processor2.prototype;
18028 _proto.normalize = function normalize(plugins) {
18029 var normalized = [];
18030 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
18031 var i2 = _step.value;
18032 if (i2.postcss === true) {
18033 i2 = i2();
18034 } else if (i2.postcss) {
18035 i2 = i2.postcss;
18036 }
18037 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
18038 normalized = normalized.concat(i2.plugins);
18039 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
18040 normalized.push(i2);
18041 } else if (typeof i2 === "function") {
18042 normalized.push(i2);
18043 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
18044 if (true) {
18045 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.");
18046 }
18047 } else {
18048 throw new Error(i2 + " is not a PostCSS plugin");
18049 }
18050 }
18051 return normalized;
18052 };
18053 _proto.process = function process1(css, opts) {
18054 if (opts === void 0) opts = {};
18055 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
18056 return new NoWorkResult22(this, css, opts);
18057 } else {
18058 return new LazyResult$1(this, css, opts);
18059 }
18060 };
18061 _proto.use = function use(plugin22) {
18062 this.plugins = this.plugins.concat(this.normalize([
18063 plugin22
18064 ]));
18065 return this;
18066 };
18067 return Processor2;
18068 }();
18069 var processor = Processor$1;
18070 Processor$1.default = Processor$1;
18071 Root$2.registerProcessor(Processor$1);
18072 Document$1.registerProcessor(Processor$1);
18073 var Declaration$1 = declaration;
18074 var PreviousMap22 = previousMap;
18075 var Comment$1 = comment;
18076 var AtRule$1 = atRule;
18077 var Input$1 = input;
18078 var Root$1 = root;
18079 var Rule$1 = rule;
18080 function fromJSON$1(json, inputs) {
18081 if (Array.isArray(json)) return json.map(function(n2) {
18082 return fromJSON$1(n2);
18083 });
18084 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
18085 "inputs"
18086 ]);
18087 if (ownInputs) {
18088 inputs = [];
18089 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
18090 var input2 = _step.value;
18091 var inputHydrated = _extends({}, input2, {
18092 __proto__: Input$1.prototype
18093 });
18094 if (inputHydrated.map) {
18095 inputHydrated.map = _extends({}, inputHydrated.map, {
18096 __proto__: PreviousMap22.prototype
18097 });
18098 }
18099 inputs.push(inputHydrated);
18100 }
18101 }
18102 if (defaults.nodes) {
18103 defaults.nodes = json.nodes.map(function(n2) {
18104 return fromJSON$1(n2, inputs);
18105 });
18106 }
18107 if (defaults.source) {
18108 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
18109 "inputId"
18110 ]);
18111 defaults.source = source;
18112 if (inputId != null) {
18113 defaults.source.input = inputs[inputId];
18114 }
18115 }
18116 if (defaults.type === "root") {
18117 return new Root$1(defaults);
18118 } else if (defaults.type === "decl") {
18119 return new Declaration$1(defaults);
18120 } else if (defaults.type === "rule") {
18121 return new Rule$1(defaults);
18122 } else if (defaults.type === "comment") {
18123 return new Comment$1(defaults);
18124 } else if (defaults.type === "atrule") {
18125 return new AtRule$1(defaults);
18126 } else {
18127 throw new Error("Unknown node type: " + json.type);
18128 }
18129 }
18130 var fromJSON_1 = fromJSON$1;
18131 fromJSON$1.default = fromJSON$1;
18132 var CssSyntaxError22 = cssSyntaxError;
18133 var Declaration22 = declaration;
18134 var LazyResult22 = lazyResult;
18135 var Container22 = container;
18136 var Processor22 = processor;
18137 var stringify = stringify_1;
18138 var fromJSON = fromJSON_1;
18139 var Document222 = document$1$2;
18140 var Warning22 = warning;
18141 var Comment22 = comment;
18142 var AtRule22 = atRule;
18143 var Result22 = result;
18144 var Input22 = input;
18145 var parse = parse_1;
18146 var list = list_1;
18147 var Rule22 = rule;
18148 var Root22 = root;
18149 var Node22 = node;
18150 function postcss() {
18151 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
18152 plugins[_key] = arguments[_key];
18153 }
18154 if (plugins.length === 1 && Array.isArray(plugins[0])) {
18155 plugins = plugins[0];
18156 }
18157 return new Processor22(plugins);
18158 }
18159 postcss.plugin = function plugin2(name, initializer) {
18160 var warningPrinted = false;
18161 function creator() {
18162 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18163 args[_key] = arguments[_key];
18164 }
18165 if (console && console.warn && !warningPrinted) {
18166 warningPrinted = true;
18167 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
18168 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
18169 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
18170 }
18171 }
18172 var transformer = initializer.apply(void 0, [].concat(args));
18173 transformer.postcssPlugin = name;
18174 transformer.postcssVersion = new Processor22().version;
18175 return transformer;
18176 }
18177 var cache;
18178 Object.defineProperty(creator, "postcss", {
18179 get: function get() {
18180 if (!cache) cache = creator();
18181 return cache;
18182 }
18183 });
18184 creator.process = function(css, processOpts, pluginOpts) {
18185 return postcss([
18186 creator(pluginOpts)
18187 ]).process(css, processOpts);
18188 };
18189 return creator;
18190 };
18191 postcss.stringify = stringify;
18192 postcss.parse = parse;
18193 postcss.fromJSON = fromJSON;
18194 postcss.list = list;
18195 postcss.comment = function(defaults) {
18196 return new Comment22(defaults);
18197 };
18198 postcss.atRule = function(defaults) {
18199 return new AtRule22(defaults);
18200 };
18201 postcss.decl = function(defaults) {
18202 return new Declaration22(defaults);
18203 };
18204 postcss.rule = function(defaults) {
18205 return new Rule22(defaults);
18206 };
18207 postcss.root = function(defaults) {
18208 return new Root22(defaults);
18209 };
18210 postcss.document = function(defaults) {
18211 return new Document222(defaults);
18212 };
18213 postcss.CssSyntaxError = CssSyntaxError22;
18214 postcss.Declaration = Declaration22;
18215 postcss.Container = Container22;
18216 postcss.Processor = Processor22;
18217 postcss.Document = Document222;
18218 postcss.Comment = Comment22;
18219 postcss.Warning = Warning22;
18220 postcss.AtRule = AtRule22;
18221 postcss.Result = Result22;
18222 postcss.Input = Input22;
18223 postcss.Rule = Rule22;
18224 postcss.Root = Root22;
18225 postcss.Node = Node22;
18226 LazyResult22.registerPostcss(postcss);
18227 var postcss_1 = postcss;
18228 postcss.default = postcss;
18229 var postcss$1 = /* @__PURE__ */ getDefaultExportFromCjs(postcss_1);
18230 postcss$1.stringify;
18231 postcss$1.fromJSON;
18232 postcss$1.plugin;
18233 postcss$1.parse;
18234 postcss$1.list;
18235 postcss$1.document;
18236 postcss$1.comment;
18237 postcss$1.atRule;
18238 postcss$1.rule;
18239 postcss$1.decl;
18240 postcss$1.root;
18241 postcss$1.CssSyntaxError;
18242 postcss$1.Declaration;
18243 postcss$1.Container;
18244 postcss$1.Processor;
18245 postcss$1.Document;
18246 postcss$1.Comment;
18247 postcss$1.Warning;
18248 postcss$1.AtRule;
18249 postcss$1.Result;
18250 postcss$1.Input;
18251 postcss$1.Rule;
18252 postcss$1.Root;
18253 postcss$1.Node;
18254 var BaseRRNode = /*#__PURE__*/ function() {
18255 function BaseRRNode() {
18256 for(var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++){
18257 _args[_key] = arguments[_key];
18258 }
18259 __publicField2(this, "parentElement", null);
18260 __publicField2(this, "parentNode", null);
18261 __publicField2(this, "ownerDocument");
18262 __publicField2(this, "firstChild", null);
18263 __publicField2(this, "lastChild", null);
18264 __publicField2(this, "previousSibling", null);
18265 __publicField2(this, "nextSibling", null);
18266 __publicField2(this, "ELEMENT_NODE", 1);
18267 __publicField2(this, "TEXT_NODE", 3);
18268 __publicField2(this, "nodeType");
18269 __publicField2(this, "nodeName");
18270 __publicField2(this, "RRNodeType");
18271 }
18272 var _proto = BaseRRNode.prototype;
18273 _proto.contains = function contains(node2) {
18274 if (!_instanceof(node2, BaseRRNode)) return false;
18275 else if (node2.ownerDocument !== this.ownerDocument) return false;
18276 else if (node2 === this) return true;
18277 while(node2.parentNode){
18278 if (node2.parentNode === this) return true;
18279 node2 = node2.parentNode;
18280 }
18281 return false;
18282 };
18283 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18284 _proto.appendChild = function appendChild(_newChild) {
18285 throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.");
18286 };
18287 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18288 _proto.insertBefore = function insertBefore(_newChild, _refChild) {
18289 throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.");
18290 };
18291 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18292 _proto.removeChild = function removeChild(_node) {
18293 throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.");
18294 };
18295 _proto.toString = function toString() {
18296 return "RRNode";
18297 };
18298 _create_class(BaseRRNode, [
18299 {
18300 key: "childNodes",
18301 get: function get() {
18302 var childNodes2 = [];
18303 var childIterator = this.firstChild;
18304 while(childIterator){
18305 childNodes2.push(childIterator);
18306 childIterator = childIterator.nextSibling;
18307 }
18308 return childNodes2;
18309 }
18310 }
18311 ]);
18312 return BaseRRNode;
18313 }();
18314 var testableAccessors = {
18315 Node: [
18316 "childNodes",
18317 "parentNode",
18318 "parentElement",
18319 "textContent"
18320 ],
18321 ShadowRoot: [
18322 "host",
18323 "styleSheets"
18324 ],
18325 Element: [
18326 "shadowRoot",
18327 "querySelector",
18328 "querySelectorAll"
18329 ],
18330 MutationObserver: []
18331 };
18332 var testableMethods = {
18333 Node: [
18334 "contains",
18335 "getRootNode"
18336 ],
18337 ShadowRoot: [
18338 "getSelection"
18339 ],
18340 Element: [],
18341 MutationObserver: [
18342 "constructor"
18343 ]
18344 };
18345 var untaintedBasePrototype = {};
18346 var isAngularZonePresent = function() {
18347 return !!globalThis.Zone;
18348 };
18349 function getUntaintedPrototype(key) {
18350 if (untaintedBasePrototype[key]) return untaintedBasePrototype[key];
18351 var defaultObj = globalThis[key];
18352 var defaultPrototype = defaultObj.prototype;
18353 var accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
18354 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
18355 accessorNames.every(function(accessor) {
18356 var _a2, _b;
18357 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
18358 }));
18359 var methodNames = key in testableMethods ? testableMethods[key] : void 0;
18360 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
18361 function(method) {
18362 var _a2;
18363 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
18364 }));
18365 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {
18366 untaintedBasePrototype[key] = defaultObj.prototype;
18367 return defaultObj.prototype;
18368 }
18369 try {
18370 var iframeEl = document.createElement("iframe");
18371 document.body.appendChild(iframeEl);
18372 var win = iframeEl.contentWindow;
18373 if (!win) return defaultObj.prototype;
18374 var untaintedObject = win[key].prototype;
18375 document.body.removeChild(iframeEl);
18376 if (!untaintedObject) return defaultPrototype;
18377 return untaintedBasePrototype[key] = untaintedObject;
18378 } catch (e) {
18379 return defaultPrototype;
18380 }
18381 }
18382 var untaintedAccessorCache = {};
18383 function getUntaintedAccessor(key, instance, accessor) {
18384 var _a2;
18385 var cacheKey = key + "." + String(accessor);
18386 if (untaintedAccessorCache[cacheKey]) return untaintedAccessorCache[cacheKey].call(instance);
18387 var untaintedPrototype = getUntaintedPrototype(key);
18388 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
18389 if (!untaintedAccessor) return instance[accessor];
18390 untaintedAccessorCache[cacheKey] = untaintedAccessor;
18391 return untaintedAccessor.call(instance);
18392 }
18393 var untaintedMethodCache = {};
18394 function getUntaintedMethod(key, instance, method) {
18395 var cacheKey = key + "." + String(method);
18396 if (untaintedMethodCache[cacheKey]) return untaintedMethodCache[cacheKey].bind(instance);
18397 var untaintedPrototype = getUntaintedPrototype(key);
18398 var untaintedMethod = untaintedPrototype[method];
18399 if (typeof untaintedMethod !== "function") return instance[method];
18400 untaintedMethodCache[cacheKey] = untaintedMethod;
18401 return untaintedMethod.bind(instance);
18402 }
18403 function childNodes(n2) {
18404 return getUntaintedAccessor("Node", n2, "childNodes");
18405 }
18406 function parentNode(n2) {
18407 return getUntaintedAccessor("Node", n2, "parentNode");
18408 }
18409 function parentElement(n2) {
18410 return getUntaintedAccessor("Node", n2, "parentElement");
18411 }
18412 function textContent(n2) {
18413 return getUntaintedAccessor("Node", n2, "textContent");
18414 }
18415 function contains(n2, other) {
18416 return getUntaintedMethod("Node", n2, "contains")(other);
18417 }
18418 function getRootNode(n2) {
18419 return getUntaintedMethod("Node", n2, "getRootNode")();
18420 }
18421 function host(n2) {
18422 if (!n2 || !("host" in n2)) return null;
18423 return getUntaintedAccessor("ShadowRoot", n2, "host");
18424 }
18425 function styleSheets(n2) {
18426 return n2.styleSheets;
18427 }
18428 function shadowRoot(n2) {
18429 if (!n2 || !("shadowRoot" in n2)) return null;
18430 return getUntaintedAccessor("Element", n2, "shadowRoot");
18431 }
18432 function querySelector(n2, selectors) {
18433 return getUntaintedAccessor("Element", n2, "querySelector")(selectors);
18434 }
18435 function querySelectorAll(n2, selectors) {
18436 return getUntaintedAccessor("Element", n2, "querySelectorAll")(selectors);
18437 }
18438 function mutationObserverCtor() {
18439 return getUntaintedPrototype("MutationObserver").constructor;
18440 }
18441 function patch(source, name, replacement) {
18442 try {
18443 if (!(name in source)) {
18444 return function() {};
18445 }
18446 var original = source[name];
18447 var wrapped = replacement(original);
18448 if (typeof wrapped === "function") {
18449 wrapped.prototype = wrapped.prototype || {};
18450 Object.defineProperties(wrapped, {
18451 __rrweb_original__: {
18452 enumerable: false,
18453 value: original
18454 }
18455 });
18456 }
18457 source[name] = wrapped;
18458 return function() {
18459 source[name] = original;
18460 };
18461 } catch (e) {
18462 return function() {};
18463 }
18464 }
18465 var index = {
18466 childNodes: childNodes,
18467 parentNode: parentNode,
18468 parentElement: parentElement,
18469 textContent: textContent,
18470 contains: contains,
18471 getRootNode: getRootNode,
18472 host: host,
18473 styleSheets: styleSheets,
18474 shadowRoot: shadowRoot,
18475 querySelector: querySelector,
18476 querySelectorAll: querySelectorAll,
18477 mutationObserver: mutationObserverCtor,
18478 patch: patch
18479 };
18480 function on(type, fn, target) {
18481 if (target === void 0) target = document;
18482 var options = {
18483 capture: true,
18484 passive: true
18485 };
18486 target.addEventListener(type, fn, options);
18487 return function() {
18488 return target.removeEventListener(type, fn, options);
18489 };
18490 }
18491 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.";
18492 var _mirror = {
18493 map: {},
18494 getId: function getId() {
18495 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18496 return -1;
18497 },
18498 getNode: function getNode() {
18499 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18500 return null;
18501 },
18502 removeNodeFromMap: function removeNodeFromMap() {
18503 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18504 },
18505 has: function has() {
18506 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18507 return false;
18508 },
18509 reset: function reset() {
18510 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18511 }
18512 };
18513 if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
18514 _mirror = new Proxy(_mirror, {
18515 get: function get(target, prop, receiver) {
18516 if (prop === "map") {
18517 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18518 }
18519 return Reflect.get(target, prop, receiver);
18520 }
18521 });
18522 }
18523 function throttle(func, wait, options) {
18524 if (options === void 0) options = {};
18525 var timeout = null;
18526 var previous = 0;
18527 return function() {
18528 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18529 args[_key] = arguments[_key];
18530 }
18531 var now = Date.now();
18532 if (!previous && options.leading === false) {
18533 previous = now;
18534 }
18535 var remaining = wait - (now - previous);
18536 var context = this;
18537 if (remaining <= 0 || remaining > wait) {
18538 if (timeout) {
18539 clearTimeout(timeout);
18540 timeout = null;
18541 }
18542 previous = now;
18543 func.apply(context, args);
18544 } else if (!timeout && options.trailing !== false) {
18545 timeout = setTimeout(function() {
18546 previous = options.leading === false ? 0 : Date.now();
18547 timeout = null;
18548 func.apply(context, args);
18549 }, remaining);
18550 }
18551 };
18552 }
18553 function hookSetter(target, key, d, isRevoked, win) {
18554 if (win === void 0) win = window;
18555 var original = win.Object.getOwnPropertyDescriptor(target, key);
18556 win.Object.defineProperty(target, key, isRevoked ? d : {
18557 set: function set(value) {
18558 var _this = this;
18559 setTimeout(function() {
18560 d.set.call(_this, value);
18561 }, 0);
18562 if (original && original.set) {
18563 original.set.call(this, value);
18564 }
18565 }
18566 });
18567 return function() {
18568 return hookSetter(target, key, original || {}, true);
18569 };
18570 }
18571 var nowTimestamp = Date.now;
18572 if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
18573 nowTimestamp = function() {
18574 return /* @__PURE__ */ new Date().getTime();
18575 };
18576 }
18577 function getWindowScroll(win) {
18578 var _a2, _b, _c, _d;
18579 var doc = win.document;
18580 return {
18581 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,
18582 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
18583 };
18584 }
18585 function getWindowHeight() {
18586 return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
18587 }
18588 function getWindowWidth() {
18589 return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
18590 }
18591 function closestElementOfNode(node2) {
18592 if (!node2) {
18593 return null;
18594 }
18595 var el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index.parentElement(node2);
18596 return el;
18597 }
18598 function isBlocked(node2, blockClass, blockSelector, checkAncestors) {
18599 if (!node2) {
18600 return false;
18601 }
18602 var el = closestElementOfNode(node2);
18603 if (!el) {
18604 return false;
18605 }
18606 try {
18607 if (typeof blockClass === "string") {
18608 if (el.classList.contains(blockClass)) return true;
18609 if (checkAncestors && el.closest("." + blockClass) !== null) return true;
18610 } else {
18611 if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
18612 }
18613 } catch (e2) {}
18614 if (blockSelector) {
18615 if (el.matches(blockSelector)) return true;
18616 if (checkAncestors && el.closest(blockSelector) !== null) return true;
18617 }
18618 return false;
18619 }
18620 function isSerialized(n2, mirror2) {
18621 return mirror2.getId(n2) !== -1;
18622 }
18623 function isIgnored(n2, mirror2, slimDOMOptions) {
18624 if (n2.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
18625 return true;
18626 }
18627 return mirror2.getId(n2) === IGNORED_NODE;
18628 }
18629 function isAncestorRemoved(target, mirror2) {
18630 if (isShadowRoot(target)) {
18631 return false;
18632 }
18633 var id = mirror2.getId(target);
18634 if (!mirror2.has(id)) {
18635 return true;
18636 }
18637 var parent = index.parentNode(target);
18638 if (parent && parent.nodeType === target.DOCUMENT_NODE) {
18639 return false;
18640 }
18641 if (!parent) {
18642 return true;
18643 }
18644 return isAncestorRemoved(parent, mirror2);
18645 }
18646 function legacy_isTouchEvent(event) {
18647 return Boolean(event.changedTouches);
18648 }
18649 function polyfill$1(win) {
18650 if (win === void 0) win = window;
18651 if ("NodeList" in win && !win.NodeList.prototype.forEach) {
18652 win.NodeList.prototype.forEach = Array.prototype.forEach;
18653 }
18654 if ("DOMTokenList" in win && !win.DOMTokenList.prototype.forEach) {
18655 win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
18656 }
18657 }
18658 function isSerializedIframe(n2, mirror2) {
18659 return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
18660 }
18661 function isSerializedStylesheet(n2, mirror2) {
18662 return Boolean(n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2));
18663 }
18664 function hasShadowRoot(n2) {
18665 if (!n2) return false;
18666 if (_instanceof(n2, BaseRRNode) && "shadowRoot" in n2) {
18667 return Boolean(n2.shadowRoot);
18668 }
18669 return Boolean(index.shadowRoot(n2));
18670 }
18671 var StyleSheetMirror = /*#__PURE__*/ function() {
18672 function StyleSheetMirror() {
18673 __publicField(this, "id", 1);
18674 __publicField(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
18675 __publicField(this, "idStyleMap", /* @__PURE__ */ new Map());
18676 }
18677 var _proto = StyleSheetMirror.prototype;
18678 _proto.getId = function getId(stylesheet) {
18679 var _this_styleIDMap_get;
18680 return (_this_styleIDMap_get = this.styleIDMap.get(stylesheet)) != null ? _this_styleIDMap_get : -1;
18681 };
18682 _proto.has = function has(stylesheet) {
18683 return this.styleIDMap.has(stylesheet);
18684 };
18685 /**
18686 * @returns If the stylesheet is in the mirror, returns the id of the stylesheet. If not, return the new assigned id.
18687 */ _proto.add = function add(stylesheet, id) {
18688 if (this.has(stylesheet)) return this.getId(stylesheet);
18689 var newId;
18690 if (id === void 0) {
18691 newId = this.id++;
18692 } else newId = id;
18693 this.styleIDMap.set(stylesheet, newId);
18694 this.idStyleMap.set(newId, stylesheet);
18695 return newId;
18696 };
18697 _proto.getStyle = function getStyle(id) {
18698 return this.idStyleMap.get(id) || null;
18699 };
18700 _proto.reset = function reset() {
18701 this.styleIDMap = /* @__PURE__ */ new WeakMap();
18702 this.idStyleMap = /* @__PURE__ */ new Map();
18703 this.id = 1;
18704 };
18705 _proto.generateId = function generateId() {
18706 return this.id++;
18707 };
18708 return StyleSheetMirror;
18709 }();
18710 function getShadowHost(n2) {
18711 var _a2;
18712 var shadowHost = null;
18713 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));
18714 return shadowHost;
18715 }
18716 function getRootShadowHost(n2) {
18717 var rootShadowHost = n2;
18718 var shadowHost;
18719 while(shadowHost = getShadowHost(rootShadowHost))rootShadowHost = shadowHost;
18720 return rootShadowHost;
18721 }
18722 function shadowHostInDom(n2) {
18723 var doc = n2.ownerDocument;
18724 if (!doc) return false;
18725 var shadowHost = getRootShadowHost(n2);
18726 return index.contains(doc, shadowHost);
18727 }
18728 function inDom(n2) {
18729 var doc = n2.ownerDocument;
18730 if (!doc) return false;
18731 return index.contains(doc, n2) || shadowHostInDom(n2);
18732 }
18733 var EventType = /* @__PURE__ */ function(EventType2) {
18734 EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
18735 EventType2[EventType2["Load"] = 1] = "Load";
18736 EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
18737 EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
18738 EventType2[EventType2["Meta"] = 4] = "Meta";
18739 EventType2[EventType2["Custom"] = 5] = "Custom";
18740 EventType2[EventType2["Plugin"] = 6] = "Plugin";
18741 return EventType2;
18742 }(EventType || {});
18743 var IncrementalSource = /* @__PURE__ */ function(IncrementalSource2) {
18744 IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
18745 IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
18746 IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
18747 IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
18748 IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
18749 IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
18750 IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
18751 IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
18752 IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
18753 IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
18754 IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
18755 IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
18756 IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
18757 IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
18758 IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
18759 IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
18760 IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
18761 return IncrementalSource2;
18762 }(IncrementalSource || {});
18763 var MouseInteractions = /* @__PURE__ */ function(MouseInteractions2) {
18764 MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
18765 MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
18766 MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
18767 MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
18768 MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
18769 MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
18770 MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
18771 MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
18772 MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
18773 MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
18774 MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
18775 return MouseInteractions2;
18776 }(MouseInteractions || {});
18777 var PointerTypes = /* @__PURE__ */ function(PointerTypes2) {
18778 PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
18779 PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
18780 PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
18781 return PointerTypes2;
18782 }(PointerTypes || {});
18783 var CanvasContext = /* @__PURE__ */ function(CanvasContext2) {
18784 CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
18785 CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
18786 CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
18787 return CanvasContext2;
18788 }(CanvasContext || {});
18789 var MediaInteractions = /* @__PURE__ */ function(MediaInteractions2) {
18790 MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
18791 MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
18792 MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
18793 MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
18794 MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
18795 return MediaInteractions2;
18796 }(MediaInteractions || {});
18797 var NodeType = /* @__PURE__ */ function(NodeType2) {
18798 NodeType2[NodeType2["Document"] = 0] = "Document";
18799 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
18800 NodeType2[NodeType2["Element"] = 2] = "Element";
18801 NodeType2[NodeType2["Text"] = 3] = "Text";
18802 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
18803 NodeType2[NodeType2["Comment"] = 5] = "Comment";
18804 return NodeType2;
18805 }(NodeType || {});
18806 function isNodeInLinkedList(n2) {
18807 return "__ln" in n2;
18808 }
18809 var DoubleLinkedList = /*#__PURE__*/ function() {
18810 function DoubleLinkedList() {
18811 __publicField(this, "length", 0);
18812 __publicField(this, "head", null);
18813 __publicField(this, "tail", null);
18814 }
18815 var _proto = DoubleLinkedList.prototype;
18816 _proto.get = function get(position) {
18817 if (position >= this.length) {
18818 throw new Error("Position outside of list range");
18819 }
18820 var current = this.head;
18821 for(var index2 = 0; index2 < position; index2++){
18822 current = (current == null ? void 0 : current.next) || null;
18823 }
18824 return current;
18825 };
18826 _proto.addNode = function addNode(n2) {
18827 var node2 = {
18828 value: n2,
18829 previous: null,
18830 next: null
18831 };
18832 n2.__ln = node2;
18833 if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
18834 var current = n2.previousSibling.__ln.next;
18835 node2.next = current;
18836 node2.previous = n2.previousSibling.__ln;
18837 n2.previousSibling.__ln.next = node2;
18838 if (current) {
18839 current.previous = node2;
18840 }
18841 } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
18842 var current1 = n2.nextSibling.__ln.previous;
18843 node2.previous = current1;
18844 node2.next = n2.nextSibling.__ln;
18845 n2.nextSibling.__ln.previous = node2;
18846 if (current1) {
18847 current1.next = node2;
18848 }
18849 } else {
18850 if (this.head) {
18851 this.head.previous = node2;
18852 }
18853 node2.next = this.head;
18854 this.head = node2;
18855 }
18856 if (node2.next === null) {
18857 this.tail = node2;
18858 }
18859 this.length++;
18860 };
18861 _proto.removeNode = function removeNode(n2) {
18862 var current = n2.__ln;
18863 if (!this.head) {
18864 return;
18865 }
18866 if (!current.previous) {
18867 this.head = current.next;
18868 if (this.head) {
18869 this.head.previous = null;
18870 } else {
18871 this.tail = null;
18872 }
18873 } else {
18874 current.previous.next = current.next;
18875 if (current.next) {
18876 current.next.previous = current.previous;
18877 } else {
18878 this.tail = current.previous;
18879 }
18880 }
18881 if (n2.__ln) {
18882 delete n2.__ln;
18883 }
18884 this.length--;
18885 };
18886 return DoubleLinkedList;
18887 }();
18888 var moveKey = function(id, parentId) {
18889 return id + "@" + parentId;
18890 };
18891 var MutationBuffer = /*#__PURE__*/ function() {
18892 function MutationBuffer() {
18893 var _this = this;
18894 __publicField(this, "frozen", false);
18895 __publicField(this, "locked", false);
18896 __publicField(this, "texts", []);
18897 __publicField(this, "attributes", []);
18898 __publicField(this, "attributeMap", /* @__PURE__ */ new WeakMap());
18899 __publicField(this, "removes", []);
18900 __publicField(this, "mapRemoves", []);
18901 __publicField(this, "movedMap", {});
18902 /**
18903 * the browser MutationObserver emits multiple mutations after
18904 * a delay for performance reasons, making tracing added nodes hard
18905 * in our `processMutations` callback function.
18906 * For example, if we append an element el_1 into body, and then append
18907 * another element el_2 into el_1, these two mutations may be passed to the
18908 * callback function together when the two operations were done.
18909 * Generally we need to trace child nodes of newly added nodes, but in this
18910 * case if we count el_2 as el_1's child node in the first mutation record,
18911 * then we will count el_2 again in the second mutation record which was
18912 * duplicated.
18913 * To avoid of duplicate counting added nodes, we use a Set to store
18914 * added nodes and its child nodes during iterate mutation records. Then
18915 * collect added nodes from the Set which have no duplicate copy. But
18916 * this also causes newly added nodes will not be serialized with id ASAP,
18917 * which means all the id related calculation should be lazy too.
18918 */ __publicField(this, "addedSet", /* @__PURE__ */ new Set());
18919 __publicField(this, "movedSet", /* @__PURE__ */ new Set());
18920 __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
18921 __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
18922 __publicField(this, "mutationCb");
18923 __publicField(this, "blockClass");
18924 __publicField(this, "blockSelector");
18925 __publicField(this, "maskTextClass");
18926 __publicField(this, "maskTextSelector");
18927 __publicField(this, "inlineStylesheet");
18928 __publicField(this, "maskInputOptions");
18929 __publicField(this, "maskTextFn");
18930 __publicField(this, "maskInputFn");
18931 __publicField(this, "keepIframeSrcFn");
18932 __publicField(this, "recordCanvas");
18933 __publicField(this, "inlineImages");
18934 __publicField(this, "slimDOMOptions");
18935 __publicField(this, "dataURLOptions");
18936 __publicField(this, "doc");
18937 __publicField(this, "mirror");
18938 __publicField(this, "iframeManager");
18939 __publicField(this, "stylesheetManager");
18940 __publicField(this, "shadowDomManager");
18941 __publicField(this, "canvasManager");
18942 __publicField(this, "processedNodeManager");
18943 __publicField(this, "unattachedDoc");
18944 __publicField(this, "processMutations", function(mutations) {
18945 mutations.forEach(_this.processMutation);
18946 _this.emit();
18947 });
18948 __publicField(this, "emit", function() {
18949 if (_this.frozen || _this.locked) {
18950 return;
18951 }
18952 var adds = [];
18953 var addedIds = /* @__PURE__ */ new Set();
18954 var addList = new DoubleLinkedList();
18955 var getNextId = function(n2) {
18956 var ns = n2;
18957 var nextId = IGNORED_NODE;
18958 while(nextId === IGNORED_NODE){
18959 ns = ns && ns.nextSibling;
18960 nextId = ns && _this.mirror.getId(ns);
18961 }
18962 return nextId;
18963 };
18964 var pushAdd = function(n2) {
18965 var parent = index.parentNode(n2);
18966 if (!parent || !inDom(n2)) {
18967 return;
18968 }
18969 var cssCaptured = false;
18970 if (n2.nodeType === Node.TEXT_NODE) {
18971 var parentTag = parent.tagName;
18972 if (parentTag === "TEXTAREA") {
18973 return;
18974 } else if (parentTag === "STYLE" && _this.addedSet.has(parent)) {
18975 cssCaptured = true;
18976 }
18977 }
18978 var parentId = isShadowRoot(parent) ? _this.mirror.getId(getShadowHost(n2)) : _this.mirror.getId(parent);
18979 var nextId = getNextId(n2);
18980 if (parentId === -1 || nextId === -1) {
18981 return addList.addNode(n2);
18982 }
18983 var sn = serializeNodeWithId(n2, {
18984 doc: _this.doc,
18985 mirror: _this.mirror,
18986 blockClass: _this.blockClass,
18987 blockSelector: _this.blockSelector,
18988 maskTextClass: _this.maskTextClass,
18989 maskTextSelector: _this.maskTextSelector,
18990 skipChild: true,
18991 newlyAddedElement: true,
18992 inlineStylesheet: _this.inlineStylesheet,
18993 maskInputOptions: _this.maskInputOptions,
18994 maskTextFn: _this.maskTextFn,
18995 maskInputFn: _this.maskInputFn,
18996 slimDOMOptions: _this.slimDOMOptions,
18997 dataURLOptions: _this.dataURLOptions,
18998 recordCanvas: _this.recordCanvas,
18999 inlineImages: _this.inlineImages,
19000 onSerialize: function(currentN) {
19001 if (isSerializedIframe(currentN, _this.mirror)) {
19002 _this.iframeManager.addIframe(currentN);
19003 }
19004 if (isSerializedStylesheet(currentN, _this.mirror)) {
19005 _this.stylesheetManager.trackLinkElement(currentN);
19006 }
19007 if (hasShadowRoot(n2)) {
19008 _this.shadowDomManager.addShadowRoot(index.shadowRoot(n2), _this.doc);
19009 }
19010 },
19011 onIframeLoad: function(iframe, childSn) {
19012 _this.iframeManager.attachIframe(iframe, childSn);
19013 _this.shadowDomManager.observeAttachShadow(iframe);
19014 },
19015 onStylesheetLoad: function(link, childSn) {
19016 _this.stylesheetManager.attachLinkElement(link, childSn);
19017 },
19018 cssCaptured: cssCaptured
19019 });
19020 if (sn) {
19021 adds.push({
19022 parentId: parentId,
19023 nextId: nextId,
19024 node: sn
19025 });
19026 addedIds.add(sn.id);
19027 }
19028 };
19029 while(_this.mapRemoves.length){
19030 _this.mirror.removeNodeFromMap(_this.mapRemoves.shift());
19031 }
19032 for(var _iterator = _create_for_of_iterator_helper_loose(_this.movedSet), _step; !(_step = _iterator()).done;){
19033 var n2 = _step.value;
19034 if (isParentRemoved(_this.removesSubTreeCache, n2, _this.mirror) && !_this.movedSet.has(index.parentNode(n2))) {
19035 continue;
19036 }
19037 pushAdd(n2);
19038 }
19039 for(var _iterator1 = _create_for_of_iterator_helper_loose(_this.addedSet), _step1; !(_step1 = _iterator1()).done;){
19040 var n21 = _step1.value;
19041 if (!isAncestorInSet(_this.droppedSet, n21) && !isParentRemoved(_this.removesSubTreeCache, n21, _this.mirror)) {
19042 pushAdd(n21);
19043 } else if (isAncestorInSet(_this.movedSet, n21)) {
19044 pushAdd(n21);
19045 } else {
19046 _this.droppedSet.add(n21);
19047 }
19048 }
19049 var candidate = null;
19050 while(addList.length){
19051 var node2 = null;
19052 if (candidate) {
19053 var parentId = _this.mirror.getId(index.parentNode(candidate.value));
19054 var nextId = getNextId(candidate.value);
19055 if (parentId !== -1 && nextId !== -1) {
19056 node2 = candidate;
19057 }
19058 }
19059 if (!node2) {
19060 var tailNode = addList.tail;
19061 while(tailNode){
19062 var _node = tailNode;
19063 tailNode = tailNode.previous;
19064 if (_node) {
19065 var parentId1 = _this.mirror.getId(index.parentNode(_node.value));
19066 var nextId1 = getNextId(_node.value);
19067 if (nextId1 === -1) continue;
19068 else if (parentId1 !== -1) {
19069 node2 = _node;
19070 break;
19071 } else {
19072 var unhandledNode = _node.value;
19073 var parent = index.parentNode(unhandledNode);
19074 if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
19075 var shadowHost = index.host(parent);
19076 var parentId2 = _this.mirror.getId(shadowHost);
19077 if (parentId2 !== -1) {
19078 node2 = _node;
19079 break;
19080 }
19081 }
19082 }
19083 }
19084 }
19085 }
19086 if (!node2) {
19087 while(addList.head){
19088 addList.removeNode(addList.head.value);
19089 }
19090 break;
19091 }
19092 candidate = node2.previous;
19093 addList.removeNode(node2.value);
19094 pushAdd(node2.value);
19095 }
19096 var payload = {
19097 texts: _this.texts.map(function(text) {
19098 var n2 = text.node;
19099 var parent = index.parentNode(n2);
19100 if (parent && parent.tagName === "TEXTAREA") {
19101 _this.genTextAreaValueMutation(parent);
19102 }
19103 return {
19104 id: _this.mirror.getId(n2),
19105 value: text.value
19106 };
19107 }).filter(function(text) {
19108 return !addedIds.has(text.id);
19109 }).filter(function(text) {
19110 return _this.mirror.has(text.id);
19111 }),
19112 attributes: _this.attributes.map(function(attribute) {
19113 var attributes = attribute.attributes;
19114 if (typeof attributes.style === "string") {
19115 var diffAsStr = JSON.stringify(attribute.styleDiff);
19116 var unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
19117 if (diffAsStr.length < attributes.style.length) {
19118 if ((diffAsStr + unchangedAsStr).split("var(").length === attributes.style.split("var(").length) {
19119 attributes.style = attribute.styleDiff;
19120 }
19121 }
19122 }
19123 return {
19124 id: _this.mirror.getId(attribute.node),
19125 attributes: attributes
19126 };
19127 }).filter(function(attribute) {
19128 return !addedIds.has(attribute.id);
19129 }).filter(function(attribute) {
19130 return _this.mirror.has(attribute.id);
19131 }),
19132 removes: _this.removes,
19133 adds: adds
19134 };
19135 if (!payload.texts.length && !payload.attributes.length && !payload.removes.length && !payload.adds.length) {
19136 return;
19137 }
19138 _this.texts = [];
19139 _this.attributes = [];
19140 _this.attributeMap = /* @__PURE__ */ new WeakMap();
19141 _this.removes = [];
19142 _this.addedSet = /* @__PURE__ */ new Set();
19143 _this.movedSet = /* @__PURE__ */ new Set();
19144 _this.droppedSet = /* @__PURE__ */ new Set();
19145 _this.removesSubTreeCache = /* @__PURE__ */ new Set();
19146 _this.movedMap = {};
19147 _this.mutationCb(payload);
19148 });
19149 __publicField(this, "genTextAreaValueMutation", function(textarea) {
19150 var item = _this.attributeMap.get(textarea);
19151 if (!item) {
19152 item = {
19153 node: textarea,
19154 attributes: {},
19155 styleDiff: {},
19156 _unchangedStyles: {}
19157 };
19158 _this.attributes.push(item);
19159 _this.attributeMap.set(textarea, item);
19160 }
19161 var value = Array.from(index.childNodes(textarea), function(cn) {
19162 return index.textContent(cn) || "";
19163 }).join("");
19164 item.attributes.value = maskInputValue({
19165 element: textarea,
19166 maskInputOptions: _this.maskInputOptions,
19167 tagName: textarea.tagName,
19168 type: getInputType(textarea),
19169 value: value,
19170 maskInputFn: _this.maskInputFn
19171 });
19172 });
19173 __publicField(this, "processMutation", function(m) {
19174 if (isIgnored(m.target, _this.mirror, _this.slimDOMOptions)) {
19175 return;
19176 }
19177 switch(m.type){
19178 case "characterData":
19179 {
19180 var value = index.textContent(m.target);
19181 if (!isBlocked(m.target, _this.blockClass, _this.blockSelector, false) && value !== m.oldValue) {
19182 _this.texts.push({
19183 value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, true) && value ? _this.maskTextFn ? _this.maskTextFn(value, closestElementOfNode(m.target)) : value.replace(/[\S]/g, "*") : value,
19184 node: m.target
19185 });
19186 }
19187 break;
19188 }
19189 case "attributes":
19190 {
19191 var target = m.target;
19192 var attributeName = m.attributeName;
19193 var value1 = m.target.getAttribute(attributeName);
19194 if (attributeName === "value") {
19195 var type = getInputType(target);
19196 value1 = maskInputValue({
19197 element: target,
19198 maskInputOptions: _this.maskInputOptions,
19199 tagName: target.tagName,
19200 type: type,
19201 value: value1,
19202 maskInputFn: _this.maskInputFn
19203 });
19204 }
19205 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || value1 === m.oldValue) {
19206 return;
19207 }
19208 var item = _this.attributeMap.get(m.target);
19209 if (target.tagName === "IFRAME" && attributeName === "src" && !_this.keepIframeSrcFn(value1)) {
19210 if (!target.contentDocument) {
19211 attributeName = "rr_src";
19212 } else {
19213 return;
19214 }
19215 }
19216 if (!item) {
19217 item = {
19218 node: m.target,
19219 attributes: {},
19220 styleDiff: {},
19221 _unchangedStyles: {}
19222 };
19223 _this.attributes.push(item);
19224 _this.attributeMap.set(m.target, item);
19225 }
19226 if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
19227 target.setAttribute("data-rr-is-password", "true");
19228 }
19229 if (!ignoreAttribute(target.tagName, attributeName)) {
19230 item.attributes[attributeName] = transformAttribute(_this.doc, toLowerCase(target.tagName), toLowerCase(attributeName), value1);
19231 if (attributeName === "style") {
19232 if (!_this.unattachedDoc) {
19233 try {
19234 _this.unattachedDoc = document.implementation.createHTMLDocument();
19235 } catch (e2) {
19236 _this.unattachedDoc = _this.doc;
19237 }
19238 }
19239 var old = _this.unattachedDoc.createElement("span");
19240 if (m.oldValue) {
19241 old.setAttribute("style", m.oldValue);
19242 }
19243 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(target.style)), _step; !(_step = _iterator()).done;){
19244 var pname = _step.value;
19245 var newValue = target.style.getPropertyValue(pname);
19246 var newPriority = target.style.getPropertyPriority(pname);
19247 if (newValue !== old.style.getPropertyValue(pname) || newPriority !== old.style.getPropertyPriority(pname)) {
19248 if (newPriority === "") {
19249 item.styleDiff[pname] = newValue;
19250 } else {
19251 item.styleDiff[pname] = [
19252 newValue,
19253 newPriority
19254 ];
19255 }
19256 } else {
19257 item._unchangedStyles[pname] = [
19258 newValue,
19259 newPriority
19260 ];
19261 }
19262 }
19263 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(old.style)), _step1; !(_step1 = _iterator1()).done;){
19264 var pname1 = _step1.value;
19265 if (target.style.getPropertyValue(pname1) === "") {
19266 item.styleDiff[pname1] = false;
19267 }
19268 }
19269 } else if (attributeName === "open" && target.tagName === "DIALOG") {
19270 if (target.matches("dialog:modal")) {
19271 item.attributes["rr_open_mode"] = "modal";
19272 } else {
19273 item.attributes["rr_open_mode"] = "non-modal";
19274 }
19275 }
19276 }
19277 break;
19278 }
19279 case "childList":
19280 {
19281 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, true)) return;
19282 if (m.target.tagName === "TEXTAREA") {
19283 _this.genTextAreaValueMutation(m.target);
19284 return;
19285 }
19286 m.addedNodes.forEach(function(n2) {
19287 return _this.genAdds(n2, m.target);
19288 });
19289 m.removedNodes.forEach(function(n2) {
19290 var nodeId = _this.mirror.getId(n2);
19291 var parentId = isShadowRoot(m.target) ? _this.mirror.getId(index.host(m.target)) : _this.mirror.getId(m.target);
19292 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || isIgnored(n2, _this.mirror, _this.slimDOMOptions) || !isSerialized(n2, _this.mirror)) {
19293 return;
19294 }
19295 if (_this.addedSet.has(n2)) {
19296 deepDelete(_this.addedSet, n2);
19297 _this.droppedSet.add(n2);
19298 } else if (_this.addedSet.has(m.target) && nodeId === -1) ;
19299 else if (isAncestorRemoved(m.target, _this.mirror)) ;
19300 else if (_this.movedSet.has(n2) && _this.movedMap[moveKey(nodeId, parentId)]) {
19301 deepDelete(_this.movedSet, n2);
19302 } else {
19303 _this.removes.push({
19304 parentId: parentId,
19305 id: nodeId,
19306 isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
19307 });
19308 processRemoves(n2, _this.removesSubTreeCache);
19309 }
19310 _this.mapRemoves.push(n2);
19311 });
19312 break;
19313 }
19314 }
19315 });
19316 /**
19317 * Make sure you check if `n`'s parent is blocked before calling this function
19318 * */ __publicField(this, "genAdds", function(n2, target) {
19319 if (_this.processedNodeManager.inOtherBuffer(n2, _this)) return;
19320 if (_this.addedSet.has(n2) || _this.movedSet.has(n2)) return;
19321 if (_this.mirror.hasNode(n2)) {
19322 if (isIgnored(n2, _this.mirror, _this.slimDOMOptions)) {
19323 return;
19324 }
19325 _this.movedSet.add(n2);
19326 var targetId = null;
19327 if (target && _this.mirror.hasNode(target)) {
19328 targetId = _this.mirror.getId(target);
19329 }
19330 if (targetId && targetId !== -1) {
19331 _this.movedMap[moveKey(_this.mirror.getId(n2), targetId)] = true;
19332 }
19333 } else {
19334 _this.addedSet.add(n2);
19335 _this.droppedSet.delete(n2);
19336 }
19337 if (!isBlocked(n2, _this.blockClass, _this.blockSelector, false)) {
19338 index.childNodes(n2).forEach(function(childN) {
19339 return _this.genAdds(childN);
19340 });
19341 if (hasShadowRoot(n2)) {
19342 index.childNodes(index.shadowRoot(n2)).forEach(function(childN) {
19343 _this.processedNodeManager.add(childN, _this);
19344 _this.genAdds(childN, n2);
19345 });
19346 }
19347 }
19348 });
19349 }
19350 var _proto = MutationBuffer.prototype;
19351 _proto.init = function init(options) {
19352 var _this = this;
19353 [
19354 "mutationCb",
19355 "blockClass",
19356 "blockSelector",
19357 "maskTextClass",
19358 "maskTextSelector",
19359 "inlineStylesheet",
19360 "maskInputOptions",
19361 "maskTextFn",
19362 "maskInputFn",
19363 "keepIframeSrcFn",
19364 "recordCanvas",
19365 "inlineImages",
19366 "slimDOMOptions",
19367 "dataURLOptions",
19368 "doc",
19369 "mirror",
19370 "iframeManager",
19371 "stylesheetManager",
19372 "shadowDomManager",
19373 "canvasManager",
19374 "processedNodeManager"
19375 ].forEach(function(key) {
19376 _this[key] = options[key];
19377 });
19378 };
19379 _proto.freeze = function freeze() {
19380 this.frozen = true;
19381 this.canvasManager.freeze();
19382 };
19383 _proto.unfreeze = function unfreeze() {
19384 this.frozen = false;
19385 this.canvasManager.unfreeze();
19386 this.emit();
19387 };
19388 _proto.isFrozen = function isFrozen() {
19389 return this.frozen;
19390 };
19391 _proto.lock = function lock() {
19392 this.locked = true;
19393 this.canvasManager.lock();
19394 };
19395 _proto.unlock = function unlock() {
19396 this.locked = false;
19397 this.canvasManager.unlock();
19398 this.emit();
19399 };
19400 _proto.reset = function reset() {
19401 this.shadowDomManager.reset();
19402 this.canvasManager.reset();
19403 };
19404 return MutationBuffer;
19405 }();
19406 function deepDelete(addsSet, n2) {
19407 addsSet.delete(n2);
19408 index.childNodes(n2).forEach(function(childN) {
19409 return deepDelete(addsSet, childN);
19410 });
19411 }
19412 function processRemoves(n2, cache) {
19413 var queue = [
19414 n2
19415 ];
19416 while(queue.length){
19417 var next = queue.pop();
19418 if (cache.has(next)) continue;
19419 cache.add(next);
19420 index.childNodes(next).forEach(function(n22) {
19421 return queue.push(n22);
19422 });
19423 }
19424 return;
19425 }
19426 function isParentRemoved(removes, n2, mirror2) {
19427 if (removes.size === 0) return false;
19428 return _isParentRemoved(removes, n2);
19429 }
19430 function _isParentRemoved(removes, n2, _mirror2) {
19431 var node2 = index.parentNode(n2);
19432 if (!node2) return false;
19433 return removes.has(node2);
19434 }
19435 function isAncestorInSet(set, n2) {
19436 if (set.size === 0) return false;
19437 return _isAncestorInSet(set, n2);
19438 }
19439 function _isAncestorInSet(set, n2) {
19440 var parent = index.parentNode(n2);
19441 if (!parent) {
19442 return false;
19443 }
19444 if (set.has(parent)) {
19445 return true;
19446 }
19447 return _isAncestorInSet(set, parent);
19448 }
19449 var errorHandler;
19450 function registerErrorHandler(handler) {
19451 errorHandler = handler;
19452 }
19453 function unregisterErrorHandler() {
19454 errorHandler = void 0;
19455 }
19456 var callbackWrapper = function(cb) {
19457 if (!errorHandler) {
19458 return cb;
19459 }
19460 var rrwebWrapped = function() {
19461 for(var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++){
19462 rest[_key] = arguments[_key];
19463 }
19464 try {
19465 return cb.apply(void 0, [].concat(rest));
19466 } catch (error) {
19467 if (errorHandler && errorHandler(error) === true) {
19468 return;
19469 }
19470 throw error;
19471 }
19472 };
19473 return rrwebWrapped;
19474 };
19475 var mutationBuffers = [];
19476 function getEventTarget(event) {
19477 try {
19478 if ("composedPath" in event) {
19479 var path = event.composedPath();
19480 if (path.length) {
19481 return path[0];
19482 }
19483 } else if ("path" in event && event.path.length) {
19484 return event.path[0];
19485 }
19486 } catch (e) {}
19487 return event && event.target;
19488 }
19489 function initMutationObserver(options, rootEl) {
19490 var mutationBuffer = new MutationBuffer();
19491 mutationBuffers.push(mutationBuffer);
19492 mutationBuffer.init(options);
19493 var observer = new (mutationObserverCtor())(callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer)));
19494 observer.observe(rootEl, {
19495 attributes: true,
19496 attributeOldValue: true,
19497 characterData: true,
19498 characterDataOldValue: true,
19499 childList: true,
19500 subtree: true
19501 });
19502 return observer;
19503 }
19504 function initMoveObserver(param) {
19505 var mousemoveCb = param.mousemoveCb, sampling = param.sampling, doc = param.doc, mirror2 = param.mirror;
19506 if (sampling.mousemove === false) {
19507 return function() {};
19508 }
19509 var threshold = typeof sampling.mousemove === "number" ? sampling.mousemove : 50;
19510 var callbackThreshold = typeof sampling.mousemoveCallback === "number" ? sampling.mousemoveCallback : 500;
19511 var positions = [];
19512 var timeBaseline;
19513 var wrappedCb = throttle(callbackWrapper(function(source) {
19514 var totalOffset = Date.now() - timeBaseline;
19515 mousemoveCb(positions.map(function(p) {
19516 p.timeOffset -= totalOffset;
19517 return p;
19518 }), source);
19519 positions = [];
19520 timeBaseline = null;
19521 }), callbackThreshold);
19522 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
19523 var target = getEventTarget(evt);
19524 var _ref = legacy_isTouchEvent(evt) ? evt.changedTouches[0] : evt, clientX = _ref.clientX, clientY = _ref.clientY;
19525 if (!timeBaseline) {
19526 timeBaseline = nowTimestamp();
19527 }
19528 positions.push({
19529 x: clientX,
19530 y: clientY,
19531 id: mirror2.getId(target),
19532 timeOffset: nowTimestamp() - timeBaseline
19533 });
19534 wrappedCb(typeof DragEvent !== "undefined" && _instanceof(evt, DragEvent) ? IncrementalSource.Drag : _instanceof(evt, MouseEvent) ? IncrementalSource.MouseMove : IncrementalSource.TouchMove);
19535 }), threshold, {
19536 trailing: false
19537 }));
19538 var handlers = [
19539 on("mousemove", updatePosition, doc),
19540 on("touchmove", updatePosition, doc),
19541 on("drag", updatePosition, doc)
19542 ];
19543 return callbackWrapper(function() {
19544 handlers.forEach(function(h) {
19545 return h();
19546 });
19547 });
19548 }
19549 function initMouseInteractionObserver(param) {
19550 var mouseInteractionCb = param.mouseInteractionCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
19551 if (sampling.mouseInteraction === false) {
19552 return function() {};
19553 }
19554 var disableMap = sampling.mouseInteraction === true || sampling.mouseInteraction === void 0 ? {} : sampling.mouseInteraction;
19555 var handlers = [];
19556 var currentPointerType = null;
19557 var getHandler = function(eventKey) {
19558 return function(event) {
19559 var target = getEventTarget(event);
19560 if (isBlocked(target, blockClass, blockSelector, true)) {
19561 return;
19562 }
19563 var pointerType = null;
19564 var thisEventKey = eventKey;
19565 if ("pointerType" in event) {
19566 switch(event.pointerType){
19567 case "mouse":
19568 pointerType = PointerTypes.Mouse;
19569 break;
19570 case "touch":
19571 pointerType = PointerTypes.Touch;
19572 break;
19573 case "pen":
19574 pointerType = PointerTypes.Pen;
19575 break;
19576 }
19577 if (pointerType === PointerTypes.Touch) {
19578 if (MouseInteractions[eventKey] === MouseInteractions.MouseDown) {
19579 thisEventKey = "TouchStart";
19580 } else if (MouseInteractions[eventKey] === MouseInteractions.MouseUp) {
19581 thisEventKey = "TouchEnd";
19582 }
19583 } else if (pointerType === PointerTypes.Pen) ;
19584 } else if (legacy_isTouchEvent(event)) {
19585 pointerType = PointerTypes.Touch;
19586 }
19587 if (pointerType !== null) {
19588 currentPointerType = pointerType;
19589 if (thisEventKey.startsWith("Touch") && pointerType === PointerTypes.Touch || thisEventKey.startsWith("Mouse") && pointerType === PointerTypes.Mouse) {
19590 pointerType = null;
19591 }
19592 } else if (MouseInteractions[eventKey] === MouseInteractions.Click) {
19593 pointerType = currentPointerType;
19594 currentPointerType = null;
19595 }
19596 var e2 = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
19597 if (!e2) {
19598 return;
19599 }
19600 var id = mirror2.getId(target);
19601 var clientX = e2.clientX, clientY = e2.clientY;
19602 callbackWrapper(mouseInteractionCb)(_extends({
19603 type: MouseInteractions[thisEventKey],
19604 id: id,
19605 x: clientX,
19606 y: clientY
19607 }, pointerType !== null && {
19608 pointerType: pointerType
19609 }));
19610 };
19611 };
19612 Object.keys(MouseInteractions).filter(function(key) {
19613 return Number.isNaN(Number(key)) && !key.endsWith("_Departed") && disableMap[key] !== false;
19614 }).forEach(function(eventKey) {
19615 var eventName = toLowerCase(eventKey);
19616 var handler = getHandler(eventKey);
19617 if (window.PointerEvent) {
19618 switch(MouseInteractions[eventKey]){
19619 case MouseInteractions.MouseDown:
19620 case MouseInteractions.MouseUp:
19621 eventName = eventName.replace("mouse", "pointer");
19622 break;
19623 case MouseInteractions.TouchStart:
19624 case MouseInteractions.TouchEnd:
19625 return;
19626 }
19627 }
19628 handlers.push(on(eventName, handler, doc));
19629 });
19630 return callbackWrapper(function() {
19631 handlers.forEach(function(h) {
19632 return h();
19633 });
19634 });
19635 }
19636 function initScrollObserver(param) {
19637 var scrollCb = param.scrollCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
19638 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
19639 var target = getEventTarget(evt);
19640 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
19641 return;
19642 }
19643 var id = mirror2.getId(target);
19644 if (target === doc && doc.defaultView) {
19645 var scrollLeftTop = getWindowScroll(doc.defaultView);
19646 scrollCb({
19647 id: id,
19648 x: scrollLeftTop.left,
19649 y: scrollLeftTop.top
19650 });
19651 } else {
19652 scrollCb({
19653 id: id,
19654 x: target.scrollLeft,
19655 y: target.scrollTop
19656 });
19657 }
19658 }), sampling.scroll || 100));
19659 return on("scroll", updatePosition, doc);
19660 }
19661 function initViewportResizeObserver(param, param1) {
19662 var viewportResizeCb = param.viewportResizeCb;
19663 var win = param1.win;
19664 var lastH = -1;
19665 var lastW = -1;
19666 var updateDimension = callbackWrapper(throttle(callbackWrapper(function() {
19667 var height = getWindowHeight();
19668 var width = getWindowWidth();
19669 if (lastH !== height || lastW !== width) {
19670 viewportResizeCb({
19671 width: Number(width),
19672 height: Number(height)
19673 });
19674 lastH = height;
19675 lastW = width;
19676 }
19677 }), 200));
19678 return on("resize", updateDimension, win);
19679 }
19680 var INPUT_TAGS = [
19681 "INPUT",
19682 "TEXTAREA",
19683 "SELECT"
19684 ];
19685 var lastInputValueMap = /* @__PURE__ */ new WeakMap();
19686 function initInputObserver(param) {
19687 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;
19688 function eventHandler(event) {
19689 var target = getEventTarget(event);
19690 var userTriggered = event.isTrusted;
19691 var tagName = target && target.tagName;
19692 if (target && tagName === "OPTION") {
19693 target = index.parentElement(target);
19694 }
19695 if (!target || !tagName || INPUT_TAGS.indexOf(tagName) < 0 || isBlocked(target, blockClass, blockSelector, true)) {
19696 return;
19697 }
19698 if (target.classList.contains(ignoreClass) || ignoreSelector && target.matches(ignoreSelector)) {
19699 return;
19700 }
19701 var text = target.value;
19702 var isChecked = false;
19703 var type = getInputType(target) || "";
19704 if (type === "radio" || type === "checkbox") {
19705 isChecked = target.checked;
19706 } else if (maskInputOptions[tagName.toLowerCase()] || maskInputOptions[type]) {
19707 text = maskInputValue({
19708 element: target,
19709 maskInputOptions: maskInputOptions,
19710 tagName: tagName,
19711 type: type,
19712 value: text,
19713 maskInputFn: maskInputFn
19714 });
19715 }
19716 cbWithDedup(target, userTriggeredOnInput ? {
19717 text: text,
19718 isChecked: isChecked,
19719 userTriggered: userTriggered
19720 } : {
19721 text: text,
19722 isChecked: isChecked
19723 });
19724 var name = target.name;
19725 if (type === "radio" && name && isChecked) {
19726 doc.querySelectorAll('input[type="radio"][name="' + name + '"]').forEach(function(el) {
19727 if (el !== target) {
19728 var text2 = el.value;
19729 cbWithDedup(el, userTriggeredOnInput ? {
19730 text: text2,
19731 isChecked: !isChecked,
19732 userTriggered: false
19733 } : {
19734 text: text2,
19735 isChecked: !isChecked
19736 });
19737 }
19738 });
19739 }
19740 }
19741 function cbWithDedup(target, v2) {
19742 var lastInputValue = lastInputValueMap.get(target);
19743 if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
19744 lastInputValueMap.set(target, v2);
19745 var id = mirror2.getId(target);
19746 callbackWrapper(inputCb)(_extends({}, v2, {
19747 id: id
19748 }));
19749 }
19750 }
19751 var events = sampling.input === "last" ? [
19752 "change"
19753 ] : [
19754 "input",
19755 "change"
19756 ];
19757 var handlers = events.map(function(eventName) {
19758 return on(eventName, callbackWrapper(eventHandler), doc);
19759 });
19760 var currentWindow = doc.defaultView;
19761 if (!currentWindow) {
19762 return function() {
19763 handlers.forEach(function(h) {
19764 return h();
19765 });
19766 };
19767 }
19768 var propertyDescriptor = currentWindow.Object.getOwnPropertyDescriptor(currentWindow.HTMLInputElement.prototype, "value");
19769 var hookProperties = [
19770 [
19771 currentWindow.HTMLInputElement.prototype,
19772 "value"
19773 ],
19774 [
19775 currentWindow.HTMLInputElement.prototype,
19776 "checked"
19777 ],
19778 [
19779 currentWindow.HTMLSelectElement.prototype,
19780 "value"
19781 ],
19782 [
19783 currentWindow.HTMLTextAreaElement.prototype,
19784 "value"
19785 ],
19786 // Some UI library use selectedIndex to set select value
19787 [
19788 currentWindow.HTMLSelectElement.prototype,
19789 "selectedIndex"
19790 ],
19791 [
19792 currentWindow.HTMLOptionElement.prototype,
19793 "selected"
19794 ]
19795 ];
19796 if (propertyDescriptor && propertyDescriptor.set) {
19797 var _handlers;
19798 (_handlers = handlers).push.apply(_handlers, [].concat(hookProperties.map(function(p) {
19799 return hookSetter(p[0], p[1], {
19800 set: function set() {
19801 callbackWrapper(eventHandler)({
19802 target: this,
19803 isTrusted: false
19804 });
19805 }
19806 }, false, currentWindow);
19807 })));
19808 }
19809 return callbackWrapper(function() {
19810 handlers.forEach(function(h) {
19811 return h();
19812 });
19813 });
19814 }
19815 function getNestedCSSRulePositions(rule2) {
19816 var positions = [];
19817 function recurse(childRule, pos) {
19818 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)) {
19819 var rules2 = Array.from(childRule.parentRule.cssRules);
19820 var index2 = rules2.indexOf(childRule);
19821 pos.unshift(index2);
19822 } else if (childRule.parentStyleSheet) {
19823 var rules21 = Array.from(childRule.parentStyleSheet.cssRules);
19824 var index21 = rules21.indexOf(childRule);
19825 pos.unshift(index21);
19826 }
19827 return pos;
19828 }
19829 return recurse(rule2, positions);
19830 }
19831 function getIdAndStyleId(sheet, mirror2, styleMirror) {
19832 var id, styleId;
19833 if (!sheet) return {};
19834 if (sheet.ownerNode) id = mirror2.getId(sheet.ownerNode);
19835 else styleId = styleMirror.getId(sheet);
19836 return {
19837 styleId: styleId,
19838 id: id
19839 };
19840 }
19841 function initStyleSheetObserver(param, param1) {
19842 var styleSheetRuleCb = param.styleSheetRuleCb, mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
19843 var win = param1.win;
19844 if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
19845 return function() {};
19846 }
19847 var insertRule = win.CSSStyleSheet.prototype.insertRule;
19848 win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
19849 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19850 var rule2 = argumentsList[0], index2 = argumentsList[1];
19851 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19852 if (id && id !== -1 || styleId && styleId !== -1) {
19853 styleSheetRuleCb({
19854 id: id,
19855 styleId: styleId,
19856 adds: [
19857 {
19858 rule: rule2,
19859 index: index2
19860 }
19861 ]
19862 });
19863 }
19864 return target.apply(thisArg, argumentsList);
19865 })
19866 });
19867 win.CSSStyleSheet.prototype.addRule = function(selector, styleBlock, index2) {
19868 if (index2 === void 0) index2 = this.cssRules.length;
19869 var rule2 = selector + " { " + styleBlock + " }";
19870 return win.CSSStyleSheet.prototype.insertRule.apply(this, [
19871 rule2,
19872 index2
19873 ]);
19874 };
19875 var deleteRule = win.CSSStyleSheet.prototype.deleteRule;
19876 win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
19877 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19878 var index2 = argumentsList[0];
19879 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19880 if (id && id !== -1 || styleId && styleId !== -1) {
19881 styleSheetRuleCb({
19882 id: id,
19883 styleId: styleId,
19884 removes: [
19885 {
19886 index: index2
19887 }
19888 ]
19889 });
19890 }
19891 return target.apply(thisArg, argumentsList);
19892 })
19893 });
19894 win.CSSStyleSheet.prototype.removeRule = function(index2) {
19895 return win.CSSStyleSheet.prototype.deleteRule.apply(this, [
19896 index2
19897 ]);
19898 };
19899 var replace;
19900 if (win.CSSStyleSheet.prototype.replace) {
19901 replace = win.CSSStyleSheet.prototype.replace;
19902 win.CSSStyleSheet.prototype.replace = new Proxy(replace, {
19903 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19904 var text = argumentsList[0];
19905 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19906 if (id && id !== -1 || styleId && styleId !== -1) {
19907 styleSheetRuleCb({
19908 id: id,
19909 styleId: styleId,
19910 replace: text
19911 });
19912 }
19913 return target.apply(thisArg, argumentsList);
19914 })
19915 });
19916 }
19917 var replaceSync;
19918 if (win.CSSStyleSheet.prototype.replaceSync) {
19919 replaceSync = win.CSSStyleSheet.prototype.replaceSync;
19920 win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {
19921 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19922 var text = argumentsList[0];
19923 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19924 if (id && id !== -1 || styleId && styleId !== -1) {
19925 styleSheetRuleCb({
19926 id: id,
19927 styleId: styleId,
19928 replaceSync: text
19929 });
19930 }
19931 return target.apply(thisArg, argumentsList);
19932 })
19933 });
19934 }
19935 var supportedNestedCSSRuleTypes = {};
19936 if (canMonkeyPatchNestedCSSRule("CSSGroupingRule")) {
19937 supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
19938 } else {
19939 if (canMonkeyPatchNestedCSSRule("CSSMediaRule")) {
19940 supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
19941 }
19942 if (canMonkeyPatchNestedCSSRule("CSSConditionRule")) {
19943 supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
19944 }
19945 if (canMonkeyPatchNestedCSSRule("CSSSupportsRule")) {
19946 supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
19947 }
19948 }
19949 var unmodifiedFunctions = {};
19950 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
19951 var typeKey = param[0], type = param[1];
19952 unmodifiedFunctions[typeKey] = {
19953 // eslint-disable-next-line @typescript-eslint/unbound-method
19954 insertRule: type.prototype.insertRule,
19955 // eslint-disable-next-line @typescript-eslint/unbound-method
19956 deleteRule: type.prototype.deleteRule
19957 };
19958 type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
19959 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19960 var rule2 = argumentsList[0], index2 = argumentsList[1];
19961 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19962 if (id && id !== -1 || styleId && styleId !== -1) {
19963 styleSheetRuleCb({
19964 id: id,
19965 styleId: styleId,
19966 adds: [
19967 {
19968 rule: rule2,
19969 index: [].concat(getNestedCSSRulePositions(thisArg), [
19970 index2 || 0
19971 ])
19972 }
19973 ]
19974 });
19975 }
19976 return target.apply(thisArg, argumentsList);
19977 })
19978 });
19979 type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
19980 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19981 var index2 = argumentsList[0];
19982 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19983 if (id && id !== -1 || styleId && styleId !== -1) {
19984 styleSheetRuleCb({
19985 id: id,
19986 styleId: styleId,
19987 removes: [
19988 {
19989 index: [].concat(getNestedCSSRulePositions(thisArg), [
19990 index2
19991 ])
19992 }
19993 ]
19994 });
19995 }
19996 return target.apply(thisArg, argumentsList);
19997 })
19998 });
19999 });
20000 return callbackWrapper(function() {
20001 win.CSSStyleSheet.prototype.insertRule = insertRule;
20002 win.CSSStyleSheet.prototype.deleteRule = deleteRule;
20003 replace && (win.CSSStyleSheet.prototype.replace = replace);
20004 replaceSync && (win.CSSStyleSheet.prototype.replaceSync = replaceSync);
20005 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
20006 var typeKey = param[0], type = param[1];
20007 type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
20008 type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
20009 });
20010 });
20011 }
20012 function initAdoptedStyleSheetObserver(param, host2) {
20013 var mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
20014 var _a2, _b, _c;
20015 var hostId = null;
20016 if (host2.nodeName === "#document") hostId = mirror2.getId(host2);
20017 else hostId = mirror2.getId(index.host(host2));
20018 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;
20019 var originalPropertyDescriptor = (patchTarget == null ? void 0 : patchTarget.prototype) ? Object.getOwnPropertyDescriptor(patchTarget == null ? void 0 : patchTarget.prototype, "adoptedStyleSheets") : void 0;
20020 if (hostId === null || hostId === -1 || !patchTarget || !originalPropertyDescriptor) return function() {};
20021 Object.defineProperty(host2, "adoptedStyleSheets", {
20022 configurable: originalPropertyDescriptor.configurable,
20023 enumerable: originalPropertyDescriptor.enumerable,
20024 get: function get() {
20025 var _a3;
20026 return (_a3 = originalPropertyDescriptor.get) == null ? void 0 : _a3.call(this);
20027 },
20028 set: function set(sheets) {
20029 var _a3;
20030 var result2 = (_a3 = originalPropertyDescriptor.set) == null ? void 0 : _a3.call(this, sheets);
20031 if (hostId !== null && hostId !== -1) {
20032 try {
20033 stylesheetManager.adoptStyleSheets(sheets, hostId);
20034 } catch (e2) {}
20035 }
20036 return result2;
20037 }
20038 });
20039 return callbackWrapper(function() {
20040 Object.defineProperty(host2, "adoptedStyleSheets", {
20041 configurable: originalPropertyDescriptor.configurable,
20042 enumerable: originalPropertyDescriptor.enumerable,
20043 // eslint-disable-next-line @typescript-eslint/unbound-method
20044 get: originalPropertyDescriptor.get,
20045 // eslint-disable-next-line @typescript-eslint/unbound-method
20046 set: originalPropertyDescriptor.set
20047 });
20048 });
20049 }
20050 function initStyleDeclarationObserver(param, param1) {
20051 var styleDeclarationCb = param.styleDeclarationCb, mirror2 = param.mirror, ignoreCSSAttributes = param.ignoreCSSAttributes, stylesheetManager = param.stylesheetManager;
20052 var win = param1.win;
20053 var setProperty = win.CSSStyleDeclaration.prototype.setProperty;
20054 win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
20055 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20056 var _a2;
20057 var property = argumentsList[0], value = argumentsList[1], priority = argumentsList[2];
20058 if (ignoreCSSAttributes.has(property)) {
20059 return setProperty.apply(thisArg, [
20060 property,
20061 value,
20062 priority
20063 ]);
20064 }
20065 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20066 if (id && id !== -1 || styleId && styleId !== -1) {
20067 styleDeclarationCb({
20068 id: id,
20069 styleId: styleId,
20070 set: {
20071 property: property,
20072 value: value,
20073 priority: priority
20074 },
20075 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20076 index: getNestedCSSRulePositions(thisArg.parentRule)
20077 });
20078 }
20079 return target.apply(thisArg, argumentsList);
20080 })
20081 });
20082 var removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
20083 win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
20084 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20085 var _a2;
20086 var property = argumentsList[0];
20087 if (ignoreCSSAttributes.has(property)) {
20088 return removeProperty.apply(thisArg, [
20089 property
20090 ]);
20091 }
20092 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20093 if (id && id !== -1 || styleId && styleId !== -1) {
20094 styleDeclarationCb({
20095 id: id,
20096 styleId: styleId,
20097 remove: {
20098 property: property
20099 },
20100 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20101 index: getNestedCSSRulePositions(thisArg.parentRule)
20102 });
20103 }
20104 return target.apply(thisArg, argumentsList);
20105 })
20106 });
20107 return callbackWrapper(function() {
20108 win.CSSStyleDeclaration.prototype.setProperty = setProperty;
20109 win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
20110 });
20111 }
20112 function initMediaInteractionObserver(param) {
20113 var mediaInteractionCb = param.mediaInteractionCb, blockClass = param.blockClass, blockSelector = param.blockSelector, mirror2 = param.mirror, sampling = param.sampling, doc = param.doc;
20114 var handler = callbackWrapper(function(type) {
20115 return throttle(callbackWrapper(function(event) {
20116 var target = getEventTarget(event);
20117 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20118 return;
20119 }
20120 var currentTime = target.currentTime, volume = target.volume, muted = target.muted, playbackRate = target.playbackRate, loop = target.loop;
20121 mediaInteractionCb({
20122 type: type,
20123 id: mirror2.getId(target),
20124 currentTime: currentTime,
20125 volume: volume,
20126 muted: muted,
20127 playbackRate: playbackRate,
20128 loop: loop
20129 });
20130 }), sampling.media || 500);
20131 });
20132 var handlers = [
20133 on("play", handler(MediaInteractions.Play), doc),
20134 on("pause", handler(MediaInteractions.Pause), doc),
20135 on("seeked", handler(MediaInteractions.Seeked), doc),
20136 on("volumechange", handler(MediaInteractions.VolumeChange), doc),
20137 on("ratechange", handler(MediaInteractions.RateChange), doc)
20138 ];
20139 return callbackWrapper(function() {
20140 handlers.forEach(function(h) {
20141 return h();
20142 });
20143 });
20144 }
20145 function initFontObserver(param) {
20146 var fontCb = param.fontCb, doc = param.doc;
20147 var win = doc.defaultView;
20148 if (!win) {
20149 return function() {};
20150 }
20151 var handlers = [];
20152 var fontMap = /* @__PURE__ */ new WeakMap();
20153 var originalFontFace = win.FontFace;
20154 win.FontFace = function FontFace2(family, source, descriptors) {
20155 var fontFace = new originalFontFace(family, source, descriptors);
20156 fontMap.set(fontFace, {
20157 family: family,
20158 buffer: typeof source !== "string",
20159 descriptors: descriptors,
20160 fontSource: typeof source === "string" ? source : JSON.stringify(Array.from(new Uint8Array(source)))
20161 });
20162 return fontFace;
20163 };
20164 var restoreHandler = patch(doc.fonts, "add", function(original) {
20165 return function(fontFace) {
20166 setTimeout(callbackWrapper(function() {
20167 var p = fontMap.get(fontFace);
20168 if (p) {
20169 fontCb(p);
20170 fontMap.delete(fontFace);
20171 }
20172 }), 0);
20173 return original.apply(this, [
20174 fontFace
20175 ]);
20176 };
20177 });
20178 handlers.push(function() {
20179 win.FontFace = originalFontFace;
20180 });
20181 handlers.push(restoreHandler);
20182 return callbackWrapper(function() {
20183 handlers.forEach(function(h) {
20184 return h();
20185 });
20186 });
20187 }
20188 function initSelectionObserver(param) {
20189 var doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, selectionCb = param.selectionCb;
20190 var collapsed = true;
20191 var updateSelection = callbackWrapper(function() {
20192 var selection = doc.getSelection();
20193 if (!selection || collapsed && (selection == null ? void 0 : selection.isCollapsed)) return;
20194 collapsed = selection.isCollapsed || false;
20195 var ranges = [];
20196 var count = selection.rangeCount || 0;
20197 for(var i2 = 0; i2 < count; i2++){
20198 var range = selection.getRangeAt(i2);
20199 var startContainer = range.startContainer, startOffset = range.startOffset, endContainer = range.endContainer, endOffset = range.endOffset;
20200 var blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
20201 if (blocked) continue;
20202 ranges.push({
20203 start: mirror2.getId(startContainer),
20204 startOffset: startOffset,
20205 end: mirror2.getId(endContainer),
20206 endOffset: endOffset
20207 });
20208 }
20209 selectionCb({
20210 ranges: ranges
20211 });
20212 });
20213 updateSelection();
20214 return on("selectionchange", updateSelection);
20215 }
20216 function initCustomElementObserver(param) {
20217 var doc = param.doc, customElementCb = param.customElementCb;
20218 var win = doc.defaultView;
20219 if (!win || !win.customElements) return function() {};
20220 var restoreHandler = patch(win.customElements, "define", function(original) {
20221 return function(name, constructor, options) {
20222 try {
20223 customElementCb({
20224 define: {
20225 name: name
20226 }
20227 });
20228 } catch (e2) {
20229 console.warn("Custom element callback failed for " + name);
20230 }
20231 return original.apply(this, [
20232 name,
20233 constructor,
20234 options
20235 ]);
20236 };
20237 });
20238 return restoreHandler;
20239 }
20240 function mergeHooks(o2, hooks) {
20241 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;
20242 o2.mutationCb = function() {
20243 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20244 p[_key] = arguments[_key];
20245 }
20246 if (hooks.mutation) {
20247 var _hooks;
20248 (_hooks = hooks).mutation.apply(_hooks, [].concat(p));
20249 }
20250 mutationCb.apply(void 0, [].concat(p));
20251 };
20252 o2.mousemoveCb = function() {
20253 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20254 p[_key] = arguments[_key];
20255 }
20256 if (hooks.mousemove) {
20257 var _hooks;
20258 (_hooks = hooks).mousemove.apply(_hooks, [].concat(p));
20259 }
20260 mousemoveCb.apply(void 0, [].concat(p));
20261 };
20262 o2.mouseInteractionCb = function() {
20263 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20264 p[_key] = arguments[_key];
20265 }
20266 if (hooks.mouseInteraction) {
20267 var _hooks;
20268 (_hooks = hooks).mouseInteraction.apply(_hooks, [].concat(p));
20269 }
20270 mouseInteractionCb.apply(void 0, [].concat(p));
20271 };
20272 o2.scrollCb = function() {
20273 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20274 p[_key] = arguments[_key];
20275 }
20276 if (hooks.scroll) {
20277 var _hooks;
20278 (_hooks = hooks).scroll.apply(_hooks, [].concat(p));
20279 }
20280 scrollCb.apply(void 0, [].concat(p));
20281 };
20282 o2.viewportResizeCb = function() {
20283 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20284 p[_key] = arguments[_key];
20285 }
20286 if (hooks.viewportResize) {
20287 var _hooks;
20288 (_hooks = hooks).viewportResize.apply(_hooks, [].concat(p));
20289 }
20290 viewportResizeCb.apply(void 0, [].concat(p));
20291 };
20292 o2.inputCb = function() {
20293 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20294 p[_key] = arguments[_key];
20295 }
20296 if (hooks.input) {
20297 var _hooks;
20298 (_hooks = hooks).input.apply(_hooks, [].concat(p));
20299 }
20300 inputCb.apply(void 0, [].concat(p));
20301 };
20302 o2.mediaInteractionCb = function() {
20303 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20304 p[_key] = arguments[_key];
20305 }
20306 if (hooks.mediaInteaction) {
20307 var _hooks;
20308 (_hooks = hooks).mediaInteaction.apply(_hooks, [].concat(p));
20309 }
20310 mediaInteractionCb.apply(void 0, [].concat(p));
20311 };
20312 o2.styleSheetRuleCb = function() {
20313 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20314 p[_key] = arguments[_key];
20315 }
20316 if (hooks.styleSheetRule) {
20317 var _hooks;
20318 (_hooks = hooks).styleSheetRule.apply(_hooks, [].concat(p));
20319 }
20320 styleSheetRuleCb.apply(void 0, [].concat(p));
20321 };
20322 o2.styleDeclarationCb = function() {
20323 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20324 p[_key] = arguments[_key];
20325 }
20326 if (hooks.styleDeclaration) {
20327 var _hooks;
20328 (_hooks = hooks).styleDeclaration.apply(_hooks, [].concat(p));
20329 }
20330 styleDeclarationCb.apply(void 0, [].concat(p));
20331 };
20332 o2.canvasMutationCb = function() {
20333 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20334 p[_key] = arguments[_key];
20335 }
20336 if (hooks.canvasMutation) {
20337 var _hooks;
20338 (_hooks = hooks).canvasMutation.apply(_hooks, [].concat(p));
20339 }
20340 canvasMutationCb.apply(void 0, [].concat(p));
20341 };
20342 o2.fontCb = function() {
20343 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20344 p[_key] = arguments[_key];
20345 }
20346 if (hooks.font) {
20347 var _hooks;
20348 (_hooks = hooks).font.apply(_hooks, [].concat(p));
20349 }
20350 fontCb.apply(void 0, [].concat(p));
20351 };
20352 o2.selectionCb = function() {
20353 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20354 p[_key] = arguments[_key];
20355 }
20356 if (hooks.selection) {
20357 var _hooks;
20358 (_hooks = hooks).selection.apply(_hooks, [].concat(p));
20359 }
20360 selectionCb.apply(void 0, [].concat(p));
20361 };
20362 o2.customElementCb = function() {
20363 for(var _len = arguments.length, c2 = new Array(_len), _key = 0; _key < _len; _key++){
20364 c2[_key] = arguments[_key];
20365 }
20366 if (hooks.customElement) {
20367 var _hooks;
20368 (_hooks = hooks).customElement.apply(_hooks, [].concat(c2));
20369 }
20370 customElementCb.apply(void 0, [].concat(c2));
20371 };
20372 }
20373 function initObservers(o2, hooks) {
20374 if (hooks === void 0) hooks = {};
20375 var currentWindow = o2.doc.defaultView;
20376 if (!currentWindow) {
20377 return function() {};
20378 }
20379 mergeHooks(o2, hooks);
20380 var mutationObserver;
20381 if (o2.recordDOM) {
20382 mutationObserver = initMutationObserver(o2, o2.doc);
20383 }
20384 var mousemoveHandler = initMoveObserver(o2);
20385 var mouseInteractionHandler = initMouseInteractionObserver(o2);
20386 var scrollHandler = initScrollObserver(o2);
20387 var viewportResizeHandler = initViewportResizeObserver(o2, {
20388 win: currentWindow
20389 });
20390 var inputHandler = initInputObserver(o2);
20391 var mediaInteractionHandler = initMediaInteractionObserver(o2);
20392 var styleSheetObserver = function() {};
20393 var adoptedStyleSheetObserver = function() {};
20394 var styleDeclarationObserver = function() {};
20395 var fontObserver = function() {};
20396 if (o2.recordDOM) {
20397 styleSheetObserver = initStyleSheetObserver(o2, {
20398 win: currentWindow
20399 });
20400 adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o2, o2.doc);
20401 styleDeclarationObserver = initStyleDeclarationObserver(o2, {
20402 win: currentWindow
20403 });
20404 if (o2.collectFonts) {
20405 fontObserver = initFontObserver(o2);
20406 }
20407 }
20408 var selectionObserver = initSelectionObserver(o2);
20409 var customElementObserver = initCustomElementObserver(o2);
20410 var pluginHandlers = [];
20411 for(var _iterator = _create_for_of_iterator_helper_loose(o2.plugins), _step; !(_step = _iterator()).done;){
20412 var plugin3 = _step.value;
20413 pluginHandlers.push(plugin3.observer(plugin3.callback, currentWindow, plugin3.options));
20414 }
20415 return callbackWrapper(function() {
20416 mutationBuffers.forEach(function(b) {
20417 return b.reset();
20418 });
20419 mutationObserver == null ? void 0 : mutationObserver.disconnect();
20420 mousemoveHandler();
20421 mouseInteractionHandler();
20422 scrollHandler();
20423 viewportResizeHandler();
20424 inputHandler();
20425 mediaInteractionHandler();
20426 styleSheetObserver();
20427 adoptedStyleSheetObserver();
20428 styleDeclarationObserver();
20429 fontObserver();
20430 selectionObserver();
20431 customElementObserver();
20432 pluginHandlers.forEach(function(h) {
20433 return h();
20434 });
20435 });
20436 }
20437 function hasNestedCSSRule(prop) {
20438 return typeof window[prop] !== "undefined";
20439 }
20440 function canMonkeyPatchNestedCSSRule(prop) {
20441 return Boolean(typeof window[prop] !== "undefined" && // Note: Generally, this check _shouldn't_ be necessary
20442 // However, in some scenarios (e.g. jsdom) this can sometimes fail, so we check for it here
20443 window[prop].prototype && "insertRule" in window[prop].prototype && "deleteRule" in window[prop].prototype);
20444 }
20445 var CrossOriginIframeMirror = /*#__PURE__*/ function() {
20446 function CrossOriginIframeMirror(generateIdFn) {
20447 __publicField(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
20448 __publicField(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
20449 this.generateIdFn = generateIdFn;
20450 }
20451 var _proto = CrossOriginIframeMirror.prototype;
20452 _proto.getId = function getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) {
20453 var idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe);
20454 var remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe);
20455 var id = idToRemoteIdMap.get(remoteId);
20456 if (!id) {
20457 id = this.generateIdFn();
20458 idToRemoteIdMap.set(remoteId, id);
20459 remoteIdToIdMap.set(id, remoteId);
20460 }
20461 return id;
20462 };
20463 _proto.getIds = function getIds(iframe, remoteId) {
20464 var _this = this;
20465 var idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);
20466 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20467 return remoteId.map(function(id) {
20468 return _this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap);
20469 });
20470 };
20471 _proto.getRemoteId = function getRemoteId(iframe, id, map) {
20472 var remoteIdToIdMap = map || this.getRemoteIdToIdMap(iframe);
20473 if (typeof id !== "number") return id;
20474 var remoteId = remoteIdToIdMap.get(id);
20475 if (!remoteId) return -1;
20476 return remoteId;
20477 };
20478 _proto.getRemoteIds = function getRemoteIds(iframe, ids) {
20479 var _this = this;
20480 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20481 return ids.map(function(id) {
20482 return _this.getRemoteId(iframe, id, remoteIdToIdMap);
20483 });
20484 };
20485 _proto.reset = function reset(iframe) {
20486 if (!iframe) {
20487 this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap();
20488 this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
20489 return;
20490 }
20491 this.iframeIdToRemoteIdMap.delete(iframe);
20492 this.iframeRemoteIdToIdMap.delete(iframe);
20493 };
20494 _proto.getIdToRemoteIdMap = function getIdToRemoteIdMap(iframe) {
20495 var idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe);
20496 if (!idToRemoteIdMap) {
20497 idToRemoteIdMap = /* @__PURE__ */ new Map();
20498 this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap);
20499 }
20500 return idToRemoteIdMap;
20501 };
20502 _proto.getRemoteIdToIdMap = function getRemoteIdToIdMap(iframe) {
20503 var remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe);
20504 if (!remoteIdToIdMap) {
20505 remoteIdToIdMap = /* @__PURE__ */ new Map();
20506 this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap);
20507 }
20508 return remoteIdToIdMap;
20509 };
20510 return CrossOriginIframeMirror;
20511 }();
20512 var IframeManager = /*#__PURE__*/ function() {
20513 function IframeManager(options) {
20514 __publicField(this, "iframes", /* @__PURE__ */ new WeakMap());
20515 __publicField(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
20516 __publicField(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
20517 __publicField(this, "crossOriginIframeStyleMirror");
20518 __publicField(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
20519 __publicField(this, "mirror");
20520 __publicField(this, "mutationCb");
20521 __publicField(this, "wrappedEmit");
20522 __publicField(this, "loadListener");
20523 __publicField(this, "stylesheetManager");
20524 __publicField(this, "recordCrossOriginIframes");
20525 this.mutationCb = options.mutationCb;
20526 this.wrappedEmit = options.wrappedEmit;
20527 this.stylesheetManager = options.stylesheetManager;
20528 this.recordCrossOriginIframes = options.recordCrossOriginIframes;
20529 this.crossOriginIframeStyleMirror = new CrossOriginIframeMirror(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror));
20530 this.mirror = options.mirror;
20531 if (this.recordCrossOriginIframes) {
20532 window.addEventListener("message", this.handleMessage.bind(this));
20533 }
20534 }
20535 var _proto = IframeManager.prototype;
20536 _proto.addIframe = function addIframe(iframeEl) {
20537 this.iframes.set(iframeEl, true);
20538 if (iframeEl.contentWindow) this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
20539 };
20540 _proto.addLoadListener = function addLoadListener(cb) {
20541 this.loadListener = cb;
20542 };
20543 _proto.attachIframe = function attachIframe(iframeEl, childSn) {
20544 var _a2, _b;
20545 this.mutationCb({
20546 adds: [
20547 {
20548 parentId: this.mirror.getId(iframeEl),
20549 nextId: null,
20550 node: childSn
20551 }
20552 ],
20553 removes: [],
20554 texts: [],
20555 attributes: [],
20556 isAttachIframe: true
20557 });
20558 if (this.recordCrossOriginIframes) (_a2 = iframeEl.contentWindow) == null ? void 0 : _a2.addEventListener("message", this.handleMessage.bind(this));
20559 (_b = this.loadListener) == null ? void 0 : _b.call(this, iframeEl);
20560 if (iframeEl.contentDocument && iframeEl.contentDocument.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0) this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
20561 };
20562 _proto.handleMessage = function handleMessage(message) {
20563 var crossOriginMessageEvent = message;
20564 if (crossOriginMessageEvent.data.type !== "rrweb" || // To filter out the rrweb messages which are forwarded by some sites.
20565 crossOriginMessageEvent.origin !== crossOriginMessageEvent.data.origin) return;
20566 var iframeSourceWindow = message.source;
20567 if (!iframeSourceWindow) return;
20568 var iframeEl = this.crossOriginIframeMap.get(message.source);
20569 if (!iframeEl) return;
20570 var transformedEvent = this.transformCrossOriginEvent(iframeEl, crossOriginMessageEvent.data.event);
20571 if (transformedEvent) this.wrappedEmit(transformedEvent, crossOriginMessageEvent.data.isCheckout);
20572 };
20573 _proto.transformCrossOriginEvent = function transformCrossOriginEvent(iframeEl, e2) {
20574 var _this = this;
20575 var _a2;
20576 switch(e2.type){
20577 case EventType.FullSnapshot:
20578 {
20579 this.crossOriginIframeMirror.reset(iframeEl);
20580 this.crossOriginIframeStyleMirror.reset(iframeEl);
20581 this.replaceIdOnNode(e2.data.node, iframeEl);
20582 var rootId = e2.data.node.id;
20583 this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
20584 this.patchRootIdOnNode(e2.data.node, rootId);
20585 return {
20586 timestamp: e2.timestamp,
20587 type: EventType.IncrementalSnapshot,
20588 data: {
20589 source: IncrementalSource.Mutation,
20590 adds: [
20591 {
20592 parentId: this.mirror.getId(iframeEl),
20593 nextId: null,
20594 node: e2.data.node
20595 }
20596 ],
20597 removes: [],
20598 texts: [],
20599 attributes: [],
20600 isAttachIframe: true
20601 }
20602 };
20603 }
20604 case EventType.Meta:
20605 case EventType.Load:
20606 case EventType.DomContentLoaded:
20607 {
20608 return false;
20609 }
20610 case EventType.Plugin:
20611 {
20612 return e2;
20613 }
20614 case EventType.Custom:
20615 {
20616 this.replaceIds(e2.data.payload, iframeEl, [
20617 "id",
20618 "parentId",
20619 "previousId",
20620 "nextId"
20621 ]);
20622 return e2;
20623 }
20624 case EventType.IncrementalSnapshot:
20625 {
20626 switch(e2.data.source){
20627 case IncrementalSource.Mutation:
20628 {
20629 e2.data.adds.forEach(function(n2) {
20630 _this.replaceIds(n2, iframeEl, [
20631 "parentId",
20632 "nextId",
20633 "previousId"
20634 ]);
20635 _this.replaceIdOnNode(n2.node, iframeEl);
20636 var rootId = _this.crossOriginIframeRootIdMap.get(iframeEl);
20637 rootId && _this.patchRootIdOnNode(n2.node, rootId);
20638 });
20639 e2.data.removes.forEach(function(n2) {
20640 _this.replaceIds(n2, iframeEl, [
20641 "parentId",
20642 "id"
20643 ]);
20644 });
20645 e2.data.attributes.forEach(function(n2) {
20646 _this.replaceIds(n2, iframeEl, [
20647 "id"
20648 ]);
20649 });
20650 e2.data.texts.forEach(function(n2) {
20651 _this.replaceIds(n2, iframeEl, [
20652 "id"
20653 ]);
20654 });
20655 return e2;
20656 }
20657 case IncrementalSource.Drag:
20658 case IncrementalSource.TouchMove:
20659 case IncrementalSource.MouseMove:
20660 {
20661 e2.data.positions.forEach(function(p) {
20662 _this.replaceIds(p, iframeEl, [
20663 "id"
20664 ]);
20665 });
20666 return e2;
20667 }
20668 case IncrementalSource.ViewportResize:
20669 {
20670 return false;
20671 }
20672 case IncrementalSource.MediaInteraction:
20673 case IncrementalSource.MouseInteraction:
20674 case IncrementalSource.Scroll:
20675 case IncrementalSource.CanvasMutation:
20676 case IncrementalSource.Input:
20677 {
20678 this.replaceIds(e2.data, iframeEl, [
20679 "id"
20680 ]);
20681 return e2;
20682 }
20683 case IncrementalSource.StyleSheetRule:
20684 case IncrementalSource.StyleDeclaration:
20685 {
20686 this.replaceIds(e2.data, iframeEl, [
20687 "id"
20688 ]);
20689 this.replaceStyleIds(e2.data, iframeEl, [
20690 "styleId"
20691 ]);
20692 return e2;
20693 }
20694 case IncrementalSource.Font:
20695 {
20696 return e2;
20697 }
20698 case IncrementalSource.Selection:
20699 {
20700 e2.data.ranges.forEach(function(range) {
20701 _this.replaceIds(range, iframeEl, [
20702 "start",
20703 "end"
20704 ]);
20705 });
20706 return e2;
20707 }
20708 case IncrementalSource.AdoptedStyleSheet:
20709 {
20710 this.replaceIds(e2.data, iframeEl, [
20711 "id"
20712 ]);
20713 this.replaceStyleIds(e2.data, iframeEl, [
20714 "styleIds"
20715 ]);
20716 (_a2 = e2.data.styles) == null ? void 0 : _a2.forEach(function(style) {
20717 _this.replaceStyleIds(style, iframeEl, [
20718 "styleId"
20719 ]);
20720 });
20721 return e2;
20722 }
20723 }
20724 }
20725 }
20726 return false;
20727 };
20728 _proto.replace = function replace(iframeMirror, obj, iframeEl, keys) {
20729 for(var _iterator = _create_for_of_iterator_helper_loose(keys), _step; !(_step = _iterator()).done;){
20730 var key = _step.value;
20731 if (!Array.isArray(obj[key]) && typeof obj[key] !== "number") continue;
20732 if (Array.isArray(obj[key])) {
20733 obj[key] = iframeMirror.getIds(iframeEl, obj[key]);
20734 } else {
20735 obj[key] = iframeMirror.getId(iframeEl, obj[key]);
20736 }
20737 }
20738 return obj;
20739 };
20740 _proto.replaceIds = function replaceIds(obj, iframeEl, keys) {
20741 return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);
20742 };
20743 _proto.replaceStyleIds = function replaceStyleIds(obj, iframeEl, keys) {
20744 return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
20745 };
20746 _proto.replaceIdOnNode = function replaceIdOnNode(node2, iframeEl) {
20747 var _this = this;
20748 this.replaceIds(node2, iframeEl, [
20749 "id",
20750 "rootId"
20751 ]);
20752 if ("childNodes" in node2) {
20753 node2.childNodes.forEach(function(child) {
20754 _this.replaceIdOnNode(child, iframeEl);
20755 });
20756 }
20757 };
20758 _proto.patchRootIdOnNode = function patchRootIdOnNode(node2, rootId) {
20759 var _this = this;
20760 if (node2.type !== NodeType.Document && !node2.rootId) node2.rootId = rootId;
20761 if ("childNodes" in node2) {
20762 node2.childNodes.forEach(function(child) {
20763 _this.patchRootIdOnNode(child, rootId);
20764 });
20765 }
20766 };
20767 return IframeManager;
20768 }();
20769 var ShadowDomManager = /*#__PURE__*/ function() {
20770 function ShadowDomManager(options) {
20771 __publicField(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
20772 __publicField(this, "mutationCb");
20773 __publicField(this, "scrollCb");
20774 __publicField(this, "bypassOptions");
20775 __publicField(this, "mirror");
20776 __publicField(this, "restoreHandlers", []);
20777 this.mutationCb = options.mutationCb;
20778 this.scrollCb = options.scrollCb;
20779 this.bypassOptions = options.bypassOptions;
20780 this.mirror = options.mirror;
20781 this.init();
20782 }
20783 var _proto = ShadowDomManager.prototype;
20784 _proto.init = function init() {
20785 this.reset();
20786 this.patchAttachShadow(Element, document);
20787 };
20788 _proto.addShadowRoot = function addShadowRoot(shadowRoot2, doc) {
20789 var _this = this;
20790 if (!isNativeShadowDom(shadowRoot2)) return;
20791 if (this.shadowDoms.has(shadowRoot2)) return;
20792 this.shadowDoms.add(shadowRoot2);
20793 var observer = initMutationObserver(_extends({}, this.bypassOptions, {
20794 doc: doc,
20795 mutationCb: this.mutationCb,
20796 mirror: this.mirror,
20797 shadowDomManager: this
20798 }), shadowRoot2);
20799 this.restoreHandlers.push(function() {
20800 return observer.disconnect();
20801 });
20802 this.restoreHandlers.push(initScrollObserver(_extends({}, this.bypassOptions, {
20803 scrollCb: this.scrollCb,
20804 // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813
20805 // scroll is not allowed to pass the boundary, so we need to listen the shadow document
20806 doc: shadowRoot2,
20807 mirror: this.mirror
20808 })));
20809 setTimeout(function() {
20810 if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0) _this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot2.adoptedStyleSheets, _this.mirror.getId(index.host(shadowRoot2)));
20811 _this.restoreHandlers.push(initAdoptedStyleSheetObserver({
20812 mirror: _this.mirror,
20813 stylesheetManager: _this.bypassOptions.stylesheetManager
20814 }, shadowRoot2));
20815 }, 0);
20816 };
20817 /**
20818 * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
20819 */ _proto.observeAttachShadow = function observeAttachShadow(iframeElement) {
20820 if (!iframeElement.contentWindow || !iframeElement.contentDocument) return;
20821 this.patchAttachShadow(iframeElement.contentWindow.Element, iframeElement.contentDocument);
20822 };
20823 /**
20824 * Patch 'attachShadow' to observe newly added shadow doms.
20825 */ _proto.patchAttachShadow = function patchAttachShadow(element, doc) {
20826 var manager = this;
20827 this.restoreHandlers.push(patch(element.prototype, "attachShadow", function(original) {
20828 return function(option) {
20829 var sRoot = original.call(this, option);
20830 var shadowRootEl = index.shadowRoot(this);
20831 if (shadowRootEl && inDom(this)) manager.addShadowRoot(shadowRootEl, doc);
20832 return sRoot;
20833 };
20834 }));
20835 };
20836 _proto.reset = function reset() {
20837 this.restoreHandlers.forEach(function(handler) {
20838 try {
20839 handler();
20840 } catch (e2) {}
20841 });
20842 this.restoreHandlers = [];
20843 this.shadowDoms = /* @__PURE__ */ new WeakSet();
20844 };
20845 return ShadowDomManager;
20846 }();
20847 var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
20848 var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
20849 for(var i$1 = 0; i$1 < chars.length; i$1++){
20850 lookup[chars.charCodeAt(i$1)] = i$1;
20851 }
20852 var encode = function encode(arraybuffer) {
20853 var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
20854 for(i2 = 0; i2 < len; i2 += 3){
20855 base64 += chars[bytes[i2] >> 2];
20856 base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
20857 base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
20858 base64 += chars[bytes[i2 + 2] & 63];
20859 }
20860 if (len % 3 === 2) {
20861 base64 = base64.substring(0, base64.length - 1) + "=";
20862 } else if (len % 3 === 1) {
20863 base64 = base64.substring(0, base64.length - 2) + "==";
20864 }
20865 return base64;
20866 };
20867 var canvasVarMap = /* @__PURE__ */ new Map();
20868 function variableListFor$1(ctx, ctor) {
20869 var contextMap = canvasVarMap.get(ctx);
20870 if (!contextMap) {
20871 contextMap = /* @__PURE__ */ new Map();
20872 canvasVarMap.set(ctx, contextMap);
20873 }
20874 if (!contextMap.has(ctor)) {
20875 contextMap.set(ctor, []);
20876 }
20877 return contextMap.get(ctor);
20878 }
20879 var saveWebGLVar = function(value, win, ctx) {
20880 if (!value || !(isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object")) return;
20881 var name = value.constructor.name;
20882 var list2 = variableListFor$1(ctx, name);
20883 var index2 = list2.indexOf(value);
20884 if (index2 === -1) {
20885 index2 = list2.length;
20886 list2.push(value);
20887 }
20888 return index2;
20889 };
20890 function serializeArg(value, win, ctx) {
20891 if (_instanceof(value, Array)) {
20892 return value.map(function(arg) {
20893 return serializeArg(arg, win, ctx);
20894 });
20895 } else if (value === null) {
20896 return value;
20897 } 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)) {
20898 var name = value.constructor.name;
20899 return {
20900 rr_type: name,
20901 args: [
20902 Object.values(value)
20903 ]
20904 };
20905 } else if (// SharedArrayBuffer disabled on most browsers due to spectre.
20906 // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer
20907 // value instanceof SharedArrayBuffer ||
20908 _instanceof(value, ArrayBuffer)) {
20909 var name1 = value.constructor.name;
20910 var base64 = encode(value);
20911 return {
20912 rr_type: name1,
20913 base64: base64
20914 };
20915 } else if (_instanceof(value, DataView)) {
20916 var name2 = value.constructor.name;
20917 return {
20918 rr_type: name2,
20919 args: [
20920 serializeArg(value.buffer, win, ctx),
20921 value.byteOffset,
20922 value.byteLength
20923 ]
20924 };
20925 } else if (_instanceof(value, HTMLImageElement)) {
20926 var name3 = value.constructor.name;
20927 var src = value.src;
20928 return {
20929 rr_type: name3,
20930 src: src
20931 };
20932 } else if (_instanceof(value, HTMLCanvasElement)) {
20933 var name4 = "HTMLImageElement";
20934 var src1 = value.toDataURL();
20935 return {
20936 rr_type: name4,
20937 src: src1
20938 };
20939 } else if (_instanceof(value, ImageData)) {
20940 var name5 = value.constructor.name;
20941 return {
20942 rr_type: name5,
20943 args: [
20944 serializeArg(value.data, win, ctx),
20945 value.width,
20946 value.height
20947 ]
20948 };
20949 } else if (isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
20950 var name6 = value.constructor.name;
20951 var index2 = saveWebGLVar(value, win, ctx);
20952 return {
20953 rr_type: name6,
20954 index: index2
20955 };
20956 }
20957 return value;
20958 }
20959 var serializeArgs = function(args, win, ctx) {
20960 return args.map(function(arg) {
20961 return serializeArg(arg, win, ctx);
20962 });
20963 };
20964 var isInstanceOfWebGLObject = function(value, win) {
20965 var webGLConstructorNames = [
20966 "WebGLActiveInfo",
20967 "WebGLBuffer",
20968 "WebGLFramebuffer",
20969 "WebGLProgram",
20970 "WebGLRenderbuffer",
20971 "WebGLShader",
20972 "WebGLShaderPrecisionFormat",
20973 "WebGLTexture",
20974 "WebGLUniformLocation",
20975 "WebGLVertexArrayObject",
20976 // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.
20977 "WebGLVertexArrayObjectOES"
20978 ];
20979 var supportedWebGLConstructorNames = webGLConstructorNames.filter(function(name) {
20980 return typeof win[name] === "function";
20981 });
20982 return Boolean(supportedWebGLConstructorNames.find(function(name) {
20983 return _instanceof(value, win[name]);
20984 }));
20985 };
20986 function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
20987 var _loop = function() {
20988 var prop = _step.value;
20989 try {
20990 if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
20991 return "continue";
20992 }
20993 var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
20994 return function() {
20995 var _this = this;
20996 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
20997 args[_key] = arguments[_key];
20998 }
20999 if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
21000 setTimeout(function() {
21001 var recordArgs = serializeArgs(args, win, _this);
21002 cb(_this.canvas, {
21003 type: CanvasContext["2D"],
21004 property: prop,
21005 args: recordArgs
21006 });
21007 }, 0);
21008 }
21009 return original.apply(this, args);
21010 };
21011 });
21012 handlers.push(restoreHandler);
21013 } catch (e) {
21014 var hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
21015 set: function set(v2) {
21016 cb(this.canvas, {
21017 type: CanvasContext["2D"],
21018 property: prop,
21019 args: [
21020 v2
21021 ],
21022 setter: true
21023 });
21024 }
21025 });
21026 handlers.push(hookHandler);
21027 }
21028 };
21029 var handlers = [];
21030 var props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
21031 for(var _iterator = _create_for_of_iterator_helper_loose(props2D), _step; !(_step = _iterator()).done;)_loop();
21032 return function() {
21033 handlers.forEach(function(h) {
21034 return h();
21035 });
21036 };
21037 }
21038 function getNormalizedContextName(contextType) {
21039 return contextType === "experimental-webgl" ? "webgl" : contextType;
21040 }
21041 function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
21042 var handlers = [];
21043 try {
21044 var restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
21045 return function(contextType) {
21046 for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
21047 args[_key - 1] = arguments[_key];
21048 }
21049 if (!isBlocked(this, blockClass, blockSelector, true)) {
21050 var ctxName = getNormalizedContextName(contextType);
21051 if (!("__context" in this)) this.__context = ctxName;
21052 if (setPreserveDrawingBufferToTrue && [
21053 "webgl",
21054 "webgl2"
21055 ].includes(ctxName)) {
21056 if (args[0] && _type_of(args[0]) === "object") {
21057 var contextAttributes = args[0];
21058 if (!contextAttributes.preserveDrawingBuffer) {
21059 contextAttributes.preserveDrawingBuffer = true;
21060 }
21061 } else {
21062 args.splice(0, 1, {
21063 preserveDrawingBuffer: true
21064 });
21065 }
21066 }
21067 }
21068 return original.apply(this, [].concat([
21069 contextType
21070 ], args));
21071 };
21072 });
21073 handlers.push(restoreHandler);
21074 } catch (e) {
21075 console.error("failed to patch HTMLCanvasElement.prototype.getContext");
21076 }
21077 return function() {
21078 handlers.forEach(function(h) {
21079 return h();
21080 });
21081 };
21082 }
21083 function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
21084 var _loop = function() {
21085 var prop = _step.value;
21086 if (//prop.startsWith('get') || // e.g. getProgramParameter, but too risky
21087 [
21088 "isContextLost",
21089 "canvas",
21090 "drawingBufferWidth",
21091 "drawingBufferHeight"
21092 ].includes(prop)) {
21093 return "continue";
21094 }
21095 try {
21096 if (typeof prototype[prop] !== "function") {
21097 return "continue";
21098 }
21099 var restoreHandler = patch(prototype, prop, function(original) {
21100 return function() {
21101 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21102 args[_key] = arguments[_key];
21103 }
21104 var result2 = original.apply(this, args);
21105 saveWebGLVar(result2, win, this);
21106 if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
21107 var recordArgs = serializeArgs(args, win, this);
21108 var mutation = {
21109 type: type,
21110 property: prop,
21111 args: recordArgs
21112 };
21113 cb(this.canvas, mutation);
21114 }
21115 return result2;
21116 };
21117 });
21118 handlers.push(restoreHandler);
21119 } catch (e) {
21120 var hookHandler = hookSetter(prototype, prop, {
21121 set: function set(v2) {
21122 cb(this.canvas, {
21123 type: type,
21124 property: prop,
21125 args: [
21126 v2
21127 ],
21128 setter: true
21129 });
21130 }
21131 });
21132 handlers.push(hookHandler);
21133 }
21134 };
21135 var handlers = [];
21136 var props = Object.getOwnPropertyNames(prototype);
21137 for(var _iterator = _create_for_of_iterator_helper_loose(props), _step; !(_step = _iterator()).done;)_loop();
21138 return handlers;
21139 }
21140 function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
21141 var _handlers;
21142 var handlers = [];
21143 (_handlers = handlers).push.apply(_handlers, [].concat(patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, blockSelector, win)));
21144 if (typeof win.WebGL2RenderingContext !== "undefined") {
21145 var _handlers1;
21146 (_handlers1 = handlers).push.apply(_handlers1, [].concat(patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, blockSelector, win)));
21147 }
21148 return function() {
21149 handlers.forEach(function(h) {
21150 return h();
21151 });
21152 };
21153 }
21154 var encodedJs = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=";
21155 var decodeBase64 = function(base64) {
21156 return Uint8Array.from(atob(base64), function(c2) {
21157 return c2.charCodeAt(0);
21158 });
21159 };
21160 var blob = typeof window !== "undefined" && window.Blob && new Blob([
21161 decodeBase64(encodedJs)
21162 ], {
21163 type: "text/javascript;charset=utf-8"
21164 });
21165 function WorkerWrapper(options) {
21166 var objURL;
21167 try {
21168 objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
21169 if (!objURL) throw "";
21170 var worker = new Worker(objURL, {
21171 name: options == null ? void 0 : options.name
21172 });
21173 worker.addEventListener("error", function() {
21174 (window.URL || window.webkitURL).revokeObjectURL(objURL);
21175 });
21176 return worker;
21177 } catch (e2) {
21178 return new Worker("data:text/javascript;base64," + encodedJs, {
21179 name: options == null ? void 0 : options.name
21180 });
21181 } finally{
21182 objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
21183 }
21184 }
21185 var CanvasManager = /*#__PURE__*/ function() {
21186 function CanvasManager(options) {
21187 var _this = this;
21188 __publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
21189 __publicField(this, "rafStamps", {
21190 latestId: 0,
21191 invokeId: null
21192 });
21193 __publicField(this, "mirror");
21194 __publicField(this, "mutationCb");
21195 __publicField(this, "resetObservers");
21196 __publicField(this, "frozen", false);
21197 __publicField(this, "locked", false);
21198 __publicField(this, "processMutation", function(target, mutation) {
21199 var newFrame = _this.rafStamps.invokeId && _this.rafStamps.latestId !== _this.rafStamps.invokeId;
21200 if (newFrame || !_this.rafStamps.invokeId) _this.rafStamps.invokeId = _this.rafStamps.latestId;
21201 if (!_this.pendingCanvasMutations.has(target)) {
21202 _this.pendingCanvasMutations.set(target, []);
21203 }
21204 _this.pendingCanvasMutations.get(target).push(mutation);
21205 });
21206 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;
21207 this.mutationCb = options.mutationCb;
21208 this.mirror = options.mirror;
21209 if (recordCanvas && sampling === "all") this.initCanvasMutationObserver(win, blockClass, blockSelector);
21210 if (recordCanvas && typeof sampling === "number") this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
21211 dataURLOptions: dataURLOptions
21212 });
21213 }
21214 var _proto = CanvasManager.prototype;
21215 _proto.reset = function reset() {
21216 this.pendingCanvasMutations.clear();
21217 this.resetObservers && this.resetObservers();
21218 };
21219 _proto.freeze = function freeze() {
21220 this.frozen = true;
21221 };
21222 _proto.unfreeze = function unfreeze() {
21223 this.frozen = false;
21224 };
21225 _proto.lock = function lock() {
21226 this.locked = true;
21227 };
21228 _proto.unlock = function unlock() {
21229 this.locked = false;
21230 };
21231 _proto.initCanvasFPSObserver = function initCanvasFPSObserver(fps, win, blockClass, blockSelector, options) {
21232 var _this = this;
21233 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, true);
21234 var snapshotInProgressMap = /* @__PURE__ */ new Map();
21235 var worker = new WorkerWrapper();
21236 worker.onmessage = function(e2) {
21237 var id = e2.data.id;
21238 snapshotInProgressMap.set(id, false);
21239 if (!("base64" in e2.data)) return;
21240 var _e2_data = e2.data, base64 = _e2_data.base64, type = _e2_data.type, width = _e2_data.width, height = _e2_data.height;
21241 _this.mutationCb({
21242 id: id,
21243 type: CanvasContext["2D"],
21244 commands: [
21245 {
21246 property: "clearRect",
21247 // wipe canvas
21248 args: [
21249 0,
21250 0,
21251 width,
21252 height
21253 ]
21254 },
21255 {
21256 property: "drawImage",
21257 // draws (semi-transparent) image
21258 args: [
21259 {
21260 rr_type: "ImageBitmap",
21261 args: [
21262 {
21263 rr_type: "Blob",
21264 data: [
21265 {
21266 rr_type: "ArrayBuffer",
21267 base64: base64
21268 }
21269 ],
21270 type: type
21271 }
21272 ]
21273 },
21274 0,
21275 0
21276 ]
21277 }
21278 ]
21279 });
21280 };
21281 var timeBetweenSnapshots = 1e3 / fps;
21282 var lastSnapshotTime = 0;
21283 var rafId;
21284 var getCanvas = function() {
21285 var matchedCanvas = [];
21286 win.document.querySelectorAll("canvas").forEach(function(canvas) {
21287 if (!isBlocked(canvas, blockClass, blockSelector, true)) {
21288 matchedCanvas.push(canvas);
21289 }
21290 });
21291 return matchedCanvas;
21292 };
21293 var takeCanvasSnapshots = function(timestamp) {
21294 if (lastSnapshotTime && timestamp - lastSnapshotTime < timeBetweenSnapshots) {
21295 rafId = requestAnimationFrame(takeCanvasSnapshots);
21296 return;
21297 }
21298 lastSnapshotTime = timestamp;
21299 var _this1 = _this;
21300 getCanvas().forEach(/*#__PURE__*/ _async_to_generator(function(canvas) {
21301 var _a2, id, context, bitmap;
21302 return _ts_generator(this, function(_state) {
21303 switch(_state.label){
21304 case 0:
21305 id = _this1.mirror.getId(canvas);
21306 if (snapshotInProgressMap.get(id)) return [
21307 2
21308 ];
21309 if (canvas.width === 0 || canvas.height === 0) return [
21310 2
21311 ];
21312 snapshotInProgressMap.set(id, true);
21313 if ([
21314 "webgl",
21315 "webgl2"
21316 ].includes(canvas.__context)) {
21317 context = canvas.getContext(canvas.__context);
21318 if (((_a2 = context == null ? void 0 : context.getContextAttributes()) == null ? void 0 : _a2.preserveDrawingBuffer) === false) {
21319 context.clear(context.COLOR_BUFFER_BIT);
21320 }
21321 }
21322 return [
21323 4,
21324 createImageBitmap(canvas)
21325 ];
21326 case 1:
21327 bitmap = _state.sent();
21328 worker.postMessage({
21329 id: id,
21330 bitmap: bitmap,
21331 width: canvas.width,
21332 height: canvas.height,
21333 dataURLOptions: options.dataURLOptions
21334 }, [
21335 bitmap
21336 ]);
21337 return [
21338 2
21339 ];
21340 }
21341 });
21342 }));
21343 rafId = requestAnimationFrame(takeCanvasSnapshots);
21344 };
21345 rafId = requestAnimationFrame(takeCanvasSnapshots);
21346 this.resetObservers = function() {
21347 canvasContextReset();
21348 cancelAnimationFrame(rafId);
21349 };
21350 };
21351 _proto.initCanvasMutationObserver = function initCanvasMutationObserver(win, blockClass, blockSelector) {
21352 this.startRAFTimestamping();
21353 this.startPendingCanvasMutationFlusher();
21354 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, false);
21355 var canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21356 var canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21357 this.resetObservers = function() {
21358 canvasContextReset();
21359 canvas2DReset();
21360 canvasWebGL1and2Reset();
21361 };
21362 };
21363 _proto.startPendingCanvasMutationFlusher = function startPendingCanvasMutationFlusher() {
21364 var _this = this;
21365 requestAnimationFrame(function() {
21366 return _this.flushPendingCanvasMutations();
21367 });
21368 };
21369 _proto.startRAFTimestamping = function startRAFTimestamping() {
21370 var _this = this;
21371 var setLatestRAFTimestamp = function(timestamp) {
21372 _this.rafStamps.latestId = timestamp;
21373 requestAnimationFrame(setLatestRAFTimestamp);
21374 };
21375 requestAnimationFrame(setLatestRAFTimestamp);
21376 };
21377 _proto.flushPendingCanvasMutations = function flushPendingCanvasMutations() {
21378 var _this = this;
21379 this.pendingCanvasMutations.forEach(function(_values, canvas) {
21380 var id = _this.mirror.getId(canvas);
21381 _this.flushPendingCanvasMutationFor(canvas, id);
21382 });
21383 requestAnimationFrame(function() {
21384 return _this.flushPendingCanvasMutations();
21385 });
21386 };
21387 _proto.flushPendingCanvasMutationFor = function flushPendingCanvasMutationFor(canvas, id) {
21388 if (this.frozen || this.locked) {
21389 return;
21390 }
21391 var valuesWithType = this.pendingCanvasMutations.get(canvas);
21392 if (!valuesWithType || id === -1) return;
21393 var values = valuesWithType.map(function(value) {
21394 value.type; var rest = _object_without_properties_loose(value, [
21395 "type"
21396 ]);
21397 return rest;
21398 });
21399 var type = valuesWithType[0].type;
21400 this.mutationCb({
21401 id: id,
21402 type: type,
21403 commands: values
21404 });
21405 this.pendingCanvasMutations.delete(canvas);
21406 };
21407 return CanvasManager;
21408 }();
21409 var StylesheetManager = /*#__PURE__*/ function() {
21410 function StylesheetManager(options) {
21411 __publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
21412 __publicField(this, "mutationCb");
21413 __publicField(this, "adoptedStyleSheetCb");
21414 __publicField(this, "styleMirror", new StyleSheetMirror());
21415 this.mutationCb = options.mutationCb;
21416 this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
21417 }
21418 var _proto = StylesheetManager.prototype;
21419 _proto.attachLinkElement = function attachLinkElement(linkEl, childSn) {
21420 if ("_cssText" in childSn.attributes) this.mutationCb({
21421 adds: [],
21422 removes: [],
21423 texts: [],
21424 attributes: [
21425 {
21426 id: childSn.id,
21427 attributes: childSn.attributes
21428 }
21429 ]
21430 });
21431 this.trackLinkElement(linkEl);
21432 };
21433 _proto.trackLinkElement = function trackLinkElement(linkEl) {
21434 if (this.trackedLinkElements.has(linkEl)) return;
21435 this.trackedLinkElements.add(linkEl);
21436 this.trackStylesheetInLinkElement(linkEl);
21437 };
21438 _proto.adoptStyleSheets = function adoptStyleSheets(sheets, hostId) {
21439 var _this, _loop = function() {
21440 var sheet = _step.value;
21441 var styleId = void 0;
21442 if (!_this.styleMirror.has(sheet)) {
21443 styleId = _this.styleMirror.add(sheet);
21444 styles.push({
21445 styleId: styleId,
21446 rules: Array.from(sheet.rules || CSSRule, function(r2, index2) {
21447 return {
21448 rule: stringifyRule(r2, sheet.href),
21449 index: index2
21450 };
21451 })
21452 });
21453 } else styleId = _this.styleMirror.getId(sheet);
21454 adoptedStyleSheetData.styleIds.push(styleId);
21455 };
21456 if (sheets.length === 0) return;
21457 var adoptedStyleSheetData = {
21458 id: hostId,
21459 styleIds: []
21460 };
21461 var styles = [];
21462 for(var _iterator = _create_for_of_iterator_helper_loose(sheets), _step; !(_step = _iterator()).done;)_this = this, _loop();
21463 if (styles.length > 0) adoptedStyleSheetData.styles = styles;
21464 this.adoptedStyleSheetCb(adoptedStyleSheetData);
21465 };
21466 _proto.reset = function reset() {
21467 this.styleMirror.reset();
21468 this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
21469 };
21470 // TODO: take snapshot on stylesheet reload by applying event listener
21471 _proto.trackStylesheetInLinkElement = function trackStylesheetInLinkElement(_linkEl) {};
21472 return StylesheetManager;
21473 }();
21474 var ProcessedNodeManager = /*#__PURE__*/ function() {
21475 function ProcessedNodeManager() {
21476 __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap());
21477 __publicField(this, "active", false);
21478 }
21479 var _proto = ProcessedNodeManager.prototype;
21480 _proto.inOtherBuffer = function inOtherBuffer(node2, thisBuffer) {
21481 var buffers = this.nodeMap.get(node2);
21482 return buffers && Array.from(buffers).some(function(buffer) {
21483 return buffer !== thisBuffer;
21484 });
21485 };
21486 _proto.add = function add(node2, buffer) {
21487 var _this = this;
21488 if (!this.active) {
21489 this.active = true;
21490 requestAnimationFrame(function() {
21491 _this.nodeMap = /* @__PURE__ */ new WeakMap();
21492 _this.active = false;
21493 });
21494 }
21495 this.nodeMap.set(node2, (this.nodeMap.get(node2) || /* @__PURE__ */ new Set()).add(buffer));
21496 };
21497 _proto.destroy = function destroy() {};
21498 return ProcessedNodeManager;
21499 }();
21500 var wrappedEmit;
21501 var takeFullSnapshot$1;
21502 var canvasManager;
21503 var recording = false;
21504 try {
21505 if (Array.from([
21506 1
21507 ], function(x2) {
21508 return x2 * 2;
21509 })[0] !== 2) {
21510 var cleanFrame = document.createElement("iframe");
21511 document.body.appendChild(cleanFrame);
21512 Array.from = ((_a = cleanFrame.contentWindow) == null ? void 0 : _a.Array.from) || Array.from;
21513 document.body.removeChild(cleanFrame);
21514 }
21515 } catch (err) {
21516 console.debug("Unable to override Array.from", err);
21517 }
21518 var mirror = createMirror$2();
21519 function record(options) {
21520 if (options === void 0) options = {};
21521 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() {
21522 return false;
21523 } : _options_keepIframeSrcFn, _options_ignoreCSSAttributes = options.ignoreCSSAttributes, ignoreCSSAttributes = _options_ignoreCSSAttributes === void 0 ? /* @__PURE__ */ new Set([]) : _options_ignoreCSSAttributes, errorHandler2 = options.errorHandler;
21524 registerErrorHandler(errorHandler2);
21525 var inEmittingFrame = recordCrossOriginIframes ? window.parent === window : true;
21526 var passEmitsToParent = false;
21527 if (!inEmittingFrame) {
21528 try {
21529 if (window.parent.document) {
21530 passEmitsToParent = false;
21531 }
21532 } catch (e2) {
21533 passEmitsToParent = true;
21534 }
21535 }
21536 if (inEmittingFrame && !emit) {
21537 throw new Error("emit function is required");
21538 }
21539 if (!inEmittingFrame && !passEmitsToParent) {
21540 return function() {};
21541 }
21542 if (mousemoveWait !== void 0 && sampling.mousemove === void 0) {
21543 sampling.mousemove = mousemoveWait;
21544 }
21545 mirror.reset();
21546 var maskInputOptions = maskAllInputs === true ? {
21547 color: true,
21548 date: true,
21549 "datetime-local": true,
21550 email: true,
21551 month: true,
21552 number: true,
21553 range: true,
21554 search: true,
21555 tel: true,
21556 text: true,
21557 time: true,
21558 url: true,
21559 week: true,
21560 textarea: true,
21561 select: true,
21562 password: true,
21563 hidden: true
21564 } : _maskInputOptions !== void 0 ? _maskInputOptions : {
21565 password: true
21566 };
21567 var slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
21568 script: true,
21569 comment: true,
21570 headFavicon: true,
21571 headWhitespace: true,
21572 headMetaSocial: true,
21573 headMetaRobots: true,
21574 headMetaHttpEquiv: true,
21575 headMetaVerification: true,
21576 // the following are off for slimDOMOptions === true,
21577 // as they destroy some (hidden) info:
21578 headMetaAuthorship: _slimDOMOptions === "all",
21579 headMetaDescKeywords: _slimDOMOptions === "all",
21580 headTitleMutations: _slimDOMOptions === "all"
21581 } : _slimDOMOptions ? _slimDOMOptions : {};
21582 polyfill$1();
21583 var lastFullSnapshotEvent;
21584 var incrementalSnapshotCount = 0;
21585 var eventProcessor = function(e2) {
21586 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
21587 var plugin3 = _step.value;
21588 if (plugin3.eventProcessor) {
21589 e2 = plugin3.eventProcessor(e2);
21590 }
21591 }
21592 if (packFn && // Disable packing events which will be emitted to parent frames.
21593 !passEmitsToParent) {
21594 e2 = packFn(e2);
21595 }
21596 return e2;
21597 };
21598 wrappedEmit = function(r2, isCheckout) {
21599 var _a2;
21600 var e2 = r2;
21601 e2.timestamp = nowTimestamp();
21602 if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
21603 mutationBuffers.forEach(function(buf) {
21604 return buf.unfreeze();
21605 });
21606 }
21607 if (inEmittingFrame) {
21608 emit == null ? void 0 : emit(eventProcessor(e2), isCheckout);
21609 } else if (passEmitsToParent) {
21610 var message = {
21611 type: "rrweb",
21612 event: eventProcessor(e2),
21613 origin: window.location.origin,
21614 isCheckout: isCheckout
21615 };
21616 window.parent.postMessage(message, "*");
21617 }
21618 if (e2.type === EventType.FullSnapshot) {
21619 lastFullSnapshotEvent = e2;
21620 incrementalSnapshotCount = 0;
21621 } else if (e2.type === EventType.IncrementalSnapshot) {
21622 if (e2.data.source === IncrementalSource.Mutation && e2.data.isAttachIframe) {
21623 return;
21624 }
21625 incrementalSnapshotCount++;
21626 var exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
21627 var exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
21628 if (exceedCount || exceedTime) {
21629 takeFullSnapshot$1(true);
21630 }
21631 }
21632 };
21633 var wrappedMutationEmit = function(m) {
21634 wrappedEmit({
21635 type: EventType.IncrementalSnapshot,
21636 data: _extends({
21637 source: IncrementalSource.Mutation
21638 }, m)
21639 });
21640 };
21641 var wrappedScrollEmit = function(p) {
21642 return wrappedEmit({
21643 type: EventType.IncrementalSnapshot,
21644 data: _extends({
21645 source: IncrementalSource.Scroll
21646 }, p)
21647 });
21648 };
21649 var wrappedCanvasMutationEmit = function(p) {
21650 return wrappedEmit({
21651 type: EventType.IncrementalSnapshot,
21652 data: _extends({
21653 source: IncrementalSource.CanvasMutation
21654 }, p)
21655 });
21656 };
21657 var wrappedAdoptedStyleSheetEmit = function(a2) {
21658 return wrappedEmit({
21659 type: EventType.IncrementalSnapshot,
21660 data: _extends({
21661 source: IncrementalSource.AdoptedStyleSheet
21662 }, a2)
21663 });
21664 };
21665 var stylesheetManager = new StylesheetManager({
21666 mutationCb: wrappedMutationEmit,
21667 adoptedStyleSheetCb: wrappedAdoptedStyleSheetEmit
21668 });
21669 var iframeManager = new IframeManager({
21670 mirror: mirror,
21671 mutationCb: wrappedMutationEmit,
21672 stylesheetManager: stylesheetManager,
21673 recordCrossOriginIframes: recordCrossOriginIframes,
21674 wrappedEmit: wrappedEmit
21675 });
21676 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
21677 var plugin3 = _step.value;
21678 if (plugin3.getMirror) plugin3.getMirror({
21679 nodeMirror: mirror,
21680 crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,
21681 crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror
21682 });
21683 }
21684 var processedNodeManager = new ProcessedNodeManager();
21685 canvasManager = new CanvasManager({
21686 recordCanvas: recordCanvas,
21687 mutationCb: wrappedCanvasMutationEmit,
21688 win: window,
21689 blockClass: blockClass,
21690 blockSelector: blockSelector,
21691 mirror: mirror,
21692 sampling: sampling.canvas,
21693 dataURLOptions: dataURLOptions
21694 });
21695 var shadowDomManager = new ShadowDomManager({
21696 mutationCb: wrappedMutationEmit,
21697 scrollCb: wrappedScrollEmit,
21698 bypassOptions: {
21699 blockClass: blockClass,
21700 blockSelector: blockSelector,
21701 maskTextClass: maskTextClass,
21702 maskTextSelector: maskTextSelector,
21703 inlineStylesheet: inlineStylesheet,
21704 maskInputOptions: maskInputOptions,
21705 dataURLOptions: dataURLOptions,
21706 maskTextFn: maskTextFn,
21707 maskInputFn: maskInputFn,
21708 recordCanvas: recordCanvas,
21709 inlineImages: inlineImages,
21710 sampling: sampling,
21711 slimDOMOptions: slimDOMOptions,
21712 iframeManager: iframeManager,
21713 stylesheetManager: stylesheetManager,
21714 canvasManager: canvasManager,
21715 keepIframeSrcFn: keepIframeSrcFn,
21716 processedNodeManager: processedNodeManager
21717 },
21718 mirror: mirror
21719 });
21720 takeFullSnapshot$1 = function(isCheckout) {
21721 if (isCheckout === void 0) isCheckout = false;
21722 if (!recordDOM) {
21723 return;
21724 }
21725 wrappedEmit({
21726 type: EventType.Meta,
21727 data: {
21728 href: window.location.href,
21729 width: getWindowWidth(),
21730 height: getWindowHeight()
21731 }
21732 }, isCheckout);
21733 stylesheetManager.reset();
21734 shadowDomManager.init();
21735 mutationBuffers.forEach(function(buf) {
21736 return buf.lock();
21737 });
21738 var node2 = snapshot(document, {
21739 mirror: mirror,
21740 blockClass: blockClass,
21741 blockSelector: blockSelector,
21742 maskTextClass: maskTextClass,
21743 maskTextSelector: maskTextSelector,
21744 inlineStylesheet: inlineStylesheet,
21745 maskAllInputs: maskInputOptions,
21746 maskTextFn: maskTextFn,
21747 maskInputFn: maskInputFn,
21748 slimDOM: slimDOMOptions,
21749 dataURLOptions: dataURLOptions,
21750 recordCanvas: recordCanvas,
21751 inlineImages: inlineImages,
21752 onSerialize: function(n2) {
21753 if (isSerializedIframe(n2, mirror)) {
21754 iframeManager.addIframe(n2);
21755 }
21756 if (isSerializedStylesheet(n2, mirror)) {
21757 stylesheetManager.trackLinkElement(n2);
21758 }
21759 if (hasShadowRoot(n2)) {
21760 shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
21761 }
21762 },
21763 onIframeLoad: function(iframe, childSn) {
21764 iframeManager.attachIframe(iframe, childSn);
21765 shadowDomManager.observeAttachShadow(iframe);
21766 },
21767 onStylesheetLoad: function(linkEl, childSn) {
21768 stylesheetManager.attachLinkElement(linkEl, childSn);
21769 },
21770 keepIframeSrcFn: keepIframeSrcFn
21771 });
21772 if (!node2) {
21773 return console.warn("Failed to snapshot the document");
21774 }
21775 wrappedEmit({
21776 type: EventType.FullSnapshot,
21777 data: {
21778 node: node2,
21779 initialOffset: getWindowScroll(window)
21780 }
21781 }, isCheckout);
21782 mutationBuffers.forEach(function(buf) {
21783 return buf.unlock();
21784 });
21785 if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0) stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.getId(document));
21786 };
21787 try {
21788 var handlers = [];
21789 var observe = function(doc) {
21790 var _a2;
21791 return callbackWrapper(initObservers)({
21792 mutationCb: wrappedMutationEmit,
21793 mousemoveCb: function(positions, source) {
21794 return wrappedEmit({
21795 type: EventType.IncrementalSnapshot,
21796 data: {
21797 source: source,
21798 positions: positions
21799 }
21800 });
21801 },
21802 mouseInteractionCb: function(d) {
21803 return wrappedEmit({
21804 type: EventType.IncrementalSnapshot,
21805 data: _extends({
21806 source: IncrementalSource.MouseInteraction
21807 }, d)
21808 });
21809 },
21810 scrollCb: wrappedScrollEmit,
21811 viewportResizeCb: function(d) {
21812 return wrappedEmit({
21813 type: EventType.IncrementalSnapshot,
21814 data: _extends({
21815 source: IncrementalSource.ViewportResize
21816 }, d)
21817 });
21818 },
21819 inputCb: function(v2) {
21820 return wrappedEmit({
21821 type: EventType.IncrementalSnapshot,
21822 data: _extends({
21823 source: IncrementalSource.Input
21824 }, v2)
21825 });
21826 },
21827 mediaInteractionCb: function(p) {
21828 return wrappedEmit({
21829 type: EventType.IncrementalSnapshot,
21830 data: _extends({
21831 source: IncrementalSource.MediaInteraction
21832 }, p)
21833 });
21834 },
21835 styleSheetRuleCb: function(r2) {
21836 return wrappedEmit({
21837 type: EventType.IncrementalSnapshot,
21838 data: _extends({
21839 source: IncrementalSource.StyleSheetRule
21840 }, r2)
21841 });
21842 },
21843 styleDeclarationCb: function(r2) {
21844 return wrappedEmit({
21845 type: EventType.IncrementalSnapshot,
21846 data: _extends({
21847 source: IncrementalSource.StyleDeclaration
21848 }, r2)
21849 });
21850 },
21851 canvasMutationCb: wrappedCanvasMutationEmit,
21852 fontCb: function(p) {
21853 return wrappedEmit({
21854 type: EventType.IncrementalSnapshot,
21855 data: _extends({
21856 source: IncrementalSource.Font
21857 }, p)
21858 });
21859 },
21860 selectionCb: function(p) {
21861 wrappedEmit({
21862 type: EventType.IncrementalSnapshot,
21863 data: _extends({
21864 source: IncrementalSource.Selection
21865 }, p)
21866 });
21867 },
21868 customElementCb: function(c2) {
21869 wrappedEmit({
21870 type: EventType.IncrementalSnapshot,
21871 data: _extends({
21872 source: IncrementalSource.CustomElement
21873 }, c2)
21874 });
21875 },
21876 blockClass: blockClass,
21877 ignoreClass: ignoreClass,
21878 ignoreSelector: ignoreSelector,
21879 maskTextClass: maskTextClass,
21880 maskTextSelector: maskTextSelector,
21881 maskInputOptions: maskInputOptions,
21882 inlineStylesheet: inlineStylesheet,
21883 sampling: sampling,
21884 recordDOM: recordDOM,
21885 recordCanvas: recordCanvas,
21886 inlineImages: inlineImages,
21887 userTriggeredOnInput: userTriggeredOnInput,
21888 collectFonts: collectFonts,
21889 doc: doc,
21890 maskInputFn: maskInputFn,
21891 maskTextFn: maskTextFn,
21892 keepIframeSrcFn: keepIframeSrcFn,
21893 blockSelector: blockSelector,
21894 slimDOMOptions: slimDOMOptions,
21895 dataURLOptions: dataURLOptions,
21896 mirror: mirror,
21897 iframeManager: iframeManager,
21898 stylesheetManager: stylesheetManager,
21899 shadowDomManager: shadowDomManager,
21900 processedNodeManager: processedNodeManager,
21901 canvasManager: canvasManager,
21902 ignoreCSSAttributes: ignoreCSSAttributes,
21903 plugins: ((_a2 = plugins == null ? void 0 : plugins.filter(function(p) {
21904 return p.observer;
21905 })) == null ? void 0 : _a2.map(function(p) {
21906 return {
21907 observer: p.observer,
21908 options: p.options,
21909 callback: function(payload) {
21910 return wrappedEmit({
21911 type: EventType.Plugin,
21912 data: {
21913 plugin: p.name,
21914 payload: payload
21915 }
21916 });
21917 }
21918 };
21919 })) || []
21920 }, hooks);
21921 };
21922 iframeManager.addLoadListener(function(iframeEl) {
21923 try {
21924 handlers.push(observe(iframeEl.contentDocument));
21925 } catch (error) {
21926 console.warn(error);
21927 }
21928 });
21929 var init = function() {
21930 takeFullSnapshot$1();
21931 handlers.push(observe(document));
21932 recording = true;
21933 };
21934 if (document.readyState === "interactive" || document.readyState === "complete") {
21935 init();
21936 } else {
21937 handlers.push(on("DOMContentLoaded", function() {
21938 wrappedEmit({
21939 type: EventType.DomContentLoaded,
21940 data: {}
21941 });
21942 if (recordAfter === "DOMContentLoaded") init();
21943 }));
21944 handlers.push(on("load", function() {
21945 wrappedEmit({
21946 type: EventType.Load,
21947 data: {}
21948 });
21949 if (recordAfter === "load") init();
21950 }, window));
21951 }
21952 return function() {
21953 handlers.forEach(function(handler) {
21954 try {
21955 handler();
21956 } catch (error) {
21957 var msg = String(error).toLowerCase();
21958 if (!msg.includes("cross-origin")) {
21959 console.warn(error);
21960 }
21961 }
21962 });
21963 processedNodeManager.destroy();
21964 recording = false;
21965 unregisterErrorHandler();
21966 };
21967 } catch (error) {
21968 console.warn(error);
21969 }
21970 }
21971 record.addCustomEvent = function(tag, payload) {
21972 if (!recording) {
21973 throw new Error("please add custom event after start recording");
21974 }
21975 wrappedEmit({
21976 type: EventType.Custom,
21977 data: {
21978 tag: tag,
21979 payload: payload
21980 }
21981 });
21982 };
21983 record.freezePage = function() {
21984 mutationBuffers.forEach(function(buf) {
21985 return buf.freeze();
21986 });
21987 };
21988 record.takeFullSnapshot = function(isCheckout) {
21989 if (!recording) {
21990 throw new Error("please take full snapshot after start recording");
21991 }
21992 takeFullSnapshot$1(isCheckout);
21993 };
21994 record.mirror = mirror;
21995 var n;
21996 !function(t2) {
21997 t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
21998 }(n || (n = {}));
21999 record.addCustomEvent;
22000 record.freezePage;
22001 record.takeFullSnapshot;
22002
22003 var setImmediate = win['setImmediate'];
22004 var builtInProp, cycle, schedulingQueue,
22005 ToString = Object.prototype.toString,
22006 timer = (typeof setImmediate !== 'undefined') ?
22007 function timer(fn) { return setImmediate(fn); } :
22008 setTimeout;
22009
22010 // dammit, IE8.
22011 try {
22012 Object.defineProperty({},'x',{});
22013 builtInProp = function builtInProp(obj,name,val,config) {
22014 return Object.defineProperty(obj,name,{
22015 value: val,
22016 writable: true,
22017 configurable: config !== false
22018 });
22019 };
22020 }
22021 catch (err) {
22022 builtInProp = function builtInProp(obj,name,val) {
22023 obj[name] = val;
22024 return obj;
22025 };
22026 }
22027
22028 // Note: using a queue instead of array for efficiency
22029 schedulingQueue = (function Queue() {
22030 var first, last, item;
22031
22032 function Item(fn,self) {
22033 this.fn = fn;
22034 this.self = self;
22035 this.next = void 0;
22036 }
22037
22038 return {
22039 add: function add(fn,self) {
22040 item = new Item(fn,self);
22041 if (last) {
22042 last.next = item;
22043 }
22044 else {
22045 first = item;
22046 }
22047 last = item;
22048 item = void 0;
22049 },
22050 drain: function drain() {
22051 var f = first;
22052 first = last = cycle = void 0;
22053
22054 while (f) {
22055 f.fn.call(f.self);
22056 f = f.next;
22057 }
22058 }
22059 };
22060 })();
22061
22062 function schedule(fn,self) {
22063 schedulingQueue.add(fn,self);
22064 if (!cycle) {
22065 cycle = timer(schedulingQueue.drain);
22066 }
22067 }
22068
22069 // promise duck typing
22070 function isThenable(o) {
22071 var _then, oType = typeof o;
22072
22073 if (o !== null && (oType === 'object' || oType === 'function')) {
22074 _then = o.then;
22075 }
22076 return typeof _then === 'function' ? _then : false;
22077 }
22078
22079 function notify() {
22080 for (var i=0; i<this.chain.length; i++) {
22081 notifyIsolated(
22082 this,
22083 (this.state === 1) ? this.chain[i].success : this.chain[i].failure,
22084 this.chain[i]
22085 );
22086 }
22087 this.chain.length = 0;
22088 }
22089
22090 // NOTE: This is a separate function to isolate
22091 // the `try..catch` so that other code can be
22092 // optimized better
22093 function notifyIsolated(self,cb,chain) {
22094 var ret, _then;
22095 try {
22096 if (cb === false) {
22097 chain.reject(self.msg);
22098 }
22099 else {
22100 if (cb === true) {
22101 ret = self.msg;
22102 }
22103 else {
22104 ret = cb.call(void 0,self.msg);
22105 }
22106
22107 if (ret === chain.promise) {
22108 chain.reject(TypeError('Promise-chain cycle'));
22109 }
22110 // eslint-disable-next-line no-cond-assign
22111 else if (_then = isThenable(ret)) {
22112 _then.call(ret,chain.resolve,chain.reject);
22113 }
22114 else {
22115 chain.resolve(ret);
22116 }
22117 }
22118 }
22119 catch (err) {
22120 chain.reject(err);
22121 }
22122 }
22123
22124 function resolve(msg) {
22125 var _then, self = this;
22126
22127 // already triggered?
22128 if (self.triggered) { return; }
22129
22130 self.triggered = true;
22131
22132 // unwrap
22133 if (self.def) {
22134 self = self.def;
22135 }
22136
22137 try {
22138 // eslint-disable-next-line no-cond-assign
22139 if (_then = isThenable(msg)) {
22140 schedule(function(){
22141 var defWrapper = new MakeDefWrapper(self);
22142 try {
22143 _then.call(msg,
22144 function $resolve$(){ resolve.apply(defWrapper,arguments); },
22145 function $reject$(){ reject.apply(defWrapper,arguments); }
22146 );
22147 }
22148 catch (err) {
22149 reject.call(defWrapper,err);
22150 }
22151 });
22152 }
22153 else {
22154 self.msg = msg;
22155 self.state = 1;
22156 if (self.chain.length > 0) {
22157 schedule(notify,self);
22158 }
22159 }
22160 }
22161 catch (err) {
22162 reject.call(new MakeDefWrapper(self),err);
22163 }
22164 }
22165
22166 function reject(msg) {
22167 var self = this;
22168
22169 // already triggered?
22170 if (self.triggered) { return; }
22171
22172 self.triggered = true;
22173
22174 // unwrap
22175 if (self.def) {
22176 self = self.def;
22177 }
22178
22179 self.msg = msg;
22180 self.state = 2;
22181 if (self.chain.length > 0) {
22182 schedule(notify,self);
22183 }
22184 }
22185
22186 function iteratePromises(Constructor,arr,resolver,rejecter) {
22187 for (var idx=0; idx<arr.length; idx++) {
22188 (function IIFE(idx){
22189 Constructor.resolve(arr[idx])
22190 .then(
22191 function $resolver$(msg){
22192 resolver(idx,msg);
22193 },
22194 rejecter
22195 );
22196 })(idx);
22197 }
22198 }
22199
22200 function MakeDefWrapper(self) {
22201 this.def = self;
22202 this.triggered = false;
22203 }
22204
22205 function MakeDef(self) {
22206 this.promise = self;
22207 this.state = 0;
22208 this.triggered = false;
22209 this.chain = [];
22210 this.msg = void 0;
22211 }
22212
22213 function NpoPromise(executor) {
22214 if (typeof executor !== 'function') {
22215 throw TypeError('Not a function');
22216 }
22217
22218 if (this['__NPO__'] !== 0) {
22219 throw TypeError('Not a promise');
22220 }
22221
22222 // instance shadowing the inherited "brand"
22223 // to signal an already "initialized" promise
22224 this['__NPO__'] = 1;
22225
22226 var def = new MakeDef(this);
22227
22228 this['then'] = function then(success,failure) {
22229 var o = {
22230 success: typeof success === 'function' ? success : true,
22231 failure: typeof failure === 'function' ? failure : false
22232 };
22233 // Note: `then(..)` itself can be borrowed to be used against
22234 // a different promise constructor for making the chained promise,
22235 // by substituting a different `this` binding.
22236 o.promise = new this.constructor(function extractChain(resolve,reject) {
22237 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22238 throw TypeError('Not a function');
22239 }
22240
22241 o.resolve = resolve;
22242 o.reject = reject;
22243 });
22244 def.chain.push(o);
22245
22246 if (def.state !== 0) {
22247 schedule(notify,def);
22248 }
22249
22250 return o.promise;
22251 };
22252 this['catch'] = function $catch$(failure) {
22253 return this.then(void 0,failure);
22254 };
22255
22256 try {
22257 executor.call(
22258 void 0,
22259 function publicResolve(msg){
22260 resolve.call(def,msg);
22261 },
22262 function publicReject(msg) {
22263 reject.call(def,msg);
22264 }
22265 );
22266 }
22267 catch (err) {
22268 reject.call(def,err);
22269 }
22270 }
22271
22272 var PromisePrototype = builtInProp({},'constructor',NpoPromise,
22273 /*configurable=*/false
22274 );
22275
22276 // Note: Android 4 cannot use `Object.defineProperty(..)` here
22277 NpoPromise.prototype = PromisePrototype;
22278
22279 // built-in "brand" to signal an "uninitialized" promise
22280 builtInProp(PromisePrototype,'__NPO__',0,
22281 /*configurable=*/false
22282 );
22283
22284 builtInProp(NpoPromise,'resolve',function Promise$resolve(msg) {
22285 var Constructor = this;
22286
22287 // spec mandated checks
22288 // note: best "isPromise" check that's practical for now
22289 if (msg && typeof msg === 'object' && msg['__NPO__'] === 1) {
22290 return msg;
22291 }
22292
22293 return new Constructor(function executor(resolve,reject){
22294 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22295 throw TypeError('Not a function');
22296 }
22297
22298 resolve(msg);
22299 });
22300 });
22301
22302 builtInProp(NpoPromise,'reject',function Promise$reject(msg) {
22303 return new this(function executor(resolve,reject){
22304 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22305 throw TypeError('Not a function');
22306 }
22307
22308 reject(msg);
22309 });
22310 });
22311
22312 builtInProp(NpoPromise,'all',function Promise$all(arr) {
22313 var Constructor = this;
22314
22315 // spec mandated checks
22316 if (ToString.call(arr) !== '[object Array]') {
22317 return Constructor.reject(TypeError('Not an array'));
22318 }
22319 if (arr.length === 0) {
22320 return Constructor.resolve([]);
22321 }
22322
22323 return new Constructor(function executor(resolve,reject){
22324 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22325 throw TypeError('Not a function');
22326 }
22327
22328 var len = arr.length, msgs = Array(len), count = 0;
22329
22330 iteratePromises(Constructor,arr,function resolver(idx,msg) {
22331 msgs[idx] = msg;
22332 if (++count === len) {
22333 resolve(msgs);
22334 }
22335 },reject);
22336 });
22337 });
22338
22339 builtInProp(NpoPromise,'race',function Promise$race(arr) {
22340 var Constructor = this;
22341
22342 // spec mandated checks
22343 if (ToString.call(arr) !== '[object Array]') {
22344 return Constructor.reject(TypeError('Not an array'));
22345 }
22346
22347 return new Constructor(function executor(resolve,reject){
22348 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22349 throw TypeError('Not a function');
22350 }
22351
22352 iteratePromises(Constructor,arr,function resolver(idx,msg){
22353 resolve(msg);
22354 },reject);
22355 });
22356 });
22357
22358 var PromisePolyfill;
22359 if (typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]') !== -1) {
22360 PromisePolyfill = Promise;
22361 } else {
22362 PromisePolyfill = NpoPromise;
22363 }
22364
22365 var Config = {
22366 DEBUG: false,
22367 LIB_VERSION: '2.71.1'
22368 };
22369
22370 /* eslint camelcase: "off", eqeqeq: "off" */
22371
22372 // Maximum allowed session recording length
22373 var MAX_RECORDING_MS = 24 * 60 * 60 * 1000; // 24 hours
22374 // Maximum allowed value for minimum session recording length
22375 var MAX_VALUE_FOR_MIN_RECORDING_MS = 8 * 1000; // 8 seconds
22376
22377 /*
22378 * Saved references to long variable names, so that closure compiler can
22379 * minimize file size.
22380 */
22381
22382 var ArrayProto = Array.prototype,
22383 FuncProto = Function.prototype,
22384 ObjProto = Object.prototype,
22385 slice = ArrayProto.slice,
22386 toString = ObjProto.toString,
22387 hasOwnProperty = ObjProto.hasOwnProperty,
22388 windowConsole = win.console,
22389 navigator = win.navigator,
22390 document$1 = win.document,
22391 windowOpera = win.opera,
22392 screen = win.screen,
22393 userAgent = navigator.userAgent;
22394
22395 var nativeBind = FuncProto.bind,
22396 nativeForEach = ArrayProto.forEach,
22397 nativeIndexOf = ArrayProto.indexOf,
22398 nativeMap = ArrayProto.map,
22399 nativeIsArray = Array.isArray,
22400 breaker = {};
22401
22402 var _ = {
22403 trim: function(str) {
22404 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
22405 return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
22406 }
22407 };
22408
22409 // Console override
22410 var console$1 = {
22411 /** @type {function(...*)} */
22412 log: function() {
22413 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22414 try {
22415 windowConsole.log.apply(windowConsole, arguments);
22416 } catch (err) {
22417 _.each(arguments, function(arg) {
22418 windowConsole.log(arg);
22419 });
22420 }
22421 }
22422 },
22423 /** @type {function(...*)} */
22424 warn: function() {
22425 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22426 var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
22427 try {
22428 windowConsole.warn.apply(windowConsole, args);
22429 } catch (err) {
22430 _.each(args, function(arg) {
22431 windowConsole.warn(arg);
22432 });
22433 }
22434 }
22435 },
22436 /** @type {function(...*)} */
22437 error: function() {
22438 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22439 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22440 try {
22441 windowConsole.error.apply(windowConsole, args);
22442 } catch (err) {
22443 _.each(args, function(arg) {
22444 windowConsole.error(arg);
22445 });
22446 }
22447 }
22448 },
22449 /** @type {function(...*)} */
22450 critical: function() {
22451 if (!_.isUndefined(windowConsole) && windowConsole) {
22452 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22453 try {
22454 windowConsole.error.apply(windowConsole, args);
22455 } catch (err) {
22456 _.each(args, function(arg) {
22457 windowConsole.error(arg);
22458 });
22459 }
22460 }
22461 }
22462 };
22463
22464 var log_func_with_prefix = function(func, prefix) {
22465 return function() {
22466 arguments[0] = '[' + prefix + '] ' + arguments[0];
22467 return func.apply(console$1, arguments);
22468 };
22469 };
22470 var console_with_prefix = function(prefix) {
22471 return {
22472 log: log_func_with_prefix(console$1.log, prefix),
22473 error: log_func_with_prefix(console$1.error, prefix),
22474 critical: log_func_with_prefix(console$1.critical, prefix)
22475 };
22476 };
22477
22478
22479 var safewrap = function(f) {
22480 return function() {
22481 try {
22482 return f.apply(this, arguments);
22483 } catch (e) {
22484 console$1.critical('Implementation error. Please turn on debug and contact support@mixpanel.com.');
22485 if (Config.DEBUG){
22486 console$1.critical(e);
22487 }
22488 }
22489 };
22490 };
22491
22492 var safewrapClass = function(klass) {
22493 var proto = klass.prototype;
22494 for (var func in proto) {
22495 if (typeof(proto[func]) === 'function') {
22496 proto[func] = safewrap(proto[func]);
22497 }
22498 }
22499 };
22500
22501
22502 // UNDERSCORE
22503 // Embed part of the Underscore Library
22504 _.bind = function(func, context) {
22505 var args, bound;
22506 if (nativeBind && func.bind === nativeBind) {
22507 return nativeBind.apply(func, slice.call(arguments, 1));
22508 }
22509 if (!_.isFunction(func)) {
22510 throw new TypeError();
22511 }
22512 args = slice.call(arguments, 2);
22513 bound = function() {
22514 if (!(this instanceof bound)) {
22515 return func.apply(context, args.concat(slice.call(arguments)));
22516 }
22517 var ctor = {};
22518 ctor.prototype = func.prototype;
22519 var self = new ctor();
22520 ctor.prototype = null;
22521 var result = func.apply(self, args.concat(slice.call(arguments)));
22522 if (Object(result) === result) {
22523 return result;
22524 }
22525 return self;
22526 };
22527 return bound;
22528 };
22529
22530 /**
22531 * @param {*=} obj
22532 * @param {function(...*)=} iterator
22533 * @param {Object=} context
22534 */
22535 _.each = function(obj, iterator, context) {
22536 if (obj === null || obj === undefined) {
22537 return;
22538 }
22539 if (nativeForEach && obj.forEach === nativeForEach) {
22540 obj.forEach(iterator, context);
22541 } else if (obj.length === +obj.length) {
22542 for (var i = 0, l = obj.length; i < l; i++) {
22543 if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
22544 return;
22545 }
22546 }
22547 } else {
22548 for (var key in obj) {
22549 if (hasOwnProperty.call(obj, key)) {
22550 if (iterator.call(context, obj[key], key, obj) === breaker) {
22551 return;
22552 }
22553 }
22554 }
22555 }
22556 };
22557
22558 _.extend = function(obj) {
22559 _.each(slice.call(arguments, 1), function(source) {
22560 for (var prop in source) {
22561 if (source[prop] !== void 0) {
22562 obj[prop] = source[prop];
22563 }
22564 }
22565 });
22566 return obj;
22567 };
22568
22569 _.isArray = nativeIsArray || function(obj) {
22570 return toString.call(obj) === '[object Array]';
22571 };
22572
22573 // from a comment on http://dbj.org/dbj/?p=286
22574 // fails on only one very rare and deliberate custom object:
22575 // var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
22576 _.isFunction = function(f) {
22577 try {
22578 return /^\s*\bfunction\b/.test(f);
22579 } catch (x) {
22580 return false;
22581 }
22582 };
22583
22584 _.isArguments = function(obj) {
22585 return !!(obj && hasOwnProperty.call(obj, 'callee'));
22586 };
22587
22588 _.toArray = function(iterable) {
22589 if (!iterable) {
22590 return [];
22591 }
22592 if (iterable.toArray) {
22593 return iterable.toArray();
22594 }
22595 if (_.isArray(iterable)) {
22596 return slice.call(iterable);
22597 }
22598 if (_.isArguments(iterable)) {
22599 return slice.call(iterable);
22600 }
22601 return _.values(iterable);
22602 };
22603
22604 _.map = function(arr, callback, context) {
22605 if (nativeMap && arr.map === nativeMap) {
22606 return arr.map(callback, context);
22607 } else {
22608 var results = [];
22609 _.each(arr, function(item) {
22610 results.push(callback.call(context, item));
22611 });
22612 return results;
22613 }
22614 };
22615
22616 _.keys = function(obj) {
22617 var results = [];
22618 if (obj === null) {
22619 return results;
22620 }
22621 _.each(obj, function(value, key) {
22622 results[results.length] = key;
22623 });
22624 return results;
22625 };
22626
22627 _.values = function(obj) {
22628 var results = [];
22629 if (obj === null) {
22630 return results;
22631 }
22632 _.each(obj, function(value) {
22633 results[results.length] = value;
22634 });
22635 return results;
22636 };
22637
22638 _.include = function(obj, target) {
22639 var found = false;
22640 if (obj === null) {
22641 return found;
22642 }
22643 if (nativeIndexOf && obj.indexOf === nativeIndexOf) {
22644 return obj.indexOf(target) != -1;
22645 }
22646 _.each(obj, function(value) {
22647 if (found || (found = (value === target))) {
22648 return breaker;
22649 }
22650 });
22651 return found;
22652 };
22653
22654 _.includes = function(str, needle) {
22655 return str.indexOf(needle) !== -1;
22656 };
22657
22658 // Underscore Addons
22659 _.inherit = function(subclass, superclass) {
22660 subclass.prototype = new superclass();
22661 subclass.prototype.constructor = subclass;
22662 subclass.superclass = superclass.prototype;
22663 return subclass;
22664 };
22665
22666 _.isObject = function(obj) {
22667 return (obj === Object(obj) && !_.isArray(obj));
22668 };
22669
22670 _.isEmptyObject = function(obj) {
22671 if (_.isObject(obj)) {
22672 for (var key in obj) {
22673 if (hasOwnProperty.call(obj, key)) {
22674 return false;
22675 }
22676 }
22677 return true;
22678 }
22679 return false;
22680 };
22681
22682 _.isUndefined = function(obj) {
22683 return obj === void 0;
22684 };
22685
22686 _.isString = function(obj) {
22687 return toString.call(obj) == '[object String]';
22688 };
22689
22690 _.isDate = function(obj) {
22691 return toString.call(obj) == '[object Date]';
22692 };
22693
22694 _.isNumber = function(obj) {
22695 return toString.call(obj) == '[object Number]';
22696 };
22697
22698 _.isElement = function(obj) {
22699 return !!(obj && obj.nodeType === 1);
22700 };
22701
22702 _.encodeDates = function(obj) {
22703 _.each(obj, function(v, k) {
22704 if (_.isDate(v)) {
22705 obj[k] = _.formatDate(v);
22706 } else if (_.isObject(v)) {
22707 obj[k] = _.encodeDates(v); // recurse
22708 }
22709 });
22710 return obj;
22711 };
22712
22713 _.timestamp = function() {
22714 Date.now = Date.now || function() {
22715 return +new Date;
22716 };
22717 return Date.now();
22718 };
22719
22720 _.formatDate = function(d) {
22721 // YYYY-MM-DDTHH:MM:SS in UTC
22722 function pad(n) {
22723 return n < 10 ? '0' + n : n;
22724 }
22725 return d.getUTCFullYear() + '-' +
22726 pad(d.getUTCMonth() + 1) + '-' +
22727 pad(d.getUTCDate()) + 'T' +
22728 pad(d.getUTCHours()) + ':' +
22729 pad(d.getUTCMinutes()) + ':' +
22730 pad(d.getUTCSeconds());
22731 };
22732
22733 _.strip_empty_properties = function(p) {
22734 var ret = {};
22735 _.each(p, function(v, k) {
22736 if (_.isString(v) && v.length > 0) {
22737 ret[k] = v;
22738 }
22739 });
22740 return ret;
22741 };
22742
22743 /*
22744 * this function returns a copy of object after truncating it. If
22745 * passed an Array or Object it will iterate through obj and
22746 * truncate all the values recursively.
22747 */
22748 _.truncate = function(obj, length) {
22749 var ret;
22750
22751 if (typeof(obj) === 'string') {
22752 ret = obj.slice(0, length);
22753 } else if (_.isArray(obj)) {
22754 ret = [];
22755 _.each(obj, function(val) {
22756 ret.push(_.truncate(val, length));
22757 });
22758 } else if (_.isObject(obj)) {
22759 ret = {};
22760 _.each(obj, function(val, key) {
22761 ret[key] = _.truncate(val, length);
22762 });
22763 } else {
22764 ret = obj;
22765 }
22766
22767 return ret;
22768 };
22769
22770 _.JSONEncode = (function() {
22771 return function(mixed_val) {
22772 var value = mixed_val;
22773 var quote = function(string) {
22774 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
22775 var meta = { // table of character substitutions
22776 '\b': '\\b',
22777 '\t': '\\t',
22778 '\n': '\\n',
22779 '\f': '\\f',
22780 '\r': '\\r',
22781 '"': '\\"',
22782 '\\': '\\\\'
22783 };
22784
22785 escapable.lastIndex = 0;
22786 return escapable.test(string) ?
22787 '"' + string.replace(escapable, function(a) {
22788 var c = meta[a];
22789 return typeof c === 'string' ? c :
22790 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
22791 }) + '"' :
22792 '"' + string + '"';
22793 };
22794
22795 var str = function(key, holder) {
22796 var gap = '';
22797 var indent = ' ';
22798 var i = 0; // The loop counter.
22799 var k = ''; // The member key.
22800 var v = ''; // The member value.
22801 var length = 0;
22802 var mind = gap;
22803 var partial = [];
22804 var value = holder[key];
22805
22806 // If the value has a toJSON method, call it to obtain a replacement value.
22807 if (value && typeof value === 'object' &&
22808 typeof value.toJSON === 'function') {
22809 value = value.toJSON(key);
22810 }
22811
22812 // What happens next depends on the value's type.
22813 switch (typeof value) {
22814 case 'string':
22815 return quote(value);
22816
22817 case 'number':
22818 // JSON numbers must be finite. Encode non-finite numbers as null.
22819 return isFinite(value) ? String(value) : 'null';
22820
22821 case 'boolean':
22822 case 'null':
22823 // If the value is a boolean or null, convert it to a string. Note:
22824 // typeof null does not produce 'null'. The case is included here in
22825 // the remote chance that this gets fixed someday.
22826
22827 return String(value);
22828
22829 case 'object':
22830 // If the type is 'object', we might be dealing with an object or an array or
22831 // null.
22832 // Due to a specification blunder in ECMAScript, typeof null is 'object',
22833 // so watch out for that case.
22834 if (!value) {
22835 return 'null';
22836 }
22837
22838 // Make an array to hold the partial results of stringifying this object value.
22839 gap += indent;
22840 partial = [];
22841
22842 // Is the value an array?
22843 if (toString.apply(value) === '[object Array]') {
22844 // The value is an array. Stringify every element. Use null as a placeholder
22845 // for non-JSON values.
22846
22847 length = value.length;
22848 for (i = 0; i < length; i += 1) {
22849 partial[i] = str(i, value) || 'null';
22850 }
22851
22852 // Join all of the elements together, separated with commas, and wrap them in
22853 // brackets.
22854 v = partial.length === 0 ? '[]' :
22855 gap ? '[\n' + gap +
22856 partial.join(',\n' + gap) + '\n' +
22857 mind + ']' :
22858 '[' + partial.join(',') + ']';
22859 gap = mind;
22860 return v;
22861 }
22862
22863 // Iterate through all of the keys in the object.
22864 for (k in value) {
22865 if (hasOwnProperty.call(value, k)) {
22866 v = str(k, value);
22867 if (v) {
22868 partial.push(quote(k) + (gap ? ': ' : ':') + v);
22869 }
22870 }
22871 }
22872
22873 // Join all of the member texts together, separated with commas,
22874 // and wrap them in braces.
22875 v = partial.length === 0 ? '{}' :
22876 gap ? '{' + partial.join(',') + '' +
22877 mind + '}' : '{' + partial.join(',') + '}';
22878 gap = mind;
22879 return v;
22880 }
22881 };
22882
22883 // Make a fake root object containing our value under the key of ''.
22884 // Return the result of stringifying the value.
22885 return str('', {
22886 '': value
22887 });
22888 };
22889 })();
22890
22891 /**
22892 * From https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
22893 * Slightly modified to throw a real Error rather than a POJO
22894 */
22895 _.JSONDecode = (function() {
22896 var at, // The index of the current character
22897 ch, // The current character
22898 escapee = {
22899 '"': '"',
22900 '\\': '\\',
22901 '/': '/',
22902 'b': '\b',
22903 'f': '\f',
22904 'n': '\n',
22905 'r': '\r',
22906 't': '\t'
22907 },
22908 text,
22909 error = function(m) {
22910 var e = new SyntaxError(m);
22911 e.at = at;
22912 e.text = text;
22913 throw e;
22914 },
22915 next = function(c) {
22916 // If a c parameter is provided, verify that it matches the current character.
22917 if (c && c !== ch) {
22918 error('Expected \'' + c + '\' instead of \'' + ch + '\'');
22919 }
22920 // Get the next character. When there are no more characters,
22921 // return the empty string.
22922 ch = text.charAt(at);
22923 at += 1;
22924 return ch;
22925 },
22926 number = function() {
22927 // Parse a number value.
22928 var number,
22929 string = '';
22930
22931 if (ch === '-') {
22932 string = '-';
22933 next('-');
22934 }
22935 while (ch >= '0' && ch <= '9') {
22936 string += ch;
22937 next();
22938 }
22939 if (ch === '.') {
22940 string += '.';
22941 while (next() && ch >= '0' && ch <= '9') {
22942 string += ch;
22943 }
22944 }
22945 if (ch === 'e' || ch === 'E') {
22946 string += ch;
22947 next();
22948 if (ch === '-' || ch === '+') {
22949 string += ch;
22950 next();
22951 }
22952 while (ch >= '0' && ch <= '9') {
22953 string += ch;
22954 next();
22955 }
22956 }
22957 number = +string;
22958 if (!isFinite(number)) {
22959 error('Bad number');
22960 } else {
22961 return number;
22962 }
22963 },
22964
22965 string = function() {
22966 // Parse a string value.
22967 var hex,
22968 i,
22969 string = '',
22970 uffff;
22971 // When parsing for string values, we must look for " and \ characters.
22972 if (ch === '"') {
22973 while (next()) {
22974 if (ch === '"') {
22975 next();
22976 return string;
22977 }
22978 if (ch === '\\') {
22979 next();
22980 if (ch === 'u') {
22981 uffff = 0;
22982 for (i = 0; i < 4; i += 1) {
22983 hex = parseInt(next(), 16);
22984 if (!isFinite(hex)) {
22985 break;
22986 }
22987 uffff = uffff * 16 + hex;
22988 }
22989 string += String.fromCharCode(uffff);
22990 } else if (typeof escapee[ch] === 'string') {
22991 string += escapee[ch];
22992 } else {
22993 break;
22994 }
22995 } else {
22996 string += ch;
22997 }
22998 }
22999 }
23000 error('Bad string');
23001 },
23002 white = function() {
23003 // Skip whitespace.
23004 while (ch && ch <= ' ') {
23005 next();
23006 }
23007 },
23008 word = function() {
23009 // true, false, or null.
23010 switch (ch) {
23011 case 't':
23012 next('t');
23013 next('r');
23014 next('u');
23015 next('e');
23016 return true;
23017 case 'f':
23018 next('f');
23019 next('a');
23020 next('l');
23021 next('s');
23022 next('e');
23023 return false;
23024 case 'n':
23025 next('n');
23026 next('u');
23027 next('l');
23028 next('l');
23029 return null;
23030 }
23031 error('Unexpected "' + ch + '"');
23032 },
23033 value, // Placeholder for the value function.
23034 array = function() {
23035 // Parse an array value.
23036 var array = [];
23037
23038 if (ch === '[') {
23039 next('[');
23040 white();
23041 if (ch === ']') {
23042 next(']');
23043 return array; // empty array
23044 }
23045 while (ch) {
23046 array.push(value());
23047 white();
23048 if (ch === ']') {
23049 next(']');
23050 return array;
23051 }
23052 next(',');
23053 white();
23054 }
23055 }
23056 error('Bad array');
23057 },
23058 object = function() {
23059 // Parse an object value.
23060 var key,
23061 object = {};
23062
23063 if (ch === '{') {
23064 next('{');
23065 white();
23066 if (ch === '}') {
23067 next('}');
23068 return object; // empty object
23069 }
23070 while (ch) {
23071 key = string();
23072 white();
23073 next(':');
23074 if (Object.hasOwnProperty.call(object, key)) {
23075 error('Duplicate key "' + key + '"');
23076 }
23077 object[key] = value();
23078 white();
23079 if (ch === '}') {
23080 next('}');
23081 return object;
23082 }
23083 next(',');
23084 white();
23085 }
23086 }
23087 error('Bad object');
23088 };
23089
23090 value = function() {
23091 // Parse a JSON value. It could be an object, an array, a string,
23092 // a number, or a word.
23093 white();
23094 switch (ch) {
23095 case '{':
23096 return object();
23097 case '[':
23098 return array();
23099 case '"':
23100 return string();
23101 case '-':
23102 return number();
23103 default:
23104 return ch >= '0' && ch <= '9' ? number() : word();
23105 }
23106 };
23107
23108 // Return the json_parse function. It will have access to all of the
23109 // above functions and variables.
23110 return function(source) {
23111 var result;
23112
23113 text = source;
23114 at = 0;
23115 ch = ' ';
23116 result = value();
23117 white();
23118 if (ch) {
23119 error('Syntax error');
23120 }
23121
23122 return result;
23123 };
23124 })();
23125
23126 _.base64Encode = function(data) {
23127 var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
23128 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
23129 ac = 0,
23130 enc = '',
23131 tmp_arr = [];
23132
23133 if (!data) {
23134 return data;
23135 }
23136
23137 data = _.utf8Encode(data);
23138
23139 do { // pack three octets into four hexets
23140 o1 = data.charCodeAt(i++);
23141 o2 = data.charCodeAt(i++);
23142 o3 = data.charCodeAt(i++);
23143
23144 bits = o1 << 16 | o2 << 8 | o3;
23145
23146 h1 = bits >> 18 & 0x3f;
23147 h2 = bits >> 12 & 0x3f;
23148 h3 = bits >> 6 & 0x3f;
23149 h4 = bits & 0x3f;
23150
23151 // use hexets to index into b64, and append result to encoded string
23152 tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
23153 } while (i < data.length);
23154
23155 enc = tmp_arr.join('');
23156
23157 switch (data.length % 3) {
23158 case 1:
23159 enc = enc.slice(0, -2) + '==';
23160 break;
23161 case 2:
23162 enc = enc.slice(0, -1) + '=';
23163 break;
23164 }
23165
23166 return enc;
23167 };
23168
23169 _.utf8Encode = function(string) {
23170 string = (string + '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
23171
23172 var utftext = '',
23173 start,
23174 end;
23175 var stringl = 0,
23176 n;
23177
23178 start = end = 0;
23179 stringl = string.length;
23180
23181 for (n = 0; n < stringl; n++) {
23182 var c1 = string.charCodeAt(n);
23183 var enc = null;
23184
23185 if (c1 < 128) {
23186 end++;
23187 } else if ((c1 > 127) && (c1 < 2048)) {
23188 enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128);
23189 } else {
23190 enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128);
23191 }
23192 if (enc !== null) {
23193 if (end > start) {
23194 utftext += string.substring(start, end);
23195 }
23196 utftext += enc;
23197 start = end = n + 1;
23198 }
23199 }
23200
23201 if (end > start) {
23202 utftext += string.substring(start, string.length);
23203 }
23204
23205 return utftext;
23206 };
23207
23208 _.UUID = function() {
23209 try {
23210 // use native Crypto API when available
23211 return win['crypto']['randomUUID']();
23212 } catch (err) {
23213 // fall back to generating our own UUID
23214 // based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
23215 var uuid = new Array(36);
23216 for (var i = 0; i < 36; i++) {
23217 uuid[i] = Math.floor(Math.random() * 16);
23218 }
23219 uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
23220 uuid[19] = uuid[19] &= -5; // set bit 6 of clock-seq-and-reserved to zero
23221 uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
23222 uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
23223
23224 return _.map(uuid, function(x) {
23225 return x.toString(16);
23226 }).join('');
23227 }
23228 };
23229
23230 // _.isBlockedUA()
23231 // This is to block various web spiders from executing our JS and
23232 // sending false tracking data
23233 var BLOCKED_UA_STRS = [
23234 'ahrefsbot',
23235 'ahrefssiteaudit',
23236 'amazonbot',
23237 'baiduspider',
23238 'bingbot',
23239 'bingpreview',
23240 'chrome-lighthouse',
23241 'facebookexternal',
23242 'petalbot',
23243 'pinterest',
23244 'screaming frog',
23245 'yahoo! slurp',
23246 'yandex',
23247
23248 // a whole bunch of goog-specific crawlers
23249 // https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
23250 'adsbot-google',
23251 'apis-google',
23252 'duplexweb-google',
23253 'feedfetcher-google',
23254 'google favicon',
23255 'google web preview',
23256 'google-read-aloud',
23257 'googlebot',
23258 'googleweblight',
23259 'mediapartners-google',
23260 'storebot-google'
23261 ];
23262 _.isBlockedUA = function(ua) {
23263 var i;
23264 ua = ua.toLowerCase();
23265 for (i = 0; i < BLOCKED_UA_STRS.length; i++) {
23266 if (ua.indexOf(BLOCKED_UA_STRS[i]) !== -1) {
23267 return true;
23268 }
23269 }
23270 return false;
23271 };
23272
23273 /**
23274 * @param {Object=} formdata
23275 * @param {string=} arg_separator
23276 */
23277 _.HTTPBuildQuery = function(formdata, arg_separator) {
23278 var use_val, use_key, tmp_arr = [];
23279
23280 if (_.isUndefined(arg_separator)) {
23281 arg_separator = '&';
23282 }
23283
23284 _.each(formdata, function(val, key) {
23285 use_val = encodeURIComponent(val.toString());
23286 use_key = encodeURIComponent(key);
23287 tmp_arr[tmp_arr.length] = use_key + '=' + use_val;
23288 });
23289
23290 return tmp_arr.join(arg_separator);
23291 };
23292
23293 _.getQueryParam = function(url, param) {
23294 // Expects a raw URL
23295
23296 param = param.replace(/[[]/g, '\\[').replace(/[\]]/g, '\\]');
23297 var regexS = '[\\?&]' + param + '=([^&#]*)',
23298 regex = new RegExp(regexS),
23299 results = regex.exec(url);
23300 if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
23301 return '';
23302 } else {
23303 var result = results[1];
23304 try {
23305 result = decodeURIComponent(result);
23306 } catch(err) {
23307 console$1.error('Skipping decoding for malformed query param: ' + result);
23308 }
23309 return result.replace(/\+/g, ' ');
23310 }
23311 };
23312
23313
23314 // _.cookie
23315 // Methods partially borrowed from quirksmode.org/js/cookies.html
23316 _.cookie = {
23317 get: function(name) {
23318 var nameEQ = name + '=';
23319 var ca = document$1.cookie.split(';');
23320 for (var i = 0; i < ca.length; i++) {
23321 var c = ca[i];
23322 while (c.charAt(0) == ' ') {
23323 c = c.substring(1, c.length);
23324 }
23325 if (c.indexOf(nameEQ) === 0) {
23326 return decodeURIComponent(c.substring(nameEQ.length, c.length));
23327 }
23328 }
23329 return null;
23330 },
23331
23332 parse: function(name) {
23333 var cookie;
23334 try {
23335 cookie = _.JSONDecode(_.cookie.get(name)) || {};
23336 } catch (err) {
23337 // noop
23338 }
23339 return cookie;
23340 },
23341
23342 set_seconds: function(name, value, seconds, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23343 var cdomain = '',
23344 expires = '',
23345 secure = '';
23346
23347 if (domain_override) {
23348 cdomain = '; domain=' + domain_override;
23349 } else if (is_cross_subdomain) {
23350 var domain = extract_domain(document$1.location.hostname);
23351 cdomain = domain ? '; domain=.' + domain : '';
23352 }
23353
23354 if (seconds) {
23355 var date = new Date();
23356 date.setTime(date.getTime() + (seconds * 1000));
23357 expires = '; expires=' + date.toGMTString();
23358 }
23359
23360 if (is_cross_site) {
23361 is_secure = true;
23362 secure = '; SameSite=None';
23363 }
23364 if (is_secure) {
23365 secure += '; secure';
23366 }
23367
23368 document$1.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23369 },
23370
23371 set: function(name, value, days, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23372 var cdomain = '', expires = '', secure = '';
23373
23374 if (domain_override) {
23375 cdomain = '; domain=' + domain_override;
23376 } else if (is_cross_subdomain) {
23377 var domain = extract_domain(document$1.location.hostname);
23378 cdomain = domain ? '; domain=.' + domain : '';
23379 }
23380
23381 if (days) {
23382 var date = new Date();
23383 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
23384 expires = '; expires=' + date.toGMTString();
23385 }
23386
23387 if (is_cross_site) {
23388 is_secure = true;
23389 secure = '; SameSite=None';
23390 }
23391 if (is_secure) {
23392 secure += '; secure';
23393 }
23394
23395 var new_cookie_val = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23396 document$1.cookie = new_cookie_val;
23397 return new_cookie_val;
23398 },
23399
23400 remove: function(name, is_cross_subdomain, domain_override) {
23401 _.cookie.set(name, '', -1, is_cross_subdomain, false, false, domain_override);
23402 }
23403 };
23404
23405 var _testStorageSupported = function (storage) {
23406 var supported = true;
23407 try {
23408 var key = '__mplss_' + cheap_guid(8),
23409 val = 'xyz';
23410 storage.setItem(key, val);
23411 if (storage.getItem(key) !== val) {
23412 supported = false;
23413 }
23414 storage.removeItem(key);
23415 } catch (err) {
23416 supported = false;
23417 }
23418 return supported;
23419 };
23420
23421 var _localStorageSupported = null;
23422 var localStorageSupported = function(storage, forceCheck) {
23423 if (_localStorageSupported !== null && !forceCheck) {
23424 return _localStorageSupported;
23425 }
23426 return _localStorageSupported = _testStorageSupported(storage || win.localStorage);
23427 };
23428
23429 var _sessionStorageSupported = null;
23430 var sessionStorageSupported = function(storage, forceCheck) {
23431 if (_sessionStorageSupported !== null && !forceCheck) {
23432 return _sessionStorageSupported;
23433 }
23434 return _sessionStorageSupported = _testStorageSupported(storage || win.sessionStorage);
23435 };
23436
23437 function _storageWrapper(storage, name, is_supported_fn) {
23438 var log_error = function(msg) {
23439 console$1.error(name + ' error: ' + msg);
23440 };
23441
23442 return {
23443 is_supported: function(forceCheck) {
23444 var supported = is_supported_fn(storage, forceCheck);
23445 if (!supported) {
23446 console$1.error(name + ' unsupported');
23447 }
23448 return supported;
23449 },
23450 error: log_error,
23451 get: function(key) {
23452 try {
23453 return storage.getItem(key);
23454 } catch (err) {
23455 log_error(err);
23456 }
23457 return null;
23458 },
23459 parse: function(key) {
23460 try {
23461 return _.JSONDecode(storage.getItem(key)) || {};
23462 } catch (err) {
23463 // noop
23464 }
23465 return null;
23466 },
23467 set: function(key, value) {
23468 try {
23469 storage.setItem(key, value);
23470 } catch (err) {
23471 log_error(err);
23472 }
23473 },
23474 remove: function(key) {
23475 try {
23476 storage.removeItem(key);
23477 } catch (err) {
23478 log_error(err);
23479 }
23480 }
23481 };
23482 }
23483
23484 _.localStorage = _storageWrapper(win.localStorage, 'localStorage', localStorageSupported);
23485 _.sessionStorage = _storageWrapper(win.sessionStorage, 'sessionStorage', sessionStorageSupported);
23486
23487 _.register_event = (function() {
23488 // written by Dean Edwards, 2005
23489 // with input from Tino Zijdel - crisp@xs4all.nl
23490 // with input from Carl Sverre - mail@carlsverre.com
23491 // with input from Mixpanel
23492 // http://dean.edwards.name/weblog/2005/10/add-event/
23493 // https://gist.github.com/1930440
23494
23495 /**
23496 * @param {Object} element
23497 * @param {string} type
23498 * @param {function(...*)} handler
23499 * @param {boolean=} oldSchool
23500 * @param {boolean=} useCapture
23501 */
23502 var register_event = function(element, type, handler, oldSchool, useCapture) {
23503 if (!element) {
23504 console$1.error('No valid element provided to register_event');
23505 return;
23506 }
23507
23508 if (element.addEventListener && !oldSchool) {
23509 element.addEventListener(type, handler, !!useCapture);
23510 } else {
23511 var ontype = 'on' + type;
23512 var old_handler = element[ontype]; // can be undefined
23513 element[ontype] = makeHandler(element, handler, old_handler);
23514 }
23515 };
23516
23517 function makeHandler(element, new_handler, old_handlers) {
23518 var handler = function(event) {
23519 event = event || fixEvent(win.event);
23520
23521 // this basically happens in firefox whenever another script
23522 // overwrites the onload callback and doesn't pass the event
23523 // object to previously defined callbacks. All the browsers
23524 // that don't define window.event implement addEventListener
23525 // so the dom_loaded handler will still be fired as usual.
23526 if (!event) {
23527 return undefined;
23528 }
23529
23530 var ret = true;
23531 var old_result, new_result;
23532
23533 if (_.isFunction(old_handlers)) {
23534 old_result = old_handlers(event);
23535 }
23536 new_result = new_handler.call(element, event);
23537
23538 if ((false === old_result) || (false === new_result)) {
23539 ret = false;
23540 }
23541
23542 return ret;
23543 };
23544
23545 return handler;
23546 }
23547
23548 function fixEvent(event) {
23549 if (event) {
23550 event.preventDefault = fixEvent.preventDefault;
23551 event.stopPropagation = fixEvent.stopPropagation;
23552 }
23553 return event;
23554 }
23555 fixEvent.preventDefault = function() {
23556 this.returnValue = false;
23557 };
23558 fixEvent.stopPropagation = function() {
23559 this.cancelBubble = true;
23560 };
23561
23562 return register_event;
23563 })();
23564
23565
23566 var TOKEN_MATCH_REGEX = new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');
23567
23568 _.dom_query = (function() {
23569 /* document.getElementsBySelector(selector)
23570 - returns an array of element objects from the current document
23571 matching the CSS selector. Selectors can contain element names,
23572 class names and ids and can be nested. For example:
23573
23574 elements = document.getElementsBySelector('div#main p a.external')
23575
23576 Will return an array of all 'a' elements with 'external' in their
23577 class attribute that are contained inside 'p' elements that are
23578 contained inside the 'div' element which has id="main"
23579
23580 New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
23581 See http://www.w3.org/TR/css3-selectors/#attribute-selectors
23582
23583 Version 0.4 - Simon Willison, March 25th 2003
23584 -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
23585 -- Opera 7 fails
23586
23587 Version 0.5 - Carl Sverre, Jan 7th 2013
23588 -- Now uses jQuery-esque `hasClass` for testing class name
23589 equality. This fixes a bug related to '-' characters being
23590 considered not part of a 'word' in regex.
23591 */
23592
23593 function getAllChildren(e) {
23594 // Returns all children of element. Workaround required for IE5/Windows. Ugh.
23595 return e.all ? e.all : e.getElementsByTagName('*');
23596 }
23597
23598 var bad_whitespace = /[\t\r\n]/g;
23599
23600 function hasClass(elem, selector) {
23601 var className = ' ' + selector + ' ';
23602 return ((' ' + elem.className + ' ').replace(bad_whitespace, ' ').indexOf(className) >= 0);
23603 }
23604
23605 function getElementsBySelector(selector) {
23606 // Attempt to fail gracefully in lesser browsers
23607 if (!document$1.getElementsByTagName) {
23608 return [];
23609 }
23610 // Split selector in to tokens
23611 var tokens = selector.split(' ');
23612 var token, bits, tagName, found, foundCount, i, j, k, elements, currentContextIndex;
23613 var currentContext = [document$1];
23614 for (i = 0; i < tokens.length; i++) {
23615 token = tokens[i].replace(/^\s+/, '').replace(/\s+$/, '');
23616 if (token.indexOf('#') > -1) {
23617 // Token is an ID selector
23618 bits = token.split('#');
23619 tagName = bits[0];
23620 var id = bits[1];
23621 var element = document$1.getElementById(id);
23622 if (!element || (tagName && element.nodeName.toLowerCase() != tagName)) {
23623 // element not found or tag with that ID not found, return false
23624 return [];
23625 }
23626 // Set currentContext to contain just this element
23627 currentContext = [element];
23628 continue; // Skip to next token
23629 }
23630 if (token.indexOf('.') > -1) {
23631 // Token contains a class selector
23632 bits = token.split('.');
23633 tagName = bits[0];
23634 var className = bits[1];
23635 if (!tagName) {
23636 tagName = '*';
23637 }
23638 // Get elements matching tag, filter them for class selector
23639 found = [];
23640 foundCount = 0;
23641 for (j = 0; j < currentContext.length; j++) {
23642 if (tagName == '*') {
23643 elements = getAllChildren(currentContext[j]);
23644 } else {
23645 elements = currentContext[j].getElementsByTagName(tagName);
23646 }
23647 for (k = 0; k < elements.length; k++) {
23648 found[foundCount++] = elements[k];
23649 }
23650 }
23651 currentContext = [];
23652 currentContextIndex = 0;
23653 for (j = 0; j < found.length; j++) {
23654 if (found[j].className &&
23655 _.isString(found[j].className) && // some SVG elements have classNames which are not strings
23656 hasClass(found[j], className)
23657 ) {
23658 currentContext[currentContextIndex++] = found[j];
23659 }
23660 }
23661 continue; // Skip to next token
23662 }
23663 // Code to deal with attribute selectors
23664 var token_match = token.match(TOKEN_MATCH_REGEX);
23665 if (token_match) {
23666 tagName = token_match[1];
23667 var attrName = token_match[2];
23668 var attrOperator = token_match[3];
23669 var attrValue = token_match[4];
23670 if (!tagName) {
23671 tagName = '*';
23672 }
23673 // Grab all of the tagName elements within current context
23674 found = [];
23675 foundCount = 0;
23676 for (j = 0; j < currentContext.length; j++) {
23677 if (tagName == '*') {
23678 elements = getAllChildren(currentContext[j]);
23679 } else {
23680 elements = currentContext[j].getElementsByTagName(tagName);
23681 }
23682 for (k = 0; k < elements.length; k++) {
23683 found[foundCount++] = elements[k];
23684 }
23685 }
23686 currentContext = [];
23687 currentContextIndex = 0;
23688 var checkFunction; // This function will be used to filter the elements
23689 switch (attrOperator) {
23690 case '=': // Equality
23691 checkFunction = function(e) {
23692 return (e.getAttribute(attrName) == attrValue);
23693 };
23694 break;
23695 case '~': // Match one of space seperated words
23696 checkFunction = function(e) {
23697 return (e.getAttribute(attrName).match(new RegExp('\\b' + attrValue + '\\b')));
23698 };
23699 break;
23700 case '|': // Match start with value followed by optional hyphen
23701 checkFunction = function(e) {
23702 return (e.getAttribute(attrName).match(new RegExp('^' + attrValue + '-?')));
23703 };
23704 break;
23705 case '^': // Match starts with value
23706 checkFunction = function(e) {
23707 return (e.getAttribute(attrName).indexOf(attrValue) === 0);
23708 };
23709 break;
23710 case '$': // Match ends with value - fails with "Warning" in Opera 7
23711 checkFunction = function(e) {
23712 return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length);
23713 };
23714 break;
23715 case '*': // Match ends with value
23716 checkFunction = function(e) {
23717 return (e.getAttribute(attrName).indexOf(attrValue) > -1);
23718 };
23719 break;
23720 default:
23721 // Just test for existence of attribute
23722 checkFunction = function(e) {
23723 return e.getAttribute(attrName);
23724 };
23725 }
23726 currentContext = [];
23727 currentContextIndex = 0;
23728 for (j = 0; j < found.length; j++) {
23729 if (checkFunction(found[j])) {
23730 currentContext[currentContextIndex++] = found[j];
23731 }
23732 }
23733 // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
23734 continue; // Skip to next token
23735 }
23736 // If we get here, token is JUST an element (not a class or ID selector)
23737 tagName = token;
23738 found = [];
23739 foundCount = 0;
23740 for (j = 0; j < currentContext.length; j++) {
23741 elements = currentContext[j].getElementsByTagName(tagName);
23742 for (k = 0; k < elements.length; k++) {
23743 found[foundCount++] = elements[k];
23744 }
23745 }
23746 currentContext = found;
23747 }
23748 return currentContext;
23749 }
23750
23751 return function(query) {
23752 if (_.isElement(query)) {
23753 return [query];
23754 } else if (_.isObject(query) && !_.isUndefined(query.length)) {
23755 return query;
23756 } else {
23757 return getElementsBySelector.call(this, query);
23758 }
23759 };
23760 })();
23761
23762 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'];
23763 var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'sccid', 'ttclid', 'twclid', 'wbraid'];
23764
23765 _.info = {
23766 campaignParams: function(default_value) {
23767 var kw = '',
23768 params = {};
23769 _.each(CAMPAIGN_KEYWORDS, function(kwkey) {
23770 kw = _.getQueryParam(document$1.URL, kwkey);
23771 if (kw.length) {
23772 params[kwkey] = kw;
23773 } else if (default_value !== undefined) {
23774 params[kwkey] = default_value;
23775 }
23776 });
23777
23778 return params;
23779 },
23780
23781 clickParams: function() {
23782 var id = '',
23783 params = {};
23784 _.each(CLICK_IDS, function(idkey) {
23785 id = _.getQueryParam(document$1.URL, idkey);
23786 if (id.length) {
23787 params[idkey] = id;
23788 }
23789 });
23790
23791 return params;
23792 },
23793
23794 marketingParams: function() {
23795 return _.extend(_.info.campaignParams(), _.info.clickParams());
23796 },
23797
23798 searchEngine: function(referrer) {
23799 if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
23800 return 'google';
23801 } else if (referrer.search('https?://(.*)bing.com') === 0) {
23802 return 'bing';
23803 } else if (referrer.search('https?://(.*)yahoo.com') === 0) {
23804 return 'yahoo';
23805 } else if (referrer.search('https?://(.*)duckduckgo.com') === 0) {
23806 return 'duckduckgo';
23807 } else {
23808 return null;
23809 }
23810 },
23811
23812 searchInfo: function(referrer) {
23813 var search = _.info.searchEngine(referrer),
23814 param = (search != 'yahoo') ? 'q' : 'p',
23815 ret = {};
23816
23817 if (search !== null) {
23818 ret['$search_engine'] = search;
23819
23820 var keyword = _.getQueryParam(referrer, param);
23821 if (keyword.length) {
23822 ret['mp_keyword'] = keyword;
23823 }
23824 }
23825
23826 return ret;
23827 },
23828
23829 /**
23830 * This function detects which browser is running this script.
23831 * The order of the checks are important since many user agents
23832 * include key words used in later checks.
23833 */
23834 browser: function(user_agent, vendor, opera) {
23835 vendor = vendor || ''; // vendor is undefined for at least IE9
23836 if (opera || _.includes(user_agent, ' OPR/')) {
23837 if (_.includes(user_agent, 'Mini')) {
23838 return 'Opera Mini';
23839 }
23840 return 'Opera';
23841 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
23842 return 'BlackBerry';
23843 } else if (_.includes(user_agent, 'IEMobile') || _.includes(user_agent, 'WPDesktop')) {
23844 return 'Internet Explorer Mobile';
23845 } else if (_.includes(user_agent, 'SamsungBrowser/')) {
23846 // https://developer.samsung.com/internet/user-agent-string-format
23847 return 'Samsung Internet';
23848 } else if (_.includes(user_agent, 'Edge') || _.includes(user_agent, 'Edg/')) {
23849 return 'Microsoft Edge';
23850 } else if (_.includes(user_agent, 'FBIOS')) {
23851 return 'Facebook Mobile';
23852 } else if (_.includes(user_agent, 'Whale/')) {
23853 // https://user-agents.net/browsers/whale-browser
23854 return 'Whale Browser';
23855 } else if (_.includes(user_agent, 'Chrome')) {
23856 return 'Chrome';
23857 } else if (_.includes(user_agent, 'CriOS')) {
23858 return 'Chrome iOS';
23859 } else if (_.includes(user_agent, 'UCWEB') || _.includes(user_agent, 'UCBrowser')) {
23860 return 'UC Browser';
23861 } else if (_.includes(user_agent, 'FxiOS')) {
23862 return 'Firefox iOS';
23863 } else if (_.includes(vendor, 'Apple')) {
23864 if (_.includes(user_agent, 'Mobile')) {
23865 return 'Mobile Safari';
23866 }
23867 return 'Safari';
23868 } else if (_.includes(user_agent, 'Android')) {
23869 return 'Android Mobile';
23870 } else if (_.includes(user_agent, 'Konqueror')) {
23871 return 'Konqueror';
23872 } else if (_.includes(user_agent, 'Firefox')) {
23873 return 'Firefox';
23874 } else if (_.includes(user_agent, 'MSIE') || _.includes(user_agent, 'Trident/')) {
23875 return 'Internet Explorer';
23876 } else if (_.includes(user_agent, 'Gecko')) {
23877 return 'Mozilla';
23878 } else {
23879 return '';
23880 }
23881 },
23882
23883 /**
23884 * This function detects which browser version is running this script,
23885 * parsing major and minor version (e.g., 42.1). User agent strings from:
23886 * http://www.useragentstring.com/pages/useragentstring.php
23887 */
23888 browserVersion: function(userAgent, vendor, opera) {
23889 var browser = _.info.browser(userAgent, vendor, opera);
23890 var versionRegexs = {
23891 'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/,
23892 'Microsoft Edge': /Edge?\/(\d+(\.\d+)?)/,
23893 'Chrome': /Chrome\/(\d+(\.\d+)?)/,
23894 'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/,
23895 'UC Browser' : /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,
23896 'Safari': /Version\/(\d+(\.\d+)?)/,
23897 'Mobile Safari': /Version\/(\d+(\.\d+)?)/,
23898 'Opera': /(Opera|OPR)\/(\d+(\.\d+)?)/,
23899 'Firefox': /Firefox\/(\d+(\.\d+)?)/,
23900 'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/,
23901 'Konqueror': /Konqueror:(\d+(\.\d+)?)/,
23902 'BlackBerry': /BlackBerry (\d+(\.\d+)?)/,
23903 'Android Mobile': /android\s(\d+(\.\d+)?)/,
23904 'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
23905 'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
23906 'Mozilla': /rv:(\d+(\.\d+)?)/,
23907 'Whale Browser': /Whale\/(\d+(\.\d+)?)/
23908 };
23909 var regex = versionRegexs[browser];
23910 if (regex === undefined) {
23911 return null;
23912 }
23913 var matches = userAgent.match(regex);
23914 if (!matches) {
23915 return null;
23916 }
23917 return parseFloat(matches[matches.length - 2]);
23918 },
23919
23920 os: function() {
23921 var a = userAgent;
23922 if (/Windows/i.test(a)) {
23923 if (/Phone/.test(a) || /WPDesktop/.test(a)) {
23924 return 'Windows Phone';
23925 }
23926 return 'Windows';
23927 } else if (/(iPhone|iPad|iPod)/.test(a)) {
23928 return 'iOS';
23929 } else if (/Android/.test(a)) {
23930 return 'Android';
23931 } else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {
23932 return 'BlackBerry';
23933 } else if (/Mac/i.test(a)) {
23934 return 'Mac OS X';
23935 } else if (/Linux/.test(a)) {
23936 return 'Linux';
23937 } else if (/CrOS/.test(a)) {
23938 return 'Chrome OS';
23939 } else {
23940 return '';
23941 }
23942 },
23943
23944 device: function(user_agent) {
23945 if (/Windows Phone/i.test(user_agent) || /WPDesktop/.test(user_agent)) {
23946 return 'Windows Phone';
23947 } else if (/iPad/.test(user_agent)) {
23948 return 'iPad';
23949 } else if (/iPod/.test(user_agent)) {
23950 return 'iPod Touch';
23951 } else if (/iPhone/.test(user_agent)) {
23952 return 'iPhone';
23953 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
23954 return 'BlackBerry';
23955 } else if (/Android/.test(user_agent)) {
23956 return 'Android';
23957 } else {
23958 return '';
23959 }
23960 },
23961
23962 referringDomain: function(referrer) {
23963 var split = referrer.split('/');
23964 if (split.length >= 3) {
23965 return split[2];
23966 }
23967 return '';
23968 },
23969
23970 currentUrl: function() {
23971 return win.location.href;
23972 },
23973
23974 properties: function(extra_props) {
23975 if (typeof extra_props !== 'object') {
23976 extra_props = {};
23977 }
23978 return _.extend(_.strip_empty_properties({
23979 '$os': _.info.os(),
23980 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
23981 '$referrer': document$1.referrer,
23982 '$referring_domain': _.info.referringDomain(document$1.referrer),
23983 '$device': _.info.device(userAgent)
23984 }), {
23985 '$current_url': _.info.currentUrl(),
23986 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera),
23987 '$screen_height': screen.height,
23988 '$screen_width': screen.width,
23989 'mp_lib': 'web',
23990 '$lib_version': Config.LIB_VERSION,
23991 '$insert_id': cheap_guid(),
23992 'time': _.timestamp() / 1000 // epoch time in seconds
23993 }, _.strip_empty_properties(extra_props));
23994 },
23995
23996 people_properties: function() {
23997 return _.extend(_.strip_empty_properties({
23998 '$os': _.info.os(),
23999 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera)
24000 }), {
24001 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera)
24002 });
24003 },
24004
24005 mpPageViewProperties: function() {
24006 return _.strip_empty_properties({
24007 'current_page_title': document$1.title,
24008 'current_domain': win.location.hostname,
24009 'current_url_path': win.location.pathname,
24010 'current_url_protocol': win.location.protocol,
24011 'current_url_search': win.location.search
24012 });
24013 }
24014 };
24015
24016 /**
24017 * Returns a throttled function that will only run at most every `waitMs` and returns a promise that resolves with the next invocation.
24018 * Throttled calls will build up a batch of args and invoke the callback with all args since the last invocation.
24019 */
24020 var batchedThrottle = function (fn, waitMs) {
24021 var timeoutPromise = null;
24022 var throttledItems = [];
24023 return function (item) {
24024 var self = this;
24025 throttledItems.push(item);
24026
24027 if (!timeoutPromise) {
24028 timeoutPromise = new PromisePolyfill(function (resolve) {
24029 setTimeout(function () {
24030 var returnValue = fn.apply(self, [throttledItems]);
24031 timeoutPromise = null;
24032 throttledItems = [];
24033 resolve(returnValue);
24034 }, waitMs);
24035 });
24036 }
24037 return timeoutPromise;
24038 };
24039 };
24040
24041 var cheap_guid = function(maxlen) {
24042 var guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
24043 return maxlen ? guid.substring(0, maxlen) : guid;
24044 };
24045
24046 /**
24047 * Generates a W3C traceparent header for easy interop with distributed tracing systems i.e Open Telemetry
24048 * https://www.w3.org/TR/trace-context/#traceparent-header
24049 */
24050 var generateTraceparent = function() {
24051 var traceID = _.UUID().replace(/-/g, '');
24052 var parentID = _.UUID().replace(/-/g, '').substring(0, 16);
24053
24054 // Sampled trace
24055 var traceFlags = '01';
24056
24057 return '00-' + traceID + '-' + parentID + '-' + traceFlags;
24058 };
24059
24060 // naive way to extract domain name (example.com) from full hostname (my.sub.example.com)
24061 var SIMPLE_DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]*\.[a-z]+$/i;
24062 // this next one attempts to account for some ccSLDs, e.g. extracting oxford.ac.uk from www.oxford.ac.uk
24063 var DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;
24064 /**
24065 * Attempts to extract main domain name from full hostname, using a few blunt heuristics. For
24066 * common TLDs like .com/.org that always have a simple SLD.TLD structure (example.com), we
24067 * simply extract the last two .-separated parts of the hostname (SIMPLE_DOMAIN_MATCH_REGEX).
24068 * For others, we attempt to account for short ccSLD+TLD combos (.ac.uk) with the legacy
24069 * DOMAIN_MATCH_REGEX (kept to maintain backwards compatibility with existing Mixpanel
24070 * integrations). The only _reliable_ way to extract domain from hostname is with an up-to-date
24071 * list like at https://publicsuffix.org/ so for cases that this helper fails at, the SDK
24072 * offers the 'cookie_domain' config option to set it explicitly.
24073 * @example
24074 * extract_domain('my.sub.example.com')
24075 * // 'example.com'
24076 */
24077 var extract_domain = function(hostname) {
24078 var domain_regex = DOMAIN_MATCH_REGEX;
24079 var parts = hostname.split('.');
24080 var tld = parts[parts.length - 1];
24081 if (tld.length > 4 || tld === 'com' || tld === 'org') {
24082 domain_regex = SIMPLE_DOMAIN_MATCH_REGEX;
24083 }
24084 var matches = hostname.match(domain_regex);
24085 return matches ? matches[0] : '';
24086 };
24087
24088 /**
24089 * Check whether we have network connection. default to true for browsers that don't support navigator.onLine (IE)
24090 * @returns {boolean}
24091 */
24092 var isOnline = function() {
24093 var onLine = win.navigator['onLine'];
24094 return _.isUndefined(onLine) || onLine;
24095 };
24096
24097 var NOOP_FUNC = function () {};
24098
24099 var JSONStringify = null, JSONParse = null;
24100 if (typeof JSON !== 'undefined') {
24101 JSONStringify = JSON.stringify;
24102 JSONParse = JSON.parse;
24103 }
24104 JSONStringify = JSONStringify || _.JSONEncode;
24105 JSONParse = JSONParse || _.JSONDecode;
24106
24107 // UNMINIFIED EXPORTS (for closure compiler)
24108 _['info'] = _.info;
24109 _['info']['browser'] = _.info.browser;
24110 _['info']['browserVersion'] = _.info.browserVersion;
24111 _['info']['device'] = _.info.device;
24112 _['info']['properties'] = _.info.properties;
24113 _['isBlockedUA'] = _.isBlockedUA;
24114 _['isEmptyObject'] = _.isEmptyObject;
24115 _['isObject'] = _.isObject;
24116 _['JSONDecode'] = _.JSONDecode;
24117 _['JSONEncode'] = _.JSONEncode;
24118 _['toArray'] = _.toArray;
24119 _['NPO'] = NpoPromise;
24120
24121 var MIXPANEL_DB_NAME = 'mixpanelBrowserDb';
24122
24123 var RECORDING_EVENTS_STORE_NAME = 'mixpanelRecordingEvents';
24124 var RECORDING_REGISTRY_STORE_NAME = 'mixpanelRecordingRegistry';
24125
24126 // note: increment the version number when adding new object stores
24127 var DB_VERSION = 1;
24128 var OBJECT_STORES = [RECORDING_EVENTS_STORE_NAME, RECORDING_REGISTRY_STORE_NAME];
24129
24130 /**
24131 * @type {import('./wrapper').StorageWrapper}
24132 */
24133 var IDBStorageWrapper = function (storeName) {
24134 /**
24135 * @type {Promise<IDBDatabase>|null}
24136 */
24137 this.dbPromise = null;
24138 this.storeName = storeName;
24139 };
24140
24141 IDBStorageWrapper.prototype._openDb = function () {
24142 return new PromisePolyfill(function (resolve, reject) {
24143 var openRequest = win.indexedDB.open(MIXPANEL_DB_NAME, DB_VERSION);
24144 openRequest['onerror'] = function () {
24145 reject(openRequest.error);
24146 };
24147
24148 openRequest['onsuccess'] = function () {
24149 resolve(openRequest.result);
24150 };
24151
24152 openRequest['onupgradeneeded'] = function (ev) {
24153 var db = ev.target.result;
24154
24155 OBJECT_STORES.forEach(function (storeName) {
24156 db.createObjectStore(storeName);
24157 });
24158 };
24159 });
24160 };
24161
24162 IDBStorageWrapper.prototype.init = function () {
24163 if (!win.indexedDB) {
24164 return PromisePolyfill.reject('indexedDB is not supported in this browser');
24165 }
24166
24167 if (!this.dbPromise) {
24168 this.dbPromise = this._openDb();
24169 }
24170
24171 return this.dbPromise
24172 .then(function (dbOrError) {
24173 if (dbOrError instanceof win['IDBDatabase']) {
24174 return PromisePolyfill.resolve();
24175 } else {
24176 return PromisePolyfill.reject(dbOrError);
24177 }
24178 });
24179 };
24180
24181 IDBStorageWrapper.prototype.isInitialized = function () {
24182 return !!this.dbPromise;
24183 };
24184
24185 /**
24186 * @param {IDBTransactionMode} mode
24187 * @param {function(IDBObjectStore): void} storeCb
24188 */
24189 IDBStorageWrapper.prototype.makeTransaction = function (mode, storeCb) {
24190 var storeName = this.storeName;
24191 var doTransaction = function (db) {
24192 return new PromisePolyfill(function (resolve, reject) {
24193 var transaction = db.transaction(storeName, mode);
24194 transaction.oncomplete = function () {
24195 resolve(transaction);
24196 };
24197 transaction.onabort = transaction.onerror = function () {
24198 reject(transaction.error);
24199 };
24200
24201 storeCb(transaction.objectStore(storeName));
24202 });
24203 };
24204
24205 return this.dbPromise
24206 .then(doTransaction)
24207 .catch(function (err) {
24208 if (err && err['name'] === 'InvalidStateError') {
24209 // try reopening the DB if the connection is closed
24210 this.dbPromise = this._openDb();
24211 return this.dbPromise.then(doTransaction);
24212 } else {
24213 return PromisePolyfill.reject(err);
24214 }
24215 }.bind(this));
24216 };
24217
24218 IDBStorageWrapper.prototype.setItem = function (key, value) {
24219 return this.makeTransaction('readwrite', function (objectStore) {
24220 objectStore.put(value, key);
24221 });
24222 };
24223
24224 IDBStorageWrapper.prototype.getItem = function (key) {
24225 var req;
24226 return this.makeTransaction('readonly', function (objectStore) {
24227 req = objectStore.get(key);
24228 }).then(function () {
24229 return req.result;
24230 });
24231 };
24232
24233 IDBStorageWrapper.prototype.removeItem = function (key) {
24234 return this.makeTransaction('readwrite', function (objectStore) {
24235 objectStore.delete(key);
24236 });
24237 };
24238
24239 IDBStorageWrapper.prototype.getAll = function () {
24240 var req;
24241 return this.makeTransaction('readonly', function (objectStore) {
24242 req = objectStore.getAll();
24243 }).then(function () {
24244 return req.result;
24245 });
24246 };
24247
24248 /**
24249 * GDPR utils
24250 *
24251 * The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
24252 * and privacy for all individuals within the European Union. It addresses the export of personal
24253 * data outside the EU. The GDPR aims primarily to give control back to citizens and residents
24254 * over their personal data and to simplify the regulatory environment for international business
24255 * by unifying the regulation within the EU.
24256 *
24257 * This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
24258 * These functions are used internally by the SDK and are not intended to be publicly exposed.
24259 */
24260
24261
24262 /**
24263 * A function used to track a Mixpanel event (e.g. MixpanelLib.track)
24264 * @callback trackFunction
24265 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
24266 * @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.
24267 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
24268 */
24269
24270 /** Public **/
24271
24272 var GDPR_DEFAULT_PERSISTENCE_PREFIX = '__mp_opt_in_out_';
24273
24274 /**
24275 * Opt the user in to data tracking and cookies/localstorage for the given token
24276 * @param {string} token - Mixpanel project tracking token
24277 * @param {Object} [options]
24278 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24279 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24280 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24281 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24282 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24283 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24284 * @param {string} [options.cookieDomain] - custom cookie domain
24285 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24286 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24287 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24288 */
24289 function optIn(token, options) {
24290 _optInOut(true, token, options);
24291 }
24292
24293 /**
24294 * Opt the user out of data tracking and cookies/localstorage for the given token
24295 * @param {string} token - Mixpanel project tracking token
24296 * @param {Object} [options]
24297 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24298 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24299 * @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires
24300 * @param {string} [options.cookieDomain] - custom cookie domain
24301 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24302 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not
24303 * @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not
24304 */
24305 function optOut(token, options) {
24306 _optInOut(false, token, options);
24307 }
24308
24309 /**
24310 * Check whether the user has opted in to data tracking and cookies/localstorage for the given token
24311 * @param {string} token - Mixpanel project tracking token
24312 * @param {Object} [options]
24313 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24314 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24315 * @returns {boolean} whether the user has opted in to the given opt type
24316 */
24317 function hasOptedIn(token, options) {
24318 return _getStorageValue(token, options) === '1';
24319 }
24320
24321 /**
24322 * Check whether the user has opted out of data tracking and cookies/localstorage for the given token
24323 * @param {string} token - Mixpanel project tracking token
24324 * @param {Object} [options]
24325 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24326 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24327 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24328 * @returns {boolean} whether the user has opted out of the given opt type
24329 */
24330 function hasOptedOut(token, options) {
24331 if (_hasDoNotTrackFlagOn(options)) {
24332 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"');
24333 return true;
24334 }
24335 var optedOut = _getStorageValue(token, options) === '0';
24336 if (optedOut) {
24337 console$1.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
24338 }
24339 return optedOut;
24340 }
24341
24342 /**
24343 * Wrap a MixpanelLib method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24344 * If the user has opted out, return early instead of executing the method.
24345 * If a callback argument was provided, execute it passing the 0 error code.
24346 * @param {function} method - wrapped method to be executed if the user has not opted out
24347 * @returns {*} the result of executing method OR undefined if the user has opted out
24348 */
24349 function addOptOutCheckMixpanelLib(method) {
24350 return _addOptOutCheck(method, function(name) {
24351 return this.get_config(name);
24352 });
24353 }
24354
24355 /**
24356 * Wrap a MixpanelPeople method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24357 * If the user has opted out, return early instead of executing the method.
24358 * If a callback argument was provided, execute it passing the 0 error code.
24359 * @param {function} method - wrapped method to be executed if the user has not opted out
24360 * @returns {*} the result of executing method OR undefined if the user has opted out
24361 */
24362 function addOptOutCheckMixpanelPeople(method) {
24363 return _addOptOutCheck(method, function(name) {
24364 return this._get_config(name);
24365 });
24366 }
24367
24368 /**
24369 * Wrap a MixpanelGroup method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24370 * If the user has opted out, return early instead of executing the method.
24371 * If a callback argument was provided, execute it passing the 0 error code.
24372 * @param {function} method - wrapped method to be executed if the user has not opted out
24373 * @returns {*} the result of executing method OR undefined if the user has opted out
24374 */
24375 function addOptOutCheckMixpanelGroup(method) {
24376 return _addOptOutCheck(method, function(name) {
24377 return this._get_config(name);
24378 });
24379 }
24380
24381 /**
24382 * Clear the user's opt in/out status of data tracking and cookies/localstorage for the given token
24383 * @param {string} token - Mixpanel project tracking token
24384 * @param {Object} [options]
24385 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24386 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24387 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24388 * @param {string} [options.cookieDomain] - custom cookie domain
24389 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24390 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24391 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24392 */
24393 function clearOptInOut(token, options) {
24394 options = options || {};
24395 _getStorage(options).remove(
24396 _getStorageKey(token, options), !!options.crossSubdomainCookie, options.cookieDomain
24397 );
24398 }
24399
24400 /** Private **/
24401
24402 /**
24403 * Get storage util
24404 * @param {Object} [options]
24405 * @param {string} [options.persistenceType]
24406 * @returns {object} either _.cookie or _.localstorage
24407 */
24408 function _getStorage(options) {
24409 options = options || {};
24410 return options.persistenceType === 'localStorage' ? _.localStorage : _.cookie;
24411 }
24412
24413 /**
24414 * Get the name of the cookie that is used for the given opt type (tracking, cookie, etc.)
24415 * @param {string} token - Mixpanel project tracking token
24416 * @param {Object} [options]
24417 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24418 * @returns {string} the name of the cookie for the given opt type
24419 */
24420 function _getStorageKey(token, options) {
24421 options = options || {};
24422 return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
24423 }
24424
24425 /**
24426 * Get the value of the cookie that is used for the given opt type (tracking, cookie, etc.)
24427 * @param {string} token - Mixpanel project tracking token
24428 * @param {Object} [options]
24429 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24430 * @returns {string} the value of the cookie for the given opt type
24431 */
24432 function _getStorageValue(token, options) {
24433 return _getStorage(options).get(_getStorageKey(token, options));
24434 }
24435
24436 /**
24437 * Check whether the user has set the DNT/doNotTrack setting to true in their browser
24438 * @param {Object} [options]
24439 * @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests
24440 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24441 * @returns {boolean} whether the DNT setting is true
24442 */
24443 function _hasDoNotTrackFlagOn(options) {
24444 if (options && options.ignoreDnt) {
24445 return false;
24446 }
24447 var win$1 = (options && options.window) || win;
24448 var nav = win$1['navigator'] || {};
24449 var hasDntOn = false;
24450
24451 _.each([
24452 nav['doNotTrack'], // standard
24453 nav['msDoNotTrack'],
24454 win$1['doNotTrack']
24455 ], function(dntValue) {
24456 if (_.includes([true, 1, '1', 'yes'], dntValue)) {
24457 hasDntOn = true;
24458 }
24459 });
24460
24461 return hasDntOn;
24462 }
24463
24464 /**
24465 * Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type
24466 * @param {boolean} optValue - whether to opt the user in or out for the given opt type
24467 * @param {string} token - Mixpanel project tracking token
24468 * @param {Object} [options]
24469 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24470 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24471 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24472 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24473 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24474 * @param {string} [options.cookieDomain] - custom cookie domain
24475 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24476 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24477 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24478 */
24479 function _optInOut(optValue, token, options) {
24480 if (!_.isString(token) || !token.length) {
24481 console$1.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token');
24482 return;
24483 }
24484
24485 options = options || {};
24486
24487 _getStorage(options).set(
24488 _getStorageKey(token, options),
24489 optValue ? 1 : 0,
24490 _.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
24491 !!options.crossSubdomainCookie,
24492 !!options.secureCookie,
24493 !!options.crossSiteCookie,
24494 options.cookieDomain
24495 );
24496
24497 if (options.track && optValue) { // only track event if opting in (optValue=true)
24498 options.track(options.trackEventName || '$opt_in', options.trackProperties, {
24499 'send_immediately': true
24500 });
24501 }
24502 }
24503
24504 /**
24505 * Wrap a method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24506 * If the user has opted out, return early instead of executing the method.
24507 * If a callback argument was provided, execute it passing the 0 error code.
24508 * @param {function} method - wrapped method to be executed if the user has not opted out
24509 * @param {function} getConfigValue - getter function for the Mixpanel API token and other options to be used with opt-out check
24510 * @returns {*} the result of executing method OR undefined if the user has opted out
24511 */
24512 function _addOptOutCheck(method, getConfigValue) {
24513 return function() {
24514 var optedOut = false;
24515
24516 try {
24517 var token = getConfigValue.call(this, 'token');
24518 var ignoreDnt = getConfigValue.call(this, 'ignore_dnt');
24519 var persistenceType = getConfigValue.call(this, 'opt_out_tracking_persistence_type');
24520 var persistencePrefix = getConfigValue.call(this, 'opt_out_tracking_cookie_prefix');
24521 var win = getConfigValue.call(this, 'window'); // used to override window during browser tests
24522
24523 if (token) { // if there was an issue getting the token, continue method execution as normal
24524 optedOut = hasOptedOut(token, {
24525 ignoreDnt: ignoreDnt,
24526 persistenceType: persistenceType,
24527 persistencePrefix: persistencePrefix,
24528 window: win
24529 });
24530 }
24531 } catch(err) {
24532 console$1.error('Unexpected error when checking tracking opt-out status: ' + err);
24533 }
24534
24535 if (!optedOut) {
24536 return method.apply(this, arguments);
24537 }
24538
24539 var callback = arguments[arguments.length - 1];
24540 if (typeof(callback) === 'function') {
24541 callback(0);
24542 }
24543
24544 return;
24545 };
24546 }
24547
24548 var logger$6 = console_with_prefix('lock');
24549
24550 /**
24551 * SharedLock: a mutex built on HTML5 localStorage, to ensure that only one browser
24552 * window/tab at a time will be able to access shared resources.
24553 *
24554 * Based on the Alur and Taubenfeld fast lock
24555 * (http://www.cs.rochester.edu/research/synchronization/pseudocode/fastlock.html)
24556 * with an added timeout to ensure there will be eventual progress in the event
24557 * that a window is closed in the middle of the callback.
24558 *
24559 * Implementation based on the original version by David Wolever (https://github.com/wolever)
24560 * at https://gist.github.com/wolever/5fd7573d1ef6166e8f8c4af286a69432.
24561 *
24562 * @example
24563 * const myLock = new SharedLock('some-key');
24564 * myLock.withLock(function() {
24565 * console.log('I hold the mutex!');
24566 * });
24567 *
24568 * @constructor
24569 */
24570 var SharedLock = function(key, options) {
24571 options = options || {};
24572
24573 this.storageKey = key;
24574 this.storage = options.storage || win.localStorage;
24575 this.pollIntervalMS = options.pollIntervalMS || 100;
24576 this.timeoutMS = options.timeoutMS || 2000;
24577
24578 // dependency-inject promise implementation for testing purposes
24579 this.promiseImpl = options.promiseImpl || PromisePolyfill;
24580 };
24581
24582 // pass in a specific pid to test contention scenarios; otherwise
24583 // it is chosen randomly for each acquisition attempt
24584 SharedLock.prototype.withLock = function(lockedCB, pid) {
24585 var Promise = this.promiseImpl;
24586 return new Promise(_.bind(function (resolve, reject) {
24587 var i = pid || (new Date().getTime() + '|' + Math.random());
24588 var startTime = new Date().getTime();
24589 var key = this.storageKey;
24590 var pollIntervalMS = this.pollIntervalMS;
24591 var timeoutMS = this.timeoutMS;
24592 var storage = this.storage;
24593
24594 var keyX = key + ':X';
24595 var keyY = key + ':Y';
24596 var keyZ = key + ':Z';
24597
24598 var delay = function(cb) {
24599 if (new Date().getTime() - startTime > timeoutMS) {
24600 logger$6.error('Timeout waiting for mutex on ' + key + '; clearing lock. [' + i + ']');
24601 storage.removeItem(keyZ);
24602 storage.removeItem(keyY);
24603 loop();
24604 return;
24605 }
24606 setTimeout(function() {
24607 try {
24608 cb();
24609 } catch(err) {
24610 reject(err);
24611 }
24612 }, pollIntervalMS * (Math.random() + 0.1));
24613 };
24614
24615 var waitFor = function(predicate, cb) {
24616 if (predicate()) {
24617 cb();
24618 } else {
24619 delay(function() {
24620 waitFor(predicate, cb);
24621 });
24622 }
24623 };
24624
24625 var getSetY = function() {
24626 var valY = storage.getItem(keyY);
24627 if (valY && valY !== i) { // if Y == i then this process already has the lock (useful for test cases)
24628 return false;
24629 } else {
24630 storage.setItem(keyY, i);
24631 if (storage.getItem(keyY) === i) {
24632 return true;
24633 } else {
24634 if (!localStorageSupported(storage, true)) {
24635 reject(new Error('localStorage support dropped while acquiring lock'));
24636 }
24637 return false;
24638 }
24639 }
24640 };
24641
24642 var loop = function() {
24643 storage.setItem(keyX, i);
24644
24645 waitFor(getSetY, function() {
24646 if (storage.getItem(keyX) === i) {
24647 criticalSection();
24648 return;
24649 }
24650
24651 delay(function() {
24652 if (storage.getItem(keyY) !== i) {
24653 loop();
24654 return;
24655 }
24656 waitFor(function() {
24657 return !storage.getItem(keyZ);
24658 }, criticalSection);
24659 });
24660 });
24661 };
24662
24663 var criticalSection = function() {
24664 storage.setItem(keyZ, '1');
24665 var removeLock = function () {
24666 storage.removeItem(keyZ);
24667 if (storage.getItem(keyY) === i) {
24668 storage.removeItem(keyY);
24669 }
24670 if (storage.getItem(keyX) === i) {
24671 storage.removeItem(keyX);
24672 }
24673 };
24674
24675 lockedCB()
24676 .then(function (ret) {
24677 removeLock();
24678 resolve(ret);
24679 })
24680 .catch(function (err) {
24681 removeLock();
24682 reject(err);
24683 });
24684 };
24685
24686 try {
24687 if (localStorageSupported(storage, true)) {
24688 loop();
24689 } else {
24690 throw new Error('localStorage support check failed');
24691 }
24692 } catch(err) {
24693 reject(err);
24694 }
24695 }, this));
24696 };
24697
24698 /**
24699 * @type {import('./wrapper').StorageWrapper}
24700 */
24701 var LocalStorageWrapper = function (storageOverride) {
24702 this.storage = storageOverride || win.localStorage;
24703 };
24704
24705 LocalStorageWrapper.prototype.init = function () {
24706 return PromisePolyfill.resolve();
24707 };
24708
24709 LocalStorageWrapper.prototype.isInitialized = function () {
24710 return true;
24711 };
24712
24713 LocalStorageWrapper.prototype.setItem = function (key, value) {
24714 return new PromisePolyfill(_.bind(function (resolve, reject) {
24715 try {
24716 this.storage.setItem(key, JSONStringify(value));
24717 } catch (e) {
24718 reject(e);
24719 }
24720 resolve();
24721 }, this));
24722 };
24723
24724 LocalStorageWrapper.prototype.getItem = function (key) {
24725 return new PromisePolyfill(_.bind(function (resolve, reject) {
24726 var item;
24727 try {
24728 item = JSONParse(this.storage.getItem(key));
24729 } catch (e) {
24730 reject(e);
24731 }
24732 resolve(item);
24733 }, this));
24734 };
24735
24736 LocalStorageWrapper.prototype.removeItem = function (key) {
24737 return new PromisePolyfill(_.bind(function (resolve, reject) {
24738 try {
24739 this.storage.removeItem(key);
24740 } catch (e) {
24741 reject(e);
24742 }
24743 resolve();
24744 }, this));
24745 };
24746
24747 var logger$5 = console_with_prefix('batch');
24748
24749 /**
24750 * RequestQueue: queue for batching API requests with localStorage backup for retries.
24751 * Maintains an in-memory queue which represents the source of truth for the current
24752 * page, but also writes all items out to a copy in the browser's localStorage, which
24753 * can be read on subsequent pageloads and retried. For batchability, all the request
24754 * items in the queue should be of the same type (events, people updates, group updates)
24755 * so they can be sent in a single request to the same API endpoint.
24756 *
24757 * LocalStorage keying and locking: In order for reloads and subsequent pageloads of
24758 * the same site to access the same persisted data, they must share the same localStorage
24759 * key (for instance based on project token and queue type). Therefore access to the
24760 * localStorage entry is guarded by an asynchronous mutex (SharedLock) to prevent
24761 * simultaneously open windows/tabs from overwriting each other's data (which would lead
24762 * to data loss in some situations).
24763 * @constructor
24764 */
24765 var RequestQueue = function (storageKey, options) {
24766 options = options || {};
24767 this.storageKey = storageKey;
24768 this.usePersistence = options.usePersistence;
24769 if (this.usePersistence) {
24770 this.queueStorage = options.queueStorage || new LocalStorageWrapper();
24771 this.lock = new SharedLock(storageKey, {
24772 storage: options.sharedLockStorage || win.localStorage,
24773 timeoutMS: options.sharedLockTimeoutMS,
24774 });
24775 }
24776 this.reportError = options.errorReporter || _.bind(logger$5.error, logger$5);
24777
24778 this.pid = options.pid || null; // pass pid to test out storage lock contention scenarios
24779
24780 this.memQueue = [];
24781 this.initialized = false;
24782
24783 if (options.enqueueThrottleMs) {
24784 this.enqueuePersisted = batchedThrottle(_.bind(this._enqueuePersisted, this), options.enqueueThrottleMs);
24785 } else {
24786 this.enqueuePersisted = _.bind(function (queueEntry) {
24787 return this._enqueuePersisted([queueEntry]);
24788 }, this);
24789 }
24790 };
24791
24792 RequestQueue.prototype.ensureInit = function () {
24793 if (this.initialized || !this.usePersistence) {
24794 return PromisePolyfill.resolve();
24795 }
24796
24797 return this.queueStorage
24798 .init()
24799 .then(_.bind(function () {
24800 this.initialized = true;
24801 }, this))
24802 .catch(_.bind(function (err) {
24803 this.reportError('Error initializing queue persistence. Disabling persistence', err);
24804 this.initialized = true;
24805 this.usePersistence = false;
24806 }, this));
24807 };
24808
24809 /**
24810 * Add one item to queues (memory and localStorage). The queued entry includes
24811 * the given item along with an auto-generated ID and a "flush-after" timestamp.
24812 * It is expected that the item will be sent over the network and dequeued
24813 * before the flush-after time; if this doesn't happen it is considered orphaned
24814 * (e.g., the original tab where it was enqueued got closed before it could be
24815 * sent) and the item can be sent by any tab that finds it in localStorage.
24816 *
24817 * The final callback param is called with a param indicating success or
24818 * failure of the enqueue operation; it is asynchronous because the localStorage
24819 * lock is asynchronous.
24820 */
24821 RequestQueue.prototype.enqueue = function (item, flushInterval) {
24822 var queueEntry = {
24823 'id': cheap_guid(),
24824 'flushAfter': new Date().getTime() + flushInterval * 2,
24825 'payload': item
24826 };
24827
24828 if (!this.usePersistence) {
24829 this.memQueue.push(queueEntry);
24830 return PromisePolyfill.resolve(true);
24831 } else {
24832 return this.enqueuePersisted(queueEntry);
24833 }
24834 };
24835
24836 RequestQueue.prototype._enqueuePersisted = function (queueEntries) {
24837 var enqueueItem = _.bind(function () {
24838 return this.ensureInit()
24839 .then(_.bind(function () {
24840 return this.readFromStorage();
24841 }, this))
24842 .then(_.bind(function (storedQueue) {
24843 return this.saveToStorage(storedQueue.concat(queueEntries));
24844 }, this))
24845 .then(_.bind(function (succeeded) {
24846 // only add to in-memory queue when storage succeeds
24847 if (succeeded) {
24848 this.memQueue = this.memQueue.concat(queueEntries);
24849 }
24850
24851 return succeeded;
24852 }, this))
24853 .catch(_.bind(function (err) {
24854 this.reportError('Error enqueueing items', err, queueEntries);
24855 return false;
24856 }, this));
24857 }, this);
24858
24859 return this.lock
24860 .withLock(enqueueItem, this.pid)
24861 .catch(_.bind(function (err) {
24862 this.reportError('Error acquiring storage lock', err);
24863 return false;
24864 }, this));
24865 };
24866
24867 /**
24868 * Read out the given number of queue entries. If this.memQueue
24869 * has fewer than batchSize items, then look for "orphaned" items
24870 * in the persisted queue (items where the 'flushAfter' time has
24871 * already passed).
24872 */
24873 RequestQueue.prototype.fillBatch = function (batchSize) {
24874 var batch = this.memQueue.slice(0, batchSize);
24875 if (this.usePersistence && batch.length < batchSize) {
24876 // don't need lock just to read events; localStorage is thread-safe
24877 // and the worst that could happen is a duplicate send of some
24878 // orphaned events, which will be deduplicated on the server side
24879 return this.ensureInit()
24880 .then(_.bind(function () {
24881 return this.readFromStorage();
24882 }, this))
24883 .then(_.bind(function (storedQueue) {
24884 if (storedQueue.length) {
24885 // item IDs already in batch; don't duplicate out of storage
24886 var idsInBatch = {}; // poor man's Set
24887 _.each(batch, function (item) {
24888 idsInBatch[item['id']] = true;
24889 });
24890
24891 for (var i = 0; i < storedQueue.length; i++) {
24892 var item = storedQueue[i];
24893 if (new Date().getTime() > item['flushAfter'] && !idsInBatch[item['id']]) {
24894 item.orphaned = true;
24895 batch.push(item);
24896 if (batch.length >= batchSize) {
24897 break;
24898 }
24899 }
24900 }
24901 }
24902
24903 return batch;
24904 }, this));
24905 } else {
24906 return PromisePolyfill.resolve(batch);
24907 }
24908 };
24909
24910 /**
24911 * Remove items with matching 'id' from array (immutably)
24912 * also remove any item without a valid id (e.g., malformed
24913 * storage entries).
24914 */
24915 var filterOutIDsAndInvalid = function (items, idSet) {
24916 var filteredItems = [];
24917 _.each(items, function (item) {
24918 if (item['id'] && !idSet[item['id']]) {
24919 filteredItems.push(item);
24920 }
24921 });
24922 return filteredItems;
24923 };
24924
24925 /**
24926 * Remove items with matching IDs from both in-memory queue
24927 * and persisted queue
24928 */
24929 RequestQueue.prototype.removeItemsByID = function (ids) {
24930 var idSet = {}; // poor man's Set
24931 _.each(ids, function (id) {
24932 idSet[id] = true;
24933 });
24934
24935 this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
24936 if (!this.usePersistence) {
24937 return PromisePolyfill.resolve(true);
24938 } else {
24939 var removeFromStorage = _.bind(function () {
24940 return this.ensureInit()
24941 .then(_.bind(function () {
24942 return this.readFromStorage();
24943 }, this))
24944 .then(_.bind(function (storedQueue) {
24945 storedQueue = filterOutIDsAndInvalid(storedQueue, idSet);
24946 return this.saveToStorage(storedQueue);
24947 }, this))
24948 .then(_.bind(function () {
24949 return this.readFromStorage();
24950 }, this))
24951 .then(_.bind(function (storedQueue) {
24952 // an extra check: did storage report success but somehow
24953 // the items are still there?
24954 for (var i = 0; i < storedQueue.length; i++) {
24955 var item = storedQueue[i];
24956 if (item['id'] && !!idSet[item['id']]) {
24957 throw new Error('Item not removed from storage');
24958 }
24959 }
24960 return true;
24961 }, this))
24962 .catch(_.bind(function (err) {
24963 this.reportError('Error removing items', err, ids);
24964 return false;
24965 }, this));
24966 }, this);
24967
24968 return this.lock
24969 .withLock(removeFromStorage, this.pid)
24970 .catch(_.bind(function (err) {
24971 this.reportError('Error acquiring storage lock', err);
24972 if (!localStorageSupported(this.lock.storage, true)) {
24973 // Looks like localStorage writes have stopped working sometime after
24974 // initialization (probably full), and so nobody can acquire locks
24975 // anymore. Consider it temporarily safe to remove items without the
24976 // lock, since nobody's writing successfully anyway.
24977 return removeFromStorage()
24978 .then(_.bind(function (success) {
24979 if (!success) {
24980 // OK, we couldn't even write out the smaller queue. Try clearing it
24981 // entirely.
24982 return this.queueStorage.removeItem(this.storageKey).then(function () {
24983 return success;
24984 });
24985 }
24986 return success;
24987 }, this))
24988 .catch(_.bind(function (err) {
24989 this.reportError('Error clearing queue', err);
24990 return false;
24991 }, this));
24992 } else {
24993 return false;
24994 }
24995 }, this));
24996 }
24997 };
24998
24999 // internal helper for RequestQueue.updatePayloads
25000 var updatePayloads = function (existingItems, itemsToUpdate) {
25001 var newItems = [];
25002 _.each(existingItems, function (item) {
25003 var id = item['id'];
25004 if (id in itemsToUpdate) {
25005 var newPayload = itemsToUpdate[id];
25006 if (newPayload !== null) {
25007 item['payload'] = newPayload;
25008 newItems.push(item);
25009 }
25010 } else {
25011 // no update
25012 newItems.push(item);
25013 }
25014 });
25015 return newItems;
25016 };
25017
25018 /**
25019 * Update payloads of given items in both in-memory queue and
25020 * persisted queue. Items set to null are removed from queues.
25021 */
25022 RequestQueue.prototype.updatePayloads = function (itemsToUpdate) {
25023 this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
25024 if (!this.usePersistence) {
25025 return PromisePolyfill.resolve(true);
25026 } else {
25027 return this.lock
25028 .withLock(_.bind(function lockAcquired() {
25029 return this.ensureInit()
25030 .then(_.bind(function () {
25031 return this.readFromStorage();
25032 }, this))
25033 .then(_.bind(function (storedQueue) {
25034 storedQueue = updatePayloads(storedQueue, itemsToUpdate);
25035 return this.saveToStorage(storedQueue);
25036 }, this))
25037 .catch(_.bind(function (err) {
25038 this.reportError('Error updating items', itemsToUpdate, err);
25039 return false;
25040 }, this));
25041 }, this), this.pid)
25042 .catch(_.bind(function (err) {
25043 this.reportError('Error acquiring storage lock', err);
25044 return false;
25045 }, this));
25046 }
25047 };
25048
25049 /**
25050 * Read and parse items array from localStorage entry, handling
25051 * malformed/missing data if necessary.
25052 */
25053 RequestQueue.prototype.readFromStorage = function () {
25054 return this.ensureInit()
25055 .then(_.bind(function () {
25056 return this.queueStorage.getItem(this.storageKey);
25057 }, this))
25058 .then(_.bind(function (storageEntry) {
25059 if (storageEntry) {
25060 if (!_.isArray(storageEntry)) {
25061 this.reportError('Invalid storage entry:', storageEntry);
25062 storageEntry = null;
25063 }
25064 }
25065 return storageEntry || [];
25066 }, this))
25067 .catch(_.bind(function (err) {
25068 this.reportError('Error retrieving queue', err);
25069 return [];
25070 }, this));
25071 };
25072
25073 /**
25074 * Serialize the given items array to localStorage.
25075 */
25076 RequestQueue.prototype.saveToStorage = function (queue) {
25077 return this.ensureInit()
25078 .then(_.bind(function () {
25079 return this.queueStorage.setItem(this.storageKey, queue);
25080 }, this))
25081 .then(function () {
25082 return true;
25083 })
25084 .catch(_.bind(function (err) {
25085 this.reportError('Error saving queue', err);
25086 return false;
25087 }, this));
25088 };
25089
25090 /**
25091 * Clear out queues (memory and localStorage).
25092 */
25093 RequestQueue.prototype.clear = function () {
25094 this.memQueue = [];
25095
25096 if (this.usePersistence) {
25097 return this.ensureInit()
25098 .then(_.bind(function () {
25099 return this.queueStorage.removeItem(this.storageKey);
25100 }, this));
25101 } else {
25102 return PromisePolyfill.resolve();
25103 }
25104 };
25105
25106 // maximum interval between request retries after exponential backoff
25107 var MAX_RETRY_INTERVAL_MS = 10 * 60 * 1000; // 10 minutes
25108
25109 var logger$4 = console_with_prefix('batch');
25110
25111 /**
25112 * RequestBatcher: manages the queueing, flushing, retry etc of requests of one
25113 * type (events, people, groups).
25114 * Uses RequestQueue to manage the backing store.
25115 * @constructor
25116 */
25117 var RequestBatcher = function(storageKey, options) {
25118 this.errorReporter = options.errorReporter;
25119 this.queue = new RequestQueue(storageKey, {
25120 errorReporter: _.bind(this.reportError, this),
25121 queueStorage: options.queueStorage,
25122 sharedLockStorage: options.sharedLockStorage,
25123 sharedLockTimeoutMS: options.sharedLockTimeoutMS,
25124 usePersistence: options.usePersistence,
25125 enqueueThrottleMs: options.enqueueThrottleMs
25126 });
25127
25128 this.libConfig = options.libConfig;
25129 this.sendRequest = options.sendRequestFunc;
25130 this.beforeSendHook = options.beforeSendHook;
25131 this.stopAllBatching = options.stopAllBatchingFunc;
25132
25133 // seed variable batch size + flush interval with configured values
25134 this.batchSize = this.libConfig['batch_size'];
25135 this.flushInterval = this.libConfig['batch_flush_interval_ms'];
25136
25137 this.stopped = !this.libConfig['batch_autostart'];
25138 this.consecutiveRemovalFailures = 0;
25139
25140 // extra client-side dedupe
25141 this.itemIdsSentSuccessfully = {};
25142
25143 // Make the flush occur at the interval specified by flushIntervalMs, default behavior will attempt consecutive flushes
25144 // as long as the queue is not empty. This is useful for high-frequency events like Session Replay where we might end up
25145 // in a request loop and get ratelimited by the server.
25146 this.flushOnlyOnInterval = options.flushOnlyOnInterval || false;
25147
25148 this._flushPromise = null;
25149 };
25150
25151 /**
25152 * Add one item to queue.
25153 */
25154 RequestBatcher.prototype.enqueue = function(item) {
25155 return this.queue.enqueue(item, this.flushInterval);
25156 };
25157
25158 /**
25159 * Start flushing batches at the configured time interval. Must call
25160 * this method upon SDK init in order to send anything over the network.
25161 */
25162 RequestBatcher.prototype.start = function() {
25163 this.stopped = false;
25164 this.consecutiveRemovalFailures = 0;
25165 return this.flush();
25166 };
25167
25168 /**
25169 * Stop flushing batches. Can be restarted by calling start().
25170 */
25171 RequestBatcher.prototype.stop = function() {
25172 this.stopped = true;
25173 if (this.timeoutID) {
25174 clearTimeout(this.timeoutID);
25175 this.timeoutID = null;
25176 }
25177 };
25178
25179 /**
25180 * Clear out queue.
25181 */
25182 RequestBatcher.prototype.clear = function() {
25183 return this.queue.clear();
25184 };
25185
25186 /**
25187 * Restore batch size configuration to whatever is set in the main SDK.
25188 */
25189 RequestBatcher.prototype.resetBatchSize = function() {
25190 this.batchSize = this.libConfig['batch_size'];
25191 };
25192
25193 /**
25194 * Restore flush interval time configuration to whatever is set in the main SDK.
25195 */
25196 RequestBatcher.prototype.resetFlush = function() {
25197 this.scheduleFlush(this.libConfig['batch_flush_interval_ms']);
25198 };
25199
25200 /**
25201 * Schedule the next flush in the given number of milliseconds.
25202 */
25203 RequestBatcher.prototype.scheduleFlush = function(flushMS) {
25204 this.flushInterval = flushMS;
25205 if (!this.stopped) { // don't schedule anymore if batching has been stopped
25206 this.timeoutID = setTimeout(_.bind(function() {
25207 if (!this.stopped) {
25208 this._flushPromise = this.flush();
25209 }
25210 }, this), this.flushInterval);
25211 }
25212 };
25213
25214 /**
25215 * Send a request using the sendRequest callback, but promisified.
25216 * TODO: sendRequest should be promisified in the first place.
25217 */
25218 RequestBatcher.prototype.sendRequestPromise = function(data, options) {
25219 return new PromisePolyfill(_.bind(function(resolve) {
25220 this.sendRequest(data, options, resolve);
25221 }, this));
25222 };
25223
25224
25225 /**
25226 * Flush one batch to network. Depending on success/failure modes, it will either
25227 * remove the batch from the queue or leave it in for retry, and schedule the next
25228 * flush. In cases of most network or API failures, it will back off exponentially
25229 * when retrying.
25230 * @param {Object} [options]
25231 * @param {boolean} [options.sendBeacon] - whether to send batch with
25232 * navigator.sendBeacon (only useful for sending batches before page unloads, as
25233 * sendBeacon offers no callbacks or status indications)
25234 */
25235 RequestBatcher.prototype.flush = function(options) {
25236 if (this.requestInProgress) {
25237 logger$4.log('Flush: Request already in progress');
25238 return PromisePolyfill.resolve();
25239 }
25240
25241 this.requestInProgress = true;
25242
25243 options = options || {};
25244 var timeoutMS = this.libConfig['batch_request_timeout_ms'];
25245 var startTime = new Date().getTime();
25246 var currentBatchSize = this.batchSize;
25247
25248 return this.queue.fillBatch(currentBatchSize)
25249 .then(_.bind(function(batch) {
25250
25251 // if there's more items in the queue than the batch size, attempt
25252 // to flush again after the current batch is done.
25253 var attemptSecondaryFlush = batch.length === currentBatchSize;
25254 var dataForRequest = [];
25255 var transformedItems = {};
25256 _.each(batch, function(item) {
25257 var payload = item['payload'];
25258 if (this.beforeSendHook && !item.orphaned) {
25259 payload = this.beforeSendHook(payload);
25260 }
25261 if (payload) {
25262 // mp_sent_by_lib_version prop captures which lib version actually
25263 // sends each event (regardless of which version originally queued
25264 // it for sending)
25265 if (payload['event'] && payload['properties']) {
25266 payload['properties'] = _.extend(
25267 {},
25268 payload['properties'],
25269 {'mp_sent_by_lib_version': Config.LIB_VERSION}
25270 );
25271 }
25272 var addPayload = true;
25273 var itemId = item['id'];
25274 if (itemId) {
25275 if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
25276 this.reportError('[dupe] item ID sent too many times, not sending', {
25277 item: item,
25278 batchSize: batch.length,
25279 timesSent: this.itemIdsSentSuccessfully[itemId]
25280 });
25281 addPayload = false;
25282 }
25283 } else {
25284 this.reportError('[dupe] found item with no ID', {item: item});
25285 }
25286
25287 if (addPayload) {
25288 dataForRequest.push(payload);
25289 }
25290 }
25291 transformedItems[item['id']] = payload;
25292 }, this);
25293
25294 if (dataForRequest.length < 1) {
25295 this.requestInProgress = false;
25296 this.resetFlush();
25297 return PromisePolyfill.resolve(); // nothing to do
25298 }
25299
25300 var removeItemsFromQueue = _.bind(function () {
25301 return this.queue
25302 .removeItemsByID(
25303 _.map(batch, function (item) {
25304 return item['id'];
25305 })
25306 )
25307 .then(_.bind(function (succeeded) {
25308 // client-side dedupe
25309 _.each(batch, _.bind(function(item) {
25310 var itemId = item['id'];
25311 if (itemId) {
25312 this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
25313 this.itemIdsSentSuccessfully[itemId]++;
25314 if (this.itemIdsSentSuccessfully[itemId] > 5) {
25315 this.reportError('[dupe] item ID sent too many times', {
25316 item: item,
25317 batchSize: batch.length,
25318 timesSent: this.itemIdsSentSuccessfully[itemId]
25319 });
25320 }
25321 } else {
25322 this.reportError('[dupe] found item with no ID while removing', {item: item});
25323 }
25324 }, this));
25325
25326 if (succeeded) {
25327 this.consecutiveRemovalFailures = 0;
25328 if (this.flushOnlyOnInterval && !attemptSecondaryFlush) {
25329 this.resetFlush(); // schedule next batch with a delay
25330 return PromisePolyfill.resolve();
25331 } else {
25332 return this.flush(); // handle next batch if the queue isn't empty
25333 }
25334 } else {
25335 if (++this.consecutiveRemovalFailures > 5) {
25336 this.reportError('Too many queue failures; disabling batching system.');
25337 this.stopAllBatching();
25338 } else {
25339 this.resetFlush();
25340 }
25341 return PromisePolyfill.resolve();
25342 }
25343 }, this));
25344 }, this);
25345
25346 var batchSendCallback = _.bind(function(res) {
25347 this.requestInProgress = false;
25348
25349 try {
25350
25351 // handle API response in a try-catch to make sure we can reset the
25352 // flush operation if something goes wrong
25353
25354 if (options.unloading) {
25355 // update persisted data to include hook transformations
25356 return this.queue.updatePayloads(transformedItems);
25357 } else if (
25358 _.isObject(res) &&
25359 res.error === 'timeout' &&
25360 new Date().getTime() - startTime >= timeoutMS
25361 ) {
25362 this.reportError('Network timeout; retrying');
25363 return this.flush();
25364 } else if (
25365 _.isObject(res) &&
25366 (
25367 res.httpStatusCode >= 500
25368 || res.httpStatusCode === 429
25369 || (res.httpStatusCode <= 0 && !isOnline())
25370 || res.error === 'timeout'
25371 )
25372 ) {
25373 // network or API error, or 429 Too Many Requests, retry
25374 var retryMS = this.flushInterval * 2;
25375 if (res.retryAfter) {
25376 retryMS = (parseInt(res.retryAfter, 10) * 1000) || retryMS;
25377 }
25378 retryMS = Math.min(MAX_RETRY_INTERVAL_MS, retryMS);
25379 this.reportError('Error; retry in ' + retryMS + ' ms');
25380 this.scheduleFlush(retryMS);
25381 return PromisePolyfill.resolve();
25382 } else if (_.isObject(res) && res.httpStatusCode === 413) {
25383 // 413 Payload Too Large
25384 if (batch.length > 1) {
25385 var halvedBatchSize = Math.max(1, Math.floor(currentBatchSize / 2));
25386 this.batchSize = Math.min(this.batchSize, halvedBatchSize, batch.length - 1);
25387 this.reportError('413 response; reducing batch size to ' + this.batchSize);
25388 this.resetFlush();
25389 return PromisePolyfill.resolve();
25390 } else {
25391 this.reportError('Single-event request too large; dropping', batch);
25392 this.resetBatchSize();
25393 return removeItemsFromQueue();
25394 }
25395 } else {
25396 // successful network request+response; remove each item in batch from queue
25397 // (even if it was e.g. a 400, in which case retrying won't help)
25398 return removeItemsFromQueue();
25399 }
25400 } catch(err) {
25401 this.reportError('Error handling API response', err);
25402 this.resetFlush();
25403 }
25404 }, this);
25405 var requestOptions = {
25406 method: 'POST',
25407 verbose: true,
25408 ignore_json_errors: true, // eslint-disable-line camelcase
25409 timeout_ms: timeoutMS // eslint-disable-line camelcase
25410 };
25411 if (options.unloading) {
25412 requestOptions.transport = 'sendBeacon';
25413 }
25414 logger$4.log('MIXPANEL REQUEST:', dataForRequest);
25415 return this.sendRequestPromise(dataForRequest, requestOptions).then(batchSendCallback);
25416 }, this))
25417 .catch(_.bind(function(err) {
25418 this.reportError('Error flushing request queue', err);
25419 this.resetFlush();
25420 }, this));
25421 };
25422
25423 /**
25424 * Log error to global logger and optional user-defined logger.
25425 */
25426 RequestBatcher.prototype.reportError = function(msg, err) {
25427 logger$4.error.apply(logger$4.error, arguments);
25428 if (this.errorReporter) {
25429 try {
25430 if (!(err instanceof Error)) {
25431 err = new Error(msg);
25432 }
25433 this.errorReporter(msg, err);
25434 } catch(err) {
25435 logger$4.error(err);
25436 }
25437 }
25438 };
25439
25440 /**
25441 * @param {import('./session-recording').SerializedRecording} serializedRecording
25442 * @returns {boolean}
25443 */
25444 var isRecordingExpired = function(serializedRecording) {
25445 var now = Date.now();
25446 return !serializedRecording || now > serializedRecording['maxExpires'] || now > serializedRecording['idleExpires'];
25447 };
25448
25449 var RECORD_ENQUEUE_THROTTLE_MS = 250;
25450
25451 var logger$3 = console_with_prefix('recorder');
25452 var CompressionStream = win['CompressionStream'];
25453
25454 var RECORDER_BATCHER_LIB_CONFIG = {
25455 'batch_size': 1000,
25456 'batch_flush_interval_ms': 10 * 1000,
25457 'batch_request_timeout_ms': 90 * 1000,
25458 'batch_autostart': true
25459 };
25460
25461 var ACTIVE_SOURCES = new Set([
25462 IncrementalSource.MouseMove,
25463 IncrementalSource.MouseInteraction,
25464 IncrementalSource.Scroll,
25465 IncrementalSource.ViewportResize,
25466 IncrementalSource.Input,
25467 IncrementalSource.TouchMove,
25468 IncrementalSource.MediaInteraction,
25469 IncrementalSource.Drag,
25470 IncrementalSource.Selection,
25471 ]);
25472
25473 function isUserEvent(ev) {
25474 return ev.type === EventType.IncrementalSnapshot && ACTIVE_SOURCES.has(ev.data.source);
25475 }
25476
25477 /**
25478 * @typedef {Object} SerializedRecording
25479 * @property {number} idleExpires
25480 * @property {number} maxExpires
25481 * @property {number} replayStartTime
25482 * @property {number} seqNo
25483 * @property {string} batchStartUrl
25484 * @property {string} replayId
25485 * @property {string} tabId
25486 * @property {string} replayStartUrl
25487 */
25488
25489 /**
25490 * @typedef {Object} SessionRecordingOptions
25491 * @property {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
25492 * @property {String} [options.replayId] - unique uuid for a single replay
25493 * @property {Function} [options.onIdleTimeout] - callback when a recording reaches idle timeout
25494 * @property {Function} [options.onMaxLengthReached] - callback when a recording reaches its maximum length
25495 * @property {Function} [options.rrwebRecord] - rrweb's `record` function
25496 * @property {Function} [options.onBatchSent] - callback when a batch of events is sent to the server
25497 * @property {Storage} [options.sharedLockStorage] - optional storage for shared lock, used for test dependency injection
25498 * optional properties for deserialization:
25499 * @property {number} idleExpires
25500 * @property {number} maxExpires
25501 * @property {number} replayStartTime
25502 * @property {number} seqNo
25503 * @property {string} batchStartUrl
25504 * @property {string} replayStartUrl
25505 */
25506
25507 /**
25508 * @typedef {Object} UserIdInfo
25509 * @property {string} distinct_id
25510 * @property {string} user_id
25511 * @property {string} device_id
25512 */
25513
25514
25515 /**
25516 * This class encapsulates a single session recording and its lifecycle.
25517 * @param {SessionRecordingOptions} options
25518 */
25519 var SessionRecording = function(options) {
25520 this._mixpanel = options.mixpanelInstance;
25521 this._onIdleTimeout = options.onIdleTimeout || NOOP_FUNC;
25522 this._onMaxLengthReached = options.onMaxLengthReached || NOOP_FUNC;
25523 this._onBatchSent = options.onBatchSent || NOOP_FUNC;
25524 this._rrwebRecord = options.rrwebRecord || null;
25525
25526 // internal rrweb stopRecording function
25527 this._stopRecording = null;
25528 this.replayId = options.replayId;
25529
25530 this.batchStartUrl = options.batchStartUrl || null;
25531 this.replayStartUrl = options.replayStartUrl || null;
25532 this.idleExpires = options.idleExpires || null;
25533 this.maxExpires = options.maxExpires || null;
25534 this.replayStartTime = options.replayStartTime || null;
25535 this.seqNo = options.seqNo || 0;
25536
25537 this.idleTimeoutId = null;
25538 this.maxTimeoutId = null;
25539
25540 this.recordMaxMs = MAX_RECORDING_MS;
25541 this.recordMinMs = 0;
25542
25543 // disable persistence if localStorage is not supported
25544 // request-queue will automatically disable persistence if indexedDB fails to initialize
25545 var usePersistence = localStorageSupported(options.sharedLockStorage, true) && !this.getConfig('disable_persistence');
25546
25547 // each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
25548 this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
25549 this.queueStorage = new IDBStorageWrapper(RECORDING_EVENTS_STORE_NAME);
25550 this.batcher = new RequestBatcher(this.batcherKey, {
25551 errorReporter: this.reportError.bind(this),
25552 flushOnlyOnInterval: true,
25553 libConfig: RECORDER_BATCHER_LIB_CONFIG,
25554 sendRequestFunc: this.flushEventsWithOptOut.bind(this),
25555 queueStorage: this.queueStorage,
25556 sharedLockStorage: options.sharedLockStorage,
25557 usePersistence: usePersistence,
25558 stopAllBatchingFunc: this.stopRecording.bind(this),
25559
25560 // increased throttle and shared lock timeout because recording events are very high frequency.
25561 // this will minimize the amount of lock contention between enqueued events.
25562 // for session recordings there is a lock for each tab anyway, so there's no risk of deadlock between tabs.
25563 enqueueThrottleMs: RECORD_ENQUEUE_THROTTLE_MS,
25564 sharedLockTimeoutMS: 10 * 1000,
25565 });
25566 };
25567
25568 /**
25569 * @returns {UserIdInfo}
25570 */
25571 SessionRecording.prototype.getUserIdInfo = function () {
25572 if (this.finalFlushUserIdInfo) {
25573 return this.finalFlushUserIdInfo;
25574 }
25575
25576 var userIdInfo = {
25577 'distinct_id': String(this._mixpanel.get_distinct_id()),
25578 };
25579
25580 // send ID management props if they exist
25581 var deviceId = this._mixpanel.get_property('$device_id');
25582 if (deviceId) {
25583 userIdInfo['$device_id'] = deviceId;
25584 }
25585 var userId = this._mixpanel.get_property('$user_id');
25586 if (userId) {
25587 userIdInfo['$user_id'] = userId;
25588 }
25589 return userIdInfo;
25590 };
25591
25592 SessionRecording.prototype.unloadPersistedData = function () {
25593 this.batcher.stop();
25594 return this.batcher.flush()
25595 .then(function () {
25596 return this.queueStorage.removeItem(this.batcherKey);
25597 }.bind(this));
25598 };
25599
25600 SessionRecording.prototype.getConfig = function(configVar) {
25601 return this._mixpanel.get_config(configVar);
25602 };
25603
25604 // Alias for getConfig, used by the common addOptOutCheckMixpanelLib function which
25605 // reaches into this class instance and expects the snake case version of the function.
25606 // eslint-disable-next-line camelcase
25607 SessionRecording.prototype.get_config = function(configVar) {
25608 return this.getConfig(configVar);
25609 };
25610
25611 SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
25612 if (this._rrwebRecord === null) {
25613 this.reportError('rrweb record function not provided. ');
25614 return;
25615 }
25616
25617 if (this._stopRecording !== null) {
25618 logger$3.log('Recording already in progress, skipping startRecording.');
25619 return;
25620 }
25621
25622 this.recordMaxMs = this.getConfig('record_max_ms');
25623 if (this.recordMaxMs > MAX_RECORDING_MS) {
25624 this.recordMaxMs = MAX_RECORDING_MS;
25625 logger$3.critical('record_max_ms cannot be greater than ' + MAX_RECORDING_MS + 'ms. Capping value.');
25626 }
25627
25628 if (!this.maxExpires) {
25629 this.maxExpires = new Date().getTime() + this.recordMaxMs;
25630 }
25631
25632 this.recordMinMs = this.getConfig('record_min_ms');
25633 if (this.recordMinMs > MAX_VALUE_FOR_MIN_RECORDING_MS) {
25634 this.recordMinMs = MAX_VALUE_FOR_MIN_RECORDING_MS;
25635 logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
25636 }
25637
25638 if (!this.replayStartTime) {
25639 this.replayStartTime = new Date().getTime();
25640 this.batchStartUrl = _.info.currentUrl();
25641 this.replayStartUrl = _.info.currentUrl();
25642 }
25643
25644 if (shouldStopBatcher || this.recordMinMs > 0) {
25645 // the primary case for shouldStopBatcher is when we're starting recording after a reset
25646 // and don't want to send anything over the network until there's
25647 // actual user activity
25648 // this also applies if the minimum recording length has not been hit yet
25649 // so that we don't send data until we know the recording will be long enough
25650 this.batcher.stop();
25651 } else {
25652 this.batcher.start();
25653 }
25654
25655 var resetIdleTimeout = function () {
25656 clearTimeout(this.idleTimeoutId);
25657 var idleTimeoutMs = this.getConfig('record_idle_timeout_ms');
25658 this.idleTimeoutId = setTimeout(this._onIdleTimeout, idleTimeoutMs);
25659 this.idleExpires = new Date().getTime() + idleTimeoutMs;
25660 }.bind(this);
25661 resetIdleTimeout();
25662
25663 var blockSelector = this.getConfig('record_block_selector');
25664 if (blockSelector === '' || blockSelector === null) {
25665 blockSelector = undefined;
25666 }
25667
25668 try {
25669 this._stopRecording = this._rrwebRecord({
25670 'emit': function (ev) {
25671 if (this.idleExpires && this.idleExpires < ev.timestamp) {
25672 this._onIdleTimeout();
25673 return;
25674 }
25675 if (isUserEvent(ev)) {
25676 if (this.batcher.stopped && new Date().getTime() - this.replayStartTime >= this.recordMinMs) {
25677 // start flushing again after user activity
25678 this.batcher.start();
25679 }
25680 resetIdleTimeout();
25681 }
25682 // promise only used to await during tests
25683 this.__enqueuePromise = this.batcher.enqueue(ev);
25684 }.bind(this),
25685 'blockClass': this.getConfig('record_block_class'),
25686 'blockSelector': blockSelector,
25687 'collectFonts': this.getConfig('record_collect_fonts'),
25688 'dataURLOptions': { // canvas image options (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL)
25689 'type': 'image/webp',
25690 'quality': 0.6
25691 },
25692 'maskAllInputs': true,
25693 'maskTextClass': this.getConfig('record_mask_text_class'),
25694 'maskTextSelector': this.getConfig('record_mask_text_selector'),
25695 'recordCanvas': this.getConfig('record_canvas'),
25696 'sampling': {
25697 'canvas': 15
25698 }
25699 });
25700 } catch (err) {
25701 this.reportError('Unexpected error when starting rrweb recording.', err);
25702 }
25703
25704 if (typeof this._stopRecording !== 'function') {
25705 this.reportError('rrweb failed to start, skipping this recording.');
25706 this._stopRecording = null;
25707 this.stopRecording(); // stop batcher looping and any timeouts
25708 return;
25709 }
25710
25711 var maxTimeoutMs = this.maxExpires - new Date().getTime();
25712 this.maxTimeoutId = setTimeout(this._onMaxLengthReached.bind(this), maxTimeoutMs);
25713 };
25714
25715 SessionRecording.prototype.stopRecording = function (skipFlush) {
25716 // store the user ID info in case this is getting called in mixpanel.reset()
25717 this.finalFlushUserIdInfo = this.getUserIdInfo();
25718
25719 if (!this.isRrwebStopped()) {
25720 try {
25721 this._stopRecording();
25722 } catch (err) {
25723 this.reportError('Error with rrweb stopRecording', err);
25724 }
25725 this._stopRecording = null;
25726 }
25727
25728 var flushPromise;
25729 if (this.batcher.stopped) {
25730 // never got user activity to flush after reset, so just clear the batcher
25731 flushPromise = this.batcher.clear();
25732 } else if (!skipFlush) {
25733 // flush any remaining events from running batcher
25734 flushPromise = this.batcher.flush();
25735 }
25736 this.batcher.stop();
25737
25738 clearTimeout(this.idleTimeoutId);
25739 clearTimeout(this.maxTimeoutId);
25740 return flushPromise;
25741 };
25742
25743 SessionRecording.prototype.isRrwebStopped = function () {
25744 return this._stopRecording === null;
25745 };
25746
25747
25748 /**
25749 * Flushes the current batch of events to the server, but passes an opt-out callback to make sure
25750 * we stop recording and dump any queued events if the user has opted out.
25751 */
25752 SessionRecording.prototype.flushEventsWithOptOut = function (data, options, cb) {
25753 var onOptOut = function (code) {
25754 // addOptOutCheckMixpanelLib invokes this function with code=0 when the user has opted out
25755 if (code === 0) {
25756 this.stopRecording();
25757 cb({error: 'Tracking has been opted out, stopping recording.'});
25758 }
25759 }.bind(this);
25760
25761 this._flushEvents(data, options, cb, onOptOut);
25762 };
25763
25764 /**
25765 * @returns {SerializedRecording}
25766 */
25767 SessionRecording.prototype.serialize = function () {
25768 // don't break if mixpanel instance was destroyed at some point
25769 var tabId;
25770 try {
25771 tabId = this._mixpanel.get_tab_id();
25772 } catch (e) {
25773 this.reportError('Error getting tab ID for serialization ', e);
25774 tabId = null;
25775 }
25776
25777 return {
25778 'replayId': this.replayId,
25779 'seqNo': this.seqNo,
25780 'replayStartTime': this.replayStartTime,
25781 'batchStartUrl': this.batchStartUrl,
25782 'replayStartUrl': this.replayStartUrl,
25783 'idleExpires': this.idleExpires,
25784 'maxExpires': this.maxExpires,
25785 'tabId': tabId,
25786 };
25787 };
25788
25789
25790 /**
25791 * @static
25792 * @param {SerializedRecording} serializedRecording
25793 * @param {SessionRecordingOptions} options
25794 * @returns {SessionRecording}
25795 */
25796 SessionRecording.deserialize = function (serializedRecording, options) {
25797 var recording = new SessionRecording(_.extend({}, options, {
25798 replayId: serializedRecording['replayId'],
25799 batchStartUrl: serializedRecording['batchStartUrl'],
25800 replayStartUrl: serializedRecording['replayStartUrl'],
25801 idleExpires: serializedRecording['idleExpires'],
25802 maxExpires: serializedRecording['maxExpires'],
25803 replayStartTime: serializedRecording['replayStartTime'],
25804 seqNo: serializedRecording['seqNo'],
25805 sharedLockStorage: options.sharedLockStorage,
25806 }));
25807
25808 return recording;
25809 };
25810
25811 SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, reqBody, callback) {
25812 var onSuccess = function (response, responseBody) {
25813 // Update batch specific props only if the request was successful to guarantee ordering.
25814 // RequestBatcher will always flush the next batch after the previous one succeeds.
25815 // extra check to see if the replay ID has changed so that we don't increment the seqNo on the wrong replay
25816 if (response.status === 200 && this.replayId === currentReplayId) {
25817 this.seqNo++;
25818 this.batchStartUrl = _.info.currentUrl();
25819 }
25820
25821 this._onBatchSent();
25822 callback({
25823 status: 0,
25824 httpStatusCode: response.status,
25825 responseBody: responseBody,
25826 retryAfter: response.headers.get('Retry-After')
25827 });
25828 }.bind(this);
25829 var apiHost = (this._mixpanel.get_api_host && this._mixpanel.get_api_host('record')) || this.getConfig('api_host');
25830 win['fetch'](apiHost + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
25831 'method': 'POST',
25832 'headers': {
25833 'Authorization': 'Basic ' + btoa(this.getConfig('token') + ':'),
25834 'Content-Type': 'application/octet-stream'
25835 },
25836 'body': reqBody,
25837 }).then(function (response) {
25838 response.json().then(function (responseBody) {
25839 onSuccess(response, responseBody);
25840 }).catch(function (error) {
25841 callback({error: error});
25842 });
25843 }).catch(function (error) {
25844 callback({error: error, httpStatusCode: 0});
25845 });
25846 };
25847
25848 SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (data, options, callback) {
25849 var numEvents = data.length;
25850
25851 if (numEvents > 0) {
25852 var replayId = this.replayId;
25853
25854 // each rrweb event has a timestamp - leverage those to get time properties
25855 var batchStartTime = Infinity;
25856 var batchEndTime = -Infinity;
25857 var hasFullSnapshot = false;
25858 for (var i = 0; i < numEvents; i++) {
25859 batchStartTime = Math.min(batchStartTime, data[i].timestamp);
25860 batchEndTime = Math.max(batchEndTime, data[i].timestamp);
25861 if (data[i].type === EventType.FullSnapshot) {
25862 hasFullSnapshot = true;
25863 }
25864 }
25865
25866 if (this.seqNo === 0) {
25867 if (!hasFullSnapshot) {
25868 callback({error: 'First batch does not contain a full snapshot. Aborting recording.'});
25869 this.stopRecording(true);
25870 return;
25871 }
25872 this.replayStartTime = batchStartTime;
25873 } else if (!this.replayStartTime) {
25874 this.reportError('Replay start time not set but seqNo is not 0. Using current batch start time as a fallback.');
25875 this.replayStartTime = batchStartTime;
25876 }
25877
25878 var replayLengthMs = batchEndTime - this.replayStartTime;
25879
25880 var reqParams = {
25881 '$current_url': this.batchStartUrl,
25882 '$lib_version': Config.LIB_VERSION,
25883 'batch_start_time': batchStartTime / 1000,
25884 'mp_lib': 'web',
25885 'replay_id': replayId,
25886 'replay_length_ms': replayLengthMs,
25887 'replay_start_time': this.replayStartTime / 1000,
25888 'replay_start_url': this.replayStartUrl,
25889 'seq': this.seqNo
25890 };
25891 var eventsJson = JSON.stringify(data);
25892 Object.assign(reqParams, this.getUserIdInfo());
25893
25894 if (CompressionStream) {
25895 var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
25896 var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
25897 new Response(gzipStream)
25898 .blob()
25899 .then(function(compressedBlob) {
25900 reqParams['format'] = 'gzip';
25901 this._sendRequest(replayId, reqParams, compressedBlob, callback);
25902 }.bind(this));
25903 } else {
25904 reqParams['format'] = 'body';
25905 this._sendRequest(replayId, reqParams, eventsJson, callback);
25906 }
25907 }
25908 });
25909
25910
25911 SessionRecording.prototype.reportError = function(msg, err) {
25912 logger$3.error.apply(logger$3.error, arguments);
25913 try {
25914 if (!err && !(msg instanceof Error)) {
25915 msg = new Error(msg);
25916 }
25917 this.getConfig('error_reporter')(msg, err);
25918 } catch(err) {
25919 logger$3.error(err);
25920 }
25921 };
25922
25923 /**
25924 * Module for handling the storage and retrieval of recording metadata as well as any active recordings.
25925 * Makes sure that only one tab can be recording at a time.
25926 */
25927 var RecordingRegistry = function (options) {
25928 /** @type {IDBStorageWrapper} */
25929 this.idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
25930 this.errorReporter = options.errorReporter;
25931 this.mixpanelInstance = options.mixpanelInstance;
25932 this.sharedLockStorage = options.sharedLockStorage;
25933 };
25934
25935 RecordingRegistry.prototype.isPersistenceEnabled = function() {
25936 return !this.mixpanelInstance.get_config('disable_persistence');
25937 };
25938
25939 RecordingRegistry.prototype.handleError = function (err) {
25940 this.errorReporter('IndexedDB error: ', err);
25941 };
25942
25943 /**
25944 * @param {import('./session-recording').SerializedRecording} serializedRecording
25945 */
25946 RecordingRegistry.prototype.setActiveRecording = function (serializedRecording) {
25947 if (!this.isPersistenceEnabled()) {
25948 return PromisePolyfill.resolve();
25949 }
25950
25951 var tabId = serializedRecording['tabId'];
25952 if (!tabId) {
25953 console.warn('No tab ID is set, cannot persist recording metadata.');
25954 return PromisePolyfill.resolve();
25955 }
25956
25957 return this.idb.init()
25958 .then(function () {
25959 return this.idb.setItem(tabId, serializedRecording);
25960 }.bind(this))
25961 .catch(this.handleError.bind(this));
25962 };
25963
25964 /**
25965 * @returns {Promise<import('./session-recording').SerializedRecording>}
25966 */
25967 RecordingRegistry.prototype.getActiveRecording = function () {
25968 if (!this.isPersistenceEnabled()) {
25969 return PromisePolyfill.resolve(null);
25970 }
25971
25972 return this.idb.init()
25973 .then(function () {
25974 return this.idb.getItem(this.mixpanelInstance.get_tab_id());
25975 }.bind(this))
25976 .then(function (serializedRecording) {
25977 return isRecordingExpired(serializedRecording) ? null : serializedRecording;
25978 }.bind(this))
25979 .catch(this.handleError.bind(this));
25980 };
25981
25982 RecordingRegistry.prototype.clearActiveRecording = function () {
25983 if (this.isPersistenceEnabled()) {
25984 // mark recording as expired instead of deleting it in case the page unloads mid-flush and doesn't make it to ingestion.
25985 // this will ensure the next pageload will flush the remaining events, but not try to continue the recording.
25986 return this.markActiveRecordingExpired();
25987 } else {
25988 return this.deleteActiveRecording();
25989 }
25990 };
25991
25992 RecordingRegistry.prototype.markActiveRecordingExpired = function () {
25993 return this.getActiveRecording()
25994 .then(function (serializedRecording) {
25995 if (serializedRecording) {
25996 serializedRecording['maxExpires'] = 0;
25997 return this.setActiveRecording(serializedRecording);
25998 }
25999 }.bind(this))
26000 .catch(this.handleError.bind(this));
26001 };
26002
26003 RecordingRegistry.prototype.deleteActiveRecording = function () {
26004 // avoid initializing IDB if this registry instance hasn't already written a recording
26005 if (this.idb.isInitialized()) {
26006 return this.idb.removeItem(this.mixpanelInstance.get_tab_id())
26007 .catch(this.handleError.bind(this));
26008 } else {
26009 return PromisePolyfill.resolve();
26010 }
26011 };
26012
26013 /**
26014 * Flush any inactive recordings from the registry to minimize data loss.
26015 * The main idea here is that we can flush remaining rrweb events on the next page load if a tab is closed mid-batch.
26016 */
26017 RecordingRegistry.prototype.flushInactiveRecordings = function () {
26018 if (!this.isPersistenceEnabled()) {
26019 return PromisePolyfill.resolve([]);
26020 }
26021
26022 return this.idb.init()
26023 .then(function() {
26024 return this.idb.getAll();
26025 }.bind(this))
26026 .then(function (serializedRecordings) {
26027 // clean up any expired recordings from the registry, non-expired ones may be active in other tabs
26028 var unloadPromises = serializedRecordings
26029 .filter(function (serializedRecording) {
26030 return isRecordingExpired(serializedRecording);
26031 })
26032 .map(function (serializedRecording) {
26033 var sessionRecording = SessionRecording.deserialize(serializedRecording, {
26034 mixpanelInstance: this.mixpanelInstance,
26035 sharedLockStorage: this.sharedLockStorage
26036 });
26037 return sessionRecording.unloadPersistedData()
26038 .then(function () {
26039 // expired recording was successfully flushed, we can clean it up from the registry
26040 return this.idb.removeItem(serializedRecording['tabId']);
26041 }.bind(this))
26042 .catch(this.handleError.bind(this));
26043 }.bind(this));
26044
26045 return PromisePolyfill.all(unloadPromises);
26046 }.bind(this))
26047 .catch(this.handleError.bind(this));
26048 };
26049
26050 var logger$2 = console_with_prefix('recorder');
26051
26052 /**
26053 * Recorder API: bundles rrweb and and exposes methods to start and stop recordings.
26054 * @param {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
26055 */
26056 var MixpanelRecorder = function(mixpanelInstance, rrwebRecord, sharedLockStorage) {
26057 this.mixpanelInstance = mixpanelInstance;
26058 this.rrwebRecord = rrwebRecord || record;
26059 this.sharedLockStorage = sharedLockStorage;
26060
26061 /**
26062 * @member {import('./registry').RecordingRegistry}
26063 */
26064 this.recordingRegistry = new RecordingRegistry({
26065 mixpanelInstance: this.mixpanelInstance,
26066 errorReporter: logger$2.error,
26067 sharedLockStorage: sharedLockStorage
26068 });
26069 this._flushInactivePromise = this.recordingRegistry.flushInactiveRecordings();
26070
26071 this.activeRecording = null;
26072 this.stopRecordingInProgress = false;
26073 };
26074
26075 MixpanelRecorder.prototype.startRecording = function(options) {
26076 options = options || {};
26077 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26078 logger$2.log('Recording already in progress, skipping startRecording.');
26079 return;
26080 }
26081
26082 var onIdleTimeout = function () {
26083 logger$2.log('Idle timeout reached, restarting recording.');
26084 this.resetRecording();
26085 }.bind(this);
26086
26087 var onMaxLengthReached = function () {
26088 logger$2.log('Max recording length reached, stopping recording.');
26089 this.resetRecording();
26090 }.bind(this);
26091
26092 var onBatchSent = function () {
26093 this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26094 this['__flushPromise'] = this.activeRecording.batcher._flushPromise;
26095 }.bind(this);
26096
26097 /**
26098 * @type {import('./session-recording').SessionRecordingOptions}
26099 */
26100 var sessionRecordingOptions = {
26101 mixpanelInstance: this.mixpanelInstance,
26102 onBatchSent: onBatchSent,
26103 onIdleTimeout: onIdleTimeout,
26104 onMaxLengthReached: onMaxLengthReached,
26105 replayId: _.UUID(),
26106 rrwebRecord: this.rrwebRecord,
26107 sharedLockStorage: this.sharedLockStorage
26108 };
26109
26110 if (options.activeSerializedRecording) {
26111 this.activeRecording = SessionRecording.deserialize(options.activeSerializedRecording, sessionRecordingOptions);
26112 } else {
26113 this.activeRecording = new SessionRecording(sessionRecordingOptions);
26114 }
26115
26116 this.activeRecording.startRecording(options.shouldStopBatcher);
26117 return this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26118 };
26119
26120 MixpanelRecorder.prototype.stopRecording = function() {
26121 // Prevents activeSerializedRecording from being reused when stopping the recording.
26122 this.stopRecordingInProgress = true;
26123 return this._stopCurrentRecording(false, true).then(function() {
26124 return this.recordingRegistry.clearActiveRecording();
26125 }.bind(this)).then(function() {
26126 this.stopRecordingInProgress = false;
26127 }.bind(this));
26128 };
26129
26130 MixpanelRecorder.prototype.pauseRecording = function() {
26131 return this._stopCurrentRecording(false);
26132 };
26133
26134 MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush, disableActiveRecording) {
26135 if (this.activeRecording) {
26136 var stopRecordingPromise = this.activeRecording.stopRecording(skipFlush);
26137 if (disableActiveRecording) {
26138 this.activeRecording = null;
26139 }
26140 return stopRecordingPromise;
26141 }
26142 return PromisePolyfill.resolve();
26143 };
26144
26145 MixpanelRecorder.prototype.resumeRecording = function (startNewIfInactive) {
26146 if (this.activeRecording && this.activeRecording.isRrwebStopped()) {
26147 this.activeRecording.startRecording(false);
26148 return PromisePolyfill.resolve(null);
26149 }
26150
26151 return this.recordingRegistry.getActiveRecording()
26152 .then(function (activeSerializedRecording) {
26153 if (activeSerializedRecording && !this.stopRecordingInProgress) {
26154 return this.startRecording({activeSerializedRecording: activeSerializedRecording});
26155 } else if (startNewIfInactive) {
26156 return this.startRecording({shouldStopBatcher: false});
26157 } else {
26158 logger$2.log('No resumable recording found.');
26159 return null;
26160 }
26161 }.bind(this));
26162 };
26163
26164
26165 MixpanelRecorder.prototype.resetRecording = function () {
26166 this.stopRecording();
26167 this.startRecording({shouldStopBatcher: true});
26168 };
26169
26170 MixpanelRecorder.prototype.getActiveReplayId = function () {
26171 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26172 return this.activeRecording.replayId;
26173 } else {
26174 return null;
26175 }
26176 };
26177
26178 // getter so that older mixpanel-core versions can still retrieve the replay ID
26179 // when pulling the latest recorder bundle from the CDN
26180 Object.defineProperty(MixpanelRecorder.prototype, 'replayId', {
26181 get: function () {
26182 return this.getActiveReplayId();
26183 }
26184 });
26185
26186 win['__mp_recorder'] = MixpanelRecorder;
26187
26188 // stateless utils
26189 // mostly from https://github.com/mixpanel/mixpanel-js/blob/989ada50f518edab47b9c4fd9535f9fbd5ec5fc0/src/autotrack-utils.js
26190
26191
26192 var EV_CHANGE = 'change';
26193 var EV_CLICK = 'click';
26194 var EV_HASHCHANGE = 'hashchange';
26195 var EV_INPUT = 'input';
26196 var EV_LOAD = 'load';
26197 var EV_MP_LOCATION_CHANGE = 'mp_locationchange';
26198 var EV_POPSTATE = 'popstate';
26199 // TODO scrollend isn't available in Safari: document or polyfill?
26200 var EV_SCROLLEND = 'scrollend';
26201 var EV_SCROLL = 'scroll';
26202 var EV_SELECT = 'select';
26203 var EV_SUBMIT = 'submit';
26204 var EV_TOGGLE = 'toggle';
26205 var EV_VISIBILITYCHANGE = 'visibilitychange';
26206
26207 var CLICK_EVENT_PROPS = [
26208 'clientX', 'clientY',
26209 'offsetX', 'offsetY',
26210 'pageX', 'pageY',
26211 'screenX', 'screenY',
26212 'x', 'y'
26213 ];
26214 var OPT_IN_CLASSES = ['mp-include'];
26215 var OPT_OUT_CLASSES = ['mp-no-track'];
26216 var SENSITIVE_DATA_CLASSES = OPT_OUT_CLASSES.concat(['mp-sensitive']);
26217 var TRACKED_ATTRS = [
26218 'aria-label', 'aria-labelledby', 'aria-describedby',
26219 'href', 'name', 'role', 'title', 'type'
26220 ];
26221
26222 var INTERACTIVE_ARIA_ROLES = {
26223 'button': true,
26224 'checkbox': true,
26225 'combobox': true,
26226 'grid': true,
26227 'link': true,
26228 'listbox': true,
26229 'menu': true,
26230 'menubar': true,
26231 'menuitem': true,
26232 'menuitemcheckbox': true,
26233 'menuitemradio': true,
26234 'navigation': true,
26235 'option': true,
26236 'radio': true,
26237 'radiogroup': true,
26238 'searchbox': true,
26239 'slider': true,
26240 'spinbutton': true,
26241 'switch': true,
26242 'tab': true,
26243 'tablist': true,
26244 'textbox': true,
26245 'tree': true,
26246 'treegrid': true,
26247 'treeitem': true
26248 };
26249
26250 var ALWAYS_NON_INTERACTIVE_TAGS = {
26251 // Document metadata
26252 'base': true,
26253 'head': true,
26254 'html': true,
26255 'link': true,
26256 'meta': true,
26257 'script': true,
26258 'style': true,
26259 'title': true,
26260 // Text formatting
26261 'br': true,
26262 'hr': true,
26263 'wbr': true,
26264 // Other
26265 'noscript': true,
26266 'picture': true,
26267 'source': true,
26268 'template': true,
26269 'track': true
26270 };
26271
26272 // Common container tags that need additional checks
26273 var TEXT_CONTAINER_TAGS = {
26274 'article': true,
26275 'div': true,
26276 'h1': true,
26277 'h2': true,
26278 'h3': true,
26279 'h4': true,
26280 'h5': true,
26281 'h6': true,
26282 'p': true,
26283 'section': true,
26284 'span': true
26285 };
26286
26287 var EVENT_HANDLER_ATTRIBUTES = [
26288 'onclick', 'onmousedown', 'onmouseup', 'onpointerdown', 'onpointerup', 'ontouchend', 'ontouchstart'
26289 ];
26290
26291 var MAX_DEPTH = 5;
26292
26293 var logger$1 = console_with_prefix('autocapture');
26294
26295
26296 function getClasses(el) {
26297 var classes = {};
26298 var classList = getClassName(el).split(' ');
26299 for (var i = 0; i < classList.length; i++) {
26300 var cls = classList[i];
26301 if (cls) {
26302 classes[cls] = true;
26303 }
26304 }
26305 return classes;
26306 }
26307
26308 /*
26309 * Get the className of an element, accounting for edge cases where element.className is an object
26310 * @param {Element} el - element to get the className of
26311 * @returns {string} the element's class
26312 */
26313 function getClassName(el) {
26314 switch(typeof el.className) {
26315 case 'string':
26316 return el.className;
26317 case 'object': // handle cases where className might be SVGAnimatedString or some other type
26318 return el.className.baseVal || el.getAttribute('class') || '';
26319 default: // future proof
26320 return '';
26321 }
26322 }
26323
26324 function getPreviousElementSibling(el) {
26325 if (el.previousElementSibling) {
26326 return el.previousElementSibling;
26327 } else {
26328 do {
26329 el = el.previousSibling;
26330 } while (el && !isElementNode(el));
26331 return el;
26332 }
26333 }
26334
26335 function getPropertiesFromElement(el, ev, blockAttrsSet, extraAttrs, allowElementCallback, allowSelectors) {
26336 var props = {
26337 '$classes': getClassName(el).split(' '),
26338 '$tag_name': el.tagName.toLowerCase()
26339 };
26340 var elId = el.id;
26341 if (elId) {
26342 props['$id'] = elId;
26343 }
26344
26345 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors)) {
26346 _.each(TRACKED_ATTRS.concat(extraAttrs), function(attr) {
26347 if (el.hasAttribute(attr) && !blockAttrsSet[attr]) {
26348 var attrVal = el.getAttribute(attr);
26349 if (shouldTrackValue(attrVal)) {
26350 props['$attr-' + attr] = attrVal;
26351 }
26352 }
26353 });
26354 }
26355
26356 var nthChild = 1;
26357 var nthOfType = 1;
26358 var currentElem = el;
26359 while (currentElem = getPreviousElementSibling(currentElem)) { // eslint-disable-line no-cond-assign
26360 nthChild++;
26361 if (currentElem.tagName === el.tagName) {
26362 nthOfType++;
26363 }
26364 }
26365 props['$nth_child'] = nthChild;
26366 props['$nth_of_type'] = nthOfType;
26367
26368 return props;
26369 }
26370
26371 function getPropsForDOMEvent(ev, config) {
26372 var allowElementCallback = config.allowElementCallback;
26373 var allowSelectors = config.allowSelectors || [];
26374 var blockAttrs = config.blockAttrs || [];
26375 var blockElementCallback = config.blockElementCallback;
26376 var blockSelectors = config.blockSelectors || [];
26377 var captureTextContent = config.captureTextContent || false;
26378 var captureExtraAttrs = config.captureExtraAttrs || [];
26379 var capturedForHeatMap = config.capturedForHeatMap || false;
26380
26381 // convert array to set every time, as the config may have changed
26382 var blockAttrsSet = {};
26383 _.each(blockAttrs, function(attr) {
26384 blockAttrsSet[attr] = true;
26385 });
26386
26387 var props = null;
26388
26389 var target = typeof ev.target === 'undefined' ? ev.srcElement : ev.target;
26390 if (isTextNode(target)) { // defeat Safari bug (see: http://www.quirksmode.org/js/events_properties.html)
26391 target = target.parentNode;
26392 }
26393
26394 if (
26395 shouldTrackDomEvent(target, ev) &&
26396 isElementAllowed(target, ev, allowElementCallback, allowSelectors) &&
26397 !isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26398 ) {
26399 var targetElementList = [target];
26400 var curEl = target;
26401 while (curEl.parentNode && !isTag(curEl, 'body')) {
26402 targetElementList.push(curEl.parentNode);
26403 curEl = curEl.parentNode;
26404 }
26405
26406 var elementsJson = [];
26407 var href, explicitNoTrack = false;
26408 _.each(targetElementList, function(el) {
26409 var shouldTrackDetails = shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors);
26410
26411 // if the element or a parent element is an anchor tag
26412 // include the href as a property
26413 if (!blockAttrsSet['href'] && el.tagName.toLowerCase() === 'a') {
26414 href = el.getAttribute('href');
26415 href = shouldTrackDetails && shouldTrackValue(href) && href;
26416 }
26417
26418 if (isElementBlocked(el, ev, blockElementCallback, blockSelectors)) {
26419 explicitNoTrack = true;
26420 }
26421
26422 elementsJson.push(getPropertiesFromElement(el, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors));
26423 }, this);
26424
26425 if (!explicitNoTrack) {
26426 var docElement = document$1['documentElement'];
26427 props = {
26428 '$event_type': ev.type,
26429 '$host': win.location.host,
26430 '$pathname': win.location.pathname,
26431 '$elements': elementsJson,
26432 '$el_attr__href': href,
26433 '$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
26434 '$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0),
26435 '$pageHeight': document$1['body']['offsetHeight'] || 0,
26436 '$pageWidth': document$1['body']['offsetWidth'] || 0,
26437 };
26438 _.each(captureExtraAttrs, function(attr) {
26439 if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
26440 var attrVal = target.getAttribute(attr);
26441 if (shouldTrackValue(attrVal)) {
26442 props['$el_attr__' + attr] = attrVal;
26443 }
26444 }
26445 });
26446
26447 if (captureTextContent) {
26448 elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26449 if (elementText && elementText.length) {
26450 props['$el_text'] = elementText;
26451 }
26452 }
26453
26454 if (ev.type === EV_CLICK) {
26455 _.each(CLICK_EVENT_PROPS, function(prop) {
26456 if (prop in ev) {
26457 props['$' + prop] = ev[prop];
26458 }
26459 });
26460 if (capturedForHeatMap) {
26461 props['$captured_for_heatmap'] = true;
26462 }
26463 target = guessRealClickTarget(ev);
26464 }
26465 // prioritize text content from "real" click target if different from original target
26466 if (captureTextContent) {
26467 var elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26468 if (elementText && elementText.length) {
26469 props['$el_text'] = elementText;
26470 }
26471 }
26472
26473 if (target) {
26474 // target may have been recalculated; check allowlists and blocklists again
26475 if (
26476 !isElementAllowed(target, ev, allowElementCallback, allowSelectors) ||
26477 isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26478 ) {
26479 return null;
26480 }
26481
26482 var targetProps = getPropertiesFromElement(target, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors);
26483 props['$target'] = targetProps;
26484 // pull up more props onto main event props
26485 props['$el_classes'] = targetProps['$classes'];
26486 _.extend(props, _.strip_empty_properties({
26487 '$el_id': targetProps['$id'],
26488 '$el_tag_name': targetProps['$tag_name']
26489 }));
26490 }
26491 }
26492 }
26493
26494 return props;
26495 }
26496
26497
26498 /**
26499 * Get the direct text content of an element, protecting against sensitive data collection.
26500 * Concats textContent of each of the element's text node children; this avoids potential
26501 * collection of sensitive data that could happen if we used element.textContent and the
26502 * element had sensitive child elements, since element.textContent includes child content.
26503 * Scrubs values that look like they could be sensitive (i.e. cc or ssn number).
26504 * @param {Element} el - element to get the text of
26505 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
26506 * @returns {string} the element's direct text content
26507 */
26508 function getSafeText(el, ev, allowElementCallback, allowSelectors) {
26509 var elText = '';
26510
26511 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) && el.childNodes && el.childNodes.length) {
26512 _.each(el.childNodes, function(child) {
26513 if (isTextNode(child) && child.textContent) {
26514 elText += _.trim(child.textContent)
26515 // scrub potentially sensitive values
26516 .split(/(\s+)/).filter(shouldTrackValue).join('')
26517 // normalize whitespace
26518 .replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ')
26519 // truncate
26520 .substring(0, 255);
26521 }
26522 });
26523 }
26524
26525 return _.trim(elText);
26526 }
26527
26528 function guessRealClickTarget(ev) {
26529 var target = ev.target;
26530 var composedPath = ev['composedPath']();
26531 for (var i = 0; i < composedPath.length; i++) {
26532 var node = composedPath[i];
26533 if (
26534 isTag(node, 'a') ||
26535 isTag(node, 'button') ||
26536 isTag(node, 'input') ||
26537 isTag(node, 'select') ||
26538 (node.getAttribute && node.getAttribute('role') === 'button')
26539 ) {
26540 target = node;
26541 break;
26542 }
26543 if (node === target) {
26544 break;
26545 }
26546 }
26547 return target;
26548 }
26549
26550 function isElementAllowed(el, ev, allowElementCallback, allowSelectors) {
26551 if (allowElementCallback) {
26552 try {
26553 if (!allowElementCallback(el, ev)) {
26554 return false;
26555 }
26556 } catch (err) {
26557 logger$1.critical('Error while checking element in allowElementCallback', err);
26558 return false;
26559 }
26560 }
26561
26562 if (!allowSelectors.length) {
26563 // no allowlist; all elements are fair game
26564 return true;
26565 }
26566
26567 for (var i = 0; i < allowSelectors.length; i++) {
26568 var sel = allowSelectors[i];
26569 try {
26570 if (el['matches'](sel)) {
26571 return true;
26572 }
26573 } catch (err) {
26574 logger$1.critical('Error while checking selector: ' + sel, err);
26575 }
26576 }
26577 return false;
26578 }
26579
26580 function isElementBlocked(el, ev, blockElementCallback, blockSelectors) {
26581 var i;
26582
26583 if (blockElementCallback) {
26584 try {
26585 if (blockElementCallback(el, ev)) {
26586 return true;
26587 }
26588 } catch (err) {
26589 logger$1.critical('Error while checking element in blockElementCallback', err);
26590 return true;
26591 }
26592 }
26593
26594 if (blockSelectors && blockSelectors.length) {
26595 // programmatically prevent tracking of elements that match CSS selectors
26596 for (i = 0; i < blockSelectors.length; i++) {
26597 var sel = blockSelectors[i];
26598 try {
26599 if (el['matches'](sel)) {
26600 return true;
26601 }
26602 } catch (err) {
26603 logger$1.critical('Error while checking selector: ' + sel, err);
26604 }
26605 }
26606 }
26607
26608 // allow users to programmatically prevent tracking of elements by adding default classes such as 'mp-no-track'
26609 var classes = getClasses(el);
26610 for (i = 0; i < OPT_OUT_CLASSES.length; i++) {
26611 if (classes[OPT_OUT_CLASSES[i]]) {
26612 return true;
26613 }
26614 }
26615
26616 return false;
26617 }
26618
26619 /*
26620 * Check whether a DOM node has nodeType Node.ELEMENT_NODE
26621 * @param {Node} node - node to check
26622 * @returns {boolean} whether node is of the correct nodeType
26623 */
26624 function isElementNode(node) {
26625 return node && node.nodeType === 1; // Node.ELEMENT_NODE - use integer constant for browser portability
26626 }
26627
26628 /*
26629 * Check whether an element is of a given tag type.
26630 * Due to potential reference discrepancies (such as the webcomponents.js polyfill),
26631 * we want to match tagNames instead of specific references because something like
26632 * element === document.body won't always work because element might not be a native
26633 * element.
26634 * @param {Element} el - element to check
26635 * @param {string} tag - tag name (e.g., "div")
26636 * @returns {boolean} whether el is of the given tag type
26637 */
26638 function isTag(el, tag) {
26639 return el && el.tagName && el.tagName.toLowerCase() === tag.toLowerCase();
26640 }
26641
26642 /*
26643 * Check whether a DOM node is a TEXT_NODE
26644 * @param {Node} node - node to check
26645 * @returns {boolean} whether node is of type Node.TEXT_NODE
26646 */
26647 function isTextNode(node) {
26648 return node && node.nodeType === 3; // Node.TEXT_NODE - use integer constant for browser portability
26649 }
26650
26651 function minDOMApisSupported() {
26652 try {
26653 var testEl = document$1.createElement('div');
26654 return !!testEl['matches'];
26655 } catch (err) {
26656 return false;
26657 }
26658 }
26659
26660 function weakSetSupported() {
26661 return typeof WeakSet !== 'undefined';
26662 }
26663
26664 /*
26665 * Check whether a DOM event should be "tracked" or if it may contain sensitive data
26666 * using a variety of heuristics.
26667 * @param {Element} el - element to check
26668 * @param {Event} ev - event to check
26669 * @returns {boolean} whether the event should be tracked
26670 */
26671 function shouldTrackDomEvent(el, ev) {
26672 if (!el || isTag(el, 'html') || !isElementNode(el)) {
26673 return false;
26674 }
26675 var tag = el.tagName.toLowerCase();
26676 switch (tag) {
26677 case 'form':
26678 return ev.type === EV_SUBMIT;
26679 case 'input':
26680 if (['button', 'submit'].indexOf(el.getAttribute('type')) === -1) {
26681 return ev.type === EV_CHANGE;
26682 } else {
26683 return ev.type === EV_CLICK;
26684 }
26685 case 'select':
26686 case 'textarea':
26687 return ev.type === EV_CHANGE;
26688 default:
26689 return ev.type === EV_CLICK;
26690 }
26691 }
26692
26693 /*
26694 * Check whether a DOM element should be "tracked" or if it may contain sensitive data
26695 * using a variety of heuristics.
26696 * @param {Element} el - element to check
26697 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
26698 * @returns {boolean} whether the element should be tracked
26699 */
26700 function shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) {
26701 var i;
26702
26703 if (!isElementAllowed(el, ev, allowElementCallback, allowSelectors)) {
26704 return false;
26705 }
26706
26707 for (var curEl = el; curEl.parentNode && !isTag(curEl, 'body'); curEl = curEl.parentNode) {
26708 var classes = getClasses(curEl);
26709 for (i = 0; i < SENSITIVE_DATA_CLASSES.length; i++) {
26710 if (classes[SENSITIVE_DATA_CLASSES[i]]) {
26711 return false;
26712 }
26713 }
26714 }
26715
26716 var elClasses = getClasses(el);
26717 for (i = 0; i < OPT_IN_CLASSES.length; i++) {
26718 if (elClasses[OPT_IN_CLASSES[i]]) {
26719 return true;
26720 }
26721 }
26722
26723 // don't send data from inputs or similar elements since there will always be
26724 // a risk of clientside javascript placing sensitive data in attributes
26725 if (
26726 isTag(el, 'input') ||
26727 isTag(el, 'select') ||
26728 isTag(el, 'textarea') ||
26729 el.getAttribute('contenteditable') === 'true'
26730 ) {
26731 return false;
26732 }
26733
26734 // don't include hidden or password fields
26735 var type = el.type || '';
26736 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"]
26737 switch(type.toLowerCase()) {
26738 case 'hidden':
26739 return false;
26740 case 'password':
26741 return false;
26742 }
26743 }
26744
26745 // filter out data from fields that look like sensitive fields
26746 var name = el.name || el.id || '';
26747 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"]
26748 var sensitiveNameRegex = /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i;
26749 if (sensitiveNameRegex.test(name.replace(/[^a-zA-Z0-9]/g, ''))) {
26750 return false;
26751 }
26752 }
26753
26754 return true;
26755 }
26756
26757
26758 /*
26759 * Check whether a string value should be "tracked" or if it may contain sensitive data
26760 * using a variety of heuristics.
26761 * @param {string} value - string value to check
26762 * @returns {boolean} whether the element should be tracked
26763 */
26764 function shouldTrackValue(value) {
26765 if (value === null || _.isUndefined(value)) {
26766 return false;
26767 }
26768
26769 if (typeof value === 'string') {
26770 value = _.trim(value);
26771
26772 // check to see if input value looks like a credit card number
26773 // see: https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch04s20.html
26774 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}))$/;
26775 if (ccRegex.test((value || '').replace(/[- ]/g, ''))) {
26776 return false;
26777 }
26778
26779 // check to see if input value looks like a social security number
26780 var ssnRegex = /(^\d{3}-?\d{2}-?\d{4}$)/;
26781 if (ssnRegex.test(value)) {
26782 return false;
26783 }
26784 }
26785
26786 return true;
26787 }
26788
26789 /**
26790 * Creates a cross-browser compatible scroll end function with appropriate event listener.
26791 * For browsers that support scrollend, returns the original function with scrollend event.
26792 * For browsers without scrollend support, returns a debounced function that triggers
26793 * 100ms after the last scroll event to simulate scrollend behavior.
26794 * @param {Function} originalFunction - The function to call when scrolling ends
26795 * @returns {Object} Object containing listener function and eventType string
26796 * @returns {Function} returns.listener - The wrapped function to use as event listener
26797 * @returns {string} returns.eventType - The event type to listen for ('scrollend' or 'scroll')
26798 */
26799 function getPolyfillScrollEndFunction(originalFunction) {
26800 var supportsScrollEnd = 'onscrollend' in win;
26801 var polyfillFunction = safewrap(originalFunction);
26802 var polyfillEvent = EV_SCROLLEND;
26803 if (!supportsScrollEnd) {
26804 // Polyfill for browsers without scrollend support: wait 100ms after the last scroll event
26805 // https://developer.chrome.com/blog/scrollend-a-new-javascript-event
26806 var scrollTimer = null;
26807 var scrollDelayMs = 100;
26808
26809 polyfillFunction = safewrap(function() {
26810 clearTimeout(scrollTimer);
26811 scrollTimer = setTimeout(originalFunction, scrollDelayMs);
26812 });
26813
26814 polyfillEvent = EV_SCROLL;
26815 }
26816
26817 return {
26818 listener: polyfillFunction,
26819 eventType: polyfillEvent
26820 };
26821 }
26822
26823 function hasInlineEventHandlers(element) {
26824 for (var i = 0; i < EVENT_HANDLER_ATTRIBUTES.length; i++) {
26825 if (element.hasAttribute(EVENT_HANDLER_ATTRIBUTES[i])) {
26826 return true;
26827 }
26828 }
26829 return false;
26830 }
26831
26832 function hasInteractiveAriaRole(element) {
26833 var role = element.getAttribute('role');
26834 if (!role) return false;
26835
26836 // Handle invalid markup where multiple roles might be specified
26837 // Only the first token is recognized per ARIA spec
26838 var primaryRole = role.trim().split(/\s+/)[0].toLowerCase();
26839
26840 return INTERACTIVE_ARIA_ROLES[primaryRole];
26841 }
26842
26843 function hasAnyInteractivityIndicators(element) {
26844 var tagName = element.tagName.toLowerCase();
26845
26846 // Check for interactive HTML elements
26847 if (tagName === 'button' ||
26848 tagName === 'input' ||
26849 tagName === 'select' ||
26850 tagName === 'textarea' ||
26851 tagName === 'details' ||
26852 tagName === 'dialog') {
26853 return true;
26854 }
26855
26856 if (element.isContentEditable) {
26857 return true;
26858 }
26859
26860 if (element.onclick || element.onmousedown || element.onmouseup || element.ontouchstart || element.ontouchend) {
26861 return true;
26862 }
26863
26864 if (hasInlineEventHandlers(element)) {
26865 return true;
26866 }
26867
26868 if (hasInteractiveAriaRole(element)) {
26869 return true;
26870 }
26871
26872 if (tagName === 'a' && element.hasAttribute('href')) {
26873 return true;
26874 }
26875
26876 if (element.hasAttribute('tabindex')) {
26877 return true;
26878 }
26879
26880 return false;
26881 }
26882
26883
26884 function isDefinitelyNonInteractive(element) {
26885 if (!element || !element.tagName) {
26886 return true;
26887 }
26888
26889 var tagName = element.tagName.toLowerCase();
26890
26891 // These tags are definitely non-interactive
26892 if (ALWAYS_NON_INTERACTIVE_TAGS[tagName]) {
26893 return true;
26894 }
26895
26896 // For all other elements, we can only be certain they're non-interactive if they lack ALL indicators of interactivity
26897 // Check for any signs of interactivity
26898 if (hasAnyInteractivityIndicators(element)) {
26899 return false;
26900 }
26901
26902 // Check parent chain for interactive context
26903 var parent = element.parentElement;
26904 var depth = 0;
26905
26906 while (parent && depth < MAX_DEPTH) {
26907 if (hasAnyInteractivityIndicators(parent)) {
26908 return false; // Element is inside an interactive parent
26909 }
26910
26911 if (parent.getRootNode && parent.getRootNode() !== document$1) {
26912 var root = parent.getRootNode();
26913 if (root.host && hasAnyInteractivityIndicators(root.host)) {
26914 return false; // Inside an interactive shadow host
26915 }
26916 }
26917
26918 parent = parent.parentElement;
26919 depth++;
26920 }
26921
26922 // Pure text containers without any interactive context
26923 if (TEXT_CONTAINER_TAGS[tagName]) {
26924 // These are non-interactive ONLY if they have no interactive indicators (already checked as part of hasAnyInteractivityIndicators)
26925 return true;
26926 }
26927
26928 // Default: we can't be certain it's non-interactive
26929 return false;
26930 }
26931
26932 /** @const */ var DEFAULT_RAGE_CLICK_THRESHOLD_PX = 30;
26933 /** @const */ var DEFAULT_RAGE_CLICK_TIMEOUT_MS = 1000;
26934 /** @const */ var DEFAULT_RAGE_CLICK_CLICK_COUNT = 4;
26935
26936 function RageClickTracker() {
26937 this.clicks = [];
26938 }
26939
26940 RageClickTracker.prototype.isRageClick = function(x, y, options) {
26941 options = options || {};
26942 var thresholdPx = options['threshold_px'] || DEFAULT_RAGE_CLICK_THRESHOLD_PX;
26943 var timeoutMs = options['timeout_ms'] || DEFAULT_RAGE_CLICK_TIMEOUT_MS;
26944 var clickCount = options['click_count'] || DEFAULT_RAGE_CLICK_CLICK_COUNT;
26945 var timestamp = Date.now();
26946
26947 var lastClick = this.clicks[this.clicks.length - 1];
26948 if (
26949 lastClick &&
26950 timestamp - lastClick.timestamp < timeoutMs &&
26951 Math.sqrt(Math.pow(x - lastClick.x, 2) + Math.pow(y - lastClick.y, 2)) < thresholdPx
26952 ) {
26953 this.clicks.push({ x: x, y: y, timestamp: timestamp });
26954 if (this.clicks.length >= clickCount) {
26955 this.clicks = [];
26956 return true;
26957 }
26958 } else {
26959 this.clicks = [{ x: x, y: y, timestamp: timestamp }];
26960 }
26961 return false;
26962 };
26963
26964 function ShadowDOMObserver(changeCallback, observerConfig) {
26965 this.changeCallback = changeCallback || function() {};
26966 this.observerConfig = observerConfig;
26967
26968 this.observedShadowRoots = null;
26969 this.shadowObservers = [];
26970 }
26971
26972 ShadowDOMObserver.prototype.getEventTarget = function(event) {
26973 if (!this.observedShadowRoots) {
26974 return;
26975 }
26976 var path = this.getComposedPath(event);
26977 if (path && path.length) {
26978 return path[0];
26979 }
26980
26981 return event['target'] || event['srcElement'];
26982 };
26983
26984
26985 ShadowDOMObserver.prototype.getComposedPath = function(event) {
26986 if ('composedPath' in event) {
26987 return event['composedPath']();
26988 }
26989
26990 return [];
26991 };
26992 ShadowDOMObserver.prototype.observeFromEvent = function(event) {
26993 if (!this.observedShadowRoots) {
26994 return;
26995 }
26996
26997 var path = this.getComposedPath(event);
26998
26999 // Check each element in path for shadow roots
27000 for (var i = 0; i < path.length; i++) {
27001 var element = path[i];
27002
27003 if (element && element.shadowRoot) {
27004 this.observeShadowRoot(element.shadowRoot);
27005 }
27006 }
27007 };
27008
27009
27010 ShadowDOMObserver.prototype.observeShadowRoot = function(shadowRoot) {
27011 if (!this.observedShadowRoots || this.observedShadowRoots.has(shadowRoot)) {
27012 return;
27013 }
27014
27015 var self = this;
27016
27017 try {
27018 this.observedShadowRoots.add(shadowRoot);
27019
27020 var observer = new window.MutationObserver(function() {
27021 self.changeCallback();
27022 });
27023
27024 observer.observe(shadowRoot, this.observerConfig);
27025 this.shadowObservers.push(observer);
27026 } catch (e) {
27027 logger$1.critical('Error while observing shadow root', e);
27028 }
27029 };
27030
27031
27032 ShadowDOMObserver.prototype.start = function() {
27033 if (this.observedShadowRoots) {
27034 return;
27035 }
27036
27037 if (!weakSetSupported()) {
27038 logger$1.critical('Shadow DOM observation unavailable: WeakSet not supported');
27039 return;
27040 }
27041
27042 this.observedShadowRoots = new WeakSet();
27043 };
27044
27045 ShadowDOMObserver.prototype.stop = function() {
27046 if (!this.observedShadowRoots) {
27047 return;
27048 }
27049
27050 for (var i = 0; i < this.shadowObservers.length; i++) {
27051 try {
27052 this.shadowObservers[i].disconnect();
27053 } catch (e) {
27054 logger$1.critical('Error while disconnecting shadow DOM observer', e);
27055 }
27056 }
27057 this.shadowObservers = [];
27058 this.observedShadowRoots = null;
27059 };
27060
27061 /** @const */ var DEFAULT_DEAD_CLICK_TIMEOUT_MS = 500;
27062 /** @const */ var INTERACTION_EVENTS = [EV_CHANGE, EV_INPUT, EV_SUBMIT, EV_SELECT, EV_TOGGLE];
27063 /** @const */ var LAYOUT_EVENTS = [EV_SCROLLEND];
27064 /** @const */ var NAVIGATION_EVENTS = [EV_HASHCHANGE];
27065 /** @const */ var MUTATION_OBSERVER_CONFIG = {
27066 characterData: true,
27067 childList: true,
27068 subtree: true,
27069 attributes: true,
27070 attributeFilter: ['style', 'class', 'hidden', 'checked', 'selected', 'value', 'display', 'visibility']
27071 };
27072
27073
27074 function DeadClickTracker(onDeadClickCallback) {
27075 this.eventListeners = [];
27076 this.mutationObserver = null;
27077 this.shadowDOMObserver = null;
27078
27079 this.isTracking = false;
27080 this.lastChangeEventTimestamp = 0;
27081 this.pendingClicks = [];
27082 this.onDeadClickCallback = onDeadClickCallback;
27083 this.processingActive = false;
27084 this.processingTimeout = null;
27085 }
27086
27087
27088 DeadClickTracker.prototype.addClick = function(event) {
27089 var element = this.shadowDOMObserver && this.shadowDOMObserver.getEventTarget(event);
27090
27091 if (!element) {
27092 element = event['target'] || event['srcElement'];
27093 }
27094
27095 if (!element || isDefinitelyNonInteractive(element)) {
27096 return false;
27097 }
27098
27099 if (this.shadowDOMObserver) {
27100 this.shadowDOMObserver.observeFromEvent(event);
27101 }
27102 this.pendingClicks.push({
27103 element: element,
27104 event: event,
27105 timestamp: Date.now()
27106 });
27107 return true;
27108 };
27109
27110 DeadClickTracker.prototype.trackClick = function(event, config) {
27111 if (!this.isTracking) {
27112 return false;
27113 }
27114
27115 var added = this.addClick(event);
27116 if (added) {
27117 this.triggerProcessing(config);
27118 }
27119 return added;
27120 };
27121
27122 DeadClickTracker.prototype.getDeadClicks = function(config) {
27123 if (this.pendingClicks.length === 0) {
27124 return [];
27125 }
27126
27127 var timeoutMs = config['timeout_ms'];
27128 var now = Date.now();
27129 var clicksToEvaluate = this.pendingClicks.slice(); // Copy array
27130 this.pendingClicks = []; // Clear original
27131
27132 var deadClicks = [];
27133
27134 for (var i = 0; i < clicksToEvaluate.length; i++) {
27135 var click = clicksToEvaluate[i];
27136
27137 if (now - click.timestamp >= timeoutMs) {
27138 // Click has exceeded timeout, check if it's dead by looking for changes after this specific click
27139 if (!this.hasChangesAfter(click.timestamp)) {
27140 deadClicks.push(click);
27141 }
27142 } else {
27143 // Still pending - add back
27144 this.pendingClicks.push(click);
27145 }
27146 }
27147
27148 return deadClicks;
27149 };
27150
27151 DeadClickTracker.prototype.hasChangesAfter = function(timestamp) {
27152 // 100ms tolerance for race condition between when we record the click and the change event
27153 return this.lastChangeEventTimestamp >= (timestamp - 100);
27154 };
27155
27156 DeadClickTracker.prototype.recordChangeEvent = function() {
27157 this.lastChangeEventTimestamp = Date.now();
27158 };
27159
27160 DeadClickTracker.prototype.triggerProcessing = function(config) {
27161 // Prevent multiple concurrent processing chains
27162 if (this.processingActive) {
27163 return;
27164 }
27165 this.processingActive = true;
27166 this.processRecursively(config);
27167 };
27168
27169 DeadClickTracker.prototype.processRecursively = function(config) {
27170 if (!this.isTracking || !this.onDeadClickCallback) {
27171 this.processingActive = false;
27172 return;
27173 }
27174
27175 var timeoutMs = config['timeout_ms'];
27176 var self = this;
27177
27178 this.processingTimeout = setTimeout(function() {
27179 if (!self.processingActive) {
27180 return;
27181 }
27182
27183 var deadClicks = self.getDeadClicks(config);
27184
27185 for (var i = 0; i < deadClicks.length; i++) {
27186 self.onDeadClickCallback(deadClicks[i].event);
27187 }
27188
27189 if (self.pendingClicks.length > 0) {
27190 self.processRecursively(config);
27191 } else {
27192 self.processingActive = false;
27193 }
27194 }, timeoutMs);
27195 };
27196
27197 DeadClickTracker.prototype.startTracking = function() {
27198 if (this.isTracking) {
27199 return;
27200 }
27201
27202 this.isTracking = true;
27203
27204 var self = this;
27205
27206 INTERACTION_EVENTS.forEach(function(event) {
27207 var handler = function() {
27208 self.recordChangeEvent();
27209 };
27210 document.addEventListener(event, handler, { capture: true, passive: true });
27211 self.eventListeners.push({ target: document, event: event, handler: handler, options: { capture: true, passive: true } });
27212 });
27213 NAVIGATION_EVENTS.forEach(function(event) {
27214 var handler = function() {
27215 self.recordChangeEvent();
27216 };
27217 window.addEventListener(event, handler);
27218 self.eventListeners.push({ target: window, event: event, handler: handler });
27219 });
27220 LAYOUT_EVENTS.forEach(function(event) {
27221 var handler = function() {
27222 self.recordChangeEvent();
27223 };
27224 window.addEventListener(event, handler, { passive: true });
27225 self.eventListeners.push({ target: window, event: event, handler: handler, options: { passive: true } });
27226 });
27227 var selectionHandler = function() {
27228 self.recordChangeEvent();
27229 };
27230 document.addEventListener('selectionchange', selectionHandler);
27231 self.eventListeners.push({ target: document, event: 'selectionchange', handler: selectionHandler });
27232
27233 // Set up MutationObserver
27234 if (window.MutationObserver) {
27235 try {
27236 this.mutationObserver = new window.MutationObserver(function() {
27237 self.recordChangeEvent();
27238 });
27239
27240 this.mutationObserver.observe(document.body || document.documentElement, MUTATION_OBSERVER_CONFIG);
27241 } catch (e) {
27242 logger$1.critical('Error while setting up mutation observer', e);
27243 }
27244 }
27245
27246 // Set up Shadow DOM observer
27247 if (window.customElements) {
27248 try {
27249 this.shadowDOMObserver = new ShadowDOMObserver(
27250 function() {
27251 self.recordChangeEvent();
27252 },
27253 MUTATION_OBSERVER_CONFIG
27254 );
27255 this.shadowDOMObserver.start();
27256 } catch (e) {
27257 logger$1.critical('Error while setting up shadow DOM observer', e);
27258 this.shadowDOMObserver = null;
27259 }
27260 }
27261 };
27262
27263 DeadClickTracker.prototype.stopTracking = function() {
27264 if (!this.isTracking) {
27265 return;
27266 }
27267
27268 this.isTracking = false;
27269 this.pendingClicks = [];
27270 this.lastChangeEventTimestamp = 0;
27271 this.processingActive = false;
27272
27273 if (this.processingTimeout) {
27274 clearTimeout(this.processingTimeout);
27275 this.processingTimeout = null;
27276 }
27277
27278 // Remove all event listeners
27279 for (var i = 0; i < this.eventListeners.length; i++) {
27280 var listener = this.eventListeners[i];
27281 try {
27282 listener.target.removeEventListener(listener.event, listener.handler, listener.options);
27283 } catch (e) {
27284 logger$1.critical('Error while removing event listener', e);
27285 }
27286 }
27287 this.eventListeners = [];
27288
27289 if (this.mutationObserver) {
27290 try {
27291 this.mutationObserver.disconnect();
27292 } catch (e) {
27293 logger$1.critical('Error while disconnecting mutation observer', e);
27294 }
27295 this.mutationObserver = null;
27296 }
27297
27298 if (this.shadowDOMObserver) {
27299 try {
27300 this.shadowDOMObserver.stop();
27301 } catch (e) {
27302 logger$1.critical('Error while stopping shadow DOM observer', e);
27303 }
27304 this.shadowDOMObserver = null;
27305 }
27306 };
27307
27308 var AUTOCAPTURE_CONFIG_KEY = 'autocapture';
27309 var LEGACY_PAGEVIEW_CONFIG_KEY = 'track_pageview';
27310
27311 var PAGEVIEW_OPTION_FULL_URL = 'full-url';
27312 var PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING = 'url-with-path-and-query-string';
27313 var PAGEVIEW_OPTION_URL_WITH_PATH = 'url-with-path';
27314
27315 var CONFIG_ALLOW_ELEMENT_CALLBACK = 'allow_element_callback';
27316 var CONFIG_ALLOW_SELECTORS = 'allow_selectors';
27317 var CONFIG_ALLOW_URL_REGEXES = 'allow_url_regexes';
27318 var CONFIG_BLOCK_ATTRS = 'block_attrs';
27319 var CONFIG_BLOCK_ELEMENT_CALLBACK = 'block_element_callback';
27320 var CONFIG_BLOCK_SELECTORS = 'block_selectors';
27321 var CONFIG_BLOCK_URL_REGEXES = 'block_url_regexes';
27322 var CONFIG_CAPTURE_EXTRA_ATTRS = 'capture_extra_attrs';
27323 var CONFIG_CAPTURE_TEXT_CONTENT = 'capture_text_content';
27324 var CONFIG_SCROLL_CAPTURE_ALL = 'scroll_capture_all';
27325 var CONFIG_SCROLL_CHECKPOINTS = 'scroll_depth_percent_checkpoints';
27326 var CONFIG_TRACK_CLICK = 'click';
27327 var CONFIG_TRACK_DEAD_CLICK = 'dead_click';
27328 var CONFIG_TRACK_INPUT = 'input';
27329 var CONFIG_TRACK_PAGEVIEW = 'pageview';
27330 var CONFIG_TRACK_RAGE_CLICK = 'rage_click';
27331 var CONFIG_TRACK_SCROLL = 'scroll';
27332 var CONFIG_TRACK_PAGE_LEAVE = 'page_leave';
27333 var CONFIG_TRACK_SUBMIT = 'submit';
27334
27335 var CONFIG_DEFAULTS$1 = {};
27336 CONFIG_DEFAULTS$1[CONFIG_ALLOW_SELECTORS] = [];
27337 CONFIG_DEFAULTS$1[CONFIG_ALLOW_URL_REGEXES] = [];
27338 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ATTRS] = [];
27339 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ELEMENT_CALLBACK] = null;
27340 CONFIG_DEFAULTS$1[CONFIG_BLOCK_SELECTORS] = [];
27341 CONFIG_DEFAULTS$1[CONFIG_BLOCK_URL_REGEXES] = [];
27342 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_EXTRA_ATTRS] = [];
27343 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_TEXT_CONTENT] = false;
27344 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CAPTURE_ALL] = false;
27345 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CHECKPOINTS] = [25, 50, 75, 100];
27346 CONFIG_DEFAULTS$1[CONFIG_TRACK_CLICK] = true;
27347 CONFIG_DEFAULTS$1[CONFIG_TRACK_DEAD_CLICK] = true;
27348 CONFIG_DEFAULTS$1[CONFIG_TRACK_INPUT] = true;
27349 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGEVIEW] = PAGEVIEW_OPTION_FULL_URL;
27350 CONFIG_DEFAULTS$1[CONFIG_TRACK_RAGE_CLICK] = true;
27351 CONFIG_DEFAULTS$1[CONFIG_TRACK_SCROLL] = true;
27352 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGE_LEAVE] = false;
27353 CONFIG_DEFAULTS$1[CONFIG_TRACK_SUBMIT] = true;
27354
27355 var DEFAULT_PROPS = {
27356 '$mp_autocapture': true
27357 };
27358
27359 var MP_EV_CLICK = '$mp_click';
27360 var MP_EV_DEAD_CLICK = '$mp_dead_click';
27361 var MP_EV_INPUT = '$mp_input_change';
27362 var MP_EV_RAGE_CLICK = '$mp_rage_click';
27363 var MP_EV_SCROLL = '$mp_scroll';
27364 var MP_EV_SUBMIT = '$mp_submit';
27365 var MP_EV_PAGE_LEAVE = '$mp_page_leave';
27366
27367 /**
27368 * Autocapture: manages automatic event tracking
27369 * @constructor
27370 */
27371 var Autocapture = function(mp) {
27372 this.mp = mp;
27373 this.maxScrollViewDepth = 0;
27374 this.hasTrackedScrollSession = false;
27375 this.previousScrollHeight = 0;
27376 };
27377
27378 Autocapture.prototype.init = function() {
27379 if (!minDOMApisSupported()) {
27380 logger$1.critical('Autocapture unavailable: missing required DOM APIs');
27381 return;
27382 }
27383 this.initPageListeners();
27384 this.initPageviewTracking();
27385 this.initClickTracking();
27386 this.initDeadClickTracking();
27387 this.initInputTracking();
27388 this.initScrollTracking();
27389 this.initSubmitTracking();
27390 this.initRageClickTracking();
27391 this.initPageLeaveTracking();
27392 };
27393
27394 Autocapture.prototype.getFullConfig = function() {
27395 var autocaptureConfig = this.mp.get_config(AUTOCAPTURE_CONFIG_KEY);
27396 if (!autocaptureConfig) {
27397 // Autocapture is completely off
27398 return {};
27399 } else if (_.isObject(autocaptureConfig)) {
27400 return _.extend({}, CONFIG_DEFAULTS$1, autocaptureConfig);
27401 } else {
27402 // Autocapture config is non-object truthy value, return default
27403 return CONFIG_DEFAULTS$1;
27404 }
27405 };
27406
27407 Autocapture.prototype.getConfig = function(key) {
27408 return this.getFullConfig()[key];
27409 };
27410
27411 Autocapture.prototype.currentUrlBlocked = function() {
27412 var i;
27413 var currentUrl = _.info.currentUrl();
27414
27415 var allowUrlRegexes = this.getConfig(CONFIG_ALLOW_URL_REGEXES) || [];
27416 if (allowUrlRegexes.length) {
27417 // we're using an allowlist, only track if current URL matches
27418 var allowed = false;
27419 for (i = 0; i < allowUrlRegexes.length; i++) {
27420 var allowRegex = allowUrlRegexes[i];
27421 try {
27422 if (currentUrl.match(allowRegex)) {
27423 allowed = true;
27424 break;
27425 }
27426 } catch (err) {
27427 logger$1.critical('Error while checking block URL regex: ' + allowRegex, err);
27428 return true;
27429 }
27430 }
27431 if (!allowed) {
27432 // wasn't allowed by any regex
27433 return true;
27434 }
27435 }
27436
27437 var blockUrlRegexes = this.getConfig(CONFIG_BLOCK_URL_REGEXES) || [];
27438 if (!blockUrlRegexes || !blockUrlRegexes.length) {
27439 return false;
27440 }
27441
27442 for (i = 0; i < blockUrlRegexes.length; i++) {
27443 try {
27444 if (currentUrl.match(blockUrlRegexes[i])) {
27445 return true;
27446 }
27447 } catch (err) {
27448 logger$1.critical('Error while checking block URL regex: ' + blockUrlRegexes[i], err);
27449 return true;
27450 }
27451 }
27452 return false;
27453 };
27454
27455 Autocapture.prototype.pageviewTrackingConfig = function() {
27456 // supports both autocapture config and old track_pageview config
27457 if (this.mp.get_config(AUTOCAPTURE_CONFIG_KEY)) {
27458 return this.getConfig(CONFIG_TRACK_PAGEVIEW);
27459 } else {
27460 return this.mp.get_config(LEGACY_PAGEVIEW_CONFIG_KEY);
27461 }
27462 };
27463
27464 // helper for event handlers
27465 Autocapture.prototype.trackDomEvent = function(ev, mpEventName) {
27466 if (this.currentUrlBlocked()) {
27467 return;
27468 }
27469
27470 var isCapturedForHeatMap = this.mp.is_recording_heatmap_data() && (
27471 (mpEventName === MP_EV_CLICK && !this.getConfig(CONFIG_TRACK_CLICK)) ||
27472 (mpEventName === MP_EV_RAGE_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK)) ||
27473 (mpEventName === MP_EV_DEAD_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK))
27474 );
27475
27476 var props = getPropsForDOMEvent(ev, {
27477 allowElementCallback: this.getConfig(CONFIG_ALLOW_ELEMENT_CALLBACK),
27478 allowSelectors: this.getConfig(CONFIG_ALLOW_SELECTORS),
27479 blockAttrs: this.getConfig(CONFIG_BLOCK_ATTRS),
27480 blockElementCallback: this.getConfig(CONFIG_BLOCK_ELEMENT_CALLBACK),
27481 blockSelectors: this.getConfig(CONFIG_BLOCK_SELECTORS),
27482 captureExtraAttrs: this.getConfig(CONFIG_CAPTURE_EXTRA_ATTRS),
27483 captureTextContent: this.getConfig(CONFIG_CAPTURE_TEXT_CONTENT),
27484 capturedForHeatMap: isCapturedForHeatMap,
27485 });
27486 if (props) {
27487 _.extend(props, DEFAULT_PROPS);
27488 this.mp.track(mpEventName, props);
27489 }
27490 };
27491
27492 Autocapture.prototype.initPageListeners = function() {
27493 win.removeEventListener(EV_POPSTATE, this.listenerPopstate);
27494 win.removeEventListener(EV_HASHCHANGE, this.listenerHashchange);
27495
27496 if (!this.pageviewTrackingConfig() && !this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
27497 // These are all the configs that use these listeners
27498 return;
27499 }
27500
27501 this.listenerPopstate = function() {
27502 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27503 };
27504 this.listenerHashchange = function() {
27505 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27506 };
27507
27508 win.addEventListener(EV_POPSTATE, this.listenerPopstate);
27509 win.addEventListener(EV_HASHCHANGE, this.listenerHashchange);
27510 var nativePushState = win.history.pushState;
27511 if (typeof nativePushState === 'function') {
27512 win.history.pushState = function(state, unused, url) {
27513 nativePushState.call(win.history, state, unused, url);
27514 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27515 };
27516 }
27517 var nativeReplaceState = win.history.replaceState;
27518 if (typeof nativeReplaceState === 'function') {
27519 win.history.replaceState = function(state, unused, url) {
27520 nativeReplaceState.call(win.history, state, unused, url);
27521 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27522 };
27523 }
27524 };
27525
27526 Autocapture.prototype._getClickTrackingConfig = function(configKey) {
27527 var config = this.getConfig(configKey);
27528
27529 if (!config) {
27530 return null; // click tracking disabled
27531 }
27532
27533 if (config === true) {
27534 return {}; // use defaults
27535 }
27536
27537 if (typeof config === 'object') {
27538 return config; // use custom configuration
27539 }
27540
27541 return {}; // fallback to defaults for any other truthy value
27542 };
27543
27544 Autocapture.prototype._trackPageLeave = function(ev, currentUrl, currentScrollHeight) {
27545 if (this.hasTrackedScrollSession) {
27546 // User has navigated away already ending their impression.
27547 return;
27548 }
27549
27550 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.is_recording_heatmap_data()) {
27551 return;
27552 }
27553
27554 this.hasTrackedScrollSession = true;
27555 var viewportHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
27556 var scrollPercentage = Math.round(Math.max(this.maxScrollViewDepth - viewportHeight, 0) / (currentScrollHeight - viewportHeight) * 100);
27557 var foldLinePercentage = Math.round((viewportHeight / currentScrollHeight) * 100);
27558 if (currentScrollHeight <= viewportHeight) {
27559 // If the content fits within the viewport, consider it fully scrolled
27560 scrollPercentage = 100;
27561 foldLinePercentage = 100;
27562 }
27563
27564 var props = _.extend({
27565 '$max_scroll_view_depth': this.maxScrollViewDepth,
27566 '$max_scroll_percentage': scrollPercentage,
27567 '$fold_line_percentage': foldLinePercentage,
27568 '$scroll_height': currentScrollHeight,
27569 '$event_type': ev.type,
27570 '$current_url': currentUrl || _.info.currentUrl(),
27571 '$viewportHeight': viewportHeight, // This is the fold line
27572 '$viewportWidth': Math.max(document$1.documentElement.clientWidth, win.innerWidth || 0),
27573 '$captured_for_heatmap': this.mp.is_recording_heatmap_data()
27574 }, DEFAULT_PROPS);
27575
27576 // Send with beacon transport to ensure event is sent before unload
27577 this.mp.track(MP_EV_PAGE_LEAVE, props, {transport: 'sendBeacon'});
27578 };
27579
27580 Autocapture.prototype._initScrollDepthTracking = function() {
27581 win.removeEventListener(EV_SCROLL, this.listenerScrollDepth);
27582 win.removeEventListener(EV_SCROLLEND, this.listenerScrollDepth);
27583
27584 if (!this.mp.get_config('record_heatmap_data')) {
27585 return;
27586 }
27587
27588 logger$1.log('Initializing scroll depth tracking');
27589
27590 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
27591
27592 var updateScrollDepth = function() {
27593 if (this.currentUrlBlocked()) {
27594 return;
27595 }
27596 var scrollViewHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0) + win.scrollY;
27597 if (scrollViewHeight > this.maxScrollViewDepth) {
27598 this.maxScrollViewDepth = scrollViewHeight;
27599 }
27600 this.previousScrollHeight = document$1.body.scrollHeight;
27601 }.bind(this);
27602
27603 var scrollEndPolyfill = getPolyfillScrollEndFunction(updateScrollDepth);
27604 this.listenerScrollDepth = scrollEndPolyfill.listener;
27605 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScrollDepth);
27606 };
27607
27608 Autocapture.prototype.initClickTracking = function() {
27609 win.removeEventListener(EV_CLICK, this.listenerClick);
27610
27611 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.get_config('record_heatmap_data')) {
27612 return;
27613 }
27614 logger$1.log('Initializing click tracking');
27615
27616 this.listenerClick = function(ev) {
27617 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.is_recording_heatmap_data()) {
27618 return;
27619 }
27620 this.trackDomEvent(ev, MP_EV_CLICK);
27621 }.bind(this);
27622 win.addEventListener(EV_CLICK, this.listenerClick);
27623 };
27624
27625 Autocapture.prototype.initDeadClickTracking = function() {
27626 var deadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
27627
27628 if (!deadClickConfig && !this.mp.get_config('record_heatmap_data')) {
27629 this.stopDeadClickTracking();
27630 return;
27631 }
27632
27633 logger$1.log('Initializing dead click tracking');
27634 if (!this._deadClickTracker) {
27635 this._deadClickTracker = new DeadClickTracker(function(deadClickEvent) {
27636 this.trackDomEvent(deadClickEvent, MP_EV_DEAD_CLICK);
27637 }.bind(this));
27638 this._deadClickTracker.startTracking();
27639 }
27640
27641 if (!this.listenerDeadClick) {
27642 this.listenerDeadClick = function(ev) {
27643 var currentDeadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
27644 if (!currentDeadClickConfig && !this.mp.is_recording_heatmap_data()) {
27645 return;
27646 }
27647 if (this.currentUrlBlocked()) {
27648 return;
27649 }
27650 // Normalize config to ensure timeout_ms is always set
27651 var normalizedConfig = currentDeadClickConfig || {};
27652 if (!normalizedConfig['timeout_ms']) {
27653 normalizedConfig['timeout_ms'] = DEFAULT_DEAD_CLICK_TIMEOUT_MS;
27654 }
27655 this._deadClickTracker.trackClick(ev, normalizedConfig);
27656 }.bind(this);
27657 win.addEventListener(EV_CLICK, this.listenerDeadClick);
27658 }
27659 };
27660
27661 Autocapture.prototype.initInputTracking = function() {
27662 win.removeEventListener(EV_CHANGE, this.listenerChange);
27663
27664 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
27665 return;
27666 }
27667 logger$1.log('Initializing input tracking');
27668
27669 this.listenerChange = function(ev) {
27670 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
27671 return;
27672 }
27673 this.trackDomEvent(ev, MP_EV_INPUT);
27674 }.bind(this);
27675 win.addEventListener(EV_CHANGE, this.listenerChange);
27676 };
27677
27678 Autocapture.prototype.initPageviewTracking = function() {
27679 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
27680
27681 if (!this.pageviewTrackingConfig()) {
27682 return;
27683 }
27684 logger$1.log('Initializing pageview tracking');
27685
27686 var previousTrackedUrl = '';
27687 var tracked = false;
27688 if (!this.currentUrlBlocked()) {
27689 tracked = this.mp.track_pageview(DEFAULT_PROPS);
27690 }
27691 if (tracked) {
27692 previousTrackedUrl = _.info.currentUrl();
27693 }
27694
27695 this.listenerLocationchange = safewrap(function() {
27696 if (this.currentUrlBlocked()) {
27697 return;
27698 }
27699
27700 var currentUrl = _.info.currentUrl();
27701 var shouldTrack = false;
27702 var didPathChange = currentUrl.split('#')[0].split('?')[0] !== previousTrackedUrl.split('#')[0].split('?')[0];
27703 var trackPageviewOption = this.pageviewTrackingConfig();
27704 if (trackPageviewOption === PAGEVIEW_OPTION_FULL_URL) {
27705 shouldTrack = currentUrl !== previousTrackedUrl;
27706 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING) {
27707 shouldTrack = currentUrl.split('#')[0] !== previousTrackedUrl.split('#')[0];
27708 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH) {
27709 shouldTrack = didPathChange;
27710 }
27711
27712 if (shouldTrack) {
27713 var tracked = this.mp.track_pageview(DEFAULT_PROPS);
27714 if (tracked) {
27715 previousTrackedUrl = currentUrl;
27716 }
27717 if (didPathChange) {
27718 this.lastScrollCheckpoint = 0;
27719 logger$1.log('Path change: re-initializing scroll depth checkpoints');
27720 }
27721 }
27722 }.bind(this));
27723 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
27724 };
27725
27726 Autocapture.prototype.initRageClickTracking = function() {
27727 win.removeEventListener(EV_CLICK, this.listenerRageClick);
27728
27729 var rageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
27730 if (!rageClickConfig && !this.mp.get_config('record_heatmap_data')) {
27731 return;
27732 }
27733
27734 logger$1.log('Initializing rage click tracking');
27735 if (!this._rageClickTracker) {
27736 this._rageClickTracker = new RageClickTracker();
27737 }
27738
27739 this.listenerRageClick = function(ev) {
27740 var currentRageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
27741 if (!currentRageClickConfig && !this.mp.is_recording_heatmap_data()) {
27742 return;
27743 }
27744
27745 if (this.currentUrlBlocked()) {
27746 return;
27747 }
27748
27749 if (this._rageClickTracker.isRageClick(ev['pageX'], ev['pageY'], currentRageClickConfig)) {
27750 this.trackDomEvent(ev, MP_EV_RAGE_CLICK);
27751 }
27752 }.bind(this);
27753 win.addEventListener(EV_CLICK, this.listenerRageClick);
27754 };
27755
27756 Autocapture.prototype.initScrollTracking = function() {
27757 win.removeEventListener(EV_SCROLLEND, this.listenerScroll);
27758 win.removeEventListener(EV_SCROLL, this.listenerScroll);
27759
27760
27761 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
27762 return;
27763 }
27764 logger$1.log('Initializing scroll tracking');
27765 this.lastScrollCheckpoint = 0;
27766
27767 var scrollTrackFunction = function() {
27768 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
27769 return;
27770 }
27771 if (this.currentUrlBlocked()) {
27772 return;
27773 }
27774
27775 var shouldTrack = this.getConfig(CONFIG_SCROLL_CAPTURE_ALL);
27776 var scrollCheckpoints = (this.getConfig(CONFIG_SCROLL_CHECKPOINTS) || [])
27777 .slice()
27778 .sort(function(a, b) { return a - b; });
27779
27780 var scrollTop = win.scrollY;
27781 var props = _.extend({'$scroll_top': scrollTop}, DEFAULT_PROPS);
27782 try {
27783 var scrollHeight = document$1.body.scrollHeight;
27784 var scrollPercentage = Math.round((scrollTop / (scrollHeight - win.innerHeight)) * 100);
27785 props['$scroll_height'] = scrollHeight;
27786 props['$scroll_percentage'] = scrollPercentage;
27787 if (scrollPercentage > this.lastScrollCheckpoint) {
27788 for (var i = 0; i < scrollCheckpoints.length; i++) {
27789 var checkpoint = scrollCheckpoints[i];
27790 if (
27791 scrollPercentage >= checkpoint &&
27792 this.lastScrollCheckpoint < checkpoint
27793 ) {
27794 props['$scroll_checkpoint'] = checkpoint;
27795 this.lastScrollCheckpoint = checkpoint;
27796 shouldTrack = true;
27797 }
27798 }
27799 }
27800 } catch (err) {
27801 logger$1.critical('Error while calculating scroll percentage', err);
27802 }
27803 if (shouldTrack) {
27804 this.mp.track(MP_EV_SCROLL, props);
27805 }
27806 }.bind(this);
27807
27808 var scrollEndPolyfill = getPolyfillScrollEndFunction(scrollTrackFunction);
27809 this.listenerScroll = scrollEndPolyfill.listener;
27810 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScroll);
27811 };
27812
27813 Autocapture.prototype.initSubmitTracking = function() {
27814 win.removeEventListener(EV_SUBMIT, this.listenerSubmit);
27815
27816 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
27817 return;
27818 }
27819 logger$1.log('Initializing submit tracking');
27820
27821 this.listenerSubmit = function(ev) {
27822 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
27823 return;
27824 }
27825 this.trackDomEvent(ev, MP_EV_SUBMIT);
27826 }.bind(this);
27827 win.addEventListener(EV_SUBMIT, this.listenerSubmit);
27828 };
27829
27830 Autocapture.prototype.initPageLeaveTracking = function() {
27831 // Capture page_leave both when the user navigates away from the page (visibilitychange) as well
27832 // as when they navigate to a different page within the SPA (popstate/pushstate/hashchange).
27833 document$1.removeEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
27834 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
27835 win.removeEventListener(EV_LOAD, this.listenerPageLoad);
27836
27837 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
27838 return;
27839 }
27840
27841 logger$1.log('Initializing page visibility tracking.');
27842 this._initScrollDepthTracking();
27843 var previousTrackedUrl = _.info.currentUrl();
27844
27845 // Initialize previousScrollHeight on `load` which handles async loading
27846 // https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
27847 this.listenerPageLoad = function() {
27848 this.previousScrollHeight = document$1.body.scrollHeight;
27849 }.bind(this);
27850 win.addEventListener(EV_LOAD, this.listenerPageLoad);
27851
27852 // Track page navigation events similar to how initPageviewTracking does it
27853 this.listenerPageLeaveLocationchange = safewrap(function(ev) {
27854 if (this.currentUrlBlocked()) {
27855 return;
27856 }
27857
27858 var currentUrl = _.info.currentUrl();
27859 // Track all URL changes including query string or fragment changes as separate scroll sessions
27860 var shouldTrack = currentUrl !== previousTrackedUrl;
27861
27862 if (shouldTrack) {
27863 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
27864 previousTrackedUrl = currentUrl;
27865 // Fragment navigation should call scroll(end) and trigger listener, don't add window.scrollY here.
27866 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
27867 this.previousScrollHeight = document$1.body.scrollHeight;
27868 this.hasTrackedScrollSession = false;
27869 }
27870 }.bind(this));
27871 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
27872
27873 this.listenerPageLeaveVisibilitychange = function(ev) {
27874 if (document$1.hidden) {
27875 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
27876 }
27877 }.bind(this);
27878 document$1.addEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
27879 };
27880
27881 Autocapture.prototype.stopDeadClickTracking = function() {
27882 if (this.listenerDeadClick) {
27883 win.removeEventListener(EV_CLICK, this.listenerDeadClick);
27884 this.listenerDeadClick = null;
27885 }
27886
27887 if (this._deadClickTracker) {
27888 this._deadClickTracker.stopTracking();
27889 this._deadClickTracker = null;
27890 }
27891 };
27892
27893 // TODO integrate error_reporter from mixpanel instance
27894 safewrapClass(Autocapture);
27895
27896 var logger = console_with_prefix('flags');
27897
27898 var FLAGS_CONFIG_KEY = 'flags';
27899
27900 var CONFIG_CONTEXT = 'context';
27901 var CONFIG_DEFAULTS = {};
27902 CONFIG_DEFAULTS[CONFIG_CONTEXT] = {};
27903
27904 /**
27905 * FeatureFlagManager: support for Mixpanel's feature flagging product
27906 * @constructor
27907 */
27908 var FeatureFlagManager = function(initOptions) {
27909 this.fetch = win['fetch'];
27910 this.getFullApiRoute = initOptions.getFullApiRoute;
27911 this.getMpConfig = initOptions.getConfigFunc;
27912 this.setMpConfig = initOptions.setConfigFunc;
27913 this.getMpProperty = initOptions.getPropertyFunc;
27914 this.track = initOptions.trackingFunc;
27915 };
27916
27917 FeatureFlagManager.prototype.init = function() {
27918 if (!this.minApisSupported()) {
27919 logger.critical('Feature Flags unavailable: missing minimum required APIs');
27920 return;
27921 }
27922
27923 this.flags = null;
27924 this.fetchFlags();
27925
27926 this.trackedFeatures = new Set();
27927 };
27928
27929 FeatureFlagManager.prototype.getFullConfig = function() {
27930 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
27931 if (!ffConfig) {
27932 // flags are completely off
27933 return {};
27934 } else if (_.isObject(ffConfig)) {
27935 return _.extend({}, CONFIG_DEFAULTS, ffConfig);
27936 } else {
27937 // config is non-object truthy value, return default
27938 return CONFIG_DEFAULTS;
27939 }
27940 };
27941
27942 FeatureFlagManager.prototype.getConfig = function(key) {
27943 return this.getFullConfig()[key];
27944 };
27945
27946 FeatureFlagManager.prototype.isSystemEnabled = function() {
27947 return !!this.getMpConfig(FLAGS_CONFIG_KEY);
27948 };
27949
27950 FeatureFlagManager.prototype.updateContext = function(newContext, options) {
27951 if (!this.isSystemEnabled()) {
27952 logger.critical('Feature Flags not enabled, cannot update context');
27953 return Promise.resolve();
27954 }
27955
27956 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
27957 if (!_.isObject(ffConfig)) {
27958 ffConfig = {};
27959 }
27960 var oldContext = (options && options['replace']) ? {} : this.getConfig(CONFIG_CONTEXT);
27961 ffConfig[CONFIG_CONTEXT] = _.extend({}, oldContext, newContext);
27962
27963 this.setMpConfig(FLAGS_CONFIG_KEY, ffConfig);
27964 return this.fetchFlags();
27965 };
27966
27967 FeatureFlagManager.prototype.areFlagsReady = function() {
27968 if (!this.isSystemEnabled()) {
27969 logger.error('Feature Flags not enabled');
27970 }
27971 return !!this.flags;
27972 };
27973
27974 FeatureFlagManager.prototype.fetchFlags = function() {
27975 if (!this.isSystemEnabled()) {
27976 return Promise.resolve();
27977 }
27978
27979 var distinctId = this.getMpProperty('distinct_id');
27980 var deviceId = this.getMpProperty('$device_id');
27981 var traceparent = generateTraceparent();
27982 logger.log('Fetching flags for distinct ID: ' + distinctId);
27983
27984 var context = _.extend({'distinct_id': distinctId, 'device_id': deviceId}, this.getConfig(CONFIG_CONTEXT));
27985 var searchParams = new URLSearchParams();
27986 searchParams.set('context', JSON.stringify(context));
27987 searchParams.set('token', this.getMpConfig('token'));
27988 searchParams.set('mp_lib', 'web');
27989 searchParams.set('$lib_version', Config.LIB_VERSION);
27990 var url = this.getFullApiRoute() + '?' + searchParams.toString();
27991
27992 this._fetchInProgressStartTime = Date.now();
27993 this.fetchPromise = this.fetch.call(win, url, {
27994 'method': 'GET',
27995 'headers': {
27996 'Authorization': 'Basic ' + btoa(this.getMpConfig('token') + ':'),
27997 'traceparent': traceparent
27998 }
27999 }).then(function(response) {
28000 this.markFetchComplete();
28001 return response.json().then(function(responseBody) {
28002 var responseFlags = responseBody['flags'];
28003 if (!responseFlags) {
28004 throw new Error('No flags in API response');
28005 }
28006 var flags = new Map();
28007 _.each(responseFlags, function(data, key) {
28008 flags.set(key, {
28009 'key': data['variant_key'],
28010 'value': data['variant_value'],
28011 'experiment_id': data['experiment_id'],
28012 'is_experiment_active': data['is_experiment_active'],
28013 'is_qa_tester': data['is_qa_tester']
28014 });
28015 });
28016 this.flags = flags;
28017 this._traceparent = traceparent;
28018 }.bind(this)).catch(function(error) {
28019 this.markFetchComplete();
28020 logger.error(error);
28021 }.bind(this));
28022 }.bind(this)).catch(function(error) {
28023 this.markFetchComplete();
28024 logger.error(error);
28025 }.bind(this));
28026
28027 return this.fetchPromise;
28028 };
28029
28030 FeatureFlagManager.prototype.markFetchComplete = function() {
28031 if (!this._fetchInProgressStartTime) {
28032 logger.error('Fetch in progress started time not set, cannot mark fetch complete');
28033 return;
28034 }
28035 this._fetchStartTime = this._fetchInProgressStartTime;
28036 this._fetchCompleteTime = Date.now();
28037 this._fetchLatency = this._fetchCompleteTime - this._fetchStartTime;
28038 this._fetchInProgressStartTime = null;
28039 };
28040
28041 FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
28042 if (!this.fetchPromise) {
28043 return new Promise(function(resolve) {
28044 logger.critical('Feature Flags not initialized');
28045 resolve(fallback);
28046 });
28047 }
28048
28049 return this.fetchPromise.then(function() {
28050 return this.getVariantSync(featureName, fallback);
28051 }.bind(this)).catch(function(error) {
28052 logger.error(error);
28053 return fallback;
28054 });
28055 };
28056
28057 FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
28058 if (!this.areFlagsReady()) {
28059 logger.log('Flags not loaded yet');
28060 return fallback;
28061 }
28062 var feature = this.flags.get(featureName);
28063 if (!feature) {
28064 logger.log('No flag found: "' + featureName + '"');
28065 return fallback;
28066 }
28067 this.trackFeatureCheck(featureName, feature);
28068 return feature;
28069 };
28070
28071 FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
28072 return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
28073 return feature['value'];
28074 }).catch(function(error) {
28075 logger.error(error);
28076 return fallbackValue;
28077 });
28078 };
28079
28080 // TODO remove deprecated method
28081 FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
28082 logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
28083 return this.getVariantValue(featureName, fallbackValue);
28084 };
28085
28086 FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
28087 return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
28088 };
28089
28090 FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
28091 return this.getVariantValue(featureName).then(function() {
28092 return this.isEnabledSync(featureName, fallbackValue);
28093 }.bind(this)).catch(function(error) {
28094 logger.error(error);
28095 return fallbackValue;
28096 });
28097 };
28098
28099 FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
28100 fallbackValue = fallbackValue || false;
28101 var val = this.getVariantValueSync(featureName, fallbackValue);
28102 if (val !== true && val !== false) {
28103 logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
28104 val = fallbackValue;
28105 }
28106 return val;
28107 };
28108
28109 FeatureFlagManager.prototype.trackFeatureCheck = function(featureName, feature) {
28110 if (this.trackedFeatures.has(featureName)) {
28111 return;
28112 }
28113 this.trackedFeatures.add(featureName);
28114
28115 var trackingProperties = {
28116 'Experiment name': featureName,
28117 'Variant name': feature['key'],
28118 '$experiment_type': 'feature_flag',
28119 'Variant fetch start time': new Date(this._fetchStartTime).toISOString(),
28120 'Variant fetch complete time': new Date(this._fetchCompleteTime).toISOString(),
28121 'Variant fetch latency (ms)': this._fetchLatency,
28122 'Variant fetch traceparent': this._traceparent,
28123 };
28124
28125 if (feature['experiment_id'] !== 'undefined') {
28126 trackingProperties['$experiment_id'] = feature['experiment_id'];
28127 }
28128 if (feature['is_experiment_active'] !== 'undefined') {
28129 trackingProperties['$is_experiment_active'] = feature['is_experiment_active'];
28130 }
28131 if (feature['is_qa_tester'] !== 'undefined') {
28132 trackingProperties['$is_qa_tester'] = feature['is_qa_tester'];
28133 }
28134
28135 this.track('$experiment_started', trackingProperties);
28136 };
28137
28138 FeatureFlagManager.prototype.minApisSupported = function() {
28139 return !!this.fetch &&
28140 typeof Promise !== 'undefined' &&
28141 typeof Map !== 'undefined' &&
28142 typeof Set !== 'undefined';
28143 };
28144
28145 safewrapClass(FeatureFlagManager);
28146
28147 FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
28148 FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
28149 FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
28150 FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
28151 FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
28152 FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
28153 FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
28154 FeatureFlagManager.prototype['update_context'] = FeatureFlagManager.prototype.updateContext;
28155
28156 // Deprecated method
28157 FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
28158
28159 /* eslint camelcase: "off" */
28160
28161
28162 /**
28163 * DomTracker Object
28164 * @constructor
28165 */
28166 var DomTracker = function() {};
28167
28168
28169 // interface
28170 DomTracker.prototype.create_properties = function() {};
28171 DomTracker.prototype.event_handler = function() {};
28172 DomTracker.prototype.after_track_handler = function() {};
28173
28174 DomTracker.prototype.init = function(mixpanel_instance) {
28175 this.mp = mixpanel_instance;
28176 return this;
28177 };
28178
28179 /**
28180 * @param {Object|string} query
28181 * @param {string} event_name
28182 * @param {Object=} properties
28183 * @param {function=} user_callback
28184 */
28185 DomTracker.prototype.track = function(query, event_name, properties, user_callback) {
28186 var that = this;
28187 var elements = _.dom_query(query);
28188
28189 if (elements.length === 0) {
28190 console$1.error('The DOM query (' + query + ') returned 0 elements');
28191 return;
28192 }
28193
28194 _.each(elements, function(element) {
28195 _.register_event(element, this.override_event, function(e) {
28196 var options = {};
28197 var props = that.create_properties(properties, this);
28198 var timeout = that.mp.get_config('track_links_timeout');
28199
28200 that.event_handler(e, this, options);
28201
28202 // in case the mixpanel servers don't get back to us in time
28203 window.setTimeout(that.track_callback(user_callback, props, options, true), timeout);
28204
28205 // fire the tracking event
28206 that.mp.track(event_name, props, that.track_callback(user_callback, props, options));
28207 });
28208 }, this);
28209
28210 return true;
28211 };
28212
28213 /**
28214 * @param {function} user_callback
28215 * @param {Object} props
28216 * @param {boolean=} timeout_occured
28217 */
28218 DomTracker.prototype.track_callback = function(user_callback, props, options, timeout_occured) {
28219 timeout_occured = timeout_occured || false;
28220 var that = this;
28221
28222 return function() {
28223 // options is referenced from both callbacks, so we can have
28224 // a 'lock' of sorts to ensure only one fires
28225 if (options.callback_fired) { return; }
28226 options.callback_fired = true;
28227
28228 if (user_callback && user_callback(timeout_occured, props) === false) {
28229 // user can prevent the default functionality by
28230 // returning false from their callback
28231 return;
28232 }
28233
28234 that.after_track_handler(props, options, timeout_occured);
28235 };
28236 };
28237
28238 DomTracker.prototype.create_properties = function(properties, element) {
28239 var props;
28240
28241 if (typeof(properties) === 'function') {
28242 props = properties(element);
28243 } else {
28244 props = _.extend({}, properties);
28245 }
28246
28247 return props;
28248 };
28249
28250 /**
28251 * LinkTracker Object
28252 * @constructor
28253 * @extends DomTracker
28254 */
28255 var LinkTracker = function() {
28256 this.override_event = 'click';
28257 };
28258 _.inherit(LinkTracker, DomTracker);
28259
28260 LinkTracker.prototype.create_properties = function(properties, element) {
28261 var props = LinkTracker.superclass.create_properties.apply(this, arguments);
28262
28263 if (element.href) { props['url'] = element.href; }
28264
28265 return props;
28266 };
28267
28268 LinkTracker.prototype.event_handler = function(evt, element, options) {
28269 options.new_tab = (
28270 evt.which === 2 ||
28271 evt.metaKey ||
28272 evt.ctrlKey ||
28273 element.target === '_blank'
28274 );
28275 options.href = element.href;
28276
28277 if (!options.new_tab) {
28278 evt.preventDefault();
28279 }
28280 };
28281
28282 LinkTracker.prototype.after_track_handler = function(props, options) {
28283 if (options.new_tab) { return; }
28284
28285 setTimeout(function() {
28286 window.location = options.href;
28287 }, 0);
28288 };
28289
28290 /**
28291 * FormTracker Object
28292 * @constructor
28293 * @extends DomTracker
28294 */
28295 var FormTracker = function() {
28296 this.override_event = 'submit';
28297 };
28298 _.inherit(FormTracker, DomTracker);
28299
28300 FormTracker.prototype.event_handler = function(evt, element, options) {
28301 options.element = element;
28302 evt.preventDefault();
28303 };
28304
28305 FormTracker.prototype.after_track_handler = function(props, options) {
28306 setTimeout(function() {
28307 options.element.submit();
28308 }, 0);
28309 };
28310
28311 /* eslint camelcase: "off" */
28312
28313
28314 /** @const */ var SET_ACTION = '$set';
28315 /** @const */ var SET_ONCE_ACTION = '$set_once';
28316 /** @const */ var UNSET_ACTION = '$unset';
28317 /** @const */ var ADD_ACTION = '$add';
28318 /** @const */ var APPEND_ACTION = '$append';
28319 /** @const */ var UNION_ACTION = '$union';
28320 /** @const */ var REMOVE_ACTION = '$remove';
28321 /** @const */ var DELETE_ACTION = '$delete';
28322
28323 // Common internal methods for mixpanel.people and mixpanel.group APIs.
28324 // These methods shouldn't involve network I/O.
28325 var apiActions = {
28326 set_action: function(prop, to) {
28327 var data = {};
28328 var $set = {};
28329 if (_.isObject(prop)) {
28330 _.each(prop, function(v, k) {
28331 if (!this._is_reserved_property(k)) {
28332 $set[k] = v;
28333 }
28334 }, this);
28335 } else {
28336 $set[prop] = to;
28337 }
28338
28339 data[SET_ACTION] = $set;
28340 return data;
28341 },
28342
28343 unset_action: function(prop) {
28344 var data = {};
28345 var $unset = [];
28346 if (!_.isArray(prop)) {
28347 prop = [prop];
28348 }
28349
28350 _.each(prop, function(k) {
28351 if (!this._is_reserved_property(k)) {
28352 $unset.push(k);
28353 }
28354 }, this);
28355
28356 data[UNSET_ACTION] = $unset;
28357 return data;
28358 },
28359
28360 set_once_action: function(prop, to) {
28361 var data = {};
28362 var $set_once = {};
28363 if (_.isObject(prop)) {
28364 _.each(prop, function(v, k) {
28365 if (!this._is_reserved_property(k)) {
28366 $set_once[k] = v;
28367 }
28368 }, this);
28369 } else {
28370 $set_once[prop] = to;
28371 }
28372 data[SET_ONCE_ACTION] = $set_once;
28373 return data;
28374 },
28375
28376 union_action: function(list_name, values) {
28377 var data = {};
28378 var $union = {};
28379 if (_.isObject(list_name)) {
28380 _.each(list_name, function(v, k) {
28381 if (!this._is_reserved_property(k)) {
28382 $union[k] = _.isArray(v) ? v : [v];
28383 }
28384 }, this);
28385 } else {
28386 $union[list_name] = _.isArray(values) ? values : [values];
28387 }
28388 data[UNION_ACTION] = $union;
28389 return data;
28390 },
28391
28392 append_action: function(list_name, value) {
28393 var data = {};
28394 var $append = {};
28395 if (_.isObject(list_name)) {
28396 _.each(list_name, function(v, k) {
28397 if (!this._is_reserved_property(k)) {
28398 $append[k] = v;
28399 }
28400 }, this);
28401 } else {
28402 $append[list_name] = value;
28403 }
28404 data[APPEND_ACTION] = $append;
28405 return data;
28406 },
28407
28408 remove_action: function(list_name, value) {
28409 var data = {};
28410 var $remove = {};
28411 if (_.isObject(list_name)) {
28412 _.each(list_name, function(v, k) {
28413 if (!this._is_reserved_property(k)) {
28414 $remove[k] = v;
28415 }
28416 }, this);
28417 } else {
28418 $remove[list_name] = value;
28419 }
28420 data[REMOVE_ACTION] = $remove;
28421 return data;
28422 },
28423
28424 delete_action: function() {
28425 var data = {};
28426 data[DELETE_ACTION] = '';
28427 return data;
28428 }
28429 };
28430
28431 /* eslint camelcase: "off" */
28432
28433 /**
28434 * Mixpanel Group Object
28435 * @constructor
28436 */
28437 var MixpanelGroup = function() {};
28438
28439 _.extend(MixpanelGroup.prototype, apiActions);
28440
28441 MixpanelGroup.prototype._init = function(mixpanel_instance, group_key, group_id) {
28442 this._mixpanel = mixpanel_instance;
28443 this._group_key = group_key;
28444 this._group_id = group_id;
28445 };
28446
28447 /**
28448 * Set properties on a group.
28449 *
28450 * ### Usage:
28451 *
28452 * mixpanel.get_group('company', 'mixpanel').set('Location', '405 Howard');
28453 *
28454 * // or set multiple properties at once
28455 * mixpanel.get_group('company', 'mixpanel').set({
28456 * 'Location': '405 Howard',
28457 * 'Founded' : 2009,
28458 * });
28459 * // properties can be strings, integers, dates, or lists
28460 *
28461 * @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.
28462 * @param {*} [to] A value to set on the given property name
28463 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28464 */
28465 MixpanelGroup.prototype.set = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28466 var data = this.set_action(prop, to);
28467 if (_.isObject(prop)) {
28468 callback = to;
28469 }
28470 return this._send_request(data, callback);
28471 });
28472
28473 /**
28474 * Set properties on a group, only if they do not yet exist.
28475 * This will not overwrite previous group property values, unlike
28476 * group.set().
28477 *
28478 * ### Usage:
28479 *
28480 * mixpanel.get_group('company', 'mixpanel').set_once('Location', '405 Howard');
28481 *
28482 * // or set multiple properties at once
28483 * mixpanel.get_group('company', 'mixpanel').set_once({
28484 * 'Location': '405 Howard',
28485 * 'Founded' : 2009,
28486 * });
28487 * // properties can be strings, integers, lists or dates
28488 *
28489 * @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.
28490 * @param {*} [to] A value to set on the given property name
28491 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28492 */
28493 MixpanelGroup.prototype.set_once = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28494 var data = this.set_once_action(prop, to);
28495 if (_.isObject(prop)) {
28496 callback = to;
28497 }
28498 return this._send_request(data, callback);
28499 });
28500
28501 /**
28502 * Unset properties on a group permanently.
28503 *
28504 * ### Usage:
28505 *
28506 * mixpanel.get_group('company', 'mixpanel').unset('Founded');
28507 *
28508 * @param {String} prop The name of the property.
28509 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28510 */
28511 MixpanelGroup.prototype.unset = addOptOutCheckMixpanelGroup(function(prop, callback) {
28512 var data = this.unset_action(prop);
28513 return this._send_request(data, callback);
28514 });
28515
28516 /**
28517 * Merge a given list with a list-valued group property, excluding duplicate values.
28518 *
28519 * ### Usage:
28520 *
28521 * // merge a value to a list, creating it if needed
28522 * mixpanel.get_group('company', 'mixpanel').union('Location', ['San Francisco', 'London']);
28523 *
28524 * @param {String} list_name Name of the property.
28525 * @param {Array} values Values to merge with the given property
28526 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28527 */
28528 MixpanelGroup.prototype.union = addOptOutCheckMixpanelGroup(function(list_name, values, callback) {
28529 if (_.isObject(list_name)) {
28530 callback = values;
28531 }
28532 var data = this.union_action(list_name, values);
28533 return this._send_request(data, callback);
28534 });
28535
28536 /**
28537 * Permanently delete a group.
28538 *
28539 * ### Usage:
28540 *
28541 * mixpanel.get_group('company', 'mixpanel').delete();
28542 *
28543 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28544 */
28545 MixpanelGroup.prototype['delete'] = addOptOutCheckMixpanelGroup(function(callback) {
28546 // bracket notation above prevents a minification error related to reserved words
28547 var data = this.delete_action();
28548 return this._send_request(data, callback);
28549 });
28550
28551 /**
28552 * Remove a property from a group. The value will be ignored if doesn't exist.
28553 *
28554 * ### Usage:
28555 *
28556 * mixpanel.get_group('company', 'mixpanel').remove('Location', 'London');
28557 *
28558 * @param {String} list_name Name of the property.
28559 * @param {Object} value Value to remove from the given group property
28560 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28561 */
28562 MixpanelGroup.prototype.remove = addOptOutCheckMixpanelGroup(function(list_name, value, callback) {
28563 var data = this.remove_action(list_name, value);
28564 return this._send_request(data, callback);
28565 });
28566
28567 MixpanelGroup.prototype._send_request = function(data, callback) {
28568 data['$group_key'] = this._group_key;
28569 data['$group_id'] = this._group_id;
28570 data['$token'] = this._get_config('token');
28571
28572 var date_encoded_data = _.encodeDates(data);
28573 return this._mixpanel._track_or_batch({
28574 type: 'groups',
28575 data: date_encoded_data,
28576 endpoint: this._mixpanel.get_api_host('groups') + '/' + this._get_config('api_routes')['groups'],
28577 batcher: this._mixpanel.request_batchers.groups
28578 }, callback);
28579 };
28580
28581 MixpanelGroup.prototype._is_reserved_property = function(prop) {
28582 return prop === '$group_key' || prop === '$group_id';
28583 };
28584
28585 MixpanelGroup.prototype._get_config = function(conf) {
28586 return this._mixpanel.get_config(conf);
28587 };
28588
28589 MixpanelGroup.prototype.toString = function() {
28590 return this._mixpanel.toString() + '.group.' + this._group_key + '.' + this._group_id;
28591 };
28592
28593 // MixpanelGroup Exports
28594 MixpanelGroup.prototype['remove'] = MixpanelGroup.prototype.remove;
28595 MixpanelGroup.prototype['set'] = MixpanelGroup.prototype.set;
28596 MixpanelGroup.prototype['set_once'] = MixpanelGroup.prototype.set_once;
28597 MixpanelGroup.prototype['union'] = MixpanelGroup.prototype.union;
28598 MixpanelGroup.prototype['unset'] = MixpanelGroup.prototype.unset;
28599 MixpanelGroup.prototype['toString'] = MixpanelGroup.prototype.toString;
28600
28601 /* eslint camelcase: "off" */
28602
28603 /**
28604 * Mixpanel People Object
28605 * @constructor
28606 */
28607 var MixpanelPeople = function() {};
28608
28609 _.extend(MixpanelPeople.prototype, apiActions);
28610
28611 MixpanelPeople.prototype._init = function(mixpanel_instance) {
28612 this._mixpanel = mixpanel_instance;
28613 };
28614
28615 /*
28616 * Set properties on a user record.
28617 *
28618 * ### Usage:
28619 *
28620 * mixpanel.people.set('gender', 'm');
28621 *
28622 * // or set multiple properties at once
28623 * mixpanel.people.set({
28624 * 'Company': 'Acme',
28625 * 'Plan': 'Premium',
28626 * 'Upgrade date': new Date()
28627 * });
28628 * // properties can be strings, integers, dates, or lists
28629 *
28630 * @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.
28631 * @param {*} [to] A value to set on the given property name
28632 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28633 */
28634 MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
28635 var data = this.set_action(prop, to);
28636 if (_.isObject(prop)) {
28637 callback = to;
28638 }
28639 // make sure that the referrer info has been updated and saved
28640 if (this._get_config('save_referrer')) {
28641 this._mixpanel['persistence'].update_referrer_info(document.referrer);
28642 }
28643
28644 // update $set object with default people properties
28645 data[SET_ACTION] = _.extend(
28646 {},
28647 _.info.people_properties(),
28648 data[SET_ACTION]
28649 );
28650 return this._send_request(data, callback);
28651 });
28652
28653 /*
28654 * Set properties on a user record, only if they do not yet exist.
28655 * This will not overwrite previous people property values, unlike
28656 * people.set().
28657 *
28658 * ### Usage:
28659 *
28660 * mixpanel.people.set_once('First Login Date', new Date());
28661 *
28662 * // or set multiple properties at once
28663 * mixpanel.people.set_once({
28664 * 'First Login Date': new Date(),
28665 * 'Starting Plan': 'Premium'
28666 * });
28667 *
28668 * // properties can be strings, integers or dates
28669 *
28670 * @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.
28671 * @param {*} [to] A value to set on the given property name
28672 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28673 */
28674 MixpanelPeople.prototype.set_once = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
28675 var data = this.set_once_action(prop, to);
28676 if (_.isObject(prop)) {
28677 callback = to;
28678 }
28679 return this._send_request(data, callback);
28680 });
28681
28682 /*
28683 * Unset properties on a user record (permanently removes the properties and their values from a profile).
28684 *
28685 * ### Usage:
28686 *
28687 * mixpanel.people.unset('gender');
28688 *
28689 * // or unset multiple properties at once
28690 * mixpanel.people.unset(['gender', 'Company']);
28691 *
28692 * @param {Array|String} prop If a string, this is the name of the property. If an array, this is a list of property names.
28693 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28694 */
28695 MixpanelPeople.prototype.unset = addOptOutCheckMixpanelPeople(function(prop, callback) {
28696 var data = this.unset_action(prop);
28697 return this._send_request(data, callback);
28698 });
28699
28700 /*
28701 * Increment/decrement numeric people analytics properties.
28702 *
28703 * ### Usage:
28704 *
28705 * mixpanel.people.increment('page_views', 1);
28706 *
28707 * // or, for convenience, if you're just incrementing a counter by
28708 * // 1, you can simply do
28709 * mixpanel.people.increment('page_views');
28710 *
28711 * // to decrement a counter, pass a negative number
28712 * mixpanel.people.increment('credits_left', -1);
28713 *
28714 * // like mixpanel.people.set(), you can increment multiple
28715 * // properties at once:
28716 * mixpanel.people.increment({
28717 * counter1: 1,
28718 * counter2: 6
28719 * });
28720 *
28721 * @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.
28722 * @param {Number} [by] An amount to increment the given property
28723 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28724 */
28725 MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop, by, callback) {
28726 var data = {};
28727 var $add = {};
28728 if (_.isObject(prop)) {
28729 _.each(prop, function(v, k) {
28730 if (!this._is_reserved_property(k)) {
28731 if (isNaN(parseFloat(v))) {
28732 console$1.error('Invalid increment value passed to mixpanel.people.increment - must be a number');
28733 return;
28734 } else {
28735 $add[k] = v;
28736 }
28737 }
28738 }, this);
28739 callback = by;
28740 } else {
28741 // convenience: mixpanel.people.increment('property'); will
28742 // increment 'property' by 1
28743 if (_.isUndefined(by)) {
28744 by = 1;
28745 }
28746 $add[prop] = by;
28747 }
28748 data[ADD_ACTION] = $add;
28749
28750 return this._send_request(data, callback);
28751 });
28752
28753 /*
28754 * Append a value to a list-valued people analytics property.
28755 *
28756 * ### Usage:
28757 *
28758 * // append a value to a list, creating it if needed
28759 * mixpanel.people.append('pages_visited', 'homepage');
28760 *
28761 * // like mixpanel.people.set(), you can append multiple
28762 * // properties at once:
28763 * mixpanel.people.append({
28764 * list1: 'bob',
28765 * list2: 123
28766 * });
28767 *
28768 * @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.
28769 * @param {*} [value] value An item to append to the list
28770 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28771 */
28772 MixpanelPeople.prototype.append = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
28773 if (_.isObject(list_name)) {
28774 callback = value;
28775 }
28776 var data = this.append_action(list_name, value);
28777 return this._send_request(data, callback);
28778 });
28779
28780 /*
28781 * Remove a value from a list-valued people analytics property.
28782 *
28783 * ### Usage:
28784 *
28785 * mixpanel.people.remove('School', 'UCB');
28786 *
28787 * @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.
28788 * @param {*} [value] value Item to remove from the list
28789 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28790 */
28791 MixpanelPeople.prototype.remove = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
28792 if (_.isObject(list_name)) {
28793 callback = value;
28794 }
28795 var data = this.remove_action(list_name, value);
28796 return this._send_request(data, callback);
28797 });
28798
28799 /*
28800 * Merge a given list with a list-valued people analytics property,
28801 * excluding duplicate values.
28802 *
28803 * ### Usage:
28804 *
28805 * // merge a value to a list, creating it if needed
28806 * mixpanel.people.union('pages_visited', 'homepage');
28807 *
28808 * // like mixpanel.people.set(), you can append multiple
28809 * // properties at once:
28810 * mixpanel.people.union({
28811 * list1: 'bob',
28812 * list2: 123
28813 * });
28814 *
28815 * // like mixpanel.people.append(), you can append multiple
28816 * // values to the same list:
28817 * mixpanel.people.union({
28818 * list1: ['bob', 'billy']
28819 * });
28820 *
28821 * @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.
28822 * @param {*} [value] Value / values to merge with the given property
28823 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28824 */
28825 MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name, values, callback) {
28826 if (_.isObject(list_name)) {
28827 callback = values;
28828 }
28829 var data = this.union_action(list_name, values);
28830 return this._send_request(data, callback);
28831 });
28832
28833 /*
28834 * Record that you have charged the current user a certain amount
28835 * of money. Charges recorded with track_charge() will appear in the
28836 * Mixpanel revenue report.
28837 *
28838 * ### Usage:
28839 *
28840 * // charge a user $50
28841 * mixpanel.people.track_charge(50);
28842 *
28843 * // charge a user $30.50 on the 2nd of january
28844 * mixpanel.people.track_charge(30.50, {
28845 * '$time': new Date('jan 1 2012')
28846 * });
28847 *
28848 * @param {Number} amount The amount of money charged to the current user
28849 * @param {Object} [properties] An associative array of properties associated with the charge
28850 * @param {Function} [callback] If provided, the callback will be called when the server responds
28851 * @deprecated
28852 */
28853 MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
28854 console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
28855 });
28856
28857 /*
28858 * Permanently clear all revenue report transactions from the
28859 * current user's people analytics profile.
28860 *
28861 * ### Usage:
28862 *
28863 * mixpanel.people.clear_charges();
28864 *
28865 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28866 * @deprecated
28867 */
28868 MixpanelPeople.prototype.clear_charges = function(callback) {
28869 return this.set('$transactions', [], callback);
28870 };
28871
28872 /*
28873 * Permanently deletes the current people analytics profile from
28874 * Mixpanel (using the current distinct_id).
28875 *
28876 * ### Usage:
28877 *
28878 * // remove the all data you have stored about the current user
28879 * mixpanel.people.delete_user();
28880 *
28881 */
28882 MixpanelPeople.prototype.delete_user = function() {
28883 if (!this._identify_called()) {
28884 console$1.error('mixpanel.people.delete_user() requires you to call identify() first');
28885 return;
28886 }
28887 var data = {'$delete': this._mixpanel.get_distinct_id()};
28888 return this._send_request(data);
28889 };
28890
28891 MixpanelPeople.prototype.toString = function() {
28892 return this._mixpanel.toString() + '.people';
28893 };
28894
28895 MixpanelPeople.prototype._send_request = function(data, callback) {
28896 data['$token'] = this._get_config('token');
28897 data['$distinct_id'] = this._mixpanel.get_distinct_id();
28898 var device_id = this._mixpanel.get_property('$device_id');
28899 var user_id = this._mixpanel.get_property('$user_id');
28900 var had_persisted_distinct_id = this._mixpanel.get_property('$had_persisted_distinct_id');
28901 if (device_id) {
28902 data['$device_id'] = device_id;
28903 }
28904 if (user_id) {
28905 data['$user_id'] = user_id;
28906 }
28907 if (had_persisted_distinct_id) {
28908 data['$had_persisted_distinct_id'] = had_persisted_distinct_id;
28909 }
28910
28911 var date_encoded_data = _.encodeDates(data);
28912
28913 if (!this._identify_called()) {
28914 this._enqueue(data);
28915 if (!_.isUndefined(callback)) {
28916 if (this._get_config('verbose')) {
28917 callback({status: -1, error: null});
28918 } else {
28919 callback(-1);
28920 }
28921 }
28922 return _.truncate(date_encoded_data, 255);
28923 }
28924
28925 return this._mixpanel._track_or_batch({
28926 type: 'people',
28927 data: date_encoded_data,
28928 endpoint: this._mixpanel.get_api_host('people') + '/' + this._get_config('api_routes')['engage'],
28929 batcher: this._mixpanel.request_batchers.people
28930 }, callback);
28931 };
28932
28933 MixpanelPeople.prototype._get_config = function(conf_var) {
28934 return this._mixpanel.get_config(conf_var);
28935 };
28936
28937 MixpanelPeople.prototype._identify_called = function() {
28938 return this._mixpanel._flags.identify_called === true;
28939 };
28940
28941 // Queue up engage operations if identify hasn't been called yet.
28942 MixpanelPeople.prototype._enqueue = function(data) {
28943 if (SET_ACTION in data) {
28944 this._mixpanel['persistence']._add_to_people_queue(SET_ACTION, data);
28945 } else if (SET_ONCE_ACTION in data) {
28946 this._mixpanel['persistence']._add_to_people_queue(SET_ONCE_ACTION, data);
28947 } else if (UNSET_ACTION in data) {
28948 this._mixpanel['persistence']._add_to_people_queue(UNSET_ACTION, data);
28949 } else if (ADD_ACTION in data) {
28950 this._mixpanel['persistence']._add_to_people_queue(ADD_ACTION, data);
28951 } else if (APPEND_ACTION in data) {
28952 this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, data);
28953 } else if (REMOVE_ACTION in data) {
28954 this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, data);
28955 } else if (UNION_ACTION in data) {
28956 this._mixpanel['persistence']._add_to_people_queue(UNION_ACTION, data);
28957 } else {
28958 console$1.error('Invalid call to _enqueue():', data);
28959 }
28960 };
28961
28962 MixpanelPeople.prototype._flush_one_queue = function(action, action_method, callback, queue_to_params_fn) {
28963 var _this = this;
28964 var queued_data = _.extend({}, this._mixpanel['persistence'].load_queue(action));
28965 var action_params = queued_data;
28966
28967 if (!_.isUndefined(queued_data) && _.isObject(queued_data) && !_.isEmptyObject(queued_data)) {
28968 _this._mixpanel['persistence']._pop_from_people_queue(action, queued_data);
28969 _this._mixpanel['persistence'].save();
28970 if (queue_to_params_fn) {
28971 action_params = queue_to_params_fn(queued_data);
28972 }
28973 action_method.call(_this, action_params, function(response, data) {
28974 // on bad response, we want to add it back to the queue
28975 if (response === 0) {
28976 _this._mixpanel['persistence']._add_to_people_queue(action, queued_data);
28977 }
28978 if (!_.isUndefined(callback)) {
28979 callback(response, data);
28980 }
28981 });
28982 }
28983 };
28984
28985 // Flush queued engage operations - order does not matter,
28986 // and there are network level race conditions anyway
28987 MixpanelPeople.prototype._flush = function(
28988 _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
28989 ) {
28990 var _this = this;
28991
28992 this._flush_one_queue(SET_ACTION, this.set, _set_callback);
28993 this._flush_one_queue(SET_ONCE_ACTION, this.set_once, _set_once_callback);
28994 this._flush_one_queue(UNSET_ACTION, this.unset, _unset_callback, function(queue) { return _.keys(queue); });
28995 this._flush_one_queue(ADD_ACTION, this.increment, _add_callback);
28996 this._flush_one_queue(UNION_ACTION, this.union, _union_callback);
28997
28998 // we have to fire off each $append individually since there is
28999 // no concat method server side
29000 var $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29001 if (!_.isUndefined($append_queue) && _.isArray($append_queue) && $append_queue.length) {
29002 var $append_item;
29003 var append_callback = function(response, data) {
29004 if (response === 0) {
29005 _this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, $append_item);
29006 }
29007 if (!_.isUndefined(_append_callback)) {
29008 _append_callback(response, data);
29009 }
29010 };
29011 for (var i = $append_queue.length - 1; i >= 0; i--) {
29012 $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29013 $append_item = $append_queue.pop();
29014 _this._mixpanel['persistence'].save();
29015 if (!_.isEmptyObject($append_item)) {
29016 _this.append($append_item, append_callback);
29017 }
29018 }
29019 }
29020
29021 // same for $remove
29022 var $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29023 if (!_.isUndefined($remove_queue) && _.isArray($remove_queue) && $remove_queue.length) {
29024 var $remove_item;
29025 var remove_callback = function(response, data) {
29026 if (response === 0) {
29027 _this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, $remove_item);
29028 }
29029 if (!_.isUndefined(_remove_callback)) {
29030 _remove_callback(response, data);
29031 }
29032 };
29033 for (var j = $remove_queue.length - 1; j >= 0; j--) {
29034 $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29035 $remove_item = $remove_queue.pop();
29036 _this._mixpanel['persistence'].save();
29037 if (!_.isEmptyObject($remove_item)) {
29038 _this.remove($remove_item, remove_callback);
29039 }
29040 }
29041 }
29042 };
29043
29044 MixpanelPeople.prototype._is_reserved_property = function(prop) {
29045 return prop === '$distinct_id' || prop === '$token' || prop === '$device_id' || prop === '$user_id' || prop === '$had_persisted_distinct_id';
29046 };
29047
29048 // MixpanelPeople Exports
29049 MixpanelPeople.prototype['set'] = MixpanelPeople.prototype.set;
29050 MixpanelPeople.prototype['set_once'] = MixpanelPeople.prototype.set_once;
29051 MixpanelPeople.prototype['unset'] = MixpanelPeople.prototype.unset;
29052 MixpanelPeople.prototype['increment'] = MixpanelPeople.prototype.increment;
29053 MixpanelPeople.prototype['append'] = MixpanelPeople.prototype.append;
29054 MixpanelPeople.prototype['remove'] = MixpanelPeople.prototype.remove;
29055 MixpanelPeople.prototype['union'] = MixpanelPeople.prototype.union;
29056 MixpanelPeople.prototype['track_charge'] = MixpanelPeople.prototype.track_charge;
29057 MixpanelPeople.prototype['clear_charges'] = MixpanelPeople.prototype.clear_charges;
29058 MixpanelPeople.prototype['delete_user'] = MixpanelPeople.prototype.delete_user;
29059 MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
29060
29061 /* eslint camelcase: "off" */
29062
29063
29064 /*
29065 * Constants
29066 */
29067 /** @const */ var SET_QUEUE_KEY = '__mps';
29068 /** @const */ var SET_ONCE_QUEUE_KEY = '__mpso';
29069 /** @const */ var UNSET_QUEUE_KEY = '__mpus';
29070 /** @const */ var ADD_QUEUE_KEY = '__mpa';
29071 /** @const */ var APPEND_QUEUE_KEY = '__mpap';
29072 /** @const */ var REMOVE_QUEUE_KEY = '__mpr';
29073 /** @const */ var UNION_QUEUE_KEY = '__mpu';
29074 // This key is deprecated, but we want to check for it to see whether aliasing is allowed.
29075 /** @const */ var PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id';
29076 /** @const */ var ALIAS_ID_KEY = '__alias';
29077 /** @const */ var EVENT_TIMERS_KEY = '__timers';
29078 /** @const */ var RESERVED_PROPERTIES = [
29079 SET_QUEUE_KEY,
29080 SET_ONCE_QUEUE_KEY,
29081 UNSET_QUEUE_KEY,
29082 ADD_QUEUE_KEY,
29083 APPEND_QUEUE_KEY,
29084 REMOVE_QUEUE_KEY,
29085 UNION_QUEUE_KEY,
29086 PEOPLE_DISTINCT_ID_KEY,
29087 ALIAS_ID_KEY,
29088 EVENT_TIMERS_KEY
29089 ];
29090
29091 /**
29092 * Mixpanel Persistence Object
29093 * @constructor
29094 */
29095 var MixpanelPersistence = function(config) {
29096 this['props'] = {};
29097 this.campaign_params_saved = false;
29098
29099 if (config['persistence_name']) {
29100 this.name = 'mp_' + config['persistence_name'];
29101 } else {
29102 this.name = 'mp_' + config['token'] + '_mixpanel';
29103 }
29104
29105 var storage_type = config['persistence'];
29106 if (storage_type !== 'cookie' && storage_type !== 'localStorage') {
29107 console$1.critical('Unknown persistence type ' + storage_type + '; falling back to cookie');
29108 storage_type = config['persistence'] = 'cookie';
29109 }
29110
29111 if (storage_type === 'localStorage' && _.localStorage.is_supported()) {
29112 this.storage = _.localStorage;
29113 } else {
29114 this.storage = _.cookie;
29115 }
29116
29117 this.load();
29118 this.update_config(config);
29119 this.upgrade();
29120 this.save();
29121 };
29122
29123 MixpanelPersistence.prototype.properties = function() {
29124 var p = {};
29125
29126 this.load();
29127
29128 // Filter out reserved properties
29129 _.each(this['props'], function(v, k) {
29130 if (!_.include(RESERVED_PROPERTIES, k)) {
29131 p[k] = v;
29132 }
29133 });
29134 return p;
29135 };
29136
29137 MixpanelPersistence.prototype.load = function() {
29138 if (this.disabled) { return; }
29139
29140 var entry = this.storage.parse(this.name);
29141
29142 if (entry) {
29143 this['props'] = _.extend({}, entry);
29144 }
29145 };
29146
29147 MixpanelPersistence.prototype.upgrade = function() {
29148 var old_cookie,
29149 old_localstorage;
29150
29151 // if transferring from cookie to localStorage or vice-versa, copy existing
29152 // super properties over to new storage mode
29153 if (this.storage === _.localStorage) {
29154 old_cookie = _.cookie.parse(this.name);
29155
29156 _.cookie.remove(this.name);
29157 _.cookie.remove(this.name, true);
29158
29159 if (old_cookie) {
29160 this.register_once(old_cookie);
29161 }
29162 } else if (this.storage === _.cookie) {
29163 old_localstorage = _.localStorage.parse(this.name);
29164
29165 _.localStorage.remove(this.name);
29166
29167 if (old_localstorage) {
29168 this.register_once(old_localstorage);
29169 }
29170 }
29171 };
29172
29173 MixpanelPersistence.prototype.save = function() {
29174 if (this.disabled) { return; }
29175
29176 this.storage.set(
29177 this.name,
29178 JSONStringify(this['props']),
29179 this.expire_days,
29180 this.cross_subdomain,
29181 this.secure,
29182 this.cross_site,
29183 this.cookie_domain
29184 );
29185 };
29186
29187 MixpanelPersistence.prototype.load_prop = function(key) {
29188 this.load();
29189 return this['props'][key];
29190 };
29191
29192 MixpanelPersistence.prototype.remove = function() {
29193 // remove both domain and subdomain cookies
29194 this.storage.remove(this.name, false, this.cookie_domain);
29195 this.storage.remove(this.name, true, this.cookie_domain);
29196 };
29197
29198 // removes the storage entry and deletes all loaded data
29199 // forced name for tests
29200 MixpanelPersistence.prototype.clear = function() {
29201 this.remove();
29202 this['props'] = {};
29203 };
29204
29205 /**
29206 * @param {Object} props
29207 * @param {*=} default_value
29208 * @param {number=} days
29209 */
29210 MixpanelPersistence.prototype.register_once = function(props, default_value, days) {
29211 if (_.isObject(props)) {
29212 if (typeof(default_value) === 'undefined') { default_value = 'None'; }
29213 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29214
29215 this.load();
29216
29217 _.each(props, function(val, prop) {
29218 if (!this['props'].hasOwnProperty(prop) || this['props'][prop] === default_value) {
29219 this['props'][prop] = val;
29220 }
29221 }, this);
29222
29223 this.save();
29224
29225 return true;
29226 }
29227 return false;
29228 };
29229
29230 /**
29231 * @param {Object} props
29232 * @param {number=} days
29233 */
29234 MixpanelPersistence.prototype.register = function(props, days) {
29235 if (_.isObject(props)) {
29236 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29237
29238 this.load();
29239 _.extend(this['props'], props);
29240 this.save();
29241
29242 return true;
29243 }
29244 return false;
29245 };
29246
29247 MixpanelPersistence.prototype.unregister = function(prop) {
29248 this.load();
29249 if (prop in this['props']) {
29250 delete this['props'][prop];
29251 this.save();
29252 }
29253 };
29254
29255 MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
29256 this.register(_.info.searchInfo(referrer));
29257 };
29258
29259 // EXPORTED METHOD, we test this directly.
29260 MixpanelPersistence.prototype.update_referrer_info = function(referrer) {
29261 // If referrer doesn't exist, we want to note the fact that it was type-in traffic.
29262 this.register_once({
29263 '$initial_referrer': referrer || '$direct',
29264 '$initial_referring_domain': _.info.referringDomain(referrer) || '$direct'
29265 }, '');
29266 };
29267
29268 MixpanelPersistence.prototype.get_referrer_info = function() {
29269 return _.strip_empty_properties({
29270 '$initial_referrer': this['props']['$initial_referrer'],
29271 '$initial_referring_domain': this['props']['$initial_referring_domain']
29272 });
29273 };
29274
29275 MixpanelPersistence.prototype.update_config = function(config) {
29276 this.default_expiry = this.expire_days = config['cookie_expiration'];
29277 this.set_disabled(config['disable_persistence']);
29278 this.set_cookie_domain(config['cookie_domain']);
29279 this.set_cross_site(config['cross_site_cookie']);
29280 this.set_cross_subdomain(config['cross_subdomain_cookie']);
29281 this.set_secure(config['secure_cookie']);
29282 };
29283
29284 MixpanelPersistence.prototype.set_disabled = function(disabled) {
29285 this.disabled = disabled;
29286 if (this.disabled) {
29287 this.remove();
29288 } else {
29289 this.save();
29290 }
29291 };
29292
29293 MixpanelPersistence.prototype.set_cookie_domain = function(cookie_domain) {
29294 if (cookie_domain !== this.cookie_domain) {
29295 this.remove();
29296 this.cookie_domain = cookie_domain;
29297 this.save();
29298 }
29299 };
29300
29301 MixpanelPersistence.prototype.set_cross_site = function(cross_site) {
29302 if (cross_site !== this.cross_site) {
29303 this.cross_site = cross_site;
29304 this.remove();
29305 this.save();
29306 }
29307 };
29308
29309 MixpanelPersistence.prototype.set_cross_subdomain = function(cross_subdomain) {
29310 if (cross_subdomain !== this.cross_subdomain) {
29311 this.cross_subdomain = cross_subdomain;
29312 this.remove();
29313 this.save();
29314 }
29315 };
29316
29317 MixpanelPersistence.prototype.get_cross_subdomain = function() {
29318 return this.cross_subdomain;
29319 };
29320
29321 MixpanelPersistence.prototype.set_secure = function(secure) {
29322 if (secure !== this.secure) {
29323 this.secure = secure ? true : false;
29324 this.remove();
29325 this.save();
29326 }
29327 };
29328
29329 MixpanelPersistence.prototype._add_to_people_queue = function(queue, data) {
29330 var q_key = this._get_queue_key(queue),
29331 q_data = data[queue],
29332 set_q = this._get_or_create_queue(SET_ACTION),
29333 set_once_q = this._get_or_create_queue(SET_ONCE_ACTION),
29334 unset_q = this._get_or_create_queue(UNSET_ACTION),
29335 add_q = this._get_or_create_queue(ADD_ACTION),
29336 union_q = this._get_or_create_queue(UNION_ACTION),
29337 remove_q = this._get_or_create_queue(REMOVE_ACTION, []),
29338 append_q = this._get_or_create_queue(APPEND_ACTION, []);
29339
29340 if (q_key === SET_QUEUE_KEY) {
29341 // Update the set queue - we can override any existing values
29342 _.extend(set_q, q_data);
29343 // if there was a pending increment, override it
29344 // with the set.
29345 this._pop_from_people_queue(ADD_ACTION, q_data);
29346 // if there was a pending union, override it
29347 // with the set.
29348 this._pop_from_people_queue(UNION_ACTION, q_data);
29349 this._pop_from_people_queue(UNSET_ACTION, q_data);
29350 } else if (q_key === SET_ONCE_QUEUE_KEY) {
29351 // only queue the data if there is not already a set_once call for it.
29352 _.each(q_data, function(v, k) {
29353 if (!(k in set_once_q)) {
29354 set_once_q[k] = v;
29355 }
29356 });
29357 this._pop_from_people_queue(UNSET_ACTION, q_data);
29358 } else if (q_key === UNSET_QUEUE_KEY) {
29359 _.each(q_data, function(prop) {
29360
29361 // undo previously-queued actions on this key
29362 _.each([set_q, set_once_q, add_q, union_q], function(enqueued_obj) {
29363 if (prop in enqueued_obj) {
29364 delete enqueued_obj[prop];
29365 }
29366 });
29367 _.each(append_q, function(append_obj) {
29368 if (prop in append_obj) {
29369 delete append_obj[prop];
29370 }
29371 });
29372
29373 unset_q[prop] = true;
29374
29375 });
29376 } else if (q_key === ADD_QUEUE_KEY) {
29377 _.each(q_data, function(v, k) {
29378 // If it exists in the set queue, increment
29379 // the value
29380 if (k in set_q) {
29381 set_q[k] += v;
29382 } else {
29383 // If it doesn't exist, update the add
29384 // queue
29385 if (!(k in add_q)) {
29386 add_q[k] = 0;
29387 }
29388 add_q[k] += v;
29389 }
29390 }, this);
29391 this._pop_from_people_queue(UNSET_ACTION, q_data);
29392 } else if (q_key === UNION_QUEUE_KEY) {
29393 _.each(q_data, function(v, k) {
29394 if (_.isArray(v)) {
29395 if (!(k in union_q)) {
29396 union_q[k] = [];
29397 }
29398 // Prevent duplicate values
29399 _.each(v, function(item) {
29400 if (!_.include(union_q[k], item)) {
29401 union_q[k].push(item);
29402 }
29403 });
29404 }
29405 });
29406 this._pop_from_people_queue(UNSET_ACTION, q_data);
29407 } else if (q_key === REMOVE_QUEUE_KEY) {
29408 remove_q.push(q_data);
29409 this._pop_from_people_queue(APPEND_ACTION, q_data);
29410 } else if (q_key === APPEND_QUEUE_KEY) {
29411 append_q.push(q_data);
29412 this._pop_from_people_queue(UNSET_ACTION, q_data);
29413 }
29414
29415 console$1.log('MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):');
29416 console$1.log(data);
29417
29418 this.save();
29419 };
29420
29421 MixpanelPersistence.prototype._pop_from_people_queue = function(queue, data) {
29422 var q = this['props'][this._get_queue_key(queue)];
29423 if (!_.isUndefined(q)) {
29424 _.each(data, function(v, k) {
29425 if (queue === APPEND_ACTION || queue === REMOVE_ACTION) {
29426 // list actions: only remove if both k+v match
29427 // e.g. remove should not override append in a case like
29428 // append({foo: 'bar'}); remove({foo: 'qux'})
29429 _.each(q, function(queued_action) {
29430 if (queued_action[k] === v) {
29431 delete queued_action[k];
29432 }
29433 });
29434 } else {
29435 delete q[k];
29436 }
29437 }, this);
29438 }
29439 };
29440
29441 MixpanelPersistence.prototype.load_queue = function(queue) {
29442 return this.load_prop(this._get_queue_key(queue));
29443 };
29444
29445 MixpanelPersistence.prototype._get_queue_key = function(queue) {
29446 if (queue === SET_ACTION) {
29447 return SET_QUEUE_KEY;
29448 } else if (queue === SET_ONCE_ACTION) {
29449 return SET_ONCE_QUEUE_KEY;
29450 } else if (queue === UNSET_ACTION) {
29451 return UNSET_QUEUE_KEY;
29452 } else if (queue === ADD_ACTION) {
29453 return ADD_QUEUE_KEY;
29454 } else if (queue === APPEND_ACTION) {
29455 return APPEND_QUEUE_KEY;
29456 } else if (queue === REMOVE_ACTION) {
29457 return REMOVE_QUEUE_KEY;
29458 } else if (queue === UNION_ACTION) {
29459 return UNION_QUEUE_KEY;
29460 } else {
29461 console$1.error('Invalid queue:', queue);
29462 }
29463 };
29464
29465 MixpanelPersistence.prototype._get_or_create_queue = function(queue, default_val) {
29466 var key = this._get_queue_key(queue);
29467 default_val = _.isUndefined(default_val) ? {} : default_val;
29468 return this['props'][key] || (this['props'][key] = default_val);
29469 };
29470
29471 MixpanelPersistence.prototype.set_event_timer = function(event_name, timestamp) {
29472 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29473 timers[event_name] = timestamp;
29474 this['props'][EVENT_TIMERS_KEY] = timers;
29475 this.save();
29476 };
29477
29478 MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
29479 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29480 var timestamp = timers[event_name];
29481 if (!_.isUndefined(timestamp)) {
29482 delete this['props'][EVENT_TIMERS_KEY][event_name];
29483 this.save();
29484 }
29485 return timestamp;
29486 };
29487
29488 /* eslint camelcase: "off" */
29489
29490 /*
29491 * Mixpanel JS Library
29492 *
29493 * Copyright 2012, Mixpanel, Inc. All Rights Reserved
29494 * http://mixpanel.com/
29495 *
29496 * Includes portions of Underscore.js
29497 * http://documentcloud.github.com/underscore/
29498 * (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
29499 * Released under the MIT License.
29500 */
29501
29502 /*
29503 SIMPLE STYLE GUIDE:
29504
29505 this.x === public function
29506 this._x === internal - only use within this file
29507 this.__x === private - only use within the class
29508
29509 Globals should be all caps
29510 */
29511
29512 var init_type; // MODULE or SNIPPET loader
29513 // allow bundlers to specify how extra code (recorder bundle) should be loaded
29514 // eslint-disable-next-line no-unused-vars
29515 var load_extra_bundle = function(src, _onload) {
29516 throw new Error(src + ' not available in this build.');
29517 };
29518
29519 var mixpanel_master; // main mixpanel instance / object
29520 var INIT_MODULE = 0;
29521 var INIT_SNIPPET = 1;
29522
29523 var IDENTITY_FUNC = function(x) {return x;};
29524
29525 /** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
29526 /** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
29527 /** @const */ var PAYLOAD_TYPE_JSON = 'json';
29528 /** @const */ var DEVICE_ID_PREFIX = '$device:';
29529
29530
29531 /*
29532 * Dynamic... constants? Is that an oxymoron?
29533 */
29534 // http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
29535 // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#withCredentials
29536 var USE_XHR = (win.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest());
29537
29538 // IE<10 does not support cross-origin XHR's but script tags
29539 // with defer won't block window.onload; ENQUEUE_REQUESTS
29540 // should only be true for Opera<12
29541 var ENQUEUE_REQUESTS = !USE_XHR && (userAgent.indexOf('MSIE') === -1) && (userAgent.indexOf('Mozilla') === -1);
29542
29543 // save reference to navigator.sendBeacon so it can be minified
29544 var sendBeacon = null;
29545 if (navigator['sendBeacon']) {
29546 sendBeacon = function() {
29547 // late reference to navigator.sendBeacon to allow patching/spying
29548 return navigator['sendBeacon'].apply(navigator, arguments);
29549 };
29550 }
29551
29552 var DEFAULT_API_ROUTES = {
29553 'track': 'track/',
29554 'engage': 'engage/',
29555 'groups': 'groups/',
29556 'record': 'record/',
29557 'flags': 'flags/'
29558 };
29559
29560 /*
29561 * Module-level globals
29562 */
29563 var DEFAULT_CONFIG = {
29564 'api_host': 'https://api-js.mixpanel.com',
29565 'api_hosts': {},
29566 'api_routes': DEFAULT_API_ROUTES,
29567 'api_extra_query_params': {},
29568 'api_method': 'POST',
29569 'api_transport': 'XHR',
29570 'api_payload_format': PAYLOAD_TYPE_BASE64,
29571 'app_host': 'https://mixpanel.com',
29572 'autocapture': false,
29573 'cdn': 'https://cdn.mxpnl.com',
29574 'cross_site_cookie': false,
29575 'cross_subdomain_cookie': true,
29576 'error_reporter': NOOP_FUNC,
29577 'flags': false,
29578 'persistence': 'cookie',
29579 'persistence_name': '',
29580 'cookie_domain': '',
29581 'cookie_name': '',
29582 'loaded': NOOP_FUNC,
29583 'mp_loader': null,
29584 'track_marketing': true,
29585 'track_pageview': false,
29586 'skip_first_touch_marketing': false,
29587 'store_google': true,
29588 'stop_utm_persistence': false,
29589 'save_referrer': true,
29590 'test': false,
29591 'verbose': false,
29592 'img': false,
29593 'debug': false,
29594 'track_links_timeout': 300,
29595 'cookie_expiration': 365,
29596 'upgrade': false,
29597 'disable_persistence': false,
29598 'disable_cookie': false,
29599 'secure_cookie': false,
29600 'ip': true,
29601 'opt_out_tracking_by_default': false,
29602 'opt_out_persistence_by_default': false,
29603 'opt_out_tracking_persistence_type': 'localStorage',
29604 'opt_out_tracking_cookie_prefix': null,
29605 'property_blacklist': [],
29606 'xhr_headers': {}, // { header: value, header2: value }
29607 'ignore_dnt': false,
29608 'batch_requests': true,
29609 'batch_size': 50,
29610 'batch_flush_interval_ms': 5000,
29611 'batch_request_timeout_ms': 90000,
29612 'batch_autostart': true,
29613 'hooks': {},
29614 'record_block_class': new RegExp('^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$'),
29615 'record_block_selector': 'img, video, audio',
29616 'record_canvas': false,
29617 'record_collect_fonts': false,
29618 'record_heatmap_data': false,
29619 'record_idle_timeout_ms': 30 * 60 * 1000, // 30 minutes
29620 'record_mask_text_class': new RegExp('^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$'),
29621 'record_mask_text_selector': '*',
29622 'record_max_ms': MAX_RECORDING_MS,
29623 'record_min_ms': 0,
29624 'record_sessions_percent': 0,
29625 'recorder_src': 'https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js'
29626 };
29627
29628 var DOM_LOADED = false;
29629
29630 /**
29631 * Mixpanel Library Object
29632 * @constructor
29633 */
29634 var MixpanelLib = function() {};
29635
29636
29637 /**
29638 * create_mplib(token:string, config:object, name:string)
29639 *
29640 * This function is used by the init method of MixpanelLib objects
29641 * as well as the main initializer at the end of the JSLib (that
29642 * initializes document.mixpanel as well as any additional instances
29643 * declared before this file has loaded).
29644 */
29645 var create_mplib = function(token, config, name) {
29646 var instance,
29647 target = (name === PRIMARY_INSTANCE_NAME) ? mixpanel_master : mixpanel_master[name];
29648
29649 if (target && init_type === INIT_MODULE) {
29650 instance = target;
29651 } else {
29652 if (target && !_.isArray(target)) {
29653 console$1.error('You have already initialized ' + name);
29654 return;
29655 }
29656 instance = new MixpanelLib();
29657 }
29658
29659 instance._cached_groups = {}; // cache groups in a pool
29660
29661 instance._init(token, config, name);
29662
29663 instance['people'] = new MixpanelPeople();
29664 instance['people']._init(instance);
29665
29666 if (!instance.get_config('skip_first_touch_marketing')) {
29667 // We need null UTM params in the object because
29668 // UTM parameters act as a tuple. If any UTM param
29669 // is present, then we set all UTM params including
29670 // empty ones together
29671 var utm_params = _.info.campaignParams(null);
29672 var initial_utm_params = {};
29673 var has_utm = false;
29674 _.each(utm_params, function(utm_value, utm_key) {
29675 initial_utm_params['initial_' + utm_key] = utm_value;
29676 if (utm_value) {
29677 has_utm = true;
29678 }
29679 });
29680 if (has_utm) {
29681 instance['people'].set_once(initial_utm_params);
29682 }
29683 }
29684
29685 // if any instance on the page has debug = true, we set the
29686 // global debug to be true
29687 Config.DEBUG = Config.DEBUG || instance.get_config('debug');
29688
29689 // if target is not defined, we called init after the lib already
29690 // loaded, so there won't be an array of things to execute
29691 if (!_.isUndefined(target) && _.isArray(target)) {
29692 // Crunch through the people queue first - we queue this data up &
29693 // flush on identify, so it's better to do all these operations first
29694 instance._execute_array.call(instance['people'], target['people']);
29695 instance._execute_array(target);
29696 }
29697
29698 return instance;
29699 };
29700
29701 // Initialization methods
29702
29703 /**
29704 * This function initializes a new instance of the Mixpanel tracking object.
29705 * All new instances are added to the main mixpanel object as sub properties (such as
29706 * mixpanel.library_name) and also returned by this function. To define a
29707 * second instance on the page, you would call:
29708 *
29709 * mixpanel.init('new token', { your: 'config' }, 'library_name');
29710 *
29711 * and use it like so:
29712 *
29713 * mixpanel.library_name.track(...);
29714 *
29715 * @param {String} token Your Mixpanel API token
29716 * @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>.
29717 * @param {String} [name] The name for the new mixpanel instance that you want created
29718 */
29719 MixpanelLib.prototype.init = function (token, config, name) {
29720 if (_.isUndefined(name)) {
29721 this.report_error('You must name your new library: init(token, config, name)');
29722 return;
29723 }
29724 if (name === PRIMARY_INSTANCE_NAME) {
29725 this.report_error('You must initialize the main mixpanel object right after you include the Mixpanel js snippet');
29726 return;
29727 }
29728
29729 var instance = create_mplib(token, config, name);
29730 mixpanel_master[name] = instance;
29731 instance._loaded();
29732
29733 return instance;
29734 };
29735
29736 // mixpanel._init(token:string, config:object, name:string)
29737 //
29738 // This function sets up the current instance of the mixpanel
29739 // library. The difference between this method and the init(...)
29740 // method is this one initializes the actual instance, whereas the
29741 // init(...) method sets up a new library and calls _init on it.
29742 //
29743 MixpanelLib.prototype._init = function(token, config, name) {
29744 config = config || {};
29745
29746 this['__loaded'] = true;
29747 this['config'] = {};
29748
29749 var variable_features = {};
29750
29751 // default to JSON payload for standard mixpanel.com API hosts
29752 if (!('api_payload_format' in config)) {
29753 var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
29754 if (api_host.match(/\.mixpanel\.com/)) {
29755 variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
29756 }
29757 }
29758
29759 this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
29760 'name': name,
29761 'token': token,
29762 'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
29763 }));
29764
29765 this['_jsc'] = NOOP_FUNC;
29766
29767 this.__dom_loaded_queue = [];
29768 this.__request_queue = [];
29769 this.__disabled_events = [];
29770 this._flags = {
29771 'disable_all_events': false,
29772 'identify_called': false
29773 };
29774
29775 // set up request queueing/batching
29776 this.request_batchers = {};
29777 this._batch_requests = this.get_config('batch_requests');
29778 if (this._batch_requests) {
29779 if (!_.localStorage.is_supported(true) || !USE_XHR) {
29780 this._batch_requests = false;
29781 console$1.log('Turning off Mixpanel request-queueing; needs XHR and localStorage support');
29782 _.each(this.get_batcher_configs(), function(batcher_config) {
29783 console$1.log('Clearing batch queue ' + batcher_config.queue_key);
29784 _.localStorage.remove(batcher_config.queue_key);
29785 });
29786 } else {
29787 this.init_batchers();
29788 if (sendBeacon && win.addEventListener) {
29789 // Before page closes or hides (user tabs away etc), attempt to flush any events
29790 // queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
29791 // events will not be removed from the persistent store; if the site is loaded again,
29792 // the events will be flushed again on startup and deduplicated on the Mixpanel server
29793 // side.
29794 // There is no reliable way to capture only page close events, so we lean on the
29795 // visibilitychange and pagehide events as recommended at
29796 // https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event#usage_notes.
29797 // These events fire when the user clicks away from the current page/tab, so will occur
29798 // more frequently than page unload, but are the only mechanism currently for capturing
29799 // this scenario somewhat reliably.
29800 var flush_on_unload = _.bind(function() {
29801 if (!this.request_batchers.events.stopped) {
29802 this.request_batchers.events.flush({unloading: true});
29803 }
29804 }, this);
29805 win.addEventListener('pagehide', function(ev) {
29806 if (ev['persisted']) {
29807 flush_on_unload();
29808 }
29809 });
29810 win.addEventListener('visibilitychange', function() {
29811 if (document$1['visibilityState'] === 'hidden') {
29812 flush_on_unload();
29813 }
29814 });
29815 }
29816 }
29817 }
29818
29819 this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config']);
29820 this.unpersisted_superprops = {};
29821 this._gdpr_init();
29822
29823 var uuid = _.UUID();
29824 if (!this.get_distinct_id()) {
29825 // There is no need to set the distinct id
29826 // or the device id if something was already stored
29827 // in the persitence
29828 this.register_once({
29829 'distinct_id': DEVICE_ID_PREFIX + uuid,
29830 '$device_id': uuid
29831 }, '');
29832 }
29833
29834 this.flags = new FeatureFlagManager({
29835 getFullApiRoute: _.bind(function() {
29836 return this.get_api_host('flags') + '/' + this.get_config('api_routes')['flags'];
29837 }, this),
29838 getConfigFunc: _.bind(this.get_config, this),
29839 setConfigFunc: _.bind(this.set_config, this),
29840 getPropertyFunc: _.bind(this.get_property, this),
29841 trackingFunc: _.bind(this.track, this)
29842 });
29843 this.flags.init();
29844 this['flags'] = this.flags;
29845
29846 this.autocapture = new Autocapture(this);
29847 this.autocapture.init();
29848
29849 this._init_tab_id();
29850 this._check_and_start_session_recording();
29851 };
29852
29853 /**
29854 * Assigns a unique UUID to this tab / window by leveraging sessionStorage.
29855 * This is primarily used for session recording, where data must be isolated to the current tab.
29856 */
29857 MixpanelLib.prototype._init_tab_id = function() {
29858 if (this.get_config('disable_persistence')) {
29859 console$1.log('Tab ID initialization skipped due to disable_persistence config');
29860 } else if (_.sessionStorage.is_supported()) {
29861 try {
29862 var key_suffix = this.get_config('name') + '_' + this.get_config('token');
29863 var tab_id_key = 'mp_tab_id_' + key_suffix;
29864
29865 // A flag is used to determine if sessionStorage is copied over and we need to generate a new tab ID.
29866 // This enforces a unique ID in the cases like duplicated tab, window.open(...)
29867 var should_generate_new_tab_id_key = 'mp_gen_new_tab_id_' + key_suffix;
29868 if (_.sessionStorage.get(should_generate_new_tab_id_key) || !_.sessionStorage.get(tab_id_key)) {
29869 _.sessionStorage.set(tab_id_key, '$tab-' + _.UUID());
29870 }
29871
29872 _.sessionStorage.set(should_generate_new_tab_id_key, '1');
29873 this.tab_id = _.sessionStorage.get(tab_id_key);
29874
29875 // 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,
29876 // but reliable in cases where the user remains in the tab e.g. a refresh or href navigation.
29877 // If the flag is absent, this indicates to the next SDK instance that we can reuse the stored tab_id.
29878 win.addEventListener('beforeunload', function () {
29879 _.sessionStorage.remove(should_generate_new_tab_id_key);
29880 });
29881 } catch(err) {
29882 this.report_error('Error initializing tab id', err);
29883 }
29884 } else {
29885 this.report_error('Session storage is not supported, cannot keep track of unique tab ID.');
29886 }
29887 };
29888
29889 MixpanelLib.prototype.get_tab_id = function () {
29890 return this.tab_id || null;
29891 };
29892
29893 MixpanelLib.prototype._should_load_recorder = function () {
29894 if (this.get_config('disable_persistence')) {
29895 console$1.log('Load recorder check skipped due to disable_persistence config');
29896 return Promise.resolve(false);
29897 }
29898
29899 var recording_registry_idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
29900 var tab_id = this.get_tab_id();
29901 return recording_registry_idb.init()
29902 .then(function () {
29903 return recording_registry_idb.getAll();
29904 })
29905 .then(function (recordings) {
29906 for (var i = 0; i < recordings.length; i++) {
29907 // if there are expired recordings in the registry, we should load the recorder to flush them
29908 // if there's a recording for this tab id, we should load the recorder to continue the recording
29909 if (isRecordingExpired(recordings[i]) || recordings[i]['tabId'] === tab_id) {
29910 return true;
29911 }
29912 }
29913 return false;
29914 })
29915 .catch(_.bind(function (err) {
29916 this.report_error('Error checking recording registry', err);
29917 }, this));
29918 };
29919
29920 MixpanelLib.prototype._check_and_start_session_recording = addOptOutCheckMixpanelLib(function(force_start) {
29921 if (!win['MutationObserver']) {
29922 console$1.critical('Browser does not support MutationObserver; skipping session recording');
29923 return;
29924 }
29925
29926 var loadRecorder = _.bind(function(startNewIfInactive) {
29927 var handleLoadedRecorder = _.bind(function() {
29928 this._recorder = this._recorder || new win['__mp_recorder'](this);
29929 this._recorder['resumeRecording'](startNewIfInactive);
29930 }, this);
29931
29932 if (_.isUndefined(win['__mp_recorder'])) {
29933 load_extra_bundle(this.get_config('recorder_src'), handleLoadedRecorder);
29934 } else {
29935 handleLoadedRecorder();
29936 }
29937 }, this);
29938
29939 /**
29940 * If the user is sampled or start_session_recording is called, we always load the recorder since it's guaranteed a recording should start.
29941 * 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.
29942 */
29943 var is_sampled = this.get_config('record_sessions_percent') > 0 && Math.random() * 100 <= this.get_config('record_sessions_percent');
29944 if (force_start || is_sampled) {
29945 loadRecorder(true);
29946 } else {
29947 this._should_load_recorder()
29948 .then(function (shouldLoad) {
29949 if (shouldLoad) {
29950 loadRecorder(false);
29951 }
29952 });
29953 }
29954 });
29955
29956 MixpanelLib.prototype.start_session_recording = function () {
29957 this._check_and_start_session_recording(true);
29958 };
29959
29960 MixpanelLib.prototype.stop_session_recording = function () {
29961 if (this._recorder) {
29962 return this._recorder['stopRecording']();
29963 }
29964 return Promise.resolve();
29965 };
29966
29967 MixpanelLib.prototype.pause_session_recording = function () {
29968 if (this._recorder) {
29969 return this._recorder['pauseRecording']();
29970 }
29971 return Promise.resolve();
29972 };
29973
29974 MixpanelLib.prototype.resume_session_recording = function () {
29975 if (this._recorder) {
29976 return this._recorder['resumeRecording']();
29977 }
29978 return Promise.resolve();
29979 };
29980
29981 MixpanelLib.prototype.is_recording_heatmap_data = function () {
29982 return this._get_session_replay_id() && this.get_config('record_heatmap_data');
29983 };
29984
29985 MixpanelLib.prototype.get_session_recording_properties = function () {
29986 var props = {};
29987 var replay_id = this._get_session_replay_id();
29988 if (replay_id) {
29989 props['$mp_replay_id'] = replay_id;
29990 }
29991 return props;
29992 };
29993
29994 MixpanelLib.prototype.get_session_replay_url = function () {
29995 var replay_url = null;
29996 var replay_id = this._get_session_replay_id();
29997 if (replay_id) {
29998 var query_params = _.HTTPBuildQuery({
29999 'replay_id': replay_id,
30000 'distinct_id': this.get_distinct_id(),
30001 'token': this.get_config('token')
30002 });
30003 replay_url = 'https://mixpanel.com/projects/replay-redirect?' + query_params;
30004 }
30005 return replay_url;
30006 };
30007
30008 MixpanelLib.prototype._get_session_replay_id = function () {
30009 var replay_id = null;
30010 if (this._recorder) {
30011 replay_id = this._recorder['replayId'];
30012 }
30013 return replay_id || null;
30014 };
30015
30016 // "private" public method to reach into the recorder in test cases
30017 MixpanelLib.prototype.__get_recorder = function () {
30018 return this._recorder;
30019 };
30020
30021 // Private methods
30022
30023 MixpanelLib.prototype._loaded = function() {
30024 this.get_config('loaded')(this);
30025 this._set_default_superprops();
30026 this['people'].set_once(this['persistence'].get_referrer_info());
30027
30028 // `store_google` is now deprecated and previously stored UTM parameters are cleared
30029 // from persistence by default.
30030 if (this.get_config('store_google') && this.get_config('stop_utm_persistence')) {
30031 var utm_params = _.info.campaignParams(null);
30032 _.each(utm_params, function(_utm_value, utm_key) {
30033 // We need to unregister persisted UTM parameters so old values
30034 // are not mixed with the new UTM parameters
30035 this.unregister(utm_key);
30036 }.bind(this));
30037 }
30038 };
30039
30040 // update persistence with info on referrer, UTM params, etc
30041 MixpanelLib.prototype._set_default_superprops = function() {
30042 this['persistence'].update_search_keyword(document$1.referrer);
30043 // Registering super properties for UTM persistence by 'store_google' is deprecated.
30044 if (this.get_config('store_google') && !this.get_config('stop_utm_persistence')) {
30045 this.register(_.info.campaignParams());
30046 }
30047 if (this.get_config('save_referrer')) {
30048 this['persistence'].update_referrer_info(document$1.referrer);
30049 }
30050 };
30051
30052 MixpanelLib.prototype._dom_loaded = function() {
30053 _.each(this.__dom_loaded_queue, function(item) {
30054 this._track_dom.apply(this, item);
30055 }, this);
30056
30057 if (!this.has_opted_out_tracking()) {
30058 _.each(this.__request_queue, function(item) {
30059 this._send_request.apply(this, item);
30060 }, this);
30061 }
30062
30063 delete this.__dom_loaded_queue;
30064 delete this.__request_queue;
30065 };
30066
30067 MixpanelLib.prototype._track_dom = function(DomClass, args) {
30068 if (this.get_config('img')) {
30069 this.report_error('You can\'t use DOM tracking functions with img = true.');
30070 return false;
30071 }
30072
30073 if (!DOM_LOADED) {
30074 this.__dom_loaded_queue.push([DomClass, args]);
30075 return false;
30076 }
30077
30078 var dt = new DomClass().init(this);
30079 return dt.track.apply(dt, args);
30080 };
30081
30082 /**
30083 * _prepare_callback() should be called by callers of _send_request for use
30084 * as the callback argument.
30085 *
30086 * If there is no callback, this returns null.
30087 * If we are going to make XHR/XDR requests, this returns a function.
30088 * If we are going to use script tags, this returns a string to use as the
30089 * callback GET param.
30090 */
30091 MixpanelLib.prototype._prepare_callback = function(callback, data) {
30092 if (_.isUndefined(callback)) {
30093 return null;
30094 }
30095
30096 if (USE_XHR) {
30097 var callback_function = function(response) {
30098 callback(response, data);
30099 };
30100 return callback_function;
30101 } else {
30102 // if the user gives us a callback, we store as a random
30103 // property on this instances jsc function and update our
30104 // callback string to reflect that.
30105 var jsc = this['_jsc'];
30106 var randomized_cb = '' + Math.floor(Math.random() * 100000000);
30107 var callback_string = this.get_config('callback_fn') + '[' + randomized_cb + ']';
30108 jsc[randomized_cb] = function(response) {
30109 delete jsc[randomized_cb];
30110 callback(response, data);
30111 };
30112 return callback_string;
30113 }
30114 };
30115
30116 MixpanelLib.prototype._send_request = function(url, data, options, callback) {
30117 var succeeded = true;
30118
30119 if (ENQUEUE_REQUESTS) {
30120 this.__request_queue.push(arguments);
30121 return succeeded;
30122 }
30123
30124 var DEFAULT_OPTIONS = {
30125 method: this.get_config('api_method'),
30126 transport: this.get_config('api_transport'),
30127 verbose: this.get_config('verbose')
30128 };
30129 var body_data = null;
30130
30131 if (!callback && (_.isFunction(options) || typeof options === 'string')) {
30132 callback = options;
30133 options = null;
30134 }
30135 options = _.extend(DEFAULT_OPTIONS, options || {});
30136 if (!USE_XHR) {
30137 options.method = 'GET';
30138 }
30139 var use_post = options.method === 'POST';
30140 var use_sendBeacon = sendBeacon && use_post && options.transport.toLowerCase() === 'sendbeacon';
30141
30142 // needed to correctly format responses
30143 var verbose_mode = options.verbose;
30144 if (data['verbose']) { verbose_mode = true; }
30145
30146 if (this.get_config('test')) { data['test'] = 1; }
30147 if (verbose_mode) { data['verbose'] = 1; }
30148 if (this.get_config('img')) { data['img'] = 1; }
30149 if (!USE_XHR) {
30150 if (callback) {
30151 data['callback'] = callback;
30152 } else if (verbose_mode || this.get_config('test')) {
30153 // Verbose output (from verbose mode, or an error in test mode) is a json blob,
30154 // which by itself is not valid javascript. Without a callback, this verbose output will
30155 // cause an error when returned via jsonp, so we force a no-op callback param.
30156 // See the ECMA script spec: http://www.ecma-international.org/ecma-262/5.1/#sec-12.4
30157 data['callback'] = '(function(){})';
30158 }
30159 }
30160
30161 data['ip'] = this.get_config('ip')?1:0;
30162 data['_'] = new Date().getTime().toString();
30163
30164 if (use_post) {
30165 body_data = 'data=' + encodeURIComponent(data['data']);
30166 delete data['data'];
30167 }
30168
30169 _.extend(data, this.get_config('api_extra_query_params'));
30170
30171 url += '?' + _.HTTPBuildQuery(data);
30172
30173 var lib = this;
30174 if ('img' in data) {
30175 var img = document$1.createElement('img');
30176 img.src = url;
30177 document$1.body.appendChild(img);
30178 } else if (use_sendBeacon) {
30179 try {
30180 succeeded = sendBeacon(url, body_data);
30181 } catch (e) {
30182 lib.report_error(e);
30183 succeeded = false;
30184 }
30185 try {
30186 if (callback) {
30187 callback(succeeded ? 1 : 0);
30188 }
30189 } catch (e) {
30190 lib.report_error(e);
30191 }
30192 } else if (USE_XHR) {
30193 try {
30194 var req = new XMLHttpRequest();
30195 req.open(options.method, url, true);
30196
30197 var headers = this.get_config('xhr_headers');
30198 if (use_post) {
30199 headers['Content-Type'] = 'application/x-www-form-urlencoded';
30200 }
30201 _.each(headers, function(headerValue, headerName) {
30202 req.setRequestHeader(headerName, headerValue);
30203 });
30204
30205 if (options.timeout_ms && typeof req.timeout !== 'undefined') {
30206 req.timeout = options.timeout_ms;
30207 var start_time = new Date().getTime();
30208 }
30209
30210 // send the mp_optout cookie
30211 // withCredentials cannot be modified until after calling .open on Android and Mobile Safari
30212 req.withCredentials = true;
30213 req.onreadystatechange = function () {
30214 if (req.readyState === 4) { // XMLHttpRequest.DONE == 4, except in safari 4
30215 if (req.status === 200) {
30216 if (callback) {
30217 if (verbose_mode) {
30218 var response;
30219 try {
30220 response = _.JSONDecode(req.responseText);
30221 } catch (e) {
30222 lib.report_error(e);
30223 if (options.ignore_json_errors) {
30224 response = req.responseText;
30225 } else {
30226 return;
30227 }
30228 }
30229 callback(response);
30230 } else {
30231 callback(Number(req.responseText));
30232 }
30233 }
30234 } else {
30235 var error;
30236 if (
30237 req.timeout &&
30238 !req.status &&
30239 new Date().getTime() - start_time >= req.timeout
30240 ) {
30241 error = 'timeout';
30242 } else {
30243 error = 'Bad HTTP status: ' + req.status + ' ' + req.statusText;
30244 }
30245 lib.report_error(error);
30246 if (callback) {
30247 if (verbose_mode) {
30248 var response_headers = req['responseHeaders'] || {};
30249 callback({status: 0, httpStatusCode: req['status'], error: error, retryAfter: response_headers['Retry-After']});
30250 } else {
30251 callback(0);
30252 }
30253 }
30254 }
30255 }
30256 };
30257 req.send(body_data);
30258 } catch (e) {
30259 lib.report_error(e);
30260 succeeded = false;
30261 }
30262 } else {
30263 var script = document$1.createElement('script');
30264 script.type = 'text/javascript';
30265 script.async = true;
30266 script.defer = true;
30267 script.src = url;
30268 var s = document$1.getElementsByTagName('script')[0];
30269 s.parentNode.insertBefore(script, s);
30270 }
30271
30272 return succeeded;
30273 };
30274
30275 /**
30276 * _execute_array() deals with processing any mixpanel function
30277 * calls that were called before the Mixpanel library were loaded
30278 * (and are thus stored in an array so they can be called later)
30279 *
30280 * Note: we fire off all the mixpanel function calls && user defined
30281 * functions BEFORE we fire off mixpanel tracking calls. This is so
30282 * identify/register/set_config calls can properly modify early
30283 * tracking calls.
30284 *
30285 * @param {Array} array
30286 */
30287 MixpanelLib.prototype._execute_array = function(array) {
30288 var fn_name, alias_calls = [], other_calls = [], tracking_calls = [];
30289 _.each(array, function(item) {
30290 if (item) {
30291 fn_name = item[0];
30292 if (_.isArray(fn_name)) {
30293 tracking_calls.push(item); // chained call e.g. mixpanel.get_group().set()
30294 } else if (typeof(item) === 'function') {
30295 item.call(this);
30296 } else if (_.isArray(item) && fn_name === 'alias') {
30297 alias_calls.push(item);
30298 } else if (_.isArray(item) && fn_name.indexOf('track') !== -1 && typeof(this[fn_name]) === 'function') {
30299 tracking_calls.push(item);
30300 } else {
30301 other_calls.push(item);
30302 }
30303 }
30304 }, this);
30305
30306 var execute = function(calls, context) {
30307 _.each(calls, function(item) {
30308 if (_.isArray(item[0])) {
30309 // chained call
30310 var caller = context;
30311 _.each(item, function(call) {
30312 caller = caller[call[0]].apply(caller, call.slice(1));
30313 });
30314 } else {
30315 this[item[0]].apply(this, item.slice(1));
30316 }
30317 }, context);
30318 };
30319
30320 execute(alias_calls, this);
30321 execute(other_calls, this);
30322 execute(tracking_calls, this);
30323 };
30324
30325 // request queueing utils
30326
30327 MixpanelLib.prototype.are_batchers_initialized = function() {
30328 return !!this.request_batchers.events;
30329 };
30330
30331 MixpanelLib.prototype.get_batcher_configs = function() {
30332 var queue_prefix = '__mpq_' + this.get_config('token');
30333 this._batcher_configs = this._batcher_configs || {
30334 events: {type: 'events', api_name: 'track', queue_key: queue_prefix + '_ev'},
30335 people: {type: 'people', api_name: 'engage', queue_key: queue_prefix + '_pp'},
30336 groups: {type: 'groups', api_name: 'groups', queue_key: queue_prefix + '_gr'}
30337 };
30338 return this._batcher_configs;
30339 };
30340
30341 MixpanelLib.prototype.init_batchers = function() {
30342 if (!this.are_batchers_initialized()) {
30343 var batcher_for = _.bind(function(attrs) {
30344 return new RequestBatcher(
30345 attrs.queue_key,
30346 {
30347 libConfig: this['config'],
30348 errorReporter: this.get_config('error_reporter'),
30349 sendRequestFunc: _.bind(function(data, options, cb) {
30350 var api_routes = this.get_config('api_routes');
30351 this._send_request(
30352 this.get_api_host(attrs.api_name) + '/' + api_routes[attrs.api_name],
30353 this._encode_data_for_request(data),
30354 options,
30355 this._prepare_callback(cb, data)
30356 );
30357 }, this),
30358 beforeSendHook: _.bind(function(item) {
30359 return this._run_hook('before_send_' + attrs.type, item);
30360 }, this),
30361 stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
30362 usePersistence: true,
30363 }
30364 );
30365 }, this);
30366 var batcher_configs = this.get_batcher_configs();
30367 this.request_batchers = {
30368 events: batcher_for(batcher_configs.events),
30369 people: batcher_for(batcher_configs.people),
30370 groups: batcher_for(batcher_configs.groups)
30371 };
30372 }
30373 if (this.get_config('batch_autostart')) {
30374 this.start_batch_senders();
30375 }
30376 };
30377
30378 MixpanelLib.prototype.start_batch_senders = function() {
30379 this._batchers_were_started = true;
30380 if (this.are_batchers_initialized()) {
30381 this._batch_requests = true;
30382 _.each(this.request_batchers, function(batcher) {
30383 batcher.start();
30384 });
30385 }
30386 };
30387
30388 MixpanelLib.prototype.stop_batch_senders = function() {
30389 this._batch_requests = false;
30390 _.each(this.request_batchers, function(batcher) {
30391 batcher.stop();
30392 batcher.clear();
30393 });
30394 };
30395
30396 /**
30397 * push() keeps the standard async-array-push
30398 * behavior around after the lib is loaded.
30399 * This is only useful for external integrations that
30400 * do not wish to rely on our convenience methods
30401 * (created in the snippet).
30402 *
30403 * ### Usage:
30404 * mixpanel.push(['register', { a: 'b' }]);
30405 *
30406 * @param {Array} item A [function_name, args...] array to be executed
30407 */
30408 MixpanelLib.prototype.push = function(item) {
30409 this._execute_array([item]);
30410 };
30411
30412 /**
30413 * Disable events on the Mixpanel object. If passed no arguments,
30414 * this function disables tracking of any event. If passed an
30415 * array of event names, those events will be disabled, but other
30416 * events will continue to be tracked.
30417 *
30418 * Note: this function does not stop other mixpanel functions from
30419 * firing, such as register() or people.set().
30420 *
30421 * @param {Array} [events] An array of event names to disable
30422 */
30423 MixpanelLib.prototype.disable = function(events) {
30424 if (typeof(events) === 'undefined') {
30425 this._flags.disable_all_events = true;
30426 } else {
30427 this.__disabled_events = this.__disabled_events.concat(events);
30428 }
30429 };
30430
30431 MixpanelLib.prototype._encode_data_for_request = function(data) {
30432 var encoded_data = JSONStringify(data);
30433 if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
30434 encoded_data = _.base64Encode(encoded_data);
30435 }
30436 return {'data': encoded_data};
30437 };
30438
30439 // internal method for handling track vs batch-enqueue logic
30440 MixpanelLib.prototype._track_or_batch = function(options, callback) {
30441 var truncated_data = _.truncate(options.data, 255);
30442 var endpoint = options.endpoint;
30443 var batcher = options.batcher;
30444 var should_send_immediately = options.should_send_immediately;
30445 var send_request_options = options.send_request_options || {};
30446 callback = callback || NOOP_FUNC;
30447
30448 var request_enqueued_or_initiated = true;
30449 var send_request_immediately = _.bind(function() {
30450 if (!send_request_options.skip_hooks) {
30451 truncated_data = this._run_hook('before_send_' + options.type, truncated_data);
30452 }
30453 if (truncated_data) {
30454 console$1.log('MIXPANEL REQUEST:');
30455 console$1.log(truncated_data);
30456 return this._send_request(
30457 endpoint,
30458 this._encode_data_for_request(truncated_data),
30459 send_request_options,
30460 this._prepare_callback(callback, truncated_data)
30461 );
30462 } else {
30463 return null;
30464 }
30465 }, this);
30466
30467 if (this._batch_requests && !should_send_immediately) {
30468 batcher.enqueue(truncated_data).then(function(succeeded) {
30469 if (succeeded) {
30470 callback(1, truncated_data);
30471 } else {
30472 send_request_immediately();
30473 }
30474 });
30475 } else {
30476 request_enqueued_or_initiated = send_request_immediately();
30477 }
30478
30479 return request_enqueued_or_initiated && truncated_data;
30480 };
30481
30482 /**
30483 * Track an event. This is the most important and
30484 * frequently used Mixpanel function.
30485 *
30486 * ### Usage:
30487 *
30488 * // track an event named 'Registered'
30489 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
30490 *
30491 * // track an event using navigator.sendBeacon
30492 * mixpanel.track('Left page', {'duration_seconds': 35}, {transport: 'sendBeacon'});
30493 *
30494 * To track link clicks or form submissions, see track_links() or track_forms().
30495 *
30496 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
30497 * @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.
30498 * @param {Object} [options] Optional configuration for this track request.
30499 * @param {String} [options.transport] Transport method for network request ('xhr' or 'sendBeacon').
30500 * @param {Boolean} [options.send_immediately] Whether to bypass batching/queueing and send track request immediately.
30501 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
30502 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
30503 * with the tracking payload sent to the API server is returned; otherwise false.
30504 */
30505 MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
30506 if (!callback && typeof options === 'function') {
30507 callback = options;
30508 options = null;
30509 }
30510 options = options || {};
30511 var transport = options['transport']; // external API, don't minify 'transport' prop
30512 if (transport) {
30513 options.transport = transport; // 'transport' prop name can be minified internally
30514 }
30515 var should_send_immediately = options['send_immediately'];
30516 if (typeof callback !== 'function') {
30517 callback = NOOP_FUNC;
30518 }
30519
30520 if (_.isUndefined(event_name)) {
30521 this.report_error('No event name provided to mixpanel.track');
30522 return;
30523 }
30524
30525 if (this._event_is_disabled(event_name)) {
30526 callback(0);
30527 return;
30528 }
30529
30530 // set defaults
30531 properties = _.extend({}, properties);
30532 properties['token'] = this.get_config('token');
30533
30534 // set $duration if time_event was previously called for this event
30535 var start_timestamp = this['persistence'].remove_event_timer(event_name);
30536 if (!_.isUndefined(start_timestamp)) {
30537 var duration_in_ms = new Date().getTime() - start_timestamp;
30538 properties['$duration'] = parseFloat((duration_in_ms / 1000).toFixed(3));
30539 }
30540
30541 this._set_default_superprops();
30542
30543 var marketing_properties = this.get_config('track_marketing')
30544 ? _.info.marketingParams()
30545 : {};
30546
30547 // note: extend writes to the first object, so lets make sure we
30548 // don't write to the persistence properties object and info
30549 // properties object by passing in a new object
30550
30551 // update properties with pageview info and super-properties
30552 properties = _.extend(
30553 {},
30554 _.info.properties({'mp_loader': this.get_config('mp_loader')}),
30555 marketing_properties,
30556 this['persistence'].properties(),
30557 this.unpersisted_superprops,
30558 this.get_session_recording_properties(),
30559 properties
30560 );
30561
30562 var property_blacklist = this.get_config('property_blacklist');
30563 if (_.isArray(property_blacklist)) {
30564 _.each(property_blacklist, function(blacklisted_prop) {
30565 delete properties[blacklisted_prop];
30566 });
30567 } else {
30568 this.report_error('Invalid value for property_blacklist config: ' + property_blacklist);
30569 }
30570
30571 var data = {
30572 'event': event_name,
30573 'properties': properties
30574 };
30575 var ret = this._track_or_batch({
30576 type: 'events',
30577 data: data,
30578 endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
30579 batcher: this.request_batchers.events,
30580 should_send_immediately: should_send_immediately,
30581 send_request_options: options
30582 }, callback);
30583
30584 return ret;
30585 });
30586
30587 /**
30588 * Register the current user into one/many groups.
30589 *
30590 * ### Usage:
30591 *
30592 * mixpanel.set_group('company', ['mixpanel', 'google']) // an array of IDs
30593 * mixpanel.set_group('company', 'mixpanel')
30594 * mixpanel.set_group('company', 128746312)
30595 *
30596 * @param {String} group_key Group key
30597 * @param {Array|String|Number} group_ids An array of group IDs, or a singular group ID
30598 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30599 *
30600 */
30601 MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key, group_ids, callback) {
30602 if (!_.isArray(group_ids)) {
30603 group_ids = [group_ids];
30604 }
30605 var prop = {};
30606 prop[group_key] = group_ids;
30607 this.register(prop);
30608 return this['people'].set(group_key, group_ids, callback);
30609 });
30610
30611 /**
30612 * Add a new group for this user.
30613 *
30614 * ### Usage:
30615 *
30616 * mixpanel.add_group('company', 'mixpanel')
30617 *
30618 * @param {String} group_key Group key
30619 * @param {*} group_id A valid Mixpanel property type
30620 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30621 */
30622 MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
30623 var old_values = this.get_property(group_key);
30624 var prop = {};
30625 if (old_values === undefined) {
30626 prop[group_key] = [group_id];
30627 this.register(prop);
30628 } else {
30629 if (old_values.indexOf(group_id) === -1) {
30630 old_values.push(group_id);
30631 prop[group_key] = old_values;
30632 this.register(prop);
30633 }
30634 }
30635 return this['people'].union(group_key, group_id, callback);
30636 });
30637
30638 /**
30639 * Remove a group from this user.
30640 *
30641 * ### Usage:
30642 *
30643 * mixpanel.remove_group('company', 'mixpanel')
30644 *
30645 * @param {String} group_key Group key
30646 * @param {*} group_id A valid Mixpanel property type
30647 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30648 */
30649 MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
30650 var old_value = this.get_property(group_key);
30651 // if the value doesn't exist, the persistent store is unchanged
30652 if (old_value !== undefined) {
30653 var idx = old_value.indexOf(group_id);
30654 if (idx > -1) {
30655 old_value.splice(idx, 1);
30656 this.register({group_key: old_value});
30657 }
30658 if (old_value.length === 0) {
30659 this.unregister(group_key);
30660 }
30661 }
30662 return this['people'].remove(group_key, group_id, callback);
30663 });
30664
30665 /**
30666 * Track an event with specific groups.
30667 *
30668 * ### Usage:
30669 *
30670 * mixpanel.track_with_groups('purchase', {'product': 'iphone'}, {'University': ['UCB', 'UCLA']})
30671 *
30672 * @param {String} event_name The name of the event (see `mixpanel.track()`)
30673 * @param {Object=} properties A set of properties to include with the event you're sending (see `mixpanel.track()`)
30674 * @param {Object=} groups An object mapping group name keys to one or more values
30675 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30676 */
30677 MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(event_name, properties, groups, callback) {
30678 var tracking_props = _.extend({}, properties || {});
30679 _.each(groups, function(v, k) {
30680 if (v !== null && v !== undefined) {
30681 tracking_props[k] = v;
30682 }
30683 });
30684 return this.track(event_name, tracking_props, callback);
30685 });
30686
30687 MixpanelLib.prototype._create_map_key = function (group_key, group_id) {
30688 return group_key + '_' + JSON.stringify(group_id);
30689 };
30690
30691 MixpanelLib.prototype._remove_group_from_cache = function (group_key, group_id) {
30692 delete this._cached_groups[this._create_map_key(group_key, group_id)];
30693 };
30694
30695 /**
30696 * Look up reference to a Mixpanel group
30697 *
30698 * ### Usage:
30699 *
30700 * mixpanel.get_group(group_key, group_id)
30701 *
30702 * @param {String} group_key Group key
30703 * @param {Object} group_id A valid Mixpanel property type
30704 * @returns {Object} A MixpanelGroup identifier
30705 */
30706 MixpanelLib.prototype.get_group = function (group_key, group_id) {
30707 var map_key = this._create_map_key(group_key, group_id);
30708 var group = this._cached_groups[map_key];
30709 if (group === undefined || group._group_key !== group_key || group._group_id !== group_id) {
30710 group = new MixpanelGroup();
30711 group._init(this, group_key, group_id);
30712 this._cached_groups[map_key] = group;
30713 }
30714 return group;
30715 };
30716
30717 /**
30718 * Track a default Mixpanel page view event, which includes extra default event properties to
30719 * improve page view data.
30720 *
30721 * ### Usage:
30722 *
30723 * // track a default $mp_web_page_view event
30724 * mixpanel.track_pageview();
30725 *
30726 * // track a page view event with additional event properties
30727 * mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
30728 *
30729 * // example approach to track page views on different page types as event properties
30730 * mixpanel.track_pageview({'page': 'pricing'});
30731 * mixpanel.track_pageview({'page': 'homepage'});
30732 *
30733 * // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
30734 * // individual pages on the same site or product. Use cases for custom event_name may be page
30735 * // views on different products or internal applications that are considered completely separate
30736 * mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
30737 *
30738 * ### Notes:
30739 *
30740 * The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
30741 * may be turned on for tracking page loads automatically.
30742 *
30743 * // track only page loads
30744 * mixpanel.init(PROJECT_TOKEN, {track_pageview: true});
30745 *
30746 * // track when the URL changes in any manner
30747 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'full-url'});
30748 *
30749 * // track when the URL changes, ignoring any changes in the hash part
30750 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path-and-query-string'});
30751 *
30752 * // track when the path changes, ignoring any query parameter or hash changes
30753 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path'});
30754 *
30755 * @param {Object} [properties] An optional set of additional properties to send with the page view event
30756 * @param {Object} [options] Page view tracking options
30757 * @param {String} [options.event_name] - Alternate name for the tracking event
30758 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
30759 * with the tracking payload sent to the API server is returned; otherwise false.
30760 */
30761 MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
30762 if (typeof properties !== 'object') {
30763 properties = {};
30764 }
30765 options = options || {};
30766 var event_name = options['event_name'] || '$mp_web_page_view';
30767
30768 var default_page_properties = _.extend(
30769 _.info.mpPageViewProperties(),
30770 _.info.campaignParams(),
30771 _.info.clickParams()
30772 );
30773
30774 var event_properties = _.extend(
30775 {},
30776 default_page_properties,
30777 properties
30778 );
30779
30780 return this.track(event_name, event_properties);
30781 });
30782
30783 /**
30784 * Track clicks on a set of document elements. Selector must be a
30785 * valid query. Elements must exist on the page at the time track_links is called.
30786 *
30787 * ### Usage:
30788 *
30789 * // track click for link id #nav
30790 * mixpanel.track_links('#nav', 'Clicked Nav Link');
30791 *
30792 * ### Notes:
30793 *
30794 * This function will wait up to 300 ms for the Mixpanel
30795 * servers to respond. If they have not responded by that time
30796 * it will head to the link without ensuring that your event
30797 * has been tracked. To configure this timeout please see the
30798 * set_config() documentation below.
30799 *
30800 * If you pass a function in as the properties argument, the
30801 * function will receive the DOMElement that triggered the
30802 * event as an argument. You are expected to return an object
30803 * from the function; any properties defined on this object
30804 * will be sent to mixpanel as event properties.
30805 *
30806 * @type {Function}
30807 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
30808 * @param {String} event_name The name of the event to track
30809 * @param {Object|Function} [properties] A properties object or function that returns a dictionary of properties when passed a DOMElement
30810 */
30811 MixpanelLib.prototype.track_links = function() {
30812 return this._track_dom.call(this, LinkTracker, arguments);
30813 };
30814
30815 /**
30816 * Track form submissions. Selector must be a valid query.
30817 *
30818 * ### Usage:
30819 *
30820 * // track submission for form id 'register'
30821 * mixpanel.track_forms('#register', 'Created Account');
30822 *
30823 * ### Notes:
30824 *
30825 * This function will wait up to 300 ms for the mixpanel
30826 * servers to respond, if they have not responded by that time
30827 * it will head to the link without ensuring that your event
30828 * has been tracked. To configure this timeout please see the
30829 * set_config() documentation below.
30830 *
30831 * If you pass a function in as the properties argument, the
30832 * function will receive the DOMElement that triggered the
30833 * event as an argument. You are expected to return an object
30834 * from the function; any properties defined on this object
30835 * will be sent to mixpanel as event properties.
30836 *
30837 * @type {Function}
30838 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
30839 * @param {String} event_name The name of the event to track
30840 * @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
30841 */
30842 MixpanelLib.prototype.track_forms = function() {
30843 return this._track_dom.call(this, FormTracker, arguments);
30844 };
30845
30846 /**
30847 * Time an event by including the time between this call and a
30848 * later 'track' call for the same event in the properties sent
30849 * with the event.
30850 *
30851 * ### Usage:
30852 *
30853 * // time an event named 'Registered'
30854 * mixpanel.time_event('Registered');
30855 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
30856 *
30857 * When called for a particular event name, the next track call for that event
30858 * name will include the elapsed time between the 'time_event' and 'track'
30859 * calls. This value is stored as seconds in the '$duration' property.
30860 *
30861 * @param {String} event_name The name of the event.
30862 */
30863 MixpanelLib.prototype.time_event = function(event_name) {
30864 if (_.isUndefined(event_name)) {
30865 this.report_error('No event name provided to mixpanel.time_event');
30866 return;
30867 }
30868
30869 if (this._event_is_disabled(event_name)) {
30870 return;
30871 }
30872
30873 this['persistence'].set_event_timer(event_name, new Date().getTime());
30874 };
30875
30876 var REGISTER_DEFAULTS = {
30877 'persistent': true
30878 };
30879 /**
30880 * Helper to parse options param for register methods, maintaining
30881 * legacy support for plain "days" param instead of options object
30882 * @param {Number|Object} [days_or_options] 'days' option (Number), or Options object for register methods
30883 * @returns {Object} options object
30884 */
30885 var options_for_register = function(days_or_options) {
30886 var options;
30887 if (_.isObject(days_or_options)) {
30888 options = days_or_options;
30889 } else if (!_.isUndefined(days_or_options)) {
30890 options = {'days': days_or_options};
30891 } else {
30892 options = {};
30893 }
30894 return _.extend({}, REGISTER_DEFAULTS, options);
30895 };
30896
30897 /**
30898 * Register a set of super properties, which are included with all
30899 * events. This will overwrite previous super property values.
30900 *
30901 * ### Usage:
30902 *
30903 * // register 'Gender' as a super property
30904 * mixpanel.register({'Gender': 'Female'});
30905 *
30906 * // register several super properties when a user signs up
30907 * mixpanel.register({
30908 * 'Email': 'jdoe@example.com',
30909 * 'Account Type': 'Free'
30910 * });
30911 *
30912 * // register only for the current pageload
30913 * mixpanel.register({'Name': 'Pat'}, {persistent: false});
30914 *
30915 * @param {Object} properties An associative array of properties to store about the user
30916 * @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)
30917 * @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)
30918 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
30919 */
30920 MixpanelLib.prototype.register = function(props, days_or_options) {
30921 var options = options_for_register(days_or_options);
30922 if (options['persistent']) {
30923 this['persistence'].register(props, options['days']);
30924 } else {
30925 _.extend(this.unpersisted_superprops, props);
30926 }
30927 };
30928
30929 /**
30930 * Register a set of super properties only once. This will not
30931 * overwrite previous super property values, unlike register().
30932 *
30933 * ### Usage:
30934 *
30935 * // register a super property for the first time only
30936 * mixpanel.register_once({
30937 * 'First Login Date': new Date().toISOString()
30938 * });
30939 *
30940 * // register once, only for the current pageload
30941 * mixpanel.register_once({
30942 * 'First interaction time': new Date().toISOString()
30943 * }, 'None', {persistent: false});
30944 *
30945 * ### Notes:
30946 *
30947 * If default_value is specified, current super properties
30948 * with that value will be overwritten.
30949 *
30950 * @param {Object} properties An associative array of properties to store about the user
30951 * @param {*} [default_value] Value to override if already set in super properties (ex: 'False') Default: 'None'
30952 * @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)
30953 * @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)
30954 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
30955 */
30956 MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
30957 var options = options_for_register(days_or_options);
30958 if (options['persistent']) {
30959 this['persistence'].register_once(props, default_value, options['days']);
30960 } else {
30961 if (typeof(default_value) === 'undefined') {
30962 default_value = 'None';
30963 }
30964 _.each(props, function(val, prop) {
30965 if (!this.unpersisted_superprops.hasOwnProperty(prop) || this.unpersisted_superprops[prop] === default_value) {
30966 this.unpersisted_superprops[prop] = val;
30967 }
30968 }, this);
30969 }
30970 };
30971
30972 /**
30973 * Delete a super property stored with the current user.
30974 *
30975 * @param {String} property The name of the super property to remove
30976 * @param {Object} [options]
30977 * @param {boolean} [options.persistent=true] - whether to look in persistent storage (cookie/localStorage)
30978 */
30979 MixpanelLib.prototype.unregister = function(property, options) {
30980 options = options_for_register(options);
30981 if (options['persistent']) {
30982 this['persistence'].unregister(property);
30983 } else {
30984 delete this.unpersisted_superprops[property];
30985 }
30986 };
30987
30988 MixpanelLib.prototype._register_single = function(prop, value) {
30989 var props = {};
30990 props[prop] = value;
30991 this.register(props);
30992 };
30993
30994 /**
30995 * Identify a user with a unique ID to track user activity across
30996 * devices, tie a user to their events, and create a user profile.
30997 * If you never call this method, unique visitors are tracked using
30998 * a UUID generated the first time they visit the site.
30999 *
31000 * Call identify when you know the identity of the current user,
31001 * typically after login or signup. We recommend against using
31002 * identify for anonymous visitors to your site.
31003 *
31004 * ### Notes:
31005 * If your project has
31006 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31007 * enabled, the identify method will connect pre- and
31008 * post-authentication events when appropriate.
31009 *
31010 * If your project does not have ID Merge enabled, identify will
31011 * change the user's local distinct_id to the unique ID you pass.
31012 * Events tracked prior to authentication will not be connected
31013 * to the same user identity. If ID Merge is disabled, alias can
31014 * be used to connect pre- and post-registration events.
31015 *
31016 * @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.
31017 */
31018 MixpanelLib.prototype.identify = function(
31019 new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
31020 ) {
31021 // Optional Parameters
31022 // _set_callback:function A callback to be run if and when the People set queue is flushed
31023 // _add_callback:function A callback to be run if and when the People add queue is flushed
31024 // _append_callback:function A callback to be run if and when the People append queue is flushed
31025 // _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
31026 // _union_callback:function A callback to be run if and when the People union queue is flushed
31027 // _unset_callback:function A callback to be run if and when the People unset queue is flushed
31028
31029 var previous_distinct_id = this.get_distinct_id();
31030 if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
31031 // we allow the following condition if previous distinct_id is same as new_distinct_id
31032 // so that you can force flush people updates for anonymous profiles.
31033 if (typeof new_distinct_id === 'string' && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
31034 this.report_error('distinct_id cannot have $device: prefix');
31035 return -1;
31036 }
31037 this.register({'$user_id': new_distinct_id});
31038 }
31039
31040 if (!this.get_property('$device_id')) {
31041 // The persisted distinct id might not actually be a device id at all
31042 // it might be a distinct id of the user from before
31043 var device_id = previous_distinct_id;
31044 this.register_once({
31045 '$had_persisted_distinct_id': true,
31046 '$device_id': device_id
31047 }, '');
31048 }
31049
31050 // identify only changes the distinct id if it doesn't match either the existing or the alias;
31051 // if it's new, blow away the alias as well.
31052 if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
31053 this.unregister(ALIAS_ID_KEY);
31054 this.register({'distinct_id': new_distinct_id});
31055 }
31056 this._flags.identify_called = true;
31057 // Flush any queued up people requests
31058 this['people']._flush(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback);
31059
31060 // send an $identify event any time the distinct_id is changing - logic on the server
31061 // will determine whether or not to do anything with it.
31062 if (new_distinct_id !== previous_distinct_id) {
31063 this.track('$identify', {
31064 'distinct_id': new_distinct_id,
31065 '$anon_distinct_id': previous_distinct_id
31066 }, {skip_hooks: true});
31067 }
31068
31069 // check feature flags again if distinct id has changed
31070 if (new_distinct_id !== previous_distinct_id) {
31071 this.flags.fetchFlags();
31072 }
31073 };
31074
31075 /**
31076 * Clears super properties and generates a new random distinct_id for this instance.
31077 * Useful for clearing data when a user logs out.
31078 */
31079 MixpanelLib.prototype.reset = function() {
31080 this.stop_session_recording();
31081 this['persistence'].clear();
31082 this._flags.identify_called = false;
31083 var uuid = _.UUID();
31084 this.register_once({
31085 'distinct_id': DEVICE_ID_PREFIX + uuid,
31086 '$device_id': uuid
31087 }, '');
31088 this._check_and_start_session_recording();
31089 };
31090
31091 /**
31092 * Returns the current distinct id of the user. This is either the id automatically
31093 * generated by the library or the id that has been passed by a call to identify().
31094 *
31095 * ### Notes:
31096 *
31097 * get_distinct_id() can only be called after the Mixpanel library has finished loading.
31098 * init() has a loaded function available to handle this automatically. For example:
31099 *
31100 * // set distinct_id after the mixpanel library has loaded
31101 * mixpanel.init('YOUR PROJECT TOKEN', {
31102 * loaded: function(mixpanel) {
31103 * distinct_id = mixpanel.get_distinct_id();
31104 * }
31105 * });
31106 */
31107 MixpanelLib.prototype.get_distinct_id = function() {
31108 return this.get_property('distinct_id');
31109 };
31110
31111 /**
31112 * The alias method creates an alias which Mixpanel will use to
31113 * remap one id to another. Multiple aliases can point to the
31114 * same identifier.
31115 *
31116 * The following is a valid use of alias:
31117 *
31118 * mixpanel.alias('new_id', 'existing_id');
31119 * // You can add multiple id aliases to the existing ID
31120 * mixpanel.alias('newer_id', 'existing_id');
31121 *
31122 * Aliases can also be chained - the following is a valid example:
31123 *
31124 * mixpanel.alias('new_id', 'existing_id');
31125 * // chain newer_id - new_id - existing_id
31126 * mixpanel.alias('newer_id', 'new_id');
31127 *
31128 * Aliases cannot point to multiple identifiers - the following
31129 * example will not work:
31130 *
31131 * mixpanel.alias('new_id', 'existing_id');
31132 * // this is invalid as 'new_id' already points to 'existing_id'
31133 * mixpanel.alias('new_id', 'newer_id');
31134 *
31135 * ### Notes:
31136 *
31137 * If your project does not have
31138 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31139 * enabled, the best practice is to call alias once when a unique
31140 * ID is first created for a user (e.g., when a user first registers
31141 * for an account). Do not use alias multiple times for a single
31142 * user without ID Merge enabled.
31143 *
31144 * @param {String} alias A unique identifier that you want to use for this user in the future.
31145 * @param {String} [original] The current identifier being used for this user.
31146 */
31147 MixpanelLib.prototype.alias = function(alias, original) {
31148 // If the $people_distinct_id key exists in persistence, there has been a previous
31149 // mixpanel.people.identify() call made for this user. It is VERY BAD to make an alias with
31150 // this ID, as it will duplicate users.
31151 if (alias === this.get_property(PEOPLE_DISTINCT_ID_KEY)) {
31152 this.report_error('Attempting to create alias for existing People user - aborting.');
31153 return -2;
31154 }
31155
31156 var _this = this;
31157 if (_.isUndefined(original)) {
31158 original = this.get_distinct_id();
31159 }
31160 if (alias !== original) {
31161 this._register_single(ALIAS_ID_KEY, alias);
31162 return this.track('$create_alias', {
31163 'alias': alias,
31164 'distinct_id': original
31165 }, {
31166 skip_hooks: true
31167 }, function() {
31168 // Flush the people queue
31169 _this.identify(alias);
31170 });
31171 } else {
31172 this.report_error('alias matches current distinct_id - skipping api call.');
31173 this.identify(alias);
31174 return -1;
31175 }
31176 };
31177
31178 /**
31179 * Provide a string to recognize the user by. The string passed to
31180 * this method will appear in the Mixpanel Streams product rather
31181 * than an automatically generated name. Name tags do not have to
31182 * be unique.
31183 *
31184 * This value will only be included in Streams data.
31185 *
31186 * @param {String} name_tag A human readable name for the user
31187 * @deprecated
31188 */
31189 MixpanelLib.prototype.name_tag = function(name_tag) {
31190 this._register_single('mp_name_tag', name_tag);
31191 };
31192
31193 /**
31194 * Update the configuration of a mixpanel library instance.
31195 *
31196 * The default config is:
31197 *
31198 * {
31199 * // host for requests (customizable for e.g. a local proxy)
31200 * api_host: 'https://api-js.mixpanel.com',
31201 *
31202 * // endpoints for different types of requests
31203 * api_routes: {
31204 * track: 'track/',
31205 * engage: 'engage/',
31206 * groups: 'groups/',
31207 * }
31208 *
31209 * // HTTP method for tracking requests
31210 * api_method: 'POST'
31211 *
31212 * // transport for sending requests ('XHR' or 'sendBeacon')
31213 * // NB: sendBeacon should only be used for scenarios such as
31214 * // page unload where a "best-effort" attempt to send is
31215 * // acceptable; the sendBeacon API does not support callbacks
31216 * // or any way to know the result of the request. Mixpanel
31217 * // tracking via sendBeacon will not support any event-
31218 * // batching or retry mechanisms.
31219 * api_transport: 'XHR'
31220 *
31221 * // request-batching/queueing/retry
31222 * batch_requests: true,
31223 *
31224 * // maximum number of events/updates to send in a single
31225 * // network request
31226 * batch_size: 50,
31227 *
31228 * // milliseconds to wait between sending batch requests
31229 * batch_flush_interval_ms: 5000,
31230 *
31231 * // milliseconds to wait for network responses to batch requests
31232 * // before they are considered timed-out and retried
31233 * batch_request_timeout_ms: 90000,
31234 *
31235 * // override value for cookie domain, only useful for ensuring
31236 * // correct cross-subdomain cookies on unusual domains like
31237 * // subdomain.mainsite.avocat.fr; NB this cannot be used to
31238 * // set cookies on a different domain than the current origin
31239 * cookie_domain: ''
31240 *
31241 * // super properties cookie expiration (in days)
31242 * cookie_expiration: 365
31243 *
31244 * // if true, cookie will be set with SameSite=None; Secure
31245 * // this is only useful in special situations, like embedded
31246 * // 3rd-party iframes that set up a Mixpanel instance
31247 * cross_site_cookie: false
31248 *
31249 * // super properties span subdomains
31250 * cross_subdomain_cookie: true
31251 *
31252 * // debug mode
31253 * debug: false
31254 *
31255 * // if this is true, the mixpanel cookie or localStorage entry
31256 * // will be deleted, and no user persistence will take place
31257 * disable_persistence: false
31258 *
31259 * // if this is true, Mixpanel will automatically determine
31260 * // City, Region and Country data using the IP address of
31261 * //the client
31262 * ip: true
31263 *
31264 * // opt users out of tracking by this Mixpanel instance by default
31265 * opt_out_tracking_by_default: false
31266 *
31267 * // opt users out of browser data storage by this Mixpanel instance by default
31268 * opt_out_persistence_by_default: false
31269 *
31270 * // persistence mechanism used by opt-in/opt-out methods - cookie
31271 * // or localStorage - falls back to cookie if localStorage is unavailable
31272 * opt_out_tracking_persistence_type: 'localStorage'
31273 *
31274 * // customize the name of cookie/localStorage set by opt-in/opt-out methods
31275 * opt_out_tracking_cookie_prefix: null
31276 *
31277 * // type of persistent store for super properties (cookie/
31278 * // localStorage) if set to 'localStorage', any existing
31279 * // mixpanel cookie value with the same persistence_name
31280 * // will be transferred to localStorage and deleted
31281 * persistence: 'cookie'
31282 *
31283 * // name for super properties persistent store
31284 * persistence_name: ''
31285 *
31286 * // names of properties/superproperties which should never
31287 * // be sent with track() calls
31288 * property_blacklist: []
31289 *
31290 * // if this is true, mixpanel cookies will be marked as
31291 * // secure, meaning they will only be transmitted over https
31292 * secure_cookie: false
31293 *
31294 * // disables enriching user profiles with first touch marketing data
31295 * skip_first_touch_marketing: false
31296 *
31297 * // the amount of time track_links will
31298 * // wait for Mixpanel's servers to respond
31299 * track_links_timeout: 300
31300 *
31301 * // adds any UTM parameters and click IDs present on the page to any events fired
31302 * track_marketing: true
31303 *
31304 * // enables automatic page view tracking using default page view events through
31305 * // the track_pageview() method
31306 * track_pageview: false
31307 *
31308 * // if you set upgrade to be true, the library will check for
31309 * // a cookie from our old js library and import super
31310 * // properties from it, then the old cookie is deleted
31311 * // The upgrade config option only works in the initialization,
31312 * // so make sure you set it when you create the library.
31313 * upgrade: false
31314 *
31315 * // extra HTTP request headers to set for each API request, in
31316 * // the format {'Header-Name': value}
31317 * xhr_headers: {}
31318 *
31319 * // whether to ignore or respect the web browser's Do Not Track setting
31320 * ignore_dnt: false
31321 * }
31322 *
31323 *
31324 * @param {Object} config A dictionary of new configuration values to update
31325 */
31326 MixpanelLib.prototype.set_config = function(config) {
31327 if (_.isObject(config)) {
31328 _.extend(this['config'], config);
31329
31330 var new_batch_size = config['batch_size'];
31331 if (new_batch_size) {
31332 _.each(this.request_batchers, function(batcher) {
31333 batcher.resetBatchSize();
31334 });
31335 }
31336
31337 if (!this.get_config('persistence_name')) {
31338 this['config']['persistence_name'] = this['config']['cookie_name'];
31339 }
31340 if (!this.get_config('disable_persistence')) {
31341 this['config']['disable_persistence'] = this['config']['disable_cookie'];
31342 }
31343
31344 if (this['persistence']) {
31345 this['persistence'].update_config(this['config']);
31346 }
31347 Config.DEBUG = Config.DEBUG || this.get_config('debug');
31348
31349 if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
31350 this.autocapture.init();
31351 }
31352 }
31353 };
31354
31355 /**
31356 * returns the current config object for the library.
31357 */
31358 MixpanelLib.prototype.get_config = function(prop_name) {
31359 return this['config'][prop_name];
31360 };
31361
31362 /**
31363 * Fetch a hook function from config, with safe default, and run it
31364 * against the given arguments
31365 * @param {string} hook_name which hook to retrieve
31366 * @returns {any|null} return value of user-provided hook, or null if nothing was returned
31367 */
31368 MixpanelLib.prototype._run_hook = function(hook_name) {
31369 var ret = (this['config']['hooks'][hook_name] || IDENTITY_FUNC).apply(this, slice.call(arguments, 1));
31370 if (typeof ret === 'undefined') {
31371 this.report_error(hook_name + ' hook did not return a value');
31372 ret = null;
31373 }
31374 return ret;
31375 };
31376
31377 /**
31378 * Returns the value of the super property named property_name. If no such
31379 * property is set, get_property() will return the undefined value.
31380 *
31381 * ### Notes:
31382 *
31383 * get_property() can only be called after the Mixpanel library has finished loading.
31384 * init() has a loaded function available to handle this automatically. For example:
31385 *
31386 * // grab value for 'user_id' after the mixpanel library has loaded
31387 * mixpanel.init('YOUR PROJECT TOKEN', {
31388 * loaded: function(mixpanel) {
31389 * user_id = mixpanel.get_property('user_id');
31390 * }
31391 * });
31392 *
31393 * @param {String} property_name The name of the super property you want to retrieve
31394 */
31395 MixpanelLib.prototype.get_property = function(property_name) {
31396 return this['persistence'].load_prop([property_name]);
31397 };
31398
31399 /**
31400 * Get the API host for a specific endpoint type, falling back to the default api_host if not specified
31401 *
31402 * @param {String} endpoint_type The type of endpoint (e.g., "events", "people", "groups")
31403 * @returns {String} The API host to use for this endpoint
31404 */
31405 MixpanelLib.prototype.get_api_host = function(endpoint_type) {
31406 return this.get_config('api_hosts')[endpoint_type] || this.get_config('api_host');
31407 };
31408
31409 MixpanelLib.prototype.toString = function() {
31410 var name = this.get_config('name');
31411 if (name !== PRIMARY_INSTANCE_NAME) {
31412 name = PRIMARY_INSTANCE_NAME + '.' + name;
31413 }
31414 return name;
31415 };
31416
31417 MixpanelLib.prototype._event_is_disabled = function(event_name) {
31418 return _.isBlockedUA(userAgent) ||
31419 this._flags.disable_all_events ||
31420 _.include(this.__disabled_events, event_name);
31421 };
31422
31423 // perform some housekeeping around GDPR opt-in/out state
31424 MixpanelLib.prototype._gdpr_init = function() {
31425 var is_localStorage_requested = this.get_config('opt_out_tracking_persistence_type') === 'localStorage';
31426
31427 // try to convert opt-in/out cookies to localStorage if possible
31428 if (is_localStorage_requested && _.localStorage.is_supported()) {
31429 if (!this.has_opted_in_tracking() && this.has_opted_in_tracking({'persistence_type': 'cookie'})) {
31430 this.opt_in_tracking({'enable_persistence': false});
31431 }
31432 if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({'persistence_type': 'cookie'})) {
31433 this.opt_out_tracking({'clear_persistence': false});
31434 }
31435 this.clear_opt_in_out_tracking({
31436 'persistence_type': 'cookie',
31437 'enable_persistence': false
31438 });
31439 }
31440
31441 // check whether the user has already opted out - if so, clear & disable persistence
31442 if (this.has_opted_out_tracking()) {
31443 this._gdpr_update_persistence({'clear_persistence': true});
31444
31445 // check whether we should opt out by default
31446 // note: we don't clear persistence here by default since opt-out default state is often
31447 // used as an initial state while GDPR information is being collected
31448 } else if (!this.has_opted_in_tracking() && (
31449 this.get_config('opt_out_tracking_by_default') || _.cookie.get('mp_optout')
31450 )) {
31451 _.cookie.remove('mp_optout');
31452 this.opt_out_tracking({
31453 'clear_persistence': this.get_config('opt_out_persistence_by_default')
31454 });
31455 }
31456 };
31457
31458 /**
31459 * Enable or disable persistence based on options
31460 * only enable/disable if persistence is not already in this state
31461 * @param {boolean} [options.clear_persistence] If true, will delete all data stored by the sdk in persistence and disable it
31462 * @param {boolean} [options.enable_persistence] If true, will re-enable sdk persistence
31463 */
31464 MixpanelLib.prototype._gdpr_update_persistence = function(options) {
31465 var disabled;
31466 if (options && options['clear_persistence']) {
31467 disabled = true;
31468 } else if (options && options['enable_persistence']) {
31469 disabled = false;
31470 } else {
31471 return;
31472 }
31473
31474 if (!this.get_config('disable_persistence') && this['persistence'].disabled !== disabled) {
31475 this['persistence'].set_disabled(disabled);
31476 }
31477
31478 if (disabled) {
31479 this.stop_batch_senders();
31480 this.stop_session_recording();
31481 } else {
31482 // only start batchers after opt-in if they have previously been started
31483 // in order to avoid unintentionally starting up batching for the first time
31484 if (this._batchers_were_started) {
31485 this.start_batch_senders();
31486 }
31487 }
31488 };
31489
31490 // call a base gdpr function after constructing the appropriate token and options args
31491 MixpanelLib.prototype._gdpr_call_func = function(func, options) {
31492 options = _.extend({
31493 'track': _.bind(this.track, this),
31494 'persistence_type': this.get_config('opt_out_tracking_persistence_type'),
31495 'cookie_prefix': this.get_config('opt_out_tracking_cookie_prefix'),
31496 'cookie_expiration': this.get_config('cookie_expiration'),
31497 'cross_site_cookie': this.get_config('cross_site_cookie'),
31498 'cross_subdomain_cookie': this.get_config('cross_subdomain_cookie'),
31499 'cookie_domain': this.get_config('cookie_domain'),
31500 'secure_cookie': this.get_config('secure_cookie'),
31501 'ignore_dnt': this.get_config('ignore_dnt')
31502 }, options);
31503
31504 // check if localStorage can be used for recording opt out status, fall back to cookie if not
31505 if (!_.localStorage.is_supported()) {
31506 options['persistence_type'] = 'cookie';
31507 }
31508
31509 return func(this.get_config('token'), {
31510 track: options['track'],
31511 trackEventName: options['track_event_name'],
31512 trackProperties: options['track_properties'],
31513 persistenceType: options['persistence_type'],
31514 persistencePrefix: options['cookie_prefix'],
31515 cookieDomain: options['cookie_domain'],
31516 cookieExpiration: options['cookie_expiration'],
31517 crossSiteCookie: options['cross_site_cookie'],
31518 crossSubdomainCookie: options['cross_subdomain_cookie'],
31519 secureCookie: options['secure_cookie'],
31520 ignoreDnt: options['ignore_dnt']
31521 });
31522 };
31523
31524 /**
31525 * Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
31526 *
31527 * ### Usage:
31528 *
31529 * // opt user in
31530 * mixpanel.opt_in_tracking();
31531 *
31532 * // opt user in with specific event name, properties, cookie configuration
31533 * mixpanel.opt_in_tracking({
31534 * track_event_name: 'User opted in',
31535 * track_event_properties: {
31536 * 'Email': 'jdoe@example.com'
31537 * },
31538 * cookie_expiration: 30,
31539 * secure_cookie: true
31540 * });
31541 *
31542 * @param {Object} [options] A dictionary of config options to override
31543 * @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)
31544 * @param {string} [options.track_event_name=$opt_in] Event name to be used for tracking the opt-in action
31545 * @param {Object} [options.track_properties] Set of properties to be tracked along with the opt-in action
31546 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
31547 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31548 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31549 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
31550 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
31551 * @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)
31552 * @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)
31553 * @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)
31554 */
31555 MixpanelLib.prototype.opt_in_tracking = function(options) {
31556 options = _.extend({
31557 'enable_persistence': true
31558 }, options);
31559
31560 this._gdpr_call_func(optIn, options);
31561 this._gdpr_update_persistence(options);
31562 };
31563
31564 /**
31565 * Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
31566 *
31567 * ### Usage:
31568 *
31569 * // opt user out
31570 * mixpanel.opt_out_tracking();
31571 *
31572 * // opt user out with different cookie configuration from Mixpanel instance
31573 * mixpanel.opt_out_tracking({
31574 * cookie_expiration: 30,
31575 * secure_cookie: true
31576 * });
31577 *
31578 * @param {Object} [options] A dictionary of config options to override
31579 * @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
31580 * @param {boolean} [options.clear_persistence=true] If true, will delete all data stored by the sdk in persistence
31581 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31582 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31583 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
31584 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
31585 * @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)
31586 * @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)
31587 * @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)
31588 */
31589 MixpanelLib.prototype.opt_out_tracking = function(options) {
31590 options = _.extend({
31591 'clear_persistence': true,
31592 'delete_user': true
31593 }, options);
31594
31595 // delete user and clear charges since these methods may be disabled by opt-out
31596 if (options['delete_user'] && this['people'] && this['people']._identify_called()) {
31597 this['people'].delete_user();
31598 this['people'].clear_charges();
31599 }
31600
31601 this._gdpr_call_func(optOut, options);
31602 this._gdpr_update_persistence(options);
31603 };
31604
31605 /**
31606 * Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
31607 *
31608 * ### Usage:
31609 *
31610 * var has_opted_in = mixpanel.has_opted_in_tracking();
31611 * // use has_opted_in value
31612 *
31613 * @param {Object} [options] A dictionary of config options to override
31614 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31615 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31616 * @returns {boolean} current opt-in status
31617 */
31618 MixpanelLib.prototype.has_opted_in_tracking = function(options) {
31619 return this._gdpr_call_func(hasOptedIn, options);
31620 };
31621
31622 /**
31623 * Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
31624 *
31625 * ### Usage:
31626 *
31627 * var has_opted_out = mixpanel.has_opted_out_tracking();
31628 * // use has_opted_out value
31629 *
31630 * @param {Object} [options] A dictionary of config options to override
31631 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31632 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31633 * @returns {boolean} current opt-out status
31634 */
31635 MixpanelLib.prototype.has_opted_out_tracking = function(options) {
31636 return this._gdpr_call_func(hasOptedOut, options);
31637 };
31638
31639 /**
31640 * Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
31641 *
31642 * ### Usage:
31643 *
31644 * // clear user's opt-in/out status
31645 * mixpanel.clear_opt_in_out_tracking();
31646 *
31647 * // clear user's opt-in/out status with specific cookie configuration - should match
31648 * // configuration used when opt_in_tracking/opt_out_tracking methods were called.
31649 * mixpanel.clear_opt_in_out_tracking({
31650 * cookie_expiration: 30,
31651 * secure_cookie: true
31652 * });
31653 *
31654 * @param {Object} [options] A dictionary of config options to override
31655 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
31656 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31657 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31658 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
31659 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
31660 * @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)
31661 * @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)
31662 * @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)
31663 */
31664 MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
31665 options = _.extend({
31666 'enable_persistence': true
31667 }, options);
31668
31669 this._gdpr_call_func(clearOptInOut, options);
31670 this._gdpr_update_persistence(options);
31671 };
31672
31673 MixpanelLib.prototype.report_error = function(msg, err) {
31674 console$1.error.apply(console$1.error, arguments);
31675 try {
31676 if (!err && !(msg instanceof Error)) {
31677 msg = new Error(msg);
31678 }
31679 this.get_config('error_reporter')(msg, err);
31680 } catch(err) {
31681 console$1.error(err);
31682 }
31683 };
31684
31685 // EXPORTS (for closure compiler)
31686
31687 // MixpanelLib Exports
31688 MixpanelLib.prototype['init'] = MixpanelLib.prototype.init;
31689 MixpanelLib.prototype['reset'] = MixpanelLib.prototype.reset;
31690 MixpanelLib.prototype['disable'] = MixpanelLib.prototype.disable;
31691 MixpanelLib.prototype['time_event'] = MixpanelLib.prototype.time_event;
31692 MixpanelLib.prototype['track'] = MixpanelLib.prototype.track;
31693 MixpanelLib.prototype['track_links'] = MixpanelLib.prototype.track_links;
31694 MixpanelLib.prototype['track_forms'] = MixpanelLib.prototype.track_forms;
31695 MixpanelLib.prototype['track_pageview'] = MixpanelLib.prototype.track_pageview;
31696 MixpanelLib.prototype['register'] = MixpanelLib.prototype.register;
31697 MixpanelLib.prototype['register_once'] = MixpanelLib.prototype.register_once;
31698 MixpanelLib.prototype['unregister'] = MixpanelLib.prototype.unregister;
31699 MixpanelLib.prototype['identify'] = MixpanelLib.prototype.identify;
31700 MixpanelLib.prototype['alias'] = MixpanelLib.prototype.alias;
31701 MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
31702 MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
31703 MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
31704 MixpanelLib.prototype['get_api_host'] = MixpanelLib.prototype.get_api_host;
31705 MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
31706 MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
31707 MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
31708 MixpanelLib.prototype['opt_out_tracking'] = MixpanelLib.prototype.opt_out_tracking;
31709 MixpanelLib.prototype['opt_in_tracking'] = MixpanelLib.prototype.opt_in_tracking;
31710 MixpanelLib.prototype['has_opted_out_tracking'] = MixpanelLib.prototype.has_opted_out_tracking;
31711 MixpanelLib.prototype['has_opted_in_tracking'] = MixpanelLib.prototype.has_opted_in_tracking;
31712 MixpanelLib.prototype['clear_opt_in_out_tracking'] = MixpanelLib.prototype.clear_opt_in_out_tracking;
31713 MixpanelLib.prototype['get_group'] = MixpanelLib.prototype.get_group;
31714 MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
31715 MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
31716 MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
31717 MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
31718 MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
31719 MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;
31720 MixpanelLib.prototype['start_session_recording'] = MixpanelLib.prototype.start_session_recording;
31721 MixpanelLib.prototype['stop_session_recording'] = MixpanelLib.prototype.stop_session_recording;
31722 MixpanelLib.prototype['pause_session_recording'] = MixpanelLib.prototype.pause_session_recording;
31723 MixpanelLib.prototype['resume_session_recording'] = MixpanelLib.prototype.resume_session_recording;
31724 MixpanelLib.prototype['get_session_recording_properties'] = MixpanelLib.prototype.get_session_recording_properties;
31725 MixpanelLib.prototype['get_session_replay_url'] = MixpanelLib.prototype.get_session_replay_url;
31726 MixpanelLib.prototype['get_tab_id'] = MixpanelLib.prototype.get_tab_id;
31727 MixpanelLib.prototype['DEFAULT_API_ROUTES'] = DEFAULT_API_ROUTES;
31728
31729 // Exports intended only for testing
31730 MixpanelLib.prototype['__get_recorder'] = MixpanelLib.prototype.__get_recorder;
31731
31732 // MixpanelPersistence Exports
31733 MixpanelPersistence.prototype['properties'] = MixpanelPersistence.prototype.properties;
31734 MixpanelPersistence.prototype['update_search_keyword'] = MixpanelPersistence.prototype.update_search_keyword;
31735 MixpanelPersistence.prototype['update_referrer_info'] = MixpanelPersistence.prototype.update_referrer_info;
31736 MixpanelPersistence.prototype['get_cross_subdomain'] = MixpanelPersistence.prototype.get_cross_subdomain;
31737 MixpanelPersistence.prototype['clear'] = MixpanelPersistence.prototype.clear;
31738
31739
31740 var instances = {};
31741 var extend_mp = function() {
31742 // add all the sub mixpanel instances
31743 _.each(instances, function(instance, name) {
31744 if (name !== PRIMARY_INSTANCE_NAME) { mixpanel_master[name] = instance; }
31745 });
31746
31747 // add private functions as _
31748 mixpanel_master['_'] = _;
31749 };
31750
31751 var override_mp_init_func = function() {
31752 // we override the snippets init function to handle the case where a
31753 // user initializes the mixpanel library after the script loads & runs
31754 mixpanel_master['init'] = function(token, config, name) {
31755 if (name) {
31756 // initialize a sub library
31757 if (!mixpanel_master[name]) {
31758 mixpanel_master[name] = instances[name] = create_mplib(token, config, name);
31759 mixpanel_master[name]._loaded();
31760 }
31761 return mixpanel_master[name];
31762 } else {
31763 var instance = mixpanel_master;
31764
31765 if (instances[PRIMARY_INSTANCE_NAME]) {
31766 // main mixpanel lib already initialized
31767 instance = instances[PRIMARY_INSTANCE_NAME];
31768 } else if (token) {
31769 // intialize the main mixpanel lib
31770 instance = create_mplib(token, config, PRIMARY_INSTANCE_NAME);
31771 instance._loaded();
31772 instances[PRIMARY_INSTANCE_NAME] = instance;
31773 }
31774
31775 mixpanel_master = instance;
31776 if (init_type === INIT_SNIPPET) {
31777 win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
31778 }
31779 extend_mp();
31780 }
31781 };
31782 };
31783
31784 var add_dom_loaded_handler = function() {
31785 // Cross browser DOM Loaded support
31786 function dom_loaded_handler() {
31787 // function flag since we only want to execute this once
31788 if (dom_loaded_handler.done) { return; }
31789 dom_loaded_handler.done = true;
31790
31791 DOM_LOADED = true;
31792 ENQUEUE_REQUESTS = false;
31793
31794 _.each(instances, function(inst) {
31795 inst._dom_loaded();
31796 });
31797 }
31798
31799 function do_scroll_check() {
31800 try {
31801 document$1.documentElement.doScroll('left');
31802 } catch(e) {
31803 setTimeout(do_scroll_check, 1);
31804 return;
31805 }
31806
31807 dom_loaded_handler();
31808 }
31809
31810 if (document$1.addEventListener) {
31811 if (document$1.readyState === 'complete') {
31812 // safari 4 can fire the DOMContentLoaded event before loading all
31813 // external JS (including this file). you will see some copypasta
31814 // on the internet that checks for 'complete' and 'loaded', but
31815 // 'loaded' is an IE thing
31816 dom_loaded_handler();
31817 } else {
31818 document$1.addEventListener('DOMContentLoaded', dom_loaded_handler, false);
31819 }
31820 } else if (document$1.attachEvent) {
31821 // IE
31822 document$1.attachEvent('onreadystatechange', dom_loaded_handler);
31823
31824 // check to make sure we arn't in a frame
31825 var toplevel = false;
31826 try {
31827 toplevel = win.frameElement === null;
31828 } catch(e) {
31829 // noop
31830 }
31831
31832 if (document$1.documentElement.doScroll && toplevel) {
31833 do_scroll_check();
31834 }
31835 }
31836
31837 // fallback handler, always will work
31838 _.register_event(win, 'load', dom_loaded_handler, true);
31839 };
31840
31841 function init_as_module(bundle_loader) {
31842 load_extra_bundle = bundle_loader;
31843 init_type = INIT_MODULE;
31844 mixpanel_master = new MixpanelLib();
31845
31846 override_mp_init_func();
31847 mixpanel_master['init']();
31848 add_dom_loaded_handler();
31849
31850 return mixpanel_master;
31851 }
31852
31853 // For loading separate bundles asynchronously via script tag
31854 // so that we don't load them until they are needed at runtime.
31855
31856 // For builds that have everything in one bundle, no extra work.
31857 function loadNoop (_src, onload) {
31858 onload();
31859 }
31860
31861 /* eslint camelcase: "off" */
31862
31863 var mixpanel = init_as_module(loadNoop);
31864
31865
31866
31867
31868 /***/ }),
31869
31870 /***/ "../node_modules/redux-thunk/es/index.js":
31871 /*!***********************************************!*\
31872 !*** ../node_modules/redux-thunk/es/index.js ***!
31873 \***********************************************/
31874 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
31875
31876 "use strict";
31877 __webpack_require__.r(__webpack_exports__);
31878 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
31879 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
31880 /* harmony export */ });
31881 /** A function that accepts a potential "extra argument" value to be injected later,
31882 * and returns an instance of the thunk middleware that uses that value
31883 */
31884 function createThunkMiddleware(extraArgument) {
31885 // Standard Redux middleware definition pattern:
31886 // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
31887 var middleware = function middleware(_ref) {
31888 var dispatch = _ref.dispatch,
31889 getState = _ref.getState;
31890 return function (next) {
31891 return function (action) {
31892 // The thunk middleware looks for any functions that were passed to `store.dispatch`.
31893 // If this "action" is really a function, call it and return the result.
31894 if (typeof action === 'function') {
31895 // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
31896 return action(dispatch, getState, extraArgument);
31897 } // Otherwise, pass the action down the middleware chain as usual
31898
31899
31900 return next(action);
31901 };
31902 };
31903 };
31904
31905 return middleware;
31906 }
31907
31908 var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
31909 // with whatever "extra arg" they want to inject into their thunks
31910
31911 thunk.withExtraArgument = createThunkMiddleware;
31912 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (thunk);
31913
31914 /***/ }),
31915
31916 /***/ "../node_modules/redux/es/redux.js":
31917 /*!*****************************************!*\
31918 !*** ../node_modules/redux/es/redux.js ***!
31919 \*****************************************/
31920 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
31921
31922 "use strict";
31923 __webpack_require__.r(__webpack_exports__);
31924 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
31925 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* binding */ ActionTypes),
31926 /* harmony export */ applyMiddleware: () => (/* binding */ applyMiddleware),
31927 /* harmony export */ bindActionCreators: () => (/* binding */ bindActionCreators),
31928 /* harmony export */ combineReducers: () => (/* binding */ combineReducers),
31929 /* harmony export */ compose: () => (/* binding */ compose),
31930 /* harmony export */ createStore: () => (/* binding */ createStore),
31931 /* harmony export */ legacy_createStore: () => (/* binding */ legacy_createStore)
31932 /* harmony export */ });
31933 /* 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");
31934
31935
31936 /**
31937 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
31938 *
31939 * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
31940 * during build.
31941 * @param {number} code
31942 */
31943 function formatProdErrorMessage(code) {
31944 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. ';
31945 }
31946
31947 // Inlined version of the `symbol-observable` polyfill
31948 var $$observable = (function () {
31949 return typeof Symbol === 'function' && Symbol.observable || '@@observable';
31950 })();
31951
31952 /**
31953 * These are private action types reserved by Redux.
31954 * For any unknown actions, you must return the current state.
31955 * If the current state is undefined, you must return the initial state.
31956 * Do not reference these action types directly in your code.
31957 */
31958 var randomString = function randomString() {
31959 return Math.random().toString(36).substring(7).split('').join('.');
31960 };
31961
31962 var ActionTypes = {
31963 INIT: "@@redux/INIT" + randomString(),
31964 REPLACE: "@@redux/REPLACE" + randomString(),
31965 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
31966 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
31967 }
31968 };
31969
31970 /**
31971 * @param {any} obj The object to inspect.
31972 * @returns {boolean} True if the argument appears to be a plain object.
31973 */
31974 function isPlainObject(obj) {
31975 if (typeof obj !== 'object' || obj === null) return false;
31976 var proto = obj;
31977
31978 while (Object.getPrototypeOf(proto) !== null) {
31979 proto = Object.getPrototypeOf(proto);
31980 }
31981
31982 return Object.getPrototypeOf(obj) === proto;
31983 }
31984
31985 // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
31986 function miniKindOf(val) {
31987 if (val === void 0) return 'undefined';
31988 if (val === null) return 'null';
31989 var type = typeof val;
31990
31991 switch (type) {
31992 case 'boolean':
31993 case 'string':
31994 case 'number':
31995 case 'symbol':
31996 case 'function':
31997 {
31998 return type;
31999 }
32000 }
32001
32002 if (Array.isArray(val)) return 'array';
32003 if (isDate(val)) return 'date';
32004 if (isError(val)) return 'error';
32005 var constructorName = ctorName(val);
32006
32007 switch (constructorName) {
32008 case 'Symbol':
32009 case 'Promise':
32010 case 'WeakMap':
32011 case 'WeakSet':
32012 case 'Map':
32013 case 'Set':
32014 return constructorName;
32015 } // other
32016
32017
32018 return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
32019 }
32020
32021 function ctorName(val) {
32022 return typeof val.constructor === 'function' ? val.constructor.name : null;
32023 }
32024
32025 function isError(val) {
32026 return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
32027 }
32028
32029 function isDate(val) {
32030 if (val instanceof Date) return true;
32031 return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
32032 }
32033
32034 function kindOf(val) {
32035 var typeOfVal = typeof val;
32036
32037 if (true) {
32038 typeOfVal = miniKindOf(val);
32039 }
32040
32041 return typeOfVal;
32042 }
32043
32044 /**
32045 * @deprecated
32046 *
32047 * **We recommend using the `configureStore` method
32048 * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
32049 *
32050 * Redux Toolkit is our recommended approach for writing Redux logic today,
32051 * including store setup, reducers, data fetching, and more.
32052 *
32053 * **For more details, please read this Redux docs page:**
32054 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32055 *
32056 * `configureStore` from Redux Toolkit is an improved version of `createStore` that
32057 * simplifies setup and helps avoid common bugs.
32058 *
32059 * You should not be using the `redux` core package by itself today, except for learning purposes.
32060 * The `createStore` method from the core `redux` package will not be removed, but we encourage
32061 * all users to migrate to using Redux Toolkit for all Redux code.
32062 *
32063 * If you want to use `createStore` without this visual deprecation warning, use
32064 * the `legacy_createStore` import instead:
32065 *
32066 * `import { legacy_createStore as createStore} from 'redux'`
32067 *
32068 */
32069
32070 function createStore(reducer, preloadedState, enhancer) {
32071 var _ref2;
32072
32073 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
32074 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.');
32075 }
32076
32077 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
32078 enhancer = preloadedState;
32079 preloadedState = undefined;
32080 }
32081
32082 if (typeof enhancer !== 'undefined') {
32083 if (typeof enhancer !== 'function') {
32084 throw new Error( false ? 0 : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
32085 }
32086
32087 return enhancer(createStore)(reducer, preloadedState);
32088 }
32089
32090 if (typeof reducer !== 'function') {
32091 throw new Error( false ? 0 : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
32092 }
32093
32094 var currentReducer = reducer;
32095 var currentState = preloadedState;
32096 var currentListeners = [];
32097 var nextListeners = currentListeners;
32098 var isDispatching = false;
32099 /**
32100 * This makes a shallow copy of currentListeners so we can use
32101 * nextListeners as a temporary list while dispatching.
32102 *
32103 * This prevents any bugs around consumers calling
32104 * subscribe/unsubscribe in the middle of a dispatch.
32105 */
32106
32107 function ensureCanMutateNextListeners() {
32108 if (nextListeners === currentListeners) {
32109 nextListeners = currentListeners.slice();
32110 }
32111 }
32112 /**
32113 * Reads the state tree managed by the store.
32114 *
32115 * @returns {any} The current state tree of your application.
32116 */
32117
32118
32119 function getState() {
32120 if (isDispatching) {
32121 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.');
32122 }
32123
32124 return currentState;
32125 }
32126 /**
32127 * Adds a change listener. It will be called any time an action is dispatched,
32128 * and some part of the state tree may potentially have changed. You may then
32129 * call `getState()` to read the current state tree inside the callback.
32130 *
32131 * You may call `dispatch()` from a change listener, with the following
32132 * caveats:
32133 *
32134 * 1. The subscriptions are snapshotted just before every `dispatch()` call.
32135 * If you subscribe or unsubscribe while the listeners are being invoked, this
32136 * will not have any effect on the `dispatch()` that is currently in progress.
32137 * However, the next `dispatch()` call, whether nested or not, will use a more
32138 * recent snapshot of the subscription list.
32139 *
32140 * 2. The listener should not expect to see all state changes, as the state
32141 * might have been updated multiple times during a nested `dispatch()` before
32142 * the listener is called. It is, however, guaranteed that all subscribers
32143 * registered before the `dispatch()` started will be called with the latest
32144 * state by the time it exits.
32145 *
32146 * @param {Function} listener A callback to be invoked on every dispatch.
32147 * @returns {Function} A function to remove this change listener.
32148 */
32149
32150
32151 function subscribe(listener) {
32152 if (typeof listener !== 'function') {
32153 throw new Error( false ? 0 : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
32154 }
32155
32156 if (isDispatching) {
32157 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.');
32158 }
32159
32160 var isSubscribed = true;
32161 ensureCanMutateNextListeners();
32162 nextListeners.push(listener);
32163 return function unsubscribe() {
32164 if (!isSubscribed) {
32165 return;
32166 }
32167
32168 if (isDispatching) {
32169 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.');
32170 }
32171
32172 isSubscribed = false;
32173 ensureCanMutateNextListeners();
32174 var index = nextListeners.indexOf(listener);
32175 nextListeners.splice(index, 1);
32176 currentListeners = null;
32177 };
32178 }
32179 /**
32180 * Dispatches an action. It is the only way to trigger a state change.
32181 *
32182 * The `reducer` function, used to create the store, will be called with the
32183 * current state tree and the given `action`. Its return value will
32184 * be considered the **next** state of the tree, and the change listeners
32185 * will be notified.
32186 *
32187 * The base implementation only supports plain object actions. If you want to
32188 * dispatch a Promise, an Observable, a thunk, or something else, you need to
32189 * wrap your store creating function into the corresponding middleware. For
32190 * example, see the documentation for the `redux-thunk` package. Even the
32191 * middleware will eventually dispatch plain object actions using this method.
32192 *
32193 * @param {Object} action A plain object representing “what changed”. It is
32194 * a good idea to keep actions serializable so you can record and replay user
32195 * sessions, or use the time travelling `redux-devtools`. An action must have
32196 * a `type` property which may not be `undefined`. It is a good idea to use
32197 * string constants for action types.
32198 *
32199 * @returns {Object} For convenience, the same action object you dispatched.
32200 *
32201 * Note that, if you use a custom middleware, it may wrap `dispatch()` to
32202 * return something else (for example, a Promise you can await).
32203 */
32204
32205
32206 function dispatch(action) {
32207 if (!isPlainObject(action)) {
32208 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.");
32209 }
32210
32211 if (typeof action.type === 'undefined') {
32212 throw new Error( false ? 0 : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
32213 }
32214
32215 if (isDispatching) {
32216 throw new Error( false ? 0 : 'Reducers may not dispatch actions.');
32217 }
32218
32219 try {
32220 isDispatching = true;
32221 currentState = currentReducer(currentState, action);
32222 } finally {
32223 isDispatching = false;
32224 }
32225
32226 var listeners = currentListeners = nextListeners;
32227
32228 for (var i = 0; i < listeners.length; i++) {
32229 var listener = listeners[i];
32230 listener();
32231 }
32232
32233 return action;
32234 }
32235 /**
32236 * Replaces the reducer currently used by the store to calculate the state.
32237 *
32238 * You might need this if your app implements code splitting and you want to
32239 * load some of the reducers dynamically. You might also need this if you
32240 * implement a hot reloading mechanism for Redux.
32241 *
32242 * @param {Function} nextReducer The reducer for the store to use instead.
32243 * @returns {void}
32244 */
32245
32246
32247 function replaceReducer(nextReducer) {
32248 if (typeof nextReducer !== 'function') {
32249 throw new Error( false ? 0 : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
32250 }
32251
32252 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
32253 // Any reducers that existed in both the new and old rootReducer
32254 // will receive the previous state. This effectively populates
32255 // the new state tree with any relevant data from the old one.
32256
32257 dispatch({
32258 type: ActionTypes.REPLACE
32259 });
32260 }
32261 /**
32262 * Interoperability point for observable/reactive libraries.
32263 * @returns {observable} A minimal observable of state changes.
32264 * For more information, see the observable proposal:
32265 * https://github.com/tc39/proposal-observable
32266 */
32267
32268
32269 function observable() {
32270 var _ref;
32271
32272 var outerSubscribe = subscribe;
32273 return _ref = {
32274 /**
32275 * The minimal observable subscription method.
32276 * @param {Object} observer Any object that can be used as an observer.
32277 * The observer object should have a `next` method.
32278 * @returns {subscription} An object with an `unsubscribe` method that can
32279 * be used to unsubscribe the observable from the store, and prevent further
32280 * emission of values from the observable.
32281 */
32282 subscribe: function subscribe(observer) {
32283 if (typeof observer !== 'object' || observer === null) {
32284 throw new Error( false ? 0 : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
32285 }
32286
32287 function observeState() {
32288 if (observer.next) {
32289 observer.next(getState());
32290 }
32291 }
32292
32293 observeState();
32294 var unsubscribe = outerSubscribe(observeState);
32295 return {
32296 unsubscribe: unsubscribe
32297 };
32298 }
32299 }, _ref[$$observable] = function () {
32300 return this;
32301 }, _ref;
32302 } // When a store is created, an "INIT" action is dispatched so that every
32303 // reducer returns their initial state. This effectively populates
32304 // the initial state tree.
32305
32306
32307 dispatch({
32308 type: ActionTypes.INIT
32309 });
32310 return _ref2 = {
32311 dispatch: dispatch,
32312 subscribe: subscribe,
32313 getState: getState,
32314 replaceReducer: replaceReducer
32315 }, _ref2[$$observable] = observable, _ref2;
32316 }
32317 /**
32318 * Creates a Redux store that holds the state tree.
32319 *
32320 * **We recommend using `configureStore` from the
32321 * `@reduxjs/toolkit` package**, which replaces `createStore`:
32322 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32323 *
32324 * The only way to change the data in the store is to call `dispatch()` on it.
32325 *
32326 * There should only be a single store in your app. To specify how different
32327 * parts of the state tree respond to actions, you may combine several reducers
32328 * into a single reducer function by using `combineReducers`.
32329 *
32330 * @param {Function} reducer A function that returns the next state tree, given
32331 * the current state tree and the action to handle.
32332 *
32333 * @param {any} [preloadedState] The initial state. You may optionally specify it
32334 * to hydrate the state from the server in universal apps, or to restore a
32335 * previously serialized user session.
32336 * If you use `combineReducers` to produce the root reducer function, this must be
32337 * an object with the same shape as `combineReducers` keys.
32338 *
32339 * @param {Function} [enhancer] The store enhancer. You may optionally specify it
32340 * to enhance the store with third-party capabilities such as middleware,
32341 * time travel, persistence, etc. The only store enhancer that ships with Redux
32342 * is `applyMiddleware()`.
32343 *
32344 * @returns {Store} A Redux store that lets you read the state, dispatch actions
32345 * and subscribe to changes.
32346 */
32347
32348 var legacy_createStore = createStore;
32349
32350 /**
32351 * Prints a warning in the console if it exists.
32352 *
32353 * @param {String} message The warning message.
32354 * @returns {void}
32355 */
32356 function warning(message) {
32357 /* eslint-disable no-console */
32358 if (typeof console !== 'undefined' && typeof console.error === 'function') {
32359 console.error(message);
32360 }
32361 /* eslint-enable no-console */
32362
32363
32364 try {
32365 // This error was thrown as a convenience so that if you enable
32366 // "break on all exceptions" in your console,
32367 // it would pause the execution at this line.
32368 throw new Error(message);
32369 } catch (e) {} // eslint-disable-line no-empty
32370
32371 }
32372
32373 function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
32374 var reducerKeys = Object.keys(reducers);
32375 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
32376
32377 if (reducerKeys.length === 0) {
32378 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
32379 }
32380
32381 if (!isPlainObject(inputState)) {
32382 return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
32383 }
32384
32385 var unexpectedKeys = Object.keys(inputState).filter(function (key) {
32386 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
32387 });
32388 unexpectedKeys.forEach(function (key) {
32389 unexpectedKeyCache[key] = true;
32390 });
32391 if (action && action.type === ActionTypes.REPLACE) return;
32392
32393 if (unexpectedKeys.length > 0) {
32394 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.");
32395 }
32396 }
32397
32398 function assertReducerShape(reducers) {
32399 Object.keys(reducers).forEach(function (key) {
32400 var reducer = reducers[key];
32401 var initialState = reducer(undefined, {
32402 type: ActionTypes.INIT
32403 });
32404
32405 if (typeof initialState === 'undefined') {
32406 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.");
32407 }
32408
32409 if (typeof reducer(undefined, {
32410 type: ActionTypes.PROBE_UNKNOWN_ACTION()
32411 }) === 'undefined') {
32412 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.");
32413 }
32414 });
32415 }
32416 /**
32417 * Turns an object whose values are different reducer functions, into a single
32418 * reducer function. It will call every child reducer, and gather their results
32419 * into a single state object, whose keys correspond to the keys of the passed
32420 * reducer functions.
32421 *
32422 * @param {Object} reducers An object whose values correspond to different
32423 * reducer functions that need to be combined into one. One handy way to obtain
32424 * it is to use ES6 `import * as reducers` syntax. The reducers may never return
32425 * undefined for any action. Instead, they should return their initial state
32426 * if the state passed to them was undefined, and the current state for any
32427 * unrecognized action.
32428 *
32429 * @returns {Function} A reducer function that invokes every reducer inside the
32430 * passed object, and builds a state object with the same shape.
32431 */
32432
32433
32434 function combineReducers(reducers) {
32435 var reducerKeys = Object.keys(reducers);
32436 var finalReducers = {};
32437
32438 for (var i = 0; i < reducerKeys.length; i++) {
32439 var key = reducerKeys[i];
32440
32441 if (true) {
32442 if (typeof reducers[key] === 'undefined') {
32443 warning("No reducer provided for key \"" + key + "\"");
32444 }
32445 }
32446
32447 if (typeof reducers[key] === 'function') {
32448 finalReducers[key] = reducers[key];
32449 }
32450 }
32451
32452 var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
32453 // keys multiple times.
32454
32455 var unexpectedKeyCache;
32456
32457 if (true) {
32458 unexpectedKeyCache = {};
32459 }
32460
32461 var shapeAssertionError;
32462
32463 try {
32464 assertReducerShape(finalReducers);
32465 } catch (e) {
32466 shapeAssertionError = e;
32467 }
32468
32469 return function combination(state, action) {
32470 if (state === void 0) {
32471 state = {};
32472 }
32473
32474 if (shapeAssertionError) {
32475 throw shapeAssertionError;
32476 }
32477
32478 if (true) {
32479 var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
32480
32481 if (warningMessage) {
32482 warning(warningMessage);
32483 }
32484 }
32485
32486 var hasChanged = false;
32487 var nextState = {};
32488
32489 for (var _i = 0; _i < finalReducerKeys.length; _i++) {
32490 var _key = finalReducerKeys[_i];
32491 var reducer = finalReducers[_key];
32492 var previousStateForKey = state[_key];
32493 var nextStateForKey = reducer(previousStateForKey, action);
32494
32495 if (typeof nextStateForKey === 'undefined') {
32496 var actionType = action && action.type;
32497 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.");
32498 }
32499
32500 nextState[_key] = nextStateForKey;
32501 hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
32502 }
32503
32504 hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
32505 return hasChanged ? nextState : state;
32506 };
32507 }
32508
32509 function bindActionCreator(actionCreator, dispatch) {
32510 return function () {
32511 return dispatch(actionCreator.apply(this, arguments));
32512 };
32513 }
32514 /**
32515 * Turns an object whose values are action creators, into an object with the
32516 * same keys, but with every function wrapped into a `dispatch` call so they
32517 * may be invoked directly. This is just a convenience method, as you can call
32518 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
32519 *
32520 * For convenience, you can also pass an action creator as the first argument,
32521 * and get a dispatch wrapped function in return.
32522 *
32523 * @param {Function|Object} actionCreators An object whose values are action
32524 * creator functions. One handy way to obtain it is to use ES6 `import * as`
32525 * syntax. You may also pass a single function.
32526 *
32527 * @param {Function} dispatch The `dispatch` function available on your Redux
32528 * store.
32529 *
32530 * @returns {Function|Object} The object mimicking the original object, but with
32531 * every action creator wrapped into the `dispatch` call. If you passed a
32532 * function as `actionCreators`, the return value will also be a single
32533 * function.
32534 */
32535
32536
32537 function bindActionCreators(actionCreators, dispatch) {
32538 if (typeof actionCreators === 'function') {
32539 return bindActionCreator(actionCreators, dispatch);
32540 }
32541
32542 if (typeof actionCreators !== 'object' || actionCreators === null) {
32543 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\"?");
32544 }
32545
32546 var boundActionCreators = {};
32547
32548 for (var key in actionCreators) {
32549 var actionCreator = actionCreators[key];
32550
32551 if (typeof actionCreator === 'function') {
32552 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
32553 }
32554 }
32555
32556 return boundActionCreators;
32557 }
32558
32559 /**
32560 * Composes single-argument functions from right to left. The rightmost
32561 * function can take multiple arguments as it provides the signature for
32562 * the resulting composite function.
32563 *
32564 * @param {...Function} funcs The functions to compose.
32565 * @returns {Function} A function obtained by composing the argument functions
32566 * from right to left. For example, compose(f, g, h) is identical to doing
32567 * (...args) => f(g(h(...args))).
32568 */
32569 function compose() {
32570 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
32571 funcs[_key] = arguments[_key];
32572 }
32573
32574 if (funcs.length === 0) {
32575 return function (arg) {
32576 return arg;
32577 };
32578 }
32579
32580 if (funcs.length === 1) {
32581 return funcs[0];
32582 }
32583
32584 return funcs.reduce(function (a, b) {
32585 return function () {
32586 return a(b.apply(void 0, arguments));
32587 };
32588 });
32589 }
32590
32591 /**
32592 * Creates a store enhancer that applies middleware to the dispatch method
32593 * of the Redux store. This is handy for a variety of tasks, such as expressing
32594 * asynchronous actions in a concise manner, or logging every action payload.
32595 *
32596 * See `redux-thunk` package as an example of the Redux middleware.
32597 *
32598 * Because middleware is potentially asynchronous, this should be the first
32599 * store enhancer in the composition chain.
32600 *
32601 * Note that each middleware will be given the `dispatch` and `getState` functions
32602 * as named arguments.
32603 *
32604 * @param {...Function} middlewares The middleware chain to be applied.
32605 * @returns {Function} A store enhancer applying the middleware.
32606 */
32607
32608 function applyMiddleware() {
32609 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
32610 middlewares[_key] = arguments[_key];
32611 }
32612
32613 return function (createStore) {
32614 return function () {
32615 var store = createStore.apply(void 0, arguments);
32616
32617 var _dispatch = function dispatch() {
32618 throw new Error( false ? 0 : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
32619 };
32620
32621 var middlewareAPI = {
32622 getState: store.getState,
32623 dispatch: function dispatch() {
32624 return _dispatch.apply(void 0, arguments);
32625 }
32626 };
32627 var chain = middlewares.map(function (middleware) {
32628 return middleware(middlewareAPI);
32629 });
32630 _dispatch = compose.apply(void 0, chain)(store.dispatch);
32631 return (0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])((0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])({}, store), {}, {
32632 dispatch: _dispatch
32633 });
32634 };
32635 };
32636 }
32637
32638
32639
32640
32641 /***/ }),
32642
32643 /***/ "../node_modules/reselect/es/defaultMemoize.js":
32644 /*!*****************************************************!*\
32645 !*** ../node_modules/reselect/es/defaultMemoize.js ***!
32646 \*****************************************************/
32647 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32648
32649 "use strict";
32650 __webpack_require__.r(__webpack_exports__);
32651 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32652 /* harmony export */ createCacheKeyComparator: () => (/* binding */ createCacheKeyComparator),
32653 /* harmony export */ defaultEqualityCheck: () => (/* binding */ defaultEqualityCheck),
32654 /* harmony export */ defaultMemoize: () => (/* binding */ defaultMemoize)
32655 /* harmony export */ });
32656 // Cache implementation based on Erik Rasmussen's `lru-memoize`:
32657 // https://github.com/erikras/lru-memoize
32658 var NOT_FOUND = 'NOT_FOUND';
32659
32660 function createSingletonCache(equals) {
32661 var entry;
32662 return {
32663 get: function get(key) {
32664 if (entry && equals(entry.key, key)) {
32665 return entry.value;
32666 }
32667
32668 return NOT_FOUND;
32669 },
32670 put: function put(key, value) {
32671 entry = {
32672 key: key,
32673 value: value
32674 };
32675 },
32676 getEntries: function getEntries() {
32677 return entry ? [entry] : [];
32678 },
32679 clear: function clear() {
32680 entry = undefined;
32681 }
32682 };
32683 }
32684
32685 function createLruCache(maxSize, equals) {
32686 var entries = [];
32687
32688 function get(key) {
32689 var cacheIndex = entries.findIndex(function (entry) {
32690 return equals(key, entry.key);
32691 }); // We found a cached entry
32692
32693 if (cacheIndex > -1) {
32694 var entry = entries[cacheIndex]; // Cached entry not at top of cache, move it to the top
32695
32696 if (cacheIndex > 0) {
32697 entries.splice(cacheIndex, 1);
32698 entries.unshift(entry);
32699 }
32700
32701 return entry.value;
32702 } // No entry found in cache, return sentinel
32703
32704
32705 return NOT_FOUND;
32706 }
32707
32708 function put(key, value) {
32709 if (get(key) === NOT_FOUND) {
32710 // TODO Is unshift slow?
32711 entries.unshift({
32712 key: key,
32713 value: value
32714 });
32715
32716 if (entries.length > maxSize) {
32717 entries.pop();
32718 }
32719 }
32720 }
32721
32722 function getEntries() {
32723 return entries;
32724 }
32725
32726 function clear() {
32727 entries = [];
32728 }
32729
32730 return {
32731 get: get,
32732 put: put,
32733 getEntries: getEntries,
32734 clear: clear
32735 };
32736 }
32737
32738 var defaultEqualityCheck = function defaultEqualityCheck(a, b) {
32739 return a === b;
32740 };
32741 function createCacheKeyComparator(equalityCheck) {
32742 return function areArgumentsShallowlyEqual(prev, next) {
32743 if (prev === null || next === null || prev.length !== next.length) {
32744 return false;
32745 } // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
32746
32747
32748 var length = prev.length;
32749
32750 for (var i = 0; i < length; i++) {
32751 if (!equalityCheck(prev[i], next[i])) {
32752 return false;
32753 }
32754 }
32755
32756 return true;
32757 };
32758 }
32759 // defaultMemoize now supports a configurable cache size with LRU behavior,
32760 // and optional comparison of the result value with existing values
32761 function defaultMemoize(func, equalityCheckOrOptions) {
32762 var providedOptions = typeof equalityCheckOrOptions === 'object' ? equalityCheckOrOptions : {
32763 equalityCheck: equalityCheckOrOptions
32764 };
32765 var _providedOptions$equa = providedOptions.equalityCheck,
32766 equalityCheck = _providedOptions$equa === void 0 ? defaultEqualityCheck : _providedOptions$equa,
32767 _providedOptions$maxS = providedOptions.maxSize,
32768 maxSize = _providedOptions$maxS === void 0 ? 1 : _providedOptions$maxS,
32769 resultEqualityCheck = providedOptions.resultEqualityCheck;
32770 var comparator = createCacheKeyComparator(equalityCheck);
32771 var cache = maxSize === 1 ? createSingletonCache(comparator) : createLruCache(maxSize, comparator); // we reference arguments instead of spreading them for performance reasons
32772
32773 function memoized() {
32774 var value = cache.get(arguments);
32775
32776 if (value === NOT_FOUND) {
32777 // @ts-ignore
32778 value = func.apply(null, arguments);
32779
32780 if (resultEqualityCheck) {
32781 var entries = cache.getEntries();
32782 var matchingEntry = entries.find(function (entry) {
32783 return resultEqualityCheck(entry.value, value);
32784 });
32785
32786 if (matchingEntry) {
32787 value = matchingEntry.value;
32788 }
32789 }
32790
32791 cache.put(arguments, value);
32792 }
32793
32794 return value;
32795 }
32796
32797 memoized.clearCache = function () {
32798 return cache.clear();
32799 };
32800
32801 return memoized;
32802 }
32803
32804 /***/ }),
32805
32806 /***/ "../node_modules/reselect/es/index.js":
32807 /*!********************************************!*\
32808 !*** ../node_modules/reselect/es/index.js ***!
32809 \********************************************/
32810 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32811
32812 "use strict";
32813 __webpack_require__.r(__webpack_exports__);
32814 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32815 /* harmony export */ createSelector: () => (/* binding */ createSelector),
32816 /* harmony export */ createSelectorCreator: () => (/* binding */ createSelectorCreator),
32817 /* harmony export */ createStructuredSelector: () => (/* binding */ createStructuredSelector),
32818 /* harmony export */ defaultEqualityCheck: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultEqualityCheck),
32819 /* harmony export */ defaultMemoize: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize)
32820 /* harmony export */ });
32821 /* harmony import */ var _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultMemoize */ "../node_modules/reselect/es/defaultMemoize.js");
32822
32823
32824
32825 function getDependencies(funcs) {
32826 var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
32827
32828 if (!dependencies.every(function (dep) {
32829 return typeof dep === 'function';
32830 })) {
32831 var dependencyTypes = dependencies.map(function (dep) {
32832 return typeof dep === 'function' ? "function " + (dep.name || 'unnamed') + "()" : typeof dep;
32833 }).join(', ');
32834 throw new Error("createSelector expects all input-selectors to be functions, but received the following types: [" + dependencyTypes + "]");
32835 }
32836
32837 return dependencies;
32838 }
32839
32840 function createSelectorCreator(memoize) {
32841 for (var _len = arguments.length, memoizeOptionsFromArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
32842 memoizeOptionsFromArgs[_key - 1] = arguments[_key];
32843 }
32844
32845 var createSelector = function createSelector() {
32846 for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
32847 funcs[_key2] = arguments[_key2];
32848 }
32849
32850 var _recomputations = 0;
32851
32852 var _lastResult; // Due to the intricacies of rest params, we can't do an optional arg after `...funcs`.
32853 // So, start by declaring the default value here.
32854 // (And yes, the words 'memoize' and 'options' appear too many times in this next sequence.)
32855
32856
32857 var directlyPassedOptions = {
32858 memoizeOptions: undefined
32859 }; // Normally, the result func or "output selector" is the last arg
32860
32861 var resultFunc = funcs.pop(); // If the result func is actually an _object_, assume it's our options object
32862
32863 if (typeof resultFunc === 'object') {
32864 directlyPassedOptions = resultFunc; // and pop the real result func off
32865
32866 resultFunc = funcs.pop();
32867 }
32868
32869 if (typeof resultFunc !== 'function') {
32870 throw new Error("createSelector expects an output function after the inputs, but received: [" + typeof resultFunc + "]");
32871 } // Determine which set of options we're using. Prefer options passed directly,
32872 // but fall back to options given to createSelectorCreator.
32873
32874
32875 var _directlyPassedOption = directlyPassedOptions,
32876 _directlyPassedOption2 = _directlyPassedOption.memoizeOptions,
32877 memoizeOptions = _directlyPassedOption2 === void 0 ? memoizeOptionsFromArgs : _directlyPassedOption2; // Simplifying assumption: it's unlikely that the first options arg of the provided memoizer
32878 // is an array. In most libs I've looked at, it's an equality function or options object.
32879 // Based on that, if `memoizeOptions` _is_ an array, we assume it's a full
32880 // user-provided array of options. Otherwise, it must be just the _first_ arg, and so
32881 // we wrap it in an array so we can apply it.
32882
32883 var finalMemoizeOptions = Array.isArray(memoizeOptions) ? memoizeOptions : [memoizeOptions];
32884 var dependencies = getDependencies(funcs);
32885 var memoizedResultFunc = memoize.apply(void 0, [function recomputationWrapper() {
32886 _recomputations++; // apply arguments instead of spreading for performance.
32887
32888 return resultFunc.apply(null, arguments);
32889 }].concat(finalMemoizeOptions)); // If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
32890
32891 var selector = memoize(function dependenciesChecker() {
32892 var params = [];
32893 var length = dependencies.length;
32894
32895 for (var i = 0; i < length; i++) {
32896 // apply arguments instead of spreading and mutate a local list of params for performance.
32897 // @ts-ignore
32898 params.push(dependencies[i].apply(null, arguments));
32899 } // apply arguments instead of spreading for performance.
32900
32901
32902 _lastResult = memoizedResultFunc.apply(null, params);
32903 return _lastResult;
32904 });
32905 Object.assign(selector, {
32906 resultFunc: resultFunc,
32907 memoizedResultFunc: memoizedResultFunc,
32908 dependencies: dependencies,
32909 lastResult: function lastResult() {
32910 return _lastResult;
32911 },
32912 recomputations: function recomputations() {
32913 return _recomputations;
32914 },
32915 resetRecomputations: function resetRecomputations() {
32916 return _recomputations = 0;
32917 }
32918 });
32919 return selector;
32920 }; // @ts-ignore
32921
32922
32923 return createSelector;
32924 }
32925 var createSelector = /* #__PURE__ */createSelectorCreator(_defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize);
32926 // Manual definition of state and output arguments
32927 var createStructuredSelector = function createStructuredSelector(selectors, selectorCreator) {
32928 if (selectorCreator === void 0) {
32929 selectorCreator = createSelector;
32930 }
32931
32932 if (typeof selectors !== 'object') {
32933 throw new Error('createStructuredSelector expects first argument to be an object ' + ("where each property is a selector, instead received a " + typeof selectors));
32934 }
32935
32936 var objectKeys = Object.keys(selectors);
32937 var resultSelector = selectorCreator( // @ts-ignore
32938 objectKeys.map(function (key) {
32939 return selectors[key];
32940 }), function () {
32941 for (var _len3 = arguments.length, values = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
32942 values[_key3] = arguments[_key3];
32943 }
32944
32945 return values.reduce(function (composition, value, index) {
32946 composition[objectKeys[index]] = value;
32947 return composition;
32948 }, {});
32949 });
32950 return resultSelector;
32951 };
32952
32953 /***/ }),
32954
32955 /***/ "@wordpress/i18n":
32956 /*!**************************!*\
32957 !*** external "wp.i18n" ***!
32958 \**************************/
32959 /***/ ((module) => {
32960
32961 "use strict";
32962 module.exports = wp.i18n;
32963
32964 /***/ })
32965
32966 /******/ });
32967 /************************************************************************/
32968 /******/ // The module cache
32969 /******/ var __webpack_module_cache__ = {};
32970 /******/
32971 /******/ // The require function
32972 /******/ function __webpack_require__(moduleId) {
32973 /******/ // Check if module is in cache
32974 /******/ var cachedModule = __webpack_module_cache__[moduleId];
32975 /******/ if (cachedModule !== undefined) {
32976 /******/ return cachedModule.exports;
32977 /******/ }
32978 /******/ // Create a new module (and put it into the cache)
32979 /******/ var module = __webpack_module_cache__[moduleId] = {
32980 /******/ // no module.id needed
32981 /******/ // no module.loaded needed
32982 /******/ exports: {}
32983 /******/ };
32984 /******/
32985 /******/ // Execute the module function
32986 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
32987 /******/
32988 /******/ // Return the exports of the module
32989 /******/ return module.exports;
32990 /******/ }
32991 /******/
32992 /************************************************************************/
32993 /******/ /* webpack/runtime/define property getters */
32994 /******/ (() => {
32995 /******/ // define getter functions for harmony exports
32996 /******/ __webpack_require__.d = (exports, definition) => {
32997 /******/ for(var key in definition) {
32998 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
32999 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
33000 /******/ }
33001 /******/ }
33002 /******/ };
33003 /******/ })();
33004 /******/
33005 /******/ /* webpack/runtime/global */
33006 /******/ (() => {
33007 /******/ __webpack_require__.g = (function() {
33008 /******/ if (typeof globalThis === 'object') return globalThis;
33009 /******/ try {
33010 /******/ return this || new Function('return this')();
33011 /******/ } catch (e) {
33012 /******/ if (typeof window === 'object') return window;
33013 /******/ }
33014 /******/ })();
33015 /******/ })();
33016 /******/
33017 /******/ /* webpack/runtime/hasOwnProperty shorthand */
33018 /******/ (() => {
33019 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
33020 /******/ })();
33021 /******/
33022 /******/ /* webpack/runtime/make namespace object */
33023 /******/ (() => {
33024 /******/ // define __esModule on exports
33025 /******/ __webpack_require__.r = (exports) => {
33026 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
33027 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
33028 /******/ }
33029 /******/ Object.defineProperty(exports, '__esModule', { value: true });
33030 /******/ };
33031 /******/ })();
33032 /******/
33033 /************************************************************************/
33034 var __webpack_exports__ = {};
33035 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
33036 (() => {
33037 "use strict";
33038 /*!******************************************!*\
33039 !*** ../core/common/assets/js/common.js ***!
33040 \******************************************/
33041
33042
33043 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
33044 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
33045 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
33046 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
33047 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
33048 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
33049 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
33050 var _helpers = _interopRequireDefault(__webpack_require__(/*! ./utils/helpers */ "../core/common/assets/js/utils/helpers.js"));
33051 var _storage = _interopRequireDefault(__webpack_require__(/*! ./utils/storage */ "../core/common/assets/js/utils/storage.js"));
33052 var _debug = _interopRequireDefault(__webpack_require__(/*! ./utils/debug */ "../core/common/assets/js/utils/debug.js"));
33053 var _ajax = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/ajax/assets/js/ajax */ "../core/common/modules/ajax/assets/js/ajax.js"));
33054 var _finder = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/finder/assets/js/finder */ "../core/common/modules/finder/assets/js/finder.js"));
33055 var _connect = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/connect/assets/js/connect */ "../core/common/modules/connect/assets/js/connect.js"));
33056 var _component = _interopRequireDefault(__webpack_require__(/*! ./components/wordpress/component */ "../core/common/assets/js/components/wordpress/component.js"));
33057 var _component2 = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/data/component */ "../core/common/modules/event-tracker/assets/js/data/component.js"));
33058 var _events = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/events */ "../core/common/modules/event-tracker/assets/js/events.js"));
33059 var _module = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/events-manager/assets/js/module */ "../core/common/modules/events-manager/assets/js/module.js"));
33060 var _notifications = _interopRequireDefault(__webpack_require__(/*! elementor-utils/notifications */ "../assets/dev/js/utils/notifications.js"));
33061 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)); }
33062 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
33063 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; }
33064 var ElementorCommonApp = /*#__PURE__*/function (_elementorModules$Vie) {
33065 function ElementorCommonApp() {
33066 (0, _classCallCheck2.default)(this, ElementorCommonApp);
33067 return _callSuper(this, ElementorCommonApp, arguments);
33068 }
33069 (0, _inherits2.default)(ElementorCommonApp, _elementorModules$Vie);
33070 return (0, _createClass2.default)(ElementorCommonApp, [{
33071 key: "setMarionetteTemplateCompiler",
33072 value: function setMarionetteTemplateCompiler() {
33073 Marionette.TemplateCache.prototype.compileTemplate = function (rawTemplate, options) {
33074 options = {
33075 evaluate: /<#([\s\S]+?)#>/g,
33076 interpolate: /{{{([\s\S]+?)}}}/g,
33077 escape: /{{([^}]+?)}}(?!})/g
33078 };
33079 return _.template(rawTemplate, options);
33080 };
33081 }
33082 }, {
33083 key: "getDefaultElements",
33084 value: function getDefaultElements() {
33085 return {
33086 $window: jQuery(window),
33087 $document: jQuery(document),
33088 $body: jQuery(document.body)
33089 };
33090 }
33091 }, {
33092 key: "initComponents",
33093 value: function initComponents() {
33094 this.events = new _events.default();
33095 this.eventsManager = new _module.default();
33096 this.debug = new _debug.default();
33097 this.helpers = new _helpers.default();
33098 this.storage = new _storage.default();
33099 this.dialogsManager = new DialogsManager.Instance();
33100 this.notifications = new _notifications.default();
33101 this.api = window.$e;
33102 $e.components.register(new _component2.default());
33103 elementorCommon.elements.$window.on('elementor:init-components', function () {
33104 $e.components.register(new _component.default());
33105 });
33106 this.initModules();
33107 }
33108 }, {
33109 key: "initModules",
33110 value: function initModules() {
33111 var _this = this;
33112 var activeModules = this.config.activeModules;
33113 var modules = {
33114 ajax: _ajax.default,
33115 finder: _finder.default,
33116 connect: _connect.default
33117 };
33118 activeModules.forEach(function (name) {
33119 if (modules[name]) {
33120 _this[name] = new modules[name](_this.config[name]);
33121 }
33122 });
33123 }
33124 }, {
33125 key: "compileArrayTemplateArgs",
33126 value: function compileArrayTemplateArgs(template, templateArgs) {
33127 return template.replace(/%(?:(\d+)\$)?s/g, function (match, number) {
33128 if (!number) {
33129 number = 1;
33130 }
33131 number--;
33132 return undefined !== templateArgs[number] ? templateArgs[number] : match;
33133 });
33134 }
33135 }, {
33136 key: "compileObjectTemplateArgs",
33137 value: function compileObjectTemplateArgs(template, templateArgs) {
33138 return template.replace(/{{(?:([ \w]+))}}/g, function (match, name) {
33139 return templateArgs[name] ? templateArgs[name] : match;
33140 });
33141 }
33142 }, {
33143 key: "compileTemplate",
33144 value: function compileTemplate(template, templateArgs) {
33145 return jQuery.isPlainObject(templateArgs) ? this.compileObjectTemplateArgs(template, templateArgs) : this.compileArrayTemplateArgs(template, templateArgs);
33146 }
33147 }, {
33148 key: "translate",
33149 value: function translate(stringKey, context, templateArgs, i18nStack) {
33150 if (context) {
33151 i18nStack = this.config[context].i18n;
33152 }
33153 if (!i18nStack) {
33154 i18nStack = this.config.i18n;
33155 }
33156 var string = i18nStack[stringKey];
33157 if (undefined === string) {
33158 string = stringKey;
33159 }
33160 if (templateArgs) {
33161 string = this.compileTemplate(string, templateArgs);
33162 }
33163 return string;
33164 }
33165 }, {
33166 key: "onInit",
33167 value: function onInit() {
33168 _superPropGet(ElementorCommonApp, "onInit", this, 3)([]);
33169 this.config = elementorCommonConfig;
33170 this.setMarionetteTemplateCompiler();
33171 }
33172 }]);
33173 }(elementorModules.ViewModule);
33174 window.elementorCommon = new ElementorCommonApp();
33175 elementorCommon.initComponents();
33176 })();
33177
33178 /******/ })()
33179 ;
33180 //# sourceMappingURL=common.js.map