PluginProbe
Elementor Website Builder – more than just a page builder / 3.34.0-beta1
Elementor Website Builder – more than just a page builder v3.34.0-beta1
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 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 All 457 releases
elementor / assets / js / common.js

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

33,163 lines 1.3 MB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "../assets/dev/js/editor/utils/files-upload-handler.js":
5 /*!*************************************************************!*\
6 !*** ../assets/dev/js/editor/utils/files-upload-handler.js ***!
7 \*************************************************************/
8 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
9
10 "use strict";
11 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
12
13
14 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
15 Object.defineProperty(exports, "__esModule", ({
16 value: true
17 }));
18 exports["default"] = void 0;
19 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
20 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
21 var FilesUploadHandler = exports["default"] = /*#__PURE__*/function () {
22 function FilesUploadHandler() {
23 (0, _classCallCheck2.default)(this, FilesUploadHandler);
24 }
25 return (0, _createClass2.default)(FilesUploadHandler, null, [{
26 key: "isUploadEnabled",
27 value: function isUploadEnabled(mediaType) {
28 var unfilteredFilesTypes = ['svg', 'application/json'];
29 if (!unfilteredFilesTypes.includes(mediaType)) {
30 return true;
31 }
32 return elementorCommon.config.filesUpload.unfilteredFiles;
33 }
34 }, {
35 key: "setUploadTypeCaller",
36 value: function setUploadTypeCaller(frame) {
37 frame.uploader.uploader.param('uploadTypeCaller', 'elementor-wp-media-upload');
38 }
39 }, {
40 key: "getUnfilteredFilesNonAdminDialog",
41 value: function getUnfilteredFilesNonAdminDialog() {
42 return elementorCommon.dialogsManager.createWidget('alert', {
43 id: 'e-unfiltered-files-disabled-dialog',
44 headerMessage: __('Sorry, you can\'t upload that file yet', 'elementor'),
45 message: __('This is because JSON files may pose a security risk.', 'elementor') + '<br><br>' + __('To upload them anyway, ask the site administrator to enable unfiltered file uploads.', 'elementor'),
46 strings: {
47 confirm: __('Got it', 'elementor')
48 }
49 });
50 }
51 }, {
52 key: "getUnfilteredFilesNotEnabledDialog",
53 value: function getUnfilteredFilesNotEnabledDialog(callback) {
54 var elementorInstance = window.elementorAdmin || window.elementor;
55 if (!elementorInstance.config.user.is_administrator) {
56 return this.getUnfilteredFilesNonAdminDialog();
57 }
58 var onConfirm = function onConfirm() {
59 elementorCommon.ajax.addRequest('enable_unfiltered_files_upload', {}, true);
60 elementorCommon.config.filesUpload.unfilteredFiles = true;
61 callback();
62 };
63 return elementorInstance.helpers.getSimpleDialog('e-enable-unfiltered-files-dialog', __('Enable Unfiltered File Uploads', 'elementor'), __('Before you enable unfiltered files upload, note that such files include a security risk. Elementor does run a process to remove possible malicious code, but there is still risk involved when using such files.', 'elementor'), __('Enable', 'elementor'), onConfirm);
64 }
65 }, {
66 key: "getUnfilteredFilesNotEnabledImportTemplateDialog",
67 value: function getUnfilteredFilesNotEnabledImportTemplateDialog(callback) {
68 if (!(window.elementorAdmin || window.elementor).config.user.is_administrator) {
69 return this.getUnfilteredFilesNonAdminDialog();
70 }
71 return elementorCommon.dialogsManager.createWidget('confirm', {
72 id: 'e-enable-unfiltered-files-dialog-import-template',
73 headerMessage: __('Enable Unfiltered File Uploads', 'elementor'),
74 message: __('Before you enable unfiltered files upload, note that such files include a security risk. Elementor does run a process to remove possible malicious code, but there is still risk involved when using such files.', 'elementor') + '<br /><br />' + __('If you do not enable uploading unfiltered files, any SVG or JSON (including lottie) files used in the uploaded template will not be imported.', 'elementor'),
75 position: {
76 my: 'center center',
77 at: 'center center'
78 },
79 strings: {
80 confirm: __('Enable and Import', 'elementor'),
81 cancel: __('Import Without Enabling', 'elementor')
82 },
83 onConfirm: function onConfirm() {
84 elementorCommon.ajax.addRequest('enable_unfiltered_files_upload', {
85 success: function success() {
86 // This utility is used in both the admin and the Editor.
87 elementorCommon.config.filesUpload.unfilteredFiles = true;
88 callback();
89 }
90 }, true);
91 },
92 onCancel: function onCancel() {
93 return callback();
94 }
95 });
96 }
97 }]);
98 }();
99
100 /***/ }),
101
102 /***/ "../assets/dev/js/editor/utils/is-instanceof.js":
103 /*!******************************************************!*\
104 !*** ../assets/dev/js/editor/utils/is-instanceof.js ***!
105 \******************************************************/
106 /***/ ((__unused_webpack_module, exports) => {
107
108 "use strict";
109
110
111 Object.defineProperty(exports, "__esModule", ({
112 value: true
113 }));
114 exports["default"] = void 0;
115 function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
116 function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
117 function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
118 /**
119 * Some FileAPI objects such as FileList, DataTransferItem and DataTransferItemList has inconsistency with the retrieved
120 * object (from events, etc.) and the actual JavaScript object so a regular instanceof doesn't work. This function can
121 * check whether it's instanceof by using the objects constructor and prototype names.
122 *
123 * @param object
124 * @param constructors
125 * @return {boolean}
126 */
127 var _default = exports["default"] = function _default(object, constructors) {
128 constructors = Array.isArray(constructors) ? constructors : [constructors];
129 var _iterator = _createForOfIteratorHelper(constructors),
130 _step;
131 try {
132 for (_iterator.s(); !(_step = _iterator.n()).done;) {
133 var constructor = _step.value;
134 if (object.constructor.name === constructor.prototype[Symbol.toStringTag]) {
135 return true;
136 }
137 }
138 } catch (err) {
139 _iterator.e(err);
140 } finally {
141 _iterator.f();
142 }
143 return false;
144 };
145
146 /***/ }),
147
148 /***/ "../assets/dev/js/modules/imports/args-object.js":
149 /*!*******************************************************!*\
150 !*** ../assets/dev/js/modules/imports/args-object.js ***!
151 \*******************************************************/
152 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
153
154 "use strict";
155
156
157 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
158 Object.defineProperty(exports, "__esModule", ({
159 value: true
160 }));
161 exports["default"] = void 0;
162 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
163 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
164 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
165 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
166 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
167 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
168 var _instanceType = _interopRequireDefault(__webpack_require__(/*! ./instance-type */ "../assets/dev/js/modules/imports/instance-type.js"));
169 var _isInstanceof = _interopRequireDefault(__webpack_require__(/*! ../../editor/utils/is-instanceof */ "../assets/dev/js/editor/utils/is-instanceof.js"));
170 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
171 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
172 var ArgsObject = exports["default"] = /*#__PURE__*/function (_InstanceType) {
173 /**
174 * Function constructor().
175 *
176 * Create ArgsObject.
177 *
178 * @param {{}} args
179 */
180 function ArgsObject(args) {
181 var _this;
182 (0, _classCallCheck2.default)(this, ArgsObject);
183 _this = _callSuper(this, ArgsObject);
184 _this.args = args;
185 return _this;
186 }
187
188 /**
189 * Function requireArgument().
190 *
191 * Validate property in args.
192 *
193 * @param {string} property
194 * @param {{}} args
195 *
196 * @throws {Error}
197 */
198 (0, _inherits2.default)(ArgsObject, _InstanceType);
199 return (0, _createClass2.default)(ArgsObject, [{
200 key: "requireArgument",
201 value: function requireArgument(property) {
202 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.args;
203 if (!Object.prototype.hasOwnProperty.call(args, property)) {
204 throw Error("".concat(property, " is required."));
205 }
206 }
207
208 /**
209 * Function requireArgumentType().
210 *
211 * Validate property in args using `type === typeof(args.whatever)`.
212 *
213 * @param {string} property
214 * @param {string} type
215 * @param {{}} args
216 *
217 * @throws {Error}
218 */
219 }, {
220 key: "requireArgumentType",
221 value: function requireArgumentType(property, type) {
222 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
223 this.requireArgument(property, args);
224 if ((0, _typeof2.default)(args[property]) !== type) {
225 throw Error("".concat(property, " invalid type: ").concat(type, "."));
226 }
227 }
228
229 /**
230 * Function requireArgumentInstance().
231 *
232 * Validate property in args using `args.whatever instanceof instance`.
233 *
234 * @param {string} property
235 * @param {*} instance
236 * @param {{}} args
237 *
238 * @throws {Error}
239 */
240 }, {
241 key: "requireArgumentInstance",
242 value: function requireArgumentInstance(property, instance) {
243 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
244 this.requireArgument(property, args);
245 if (!(args[property] instanceof instance) && !(0, _isInstanceof.default)(args[property], instance)) {
246 throw Error("".concat(property, " invalid instance."));
247 }
248 }
249
250 /**
251 * Function requireArgumentConstructor().
252 *
253 * Validate property in args using `type === args.whatever.constructor`.
254 *
255 * @param {string} property
256 * @param {*} type
257 * @param {{}} args
258 *
259 * @throws {Error}
260 */
261 }, {
262 key: "requireArgumentConstructor",
263 value: function requireArgumentConstructor(property, type) {
264 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
265 this.requireArgument(property, args);
266
267 // Note: Converting the constructor to string in order to avoid equation issues
268 // due to different memory addresses between iframes (window.Object !== window.top.Object).
269 if (args[property].constructor.toString() !== type.prototype.constructor.toString()) {
270 throw Error("".concat(property, " invalid constructor type."));
271 }
272 }
273 }], [{
274 key: "getInstanceType",
275 value: function getInstanceType() {
276 return 'ArgsObject';
277 }
278 }]);
279 }(_instanceType.default);
280
281 /***/ }),
282
283 /***/ "../assets/dev/js/modules/imports/instance-type.js":
284 /*!*********************************************************!*\
285 !*** ../assets/dev/js/modules/imports/instance-type.js ***!
286 \*********************************************************/
287 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
288
289 "use strict";
290
291
292 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
293 Object.defineProperty(exports, "__esModule", ({
294 value: true
295 }));
296 exports["default"] = void 0;
297 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
298 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
299 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
300 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
301 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
302 var InstanceType = exports["default"] = /*#__PURE__*/function () {
303 function InstanceType() {
304 var _this = this;
305 (0, _classCallCheck2.default)(this, InstanceType);
306 // Since anonymous classes sometimes do not get validated by babel, do it manually.
307 var target = this instanceof InstanceType ? this.constructor : void 0;
308 var prototypes = [];
309 while (target.__proto__ && target.__proto__.name) {
310 prototypes.push(target.__proto__);
311 target = target.__proto__;
312 }
313 prototypes.reverse().forEach(function (proto) {
314 return _this instanceof proto;
315 });
316 }
317 return (0, _createClass2.default)(InstanceType, null, [{
318 key: Symbol.hasInstance,
319 value: function value(target) {
320 /**
321 * This is function extending being called each time JS uses instanceOf, since babel use it each time it create new class
322 * its give's opportunity to mange capabilities of instanceOf operator.
323 * saving current class each time will give option later to handle instanceOf manually.
324 */
325 var result = _superPropGet(InstanceType, Symbol.hasInstance, this, 2)([target]);
326
327 // Act normal when validate a class, which does not have instance type.
328 if (target && !target.constructor.getInstanceType) {
329 return result;
330 }
331 if (target) {
332 if (!target.instanceTypes) {
333 target.instanceTypes = [];
334 }
335 if (!result) {
336 if (this.getInstanceType() === target.constructor.getInstanceType()) {
337 result = true;
338 }
339 }
340 if (result) {
341 var name = this.getInstanceType === InstanceType.getInstanceType ? 'BaseInstanceType' : this.getInstanceType();
342 if (-1 === target.instanceTypes.indexOf(name)) {
343 target.instanceTypes.push(name);
344 }
345 }
346 }
347 if (!result && target) {
348 // Check if the given 'target', is instance of known types.
349 result = target.instanceTypes && Array.isArray(target.instanceTypes) && -1 !== target.instanceTypes.indexOf(this.getInstanceType());
350 }
351 return result;
352 }
353 }, {
354 key: "getInstanceType",
355 value: function getInstanceType() {
356 elementorModules.ForceMethodImplementation();
357 }
358 }]);
359 }();
360
361 /***/ }),
362
363 /***/ "../assets/dev/js/modules/imports/module.js":
364 /*!**************************************************!*\
365 !*** ../assets/dev/js/modules/imports/module.js ***!
366 \**************************************************/
367 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
368
369 "use strict";
370
371
372 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
373 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
374 var Module = function Module() {
375 var $ = jQuery,
376 instanceParams = arguments,
377 self = this,
378 events = {};
379 var settings;
380 var ensureClosureMethods = function ensureClosureMethods() {
381 $.each(self, function (methodName) {
382 var oldMethod = self[methodName];
383 if ('function' !== typeof oldMethod) {
384 return;
385 }
386 self[methodName] = function () {
387 return oldMethod.apply(self, arguments);
388 };
389 });
390 };
391 var initSettings = function initSettings() {
392 settings = self.getDefaultSettings();
393 var instanceSettings = instanceParams[0];
394 if (instanceSettings) {
395 $.extend(true, settings, instanceSettings);
396 }
397 };
398 var init = function init() {
399 self.__construct.apply(self, instanceParams);
400 ensureClosureMethods();
401 initSettings();
402 self.trigger('init');
403 };
404 this.getItems = function (items, itemKey) {
405 if (itemKey) {
406 var keyStack = itemKey.split('.'),
407 currentKey = keyStack.splice(0, 1);
408 if (!keyStack.length) {
409 return items[currentKey];
410 }
411 if (!items[currentKey]) {
412 return;
413 }
414 return this.getItems(items[currentKey], keyStack.join('.'));
415 }
416 return items;
417 };
418 this.getSettings = function (setting) {
419 return this.getItems(settings, setting);
420 };
421 this.setSettings = function (settingKey, value, settingsContainer) {
422 if (!settingsContainer) {
423 settingsContainer = settings;
424 }
425 if ('object' === (0, _typeof2.default)(settingKey)) {
426 $.extend(settingsContainer, settingKey);
427 return self;
428 }
429 var keyStack = settingKey.split('.'),
430 currentKey = keyStack.splice(0, 1);
431 if (!keyStack.length) {
432 settingsContainer[currentKey] = value;
433 return self;
434 }
435 if (!settingsContainer[currentKey]) {
436 settingsContainer[currentKey] = {};
437 }
438 return self.setSettings(keyStack.join('.'), value, settingsContainer[currentKey]);
439 };
440 this.getErrorMessage = function (type, functionName) {
441 var message;
442 switch (type) {
443 case 'forceMethodImplementation':
444 message = "The method '".concat(functionName, "' must to be implemented in the inheritor child.");
445 break;
446 default:
447 message = 'An error occurs';
448 }
449 return message;
450 };
451
452 // TODO: This function should be deleted ?.
453 this.forceMethodImplementation = function (functionName) {
454 throw new Error(this.getErrorMessage('forceMethodImplementation', functionName));
455 };
456 this.on = function (eventName, callback) {
457 if ('object' === (0, _typeof2.default)(eventName)) {
458 $.each(eventName, function (singleEventName) {
459 self.on(singleEventName, this);
460 });
461 return self;
462 }
463 var eventNames = eventName.split(' ');
464 eventNames.forEach(function (singleEventName) {
465 if (!events[singleEventName]) {
466 events[singleEventName] = [];
467 }
468 events[singleEventName].push(callback);
469 });
470 return self;
471 };
472 this.off = function (eventName, callback) {
473 if (!events[eventName]) {
474 return self;
475 }
476 if (!callback) {
477 delete events[eventName];
478 return self;
479 }
480 var callbackIndex = events[eventName].indexOf(callback);
481 if (-1 !== callbackIndex) {
482 delete events[eventName][callbackIndex];
483
484 // Reset array index (for next off on same event).
485 events[eventName] = events[eventName].filter(function (val) {
486 return val;
487 });
488 }
489 return self;
490 };
491 this.trigger = function (eventName) {
492 var methodName = 'on' + eventName[0].toUpperCase() + eventName.slice(1),
493 params = Array.prototype.slice.call(arguments, 1);
494 if (self[methodName]) {
495 self[methodName].apply(self, params);
496 }
497 var callbacks = events[eventName];
498 if (!callbacks) {
499 return self;
500 }
501 $.each(callbacks, function (index, callback) {
502 callback.apply(self, params);
503 });
504 return self;
505 };
506 init();
507 };
508 Module.prototype.__construct = function () {};
509 Module.prototype.getDefaultSettings = function () {
510 return {};
511 };
512 Module.prototype.getConstructorID = function () {
513 return this.constructor.name;
514 };
515 Module.extend = function (properties) {
516 var $ = jQuery,
517 parent = this;
518 var child = function child() {
519 return parent.apply(this, arguments);
520 };
521 $.extend(child, parent);
522 child.prototype = Object.create($.extend({}, parent.prototype, properties));
523 child.prototype.constructor = child;
524 child.__super__ = parent.prototype;
525 return child;
526 };
527 module.exports = Module;
528
529 /***/ }),
530
531 /***/ "../assets/dev/js/utils/notifications.js":
532 /*!***********************************************!*\
533 !*** ../assets/dev/js/utils/notifications.js ***!
534 \***********************************************/
535 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
536
537 "use strict";
538
539
540 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
541 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
542 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
543 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
544 module.exports = elementorModules.Module.extend({
545 initToast: function initToast() {
546 var toast = elementorCommon.dialogsManager.createWidget('buttons', {
547 id: 'elementor-toast',
548 position: {
549 my: 'center bottom',
550 at: 'center bottom-10',
551 of: '#elementor-panel-inner',
552 autoRefresh: true
553 },
554 hide: {
555 onClick: true,
556 auto: true,
557 autoDelay: 10000
558 },
559 effects: {
560 show: function show() {
561 var $widget = toast.getElements('widget');
562 $widget.show();
563 toast.refreshPosition();
564 var top = parseInt($widget.css('top'), 10);
565 $widget.hide().css('top', top + 100);
566 $widget.animate({
567 opacity: 'show',
568 height: 'show',
569 paddingBottom: 'show',
570 paddingTop: 'show',
571 top: top
572 }, {
573 easing: 'linear',
574 duration: 300
575 });
576 },
577 hide: function hide() {
578 var $widget = toast.getElements('widget'),
579 top = parseInt($widget.css('top'), 10);
580 $widget.animate({
581 opacity: 'hide',
582 height: 'hide',
583 paddingBottom: 'hide',
584 paddingTop: 'hide',
585 top: top + 100
586 }, {
587 easing: 'linear',
588 duration: 300
589 });
590 }
591 },
592 button: {
593 tag: 'div'
594 }
595 });
596 this.getToast = function () {
597 return toast;
598 };
599 },
600 showToast: function showToast(options) {
601 var toast = this.getToast();
602 toast.setMessage(options.message);
603 toast.getElements('buttonsWrapper').empty();
604 var isPositionValid = this.isPositionValid(options === null || options === void 0 ? void 0 : options.position);
605 if (!isPositionValid) {
606 this.positionToWindow();
607 }
608 if (options !== null && options !== void 0 && options.position && isPositionValid) {
609 toast.setSettings('position', options.position);
610 }
611 if (options.buttons) {
612 options.buttons.forEach(function (button) {
613 toast.addButton(button);
614 });
615 }
616 if (options.classes) {
617 toast.getElements('widget').addClass(options.classes);
618 }
619 if (options.sticky) {
620 toast.setSettings({
621 hide: {
622 auto: false,
623 onClick: false
624 }
625 });
626 }
627 return toast.show();
628 },
629 isPositionValid: function isPositionValid(position) {
630 var _position$of;
631 var positionToCheck = (_position$of = position === null || position === void 0 ? void 0 : position.of) !== null && _position$of !== void 0 ? _position$of : this.getToast().getSettings('position').of;
632 if (!positionToCheck) {
633 return false;
634 }
635 return !!document.querySelector(positionToCheck);
636 },
637 positionToWindow: function positionToWindow() {
638 var toast = this.getToast();
639 var position = _objectSpread(_objectSpread({}, toast.getSettings('position')), {}, {
640 my: 'right top',
641 at: 'right-10 top+42',
642 // 42px is the default admin bar height + 10px
643 of: ''
644 });
645 toast.setSettings('position', position);
646 toast.getElements('widget').addClass('dialog-position-window');
647 },
648 onInit: function onInit() {
649 this.initToast();
650 }
651 });
652
653 /***/ }),
654
655 /***/ "../assets/dev/js/utils/tiers.js":
656 /*!***************************************!*\
657 !*** ../assets/dev/js/utils/tiers.js ***!
658 \***************************************/
659 /***/ ((__unused_webpack_module, exports) => {
660
661 "use strict";
662
663
664 Object.defineProperty(exports, "__esModule", ({
665 value: true
666 }));
667 exports.isTierAtLeast = exports.TIERS_PRIORITY = exports.TIERS = void 0;
668 var TIERS_PRIORITY = exports.TIERS_PRIORITY = Object.freeze(['free', 'essential', 'essential-oct2023', 'advanced', 'expert', 'agency']);
669
670 /**
671 * @type {Readonly<{
672 * free: string;
673 * essential: string;
674 * 'essential-oct2023': string;
675 * advanced: string;
676 * expert: string;
677 * agency: string;
678 * }>}
679 */
680 var TIERS = exports.TIERS = Object.freeze(TIERS_PRIORITY.reduce(function (acc, tier) {
681 acc[tier] = tier;
682 return acc;
683 }, {}));
684 var isTierAtLeast = exports.isTierAtLeast = function isTierAtLeast(currentTier, expectedTier) {
685 var currentTierIndex = TIERS_PRIORITY.indexOf(currentTier);
686 var expectedTierIndex = TIERS_PRIORITY.indexOf(expectedTier);
687 if (-1 === currentTierIndex || -1 === expectedTierIndex) {
688 return false;
689 }
690 return currentTierIndex >= expectedTierIndex;
691 };
692
693 /***/ }),
694
695 /***/ "../assets/dev/js/utils/time.js":
696 /*!**************************************!*\
697 !*** ../assets/dev/js/utils/time.js ***!
698 \**************************************/
699 /***/ ((__unused_webpack_module, exports) => {
700
701 "use strict";
702
703
704 Object.defineProperty(exports, "__esModule", ({
705 value: true
706 }));
707 exports["default"] = getUserTimestamp;
708 /**
709 * Returns the timestamp in ISO8601 format with the UTC timezone offset.
710 *
711 * @since 3.6.0
712 *
713 * @param {Date} date
714 * @return {Date} timestamp
715 */
716 function getUserTimestamp() {
717 var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
718 var timezoneOffset = date.getTimezoneOffset();
719
720 // Local time for the user
721 var UTCTimestamp = new Date(date.getTime() - timezoneOffset * 60000).toISOString();
722
723 // Remove the Z suffix from the string.
724 UTCTimestamp = UTCTimestamp.slice(0, -1);
725
726 // Create the offset string in the format `+HH:00` (or minus (-) prefix for negative offset instead of plus)
727 var decimalTimezoneOffset = timezoneOffset / 60,
728 // Negative offsets include a '-' sign in the getTimezoneOffset value, positive values need a '+' prefix (ISO8601).
729 sign = 0 <= decimalTimezoneOffset ? '+' : '-',
730 hours = Math.abs(Math.floor(decimalTimezoneOffset)),
731 minutes = Math.abs(decimalTimezoneOffset % 1) * 60,
732 addZeroToHour = 10 > hours ? '0' : '',
733 addZeroToMinutes = 10 > minutes ? '0' : '';
734 var formattedTimezoneOffset = sign + addZeroToHour + hours + ':' + addZeroToMinutes + minutes;
735 return UTCTimestamp + formattedTimezoneOffset;
736 }
737
738 /***/ }),
739
740 /***/ "../core/common/assets/js/components/wordpress/commands-data/index.js":
741 /*!****************************************************************************!*\
742 !*** ../core/common/assets/js/components/wordpress/commands-data/index.js ***!
743 \****************************************************************************/
744 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
745
746 "use strict";
747
748
749 Object.defineProperty(exports, "__esModule", ({
750 value: true
751 }));
752 Object.defineProperty(exports, "Media", ({
753 enumerable: true,
754 get: function get() {
755 return _media.Media;
756 }
757 }));
758 var _media = __webpack_require__(/*! ./media */ "../core/common/assets/js/components/wordpress/commands-data/media.js");
759
760 /***/ }),
761
762 /***/ "../core/common/assets/js/components/wordpress/commands-data/media.js":
763 /*!****************************************************************************!*\
764 !*** ../core/common/assets/js/components/wordpress/commands-data/media.js ***!
765 \****************************************************************************/
766 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
767
768 "use strict";
769 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
770
771
772 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
773 Object.defineProperty(exports, "__esModule", ({
774 value: true
775 }));
776 exports.Media = void 0;
777 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
778 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
779 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
780 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
781 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
782 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
783 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
784 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
785 var _commandData = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-data */ "../modules/web-cli/assets/js/modules/command-data.js"));
786 var _filesUploadHandler = _interopRequireDefault(__webpack_require__(/*! elementor-editor/utils/files-upload-handler */ "../assets/dev/js/editor/utils/files-upload-handler.js"));
787 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
788 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
789 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
790 var Media = exports.Media = /*#__PURE__*/function (_CommandData) {
791 function Media() {
792 (0, _classCallCheck2.default)(this, Media);
793 return _callSuper(this, Media, arguments);
794 }
795 (0, _inherits2.default)(Media, _CommandData);
796 return (0, _createClass2.default)(Media, [{
797 key: "validateArgs",
798 value: function validateArgs() {
799 this.requireArgumentInstance('file', File);
800 }
801 }, {
802 key: "getRequestData",
803 value: function getRequestData() {
804 var requestData = _superPropGet(Media, "getRequestData", this, 3)([]);
805 requestData.namespace = 'wp';
806 requestData.version = '2';
807 return requestData;
808 }
809 }, {
810 key: "applyBeforeCreate",
811 value: function applyBeforeCreate(args) {
812 var _args$options;
813 args.headers = {
814 'Content-Disposition': "attachment; filename=".concat(this.file.name),
815 'Content-Type': this.file.type
816 };
817 args.query = {
818 uploadTypeCaller: 'elementor-wp-media-upload'
819 };
820 args.data = this.file;
821 if ((_args$options = args.options) !== null && _args$options !== void 0 && _args$options.progress) {
822 this.toast = elementor.notifications.showToast({
823 // eslint-disable-next-line @wordpress/i18n-ellipsis
824 message: __('Uploading...'),
825 sticky: true
826 });
827 }
828 return args;
829 }
830 }, {
831 key: "applyAfterCreate",
832 value: function applyAfterCreate(data, args) {
833 var _args$options2;
834 if ((_args$options2 = args.options) !== null && _args$options2 !== void 0 && _args$options2.progress) {
835 this.toast.hide();
836 }
837 return data;
838 }
839 }, {
840 key: "run",
841 value: function () {
842 var _run = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
843 return _regenerator.default.wrap(function (_context) {
844 while (1) switch (_context.prev = _context.next) {
845 case 0:
846 this.file = this.args.file;
847 if (!(this.file.size > parseInt(window._wpPluploadSettings.defaults.filters.max_file_size, 10))) {
848 _context.next = 1;
849 break;
850 }
851 throw new Error(__('The file exceeds the maximum upload size for this site.', 'elementor'));
852 case 1:
853 if (!(!window._wpPluploadSettings.defaults.filters.mime_types[0].extensions.split(',').includes(this.file.name.split('.').pop()) && !elementor.config.filesUpload.unfilteredFiles)) {
854 _context.next = 2;
855 break;
856 }
857 _filesUploadHandler.default.getUnfilteredFilesNotEnabledDialog(function () {}).show();
858 return _context.abrupt("return");
859 case 2:
860 _context.next = 3;
861 return _superPropGet(Media, "run", this, 3)([]);
862 case 3:
863 return _context.abrupt("return", _context.sent);
864 case 4:
865 case "end":
866 return _context.stop();
867 }
868 }, _callee, this);
869 }));
870 function run() {
871 return _run.apply(this, arguments);
872 }
873 return run;
874 }()
875 }], [{
876 key: "getEndpointFormat",
877 value: function getEndpointFormat() {
878 // 'wp/media' to 'media' since `requestData.namespace` is 'wp'.
879 return 'media';
880 }
881 }]);
882 }(_commandData.default);
883
884 /***/ }),
885
886 /***/ "../core/common/assets/js/components/wordpress/component.js":
887 /*!******************************************************************!*\
888 !*** ../core/common/assets/js/components/wordpress/component.js ***!
889 \******************************************************************/
890 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
891
892 "use strict";
893
894
895 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
896 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
897 Object.defineProperty(exports, "__esModule", ({
898 value: true
899 }));
900 exports["default"] = void 0;
901 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
902 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
903 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
904 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
905 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
906 var _componentBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
907 var dataCommands = _interopRequireWildcard(__webpack_require__(/*! ./commands-data/ */ "../core/common/assets/js/components/wordpress/commands-data/index.js"));
908 function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
909 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
910 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
911 var Component = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
912 function Component() {
913 (0, _classCallCheck2.default)(this, Component);
914 return _callSuper(this, Component, arguments);
915 }
916 (0, _inherits2.default)(Component, _ComponentBase);
917 return (0, _createClass2.default)(Component, [{
918 key: "getNamespace",
919 value: function getNamespace() {
920 return 'wp';
921 }
922 }, {
923 key: "defaultData",
924 value: function defaultData() {
925 return this.importCommands(dataCommands);
926 }
927 }]);
928 }(_componentBase.default);
929
930 /***/ }),
931
932 /***/ "../core/common/assets/js/utils/debug.js":
933 /*!***********************************************!*\
934 !*** ../core/common/assets/js/utils/debug.js ***!
935 \***********************************************/
936 /***/ ((module) => {
937
938 "use strict";
939
940
941 // Moved from assets/dev/js/editor/utils
942 var Debug = function Debug() {
943 var self = this,
944 errorStack = [],
945 settings = {},
946 elements = {};
947 var initSettings = function initSettings() {
948 settings = {
949 debounceDelay: 500,
950 urlsToWatch: ['elementor/assets']
951 };
952 };
953 var initElements = function initElements() {
954 elements.$window = jQuery(window);
955 };
956 var onError = function onError(event) {
957 var _event$originalEvent;
958 var error = (_event$originalEvent = event.originalEvent) === null || _event$originalEvent === void 0 ? void 0 : _event$originalEvent.error;
959 if (!error) {
960 return;
961 }
962 var isInWatchList = false,
963 urlsToWatch = settings.urlsToWatch;
964 jQuery.each(urlsToWatch, function () {
965 if (-1 !== error.stack.indexOf(this)) {
966 isInWatchList = true;
967 return false;
968 }
969 });
970 if (!isInWatchList) {
971 return;
972 }
973 self.addError({
974 type: error.name,
975 message: error.message,
976 url: event.originalEvent.filename,
977 line: event.originalEvent.lineno,
978 column: event.originalEvent.colno
979 });
980 };
981 var bindEvents = function bindEvents() {
982 elements.$window.on('error', onError);
983 };
984 var init = function init() {
985 initSettings();
986 initElements();
987 bindEvents();
988 self.sendErrors = _.debounce(self.sendErrors, settings.debounceDelay);
989 };
990 this.addURLToWatch = function (url) {
991 settings.urlsToWatch.push(url);
992 };
993 this.addCustomError = function (error, category, tag) {
994 var errorInfo = {
995 type: error.name,
996 message: error.message,
997 url: error.fileName || error.sourceURL,
998 line: error.lineNumber || error.line,
999 column: error.columnNumber || error.column,
1000 customFields: {
1001 category: category || 'general',
1002 tag: tag
1003 }
1004 };
1005 if (!errorInfo.url) {
1006 var stackInfo = error.stack.match(/\n {4}at (.*?(?=:(\d+):(\d+)))/);
1007 if (stackInfo) {
1008 errorInfo.url = stackInfo[1];
1009 errorInfo.line = stackInfo[2];
1010 errorInfo.column = stackInfo[3];
1011 }
1012 }
1013 this.addError(errorInfo);
1014 };
1015 this.addError = function (errorParams) {
1016 var defaultParams = {
1017 type: 'Error',
1018 timestamp: Math.floor(new Date().getTime() / 1000),
1019 message: null,
1020 url: null,
1021 line: null,
1022 column: null,
1023 customFields: {}
1024 };
1025 errorStack.push(jQuery.extend(true, defaultParams, errorParams));
1026 self.sendErrors();
1027 };
1028 this.sendErrors = function () {
1029 // Avoid recursions on errors in ajax
1030 elements.$window.off('error', onError);
1031 jQuery.ajax({
1032 url: elementorCommon.config.ajax.url,
1033 method: 'POST',
1034 data: {
1035 action: 'elementor_js_log',
1036 _nonce: elementorCommon.ajax.getSettings('nonce'),
1037 data: errorStack
1038 },
1039 success: function success() {
1040 errorStack = [];
1041
1042 // Restore error handler
1043 elements.$window.on('error', onError);
1044 }
1045 });
1046 };
1047 init();
1048 };
1049 module.exports = Debug;
1050
1051 /***/ }),
1052
1053 /***/ "../core/common/assets/js/utils/helpers.js":
1054 /*!*************************************************!*\
1055 !*** ../core/common/assets/js/utils/helpers.js ***!
1056 \*************************************************/
1057 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1058
1059 "use strict";
1060
1061
1062 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1063 Object.defineProperty(exports, "__esModule", ({
1064 value: true
1065 }));
1066 exports["default"] = void 0;
1067 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1068 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1069 var Helpers = exports["default"] = /*#__PURE__*/function () {
1070 function Helpers() {
1071 (0, _classCallCheck2.default)(this, Helpers);
1072 }
1073 return (0, _createClass2.default)(Helpers, [{
1074 key: "consoleWarn",
1075 value:
1076 /**
1077 * @param {*} args
1078 * @deprecated since 3.7.0, use `elementorDevTools.consoleWarn()` instead.
1079 */
1080 function consoleWarn() {
1081 var _elementorDevTools;
1082 (_elementorDevTools = elementorDevTools).consoleWarn.apply(_elementorDevTools, arguments);
1083
1084 // This is is self is deprecated.
1085 elementorDevTools.deprecation.deprecated('elementorCommon.helpers.consoleWarn()', '3.7.0', 'elementorDevTools.consoleWarn()');
1086 }
1087
1088 /**
1089 * @param {string} message
1090 * @deprecated since 3.7.0, use `console.error()` instead.
1091 */
1092 }, {
1093 key: "consoleError",
1094 value: function consoleError(message) {
1095 // eslint-disable-next-line no-console
1096 console.error(message);
1097
1098 // This is is self is deprecated.
1099 elementorDevTools.deprecation.deprecated('elementorCommon.helpers.consoleError()', '3.7.0', 'console.error()');
1100 }
1101 }, {
1102 key: "cloneObject",
1103 value: function cloneObject(object) {
1104 return JSON.parse(JSON.stringify(object));
1105 }
1106 }, {
1107 key: "upperCaseWords",
1108 value: function upperCaseWords(string) {
1109 return (string + '').replace(/^(.)|\s+(.)/g, function ($1) {
1110 return $1.toUpperCase();
1111 });
1112 }
1113 }, {
1114 key: "getUniqueId",
1115 value: function getUniqueId() {
1116 return Math.random().toString(16).substr(2, 7);
1117 }
1118 }]);
1119 }();
1120
1121 /***/ }),
1122
1123 /***/ "../core/common/assets/js/utils/storage.js":
1124 /*!*************************************************!*\
1125 !*** ../core/common/assets/js/utils/storage.js ***!
1126 \*************************************************/
1127 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1128
1129 "use strict";
1130
1131
1132 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1133 Object.defineProperty(exports, "__esModule", ({
1134 value: true
1135 }));
1136 exports["default"] = void 0;
1137 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1138 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1139 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1140 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1141 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1142 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1143 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1144 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1145 function _default() {
1146 (0, _classCallCheck2.default)(this, _default);
1147 return _callSuper(this, _default, arguments);
1148 }
1149 (0, _inherits2.default)(_default, _elementorModules$Mod);
1150 return (0, _createClass2.default)(_default, [{
1151 key: "get",
1152 value: function get(key, options) {
1153 options = options || {};
1154 var storage;
1155 try {
1156 storage = options.session ? sessionStorage : localStorage;
1157 } catch (e) {
1158 return key ? undefined : {};
1159 }
1160 var elementorStorage = storage.getItem('elementor');
1161 if (elementorStorage) {
1162 elementorStorage = JSON.parse(elementorStorage);
1163 } else {
1164 elementorStorage = {};
1165 }
1166 if (!elementorStorage.__expiration) {
1167 elementorStorage.__expiration = {};
1168 }
1169 var expiration = elementorStorage.__expiration;
1170 var expirationToCheck = [];
1171 if (key) {
1172 if (expiration[key]) {
1173 expirationToCheck = [key];
1174 }
1175 } else {
1176 expirationToCheck = Object.keys(expiration);
1177 }
1178 var entryExpired = false;
1179 expirationToCheck.forEach(function (expirationKey) {
1180 if (new Date(expiration[expirationKey]) < new Date()) {
1181 delete elementorStorage[expirationKey];
1182 delete expiration[expirationKey];
1183 entryExpired = true;
1184 }
1185 });
1186 if (entryExpired) {
1187 this.save(elementorStorage, options.session);
1188 }
1189 if (key) {
1190 return elementorStorage[key];
1191 }
1192 return elementorStorage;
1193 }
1194 }, {
1195 key: "set",
1196 value: function set(key, value, options) {
1197 options = options || {};
1198 var elementorStorage = this.get(null, options);
1199 elementorStorage[key] = value;
1200 if (options.lifetimeInSeconds) {
1201 var date = new Date();
1202 date.setTime(date.getTime() + options.lifetimeInSeconds * 1000);
1203 elementorStorage.__expiration[key] = date.getTime();
1204 }
1205 this.save(elementorStorage, options.session);
1206 }
1207 }, {
1208 key: "save",
1209 value: function save(object, session) {
1210 var storage;
1211 try {
1212 storage = session ? sessionStorage : localStorage;
1213 } catch (e) {
1214 return;
1215 }
1216 storage.setItem('elementor', JSON.stringify(object));
1217 }
1218 }]);
1219 }(elementorModules.Module);
1220
1221 /***/ }),
1222
1223 /***/ "../core/common/modules/ajax/assets/js/ajax.js":
1224 /*!*****************************************************!*\
1225 !*** ../core/common/modules/ajax/assets/js/ajax.js ***!
1226 \*****************************************************/
1227 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1228
1229 "use strict";
1230
1231
1232 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1233 Object.defineProperty(exports, "__esModule", ({
1234 value: true
1235 }));
1236 exports["default"] = void 0;
1237 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
1238 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1239 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1240 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1241 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1242 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1243 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1244 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1245 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1246 function _default() {
1247 var _this;
1248 (0, _classCallCheck2.default)(this, _default);
1249 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1250 args[_key] = arguments[_key];
1251 }
1252 _this = _callSuper(this, _default, [].concat(args));
1253 _this.requests = {};
1254 _this.cache = {};
1255 _this.initRequestConstants();
1256 _this.debounceSendBatch = _.debounce(_this.sendBatch.bind(_this), 500);
1257 return _this;
1258 }
1259 (0, _inherits2.default)(_default, _elementorModules$Mod);
1260 return (0, _createClass2.default)(_default, [{
1261 key: "getDefaultSettings",
1262 value: function getDefaultSettings() {
1263 return {
1264 ajaxParams: {
1265 type: 'POST',
1266 url: elementorCommon.config.ajax.url,
1267 data: {},
1268 dataType: 'json'
1269 },
1270 actionPrefix: 'elementor_'
1271 };
1272 }
1273 }, {
1274 key: "initRequestConstants",
1275 value: function initRequestConstants() {
1276 this.requestConstants = {
1277 _nonce: this.getSettings('nonce')
1278 };
1279 }
1280 }, {
1281 key: "addRequestConstant",
1282 value: function addRequestConstant(key, value) {
1283 this.requestConstants[key] = value;
1284 }
1285 }, {
1286 key: "getCacheKey",
1287 value: function getCacheKey(request) {
1288 return JSON.stringify({
1289 unique_id: request.unique_id,
1290 data: request.data
1291 });
1292 }
1293 }, {
1294 key: "loadObjects",
1295 value: function loadObjects(options) {
1296 var _this2 = this;
1297 var dataCollection = {};
1298 var deferredArray = [];
1299 if (options.before) {
1300 options.before();
1301 }
1302 options.ids.forEach(function (objectId) {
1303 deferredArray.push(_this2.load({
1304 action: options.action,
1305 unique_id: options.data.unique_id + objectId,
1306 data: jQuery.extend({
1307 id: objectId
1308 }, options.data)
1309 }).done(function (data) {
1310 return dataCollection = jQuery.extend(dataCollection, data);
1311 }));
1312 });
1313 jQuery.when.apply(jQuery, deferredArray).done(function () {
1314 return options.success(dataCollection);
1315 });
1316 }
1317 }, {
1318 key: "load",
1319 value: function load(request, immediately) {
1320 var _this3 = this;
1321 if (!request.unique_id) {
1322 request.unique_id = request.action;
1323 }
1324 if (request.before) {
1325 request.before();
1326 }
1327 var deferred;
1328 var cacheKey = this.getCacheKey(request);
1329 if (_.has(this.cache, cacheKey)) {
1330 deferred = jQuery.Deferred().done(request.success).resolve(this.cache[cacheKey]);
1331 } else {
1332 deferred = this.addRequest(request.action, {
1333 data: request.data,
1334 unique_id: request.unique_id,
1335 success: function success(data) {
1336 return _this3.cache[cacheKey] = data;
1337 }
1338 }, immediately).done(request.success);
1339 }
1340 return deferred;
1341 }
1342 }, {
1343 key: "cancelRequest",
1344 value: function cancelRequest(requestId) {
1345 var request = this.requests[requestId];
1346 if (!request) {
1347 return null;
1348 }
1349 if (request.options.deferred.jqXhr) {
1350 return request.options.deferred.jqXhr.abort('Request canceled');
1351 }
1352 if (request.options.deferred) {
1353 return request.options.deferred.reject('Request canceled');
1354 }
1355 }
1356 }, {
1357 key: "addRequest",
1358 value: function addRequest(action, options, immediately) {
1359 options = options || {};
1360 if (!options.unique_id) {
1361 options.unique_id = action;
1362 }
1363 options.deferred = jQuery.Deferred().done(options.success).fail(options.error).always(options.complete);
1364 var request = {
1365 action: action,
1366 options: options
1367 };
1368 if (immediately) {
1369 var requests = {};
1370 requests[options.unique_id] = request;
1371 options.deferred.jqXhr = this.sendBatch(requests);
1372 } else {
1373 this.requests[options.unique_id] = request;
1374 this.debounceSendBatch();
1375 }
1376 return options.deferred;
1377 }
1378 }, {
1379 key: "sendBatch",
1380 value: function sendBatch(requests) {
1381 var actions = {};
1382 if (!requests) {
1383 requests = this.requests;
1384
1385 // Empty for next batch.
1386 this.requests = {};
1387 }
1388 Object.entries(requests).forEach(function (_ref) {
1389 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
1390 id = _ref2[0],
1391 request = _ref2[1];
1392 return actions[id] = {
1393 action: request.action,
1394 data: request.options.data
1395 };
1396 });
1397 return this.send('ajax', {
1398 data: {
1399 actions: JSON.stringify(actions)
1400 },
1401 success: function success(data) {
1402 Object.entries(data.responses).forEach(function (_ref3) {
1403 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
1404 id = _ref4[0],
1405 response = _ref4[1];
1406 var options = requests[id].options;
1407 if (options) {
1408 if (response.success) {
1409 options.deferred.resolve(response.data);
1410 } else if (!response.success) {
1411 options.deferred.reject(response.data);
1412 }
1413 }
1414 });
1415 },
1416 error: function error(data) {
1417 return Object.values(requests).forEach(function (args) {
1418 if (args.options) {
1419 args.options.deferred.reject(data);
1420 }
1421 });
1422 }
1423 });
1424 }
1425 }, {
1426 key: "prepareSend",
1427 value: function prepareSend(action, options) {
1428 var _this4 = this;
1429 var settings = this.getSettings(),
1430 ajaxParams = elementorCommon.helpers.cloneObject(settings.ajaxParams);
1431 options = options || {};
1432 action = settings.actionPrefix + action;
1433 jQuery.extend(ajaxParams, options);
1434 var requestConstants = elementorCommon.helpers.cloneObject(this.requestConstants);
1435 requestConstants.action = action;
1436 var isFormData = ajaxParams.data instanceof FormData;
1437 Object.entries(requestConstants).forEach(function (_ref5) {
1438 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
1439 key = _ref6[0],
1440 value = _ref6[1];
1441 if (isFormData) {
1442 ajaxParams.data.append(key, value);
1443 } else {
1444 ajaxParams.data[key] = value;
1445 }
1446 });
1447 var successCallback = ajaxParams.success,
1448 errorCallback = ajaxParams.error;
1449 if (successCallback || errorCallback) {
1450 ajaxParams.success = function (response) {
1451 if (response.success && successCallback) {
1452 successCallback(response.data);
1453 }
1454 if (!response.success && errorCallback) {
1455 errorCallback(response.data);
1456 }
1457 };
1458 if (errorCallback) {
1459 ajaxParams.error = function (data) {
1460 return errorCallback(data);
1461 };
1462 } else {
1463 ajaxParams.error = function (xmlHttpRequest) {
1464 if (xmlHttpRequest.readyState || 'abort' !== xmlHttpRequest.statusText) {
1465 _this4.trigger('request:unhandledError', xmlHttpRequest);
1466 }
1467 };
1468 }
1469 }
1470 return ajaxParams;
1471 }
1472 }, {
1473 key: "send",
1474 value: function send(action, options) {
1475 return jQuery.ajax(this.prepareSend(action, options));
1476 }
1477 }, {
1478 key: "addRequestCache",
1479 value: function addRequestCache(request, data) {
1480 var cacheKey = this.getCacheKey(request);
1481 this.cache[cacheKey] = data;
1482 }
1483 }, {
1484 key: "invalidateCache",
1485 value: function invalidateCache(request) {
1486 var cacheKey = this.getCacheKey(request);
1487 delete this.cache[cacheKey];
1488 }
1489 }]);
1490 }(elementorModules.Module);
1491
1492 /***/ }),
1493
1494 /***/ "../core/common/modules/connect/assets/js/connect.js":
1495 /*!***********************************************************!*\
1496 !*** ../core/common/modules/connect/assets/js/connect.js ***!
1497 \***********************************************************/
1498 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1499
1500 "use strict";
1501 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
1502
1503
1504 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1505 Object.defineProperty(exports, "__esModule", ({
1506 value: true
1507 }));
1508 exports["default"] = void 0;
1509 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1510 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1511 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1512 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1513 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
1514 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1515 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1516 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1517 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
1518 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Vie) {
1519 function _default() {
1520 (0, _classCallCheck2.default)(this, _default);
1521 return _callSuper(this, _default, arguments);
1522 }
1523 (0, _inherits2.default)(_default, _elementorModules$Vie);
1524 return (0, _createClass2.default)(_default, [{
1525 key: "addPopupPlugin",
1526 value: function addPopupPlugin() {
1527 var counter = 0;
1528 jQuery.fn.elementorConnect = function (options) {
1529 var _this = this;
1530 // Open the Connect Dialog in a popup window.
1531 if (options !== null && options !== void 0 && options.popup) {
1532 jQuery(this).on('click', function (event) {
1533 var _options$popup, _options$popup2;
1534 event.preventDefault();
1535 var width = ((_options$popup = options.popup) === null || _options$popup === void 0 ? void 0 : _options$popup.width) || 600,
1536 height = ((_options$popup2 = options.popup) === null || _options$popup2 === void 0 ? void 0 : _options$popup2.height) || 700;
1537 window.open(jQuery(_this).attr('href') + '&mode=popup', 'elementorConnect', "toolbar=no, menubar=no, width=".concat(width, ", height=").concat(height, ", top=200, left=0"));
1538 });
1539 delete options.popup;
1540 }
1541 var settings = jQuery.extend({
1542 // These are the defaults.
1543 success: function success() {
1544 return location.reload();
1545 },
1546 error: function error() {
1547 elementor.notifications.showToast({
1548 message: __('Unable to connect', 'elementor')
1549 });
1550 },
1551 parseUrl: function parseUrl(url) {
1552 return url;
1553 } // Allow to change the url, e.g: replace placeholders like '%%template_type%%' with actual value.
1554 }, options);
1555 this.each(function () {
1556 counter++;
1557 var $this = jQuery(this),
1558 callbackId = 'cb' + counter;
1559 $this.attr({
1560 target: '_blank',
1561 rel: 'opener',
1562 href: settings.parseUrl($this.attr('href') + '&mode=popup&callback_id=' + callbackId)
1563 });
1564 elementorCommon.elements.$window.on('elementor/connect/success/' + callbackId, settings.success).on('elementor/connect/error/' + callbackId, settings.error);
1565 });
1566 return this;
1567 };
1568 }
1569 }, {
1570 key: "getDefaultSettings",
1571 value: function getDefaultSettings() {
1572 return {
1573 selectors: {
1574 connectButton: '#elementor-template-library-connect__button'
1575 }
1576 };
1577 }
1578 }, {
1579 key: "getDefaultElements",
1580 value: function getDefaultElements() {
1581 return {
1582 $connectButton: jQuery(this.getSettings('selectors.connectButton'))
1583 };
1584 }
1585 }, {
1586 key: "applyPopup",
1587 value: function applyPopup() {
1588 this.elements.$connectButton.elementorConnect();
1589 }
1590 }, {
1591 key: "onInit",
1592 value: function onInit() {
1593 _superPropGet(_default, "onInit", this, 3)([]);
1594 this.addPopupPlugin();
1595 this.applyPopup();
1596 }
1597 }]);
1598 }(elementorModules.ViewModule);
1599
1600 /***/ }),
1601
1602 /***/ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js":
1603 /*!**********************************************************************************!*\
1604 !*** ../core/common/modules/event-tracker/assets/js/data/commands-data/index.js ***!
1605 \**********************************************************************************/
1606 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1607
1608 "use strict";
1609
1610
1611 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1612 Object.defineProperty(exports, "__esModule", ({
1613 value: true
1614 }));
1615 exports.Index = void 0;
1616 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1617 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1618 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1619 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1620 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1621 var _commandData = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-data */ "../modules/web-cli/assets/js/modules/command-data.js"));
1622 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1623 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1624 var Index = exports.Index = /*#__PURE__*/function (_CommandData) {
1625 function Index() {
1626 (0, _classCallCheck2.default)(this, Index);
1627 return _callSuper(this, Index, arguments);
1628 }
1629 (0, _inherits2.default)(Index, _CommandData);
1630 return (0, _createClass2.default)(Index, null, [{
1631 key: "getEndpointFormat",
1632 value: function getEndpointFormat() {
1633 return 'send-event';
1634 }
1635 }]);
1636 }(_commandData.default);
1637
1638 /***/ }),
1639
1640 /***/ "../core/common/modules/event-tracker/assets/js/data/component.js":
1641 /*!************************************************************************!*\
1642 !*** ../core/common/modules/event-tracker/assets/js/data/component.js ***!
1643 \************************************************************************/
1644 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1645
1646 "use strict";
1647
1648
1649 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1650 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
1651 Object.defineProperty(exports, "__esModule", ({
1652 value: true
1653 }));
1654 exports["default"] = void 0;
1655 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1656 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1657 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1658 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1659 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1660 var _componentBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
1661 var commandsData = _interopRequireWildcard(__webpack_require__(/*! ./commands-data/ */ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js"));
1662 function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
1663 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1664 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1665 var Component = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
1666 function Component() {
1667 (0, _classCallCheck2.default)(this, Component);
1668 return _callSuper(this, Component, arguments);
1669 }
1670 (0, _inherits2.default)(Component, _ComponentBase);
1671 return (0, _createClass2.default)(Component, [{
1672 key: "getNamespace",
1673 value: function getNamespace() {
1674 return 'event-tracker';
1675 }
1676 }, {
1677 key: "defaultData",
1678 value: function defaultData() {
1679 return this.importCommands(commandsData);
1680 }
1681 }]);
1682 }(_componentBase.default);
1683
1684 /***/ }),
1685
1686 /***/ "../core/common/modules/event-tracker/assets/js/events.js":
1687 /*!****************************************************************!*\
1688 !*** ../core/common/modules/event-tracker/assets/js/events.js ***!
1689 \****************************************************************/
1690 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1691
1692 "use strict";
1693
1694
1695 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1696 Object.defineProperty(exports, "__esModule", ({
1697 value: true
1698 }));
1699 exports["default"] = void 0;
1700 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1701 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1702 var _time = _interopRequireDefault(__webpack_require__(/*! elementor-utils/time */ "../assets/dev/js/utils/time.js"));
1703 var Events = exports["default"] = /*#__PURE__*/function () {
1704 function Events() {
1705 (0, _classCallCheck2.default)(this, Events);
1706 }
1707 return (0, _createClass2.default)(Events, [{
1708 key: "dispatchEvent",
1709 value: function dispatchEvent(eventData) {
1710 if (!eventData) {
1711 return;
1712 }
1713 eventData.ts = (0, _time.default)();
1714
1715 // No need to wait for response, no need to block browser in any way.
1716 $e.data.create('event-tracker/index', {
1717 event_data: eventData
1718 });
1719 }
1720 }]);
1721 }();
1722
1723 /***/ }),
1724
1725 /***/ "../core/common/modules/events-manager/assets/js/events-config.js":
1726 /*!************************************************************************!*\
1727 !*** ../core/common/modules/events-manager/assets/js/events-config.js ***!
1728 \************************************************************************/
1729 /***/ ((__unused_webpack_module, exports) => {
1730
1731 "use strict";
1732
1733
1734 Object.defineProperty(exports, "__esModule", ({
1735 value: true
1736 }));
1737 exports["default"] = void 0;
1738 var eventsConfig = {
1739 triggers: {
1740 click: 'Click',
1741 rightClick: 'Right Click',
1742 doubleClick: 'Double Click',
1743 accordionClick: 'Accordion Click',
1744 toggleClick: 'Toggle Click',
1745 dropdownClick: 'Click Dropdown',
1746 editorLoaded: 'Editor Loaded',
1747 visible: 'Visible',
1748 pageLoaded: 'Page Loaded'
1749 },
1750 locations: {
1751 widgetPanel: 'Widget Panel',
1752 topBar: 'Top Bar',
1753 elementorEditor: 'Elementor Editor',
1754 templatesLibrary: {
1755 library: 'Templates Library'
1756 },
1757 app: {
1758 import: 'Import Kit',
1759 export: 'Export Kit',
1760 kitLibrary: 'Kit Library',
1761 cloudKitLibrary: 'Cloud Kit Library'
1762 },
1763 variables: 'Variables Panel',
1764 variablesManager: 'Variables Manager',
1765 admin: 'WP admin',
1766 structurePanel: 'Structure Panel',
1767 canvas: 'Canvas'
1768 },
1769 secondaryLocations: {
1770 layout: 'Layout Section',
1771 basic: 'Basic Section',
1772 'pro-elements': 'Pro Section',
1773 general: 'General Section',
1774 'theme-elements': 'Site Section',
1775 'theme-elements-single': 'Single Section',
1776 'woocommerce-elements': 'WooCommerce Section',
1777 wordpress: 'WordPress Section',
1778 categories: 'Widgets Tab',
1779 global: 'Globals Tab',
1780 'whats-new': 'What\'s New',
1781 'document-settings': 'Document Settings icon',
1782 'preview-page': 'Preview Page',
1783 'publish-button': 'Publish Button',
1784 'widget-panel': 'Widget Panel Icon',
1785 finder: 'Finder',
1786 help: 'Help',
1787 elementorLogoDropdown: 'top_bar_elementor_logo_dropdown',
1788 elementorLogo: 'Elementor Logo',
1789 eLogoMenu: 'E-logo Menu',
1790 notes: 'Notes',
1791 siteSettings: 'Site Settings',
1792 structure: 'Structure',
1793 documentNameDropdown: 'Document Name dropdown',
1794 responsiveControls: 'Responsive controls',
1795 launchpad: 'launchpad',
1796 checklistHeader: 'Checklist Header',
1797 checklistSteps: 'Checklist Steps',
1798 userPreferences: 'User Preferences',
1799 contextMenu: 'Context Menu',
1800 templateLibrary: {
1801 saveModal: 'Save to Modal',
1802 moveModal: 'Move to Modal',
1803 bulkMoveModal: 'Bulk Move to Modal',
1804 copyModal: 'Copy to Modal',
1805 bulkCopyModal: 'Bulk Copy to Modal',
1806 saveModalSelectFolder: 'Save to Modal - select folder',
1807 saveModalSelectConnect: 'Save to Modal - connect',
1808 saveModalSelectUpgrade: 'Save to Modal - upgrade',
1809 importModal: 'Import Modal',
1810 newFolderModal: 'New Folder Modal',
1811 deleteDialog: 'Delete Dialog',
1812 deleteFolderDialog: 'Delete Folder Dialog',
1813 renameDialog: 'Rename Dialog',
1814 createFolderDialog: 'Create Folder Dialog',
1815 applySettingsDialog: 'Apply Settings Dialog',
1816 cloudTab: 'Cloud Tab',
1817 siteTab: 'Site Tab',
1818 cloudTabFolder: 'Cloud Tab - Folder',
1819 cloudTabConnect: 'Cloud Tab - Connect',
1820 cloudTabUpgrade: 'Cloud Tab - Upgrade',
1821 morePopup: 'Context Menu',
1822 quotaBar: 'Quota Bar'
1823 },
1824 kitLibrary: {
1825 cloudKitLibrary: 'kits_cloud_library',
1826 cloudKitLibraryConnect: 'kits_cloud_library_connect',
1827 cloudKitLibraryUpgrade: 'kits_cloud_library_upgrade',
1828 kitExportCustomization: 'kit_export_customization',
1829 kitExport: 'kit_export',
1830 kitExportCustomizationEdit: 'kit_export_customization_edit',
1831 kitExportSummary: 'kit_export_summary',
1832 kitImportUploadBox: 'kit_import_upload_box',
1833 kitImportCustomization: 'kit_import_customization',
1834 kitImportSummary: 'kit_import_summary'
1835 },
1836 variablesPopover: 'Variables Popover',
1837 admin: {
1838 pluginToolsTab: 'plugin_tools_tab',
1839 pluginWebsiteTemplatesTab: 'plugin_website_templates_tab'
1840 },
1841 componentsTab: 'Components Tab',
1842 canvasElement: 'Canvas Element'
1843 },
1844 elements: {
1845 accordionSection: 'Accordion section',
1846 buttonIcon: 'Button Icon',
1847 mainCta: 'Main CTA',
1848 button: 'Button',
1849 link: 'Link',
1850 dropdown: 'Dropdown',
1851 toggle: 'Toggle',
1852 launchpadChecklist: 'Checklist popup'
1853 },
1854 names: {
1855 v1: {
1856 layout: 'v1_widgets_tab_layout_section',
1857 basic: 'v1_widgets_tab_basic_section',
1858 'pro-elements': 'v1_widgets_tab_pro_section',
1859 general: 'v1_widgets_tab_general_section',
1860 'theme-elements': 'v1_widgets_tab_site_section',
1861 'theme-elements-single': 'v1_widgets_tab_single_section',
1862 'woocommerce-elements': 'v1_widgets_tab_woocommerce_section',
1863 wordpress: 'v1_widgets_tab_wordpress_section',
1864 categories: 'v1_widgets_tab',
1865 global: 'v1_globals_tab'
1866 },
1867 topBar: {
1868 whatsNew: 'top_bar_whats_new',
1869 documentSettings: 'top_bar_document_settings_icon',
1870 previewPage: 'top_bar_preview_page',
1871 publishButton: 'top_bar_publish_button',
1872 widgetPanel: 'top_bar_widget_panel_icon',
1873 finder: 'top_bar_finder',
1874 help: 'top_bar_help',
1875 history: 'top_bar_elementor_logo_dropdown_history',
1876 userPreferences: 'top_bar_elementor_logo_dropdown_user_preferences',
1877 keyboardShortcuts: 'top_bar_elementor_logo_dropdown_keyboard_shortcuts',
1878 exitToWordpress: 'top_bar_elementor_logo_dropdown_exit_to_wordpress',
1879 themeBuilder: 'top_bar_elementor_logo_dropdown_theme_builder',
1880 notes: 'top_bar_notes',
1881 siteSettings: 'top_bar_site_setting',
1882 structure: 'top_bar_structure',
1883 documentNameDropdown: 'top_bar_document_name_dropdown',
1884 responsiveControls: 'top_bar_responsive_controls',
1885 launchpadOn: 'top_bar_checklist_icon_show',
1886 launchpadOff: 'top_bar_checklist_icon_hide',
1887 elementorLogoDropdown: 'open_e_menu',
1888 connectAccount: 'connect_account',
1889 accountConnected: 'account_connected'
1890 },
1891 // ChecklistSteps event names are generated dynamically, based on stepId and action type taken: title, action, done, undone, upgrade
1892 elementorEditor: {
1893 checklist: {
1894 checklistHeaderClose: 'checklist_header_close_icon',
1895 checklistFirstPopup: 'checklist popup triggered'
1896 },
1897 userPreferences: {
1898 checklistShow: 'checklist_userpreferences_toggle_show',
1899 checklistHide: 'checklist_userpreferences_toggle_hide'
1900 }
1901 },
1902 variables: {
1903 open: 'open_variables_popover',
1904 add: 'add_new_variable',
1905 connect: 'connect_variable',
1906 save: 'save_new_variable',
1907 openManager: 'open_variables_manager',
1908 saveChanges: 'save_variables_changes',
1909 delete: 'delete_variable'
1910 },
1911 components: {
1912 createClicked: 'component_create_clicked',
1913 createCancelled: 'component_creation_cancelled',
1914 created: 'component_created',
1915 instanceAdded: 'component_instance_added',
1916 edited: 'component_edited'
1917 },
1918 global_classes: {
1919 classApplied: 'class_applied',
1920 classRemoved: 'class_removed',
1921 classManagerFilterCleared: 'class_manager_filter_cleared',
1922 classDeleted: 'class_deleted',
1923 classPublishConflict: 'class_publish_conflict',
1924 classRenamed: 'class_renamed',
1925 classCreated: 'class_created',
1926 classManagerSearched: 'class_manager_searched',
1927 classManagerFiltersOpened: 'class_manager_filters_opened',
1928 classManagerOpened: 'class_manager_opened',
1929 classManagerReorder: 'class_manager_reorder',
1930 classManagerFilterUsed: 'class_manager_filter_used',
1931 classUsageLocate: 'class_usage_locate',
1932 classUsageHovered: 'class_usage_hovered',
1933 classStyled: 'class_styled',
1934 classStateClicked: 'class_state_clicked',
1935 classUsageClicked: 'class_usage_clicked',
1936 classDuplicate: 'class_duplicate'
1937 }
1938 }
1939 };
1940 var _default = exports["default"] = eventsConfig;
1941
1942 /***/ }),
1943
1944 /***/ "../core/common/modules/events-manager/assets/js/module.js":
1945 /*!*****************************************************************!*\
1946 !*** ../core/common/modules/events-manager/assets/js/module.js ***!
1947 \*****************************************************************/
1948 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1949
1950 "use strict";
1951
1952
1953 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1954 Object.defineProperty(exports, "__esModule", ({
1955 value: true
1956 }));
1957 exports["default"] = void 0;
1958 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
1959 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
1960 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1961 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1962 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1963 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1964 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1965 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
1966 var _eventsConfig = _interopRequireDefault(__webpack_require__(/*! ./events-config */ "../core/common/modules/events-manager/assets/js/events-config.js"));
1967 var _mixpanelBrowser = _interopRequireDefault(__webpack_require__(/*! mixpanel-browser */ "../node_modules/mixpanel-browser/dist/mixpanel.module.js"));
1968 var _tiers = __webpack_require__(/*! elementor-utils/tiers */ "../assets/dev/js/utils/tiers.js");
1969 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1970 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1971 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1972 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1973 function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
1974 function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
1975 function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
1976 function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
1977 function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
1978 var _sessionRecordingInProgress = /*#__PURE__*/new WeakMap();
1979 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1980 function _default() {
1981 var _this;
1982 (0, _classCallCheck2.default)(this, _default);
1983 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1984 args[_key] = arguments[_key];
1985 }
1986 _this = _callSuper(this, _default, [].concat(args));
1987 (0, _defineProperty2.default)(_this, "trackingEnabled", false);
1988 _classPrivateFieldInitSpec(_this, _sessionRecordingInProgress, false);
1989 return _this;
1990 }
1991 (0, _inherits2.default)(_default, _elementorModules$Mod);
1992 return (0, _createClass2.default)(_default, [{
1993 key: "onInit",
1994 value: function onInit() {
1995 var _elementorCommon$conf, _elementorCommon$conf2;
1996 this.config = _eventsConfig.default;
1997 _mixpanelBrowser.default.init((_elementorCommon$conf = elementorCommon.config.editor_events) === null || _elementorCommon$conf === void 0 ? void 0 : _elementorCommon$conf.token, {
1998 persistence: 'localStorage',
1999 autocapture: false,
2000 record_sessions_percent: 0,
2001 record_idle_timeout_ms: 60000,
2002 record_max_ms: 300000,
2003 record_mask_text_selector: '',
2004 flags: true,
2005 api_hosts: {
2006 flags: 'https://api-eu.mixpanel.com'
2007 }
2008 });
2009 if ((_elementorCommon$conf2 = elementorCommon.config.editor_events) !== null && _elementorCommon$conf2 !== void 0 && _elementorCommon$conf2.can_send_events) {
2010 this.enableTracking();
2011 }
2012 }
2013 }, {
2014 key: "enableTracking",
2015 value: function enableTracking() {
2016 var _elementorCommon$conf3;
2017 var userId = (_elementorCommon$conf3 = elementorCommon.config.library_connect) === null || _elementorCommon$conf3 === void 0 ? void 0 : _elementorCommon$conf3.user_id;
2018 if (userId) {
2019 var _elementorCommon$conf4;
2020 _mixpanelBrowser.default.identify(userId);
2021 _mixpanelBrowser.default.register({
2022 appType: 'Editor'
2023 });
2024 _mixpanelBrowser.default.people.set_once({
2025 $user_id: userId,
2026 $last_login: new Date().toISOString(),
2027 $plan_type: ((_elementorCommon$conf4 = elementorCommon.config.library_connect) === null || _elementorCommon$conf4 === void 0 ? void 0 : _elementorCommon$conf4.plan_type) || _tiers.TIERS.free
2028 });
2029 }
2030 this.trackingEnabled = true;
2031 }
2032 }, {
2033 key: "dispatchEvent",
2034 value: function dispatchEvent(name, data) {
2035 var _elementorCommon$conf5, _elementorCommon$conf6, _elementorCommon$conf7, _elementorCommon$conf8, _elementorCommon$conf9, _elementorCommon$conf0, _elementorCommon$conf1, _elementorCommon$conf10, _elementorCommon$conf11, _elementorCommon$conf12;
2036 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2037 if (!((_elementorCommon$conf5 = elementorCommon.config.editor_events) !== null && _elementorCommon$conf5 !== void 0 && _elementorCommon$conf5.can_send_events)) {
2038 return;
2039 }
2040 if (!this.trackingEnabled) {
2041 this.enableTracking();
2042 }
2043 var eventData = _objectSpread({
2044 user_id: ((_elementorCommon$conf6 = elementorCommon.config.library_connect) === null || _elementorCommon$conf6 === void 0 ? void 0 : _elementorCommon$conf6.user_id) || null,
2045 user_roles: ((_elementorCommon$conf7 = elementorCommon.config.library_connect) === null || _elementorCommon$conf7 === void 0 ? void 0 : _elementorCommon$conf7.user_roles) || [],
2046 subscription_id: ((_elementorCommon$conf8 = elementorCommon.config.editor_events) === null || _elementorCommon$conf8 === void 0 ? void 0 : _elementorCommon$conf8.subscription_id) || null,
2047 user_tier: ((_elementorCommon$conf9 = elementorCommon.config.library_connect) === null || _elementorCommon$conf9 === void 0 ? void 0 : _elementorCommon$conf9.current_access_tier) || null,
2048 url: (_elementorCommon$conf0 = elementorCommon.config.editor_events) === null || _elementorCommon$conf0 === void 0 ? void 0 : _elementorCommon$conf0.site_url,
2049 wp_version: (_elementorCommon$conf1 = elementorCommon.config.editor_events) === null || _elementorCommon$conf1 === void 0 ? void 0 : _elementorCommon$conf1.wp_version,
2050 client_id: (_elementorCommon$conf10 = elementorCommon.config.editor_events) === null || _elementorCommon$conf10 === void 0 ? void 0 : _elementorCommon$conf10.site_key,
2051 app_version: (_elementorCommon$conf11 = elementorCommon.config.editor_events) === null || _elementorCommon$conf11 === void 0 ? void 0 : _elementorCommon$conf11.elementor_version,
2052 site_language: (_elementorCommon$conf12 = elementorCommon.config.editor_events) === null || _elementorCommon$conf12 === void 0 ? void 0 : _elementorCommon$conf12.site_language
2053 }, data);
2054 _mixpanelBrowser.default.track(name, eventData, options);
2055 }
2056 }, {
2057 key: "startSessionRecording",
2058 value: function startSessionRecording() {
2059 var _elementorCommon$conf13;
2060 if (!((_elementorCommon$conf13 = elementorCommon.config.editor_events) !== null && _elementorCommon$conf13 !== void 0 && _elementorCommon$conf13.can_send_events) || this.isSessionRecordingInProgress()) {
2061 return;
2062 }
2063 if (!this.trackingEnabled) {
2064 this.enableTracking();
2065 }
2066 _mixpanelBrowser.default.start_session_recording();
2067 this.setSessionRecordingInProgress(true);
2068 }
2069 }, {
2070 key: "stopSessionRecording",
2071 value: function stopSessionRecording() {
2072 var _elementorCommon$conf14;
2073 if (!((_elementorCommon$conf14 = elementorCommon.config.editor_events) !== null && _elementorCommon$conf14 !== void 0 && _elementorCommon$conf14.can_send_events) || !this.isSessionRecordingInProgress()) {
2074 return;
2075 }
2076 _mixpanelBrowser.default.stop_session_recording();
2077 this.setSessionRecordingInProgress(false);
2078 }
2079 }, {
2080 key: "setSessionRecordingInProgress",
2081 value: function setSessionRecordingInProgress(value) {
2082 if ('boolean' !== typeof value) {
2083 return;
2084 }
2085 _classPrivateFieldSet(_sessionRecordingInProgress, this, value);
2086 }
2087 }, {
2088 key: "isSessionRecordingInProgress",
2089 value: function isSessionRecordingInProgress() {
2090 return _classPrivateFieldGet(_sessionRecordingInProgress, this);
2091 }
2092 }, {
2093 key: "featureFlagIsActive",
2094 value: function () {
2095 var _featureFlagIsActive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(flagName) {
2096 var _mixpanel$flags;
2097 var isEnabled;
2098 return _regenerator.default.wrap(function (_context) {
2099 while (1) switch (_context.prev = _context.next) {
2100 case 0:
2101 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))) {
2102 _context.next = 1;
2103 break;
2104 }
2105 return _context.abrupt("return", false);
2106 case 1:
2107 _context.next = 2;
2108 return _mixpanelBrowser.default.flags.is_enabled(flagName, false);
2109 case 2:
2110 isEnabled = _context.sent;
2111 return _context.abrupt("return", true === isEnabled);
2112 case 3:
2113 case "end":
2114 return _context.stop();
2115 }
2116 }, _callee);
2117 }));
2118 function featureFlagIsActive(_x) {
2119 return _featureFlagIsActive.apply(this, arguments);
2120 }
2121 return featureFlagIsActive;
2122 }()
2123 }, {
2124 key: "getExperimentVariant",
2125 value: function () {
2126 var _getExperimentVariant = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(experimentName) {
2127 var defaultValue,
2128 _elementorCommon$conf15,
2129 _elementorCommon$conf16,
2130 isAbTestingEnabled,
2131 variant,
2132 _args2 = arguments,
2133 _t;
2134 return _regenerator.default.wrap(function (_context2) {
2135 while (1) switch (_context2.prev = _context2.next) {
2136 case 0:
2137 defaultValue = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 'control';
2138 _context2.prev = 1;
2139 isAbTestingEnabled = (_elementorCommon$conf15 = (_elementorCommon$conf16 = elementorCommon.config.editor_events) === null || _elementorCommon$conf16 === void 0 ? void 0 : _elementorCommon$conf16.flags_enabled) !== null && _elementorCommon$conf15 !== void 0 ? _elementorCommon$conf15 : false;
2140 if (isAbTestingEnabled) {
2141 _context2.next = 2;
2142 break;
2143 }
2144 return _context2.abrupt("return", defaultValue);
2145 case 2:
2146 if (_mixpanelBrowser.default) {
2147 _context2.next = 3;
2148 break;
2149 }
2150 return _context2.abrupt("return", defaultValue);
2151 case 3:
2152 if (this.trackingEnabled) {
2153 _context2.next = 4;
2154 break;
2155 }
2156 return _context2.abrupt("return", defaultValue);
2157 case 4:
2158 if (_mixpanelBrowser.default.flags) {
2159 _context2.next = 5;
2160 break;
2161 }
2162 return _context2.abrupt("return", defaultValue);
2163 case 5:
2164 if (!('function' !== typeof _mixpanelBrowser.default.flags.get_variant_value)) {
2165 _context2.next = 6;
2166 break;
2167 }
2168 return _context2.abrupt("return", defaultValue);
2169 case 6:
2170 _context2.next = 7;
2171 return _mixpanelBrowser.default.flags.get_variant_value(experimentName, defaultValue);
2172 case 7:
2173 variant = _context2.sent;
2174 if (!(undefined === variant || null === variant)) {
2175 _context2.next = 8;
2176 break;
2177 }
2178 return _context2.abrupt("return", defaultValue);
2179 case 8:
2180 return _context2.abrupt("return", variant);
2181 case 9:
2182 _context2.prev = 9;
2183 _t = _context2["catch"](1);
2184 return _context2.abrupt("return", defaultValue);
2185 case 10:
2186 case "end":
2187 return _context2.stop();
2188 }
2189 }, _callee2, this, [[1, 9]]);
2190 }));
2191 function getExperimentVariant(_x2) {
2192 return _getExperimentVariant.apply(this, arguments);
2193 }
2194 return getExperimentVariant;
2195 }()
2196 }, {
2197 key: "startExperiment",
2198 value: function startExperiment(experimentName, experimentVariant) {
2199 if (!this.trackingEnabled) {
2200 return;
2201 }
2202 _mixpanelBrowser.default.track('$experiment_started', {
2203 'Experiment name': experimentName,
2204 'Variant name': experimentVariant
2205 });
2206 }
2207 }]);
2208 }(elementorModules.Module);
2209
2210 /***/ }),
2211
2212 /***/ "../core/common/modules/finder/assets/js/commands/index.js":
2213 /*!*****************************************************************!*\
2214 !*** ../core/common/modules/finder/assets/js/commands/index.js ***!
2215 \*****************************************************************/
2216 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2217
2218 "use strict";
2219
2220
2221 Object.defineProperty(exports, "__esModule", ({
2222 value: true
2223 }));
2224 Object.defineProperty(exports, "NavigateDown", ({
2225 enumerable: true,
2226 get: function get() {
2227 return _navigateDown.NavigateDown;
2228 }
2229 }));
2230 Object.defineProperty(exports, "NavigateSelect", ({
2231 enumerable: true,
2232 get: function get() {
2233 return _navigateSelect.NavigateSelect;
2234 }
2235 }));
2236 Object.defineProperty(exports, "NavigateUp", ({
2237 enumerable: true,
2238 get: function get() {
2239 return _navigateUp.NavigateUp;
2240 }
2241 }));
2242 var _navigateDown = __webpack_require__(/*! ./navigate-down */ "../core/common/modules/finder/assets/js/commands/navigate-down.js");
2243 var _navigateSelect = __webpack_require__(/*! ./navigate-select */ "../core/common/modules/finder/assets/js/commands/navigate-select.js");
2244 var _navigateUp = __webpack_require__(/*! ./navigate-up */ "../core/common/modules/finder/assets/js/commands/navigate-up.js");
2245
2246 /***/ }),
2247
2248 /***/ "../core/common/modules/finder/assets/js/commands/navigate-down.js":
2249 /*!*************************************************************************!*\
2250 !*** ../core/common/modules/finder/assets/js/commands/navigate-down.js ***!
2251 \*************************************************************************/
2252 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2253
2254 "use strict";
2255
2256
2257 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2258 Object.defineProperty(exports, "__esModule", ({
2259 value: true
2260 }));
2261 exports["default"] = exports.NavigateDown = void 0;
2262 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2263 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2264 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2265 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2266 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2267 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2268 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)); }
2269 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2270 var NavigateDown = exports.NavigateDown = /*#__PURE__*/function (_CommandBase) {
2271 function NavigateDown() {
2272 (0, _classCallCheck2.default)(this, NavigateDown);
2273 return _callSuper(this, NavigateDown, arguments);
2274 }
2275 (0, _inherits2.default)(NavigateDown, _CommandBase);
2276 return (0, _createClass2.default)(NavigateDown, [{
2277 key: "apply",
2278 value: function apply() {
2279 this.component.getItemsView().activateNextItem();
2280 }
2281 }]);
2282 }(_commandBase.default);
2283 var _default = exports["default"] = NavigateDown;
2284
2285 /***/ }),
2286
2287 /***/ "../core/common/modules/finder/assets/js/commands/navigate-select.js":
2288 /*!***************************************************************************!*\
2289 !*** ../core/common/modules/finder/assets/js/commands/navigate-select.js ***!
2290 \***************************************************************************/
2291 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2292
2293 "use strict";
2294
2295
2296 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2297 Object.defineProperty(exports, "__esModule", ({
2298 value: true
2299 }));
2300 exports["default"] = exports.NavigateSelect = void 0;
2301 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2302 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2303 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2304 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2305 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2306 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2307 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)); }
2308 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2309 var NavigateSelect = exports.NavigateSelect = /*#__PURE__*/function (_CommandBase) {
2310 function NavigateSelect() {
2311 (0, _classCallCheck2.default)(this, NavigateSelect);
2312 return _callSuper(this, NavigateSelect, arguments);
2313 }
2314 (0, _inherits2.default)(NavigateSelect, _CommandBase);
2315 return (0, _createClass2.default)(NavigateSelect, [{
2316 key: "apply",
2317 value: function apply(args) {
2318 this.component.getItemsView().goToActiveItem(args);
2319 }
2320 }]);
2321 }(_commandBase.default);
2322 var _default = exports["default"] = NavigateSelect;
2323
2324 /***/ }),
2325
2326 /***/ "../core/common/modules/finder/assets/js/commands/navigate-up.js":
2327 /*!***********************************************************************!*\
2328 !*** ../core/common/modules/finder/assets/js/commands/navigate-up.js ***!
2329 \***********************************************************************/
2330 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2331
2332 "use strict";
2333
2334
2335 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2336 Object.defineProperty(exports, "__esModule", ({
2337 value: true
2338 }));
2339 exports["default"] = exports.NavigateUp = void 0;
2340 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2341 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2342 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2343 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2344 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2345 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2346 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)); }
2347 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2348 var NavigateUp = exports.NavigateUp = /*#__PURE__*/function (_CommandBase) {
2349 function NavigateUp() {
2350 (0, _classCallCheck2.default)(this, NavigateUp);
2351 return _callSuper(this, NavigateUp, arguments);
2352 }
2353 (0, _inherits2.default)(NavigateUp, _CommandBase);
2354 return (0, _createClass2.default)(NavigateUp, [{
2355 key: "apply",
2356 value: function apply() {
2357 this.component.getItemsView().activateNextItem(true);
2358 }
2359 }]);
2360 }(_commandBase.default);
2361 var _default = exports["default"] = NavigateUp;
2362
2363 /***/ }),
2364
2365 /***/ "../core/common/modules/finder/assets/js/component.js":
2366 /*!************************************************************!*\
2367 !*** ../core/common/modules/finder/assets/js/component.js ***!
2368 \************************************************************/
2369 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2370
2371 "use strict";
2372
2373
2374 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2375 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2376 Object.defineProperty(exports, "__esModule", ({
2377 value: true
2378 }));
2379 exports["default"] = void 0;
2380 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2381 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2382 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2383 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2384 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2385 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2386 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2387 var _componentModalBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-modal-base */ "../modules/web-cli/assets/js/modules/component-modal-base.js"));
2388 var _layout = _interopRequireDefault(__webpack_require__(/*! ./modal/views/layout */ "../core/common/modules/finder/assets/js/modal/views/layout.js"));
2389 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../core/common/modules/finder/assets/js/commands/index.js"));
2390 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); }
2391 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; }
2392 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; }
2393 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)); }
2394 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2395 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; }
2396 var Component = exports["default"] = /*#__PURE__*/function (_ComponentModalBase) {
2397 function Component() {
2398 (0, _classCallCheck2.default)(this, Component);
2399 return _callSuper(this, Component, arguments);
2400 }
2401 (0, _inherits2.default)(Component, _ComponentModalBase);
2402 return (0, _createClass2.default)(Component, [{
2403 key: "getNamespace",
2404 value: function getNamespace() {
2405 return 'finder';
2406 }
2407 }, {
2408 key: "defaultShortcuts",
2409 value: function defaultShortcuts() {
2410 var _this = this;
2411 return {
2412 '': {
2413 keys: 'ctrl+e'
2414 },
2415 'navigate-down': {
2416 keys: 'down',
2417 scopes: [this.getNamespace()],
2418 dependency: function dependency() {
2419 return _this.getItemsView();
2420 }
2421 },
2422 'navigate-up': {
2423 keys: 'up',
2424 scopes: [this.getNamespace()],
2425 dependency: function dependency() {
2426 return _this.getItemsView();
2427 }
2428 },
2429 'navigate-select': {
2430 keys: 'enter',
2431 scopes: [this.getNamespace()],
2432 dependency: function dependency() {
2433 return _this.getItemsView().$activeItem;
2434 }
2435 }
2436 };
2437 }
2438 }, {
2439 key: "defaultCommands",
2440 value: function defaultCommands() {
2441 var modalCommands = _superPropGet(Component, "defaultCommands", this, 3)([]);
2442 return _objectSpread(_objectSpread({
2443 'navigate/down': function navigate_down() {
2444 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/down' )", '3.0.0', "$e.run( 'finder/navigate-down' )");
2445 $e.run('finder/navigate-down');
2446 },
2447 'navigate/up': function navigate_up() {
2448 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/up' )", '3.0.0', "$e.run( 'finder/navigate-up' )");
2449 $e.run('finder/navigate-up');
2450 },
2451 'navigate/select': function navigate_select(event) {
2452 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/select', event )", '3.0.0', "$e.run( 'finder/navigate-select', event )");
2453
2454 // TODO: Fix $e.shortcuts use args. ( args.event ).
2455 $e.run('finder/navigate-select', event);
2456 }
2457 }, modalCommands), this.importCommands(commands));
2458 }
2459 }, {
2460 key: "getModalLayout",
2461 value: function getModalLayout() {
2462 return _layout.default;
2463 }
2464 }, {
2465 key: "getItemsView",
2466 value: function getItemsView() {
2467 return this.layout.modalContent.currentView.content.currentView;
2468 }
2469 }]);
2470 }(_componentModalBase.default);
2471
2472 /***/ }),
2473
2474 /***/ "../core/common/modules/finder/assets/js/finder.js":
2475 /*!*********************************************************!*\
2476 !*** ../core/common/modules/finder/assets/js/finder.js ***!
2477 \*********************************************************/
2478 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2479
2480 "use strict";
2481
2482
2483 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2484 Object.defineProperty(exports, "__esModule", ({
2485 value: true
2486 }));
2487 exports["default"] = void 0;
2488 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2489 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2490 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2491 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2492 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2493 var _component = _interopRequireDefault(__webpack_require__(/*! ./component */ "../core/common/modules/finder/assets/js/component.js"));
2494 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)); }
2495 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2496 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2497 function _default() {
2498 (0, _classCallCheck2.default)(this, _default);
2499 return _callSuper(this, _default, arguments);
2500 }
2501 (0, _inherits2.default)(_default, _elementorModules$Mod);
2502 return (0, _createClass2.default)(_default, [{
2503 key: "onInit",
2504 value: function onInit() {
2505 // TODO: Temp fix, do not load finder in theme-builder.
2506 // Better to pass into '$e' constructor the app owner. ( admin, editor, preview, iframe ).
2507 if (window.top !== window) {
2508 return;
2509 }
2510 this.channel = Backbone.Radio.channel('ELEMENTOR:finder');
2511 $e.components.register(new _component.default({
2512 manager: this
2513 }));
2514 }
2515 }]);
2516 }(elementorModules.Module);
2517
2518 /***/ }),
2519
2520 /***/ "../core/common/modules/finder/assets/js/modal/model/item.js":
2521 /*!*******************************************************************!*\
2522 !*** ../core/common/modules/finder/assets/js/modal/model/item.js ***!
2523 \*******************************************************************/
2524 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2525
2526 "use strict";
2527
2528
2529 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2530 Object.defineProperty(exports, "__esModule", ({
2531 value: true
2532 }));
2533 exports["default"] = void 0;
2534 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2535 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2536 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2537 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2538 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2539 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)); }
2540 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2541 var _default = exports["default"] = /*#__PURE__*/function (_Backbone$Model) {
2542 function _default() {
2543 (0, _classCallCheck2.default)(this, _default);
2544 return _callSuper(this, _default, arguments);
2545 }
2546 (0, _inherits2.default)(_default, _Backbone$Model);
2547 return (0, _createClass2.default)(_default, [{
2548 key: "defaults",
2549 value: function defaults() {
2550 return {
2551 description: '',
2552 icon: 'settings',
2553 url: '',
2554 keywords: [],
2555 actions: [],
2556 lock: null
2557 };
2558 }
2559 }]);
2560 }(Backbone.Model);
2561
2562 /***/ }),
2563
2564 /***/ "../core/common/modules/finder/assets/js/modal/views/categories.js":
2565 /*!*************************************************************************!*\
2566 !*** ../core/common/modules/finder/assets/js/modal/views/categories.js ***!
2567 \*************************************************************************/
2568 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2569
2570 "use strict";
2571
2572
2573 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2574 Object.defineProperty(exports, "__esModule", ({
2575 value: true
2576 }));
2577 exports["default"] = void 0;
2578 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2579 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2580 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2581 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2582 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2583 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
2584 var _dynamicCategory = _interopRequireDefault(__webpack_require__(/*! ./dynamic-category */ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js"));
2585 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)); }
2586 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2587 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
2588 function _default() {
2589 (0, _classCallCheck2.default)(this, _default);
2590 return _callSuper(this, _default, arguments);
2591 }
2592 (0, _inherits2.default)(_default, _Marionette$Composite);
2593 return (0, _createClass2.default)(_default, [{
2594 key: "id",
2595 value: function id() {
2596 return 'elementor-finder__results-container';
2597 }
2598 }, {
2599 key: "ui",
2600 value: function ui() {
2601 this.selectors = {
2602 noResults: '#elementor-finder__no-results',
2603 categoryItem: '.elementor-finder__results__item'
2604 };
2605 return this.selectors;
2606 }
2607 }, {
2608 key: "events",
2609 value: function events() {
2610 return {
2611 'mouseenter @ui.categoryItem': 'onCategoryItemMouseEnter'
2612 };
2613 }
2614 }, {
2615 key: "getTemplate",
2616 value: function getTemplate() {
2617 return '#tmpl-elementor-finder-results-container';
2618 }
2619 }, {
2620 key: "getChildView",
2621 value: function getChildView(childModel) {
2622 return childModel.get('dynamic') ? _dynamicCategory.default : _category.default;
2623 }
2624 }, {
2625 key: "initialize",
2626 value: function initialize() {
2627 this.$activeItem = null;
2628 this.childViewContainer = '#elementor-finder__results';
2629 this.collection = new Backbone.Collection(Object.values(elementorCommon.finder.getSettings('data')));
2630 }
2631 }, {
2632 key: "activateItem",
2633 value: function activateItem($item) {
2634 if (this.$activeItem) {
2635 this.$activeItem.removeClass('elementor-active');
2636 }
2637 $item.addClass('elementor-active');
2638 this.$activeItem = $item;
2639 }
2640 }, {
2641 key: "activateNextItem",
2642 value: function activateNextItem(reverse) {
2643 var $allItems = jQuery(this.selectors.categoryItem);
2644 var nextItemIndex = 0;
2645 if (this.$activeItem) {
2646 nextItemIndex = $allItems.index(this.$activeItem) + (reverse ? -1 : 1);
2647 if (nextItemIndex >= $allItems.length) {
2648 nextItemIndex = 0;
2649 } else if (nextItemIndex < 0) {
2650 nextItemIndex = $allItems.length - 1;
2651 }
2652 }
2653 var $nextItem = $allItems.eq(nextItemIndex);
2654 this.activateItem($nextItem);
2655 $nextItem[0].scrollIntoView({
2656 block: 'nearest'
2657 });
2658 }
2659 }, {
2660 key: "goToActiveItem",
2661 value: function goToActiveItem(event) {
2662 var $a = this.$activeItem.children('a'),
2663 isControlClicked = $e.shortcuts.isControlEvent(event);
2664 if (isControlClicked) {
2665 $a.attr('target', '_blank');
2666 }
2667 $a[0].click();
2668 if (isControlClicked) {
2669 $a.removeAttr('target');
2670 }
2671 }
2672 }, {
2673 key: "onCategoryItemMouseEnter",
2674 value: function onCategoryItemMouseEnter(event) {
2675 this.activateItem(jQuery(event.currentTarget));
2676 }
2677 }, {
2678 key: "onChildviewToggleVisibility",
2679 value: function onChildviewToggleVisibility() {
2680 var allCategoriesAreEmpty = this.children.every(function (child) {
2681 return !child.isVisible;
2682 });
2683 this.ui.noResults.toggle(allCategoriesAreEmpty);
2684 }
2685 }]);
2686 }(Marionette.CompositeView);
2687
2688 /***/ }),
2689
2690 /***/ "../core/common/modules/finder/assets/js/modal/views/category.js":
2691 /*!***********************************************************************!*\
2692 !*** ../core/common/modules/finder/assets/js/modal/views/category.js ***!
2693 \***********************************************************************/
2694 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2695
2696 "use strict";
2697
2698
2699 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2700 Object.defineProperty(exports, "__esModule", ({
2701 value: true
2702 }));
2703 exports["default"] = void 0;
2704 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2705 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2706 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2707 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2708 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2709 var _item = _interopRequireDefault(__webpack_require__(/*! ./item */ "../core/common/modules/finder/assets/js/modal/views/item.js"));
2710 var _item2 = _interopRequireDefault(__webpack_require__(/*! ../model/item */ "../core/common/modules/finder/assets/js/modal/model/item.js"));
2711 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)); }
2712 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2713 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
2714 function _default() {
2715 (0, _classCallCheck2.default)(this, _default);
2716 return _callSuper(this, _default, arguments);
2717 }
2718 (0, _inherits2.default)(_default, _Marionette$Composite);
2719 return (0, _createClass2.default)(_default, [{
2720 key: "className",
2721 value: function className() {
2722 return 'elementor-finder__results__category';
2723 }
2724 }, {
2725 key: "getTemplate",
2726 value: function getTemplate() {
2727 return '#tmpl-elementor-finder__results__category';
2728 }
2729 }, {
2730 key: "getChildView",
2731 value: function getChildView() {
2732 return _item.default;
2733 }
2734 }, {
2735 key: "initialize",
2736 value: function initialize() {
2737 this.childViewContainer = '.elementor-finder__results__category__items';
2738 this.isVisible = true;
2739 var items = this.model.get('items');
2740 if (items) {
2741 items = Object.values(items);
2742 }
2743 this.collection = new Backbone.Collection(items, {
2744 model: _item2.default
2745 });
2746 }
2747 }, {
2748 key: "filter",
2749 value: function filter(childModel) {
2750 var textFilter = this.getTextFilter();
2751 if (childModel.get('title').toLowerCase().indexOf(textFilter) >= 0) {
2752 return true;
2753 }
2754 return childModel.get('keywords').some(function (keyword) {
2755 return keyword.indexOf(textFilter) >= 0;
2756 });
2757 }
2758 }, {
2759 key: "getTextFilter",
2760 value: function getTextFilter() {
2761 return elementorCommon.finder.channel.request('filter:text').trim().toLowerCase();
2762 }
2763 }, {
2764 key: "toggleElement",
2765 value: function toggleElement() {
2766 var isCurrentlyVisible = !!this.children.length;
2767 if (isCurrentlyVisible !== this.isVisible) {
2768 this.isVisible = isCurrentlyVisible;
2769 this.$el.toggle(isCurrentlyVisible);
2770 this.triggerMethod('toggle:visibility');
2771 }
2772 }
2773 }, {
2774 key: "onRender",
2775 value: function onRender() {
2776 this.listenTo(elementorCommon.finder.channel, 'filter:change', this.onFilterChange.bind(this));
2777 }
2778 }, {
2779 key: "onFilterChange",
2780 value: function onFilterChange() {
2781 this._renderChildren();
2782 }
2783 }, {
2784 key: "onRenderCollection",
2785 value: function onRenderCollection() {
2786 this.toggleElement();
2787 }
2788 }]);
2789 }(Marionette.CompositeView);
2790
2791 /***/ }),
2792
2793 /***/ "../core/common/modules/finder/assets/js/modal/views/content.js":
2794 /*!**********************************************************************!*\
2795 !*** ../core/common/modules/finder/assets/js/modal/views/content.js ***!
2796 \**********************************************************************/
2797 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2798
2799 "use strict";
2800
2801
2802 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2803 Object.defineProperty(exports, "__esModule", ({
2804 value: true
2805 }));
2806 exports["default"] = void 0;
2807 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2808 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2809 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2810 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2811 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2812 var _categories = _interopRequireDefault(__webpack_require__(/*! ./categories */ "../core/common/modules/finder/assets/js/modal/views/categories.js"));
2813 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)); }
2814 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2815 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$LayoutVie) {
2816 function _default() {
2817 (0, _classCallCheck2.default)(this, _default);
2818 return _callSuper(this, _default, arguments);
2819 }
2820 (0, _inherits2.default)(_default, _Marionette$LayoutVie);
2821 return (0, _createClass2.default)(_default, [{
2822 key: "id",
2823 value: function id() {
2824 return 'elementor-finder';
2825 }
2826 }, {
2827 key: "getTemplate",
2828 value: function getTemplate() {
2829 return '#tmpl-elementor-finder';
2830 }
2831 }, {
2832 key: "ui",
2833 value: function ui() {
2834 return {
2835 searchInput: '#elementor-finder__search__input'
2836 };
2837 }
2838 }, {
2839 key: "events",
2840 value: function events() {
2841 return {
2842 'input @ui.searchInput': 'onSearchInputInput'
2843 };
2844 }
2845 }, {
2846 key: "regions",
2847 value: function regions() {
2848 return {
2849 content: '#elementor-finder__content'
2850 };
2851 }
2852 }, {
2853 key: "showCategoriesView",
2854 value: function showCategoriesView() {
2855 this.content.show(new _categories.default());
2856 }
2857 }, {
2858 key: "onSearchInputInput",
2859 value: function onSearchInputInput() {
2860 var value = this.ui.searchInput.val();
2861 if (value) {
2862 elementorCommon.finder.channel.reply('filter:text', value).trigger('filter:change');
2863 if (!(this.content.currentView instanceof _categories.default)) {
2864 this.showCategoriesView();
2865 }
2866 }
2867 this.content.currentView.$el.toggle(!!value);
2868 }
2869 }]);
2870 }(Marionette.LayoutView);
2871
2872 /***/ }),
2873
2874 /***/ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js":
2875 /*!*******************************************************************************!*\
2876 !*** ../core/common/modules/finder/assets/js/modal/views/dynamic-category.js ***!
2877 \*******************************************************************************/
2878 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2879
2880 "use strict";
2881
2882
2883 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2884 Object.defineProperty(exports, "__esModule", ({
2885 value: true
2886 }));
2887 exports["default"] = void 0;
2888 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2889 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2890 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2891 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2892 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2893 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2894 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
2895 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)); }
2896 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2897 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; }
2898 var _default = exports["default"] = /*#__PURE__*/function (_Category) {
2899 function _default() {
2900 (0, _classCallCheck2.default)(this, _default);
2901 return _callSuper(this, _default, arguments);
2902 }
2903 (0, _inherits2.default)(_default, _Category);
2904 return (0, _createClass2.default)(_default, [{
2905 key: "className",
2906 value: function className() {
2907 return _superPropGet(_default, "className", this, 3)([]) + ' elementor-finder__results__category--dynamic';
2908 }
2909 }, {
2910 key: "ui",
2911 value: function ui() {
2912 return {
2913 title: '.elementor-finder__results__category__title'
2914 };
2915 }
2916 }, {
2917 key: "fetchData",
2918 value: function fetchData() {
2919 var _this = this;
2920 this.ui.loadingIcon.show();
2921 elementorCommon.ajax.addRequest('finder_get_category_items', {
2922 data: {
2923 category: this.model.get('name'),
2924 filter: this.getTextFilter()
2925 },
2926 success: function success(data) {
2927 if (_this.isDestroyed) {
2928 return;
2929 }
2930 _this.collection.set(data);
2931 _this.toggleElement();
2932 _this.ui.loadingIcon.hide();
2933 }
2934 });
2935 }
2936 }, {
2937 key: "filter",
2938 value: function filter() {
2939 return true;
2940 }
2941 }, {
2942 key: "onFilterChange",
2943 value: function onFilterChange() {
2944 this.fetchData();
2945 }
2946 }, {
2947 key: "onRender",
2948 value: function onRender() {
2949 _superPropGet(_default, "onRender", this, 3)([]);
2950 this.ui.loadingIcon = jQuery('<i>', {
2951 class: 'eicon-loading eicon-animation-spin'
2952 });
2953 this.ui.title.after(this.ui.loadingIcon);
2954 this.fetchData();
2955 }
2956 }]);
2957 }(_category.default);
2958
2959 /***/ }),
2960
2961 /***/ "../core/common/modules/finder/assets/js/modal/views/item.js":
2962 /*!*******************************************************************!*\
2963 !*** ../core/common/modules/finder/assets/js/modal/views/item.js ***!
2964 \*******************************************************************/
2965 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2966
2967 "use strict";
2968 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
2969
2970
2971 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2972 Object.defineProperty(exports, "__esModule", ({
2973 value: true
2974 }));
2975 exports["default"] = void 0;
2976 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2977 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2978 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2979 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2980 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2981 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)); }
2982 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2983 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$ItemView) {
2984 function _default() {
2985 (0, _classCallCheck2.default)(this, _default);
2986 return _callSuper(this, _default, arguments);
2987 }
2988 (0, _inherits2.default)(_default, _Marionette$ItemView);
2989 return (0, _createClass2.default)(_default, [{
2990 key: "className",
2991 value: function className() {
2992 return 'elementor-finder__results__item';
2993 }
2994 }, {
2995 key: "getTemplate",
2996 value: function getTemplate() {
2997 return '#tmpl-elementor-finder__results__item';
2998 }
2999 }, {
3000 key: "events",
3001 value: function events() {
3002 this.$el[0].addEventListener('click', this.onClick.bind(this), true);
3003 }
3004 }, {
3005 key: "onClick",
3006 value: function onClick(e) {
3007 var _this = this;
3008 var lockOptions = this.model.get('lock');
3009 if (!(lockOptions !== null && lockOptions !== void 0 && lockOptions.is_locked)) {
3010 return;
3011 }
3012 e.preventDefault();
3013 e.stopImmediatePropagation();
3014 elementorCommon.dialogsManager.createWidget('confirm', {
3015 id: 'elementor-finder__lock-dialog',
3016 headerMessage: lockOptions.content.heading,
3017 message: lockOptions.content.description,
3018 position: {
3019 my: 'center center',
3020 at: 'center center'
3021 },
3022 strings: {
3023 confirm: lockOptions.button.text,
3024 cancel: __('Cancel', 'elementor')
3025 },
3026 onConfirm: function onConfirm() {
3027 var link = _this.replaceLockLinkPlaceholders(lockOptions.button.url);
3028 window.open(link, '_blank');
3029 }
3030 }).show();
3031 }
3032 }, {
3033 key: "replaceLockLinkPlaceholders",
3034 value: function replaceLockLinkPlaceholders(link) {
3035 return link.replace(/%%utm_source%%/g, 'finder').replace(/%%utm_medium%%/g, 'wp-dash');
3036 }
3037 }]);
3038 }(Marionette.ItemView);
3039
3040 /***/ }),
3041
3042 /***/ "../core/common/modules/finder/assets/js/modal/views/layout.js":
3043 /*!*********************************************************************!*\
3044 !*** ../core/common/modules/finder/assets/js/modal/views/layout.js ***!
3045 \*********************************************************************/
3046 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3047
3048 "use strict";
3049 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3050
3051
3052 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3053 Object.defineProperty(exports, "__esModule", ({
3054 value: true
3055 }));
3056 exports["default"] = void 0;
3057 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3058 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3059 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3060 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3061 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3062 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3063 var _content = _interopRequireDefault(__webpack_require__(/*! ./content */ "../core/common/modules/finder/assets/js/modal/views/content.js"));
3064 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)); }
3065 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3066 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; }
3067 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$com) {
3068 function _default() {
3069 (0, _classCallCheck2.default)(this, _default);
3070 return _callSuper(this, _default, arguments);
3071 }
3072 (0, _inherits2.default)(_default, _elementorModules$com);
3073 return (0, _createClass2.default)(_default, [{
3074 key: "getModalOptions",
3075 value: function getModalOptions() {
3076 return {
3077 id: 'elementor-finder__modal',
3078 draggable: true,
3079 effects: {
3080 show: 'show',
3081 hide: 'hide'
3082 },
3083 position: {
3084 enable: false
3085 }
3086 };
3087 }
3088 }, {
3089 key: "getLogoOptions",
3090 value: function getLogoOptions() {
3091 return {
3092 title: __('Finder', 'elementor')
3093 };
3094 }
3095 }, {
3096 key: "initialize",
3097 value: function initialize() {
3098 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3099 args[_key] = arguments[_key];
3100 }
3101 _superPropGet(_default, "initialize", this, 3)(args);
3102 this.showLogo();
3103 this.showContentView();
3104 }
3105 }, {
3106 key: "showContentView",
3107 value: function showContentView() {
3108 this.modalContent.show(new _content.default());
3109 }
3110 }, {
3111 key: "showModal",
3112 value: function showModal() {
3113 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3114 args[_key2] = arguments[_key2];
3115 }
3116 _superPropGet(_default, "showModal", this, 3)(args);
3117 this.modalContent.currentView.ui.searchInput.focus();
3118 }
3119 }]);
3120 }(elementorModules.common.views.modal.Layout);
3121
3122 /***/ }),
3123
3124 /***/ "../modules/web-cli/assets/js/core/data/errors/base-error.js":
3125 /*!*******************************************************************!*\
3126 !*** ../modules/web-cli/assets/js/core/data/errors/base-error.js ***!
3127 \*******************************************************************/
3128 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3129
3130 "use strict";
3131
3132
3133 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3134 Object.defineProperty(exports, "__esModule", ({
3135 value: true
3136 }));
3137 exports["default"] = void 0;
3138 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3139 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3140 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3141 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3142 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3143 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
3144 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3145 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3146 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../../../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
3147 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; }
3148 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; }
3149 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)); }
3150 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3151 var BaseError = exports["default"] = /*#__PURE__*/function (_Error) {
3152 /**
3153 * Error constructor.
3154 *
3155 * @param {string} message
3156 * @param {string} code
3157 * @param {*} data
3158 */
3159 function BaseError() {
3160 var _this;
3161 var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
3162 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3163 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3164 (0, _classCallCheck2.default)(this, BaseError);
3165 _this = _callSuper(this, BaseError, [message]);
3166 /**
3167 * The server error code.
3168 *
3169 * @type {string}
3170 */
3171 (0, _defineProperty2.default)(_this, "code", '');
3172 /**
3173 * Additional data about the current error.
3174 *
3175 * @type {*[]}
3176 */
3177 (0, _defineProperty2.default)(_this, "data", []);
3178 _this.code = code;
3179 _this.data = data;
3180 return _this;
3181 }
3182
3183 /**
3184 * Notify a message when the error occurs.
3185 */
3186 (0, _inherits2.default)(BaseError, _Error);
3187 return (0, _createClass2.default)(BaseError, [{
3188 key: "notify",
3189 value: function notify() {
3190 _console.default.error(_objectSpread({
3191 message: this.message
3192 }, this));
3193 }
3194 }], [{
3195 key: "create",
3196 value:
3197 /**
3198 * Static helper function to create the error.
3199 *
3200 * @param {string} message
3201 * @param {string} code
3202 * @param {*} data
3203 * @return {BaseError} error
3204 */
3205 function create(message) {
3206 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3207 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3208 return new this(message, code, data);
3209 }
3210
3211 /**
3212 * Returns the status code of the error.
3213 */
3214 }, {
3215 key: "getHTTPErrorCode",
3216 value: function getHTTPErrorCode() {
3217 (0, _forceMethodImplementation.default)();
3218 }
3219 }]);
3220 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
3221
3222 /***/ }),
3223
3224 /***/ "../modules/web-cli/assets/js/core/data/errors/default-error.js":
3225 /*!**********************************************************************!*\
3226 !*** ../modules/web-cli/assets/js/core/data/errors/default-error.js ***!
3227 \**********************************************************************/
3228 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3229
3230 "use strict";
3231
3232
3233 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3234 Object.defineProperty(exports, "__esModule", ({
3235 value: true
3236 }));
3237 exports["default"] = exports.DefaultError = void 0;
3238 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3239 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3240 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3241 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3242 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3243 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3244 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)); }
3245 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3246 var DefaultError = exports.DefaultError = /*#__PURE__*/function (_BaseError) {
3247 function DefaultError() {
3248 (0, _classCallCheck2.default)(this, DefaultError);
3249 return _callSuper(this, DefaultError, arguments);
3250 }
3251 (0, _inherits2.default)(DefaultError, _BaseError);
3252 return (0, _createClass2.default)(DefaultError, null, [{
3253 key: "getHTTPErrorCode",
3254 value: function getHTTPErrorCode() {
3255 return 501;
3256 }
3257 }]);
3258 }(_baseError.default);
3259 var _default = exports["default"] = DefaultError;
3260
3261 /***/ }),
3262
3263 /***/ "../modules/web-cli/assets/js/core/data/errors/error-404.js":
3264 /*!******************************************************************!*\
3265 !*** ../modules/web-cli/assets/js/core/data/errors/error-404.js ***!
3266 \******************************************************************/
3267 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3268
3269 "use strict";
3270
3271
3272 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3273 Object.defineProperty(exports, "__esModule", ({
3274 value: true
3275 }));
3276 exports["default"] = exports.Error404 = void 0;
3277 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3278 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3279 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3280 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3281 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3282 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3283 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3284 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)); }
3285 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3286 var Error404 = exports.Error404 = /*#__PURE__*/function (_BaseError) {
3287 function Error404() {
3288 (0, _classCallCheck2.default)(this, Error404);
3289 return _callSuper(this, Error404, arguments);
3290 }
3291 (0, _inherits2.default)(Error404, _BaseError);
3292 return (0, _createClass2.default)(Error404, [{
3293 key: "notify",
3294 value: function notify() {
3295 _console.default.warn(this.message);
3296 }
3297 }], [{
3298 key: "getHTTPErrorCode",
3299 value: function getHTTPErrorCode() {
3300 return 404;
3301 }
3302 }]);
3303 }(_baseError.default);
3304 var _default = exports["default"] = Error404;
3305
3306 /***/ }),
3307
3308 /***/ "../modules/web-cli/assets/js/core/data/errors/index.js":
3309 /*!**************************************************************!*\
3310 !*** ../modules/web-cli/assets/js/core/data/errors/index.js ***!
3311 \**************************************************************/
3312 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3313
3314 "use strict";
3315
3316
3317 Object.defineProperty(exports, "__esModule", ({
3318 value: true
3319 }));
3320 Object.defineProperty(exports, "DefaultError", ({
3321 enumerable: true,
3322 get: function get() {
3323 return _defaultError.DefaultError;
3324 }
3325 }));
3326 Object.defineProperty(exports, "Error404", ({
3327 enumerable: true,
3328 get: function get() {
3329 return _error.Error404;
3330 }
3331 }));
3332 var _defaultError = __webpack_require__(/*! ./default-error */ "../modules/web-cli/assets/js/core/data/errors/default-error.js");
3333 var _error = __webpack_require__(/*! ./error-404 */ "../modules/web-cli/assets/js/core/data/errors/error-404.js");
3334
3335 /***/ }),
3336
3337 /***/ "../modules/web-cli/assets/js/modules/command-base.js":
3338 /*!************************************************************!*\
3339 !*** ../modules/web-cli/assets/js/modules/command-base.js ***!
3340 \************************************************************/
3341 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3342
3343 "use strict";
3344
3345
3346 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3347 Object.defineProperty(exports, "__esModule", ({
3348 value: true
3349 }));
3350 exports["default"] = void 0;
3351 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3352 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3353 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3354 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3355 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3356 var _commandInfra = _interopRequireDefault(__webpack_require__(/*! ./command-infra */ "../modules/web-cli/assets/js/modules/command-infra.js"));
3357 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3358 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)); }
3359 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3360 /**
3361 * @name $e.modules.CommandBase
3362 */
3363 var CommandBase = exports["default"] = /*#__PURE__*/function (_CommandInfra) {
3364 function CommandBase() {
3365 (0, _classCallCheck2.default)(this, CommandBase);
3366 return _callSuper(this, CommandBase, arguments);
3367 }
3368 (0, _inherits2.default)(CommandBase, _CommandInfra);
3369 return (0, _createClass2.default)(CommandBase, [{
3370 key: "onBeforeRun",
3371 value: function onBeforeRun() {
3372 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3373 $e.hooks.runUIBefore(this.command, args);
3374 }
3375 }, {
3376 key: "onAfterRun",
3377 value: function onAfterRun() {
3378 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3379 var result = arguments.length > 1 ? arguments[1] : undefined;
3380 $e.hooks.runUIAfter(this.command, args, result);
3381 }
3382 }, {
3383 key: "onBeforeApply",
3384 value: function onBeforeApply() {
3385 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3386 $e.hooks.runDataDependency(this.command, args);
3387 }
3388 }, {
3389 key: "onAfterApply",
3390 value: function onAfterApply() {
3391 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3392 var result = arguments.length > 1 ? arguments[1] : undefined;
3393 return $e.hooks.runDataAfter(this.command, args, result);
3394 }
3395 }, {
3396 key: "onCatchApply",
3397 value: function onCatchApply(e) {
3398 this.runCatchHooks(e);
3399 }
3400
3401 /**
3402 * Run all the catch hooks.
3403 *
3404 * @param {Error} e
3405 */
3406 }, {
3407 key: "runCatchHooks",
3408 value: function runCatchHooks(e) {
3409 $e.hooks.runDataCatch(this.command, this.args, e);
3410 $e.hooks.runUICatch(this.command, this.args, e);
3411 }
3412
3413 /**
3414 * TODO - Remove - Backwards compatibility.
3415 *
3416 * Function requireContainer().
3417 *
3418 * Validate `arg.container` & `arg.containers`.
3419 *
3420 * @param {{}} args
3421 * @deprecated since 3.7.0, extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase` instead.
3422 *
3423 * @throws {Error}
3424 */
3425 }, {
3426 key: "requireContainer",
3427 value: function requireContainer() {
3428 var _this = this;
3429 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
3430 _deprecation.default.deprecated('requireContainer()', '3.7.0', 'Extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase`');
3431 if (!args.container && !args.containers) {
3432 throw Error('container or containers are required.');
3433 }
3434 if (args.container && args.containers) {
3435 throw Error('container and containers cannot go together please select one of them.');
3436 }
3437 var containers = args.containers || [args.container];
3438 containers.forEach(function (container) {
3439 _this.requireArgumentInstance('container', elementorModules.editor.Container, {
3440 container: container
3441 });
3442 });
3443 }
3444 }], [{
3445 key: "getInstanceType",
3446 value: function getInstanceType() {
3447 return 'CommandBase';
3448 }
3449 }]);
3450 }(_commandInfra.default);
3451
3452 /***/ }),
3453
3454 /***/ "../modules/web-cli/assets/js/modules/command-callback-base.js":
3455 /*!*********************************************************************!*\
3456 !*** ../modules/web-cli/assets/js/modules/command-callback-base.js ***!
3457 \*********************************************************************/
3458 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3459
3460 "use strict";
3461
3462
3463 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3464 Object.defineProperty(exports, "__esModule", ({
3465 value: true
3466 }));
3467 exports["default"] = void 0;
3468 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3469 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3470 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3471 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3472 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3473 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3474 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)); }
3475 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3476 /**
3477 * To support pure callbacks in the API(commands.js), to ensure they have registered with the proper context.
3478 */
3479 var CommandCallbackBase = exports["default"] = /*#__PURE__*/function (_CommandBase) {
3480 function CommandCallbackBase() {
3481 (0, _classCallCheck2.default)(this, CommandCallbackBase);
3482 return _callSuper(this, CommandCallbackBase, arguments);
3483 }
3484 (0, _inherits2.default)(CommandCallbackBase, _CommandBase);
3485 return (0, _createClass2.default)(CommandCallbackBase, [{
3486 key: "apply",
3487 value: function apply() {
3488 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3489 return this.constructor.getCallback()(args);
3490 }
3491 }], [{
3492 key: "getInstanceType",
3493 value: function getInstanceType() {
3494 return 'CommandCallbackBase';
3495 }
3496
3497 /**
3498 * Get original callback of the command.
3499 *
3500 * Support pure callbacks ( Non command-base ).
3501 *
3502 * @return {()=>{}} Command Results.
3503 */
3504 }, {
3505 key: "getCallback",
3506 value: function getCallback() {
3507 return this.registerConfig.callback;
3508 }
3509 }]);
3510 }(_commandBase.default);
3511
3512 /***/ }),
3513
3514 /***/ "../modules/web-cli/assets/js/modules/command-data.js":
3515 /*!************************************************************!*\
3516 !*** ../modules/web-cli/assets/js/modules/command-data.js ***!
3517 \************************************************************/
3518 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3519
3520 "use strict";
3521
3522
3523 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3524 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
3525 Object.defineProperty(exports, "__esModule", ({
3526 value: true
3527 }));
3528 exports["default"] = void 0;
3529 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3530 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3531 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3532 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3533 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3534 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3535 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3536 var errors = _interopRequireWildcard(__webpack_require__(/*! ../core/data/errors/ */ "../modules/web-cli/assets/js/core/data/errors/index.js"));
3537 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); }
3538 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)); }
3539 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3540 /**
3541 * @name $e.modules.CommandData
3542 */
3543 /**
3544 * @typedef {('create'|'delete'|'get'|'update'|'options')} DataTypes
3545 */
3546 /**
3547 * @typedef {{}} RequestData
3548 */
3549 /**
3550 * @typedef {import('../core/data/errors/base-error')} BaseError
3551 */
3552 var CommandData = exports["default"] = /*#__PURE__*/function (_CommandBase) {
3553 function CommandData(args) {
3554 var _this$args$options;
3555 var _this;
3556 var commandsAPI = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $e.data;
3557 (0, _classCallCheck2.default)(this, CommandData);
3558 _this = _callSuper(this, CommandData, [args, commandsAPI]);
3559 /**
3560 * Data returned from remote.
3561 *
3562 * @type {*}
3563 */
3564 (0, _defineProperty2.default)(_this, "data", void 0);
3565 /**
3566 * Fetch type.
3567 *
3568 * @type {DataTypes}
3569 */
3570 (0, _defineProperty2.default)(_this, "type", void 0);
3571 if ((_this$args$options = _this.args.options) !== null && _this$args$options !== void 0 && _this$args$options.type) {
3572 _this.type = _this.args.options.type;
3573 }
3574 return _this;
3575 }
3576
3577 /**
3578 * Function getEndpointFormat().
3579 *
3580 * @return {null|string} endpoint format
3581 */
3582 (0, _inherits2.default)(CommandData, _CommandBase);
3583 return (0, _createClass2.default)(CommandData, [{
3584 key: "getApplyMethods",
3585 value:
3586 /**
3587 * @param {DataTypes} type
3588 *
3589 * @return {boolean|{before: (function(*=): {}), after: (function({}, *=): {})}} apply methods
3590 */
3591 function getApplyMethods() {
3592 var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.type;
3593 var before, after;
3594 switch (type) {
3595 case 'create':
3596 before = this.applyBeforeCreate;
3597 after = this.applyAfterCreate;
3598 break;
3599 case 'delete':
3600 before = this.applyBeforeDelete;
3601 after = this.applyAfterDelete;
3602 break;
3603 case 'get':
3604 before = this.applyBeforeGet;
3605 after = this.applyAfterGet;
3606 break;
3607 case 'update':
3608 before = this.applyBeforeUpdate;
3609 after = this.applyAfterUpdate;
3610 break;
3611 case 'options':
3612 before = this.applyBeforeOptions;
3613 after = this.applyAfterOptions;
3614 break;
3615 default:
3616 return false;
3617 }
3618 return {
3619 before: before.bind(this),
3620 after: after.bind(this)
3621 };
3622 }
3623
3624 /**
3625 * Function getRequestData().
3626 *
3627 * @return {RequestData} request data
3628 */
3629 }, {
3630 key: "getRequestData",
3631 value: function getRequestData() {
3632 return {
3633 type: this.type,
3634 args: this.args,
3635 timestamp: new Date().getTime(),
3636 component: this.component,
3637 command: this.command,
3638 endpoint: $e.data.commandToEndpoint(this.command, JSON.parse(JSON.stringify(this.args)), this.constructor.getEndpointFormat())
3639 };
3640 }
3641 }, {
3642 key: "apply",
3643 value: function apply() {
3644 var _this2 = this;
3645 var applyMethods = this.getApplyMethods();
3646
3647 // Run 'before' method.
3648 this.args = applyMethods.before(this.args);
3649 var requestData = this.getRequestData();
3650 return $e.data.fetch(requestData).then(function (data) {
3651 _this2.data = data;
3652
3653 // Run 'after' method.
3654 _this2.data = applyMethods.after(data, _this2.args);
3655 _this2.data = {
3656 data: _this2.data
3657 };
3658
3659 // Append requestData.
3660 _this2.data = Object.assign({
3661 __requestData__: requestData
3662 }, _this2.data);
3663 return _this2.data;
3664 });
3665 }
3666
3667 /**
3668 * @param {*} [args={}]
3669 * @return {{}} filtered args
3670 */
3671 }, {
3672 key: "applyBeforeCreate",
3673 value: function applyBeforeCreate() {
3674 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3675 return args;
3676 }
3677
3678 /**
3679 * @param {{}} data
3680 * @param {*} [args={}]
3681 * @return {{}} filtered result
3682 */
3683 }, {
3684 key: "applyAfterCreate",
3685 value: function applyAfterCreate(data) {
3686 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3687 // eslint-disable-line no-unused-vars
3688 return data;
3689 }
3690
3691 /**
3692 * @param {*} [args={}]
3693 * @return {{}} filtered args
3694 */
3695 }, {
3696 key: "applyBeforeDelete",
3697 value: function applyBeforeDelete() {
3698 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3699 return args;
3700 }
3701
3702 /**
3703 * @param {{}} data
3704 * @param {*} [args={}]
3705 * @return {{}} filtered result
3706 */
3707 }, {
3708 key: "applyAfterDelete",
3709 value: function applyAfterDelete(data) {
3710 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3711 // eslint-disable-line no-unused-vars
3712 return data;
3713 }
3714
3715 /**
3716 * @param {*} [args={}]
3717 * @return {{}} filtered args
3718 */
3719 }, {
3720 key: "applyBeforeGet",
3721 value: function applyBeforeGet() {
3722 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3723 return args;
3724 }
3725
3726 /**
3727 * @param {{}} data
3728 * @param {*} [args={}]
3729 * @return {{}} filtered result
3730 */
3731 }, {
3732 key: "applyAfterGet",
3733 value: function applyAfterGet(data) {
3734 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3735 // eslint-disable-line no-unused-vars
3736 return data;
3737 }
3738
3739 /**
3740 * @param {*} [args={}]
3741 * @return {{}} filtered args
3742 */
3743 }, {
3744 key: "applyBeforeUpdate",
3745 value: function applyBeforeUpdate() {
3746 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3747 return args;
3748 }
3749
3750 /**
3751 * @param {{}} data
3752 * @param {*} [args={}]
3753 * @return {{}} filtered result
3754 */
3755 }, {
3756 key: "applyAfterUpdate",
3757 value: function applyAfterUpdate(data) {
3758 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3759 // eslint-disable-line no-unused-vars
3760 return data;
3761 }
3762
3763 /**
3764 * @param {*} [args={}]
3765 * @return {{}} filtered args
3766 */
3767 }, {
3768 key: "applyBeforeOptions",
3769 value: function applyBeforeOptions() {
3770 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3771 return args;
3772 }
3773
3774 /**
3775 * @param {{}} data
3776 * @param {*} [args={}]
3777 * @return {{}} filtered result
3778 */
3779 }, {
3780 key: "applyAfterOptions",
3781 value: function applyAfterOptions(data) {
3782 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3783 // eslint-disable-line no-unused-vars
3784 return data;
3785 }
3786
3787 /**
3788 * @param {BaseError} e
3789 */
3790 }, {
3791 key: "applyAfterCatch",
3792 value: function applyAfterCatch(e) {
3793 e.notify();
3794 }
3795 }, {
3796 key: "onCatchApply",
3797 value: function onCatchApply(e) {
3798 var _e;
3799 // TODO: If the errors that returns from the server is consistent remove the '?' from 'e'
3800 var httpErrorCode = ((_e = e) === null || _e === void 0 || (_e = _e.data) === null || _e === void 0 ? void 0 : _e.status) || 501;
3801 var dataError = Object.values(errors).find(function (error) {
3802 return error.getHTTPErrorCode() === httpErrorCode;
3803 });
3804 if (!dataError) {
3805 dataError = errors.DefaultError;
3806 }
3807 e = dataError.create(e.message, e.code, e.data || []);
3808 this.runCatchHooks(e);
3809 this.applyAfterCatch(e);
3810 }
3811 }], [{
3812 key: "getInstanceType",
3813 value: function getInstanceType() {
3814 return 'CommandData';
3815 }
3816 }, {
3817 key: "getEndpointFormat",
3818 value: function getEndpointFormat() {
3819 return null;
3820 }
3821 }]);
3822 }(_commandBase.default);
3823
3824 /***/ }),
3825
3826 /***/ "../modules/web-cli/assets/js/modules/command-infra.js":
3827 /*!*************************************************************!*\
3828 !*** ../modules/web-cli/assets/js/modules/command-infra.js ***!
3829 \*************************************************************/
3830 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3831
3832 "use strict";
3833
3834
3835 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3836 Object.defineProperty(exports, "__esModule", ({
3837 value: true
3838 }));
3839 exports["default"] = void 0;
3840 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3841 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3842 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3843 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3844 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3845 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3846 var _argsObject = _interopRequireDefault(__webpack_require__(/*! elementor-assets-js/modules/imports/args-object */ "../assets/dev/js/modules/imports/args-object.js"));
3847 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3848 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)); }
3849 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3850 /**
3851 * @typedef {import('../modules/component-base')} ComponentBase
3852 */
3853 var CommandInfra = exports["default"] = /*#__PURE__*/function (_ArgsObject) {
3854 /**
3855 * Function constructor().
3856 *
3857 * Create Commands Base.
3858 *
3859 * @param {{}} args
3860 */
3861 function CommandInfra() {
3862 var _this;
3863 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3864 (0, _classCallCheck2.default)(this, CommandInfra);
3865 _this = _callSuper(this, CommandInfra, [args]);
3866 if (!_this.constructor.registerConfig) {
3867 throw RangeError('Doing it wrong: Each command type should have `registerConfig`.');
3868 }
3869
3870 // Acknowledge self about which command it run.
3871 _this.command = _this.constructor.getCommand();
3872
3873 // Assign instance of current component.
3874 _this.component = _this.constructor.getComponent();
3875
3876 // Who ever need do something before without `super` the constructor can use `initialize` method.
3877 _this.initialize(args);
3878
3879 // Refresh args, maybe the changed via `initialize`.
3880 args = _this.args;
3881
3882 // Validate args before run.
3883 _this.validateArgs(args);
3884 return _this;
3885 }
3886
3887 /**
3888 * Function initialize().
3889 *
3890 * Initialize command, called after construction.
3891 *
3892 * @param {{}} args
3893 */
3894 (0, _inherits2.default)(CommandInfra, _ArgsObject);
3895 return (0, _createClass2.default)(CommandInfra, [{
3896 key: "currentCommand",
3897 get:
3898 /**
3899 * @deprecated since 3.7.0, use `this.command` instead.
3900 */
3901 function get() {
3902 _deprecation.default.deprecated('this.currentCommand', '3.7.0', 'this.command');
3903 return this.command;
3904 }
3905 }, {
3906 key: "initialize",
3907 value: function initialize() {
3908 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3909 } // eslint-disable-line no-unused-vars
3910
3911 /**
3912 * Function validateArgs().
3913 *
3914 * Validate command arguments.
3915 *
3916 * @param {{}} args
3917 */
3918 }, {
3919 key: "validateArgs",
3920 value: function validateArgs() {
3921 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3922 } // eslint-disable-line no-unused-vars
3923
3924 // eslint-disable-next-line jsdoc/require-returns-check
3925 /**
3926 * Function apply().
3927 *
3928 * Do the actual command.
3929 *
3930 * @param {{}} args
3931 *
3932 * @return {*} Command results.
3933 */
3934 }, {
3935 key: "apply",
3936 value: function apply() {
3937 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3938 // eslint-disable-line no-unused-vars
3939 elementorModules.ForceMethodImplementation();
3940 }
3941
3942 /**
3943 * Function run().
3944 *
3945 * Run command with history & hooks.
3946 *
3947 * @return {*} Command results.
3948 */
3949 }, {
3950 key: "run",
3951 value: function run() {
3952 return this.apply(this.args);
3953 }
3954
3955 /**
3956 * Function onBeforeRun.
3957 *
3958 * Called before run().
3959 *
3960 * @param {{}} args
3961 */
3962 }, {
3963 key: "onBeforeRun",
3964 value: function onBeforeRun() {
3965 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3966 } // eslint-disable-line no-unused-vars
3967
3968 /**
3969 * Function onAfterRun.
3970 *
3971 * Called after run().
3972 *
3973 * @param {{}} args
3974 * @param {*} result
3975 */
3976 }, {
3977 key: "onAfterRun",
3978 value: function onAfterRun() {
3979 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3980 var result = arguments.length > 1 ? arguments[1] : undefined;
3981 } // eslint-disable-line no-unused-vars
3982
3983 /**
3984 * Function onBeforeApply.
3985 *
3986 * Called before apply().
3987 *
3988 * @param {{}} args
3989 */
3990 }, {
3991 key: "onBeforeApply",
3992 value: function onBeforeApply() {
3993 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3994 } // eslint-disable-line no-unused-vars
3995
3996 /**
3997 * Function onAfterApply.
3998 *
3999 * Called after apply().
4000 *
4001 * @param {{}} args
4002 * @param {*} result
4003 */
4004 }, {
4005 key: "onAfterApply",
4006 value: function onAfterApply() {
4007 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4008 var result = arguments.length > 1 ? arguments[1] : undefined;
4009 } // eslint-disable-line no-unused-vars
4010
4011 /**
4012 * Function onCatchApply.
4013 *
4014 * Called after apply() failed.
4015 *
4016 * @param {Error} e
4017 */
4018 }, {
4019 key: "onCatchApply",
4020 value: function onCatchApply(e) {} // eslint-disable-line no-unused-vars
4021 }], [{
4022 key: "getInstanceType",
4023 value: function getInstanceType() {
4024 return 'CommandInfra';
4025 }
4026
4027 /**
4028 * Get info of command.
4029 *
4030 * @return {Object} Extra information about the command.
4031 */
4032 }, {
4033 key: "getInfo",
4034 value: function getInfo() {
4035 return {};
4036 }
4037
4038 /**
4039 * @return {string} Self command name.
4040 */
4041 }, {
4042 key: "getCommand",
4043 value: function getCommand() {
4044 return this.registerConfig.command;
4045 }
4046
4047 /**
4048 * @return {ComponentBase} Self component
4049 */
4050 }, {
4051 key: "getComponent",
4052 value: function getComponent() {
4053 return this.registerConfig.component;
4054 }
4055 }, {
4056 key: "setRegisterConfig",
4057 value: function setRegisterConfig(config) {
4058 this.registerConfig = Object.freeze(config);
4059 }
4060 }]);
4061 }(_argsObject.default);
4062 /**
4063 * @type {Object}
4064 */
4065 (0, _defineProperty2.default)(CommandInfra, "registerConfig", null);
4066
4067 /***/ }),
4068
4069 /***/ "../modules/web-cli/assets/js/modules/commands/close.js":
4070 /*!**************************************************************!*\
4071 !*** ../modules/web-cli/assets/js/modules/commands/close.js ***!
4072 \**************************************************************/
4073 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4074
4075 "use strict";
4076
4077
4078 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4079 Object.defineProperty(exports, "__esModule", ({
4080 value: true
4081 }));
4082 exports["default"] = exports.Close = void 0;
4083 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4084 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4085 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4086 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4087 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4088 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4089 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)); }
4090 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4091 var Close = exports.Close = /*#__PURE__*/function (_CommandBase) {
4092 function Close() {
4093 (0, _classCallCheck2.default)(this, Close);
4094 return _callSuper(this, Close, arguments);
4095 }
4096 (0, _inherits2.default)(Close, _CommandBase);
4097 return (0, _createClass2.default)(Close, [{
4098 key: "apply",
4099 value: function apply() {
4100 this.component.close();
4101 }
4102 }]);
4103 }(_commandBase.default);
4104 var _default = exports["default"] = Close;
4105
4106 /***/ }),
4107
4108 /***/ "../modules/web-cli/assets/js/modules/commands/index.js":
4109 /*!**************************************************************!*\
4110 !*** ../modules/web-cli/assets/js/modules/commands/index.js ***!
4111 \**************************************************************/
4112 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4113
4114 "use strict";
4115
4116
4117 Object.defineProperty(exports, "__esModule", ({
4118 value: true
4119 }));
4120 Object.defineProperty(exports, "Close", ({
4121 enumerable: true,
4122 get: function get() {
4123 return _close.Close;
4124 }
4125 }));
4126 Object.defineProperty(exports, "Open", ({
4127 enumerable: true,
4128 get: function get() {
4129 return _open.Open;
4130 }
4131 }));
4132 Object.defineProperty(exports, "Toggle", ({
4133 enumerable: true,
4134 get: function get() {
4135 return _toggle.Toggle;
4136 }
4137 }));
4138 var _close = __webpack_require__(/*! ./close */ "../modules/web-cli/assets/js/modules/commands/close.js");
4139 var _open = __webpack_require__(/*! ./open */ "../modules/web-cli/assets/js/modules/commands/open.js");
4140 var _toggle = __webpack_require__(/*! ./toggle */ "../modules/web-cli/assets/js/modules/commands/toggle.js");
4141
4142 /***/ }),
4143
4144 /***/ "../modules/web-cli/assets/js/modules/commands/open.js":
4145 /*!*************************************************************!*\
4146 !*** ../modules/web-cli/assets/js/modules/commands/open.js ***!
4147 \*************************************************************/
4148 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4149
4150 "use strict";
4151
4152
4153 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4154 Object.defineProperty(exports, "__esModule", ({
4155 value: true
4156 }));
4157 exports["default"] = exports.Open = void 0;
4158 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4159 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4160 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4161 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4162 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4163 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4164 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)); }
4165 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4166 var Open = exports.Open = /*#__PURE__*/function (_CommandBase) {
4167 function Open() {
4168 (0, _classCallCheck2.default)(this, Open);
4169 return _callSuper(this, Open, arguments);
4170 }
4171 (0, _inherits2.default)(Open, _CommandBase);
4172 return (0, _createClass2.default)(Open, [{
4173 key: "apply",
4174 value: function apply() {
4175 $e.route(this.component.getNamespace());
4176 }
4177 }]);
4178 }(_commandBase.default);
4179 var _default = exports["default"] = Open;
4180
4181 /***/ }),
4182
4183 /***/ "../modules/web-cli/assets/js/modules/commands/toggle.js":
4184 /*!***************************************************************!*\
4185 !*** ../modules/web-cli/assets/js/modules/commands/toggle.js ***!
4186 \***************************************************************/
4187 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4188
4189 "use strict";
4190
4191
4192 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4193 Object.defineProperty(exports, "__esModule", ({
4194 value: true
4195 }));
4196 exports["default"] = exports.Toggle = void 0;
4197 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4198 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4199 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4200 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4201 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4202 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4203 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)); }
4204 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4205 var Toggle = exports.Toggle = /*#__PURE__*/function (_CommandBase) {
4206 function Toggle() {
4207 (0, _classCallCheck2.default)(this, Toggle);
4208 return _callSuper(this, Toggle, arguments);
4209 }
4210 (0, _inherits2.default)(Toggle, _CommandBase);
4211 return (0, _createClass2.default)(Toggle, [{
4212 key: "apply",
4213 value: function apply() {
4214 if (this.component.isOpen) {
4215 this.component.close();
4216 } else {
4217 $e.route(this.component.getNamespace());
4218 }
4219 }
4220 }]);
4221 }(_commandBase.default);
4222 var _default = exports["default"] = Toggle;
4223
4224 /***/ }),
4225
4226 /***/ "../modules/web-cli/assets/js/modules/component-base.js":
4227 /*!**************************************************************!*\
4228 !*** ../modules/web-cli/assets/js/modules/component-base.js ***!
4229 \**************************************************************/
4230 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4231
4232 "use strict";
4233
4234
4235 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4236 Object.defineProperty(exports, "__esModule", ({
4237 value: true
4238 }));
4239 exports["default"] = void 0;
4240 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4241 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4242 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4243 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4244 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4245 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4246 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4247 var _commandCallbackBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-callback-base */ "../modules/web-cli/assets/js/modules/command-callback-base.js"));
4248 var _toolkit = __webpack_require__(/*! @reduxjs/toolkit */ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js");
4249 var _module = _interopRequireDefault(__webpack_require__(/*! elementor/assets/dev/js/modules/imports/module.js */ "../assets/dev/js/modules/imports/module.js"));
4250 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4251 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4252 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; }
4253 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; }
4254 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)); }
4255 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4256 /**
4257 * @typedef {import('./command-infra')} CommandInfra
4258 * @typedef {import('./hook-base')} HookBase
4259 * @typedef {import('../core/states/ui-state-base')} UiStateBase
4260 */
4261 var ComponentBase = exports["default"] = /*#__PURE__*/function (_Module) {
4262 function ComponentBase() {
4263 (0, _classCallCheck2.default)(this, ComponentBase);
4264 return _callSuper(this, ComponentBase, arguments);
4265 }
4266 (0, _inherits2.default)(ComponentBase, _Module);
4267 return (0, _createClass2.default)(ComponentBase, [{
4268 key: "__construct",
4269 value: function __construct() {
4270 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4271 if (args.manager) {
4272 this.manager = args.manager;
4273 }
4274 this.commands = this.defaultCommands();
4275 this.commandsInternal = this.defaultCommandsInternal();
4276 this.hooks = this.defaultHooks();
4277 this.routes = this.defaultRoutes();
4278 this.tabs = this.defaultTabs();
4279 this.shortcuts = this.defaultShortcuts();
4280 this.utils = this.defaultUtils();
4281 this.data = this.defaultData();
4282 this.uiStates = this.defaultUiStates();
4283 this.states = this.defaultStates();
4284 this.defaultRoute = '';
4285 this.currentTab = '';
4286 }
4287 }, {
4288 key: "registerAPI",
4289 value: function registerAPI() {
4290 var _this = this;
4291 Object.entries(this.getTabs()).forEach(function (tab) {
4292 return _this.registerTabRoute(tab[0]);
4293 });
4294 Object.entries(this.getRoutes()).forEach(function (_ref) {
4295 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
4296 route = _ref2[0],
4297 callback = _ref2[1];
4298 return _this.registerRoute(route, callback);
4299 });
4300 Object.entries(this.getCommands()).forEach(function (_ref3) {
4301 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
4302 command = _ref4[0],
4303 callback = _ref4[1];
4304 return _this.registerCommand(command, callback);
4305 });
4306 Object.entries(this.getCommandsInternal()).forEach(function (_ref5) {
4307 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
4308 command = _ref6[0],
4309 callback = _ref6[1];
4310 return _this.registerCommandInternal(command, callback);
4311 });
4312 Object.values(this.getHooks()).forEach(function (instance) {
4313 return _this.registerHook(instance);
4314 });
4315 Object.entries(this.getData()).forEach(function (_ref7) {
4316 var _ref8 = (0, _slicedToArray2.default)(_ref7, 2),
4317 command = _ref8[0],
4318 callback = _ref8[1];
4319 return _this.registerData(command, callback);
4320 });
4321 Object.values(this.getUiStates()).forEach(function (instance) {
4322 return _this.registerUiState(instance);
4323 });
4324 Object.entries(this.getStates()).forEach(function (_ref9) {
4325 var _ref0 = (0, _slicedToArray2.default)(_ref9, 2),
4326 id = _ref0[0],
4327 state = _ref0[1];
4328 return _this.registerState(id, state);
4329 });
4330 }
4331
4332 // eslint-disable-next-line jsdoc/require-returns-check
4333 /**
4334 * @return {string} namespace
4335 */
4336 }, {
4337 key: "getNamespace",
4338 value: function getNamespace() {
4339 (0, _forceMethodImplementation.default)();
4340 }
4341
4342 /**
4343 * @deprecated since 3.7.0, use `getServiceName()` instead.
4344 */
4345 }, {
4346 key: "getRootContainer",
4347 value: function getRootContainer() {
4348 _deprecation.default.deprecated('getRootContainer()', '3.7.0', 'getServiceName()');
4349 return this.getServiceName();
4350 }
4351 }, {
4352 key: "getServiceName",
4353 value: function getServiceName() {
4354 return this.getNamespace().split('/')[0];
4355 }
4356 }, {
4357 key: "store",
4358 get: function get() {
4359 return $e.store.get(this.getNamespace());
4360 }
4361 }, {
4362 key: "defaultTabs",
4363 value: function defaultTabs() {
4364 return {};
4365 }
4366 }, {
4367 key: "defaultRoutes",
4368 value: function defaultRoutes() {
4369 return {};
4370 }
4371 }, {
4372 key: "defaultCommands",
4373 value: function defaultCommands() {
4374 return {};
4375 }
4376 }, {
4377 key: "defaultCommandsInternal",
4378 value: function defaultCommandsInternal() {
4379 return {};
4380 }
4381 }, {
4382 key: "defaultHooks",
4383 value: function defaultHooks() {
4384 return {};
4385 }
4386
4387 /**
4388 * Get the component's default UI states.
4389 *
4390 * @return {Object} default UI states
4391 */
4392 }, {
4393 key: "defaultUiStates",
4394 value: function defaultUiStates() {
4395 return {};
4396 }
4397
4398 /**
4399 * Get the component's Redux slice settings.
4400 *
4401 * @return {Object} Redux slice settings
4402 */
4403 }, {
4404 key: "defaultStates",
4405 value: function defaultStates() {
4406 return {};
4407 }
4408 }, {
4409 key: "defaultShortcuts",
4410 value: function defaultShortcuts() {
4411 return {};
4412 }
4413 }, {
4414 key: "defaultUtils",
4415 value: function defaultUtils() {
4416 return {};
4417 }
4418 }, {
4419 key: "defaultData",
4420 value: function defaultData() {
4421 return {};
4422 }
4423 }, {
4424 key: "getCommands",
4425 value: function getCommands() {
4426 return this.commands;
4427 }
4428 }, {
4429 key: "getCommandsInternal",
4430 value: function getCommandsInternal() {
4431 return this.commandsInternal;
4432 }
4433 }, {
4434 key: "getHooks",
4435 value: function getHooks() {
4436 return this.hooks;
4437 }
4438
4439 /**
4440 * Retrieve the component's UI states.
4441 *
4442 * @return {Object} UI states
4443 */
4444 }, {
4445 key: "getUiStates",
4446 value: function getUiStates() {
4447 return this.uiStates;
4448 }
4449
4450 /**
4451 * Retrieve the component's Redux Slice.
4452 *
4453 * @return {Object} Redux Slice
4454 */
4455 }, {
4456 key: "getStates",
4457 value: function getStates() {
4458 return this.states;
4459 }
4460 }, {
4461 key: "getRoutes",
4462 value: function getRoutes() {
4463 return this.routes;
4464 }
4465 }, {
4466 key: "getTabs",
4467 value: function getTabs() {
4468 return this.tabs;
4469 }
4470 }, {
4471 key: "getShortcuts",
4472 value: function getShortcuts() {
4473 return this.shortcuts;
4474 }
4475 }, {
4476 key: "getData",
4477 value: function getData() {
4478 return this.data;
4479 }
4480
4481 /**
4482 * @param {string} command
4483 * @param {(()=>{}|CommandInfra)} context
4484 * @param {'default'|'internal'|'data'} commandsType
4485 */
4486 }, {
4487 key: "registerCommand",
4488 value: function registerCommand(command, context) {
4489 var commandsType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'default';
4490 var commandsManager;
4491 switch (commandsType) {
4492 case 'default':
4493 commandsManager = $e.commands;
4494 break;
4495 case 'internal':
4496 commandsManager = $e.commandsInternal;
4497 break;
4498 case 'data':
4499 commandsManager = $e.data;
4500 break;
4501 default:
4502 throw new Error("Invalid commands type: '".concat(command, "'"));
4503 }
4504 var fullCommand = this.getNamespace() + '/' + command,
4505 instanceType = context.getInstanceType ? context.getInstanceType() : false,
4506 registerConfig = {
4507 command: fullCommand,
4508 component: this
4509 };
4510
4511 // Support pure callback.
4512 if (!instanceType) {
4513 if ($e.devTools) {
4514 $e.devTools.log.warn("Attach command-callback-base, on command: '".concat(fullCommand, "', context is unknown type."));
4515 }
4516 registerConfig.callback = context;
4517
4518 // Unique class.
4519 context = /*#__PURE__*/function (_CommandCallbackBase) {
4520 function context() {
4521 (0, _classCallCheck2.default)(this, context);
4522 return _callSuper(this, context, arguments);
4523 }
4524 (0, _inherits2.default)(context, _CommandCallbackBase);
4525 return (0, _createClass2.default)(context);
4526 }(_commandCallbackBase.default);
4527 }
4528 context.setRegisterConfig(registerConfig);
4529 commandsManager.register(this, command, context);
4530 }
4531
4532 /**
4533 * @param {HookBase} instance
4534 */
4535 }, {
4536 key: "registerHook",
4537 value: function registerHook(instance) {
4538 return instance.register();
4539 }
4540 }, {
4541 key: "registerCommandInternal",
4542 value: function registerCommandInternal(command, context) {
4543 this.registerCommand(command, context, 'internal');
4544 }
4545
4546 /**
4547 * Register a UI state.
4548 *
4549 * @param {UiStateBase} instance - UI state instance.
4550 *
4551 * @return {void}
4552 */
4553 }, {
4554 key: "registerUiState",
4555 value: function registerUiState(instance) {
4556 $e.uiStates.register(instance);
4557 }
4558
4559 /**
4560 * Register a Redux Slice.
4561 *
4562 * @param {string} id - State id.
4563 * @param {Object} stateConfig - The state config.
4564 *
4565 * @return {void}
4566 */
4567 }, {
4568 key: "registerState",
4569 value: function registerState(id, stateConfig) {
4570 id = this.getNamespace() + (id ? "/".concat(id) : '');
4571 var slice = (0, _toolkit.createSlice)(_objectSpread(_objectSpread({}, stateConfig), {}, {
4572 name: id
4573 }));
4574 $e.store.register(id, slice);
4575 }
4576 }, {
4577 key: "registerRoute",
4578 value: function registerRoute(route, callback) {
4579 $e.routes.register(this, route, callback);
4580 }
4581 }, {
4582 key: "registerData",
4583 value: function registerData(command, context) {
4584 this.registerCommand(command, context, 'data');
4585 }
4586 }, {
4587 key: "unregisterRoute",
4588 value: function unregisterRoute(route) {
4589 $e.routes.unregister(this, route);
4590 }
4591 }, {
4592 key: "registerTabRoute",
4593 value: function registerTabRoute(tab) {
4594 var _this2 = this;
4595 this.registerRoute(tab, function (args) {
4596 return _this2.activateTab(tab, args);
4597 });
4598 }
4599 }, {
4600 key: "dependency",
4601 value: function dependency() {
4602 return true;
4603 }
4604 }, {
4605 key: "open",
4606 value: function open() {
4607 return true;
4608 }
4609 }, {
4610 key: "close",
4611 value: function close() {
4612 if (!this.isOpen) {
4613 return false;
4614 }
4615 this.isOpen = false;
4616 this.inactivate();
4617 $e.routes.clearCurrent(this.getNamespace());
4618 $e.routes.clearHistory(this.getServiceName());
4619 return true;
4620 }
4621 }, {
4622 key: "activate",
4623 value: function activate() {
4624 $e.components.activate(this.getNamespace());
4625 }
4626 }, {
4627 key: "inactivate",
4628 value: function inactivate() {
4629 $e.components.inactivate(this.getNamespace());
4630 }
4631 }, {
4632 key: "isActive",
4633 value: function isActive() {
4634 return $e.components.isActive(this.getNamespace());
4635 }
4636 }, {
4637 key: "onRoute",
4638 value: function onRoute(route) {
4639 this.toggleRouteClass(route, true);
4640 this.toggleHistoryClass();
4641 this.activate();
4642 this.trigger('route/open', route);
4643 }
4644 }, {
4645 key: "onCloseRoute",
4646 value: function onCloseRoute(route) {
4647 this.toggleRouteClass(route, false);
4648 this.inactivate();
4649 this.trigger('route/close', route);
4650 }
4651 }, {
4652 key: "setDefaultRoute",
4653 value: function setDefaultRoute(route) {
4654 this.defaultRoute = this.getNamespace() + '/' + route;
4655 }
4656 }, {
4657 key: "getDefaultRoute",
4658 value: function getDefaultRoute() {
4659 return this.defaultRoute;
4660 }
4661 }, {
4662 key: "removeTab",
4663 value: function removeTab(tab) {
4664 delete this.tabs[tab];
4665 this.unregisterRoute(tab);
4666 }
4667 }, {
4668 key: "hasTab",
4669 value: function hasTab(tab) {
4670 return !!this.tabs[tab];
4671 }
4672 }, {
4673 key: "addTab",
4674 value: function addTab(tab, args, position) {
4675 var _this3 = this;
4676 this.tabs[tab] = args;
4677 // It can be 0.
4678 if ('undefined' !== typeof position) {
4679 var newTabs = {};
4680 var ids = Object.keys(this.tabs);
4681 // Remove new tab
4682 ids.pop();
4683
4684 // Add it to position.
4685 ids.splice(position, 0, tab);
4686 ids.forEach(function (id) {
4687 newTabs[id] = _this3.tabs[id];
4688 });
4689 this.tabs = newTabs;
4690 }
4691 this.registerTabRoute(tab);
4692 }
4693 }, {
4694 key: "getTabsWrapperSelector",
4695 value: function getTabsWrapperSelector() {
4696 return '';
4697 }
4698 }, {
4699 key: "getTabRoute",
4700 value: function getTabRoute(tab) {
4701 return this.getNamespace() + '/' + tab;
4702 }
4703 }, {
4704 key: "renderTab",
4705 value: function renderTab(tab) {} // eslint-disable-line
4706 }, {
4707 key: "activateTab",
4708 value: function activateTab(tab, args) {
4709 var _this4 = this;
4710 this.renderTab(tab, args);
4711 jQuery(this.getTabsWrapperSelector() + ' .elementor-component-tab').off('click').on('click', function (event) {
4712 $e.route(_this4.getTabRoute(event.currentTarget.dataset.tab), args);
4713 }).removeClass('elementor-active').filter('[data-tab="' + tab + '"]').addClass('elementor-active');
4714 }
4715 }, {
4716 key: "getActiveTabConfig",
4717 value: function getActiveTabConfig() {
4718 return this.tabs[this.currentTab] || {};
4719 }
4720 }, {
4721 key: "getBodyClass",
4722 value: function getBodyClass(route) {
4723 return 'e-route-' + route.replace(/\//g, '-');
4724 }
4725
4726 /**
4727 * If command includes uppercase character convert it to lowercase and add `-`.
4728 * e.g: `CopyAll` is converted to `copy-all`.
4729 *
4730 * @param {string} commandName
4731 */
4732 }, {
4733 key: "normalizeCommandName",
4734 value: function normalizeCommandName(commandName) {
4735 return commandName.replace(/[A-Z]/g, function (match, offset) {
4736 return (offset > 0 ? '-' : '') + match.toLowerCase();
4737 });
4738 }
4739
4740 /**
4741 * @param {{}} commandsFromImport
4742 * @return {{}} imported commands
4743 */
4744 }, {
4745 key: "importCommands",
4746 value: function importCommands(commandsFromImport) {
4747 var _this5 = this;
4748 var commands = {};
4749
4750 // Convert `Commands` to `ComponentBase` workable format.
4751 Object.entries(commandsFromImport).forEach(function (_ref1) {
4752 var _ref10 = (0, _slicedToArray2.default)(_ref1, 2),
4753 className = _ref10[0],
4754 Class = _ref10[1];
4755 var command = _this5.normalizeCommandName(className);
4756 commands[command] = Class;
4757 });
4758 return commands;
4759 }
4760 }, {
4761 key: "importHooks",
4762 value: function importHooks(hooksFromImport) {
4763 var hooks = {};
4764 for (var key in hooksFromImport) {
4765 var hook = new hooksFromImport[key]();
4766 hooks[hook.getId()] = hook;
4767 }
4768 return hooks;
4769 }
4770
4771 /**
4772 * Import & initialize the component's UI states.
4773 * Should be used inside `defaultUiState()`.
4774 *
4775 * @param {Object} statesFromImport - UI states from import.
4776 *
4777 * @return {Object} UI States
4778 */
4779 }, {
4780 key: "importUiStates",
4781 value: function importUiStates(statesFromImport) {
4782 var _this6 = this;
4783 var uiStates = {};
4784 Object.values(statesFromImport).forEach(function (className) {
4785 var uiState = new className(_this6);
4786 uiStates[uiState.getId()] = uiState;
4787 });
4788 return uiStates;
4789 }
4790
4791 /**
4792 * Set a UI state value.
4793 * TODO: Should we provide such function? Maybe the developer should implicitly pass the full state ID?
4794 *
4795 * @param {string} state - Non-prefixed state ID.
4796 * @param {*} value - New state value.
4797 *
4798 * @return {void}
4799 */
4800 }, {
4801 key: "setUiState",
4802 value: function setUiState(state, value) {
4803 $e.uiStates.set("".concat(this.getNamespace(), "/").concat(state), value);
4804 }
4805 }, {
4806 key: "toggleRouteClass",
4807 value: function toggleRouteClass(route, state) {
4808 document.body.classList.toggle(this.getBodyClass(route), state);
4809 }
4810 }, {
4811 key: "toggleHistoryClass",
4812 value: function toggleHistoryClass() {
4813 document.body.classList.toggle('e-routes-has-history', !!$e.routes.getHistory(this.getServiceName()).length);
4814 }
4815 }]);
4816 }(_module.default);
4817
4818 /***/ }),
4819
4820 /***/ "../modules/web-cli/assets/js/modules/component-modal-base.js":
4821 /*!********************************************************************!*\
4822 !*** ../modules/web-cli/assets/js/modules/component-modal-base.js ***!
4823 \********************************************************************/
4824 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4825
4826 "use strict";
4827
4828
4829 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4830 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
4831 Object.defineProperty(exports, "__esModule", ({
4832 value: true
4833 }));
4834 exports["default"] = void 0;
4835 var _readOnlyError2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/readOnlyError */ "../node_modules/@babel/runtime/helpers/readOnlyError.js"));
4836 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4837 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4838 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4839 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4840 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
4841 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4842 var _componentBase = _interopRequireDefault(__webpack_require__(/*! ./component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
4843 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../modules/web-cli/assets/js/modules/commands/index.js"));
4844 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4845 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); }
4846 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)); }
4847 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4848 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; }
4849 var ComponentModalBase = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
4850 function ComponentModalBase() {
4851 (0, _classCallCheck2.default)(this, ComponentModalBase);
4852 return _callSuper(this, ComponentModalBase, arguments);
4853 }
4854 (0, _inherits2.default)(ComponentModalBase, _ComponentBase);
4855 return (0, _createClass2.default)(ComponentModalBase, [{
4856 key: "registerAPI",
4857 value: function registerAPI() {
4858 var _this = this;
4859 _superPropGet(ComponentModalBase, "registerAPI", this, 3)([]);
4860 $e.shortcuts.register('esc', {
4861 scopes: [this.getNamespace()],
4862 callback: function callback() {
4863 return _this.close();
4864 }
4865 });
4866 }
4867 }, {
4868 key: "defaultCommands",
4869 value: function defaultCommands() {
4870 return this.importCommands(commands);
4871 }
4872 }, {
4873 key: "defaultRoutes",
4874 value: function defaultRoutes() {
4875 return {
4876 '': function _() {/* Nothing to do, it's already rendered. */}
4877 };
4878 }
4879 }, {
4880 key: "open",
4881 value: function open() {
4882 var _this2 = this;
4883 if (!this.layout) {
4884 var layout = this.getModalLayout();
4885 this.layout = new layout({
4886 component: this
4887 });
4888 this.layout.getModal().on('hide', function () {
4889 return _this2.close();
4890 });
4891 }
4892 this.layout.showModal();
4893 return true;
4894 }
4895 }, {
4896 key: "close",
4897 value: function close() {
4898 if (!_superPropGet(ComponentModalBase, "close", this, 3)([])) {
4899 return false;
4900 }
4901 var close = elementor.hooks.applyFilters('component/modal/close', this.layout.getModal().hide.bind(this.layout.getModal()), this);
4902 close();
4903 return true;
4904 }
4905 }, {
4906 key: "getModalLayout",
4907 value: function getModalLayout() {
4908 (0, _forceMethodImplementation.default)();
4909 }
4910 }]);
4911 }(_componentBase.default);
4912
4913 /***/ }),
4914
4915 /***/ "../modules/web-cli/assets/js/utils/console.js":
4916 /*!*****************************************************!*\
4917 !*** ../modules/web-cli/assets/js/utils/console.js ***!
4918 \*****************************************************/
4919 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4920
4921 "use strict";
4922
4923
4924 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4925 Object.defineProperty(exports, "__esModule", ({
4926 value: true
4927 }));
4928 exports["default"] = void 0;
4929 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4930 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4931 var Console = exports["default"] = /*#__PURE__*/function () {
4932 function Console() {
4933 (0, _classCallCheck2.default)(this, Console);
4934 }
4935 return (0, _createClass2.default)(Console, null, [{
4936 key: "error",
4937 value: function error(message) {
4938 // Show an error if devTools is available.
4939 if ($e.devTools) {
4940 $e.devTools.log.error(message);
4941 }
4942
4943 // If not a 'Hook-Break' then show error.
4944 if (!(message instanceof $e.modules.HookBreak)) {
4945 // eslint-disable-next-line no-console
4946 console.error(message);
4947 }
4948 }
4949 }, {
4950 key: "warn",
4951 value: function warn() {
4952 var _console;
4953 var style = "font-size: 12px; background-image: url(\"".concat(elementorWebCliConfig.urls.assets, "images/logo-icon.png\"); background-repeat: no-repeat; background-size: contain;");
4954 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4955 args[_key] = arguments[_key];
4956 }
4957 args.unshift('%c %c', style, '');
4958 (_console = console).warn.apply(_console, args); // eslint-disable-line no-console
4959 }
4960 }]);
4961 }();
4962
4963 /***/ }),
4964
4965 /***/ "../modules/web-cli/assets/js/utils/deprecation.js":
4966 /*!*********************************************************!*\
4967 !*** ../modules/web-cli/assets/js/utils/deprecation.js ***!
4968 \*********************************************************/
4969 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4970
4971 "use strict";
4972
4973
4974 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4975 Object.defineProperty(exports, "__esModule", ({
4976 value: true
4977 }));
4978 exports["default"] = void 0;
4979 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4980 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4981 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4982 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
4983 // Copied from `modules/dev-tools/assets/js/deprecation.js`
4984 /**
4985 * @typedef {Object} Version
4986 * @property {number} major1 The first number
4987 * @property {number} major2 The second number
4988 * @property {number} minor The third number
4989 * @property {string} build The fourth number
4990 */
4991
4992 var softDeprecated = function softDeprecated(name, version, replacement) {
4993 if (elementorWebCliConfig.isDebug) {
4994 deprecatedMessage('soft', name, version, replacement);
4995 }
4996 };
4997 var hardDeprecated = function hardDeprecated(name, version, replacement) {
4998 deprecatedMessage('hard', name, version, replacement);
4999 };
5000 var deprecatedMessage = function deprecatedMessage(type, name, version, replacement) {
5001 var message = "`".concat(name, "` is ").concat(type, " deprecated since ").concat(version);
5002 if (replacement) {
5003 message += " - Use `".concat(replacement, "` instead");
5004 }
5005 _console.default.warn(message);
5006 };
5007 var Deprecation = exports["default"] = /*#__PURE__*/function () {
5008 function Deprecation() {
5009 (0, _classCallCheck2.default)(this, Deprecation);
5010 }
5011 return (0, _createClass2.default)(Deprecation, null, [{
5012 key: "deprecated",
5013 value: function deprecated(name, version, replacement) {
5014 if (this.isHardDeprecated(version)) {
5015 hardDeprecated(name, version, replacement);
5016 } else {
5017 softDeprecated(name, version, replacement);
5018 }
5019 }
5020
5021 /**
5022 * @param {string} version
5023 *
5024 * @return {Version}
5025 */
5026 }, {
5027 key: "parseVersion",
5028 value: function parseVersion(version) {
5029 var versionParts = version.split('.');
5030 if (versionParts.length < 3 || versionParts.length > 4) {
5031 throw new RangeError('Invalid Semantic Version string provided');
5032 }
5033 var _versionParts = (0, _slicedToArray2.default)(versionParts, 4),
5034 major1 = _versionParts[0],
5035 major2 = _versionParts[1],
5036 minor = _versionParts[2],
5037 _versionParts$ = _versionParts[3],
5038 build = _versionParts$ === void 0 ? '' : _versionParts$;
5039 return {
5040 major1: parseInt(major1),
5041 major2: parseInt(major2),
5042 minor: parseInt(minor),
5043 build: build
5044 };
5045 }
5046
5047 /**
5048 * Get total of major.
5049 *
5050 * 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,
5051 * versions with major2 more then 9 will be added to total.
5052 *
5053 * @param {Version} versionObj
5054 *
5055 * @return {number}
5056 */
5057 }, {
5058 key: "getTotalMajor",
5059 value: function getTotalMajor(versionObj) {
5060 var total = parseInt("".concat(versionObj.major1).concat(versionObj.major2, "0"));
5061 total = Number((total / 10).toFixed(0));
5062 if (versionObj.major2 > 9) {
5063 total = versionObj.major2 - 9;
5064 }
5065 return total;
5066 }
5067
5068 /**
5069 * @param {string} version1
5070 * @param {string} version2
5071 *
5072 * @return {number}
5073 */
5074 }, {
5075 key: "compareVersion",
5076 value: function compareVersion(version1, version2) {
5077 var _this = this;
5078 return [this.parseVersion(version1), this.parseVersion(version2)].map(function (versionObj) {
5079 return _this.getTotalMajor(versionObj);
5080 }).reduce(function (acc, major) {
5081 return acc - major;
5082 });
5083 }
5084
5085 /**
5086 * @param {string} version
5087 *
5088 * @return {boolean}
5089 */
5090 }, {
5091 key: "isSoftDeprecated",
5092 value: function isSoftDeprecated(version) {
5093 var total = this.compareVersion(version, elementorWebCliConfig.version);
5094 return total <= 4;
5095 }
5096
5097 /**
5098 * @param {string} version
5099 * @return {boolean}
5100 */
5101 }, {
5102 key: "isHardDeprecated",
5103 value: function isHardDeprecated(version) {
5104 var total = this.compareVersion(version, elementorWebCliConfig.version);
5105 return total < 0 || total >= 8;
5106 }
5107 }]);
5108 }();
5109
5110 /***/ }),
5111
5112 /***/ "../modules/web-cli/assets/js/utils/force-method-implementation.js":
5113 /*!*************************************************************************!*\
5114 !*** ../modules/web-cli/assets/js/utils/force-method-implementation.js ***!
5115 \*************************************************************************/
5116 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5117
5118 "use strict";
5119
5120
5121 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5122 Object.defineProperty(exports, "__esModule", ({
5123 value: true
5124 }));
5125 exports["default"] = exports.ForceMethodImplementation = void 0;
5126 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5127 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5128 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5129 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5130 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5131 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
5132 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)); }
5133 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5134 // TODO: Copied from `assets/dev/js/modules/imports/force-method-implementation.js`;
5135 var ForceMethodImplementation = exports.ForceMethodImplementation = /*#__PURE__*/function (_Error) {
5136 function ForceMethodImplementation() {
5137 var _this;
5138 var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5139 (0, _classCallCheck2.default)(this, ForceMethodImplementation);
5140 _this = _callSuper(this, ForceMethodImplementation, ["".concat(info.isStatic ? 'static ' : '').concat(info.fullName, "() should be implemented, please provide '").concat(info.functionName || info.fullName, "' functionality.")]);
5141 Error.captureStackTrace(_this, ForceMethodImplementation);
5142 return _this;
5143 }
5144 (0, _inherits2.default)(ForceMethodImplementation, _Error);
5145 return (0, _createClass2.default)(ForceMethodImplementation);
5146 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
5147 var _default = exports["default"] = function _default() {
5148 var stack = Error().stack,
5149 caller = stack.split('\n')[2].trim(),
5150 callerName = caller.startsWith('at new') ? 'constructor' : caller.split(' ')[1],
5151 info = {};
5152 info.functionName = callerName;
5153 info.fullName = callerName;
5154 if (info.functionName.includes('.')) {
5155 var parts = info.functionName.split('.');
5156 info.className = parts[0];
5157 info.functionName = parts[1];
5158 } else {
5159 info.isStatic = true;
5160 }
5161 throw new ForceMethodImplementation(info);
5162 };
5163
5164 /***/ }),
5165
5166 /***/ "../node_modules/@babel/runtime/helpers/OverloadYield.js":
5167 /*!***************************************************************!*\
5168 !*** ../node_modules/@babel/runtime/helpers/OverloadYield.js ***!
5169 \***************************************************************/
5170 /***/ ((module) => {
5171
5172 function _OverloadYield(e, d) {
5173 this.v = e, this.k = d;
5174 }
5175 module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
5176
5177 /***/ }),
5178
5179 /***/ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
5180 /*!******************************************************************!*\
5181 !*** ../node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
5182 \******************************************************************/
5183 /***/ ((module) => {
5184
5185 function _arrayLikeToArray(r, a) {
5186 (null == a || a > r.length) && (a = r.length);
5187 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
5188 return n;
5189 }
5190 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
5191
5192 /***/ }),
5193
5194 /***/ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js":
5195 /*!****************************************************************!*\
5196 !*** ../node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
5197 \****************************************************************/
5198 /***/ ((module) => {
5199
5200 function _arrayWithHoles(r) {
5201 if (Array.isArray(r)) return r;
5202 }
5203 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
5204
5205 /***/ }),
5206
5207 /***/ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js":
5208 /*!***********************************************************************!*\
5209 !*** ../node_modules/@babel/runtime/helpers/assertThisInitialized.js ***!
5210 \***********************************************************************/
5211 /***/ ((module) => {
5212
5213 function _assertThisInitialized(e) {
5214 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5215 return e;
5216 }
5217 module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
5218
5219 /***/ }),
5220
5221 /***/ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js":
5222 /*!******************************************************************!*\
5223 !*** ../node_modules/@babel/runtime/helpers/asyncToGenerator.js ***!
5224 \******************************************************************/
5225 /***/ ((module) => {
5226
5227 function asyncGeneratorStep(n, t, e, r, o, a, c) {
5228 try {
5229 var i = n[a](c),
5230 u = i.value;
5231 } catch (n) {
5232 return void e(n);
5233 }
5234 i.done ? t(u) : Promise.resolve(u).then(r, o);
5235 }
5236 function _asyncToGenerator(n) {
5237 return function () {
5238 var t = this,
5239 e = arguments;
5240 return new Promise(function (r, o) {
5241 var a = n.apply(t, e);
5242 function _next(n) {
5243 asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
5244 }
5245 function _throw(n) {
5246 asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
5247 }
5248 _next(void 0);
5249 });
5250 };
5251 }
5252 module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5253
5254 /***/ }),
5255
5256 /***/ "../node_modules/@babel/runtime/helpers/classCallCheck.js":
5257 /*!****************************************************************!*\
5258 !*** ../node_modules/@babel/runtime/helpers/classCallCheck.js ***!
5259 \****************************************************************/
5260 /***/ ((module) => {
5261
5262 function _classCallCheck(a, n) {
5263 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
5264 }
5265 module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
5266
5267 /***/ }),
5268
5269 /***/ "../node_modules/@babel/runtime/helpers/construct.js":
5270 /*!***********************************************************!*\
5271 !*** ../node_modules/@babel/runtime/helpers/construct.js ***!
5272 \***********************************************************/
5273 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5274
5275 var isNativeReflectConstruct = __webpack_require__(/*! ./isNativeReflectConstruct.js */ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js");
5276 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5277 function _construct(t, e, r) {
5278 if (isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
5279 var o = [null];
5280 o.push.apply(o, e);
5281 var p = new (t.bind.apply(t, o))();
5282 return r && setPrototypeOf(p, r.prototype), p;
5283 }
5284 module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5285
5286 /***/ }),
5287
5288 /***/ "../node_modules/@babel/runtime/helpers/createClass.js":
5289 /*!*************************************************************!*\
5290 !*** ../node_modules/@babel/runtime/helpers/createClass.js ***!
5291 \*************************************************************/
5292 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5293
5294 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5295 function _defineProperties(e, r) {
5296 for (var t = 0; t < r.length; t++) {
5297 var o = r[t];
5298 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
5299 }
5300 }
5301 function _createClass(e, r, t) {
5302 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
5303 writable: !1
5304 }), e;
5305 }
5306 module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
5307
5308 /***/ }),
5309
5310 /***/ "../node_modules/@babel/runtime/helpers/defineProperty.js":
5311 /*!****************************************************************!*\
5312 !*** ../node_modules/@babel/runtime/helpers/defineProperty.js ***!
5313 \****************************************************************/
5314 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5315
5316 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5317 function _defineProperty(e, r, t) {
5318 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5319 value: t,
5320 enumerable: !0,
5321 configurable: !0,
5322 writable: !0
5323 }) : e[r] = t, e;
5324 }
5325 module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
5326
5327 /***/ }),
5328
5329 /***/ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js":
5330 /*!********************************************************************!*\
5331 !*** ../node_modules/@babel/runtime/helpers/esm/defineProperty.js ***!
5332 \********************************************************************/
5333 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5334
5335 "use strict";
5336 __webpack_require__.r(__webpack_exports__);
5337 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5338 /* harmony export */ "default": () => (/* binding */ _defineProperty)
5339 /* harmony export */ });
5340 /* harmony import */ var _toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js");
5341
5342 function _defineProperty(e, r, t) {
5343 return (r = (0,_toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r)) in e ? Object.defineProperty(e, r, {
5344 value: t,
5345 enumerable: !0,
5346 configurable: !0,
5347 writable: !0
5348 }) : e[r] = t, e;
5349 }
5350
5351
5352 /***/ }),
5353
5354 /***/ "../node_modules/@babel/runtime/helpers/esm/objectSpread2.js":
5355 /*!*******************************************************************!*\
5356 !*** ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js ***!
5357 \*******************************************************************/
5358 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5359
5360 "use strict";
5361 __webpack_require__.r(__webpack_exports__);
5362 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5363 /* harmony export */ "default": () => (/* binding */ _objectSpread2)
5364 /* harmony export */ });
5365 /* harmony import */ var _defineProperty_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defineProperty.js */ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js");
5366
5367 function ownKeys(e, r) {
5368 var t = Object.keys(e);
5369 if (Object.getOwnPropertySymbols) {
5370 var o = Object.getOwnPropertySymbols(e);
5371 r && (o = o.filter(function (r) {
5372 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5373 })), t.push.apply(t, o);
5374 }
5375 return t;
5376 }
5377 function _objectSpread2(e) {
5378 for (var r = 1; r < arguments.length; r++) {
5379 var t = null != arguments[r] ? arguments[r] : {};
5380 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
5381 (0,_defineProperty_js__WEBPACK_IMPORTED_MODULE_0__["default"])(e, r, t[r]);
5382 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
5383 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5384 });
5385 }
5386 return e;
5387 }
5388
5389
5390 /***/ }),
5391
5392 /***/ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js":
5393 /*!*****************************************************************!*\
5394 !*** ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js ***!
5395 \*****************************************************************/
5396 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5397
5398 "use strict";
5399 __webpack_require__.r(__webpack_exports__);
5400 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5401 /* harmony export */ "default": () => (/* binding */ toPrimitive)
5402 /* harmony export */ });
5403 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5404
5405 function toPrimitive(t, r) {
5406 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(t) || !t) return t;
5407 var e = t[Symbol.toPrimitive];
5408 if (void 0 !== e) {
5409 var i = e.call(t, r || "default");
5410 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i)) return i;
5411 throw new TypeError("@@toPrimitive must return a primitive value.");
5412 }
5413 return ("string" === r ? String : Number)(t);
5414 }
5415
5416
5417 /***/ }),
5418
5419 /***/ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js":
5420 /*!*******************************************************************!*\
5421 !*** ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js ***!
5422 \*******************************************************************/
5423 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5424
5425 "use strict";
5426 __webpack_require__.r(__webpack_exports__);
5427 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5428 /* harmony export */ "default": () => (/* binding */ toPropertyKey)
5429 /* harmony export */ });
5430 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5431 /* harmony import */ var _toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js");
5432
5433
5434 function toPropertyKey(t) {
5435 var i = (0,_toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__["default"])(t, "string");
5436 return "symbol" == (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i) ? i : i + "";
5437 }
5438
5439
5440 /***/ }),
5441
5442 /***/ "../node_modules/@babel/runtime/helpers/esm/typeof.js":
5443 /*!************************************************************!*\
5444 !*** ../node_modules/@babel/runtime/helpers/esm/typeof.js ***!
5445 \************************************************************/
5446 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5447
5448 "use strict";
5449 __webpack_require__.r(__webpack_exports__);
5450 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5451 /* harmony export */ "default": () => (/* binding */ _typeof)
5452 /* harmony export */ });
5453 function _typeof(o) {
5454 "@babel/helpers - typeof";
5455
5456 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
5457 return typeof o;
5458 } : function (o) {
5459 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
5460 }, _typeof(o);
5461 }
5462
5463
5464 /***/ }),
5465
5466 /***/ "../node_modules/@babel/runtime/helpers/get.js":
5467 /*!*****************************************************!*\
5468 !*** ../node_modules/@babel/runtime/helpers/get.js ***!
5469 \*****************************************************/
5470 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5471
5472 var superPropBase = __webpack_require__(/*! ./superPropBase.js */ "../node_modules/@babel/runtime/helpers/superPropBase.js");
5473 function _get() {
5474 return module.exports = _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
5475 var p = superPropBase(e, t);
5476 if (p) {
5477 var n = Object.getOwnPropertyDescriptor(p, t);
5478 return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
5479 }
5480 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _get.apply(null, arguments);
5481 }
5482 module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
5483
5484 /***/ }),
5485
5486 /***/ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js":
5487 /*!****************************************************************!*\
5488 !*** ../node_modules/@babel/runtime/helpers/getPrototypeOf.js ***!
5489 \****************************************************************/
5490 /***/ ((module) => {
5491
5492 function _getPrototypeOf(t) {
5493 return module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
5494 return t.__proto__ || Object.getPrototypeOf(t);
5495 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _getPrototypeOf(t);
5496 }
5497 module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
5498
5499 /***/ }),
5500
5501 /***/ "../node_modules/@babel/runtime/helpers/inherits.js":
5502 /*!**********************************************************!*\
5503 !*** ../node_modules/@babel/runtime/helpers/inherits.js ***!
5504 \**********************************************************/
5505 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5506
5507 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5508 function _inherits(t, e) {
5509 if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
5510 t.prototype = Object.create(e && e.prototype, {
5511 constructor: {
5512 value: t,
5513 writable: !0,
5514 configurable: !0
5515 }
5516 }), Object.defineProperty(t, "prototype", {
5517 writable: !1
5518 }), e && setPrototypeOf(t, e);
5519 }
5520 module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
5521
5522 /***/ }),
5523
5524 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
5525 /*!***********************************************************************!*\
5526 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
5527 \***********************************************************************/
5528 /***/ ((module) => {
5529
5530 function _interopRequireDefault(e) {
5531 return e && e.__esModule ? e : {
5532 "default": e
5533 };
5534 }
5535 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
5536
5537 /***/ }),
5538
5539 /***/ "../node_modules/@babel/runtime/helpers/isNativeFunction.js":
5540 /*!******************************************************************!*\
5541 !*** ../node_modules/@babel/runtime/helpers/isNativeFunction.js ***!
5542 \******************************************************************/
5543 /***/ ((module) => {
5544
5545 function _isNativeFunction(t) {
5546 try {
5547 return -1 !== Function.toString.call(t).indexOf("[native code]");
5548 } catch (n) {
5549 return "function" == typeof t;
5550 }
5551 }
5552 module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
5553
5554 /***/ }),
5555
5556 /***/ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js":
5557 /*!**************************************************************************!*\
5558 !*** ../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js ***!
5559 \**************************************************************************/
5560 /***/ ((module) => {
5561
5562 function _isNativeReflectConstruct() {
5563 try {
5564 var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
5565 } catch (t) {}
5566 return (module.exports = _isNativeReflectConstruct = function _isNativeReflectConstruct() {
5567 return !!t;
5568 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5569 }
5570 module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5571
5572 /***/ }),
5573
5574 /***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
5575 /*!**********************************************************************!*\
5576 !*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
5577 \**********************************************************************/
5578 /***/ ((module) => {
5579
5580 function _iterableToArrayLimit(r, l) {
5581 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
5582 if (null != t) {
5583 var e,
5584 n,
5585 i,
5586 u,
5587 a = [],
5588 f = !0,
5589 o = !1;
5590 try {
5591 if (i = (t = t.call(r)).next, 0 === l) {
5592 if (Object(t) !== t) return;
5593 f = !1;
5594 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
5595 } catch (r) {
5596 o = !0, n = r;
5597 } finally {
5598 try {
5599 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
5600 } finally {
5601 if (o) throw n;
5602 }
5603 }
5604 return a;
5605 }
5606 }
5607 module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
5608
5609 /***/ }),
5610
5611 /***/ "../node_modules/@babel/runtime/helpers/nonIterableRest.js":
5612 /*!*****************************************************************!*\
5613 !*** ../node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
5614 \*****************************************************************/
5615 /***/ ((module) => {
5616
5617 function _nonIterableRest() {
5618 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5619 }
5620 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
5621
5622 /***/ }),
5623
5624 /***/ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js":
5625 /*!***************************************************************************!*\
5626 !*** ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js ***!
5627 \***************************************************************************/
5628 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5629
5630 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5631 var assertThisInitialized = __webpack_require__(/*! ./assertThisInitialized.js */ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js");
5632 function _possibleConstructorReturn(t, e) {
5633 if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
5634 if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
5635 return assertThisInitialized(t);
5636 }
5637 module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
5638
5639 /***/ }),
5640
5641 /***/ "../node_modules/@babel/runtime/helpers/readOnlyError.js":
5642 /*!***************************************************************!*\
5643 !*** ../node_modules/@babel/runtime/helpers/readOnlyError.js ***!
5644 \***************************************************************/
5645 /***/ ((module) => {
5646
5647 function _readOnlyError(r) {
5648 throw new TypeError('"' + r + '" is read-only');
5649 }
5650 module.exports = _readOnlyError, module.exports.__esModule = true, module.exports["default"] = module.exports;
5651
5652 /***/ }),
5653
5654 /***/ "../node_modules/@babel/runtime/helpers/regenerator.js":
5655 /*!*************************************************************!*\
5656 !*** ../node_modules/@babel/runtime/helpers/regenerator.js ***!
5657 \*************************************************************/
5658 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5659
5660 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
5661 function _regenerator() {
5662 /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
5663 var e,
5664 t,
5665 r = "function" == typeof Symbol ? Symbol : {},
5666 n = r.iterator || "@@iterator",
5667 o = r.toStringTag || "@@toStringTag";
5668 function i(r, n, o, i) {
5669 var c = n && n.prototype instanceof Generator ? n : Generator,
5670 u = Object.create(c.prototype);
5671 return regeneratorDefine(u, "_invoke", function (r, n, o) {
5672 var i,
5673 c,
5674 u,
5675 f = 0,
5676 p = o || [],
5677 y = !1,
5678 G = {
5679 p: 0,
5680 n: 0,
5681 v: e,
5682 a: d,
5683 f: d.bind(e, 4),
5684 d: function d(t, r) {
5685 return i = t, c = 0, u = e, G.n = r, a;
5686 }
5687 };
5688 function d(r, n) {
5689 for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
5690 var o,
5691 i = p[t],
5692 d = G.p,
5693 l = i[2];
5694 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));
5695 }
5696 if (o || r > 1) return a;
5697 throw y = !0, n;
5698 }
5699 return function (o, p, l) {
5700 if (f > 1) throw TypeError("Generator is already running");
5701 for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
5702 i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
5703 try {
5704 if (f = 2, i) {
5705 if (c || (o = "next"), t = i[o]) {
5706 if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
5707 if (!t.done) return t;
5708 u = t.value, c < 2 && (c = 0);
5709 } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
5710 i = e;
5711 } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
5712 } catch (t) {
5713 i = e, c = 1, u = t;
5714 } finally {
5715 f = 1;
5716 }
5717 }
5718 return {
5719 value: t,
5720 done: y
5721 };
5722 };
5723 }(r, o, i), !0), u;
5724 }
5725 var a = {};
5726 function Generator() {}
5727 function GeneratorFunction() {}
5728 function GeneratorFunctionPrototype() {}
5729 t = Object.getPrototypeOf;
5730 var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
5731 return this;
5732 }), t),
5733 u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
5734 function f(e) {
5735 return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
5736 }
5737 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 () {
5738 return this;
5739 }), regeneratorDefine(u, "toString", function () {
5740 return "[object Generator]";
5741 }), (module.exports = _regenerator = function _regenerator() {
5742 return {
5743 w: i,
5744 m: f
5745 };
5746 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5747 }
5748 module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5749
5750 /***/ }),
5751
5752 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js":
5753 /*!******************************************************************!*\
5754 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsync.js ***!
5755 \******************************************************************/
5756 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5757
5758 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
5759 function _regeneratorAsync(n, e, r, t, o) {
5760 var a = regeneratorAsyncGen(n, e, r, t, o);
5761 return a.next().then(function (n) {
5762 return n.done ? n.value : a.next();
5763 });
5764 }
5765 module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
5766
5767 /***/ }),
5768
5769 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js":
5770 /*!*********************************************************************!*\
5771 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js ***!
5772 \*********************************************************************/
5773 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5774
5775 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
5776 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
5777 function _regeneratorAsyncGen(r, e, t, o, n) {
5778 return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
5779 }
5780 module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
5781
5782 /***/ }),
5783
5784 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js":
5785 /*!**************************************************************************!*\
5786 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js ***!
5787 \**************************************************************************/
5788 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5789
5790 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
5791 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
5792 function AsyncIterator(t, e) {
5793 function n(r, o, i, f) {
5794 try {
5795 var c = t[r](o),
5796 u = c.value;
5797 return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
5798 n("next", t, i, f);
5799 }, function (t) {
5800 n("throw", t, i, f);
5801 }) : e.resolve(u).then(function (t) {
5802 c.value = t, i(c);
5803 }, function (t) {
5804 return n("throw", t, i, f);
5805 });
5806 } catch (t) {
5807 f(t);
5808 }
5809 }
5810 var r;
5811 this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
5812 return this;
5813 })), regeneratorDefine(this, "_invoke", function (t, o, i) {
5814 function f() {
5815 return new e(function (e, r) {
5816 n(t, i, e, r);
5817 });
5818 }
5819 return r = r ? r.then(f, f) : f();
5820 }, !0);
5821 }
5822 module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5823
5824 /***/ }),
5825
5826 /***/ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js":
5827 /*!*******************************************************************!*\
5828 !*** ../node_modules/@babel/runtime/helpers/regeneratorDefine.js ***!
5829 \*******************************************************************/
5830 /***/ ((module) => {
5831
5832 function _regeneratorDefine(e, r, n, t) {
5833 var i = Object.defineProperty;
5834 try {
5835 i({}, "", {});
5836 } catch (e) {
5837 i = 0;
5838 }
5839 module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
5840 function o(r, n) {
5841 _regeneratorDefine(e, r, function (e) {
5842 return this._invoke(r, n, e);
5843 });
5844 }
5845 r ? i ? i(e, r, {
5846 value: n,
5847 enumerable: !t,
5848 configurable: !t,
5849 writable: !t
5850 }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
5851 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
5852 }
5853 module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
5854
5855 /***/ }),
5856
5857 /***/ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js":
5858 /*!*****************************************************************!*\
5859 !*** ../node_modules/@babel/runtime/helpers/regeneratorKeys.js ***!
5860 \*****************************************************************/
5861 /***/ ((module) => {
5862
5863 function _regeneratorKeys(e) {
5864 var n = Object(e),
5865 r = [];
5866 for (var t in n) r.unshift(t);
5867 return function e() {
5868 for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
5869 return e.done = !0, e;
5870 };
5871 }
5872 module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
5873
5874 /***/ }),
5875
5876 /***/ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js":
5877 /*!********************************************************************!*\
5878 !*** ../node_modules/@babel/runtime/helpers/regeneratorRuntime.js ***!
5879 \********************************************************************/
5880 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5881
5882 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
5883 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
5884 var regeneratorAsync = __webpack_require__(/*! ./regeneratorAsync.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js");
5885 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
5886 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
5887 var regeneratorKeys = __webpack_require__(/*! ./regeneratorKeys.js */ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js");
5888 var regeneratorValues = __webpack_require__(/*! ./regeneratorValues.js */ "../node_modules/@babel/runtime/helpers/regeneratorValues.js");
5889 function _regeneratorRuntime() {
5890 "use strict";
5891
5892 var r = regenerator(),
5893 e = r.m(_regeneratorRuntime),
5894 t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
5895 function n(r) {
5896 var e = "function" == typeof r && r.constructor;
5897 return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
5898 }
5899 var o = {
5900 "throw": 1,
5901 "return": 2,
5902 "break": 3,
5903 "continue": 3
5904 };
5905 function a(r) {
5906 var e, t;
5907 return function (n) {
5908 e || (e = {
5909 stop: function stop() {
5910 return t(n.a, 2);
5911 },
5912 "catch": function _catch() {
5913 return n.v;
5914 },
5915 abrupt: function abrupt(r, e) {
5916 return t(n.a, o[r], e);
5917 },
5918 delegateYield: function delegateYield(r, o, a) {
5919 return e.resultName = o, t(n.d, regeneratorValues(r), a);
5920 },
5921 finish: function finish(r) {
5922 return t(n.f, r);
5923 }
5924 }, t = function t(r, _t, o) {
5925 n.p = e.prev, n.n = e.next;
5926 try {
5927 return r(_t, o);
5928 } finally {
5929 e.next = n.n;
5930 }
5931 }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
5932 try {
5933 return r.call(this, e);
5934 } finally {
5935 n.p = e.prev, n.n = e.next;
5936 }
5937 };
5938 }
5939 return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
5940 return {
5941 wrap: function wrap(e, t, n, o) {
5942 return r.w(a(e), t, n, o && o.reverse());
5943 },
5944 isGeneratorFunction: n,
5945 mark: r.m,
5946 awrap: function awrap(r, e) {
5947 return new OverloadYield(r, e);
5948 },
5949 AsyncIterator: regeneratorAsyncIterator,
5950 async: function async(r, e, t, o, u) {
5951 return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
5952 },
5953 keys: regeneratorKeys,
5954 values: regeneratorValues
5955 };
5956 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5957 }
5958 module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
5959
5960 /***/ }),
5961
5962 /***/ "../node_modules/@babel/runtime/helpers/regeneratorValues.js":
5963 /*!*******************************************************************!*\
5964 !*** ../node_modules/@babel/runtime/helpers/regeneratorValues.js ***!
5965 \*******************************************************************/
5966 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5967
5968 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5969 function _regeneratorValues(e) {
5970 if (null != e) {
5971 var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
5972 r = 0;
5973 if (t) return t.call(e);
5974 if ("function" == typeof e.next) return e;
5975 if (!isNaN(e.length)) return {
5976 next: function next() {
5977 return e && r >= e.length && (e = void 0), {
5978 value: e && e[r++],
5979 done: !e
5980 };
5981 }
5982 };
5983 }
5984 throw new TypeError(_typeof(e) + " is not iterable");
5985 }
5986 module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
5987
5988 /***/ }),
5989
5990 /***/ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js":
5991 /*!****************************************************************!*\
5992 !*** ../node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
5993 \****************************************************************/
5994 /***/ ((module) => {
5995
5996 function _setPrototypeOf(t, e) {
5997 return module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
5998 return t.__proto__ = e, t;
5999 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _setPrototypeOf(t, e);
6000 }
6001 module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6002
6003 /***/ }),
6004
6005 /***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js":
6006 /*!***************************************************************!*\
6007 !*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***!
6008 \***************************************************************/
6009 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6010
6011 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js");
6012 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
6013 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
6014 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "../node_modules/@babel/runtime/helpers/nonIterableRest.js");
6015 function _slicedToArray(r, e) {
6016 return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();
6017 }
6018 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6019
6020 /***/ }),
6021
6022 /***/ "../node_modules/@babel/runtime/helpers/superPropBase.js":
6023 /*!***************************************************************!*\
6024 !*** ../node_modules/@babel/runtime/helpers/superPropBase.js ***!
6025 \***************************************************************/
6026 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6027
6028 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6029 function _superPropBase(t, o) {
6030 for (; !{}.hasOwnProperty.call(t, o) && null !== (t = getPrototypeOf(t)););
6031 return t;
6032 }
6033 module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
6034
6035 /***/ }),
6036
6037 /***/ "../node_modules/@babel/runtime/helpers/toPrimitive.js":
6038 /*!*************************************************************!*\
6039 !*** ../node_modules/@babel/runtime/helpers/toPrimitive.js ***!
6040 \*************************************************************/
6041 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6042
6043 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6044 function toPrimitive(t, r) {
6045 if ("object" != _typeof(t) || !t) return t;
6046 var e = t[Symbol.toPrimitive];
6047 if (void 0 !== e) {
6048 var i = e.call(t, r || "default");
6049 if ("object" != _typeof(i)) return i;
6050 throw new TypeError("@@toPrimitive must return a primitive value.");
6051 }
6052 return ("string" === r ? String : Number)(t);
6053 }
6054 module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
6055
6056 /***/ }),
6057
6058 /***/ "../node_modules/@babel/runtime/helpers/toPropertyKey.js":
6059 /*!***************************************************************!*\
6060 !*** ../node_modules/@babel/runtime/helpers/toPropertyKey.js ***!
6061 \***************************************************************/
6062 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6063
6064 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6065 var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/toPrimitive.js");
6066 function toPropertyKey(t) {
6067 var i = toPrimitive(t, "string");
6068 return "symbol" == _typeof(i) ? i : i + "";
6069 }
6070 module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
6071
6072 /***/ }),
6073
6074 /***/ "../node_modules/@babel/runtime/helpers/typeof.js":
6075 /*!********************************************************!*\
6076 !*** ../node_modules/@babel/runtime/helpers/typeof.js ***!
6077 \********************************************************/
6078 /***/ ((module) => {
6079
6080 function _typeof(o) {
6081 "@babel/helpers - typeof";
6082
6083 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
6084 return typeof o;
6085 } : function (o) {
6086 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
6087 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
6088 }
6089 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
6090
6091 /***/ }),
6092
6093 /***/ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
6094 /*!****************************************************************************!*\
6095 !*** ../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
6096 \****************************************************************************/
6097 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6098
6099 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
6100 function _unsupportedIterableToArray(r, a) {
6101 if (r) {
6102 if ("string" == typeof r) return arrayLikeToArray(r, a);
6103 var t = {}.toString.call(r).slice(8, -1);
6104 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;
6105 }
6106 }
6107 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6108
6109 /***/ }),
6110
6111 /***/ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js":
6112 /*!*****************************************************************!*\
6113 !*** ../node_modules/@babel/runtime/helpers/wrapNativeSuper.js ***!
6114 \*****************************************************************/
6115 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6116
6117 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6118 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6119 var isNativeFunction = __webpack_require__(/*! ./isNativeFunction.js */ "../node_modules/@babel/runtime/helpers/isNativeFunction.js");
6120 var construct = __webpack_require__(/*! ./construct.js */ "../node_modules/@babel/runtime/helpers/construct.js");
6121 function _wrapNativeSuper(t) {
6122 var r = "function" == typeof Map ? new Map() : void 0;
6123 return module.exports = _wrapNativeSuper = function _wrapNativeSuper(t) {
6124 if (null === t || !isNativeFunction(t)) return t;
6125 if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
6126 if (void 0 !== r) {
6127 if (r.has(t)) return r.get(t);
6128 r.set(t, Wrapper);
6129 }
6130 function Wrapper() {
6131 return construct(t, arguments, getPrototypeOf(this).constructor);
6132 }
6133 return Wrapper.prototype = Object.create(t.prototype, {
6134 constructor: {
6135 value: Wrapper,
6136 enumerable: !1,
6137 writable: !0,
6138 configurable: !0
6139 }
6140 }), setPrototypeOf(Wrapper, t);
6141 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _wrapNativeSuper(t);
6142 }
6143 module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
6144
6145 /***/ }),
6146
6147 /***/ "../node_modules/@babel/runtime/regenerator/index.js":
6148 /*!***********************************************************!*\
6149 !*** ../node_modules/@babel/runtime/regenerator/index.js ***!
6150 \***********************************************************/
6151 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6152
6153 // TODO(Babel 8): Remove this file.
6154
6155 var runtime = __webpack_require__(/*! ../helpers/regeneratorRuntime */ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js")();
6156 module.exports = runtime;
6157
6158 // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
6159 try {
6160 regeneratorRuntime = runtime;
6161 } catch (accidentalStrictMode) {
6162 if (typeof globalThis === "object") {
6163 globalThis.regeneratorRuntime = runtime;
6164 } else {
6165 Function("r", "regeneratorRuntime = r")(runtime);
6166 }
6167 }
6168
6169
6170 /***/ }),
6171
6172 /***/ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js":
6173 /*!******************************************************************!*\
6174 !*** ../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js ***!
6175 \******************************************************************/
6176 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6177
6178 "use strict";
6179 __webpack_require__.r(__webpack_exports__);
6180 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6181 /* harmony export */ EnhancerArray: () => (/* binding */ EnhancerArray),
6182 /* harmony export */ MiddlewareArray: () => (/* binding */ MiddlewareArray),
6183 /* harmony export */ SHOULD_AUTOBATCH: () => (/* binding */ SHOULD_AUTOBATCH),
6184 /* harmony export */ TaskAbortError: () => (/* binding */ TaskAbortError),
6185 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.__DO_NOT_USE__ActionTypes),
6186 /* harmony export */ addListener: () => (/* binding */ addListener),
6187 /* harmony export */ applyMiddleware: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware),
6188 /* harmony export */ autoBatchEnhancer: () => (/* binding */ autoBatchEnhancer),
6189 /* harmony export */ bindActionCreators: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.bindActionCreators),
6190 /* harmony export */ clearAllListeners: () => (/* binding */ clearAllListeners),
6191 /* harmony export */ combineReducers: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers),
6192 /* harmony export */ compose: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.compose),
6193 /* harmony export */ configureStore: () => (/* binding */ configureStore),
6194 /* harmony export */ createAction: () => (/* binding */ createAction),
6195 /* harmony export */ createActionCreatorInvariantMiddleware: () => (/* binding */ createActionCreatorInvariantMiddleware),
6196 /* harmony export */ createAsyncThunk: () => (/* binding */ createAsyncThunk),
6197 /* harmony export */ createDraftSafeSelector: () => (/* binding */ createDraftSafeSelector),
6198 /* harmony export */ createEntityAdapter: () => (/* binding */ createEntityAdapter),
6199 /* harmony export */ createImmutableStateInvariantMiddleware: () => (/* binding */ createImmutableStateInvariantMiddleware),
6200 /* harmony export */ createListenerMiddleware: () => (/* binding */ createListenerMiddleware),
6201 /* harmony export */ createNextState: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__["default"]),
6202 /* harmony export */ createReducer: () => (/* binding */ createReducer),
6203 /* harmony export */ createSelector: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector),
6204 /* harmony export */ createSerializableStateInvariantMiddleware: () => (/* binding */ createSerializableStateInvariantMiddleware),
6205 /* harmony export */ createSlice: () => (/* binding */ createSlice),
6206 /* harmony export */ createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.createStore),
6207 /* harmony export */ current: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.current),
6208 /* harmony export */ findNonSerializableValue: () => (/* binding */ findNonSerializableValue),
6209 /* harmony export */ freeze: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.freeze),
6210 /* harmony export */ getDefaultMiddleware: () => (/* binding */ getDefaultMiddleware),
6211 /* harmony export */ getType: () => (/* binding */ getType),
6212 /* harmony export */ isAction: () => (/* binding */ isAction),
6213 /* harmony export */ isActionCreator: () => (/* binding */ isActionCreator),
6214 /* harmony export */ isAllOf: () => (/* binding */ isAllOf),
6215 /* harmony export */ isAnyOf: () => (/* binding */ isAnyOf),
6216 /* harmony export */ isAsyncThunkAction: () => (/* binding */ isAsyncThunkAction),
6217 /* harmony export */ isDraft: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.isDraft),
6218 /* harmony export */ isFluxStandardAction: () => (/* binding */ isFSA),
6219 /* harmony export */ isFulfilled: () => (/* binding */ isFulfilled),
6220 /* harmony export */ isImmutableDefault: () => (/* binding */ isImmutableDefault),
6221 /* harmony export */ isPending: () => (/* binding */ isPending),
6222 /* harmony export */ isPlain: () => (/* binding */ isPlain),
6223 /* harmony export */ isPlainObject: () => (/* binding */ isPlainObject),
6224 /* harmony export */ isRejected: () => (/* binding */ isRejected),
6225 /* harmony export */ isRejectedWithValue: () => (/* binding */ isRejectedWithValue),
6226 /* harmony export */ legacy_createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.legacy_createStore),
6227 /* harmony export */ miniSerializeError: () => (/* binding */ miniSerializeError),
6228 /* harmony export */ nanoid: () => (/* binding */ nanoid),
6229 /* harmony export */ original: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.original),
6230 /* harmony export */ prepareAutoBatched: () => (/* binding */ prepareAutoBatched),
6231 /* harmony export */ removeListener: () => (/* binding */ removeListener),
6232 /* harmony export */ unwrapResult: () => (/* binding */ unwrapResult)
6233 /* harmony export */ });
6234 /* harmony import */ var immer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! immer */ "../node_modules/immer/dist/immer.esm.mjs");
6235 /* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! redux */ "../node_modules/redux/es/redux.js");
6236 /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! reselect */ "../node_modules/reselect/es/index.js");
6237 /* harmony import */ var redux_thunk__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! redux-thunk */ "../node_modules/redux-thunk/es/index.js");
6238 var __extends = (undefined && undefined.__extends) || (function () {
6239 var extendStatics = function (d, b) {
6240 extendStatics = Object.setPrototypeOf ||
6241 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6242 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6243 return extendStatics(d, b);
6244 };
6245 return function (d, b) {
6246 if (typeof b !== "function" && b !== null)
6247 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
6248 extendStatics(d, b);
6249 function __() { this.constructor = d; }
6250 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6251 };
6252 })();
6253 var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
6254 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6255 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6256 function verb(n) { return function (v) { return step([n, v]); }; }
6257 function step(op) {
6258 if (f) throw new TypeError("Generator is already executing.");
6259 while (_) try {
6260 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;
6261 if (y = 0, t) op = [op[0] & 2, t.value];
6262 switch (op[0]) {
6263 case 0: case 1: t = op; break;
6264 case 4: _.label++; return { value: op[1], done: false };
6265 case 5: _.label++; y = op[1]; op = [0]; continue;
6266 case 7: op = _.ops.pop(); _.trys.pop(); continue;
6267 default:
6268 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6269 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6270 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6271 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6272 if (t[2]) _.ops.pop();
6273 _.trys.pop(); continue;
6274 }
6275 op = body.call(thisArg, _);
6276 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6277 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6278 }
6279 };
6280 var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
6281 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
6282 to[j] = from[i];
6283 return to;
6284 };
6285 var __defProp = Object.defineProperty;
6286 var __defProps = Object.defineProperties;
6287 var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6288 var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6289 var __hasOwnProp = Object.prototype.hasOwnProperty;
6290 var __propIsEnum = Object.prototype.propertyIsEnumerable;
6291 var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
6292 var __spreadValues = function (a, b) {
6293 for (var prop in b || (b = {}))
6294 if (__hasOwnProp.call(b, prop))
6295 __defNormalProp(a, prop, b[prop]);
6296 if (__getOwnPropSymbols)
6297 for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
6298 var prop = _c[_i];
6299 if (__propIsEnum.call(b, prop))
6300 __defNormalProp(a, prop, b[prop]);
6301 }
6302 return a;
6303 };
6304 var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
6305 var __async = function (__this, __arguments, generator) {
6306 return new Promise(function (resolve, reject) {
6307 var fulfilled = function (value) {
6308 try {
6309 step(generator.next(value));
6310 }
6311 catch (e) {
6312 reject(e);
6313 }
6314 };
6315 var rejected = function (value) {
6316 try {
6317 step(generator.throw(value));
6318 }
6319 catch (e) {
6320 reject(e);
6321 }
6322 };
6323 var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
6324 step((generator = generator.apply(__this, __arguments)).next());
6325 });
6326 };
6327 // src/index.ts
6328
6329
6330
6331
6332 // src/createDraftSafeSelector.ts
6333
6334
6335 var createDraftSafeSelector = function () {
6336 var args = [];
6337 for (var _i = 0; _i < arguments.length; _i++) {
6338 args[_i] = arguments[_i];
6339 }
6340 var selector = reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector.apply(void 0, args);
6341 var wrappedSelector = function (value) {
6342 var rest = [];
6343 for (var _i = 1; _i < arguments.length; _i++) {
6344 rest[_i - 1] = arguments[_i];
6345 }
6346 return selector.apply(void 0, __spreadArray([(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(value) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__.current)(value) : value], rest));
6347 };
6348 return wrappedSelector;
6349 };
6350 // src/configureStore.ts
6351
6352 // src/devtoolsExtension.ts
6353
6354 var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
6355 if (arguments.length === 0)
6356 return void 0;
6357 if (typeof arguments[0] === "object")
6358 return redux__WEBPACK_IMPORTED_MODULE_1__.compose;
6359 return redux__WEBPACK_IMPORTED_MODULE_1__.compose.apply(null, arguments);
6360 };
6361 var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function () {
6362 return function (noop2) {
6363 return noop2;
6364 };
6365 };
6366 // src/isPlainObject.ts
6367 function isPlainObject(value) {
6368 if (typeof value !== "object" || value === null)
6369 return false;
6370 var proto = Object.getPrototypeOf(value);
6371 if (proto === null)
6372 return true;
6373 var baseProto = proto;
6374 while (Object.getPrototypeOf(baseProto) !== null) {
6375 baseProto = Object.getPrototypeOf(baseProto);
6376 }
6377 return proto === baseProto;
6378 }
6379 // src/getDefaultMiddleware.ts
6380
6381 // src/tsHelpers.ts
6382 var hasMatchFunction = function (v) {
6383 return v && typeof v.match === "function";
6384 };
6385 // src/createAction.ts
6386 function createAction(type, prepareAction) {
6387 function actionCreator() {
6388 var args = [];
6389 for (var _i = 0; _i < arguments.length; _i++) {
6390 args[_i] = arguments[_i];
6391 }
6392 if (prepareAction) {
6393 var prepared = prepareAction.apply(void 0, args);
6394 if (!prepared) {
6395 throw new Error("prepareAction did not return an object");
6396 }
6397 return __spreadValues(__spreadValues({
6398 type: type,
6399 payload: prepared.payload
6400 }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
6401 }
6402 return { type: type, payload: args[0] };
6403 }
6404 actionCreator.toString = function () { return "" + type; };
6405 actionCreator.type = type;
6406 actionCreator.match = function (action) { return action.type === type; };
6407 return actionCreator;
6408 }
6409 function isAction(action) {
6410 return isPlainObject(action) && "type" in action;
6411 }
6412 function isActionCreator(action) {
6413 return typeof action === "function" && "type" in action && hasMatchFunction(action);
6414 }
6415 function isFSA(action) {
6416 return isAction(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
6417 }
6418 function isValidKey(key) {
6419 return ["type", "payload", "error", "meta"].indexOf(key) > -1;
6420 }
6421 function getType(actionCreator) {
6422 return "" + actionCreator;
6423 }
6424 // src/actionCreatorInvariantMiddleware.ts
6425 function getMessage(type) {
6426 var splitType = type ? ("" + type).split("/") : [];
6427 var actionName = splitType[splitType.length - 1] || "actionCreator";
6428 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.";
6429 }
6430 function createActionCreatorInvariantMiddleware(options) {
6431 if (options === void 0) { options = {}; }
6432 if (false) // removed by dead control flow
6433 {}
6434 var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
6435 return function () { return function (next) { return function (action) {
6436 if (isActionCreator2(action)) {
6437 console.warn(getMessage(action.type));
6438 }
6439 return next(action);
6440 }; }; };
6441 }
6442 // src/utils.ts
6443
6444 function getTimeMeasureUtils(maxDelay, fnName) {
6445 var elapsed = 0;
6446 return {
6447 measureTime: function (fn) {
6448 var started = Date.now();
6449 try {
6450 return fn();
6451 }
6452 finally {
6453 var finished = Date.now();
6454 elapsed += finished - started;
6455 }
6456 },
6457 warnIfExceeded: function () {
6458 if (elapsed > maxDelay) {
6459 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.");
6460 }
6461 }
6462 };
6463 }
6464 var MiddlewareArray = /** @class */ (function (_super) {
6465 __extends(MiddlewareArray, _super);
6466 function MiddlewareArray() {
6467 var args = [];
6468 for (var _i = 0; _i < arguments.length; _i++) {
6469 args[_i] = arguments[_i];
6470 }
6471 var _this = _super.apply(this, args) || this;
6472 Object.setPrototypeOf(_this, MiddlewareArray.prototype);
6473 return _this;
6474 }
6475 Object.defineProperty(MiddlewareArray, Symbol.species, {
6476 get: function () {
6477 return MiddlewareArray;
6478 },
6479 enumerable: false,
6480 configurable: true
6481 });
6482 MiddlewareArray.prototype.concat = function () {
6483 var arr = [];
6484 for (var _i = 0; _i < arguments.length; _i++) {
6485 arr[_i] = arguments[_i];
6486 }
6487 return _super.prototype.concat.apply(this, arr);
6488 };
6489 MiddlewareArray.prototype.prepend = function () {
6490 var arr = [];
6491 for (var _i = 0; _i < arguments.length; _i++) {
6492 arr[_i] = arguments[_i];
6493 }
6494 if (arr.length === 1 && Array.isArray(arr[0])) {
6495 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
6496 }
6497 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
6498 };
6499 return MiddlewareArray;
6500 }(Array));
6501 var EnhancerArray = /** @class */ (function (_super) {
6502 __extends(EnhancerArray, _super);
6503 function EnhancerArray() {
6504 var args = [];
6505 for (var _i = 0; _i < arguments.length; _i++) {
6506 args[_i] = arguments[_i];
6507 }
6508 var _this = _super.apply(this, args) || this;
6509 Object.setPrototypeOf(_this, EnhancerArray.prototype);
6510 return _this;
6511 }
6512 Object.defineProperty(EnhancerArray, Symbol.species, {
6513 get: function () {
6514 return EnhancerArray;
6515 },
6516 enumerable: false,
6517 configurable: true
6518 });
6519 EnhancerArray.prototype.concat = function () {
6520 var arr = [];
6521 for (var _i = 0; _i < arguments.length; _i++) {
6522 arr[_i] = arguments[_i];
6523 }
6524 return _super.prototype.concat.apply(this, arr);
6525 };
6526 EnhancerArray.prototype.prepend = function () {
6527 var arr = [];
6528 for (var _i = 0; _i < arguments.length; _i++) {
6529 arr[_i] = arguments[_i];
6530 }
6531 if (arr.length === 1 && Array.isArray(arr[0])) {
6532 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
6533 }
6534 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
6535 };
6536 return EnhancerArray;
6537 }(Array));
6538 function freezeDraftable(val) {
6539 return (0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(val) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(val, function () {
6540 }) : val;
6541 }
6542 // src/immutableStateInvariantMiddleware.ts
6543 var isProduction = "development" === "production";
6544 var prefix = "Invariant failed";
6545 function invariant(condition, message) {
6546 if (condition) {
6547 return;
6548 }
6549 if (isProduction) {
6550 throw new Error(prefix);
6551 }
6552 throw new Error(prefix + ": " + (message || ""));
6553 }
6554 function stringify(obj, serializer, indent, decycler) {
6555 return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
6556 }
6557 function getSerialize(serializer, decycler) {
6558 var stack = [], keys = [];
6559 if (!decycler)
6560 decycler = function (_, value) {
6561 if (stack[0] === value)
6562 return "[Circular ~]";
6563 return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
6564 };
6565 return function (key, value) {
6566 if (stack.length > 0) {
6567 var thisPos = stack.indexOf(this);
6568 ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
6569 ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
6570 if (~stack.indexOf(value))
6571 value = decycler.call(this, key, value);
6572 }
6573 else
6574 stack.push(value);
6575 return serializer == null ? value : serializer.call(this, key, value);
6576 };
6577 }
6578 function isImmutableDefault(value) {
6579 return typeof value !== "object" || value == null || Object.isFrozen(value);
6580 }
6581 function trackForMutations(isImmutable, ignorePaths, obj) {
6582 var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
6583 return {
6584 detectMutations: function () {
6585 return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
6586 }
6587 };
6588 }
6589 function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
6590 if (ignorePaths === void 0) { ignorePaths = []; }
6591 if (path === void 0) { path = ""; }
6592 if (checkedObjects === void 0) { checkedObjects = new Set(); }
6593 var tracked = { value: obj };
6594 if (!isImmutable(obj) && !checkedObjects.has(obj)) {
6595 checkedObjects.add(obj);
6596 tracked.children = {};
6597 for (var key in obj) {
6598 var childPath = path ? path + "." + key : key;
6599 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
6600 continue;
6601 }
6602 tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
6603 }
6604 }
6605 return tracked;
6606 }
6607 function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
6608 if (ignoredPaths === void 0) { ignoredPaths = []; }
6609 if (sameParentRef === void 0) { sameParentRef = false; }
6610 if (path === void 0) { path = ""; }
6611 var prevObj = trackedProperty ? trackedProperty.value : void 0;
6612 var sameRef = prevObj === obj;
6613 if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
6614 return { wasMutated: true, path: path };
6615 }
6616 if (isImmutable(prevObj) || isImmutable(obj)) {
6617 return { wasMutated: false };
6618 }
6619 var keysToDetect = {};
6620 for (var key in trackedProperty.children) {
6621 keysToDetect[key] = true;
6622 }
6623 for (var key in obj) {
6624 keysToDetect[key] = true;
6625 }
6626 var hasIgnoredPaths = ignoredPaths.length > 0;
6627 var _loop_1 = function (key) {
6628 var nestedPath = path ? path + "." + key : key;
6629 if (hasIgnoredPaths) {
6630 var hasMatches = ignoredPaths.some(function (ignored) {
6631 if (ignored instanceof RegExp) {
6632 return ignored.test(nestedPath);
6633 }
6634 return nestedPath === ignored;
6635 });
6636 if (hasMatches) {
6637 return "continue";
6638 }
6639 }
6640 var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
6641 if (result.wasMutated) {
6642 return { value: result };
6643 }
6644 };
6645 for (var key in keysToDetect) {
6646 var state_1 = _loop_1(key);
6647 if (typeof state_1 === "object")
6648 return state_1.value;
6649 }
6650 return { wasMutated: false };
6651 }
6652 function createImmutableStateInvariantMiddleware(options) {
6653 if (options === void 0) { options = {}; }
6654 if (false) // removed by dead control flow
6655 {}
6656 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;
6657 ignoredPaths = ignoredPaths || ignore;
6658 var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
6659 return function (_c) {
6660 var getState = _c.getState;
6661 var state = getState();
6662 var tracker = track(state);
6663 var result;
6664 return function (next) { return function (action) {
6665 var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
6666 measureUtils.measureTime(function () {
6667 state = getState();
6668 result = tracker.detectMutations();
6669 tracker = track(state);
6670 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)");
6671 });
6672 var dispatchedAction = next(action);
6673 measureUtils.measureTime(function () {
6674 state = getState();
6675 result = tracker.detectMutations();
6676 tracker = track(state);
6677 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)");
6678 });
6679 measureUtils.warnIfExceeded();
6680 return dispatchedAction;
6681 }; };
6682 };
6683 }
6684 // src/serializableStateInvariantMiddleware.ts
6685 function isPlain(val) {
6686 var type = typeof val;
6687 return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
6688 }
6689 function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
6690 if (path === void 0) { path = ""; }
6691 if (isSerializable === void 0) { isSerializable = isPlain; }
6692 if (ignoredPaths === void 0) { ignoredPaths = []; }
6693 var foundNestedSerializable;
6694 if (!isSerializable(value)) {
6695 return {
6696 keyPath: path || "<root>",
6697 value: value
6698 };
6699 }
6700 if (typeof value !== "object" || value === null) {
6701 return false;
6702 }
6703 if (cache == null ? void 0 : cache.has(value))
6704 return false;
6705 var entries = getEntries != null ? getEntries(value) : Object.entries(value);
6706 var hasIgnoredPaths = ignoredPaths.length > 0;
6707 var _loop_2 = function (key, nestedValue) {
6708 var nestedPath = path ? path + "." + key : key;
6709 if (hasIgnoredPaths) {
6710 var hasMatches = ignoredPaths.some(function (ignored) {
6711 if (ignored instanceof RegExp) {
6712 return ignored.test(nestedPath);
6713 }
6714 return nestedPath === ignored;
6715 });
6716 if (hasMatches) {
6717 return "continue";
6718 }
6719 }
6720 if (!isSerializable(nestedValue)) {
6721 return { value: {
6722 keyPath: nestedPath,
6723 value: nestedValue
6724 } };
6725 }
6726 if (typeof nestedValue === "object") {
6727 foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
6728 if (foundNestedSerializable) {
6729 return { value: foundNestedSerializable };
6730 }
6731 }
6732 };
6733 for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
6734 var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
6735 var state_2 = _loop_2(key, nestedValue);
6736 if (typeof state_2 === "object")
6737 return state_2.value;
6738 }
6739 if (cache && isNestedFrozen(value))
6740 cache.add(value);
6741 return false;
6742 }
6743 function isNestedFrozen(value) {
6744 if (!Object.isFrozen(value))
6745 return false;
6746 for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
6747 var nestedValue = _c[_i];
6748 if (typeof nestedValue !== "object" || nestedValue === null)
6749 continue;
6750 if (!isNestedFrozen(nestedValue))
6751 return false;
6752 }
6753 return true;
6754 }
6755 function createSerializableStateInvariantMiddleware(options) {
6756 if (options === void 0) { options = {}; }
6757 if (false) // removed by dead control flow
6758 {}
6759 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;
6760 var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
6761 return function (storeAPI) { return function (next) { return function (action) {
6762 var result = next(action);
6763 var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
6764 if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
6765 measureUtils.measureTime(function () {
6766 var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
6767 if (foundActionNonSerializableValue) {
6768 var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
6769 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)");
6770 }
6771 });
6772 }
6773 if (!ignoreState) {
6774 measureUtils.measureTime(function () {
6775 var state = storeAPI.getState();
6776 var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
6777 if (foundStateNonSerializableValue) {
6778 var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
6779 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)");
6780 }
6781 });
6782 measureUtils.warnIfExceeded();
6783 }
6784 return result;
6785 }; }; };
6786 }
6787 // src/getDefaultMiddleware.ts
6788 function isBoolean(x) {
6789 return typeof x === "boolean";
6790 }
6791 function curryGetDefaultMiddleware() {
6792 return function curriedGetDefaultMiddleware(options) {
6793 return getDefaultMiddleware(options);
6794 };
6795 }
6796 function getDefaultMiddleware(options) {
6797 if (options === void 0) { options = {}; }
6798 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;
6799 var middlewareArray = new MiddlewareArray();
6800 if (thunk) {
6801 if (isBoolean(thunk)) {
6802 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"]);
6803 }
6804 else {
6805 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"].withExtraArgument(thunk.extraArgument));
6806 }
6807 }
6808 if (true) {
6809 if (immutableCheck) {
6810 var immutableOptions = {};
6811 if (!isBoolean(immutableCheck)) {
6812 immutableOptions = immutableCheck;
6813 }
6814 middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
6815 }
6816 if (serializableCheck) {
6817 var serializableOptions = {};
6818 if (!isBoolean(serializableCheck)) {
6819 serializableOptions = serializableCheck;
6820 }
6821 middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
6822 }
6823 if (actionCreatorCheck) {
6824 var actionCreatorOptions = {};
6825 if (!isBoolean(actionCreatorCheck)) {
6826 actionCreatorOptions = actionCreatorCheck;
6827 }
6828 middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
6829 }
6830 }
6831 return middlewareArray;
6832 }
6833 // src/configureStore.ts
6834 var IS_PRODUCTION = "development" === "production";
6835 function configureStore(options) {
6836 var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
6837 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;
6838 var rootReducer;
6839 if (typeof reducer === "function") {
6840 rootReducer = reducer;
6841 }
6842 else if (isPlainObject(reducer)) {
6843 rootReducer = (0,redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers)(reducer);
6844 }
6845 else {
6846 throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
6847 }
6848 var finalMiddleware = middleware;
6849 if (typeof finalMiddleware === "function") {
6850 finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
6851 if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
6852 throw new Error("when using a middleware builder function, an array of middleware must be returned");
6853 }
6854 }
6855 if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
6856 throw new Error("each middleware provided to configureStore must be a function");
6857 }
6858 var middlewareEnhancer = redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware.apply(void 0, finalMiddleware);
6859 var finalCompose = redux__WEBPACK_IMPORTED_MODULE_1__.compose;
6860 if (devTools) {
6861 finalCompose = composeWithDevTools(__spreadValues({
6862 trace: !IS_PRODUCTION
6863 }, typeof devTools === "object" && devTools));
6864 }
6865 var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
6866 var storeEnhancers = defaultEnhancers;
6867 if (Array.isArray(enhancers)) {
6868 storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
6869 }
6870 else if (typeof enhancers === "function") {
6871 storeEnhancers = enhancers(defaultEnhancers);
6872 }
6873 var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
6874 return (0,redux__WEBPACK_IMPORTED_MODULE_1__.createStore)(rootReducer, preloadedState, composedEnhancer);
6875 }
6876 // src/createReducer.ts
6877
6878 // src/mapBuilders.ts
6879 function executeReducerBuilderCallback(builderCallback) {
6880 var actionsMap = {};
6881 var actionMatchers = [];
6882 var defaultCaseReducer;
6883 var builder = {
6884 addCase: function (typeOrActionCreator, reducer) {
6885 if (true) {
6886 if (actionMatchers.length > 0) {
6887 throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
6888 }
6889 if (defaultCaseReducer) {
6890 throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
6891 }
6892 }
6893 var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
6894 if (!type) {
6895 throw new Error("`builder.addCase` cannot be called with an empty action type");
6896 }
6897 if (type in actionsMap) {
6898 throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");
6899 }
6900 actionsMap[type] = reducer;
6901 return builder;
6902 },
6903 addMatcher: function (matcher, reducer) {
6904 if (true) {
6905 if (defaultCaseReducer) {
6906 throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
6907 }
6908 }
6909 actionMatchers.push({ matcher: matcher, reducer: reducer });
6910 return builder;
6911 },
6912 addDefaultCase: function (reducer) {
6913 if (true) {
6914 if (defaultCaseReducer) {
6915 throw new Error("`builder.addDefaultCase` can only be called once");
6916 }
6917 }
6918 defaultCaseReducer = reducer;
6919 return builder;
6920 }
6921 };
6922 builderCallback(builder);
6923 return [actionsMap, actionMatchers, defaultCaseReducer];
6924 }
6925 // src/createReducer.ts
6926 function isStateFunction(x) {
6927 return typeof x === "function";
6928 }
6929 var hasWarnedAboutObjectNotation = false;
6930 function createReducer(initialState, mapOrBuilderCallback, actionMatchers, defaultCaseReducer) {
6931 if (actionMatchers === void 0) { actionMatchers = []; }
6932 if (true) {
6933 if (typeof mapOrBuilderCallback === "object") {
6934 if (!hasWarnedAboutObjectNotation) {
6935 hasWarnedAboutObjectNotation = true;
6936 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");
6937 }
6938 }
6939 }
6940 var _c = typeof mapOrBuilderCallback === "function" ? executeReducerBuilderCallback(mapOrBuilderCallback) : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer], actionsMap = _c[0], finalActionMatchers = _c[1], finalDefaultCaseReducer = _c[2];
6941 var getInitialState;
6942 if (isStateFunction(initialState)) {
6943 getInitialState = function () { return freezeDraftable(initialState()); };
6944 }
6945 else {
6946 var frozenInitialState_1 = freezeDraftable(initialState);
6947 getInitialState = function () { return frozenInitialState_1; };
6948 }
6949 function reducer(state, action) {
6950 if (state === void 0) { state = getInitialState(); }
6951 var caseReducers = __spreadArray([
6952 actionsMap[action.type]
6953 ], finalActionMatchers.filter(function (_c) {
6954 var matcher = _c.matcher;
6955 return matcher(action);
6956 }).map(function (_c) {
6957 var reducer2 = _c.reducer;
6958 return reducer2;
6959 }));
6960 if (caseReducers.filter(function (cr) { return !!cr; }).length === 0) {
6961 caseReducers = [finalDefaultCaseReducer];
6962 }
6963 return caseReducers.reduce(function (previousState, caseReducer) {
6964 if (caseReducer) {
6965 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(previousState)) {
6966 var draft = previousState;
6967 var result = caseReducer(draft, action);
6968 if (result === void 0) {
6969 return previousState;
6970 }
6971 return result;
6972 }
6973 else if (!(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(previousState)) {
6974 var result = caseReducer(previousState, action);
6975 if (result === void 0) {
6976 if (previousState === null) {
6977 return previousState;
6978 }
6979 throw Error("A case reducer on a non-draftable value must not return undefined");
6980 }
6981 return result;
6982 }
6983 else {
6984 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(previousState, function (draft) {
6985 return caseReducer(draft, action);
6986 });
6987 }
6988 }
6989 return previousState;
6990 }, state);
6991 }
6992 reducer.getInitialState = getInitialState;
6993 return reducer;
6994 }
6995 // src/createSlice.ts
6996 var hasWarnedAboutObjectNotation2 = false;
6997 function getType2(slice, actionKey) {
6998 return slice + "/" + actionKey;
6999 }
7000 function createSlice(options) {
7001 var name = options.name;
7002 if (!name) {
7003 throw new Error("`name` is a required option for createSlice");
7004 }
7005 if (typeof process !== "undefined" && "development" === "development") {
7006 if (options.initialState === void 0) {
7007 console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
7008 }
7009 }
7010 var initialState = typeof options.initialState == "function" ? options.initialState : freezeDraftable(options.initialState);
7011 var reducers = options.reducers || {};
7012 var reducerNames = Object.keys(reducers);
7013 var sliceCaseReducersByName = {};
7014 var sliceCaseReducersByType = {};
7015 var actionCreators = {};
7016 reducerNames.forEach(function (reducerName) {
7017 var maybeReducerWithPrepare = reducers[reducerName];
7018 var type = getType2(name, reducerName);
7019 var caseReducer;
7020 var prepareCallback;
7021 if ("reducer" in maybeReducerWithPrepare) {
7022 caseReducer = maybeReducerWithPrepare.reducer;
7023 prepareCallback = maybeReducerWithPrepare.prepare;
7024 }
7025 else {
7026 caseReducer = maybeReducerWithPrepare;
7027 }
7028 sliceCaseReducersByName[reducerName] = caseReducer;
7029 sliceCaseReducersByType[type] = caseReducer;
7030 actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type);
7031 });
7032 function buildReducer() {
7033 if (true) {
7034 if (typeof options.extraReducers === "object") {
7035 if (!hasWarnedAboutObjectNotation2) {
7036 hasWarnedAboutObjectNotation2 = true;
7037 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");
7038 }
7039 }
7040 }
7041 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;
7042 var finalCaseReducers = __spreadValues(__spreadValues({}, extraReducers), sliceCaseReducersByType);
7043 return createReducer(initialState, function (builder) {
7044 for (var key in finalCaseReducers) {
7045 builder.addCase(key, finalCaseReducers[key]);
7046 }
7047 for (var _i = 0, actionMatchers_1 = actionMatchers; _i < actionMatchers_1.length; _i++) {
7048 var m = actionMatchers_1[_i];
7049 builder.addMatcher(m.matcher, m.reducer);
7050 }
7051 if (defaultCaseReducer) {
7052 builder.addDefaultCase(defaultCaseReducer);
7053 }
7054 });
7055 }
7056 var _reducer;
7057 return {
7058 name: name,
7059 reducer: function (state, action) {
7060 if (!_reducer)
7061 _reducer = buildReducer();
7062 return _reducer(state, action);
7063 },
7064 actions: actionCreators,
7065 caseReducers: sliceCaseReducersByName,
7066 getInitialState: function () {
7067 if (!_reducer)
7068 _reducer = buildReducer();
7069 return _reducer.getInitialState();
7070 }
7071 };
7072 }
7073 // src/entities/entity_state.ts
7074 function getInitialEntityState() {
7075 return {
7076 ids: [],
7077 entities: {}
7078 };
7079 }
7080 function createInitialStateFactory() {
7081 function getInitialState(additionalState) {
7082 if (additionalState === void 0) { additionalState = {}; }
7083 return Object.assign(getInitialEntityState(), additionalState);
7084 }
7085 return { getInitialState: getInitialState };
7086 }
7087 // src/entities/state_selectors.ts
7088 function createSelectorsFactory() {
7089 function getSelectors(selectState) {
7090 var selectIds = function (state) { return state.ids; };
7091 var selectEntities = function (state) { return state.entities; };
7092 var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) { return ids.map(function (id) { return entities[id]; }); });
7093 var selectId = function (_, id) { return id; };
7094 var selectById = function (entities, id) { return entities[id]; };
7095 var selectTotal = createDraftSafeSelector(selectIds, function (ids) { return ids.length; });
7096 if (!selectState) {
7097 return {
7098 selectIds: selectIds,
7099 selectEntities: selectEntities,
7100 selectAll: selectAll,
7101 selectTotal: selectTotal,
7102 selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
7103 };
7104 }
7105 var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
7106 return {
7107 selectIds: createDraftSafeSelector(selectState, selectIds),
7108 selectEntities: selectGlobalizedEntities,
7109 selectAll: createDraftSafeSelector(selectState, selectAll),
7110 selectTotal: createDraftSafeSelector(selectState, selectTotal),
7111 selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
7112 };
7113 }
7114 return { getSelectors: getSelectors };
7115 }
7116 // src/entities/state_adapter.ts
7117
7118 function createSingleArgumentStateOperator(mutator) {
7119 var operator = createStateOperator(function (_, state) { return mutator(state); });
7120 return function operation(state) {
7121 return operator(state, void 0);
7122 };
7123 }
7124 function createStateOperator(mutator) {
7125 return function operation(state, arg) {
7126 function isPayloadActionArgument(arg2) {
7127 return isFSA(arg2);
7128 }
7129 var runMutator = function (draft) {
7130 if (isPayloadActionArgument(arg)) {
7131 mutator(arg.payload, draft);
7132 }
7133 else {
7134 mutator(arg, draft);
7135 }
7136 };
7137 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(state)) {
7138 runMutator(state);
7139 return state;
7140 }
7141 else {
7142 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(state, runMutator);
7143 }
7144 };
7145 }
7146 // src/entities/utils.ts
7147 function selectIdValue(entity, selectId) {
7148 var key = selectId(entity);
7149 if ( true && key === void 0) {
7150 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());
7151 }
7152 return key;
7153 }
7154 function ensureEntitiesArray(entities) {
7155 if (!Array.isArray(entities)) {
7156 entities = Object.values(entities);
7157 }
7158 return entities;
7159 }
7160 function splitAddedUpdatedEntities(newEntities, selectId, state) {
7161 newEntities = ensureEntitiesArray(newEntities);
7162 var added = [];
7163 var updated = [];
7164 for (var _i = 0, newEntities_1 = newEntities; _i < newEntities_1.length; _i++) {
7165 var entity = newEntities_1[_i];
7166 var id = selectIdValue(entity, selectId);
7167 if (id in state.entities) {
7168 updated.push({ id: id, changes: entity });
7169 }
7170 else {
7171 added.push(entity);
7172 }
7173 }
7174 return [added, updated];
7175 }
7176 // src/entities/unsorted_state_adapter.ts
7177 function createUnsortedStateAdapter(selectId) {
7178 function addOneMutably(entity, state) {
7179 var key = selectIdValue(entity, selectId);
7180 if (key in state.entities) {
7181 return;
7182 }
7183 state.ids.push(key);
7184 state.entities[key] = entity;
7185 }
7186 function addManyMutably(newEntities, state) {
7187 newEntities = ensureEntitiesArray(newEntities);
7188 for (var _i = 0, newEntities_2 = newEntities; _i < newEntities_2.length; _i++) {
7189 var entity = newEntities_2[_i];
7190 addOneMutably(entity, state);
7191 }
7192 }
7193 function setOneMutably(entity, state) {
7194 var key = selectIdValue(entity, selectId);
7195 if (!(key in state.entities)) {
7196 state.ids.push(key);
7197 }
7198 state.entities[key] = entity;
7199 }
7200 function setManyMutably(newEntities, state) {
7201 newEntities = ensureEntitiesArray(newEntities);
7202 for (var _i = 0, newEntities_3 = newEntities; _i < newEntities_3.length; _i++) {
7203 var entity = newEntities_3[_i];
7204 setOneMutably(entity, state);
7205 }
7206 }
7207 function setAllMutably(newEntities, state) {
7208 newEntities = ensureEntitiesArray(newEntities);
7209 state.ids = [];
7210 state.entities = {};
7211 addManyMutably(newEntities, state);
7212 }
7213 function removeOneMutably(key, state) {
7214 return removeManyMutably([key], state);
7215 }
7216 function removeManyMutably(keys, state) {
7217 var didMutate = false;
7218 keys.forEach(function (key) {
7219 if (key in state.entities) {
7220 delete state.entities[key];
7221 didMutate = true;
7222 }
7223 });
7224 if (didMutate) {
7225 state.ids = state.ids.filter(function (id) { return id in state.entities; });
7226 }
7227 }
7228 function removeAllMutably(state) {
7229 Object.assign(state, {
7230 ids: [],
7231 entities: {}
7232 });
7233 }
7234 function takeNewKey(keys, update, state) {
7235 var original2 = state.entities[update.id];
7236 var updated = Object.assign({}, original2, update.changes);
7237 var newKey = selectIdValue(updated, selectId);
7238 var hasNewKey = newKey !== update.id;
7239 if (hasNewKey) {
7240 keys[update.id] = newKey;
7241 delete state.entities[update.id];
7242 }
7243 state.entities[newKey] = updated;
7244 return hasNewKey;
7245 }
7246 function updateOneMutably(update, state) {
7247 return updateManyMutably([update], state);
7248 }
7249 function updateManyMutably(updates, state) {
7250 var newKeys = {};
7251 var updatesPerEntity = {};
7252 updates.forEach(function (update) {
7253 if (update.id in state.entities) {
7254 updatesPerEntity[update.id] = {
7255 id: update.id,
7256 changes: __spreadValues(__spreadValues({}, updatesPerEntity[update.id] ? updatesPerEntity[update.id].changes : null), update.changes)
7257 };
7258 }
7259 });
7260 updates = Object.values(updatesPerEntity);
7261 var didMutateEntities = updates.length > 0;
7262 if (didMutateEntities) {
7263 var didMutateIds = updates.filter(function (update) { return takeNewKey(newKeys, update, state); }).length > 0;
7264 if (didMutateIds) {
7265 state.ids = Object.keys(state.entities);
7266 }
7267 }
7268 }
7269 function upsertOneMutably(entity, state) {
7270 return upsertManyMutably([entity], state);
7271 }
7272 function upsertManyMutably(newEntities, state) {
7273 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7274 updateManyMutably(updated, state);
7275 addManyMutably(added, state);
7276 }
7277 return {
7278 removeAll: createSingleArgumentStateOperator(removeAllMutably),
7279 addOne: createStateOperator(addOneMutably),
7280 addMany: createStateOperator(addManyMutably),
7281 setOne: createStateOperator(setOneMutably),
7282 setMany: createStateOperator(setManyMutably),
7283 setAll: createStateOperator(setAllMutably),
7284 updateOne: createStateOperator(updateOneMutably),
7285 updateMany: createStateOperator(updateManyMutably),
7286 upsertOne: createStateOperator(upsertOneMutably),
7287 upsertMany: createStateOperator(upsertManyMutably),
7288 removeOne: createStateOperator(removeOneMutably),
7289 removeMany: createStateOperator(removeManyMutably)
7290 };
7291 }
7292 // src/entities/sorted_state_adapter.ts
7293 function createSortedStateAdapter(selectId, sort) {
7294 var _c = createUnsortedStateAdapter(selectId), removeOne = _c.removeOne, removeMany = _c.removeMany, removeAll = _c.removeAll;
7295 function addOneMutably(entity, state) {
7296 return addManyMutably([entity], state);
7297 }
7298 function addManyMutably(newEntities, state) {
7299 newEntities = ensureEntitiesArray(newEntities);
7300 var models = newEntities.filter(function (model) { return !(selectIdValue(model, selectId) in state.entities); });
7301 if (models.length !== 0) {
7302 merge(models, state);
7303 }
7304 }
7305 function setOneMutably(entity, state) {
7306 return setManyMutably([entity], state);
7307 }
7308 function setManyMutably(newEntities, state) {
7309 newEntities = ensureEntitiesArray(newEntities);
7310 if (newEntities.length !== 0) {
7311 merge(newEntities, state);
7312 }
7313 }
7314 function setAllMutably(newEntities, state) {
7315 newEntities = ensureEntitiesArray(newEntities);
7316 state.entities = {};
7317 state.ids = [];
7318 addManyMutably(newEntities, state);
7319 }
7320 function updateOneMutably(update, state) {
7321 return updateManyMutably([update], state);
7322 }
7323 function updateManyMutably(updates, state) {
7324 var appliedUpdates = false;
7325 for (var _i = 0, updates_1 = updates; _i < updates_1.length; _i++) {
7326 var update = updates_1[_i];
7327 var entity = state.entities[update.id];
7328 if (!entity) {
7329 continue;
7330 }
7331 appliedUpdates = true;
7332 Object.assign(entity, update.changes);
7333 var newId = selectId(entity);
7334 if (update.id !== newId) {
7335 delete state.entities[update.id];
7336 state.entities[newId] = entity;
7337 }
7338 }
7339 if (appliedUpdates) {
7340 resortEntities(state);
7341 }
7342 }
7343 function upsertOneMutably(entity, state) {
7344 return upsertManyMutably([entity], state);
7345 }
7346 function upsertManyMutably(newEntities, state) {
7347 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7348 updateManyMutably(updated, state);
7349 addManyMutably(added, state);
7350 }
7351 function areArraysEqual(a, b) {
7352 if (a.length !== b.length) {
7353 return false;
7354 }
7355 for (var i = 0; i < a.length && i < b.length; i++) {
7356 if (a[i] === b[i]) {
7357 continue;
7358 }
7359 return false;
7360 }
7361 return true;
7362 }
7363 function merge(models, state) {
7364 models.forEach(function (model) {
7365 state.entities[selectId(model)] = model;
7366 });
7367 resortEntities(state);
7368 }
7369 function resortEntities(state) {
7370 var allEntities = Object.values(state.entities);
7371 allEntities.sort(sort);
7372 var newSortedIds = allEntities.map(selectId);
7373 var ids = state.ids;
7374 if (!areArraysEqual(ids, newSortedIds)) {
7375 state.ids = newSortedIds;
7376 }
7377 }
7378 return {
7379 removeOne: removeOne,
7380 removeMany: removeMany,
7381 removeAll: removeAll,
7382 addOne: createStateOperator(addOneMutably),
7383 updateOne: createStateOperator(updateOneMutably),
7384 upsertOne: createStateOperator(upsertOneMutably),
7385 setOne: createStateOperator(setOneMutably),
7386 setMany: createStateOperator(setManyMutably),
7387 setAll: createStateOperator(setAllMutably),
7388 addMany: createStateOperator(addManyMutably),
7389 updateMany: createStateOperator(updateManyMutably),
7390 upsertMany: createStateOperator(upsertManyMutably)
7391 };
7392 }
7393 // src/entities/create_adapter.ts
7394 function createEntityAdapter(options) {
7395 if (options === void 0) { options = {}; }
7396 var _c = __spreadValues({
7397 sortComparer: false,
7398 selectId: function (instance) { return instance.id; }
7399 }, options), selectId = _c.selectId, sortComparer = _c.sortComparer;
7400 var stateFactory = createInitialStateFactory();
7401 var selectorsFactory = createSelectorsFactory();
7402 var stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
7403 return __spreadValues(__spreadValues(__spreadValues({
7404 selectId: selectId,
7405 sortComparer: sortComparer
7406 }, stateFactory), selectorsFactory), stateAdapter);
7407 }
7408 // src/nanoid.ts
7409 var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
7410 var nanoid = function (size) {
7411 if (size === void 0) { size = 21; }
7412 var id = "";
7413 var i = size;
7414 while (i--) {
7415 id += urlAlphabet[Math.random() * 64 | 0];
7416 }
7417 return id;
7418 };
7419 // src/createAsyncThunk.ts
7420 var commonProperties = [
7421 "name",
7422 "message",
7423 "stack",
7424 "code"
7425 ];
7426 var RejectWithValue = /** @class */ (function () {
7427 function RejectWithValue(payload, meta) {
7428 this.payload = payload;
7429 this.meta = meta;
7430 }
7431 return RejectWithValue;
7432 }());
7433 var FulfillWithMeta = /** @class */ (function () {
7434 function FulfillWithMeta(payload, meta) {
7435 this.payload = payload;
7436 this.meta = meta;
7437 }
7438 return FulfillWithMeta;
7439 }());
7440 var miniSerializeError = function (value) {
7441 if (typeof value === "object" && value !== null) {
7442 var simpleError = {};
7443 for (var _i = 0, commonProperties_1 = commonProperties; _i < commonProperties_1.length; _i++) {
7444 var property = commonProperties_1[_i];
7445 if (typeof value[property] === "string") {
7446 simpleError[property] = value[property];
7447 }
7448 }
7449 return simpleError;
7450 }
7451 return { message: String(value) };
7452 };
7453 var createAsyncThunk = (function () {
7454 function createAsyncThunk2(typePrefix, payloadCreator, options) {
7455 var fulfilled = createAction(typePrefix + "/fulfilled", function (payload, requestId, arg, meta) { return ({
7456 payload: payload,
7457 meta: __spreadProps(__spreadValues({}, meta || {}), {
7458 arg: arg,
7459 requestId: requestId,
7460 requestStatus: "fulfilled"
7461 })
7462 }); });
7463 var pending = createAction(typePrefix + "/pending", function (requestId, arg, meta) { return ({
7464 payload: void 0,
7465 meta: __spreadProps(__spreadValues({}, meta || {}), {
7466 arg: arg,
7467 requestId: requestId,
7468 requestStatus: "pending"
7469 })
7470 }); });
7471 var rejected = createAction(typePrefix + "/rejected", function (error, requestId, arg, payload, meta) { return ({
7472 payload: payload,
7473 error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
7474 meta: __spreadProps(__spreadValues({}, meta || {}), {
7475 arg: arg,
7476 requestId: requestId,
7477 rejectedWithValue: !!payload,
7478 requestStatus: "rejected",
7479 aborted: (error == null ? void 0 : error.name) === "AbortError",
7480 condition: (error == null ? void 0 : error.name) === "ConditionError"
7481 })
7482 }); });
7483 var displayedWarning = false;
7484 var AC = typeof AbortController !== "undefined" ? AbortController : /** @class */ (function () {
7485 function class_1() {
7486 this.signal = {
7487 aborted: false,
7488 addEventListener: function () {
7489 },
7490 dispatchEvent: function () {
7491 return false;
7492 },
7493 onabort: function () {
7494 },
7495 removeEventListener: function () {
7496 },
7497 reason: void 0,
7498 throwIfAborted: function () {
7499 }
7500 };
7501 }
7502 class_1.prototype.abort = function () {
7503 if (true) {
7504 if (!displayedWarning) {
7505 displayedWarning = true;
7506 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'.");
7507 }
7508 }
7509 };
7510 return class_1;
7511 }());
7512 function actionCreator(arg) {
7513 return function (dispatch, getState, extra) {
7514 var requestId = (options == null ? void 0 : options.idGenerator) ? options.idGenerator(arg) : nanoid();
7515 var abortController = new AC();
7516 var abortReason;
7517 var started = false;
7518 function abort(reason) {
7519 abortReason = reason;
7520 abortController.abort();
7521 }
7522 var promise2 = function () {
7523 return __async(this, null, function () {
7524 var _a, _b, finalAction, conditionResult, abortedPromise, err_1, skipDispatch;
7525 return __generator(this, function (_c) {
7526 switch (_c.label) {
7527 case 0:
7528 _c.trys.push([0, 4, , 5]);
7529 conditionResult = (_a = options == null ? void 0 : options.condition) == null ? void 0 : _a.call(options, arg, { getState: getState, extra: extra });
7530 if (!isThenable(conditionResult)) return [3 /*break*/, 2];
7531 return [4 /*yield*/, conditionResult];
7532 case 1:
7533 conditionResult = _c.sent();
7534 _c.label = 2;
7535 case 2:
7536 if (conditionResult === false || abortController.signal.aborted) {
7537 throw {
7538 name: "ConditionError",
7539 message: "Aborted due to condition callback returning false."
7540 };
7541 }
7542 started = true;
7543 abortedPromise = new Promise(function (_, reject) { return abortController.signal.addEventListener("abort", function () { return reject({
7544 name: "AbortError",
7545 message: abortReason || "Aborted"
7546 }); }); });
7547 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 })));
7548 return [4 /*yield*/, Promise.race([
7549 abortedPromise,
7550 Promise.resolve(payloadCreator(arg, {
7551 dispatch: dispatch,
7552 getState: getState,
7553 extra: extra,
7554 requestId: requestId,
7555 signal: abortController.signal,
7556 abort: abort,
7557 rejectWithValue: function (value, meta) {
7558 return new RejectWithValue(value, meta);
7559 },
7560 fulfillWithValue: function (value, meta) {
7561 return new FulfillWithMeta(value, meta);
7562 }
7563 })).then(function (result) {
7564 if (result instanceof RejectWithValue) {
7565 throw result;
7566 }
7567 if (result instanceof FulfillWithMeta) {
7568 return fulfilled(result.payload, requestId, arg, result.meta);
7569 }
7570 return fulfilled(result, requestId, arg);
7571 })
7572 ])];
7573 case 3:
7574 finalAction = _c.sent();
7575 return [3 /*break*/, 5];
7576 case 4:
7577 err_1 = _c.sent();
7578 finalAction = err_1 instanceof RejectWithValue ? rejected(null, requestId, arg, err_1.payload, err_1.meta) : rejected(err_1, requestId, arg);
7579 return [3 /*break*/, 5];
7580 case 5:
7581 skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
7582 if (!skipDispatch) {
7583 dispatch(finalAction);
7584 }
7585 return [2 /*return*/, finalAction];
7586 }
7587 });
7588 });
7589 }();
7590 return Object.assign(promise2, {
7591 abort: abort,
7592 requestId: requestId,
7593 arg: arg,
7594 unwrap: function () {
7595 return promise2.then(unwrapResult);
7596 }
7597 });
7598 };
7599 }
7600 return Object.assign(actionCreator, {
7601 pending: pending,
7602 rejected: rejected,
7603 fulfilled: fulfilled,
7604 typePrefix: typePrefix
7605 });
7606 }
7607 createAsyncThunk2.withTypes = function () { return createAsyncThunk2; };
7608 return createAsyncThunk2;
7609 })();
7610 function unwrapResult(action) {
7611 if (action.meta && action.meta.rejectedWithValue) {
7612 throw action.payload;
7613 }
7614 if (action.error) {
7615 throw action.error;
7616 }
7617 return action.payload;
7618 }
7619 function isThenable(value) {
7620 return value !== null && typeof value === "object" && typeof value.then === "function";
7621 }
7622 // src/matchers.ts
7623 var matches = function (matcher, action) {
7624 if (hasMatchFunction(matcher)) {
7625 return matcher.match(action);
7626 }
7627 else {
7628 return matcher(action);
7629 }
7630 };
7631 function isAnyOf() {
7632 var matchers = [];
7633 for (var _i = 0; _i < arguments.length; _i++) {
7634 matchers[_i] = arguments[_i];
7635 }
7636 return function (action) {
7637 return matchers.some(function (matcher) { return matches(matcher, action); });
7638 };
7639 }
7640 function isAllOf() {
7641 var matchers = [];
7642 for (var _i = 0; _i < arguments.length; _i++) {
7643 matchers[_i] = arguments[_i];
7644 }
7645 return function (action) {
7646 return matchers.every(function (matcher) { return matches(matcher, action); });
7647 };
7648 }
7649 function hasExpectedRequestMetadata(action, validStatus) {
7650 if (!action || !action.meta)
7651 return false;
7652 var hasValidRequestId = typeof action.meta.requestId === "string";
7653 var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
7654 return hasValidRequestId && hasValidRequestStatus;
7655 }
7656 function isAsyncThunkArray(a) {
7657 return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
7658 }
7659 function isPending() {
7660 var asyncThunks = [];
7661 for (var _i = 0; _i < arguments.length; _i++) {
7662 asyncThunks[_i] = arguments[_i];
7663 }
7664 if (asyncThunks.length === 0) {
7665 return function (action) { return hasExpectedRequestMetadata(action, ["pending"]); };
7666 }
7667 if (!isAsyncThunkArray(asyncThunks)) {
7668 return isPending()(asyncThunks[0]);
7669 }
7670 return function (action) {
7671 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.pending; });
7672 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7673 return combinedMatcher(action);
7674 };
7675 }
7676 function isRejected() {
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, ["rejected"]); };
7683 }
7684 if (!isAsyncThunkArray(asyncThunks)) {
7685 return isRejected()(asyncThunks[0]);
7686 }
7687 return function (action) {
7688 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.rejected; });
7689 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7690 return combinedMatcher(action);
7691 };
7692 }
7693 function isRejectedWithValue() {
7694 var asyncThunks = [];
7695 for (var _i = 0; _i < arguments.length; _i++) {
7696 asyncThunks[_i] = arguments[_i];
7697 }
7698 var hasFlag = function (action) {
7699 return action && action.meta && action.meta.rejectedWithValue;
7700 };
7701 if (asyncThunks.length === 0) {
7702 return function (action) {
7703 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
7704 return combinedMatcher(action);
7705 };
7706 }
7707 if (!isAsyncThunkArray(asyncThunks)) {
7708 return isRejectedWithValue()(asyncThunks[0]);
7709 }
7710 return function (action) {
7711 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
7712 return combinedMatcher(action);
7713 };
7714 }
7715 function isFulfilled() {
7716 var asyncThunks = [];
7717 for (var _i = 0; _i < arguments.length; _i++) {
7718 asyncThunks[_i] = arguments[_i];
7719 }
7720 if (asyncThunks.length === 0) {
7721 return function (action) { return hasExpectedRequestMetadata(action, ["fulfilled"]); };
7722 }
7723 if (!isAsyncThunkArray(asyncThunks)) {
7724 return isFulfilled()(asyncThunks[0]);
7725 }
7726 return function (action) {
7727 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.fulfilled; });
7728 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7729 return combinedMatcher(action);
7730 };
7731 }
7732 function isAsyncThunkAction() {
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, ["pending", "fulfilled", "rejected"]); };
7739 }
7740 if (!isAsyncThunkArray(asyncThunks)) {
7741 return isAsyncThunkAction()(asyncThunks[0]);
7742 }
7743 return function (action) {
7744 var matchers = [];
7745 for (var _i = 0, asyncThunks_1 = asyncThunks; _i < asyncThunks_1.length; _i++) {
7746 var asyncThunk = asyncThunks_1[_i];
7747 matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
7748 }
7749 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7750 return combinedMatcher(action);
7751 };
7752 }
7753 // src/listenerMiddleware/utils.ts
7754 var assertFunction = function (func, expected) {
7755 if (typeof func !== "function") {
7756 throw new TypeError(expected + " is not a function");
7757 }
7758 };
7759 var noop = function () {
7760 };
7761 var catchRejection = function (promise2, onError) {
7762 if (onError === void 0) { onError = noop; }
7763 promise2.catch(onError);
7764 return promise2;
7765 };
7766 var addAbortSignalListener = function (abortSignal, callback) {
7767 abortSignal.addEventListener("abort", callback, { once: true });
7768 return function () { return abortSignal.removeEventListener("abort", callback); };
7769 };
7770 var abortControllerWithReason = function (abortController, reason) {
7771 var signal = abortController.signal;
7772 if (signal.aborted) {
7773 return;
7774 }
7775 if (!("reason" in signal)) {
7776 Object.defineProperty(signal, "reason", {
7777 enumerable: true,
7778 value: reason,
7779 configurable: true,
7780 writable: true
7781 });
7782 }
7783 ;
7784 abortController.abort(reason);
7785 };
7786 // src/listenerMiddleware/exceptions.ts
7787 var task = "task";
7788 var listener = "listener";
7789 var completed = "completed";
7790 var cancelled = "cancelled";
7791 var taskCancelled = "task-" + cancelled;
7792 var taskCompleted = "task-" + completed;
7793 var listenerCancelled = listener + "-" + cancelled;
7794 var listenerCompleted = listener + "-" + completed;
7795 var TaskAbortError = /** @class */ (function () {
7796 function TaskAbortError(code) {
7797 this.code = code;
7798 this.name = "TaskAbortError";
7799 this.message = task + " " + cancelled + " (reason: " + code + ")";
7800 }
7801 return TaskAbortError;
7802 }());
7803 // src/listenerMiddleware/task.ts
7804 var validateActive = function (signal) {
7805 if (signal.aborted) {
7806 throw new TaskAbortError(signal.reason);
7807 }
7808 };
7809 function raceWithSignal(signal, promise2) {
7810 var cleanup = noop;
7811 return new Promise(function (resolve, reject) {
7812 var notifyRejection = function () { return reject(new TaskAbortError(signal.reason)); };
7813 if (signal.aborted) {
7814 notifyRejection();
7815 return;
7816 }
7817 cleanup = addAbortSignalListener(signal, notifyRejection);
7818 promise2.finally(function () { return cleanup(); }).then(resolve, reject);
7819 }).finally(function () {
7820 cleanup = noop;
7821 });
7822 }
7823 var runTask = function (task2, cleanUp) { return __async(void 0, null, function () {
7824 var value, error_1;
7825 return __generator(this, function (_c) {
7826 switch (_c.label) {
7827 case 0:
7828 _c.trys.push([0, 3, 4, 5]);
7829 return [4 /*yield*/, Promise.resolve()];
7830 case 1:
7831 _c.sent();
7832 return [4 /*yield*/, task2()];
7833 case 2:
7834 value = _c.sent();
7835 return [2 /*return*/, {
7836 status: "ok",
7837 value: value
7838 }];
7839 case 3:
7840 error_1 = _c.sent();
7841 return [2 /*return*/, {
7842 status: error_1 instanceof TaskAbortError ? "cancelled" : "rejected",
7843 error: error_1
7844 }];
7845 case 4:
7846 cleanUp == null ? void 0 : cleanUp();
7847 return [7 /*endfinally*/];
7848 case 5: return [2 /*return*/];
7849 }
7850 });
7851 }); };
7852 var createPause = function (signal) {
7853 return function (promise2) {
7854 return catchRejection(raceWithSignal(signal, promise2).then(function (output) {
7855 validateActive(signal);
7856 return output;
7857 }));
7858 };
7859 };
7860 var createDelay = function (signal) {
7861 var pause = createPause(signal);
7862 return function (timeoutMs) {
7863 return pause(new Promise(function (resolve) { return setTimeout(resolve, timeoutMs); }));
7864 };
7865 };
7866 // src/listenerMiddleware/index.ts
7867 var assign = Object.assign;
7868 var INTERNAL_NIL_TOKEN = {};
7869 var alm = "listenerMiddleware";
7870 var createFork = function (parentAbortSignal, parentBlockingPromises) {
7871 var linkControllers = function (controller) { return addAbortSignalListener(parentAbortSignal, function () { return abortControllerWithReason(controller, parentAbortSignal.reason); }); };
7872 return function (taskExecutor, opts) {
7873 assertFunction(taskExecutor, "taskExecutor");
7874 var childAbortController = new AbortController();
7875 linkControllers(childAbortController);
7876 var result = runTask(function () { return __async(void 0, null, function () {
7877 var result2;
7878 return __generator(this, function (_c) {
7879 switch (_c.label) {
7880 case 0:
7881 validateActive(parentAbortSignal);
7882 validateActive(childAbortController.signal);
7883 return [4 /*yield*/, taskExecutor({
7884 pause: createPause(childAbortController.signal),
7885 delay: createDelay(childAbortController.signal),
7886 signal: childAbortController.signal
7887 })];
7888 case 1:
7889 result2 = _c.sent();
7890 validateActive(childAbortController.signal);
7891 return [2 /*return*/, result2];
7892 }
7893 });
7894 }); }, function () { return abortControllerWithReason(childAbortController, taskCompleted); });
7895 if (opts == null ? void 0 : opts.autoJoin) {
7896 parentBlockingPromises.push(result);
7897 }
7898 return {
7899 result: createPause(parentAbortSignal)(result),
7900 cancel: function () {
7901 abortControllerWithReason(childAbortController, taskCancelled);
7902 }
7903 };
7904 };
7905 };
7906 var createTakePattern = function (startListening, signal) {
7907 var take = function (predicate, timeout) { return __async(void 0, null, function () {
7908 var unsubscribe, tuplePromise, promises, output;
7909 return __generator(this, function (_c) {
7910 switch (_c.label) {
7911 case 0:
7912 validateActive(signal);
7913 unsubscribe = function () {
7914 };
7915 tuplePromise = new Promise(function (resolve, reject) {
7916 var stopListening = startListening({
7917 predicate: predicate,
7918 effect: function (action, listenerApi) {
7919 listenerApi.unsubscribe();
7920 resolve([
7921 action,
7922 listenerApi.getState(),
7923 listenerApi.getOriginalState()
7924 ]);
7925 }
7926 });
7927 unsubscribe = function () {
7928 stopListening();
7929 reject();
7930 };
7931 });
7932 promises = [
7933 tuplePromise
7934 ];
7935 if (timeout != null) {
7936 promises.push(new Promise(function (resolve) { return setTimeout(resolve, timeout, null); }));
7937 }
7938 _c.label = 1;
7939 case 1:
7940 _c.trys.push([1, , 3, 4]);
7941 return [4 /*yield*/, raceWithSignal(signal, Promise.race(promises))];
7942 case 2:
7943 output = _c.sent();
7944 validateActive(signal);
7945 return [2 /*return*/, output];
7946 case 3:
7947 unsubscribe();
7948 return [7 /*endfinally*/];
7949 case 4: return [2 /*return*/];
7950 }
7951 });
7952 }); };
7953 return function (predicate, timeout) { return catchRejection(take(predicate, timeout)); };
7954 };
7955 var getListenerEntryPropsFrom = function (options) {
7956 var type = options.type, actionCreator = options.actionCreator, matcher = options.matcher, predicate = options.predicate, effect = options.effect;
7957 if (type) {
7958 predicate = createAction(type).match;
7959 }
7960 else if (actionCreator) {
7961 type = actionCreator.type;
7962 predicate = actionCreator.match;
7963 }
7964 else if (matcher) {
7965 predicate = matcher;
7966 }
7967 else if (predicate) {
7968 }
7969 else {
7970 throw new Error("Creating or removing a listener requires one of the known fields for matching an action");
7971 }
7972 assertFunction(effect, "options.listener");
7973 return { predicate: predicate, type: type, effect: effect };
7974 };
7975 var createListenerEntry = function (options) {
7976 var _c = getListenerEntryPropsFrom(options), type = _c.type, predicate = _c.predicate, effect = _c.effect;
7977 var id = nanoid();
7978 var entry = {
7979 id: id,
7980 effect: effect,
7981 type: type,
7982 predicate: predicate,
7983 pending: new Set(),
7984 unsubscribe: function () {
7985 throw new Error("Unsubscribe not initialized");
7986 }
7987 };
7988 return entry;
7989 };
7990 var cancelActiveListeners = function (entry) {
7991 entry.pending.forEach(function (controller) {
7992 abortControllerWithReason(controller, listenerCancelled);
7993 });
7994 };
7995 var createClearListenerMiddleware = function (listenerMap) {
7996 return function () {
7997 listenerMap.forEach(cancelActiveListeners);
7998 listenerMap.clear();
7999 };
8000 };
8001 var safelyNotifyError = function (errorHandler, errorToNotify, errorInfo) {
8002 try {
8003 errorHandler(errorToNotify, errorInfo);
8004 }
8005 catch (errorHandlerError) {
8006 setTimeout(function () {
8007 throw errorHandlerError;
8008 }, 0);
8009 }
8010 };
8011 var addListener = createAction(alm + "/add");
8012 var clearAllListeners = createAction(alm + "/removeAll");
8013 var removeListener = createAction(alm + "/remove");
8014 var defaultErrorHandler = function () {
8015 var args = [];
8016 for (var _i = 0; _i < arguments.length; _i++) {
8017 args[_i] = arguments[_i];
8018 }
8019 console.error.apply(console, __spreadArray([alm + "/error"], args));
8020 };
8021 function createListenerMiddleware(middlewareOptions) {
8022 var _this = this;
8023 if (middlewareOptions === void 0) { middlewareOptions = {}; }
8024 var listenerMap = new Map();
8025 var extra = middlewareOptions.extra, _c = middlewareOptions.onError, onError = _c === void 0 ? defaultErrorHandler : _c;
8026 assertFunction(onError, "onError");
8027 var insertEntry = function (entry) {
8028 entry.unsubscribe = function () { return listenerMap.delete(entry.id); };
8029 listenerMap.set(entry.id, entry);
8030 return function (cancelOptions) {
8031 entry.unsubscribe();
8032 if (cancelOptions == null ? void 0 : cancelOptions.cancelActive) {
8033 cancelActiveListeners(entry);
8034 }
8035 };
8036 };
8037 var findListenerEntry = function (comparator) {
8038 for (var _i = 0, _c = Array.from(listenerMap.values()); _i < _c.length; _i++) {
8039 var entry = _c[_i];
8040 if (comparator(entry)) {
8041 return entry;
8042 }
8043 }
8044 return void 0;
8045 };
8046 var startListening = function (options) {
8047 var entry = findListenerEntry(function (existingEntry) { return existingEntry.effect === options.effect; });
8048 if (!entry) {
8049 entry = createListenerEntry(options);
8050 }
8051 return insertEntry(entry);
8052 };
8053 var stopListening = function (options) {
8054 var _c = getListenerEntryPropsFrom(options), type = _c.type, effect = _c.effect, predicate = _c.predicate;
8055 var entry = findListenerEntry(function (entry2) {
8056 var matchPredicateOrType = typeof type === "string" ? entry2.type === type : entry2.predicate === predicate;
8057 return matchPredicateOrType && entry2.effect === effect;
8058 });
8059 if (entry) {
8060 entry.unsubscribe();
8061 if (options.cancelActive) {
8062 cancelActiveListeners(entry);
8063 }
8064 }
8065 return !!entry;
8066 };
8067 var notifyListener = function (entry, action, api, getOriginalState) { return __async(_this, null, function () {
8068 var internalTaskController, take, autoJoinPromises, listenerError_1;
8069 return __generator(this, function (_c) {
8070 switch (_c.label) {
8071 case 0:
8072 internalTaskController = new AbortController();
8073 take = createTakePattern(startListening, internalTaskController.signal);
8074 autoJoinPromises = [];
8075 _c.label = 1;
8076 case 1:
8077 _c.trys.push([1, 3, 4, 6]);
8078 entry.pending.add(internalTaskController);
8079 return [4 /*yield*/, Promise.resolve(entry.effect(action, assign({}, api, {
8080 getOriginalState: getOriginalState,
8081 condition: function (predicate, timeout) { return take(predicate, timeout).then(Boolean); },
8082 take: take,
8083 delay: createDelay(internalTaskController.signal),
8084 pause: createPause(internalTaskController.signal),
8085 extra: extra,
8086 signal: internalTaskController.signal,
8087 fork: createFork(internalTaskController.signal, autoJoinPromises),
8088 unsubscribe: entry.unsubscribe,
8089 subscribe: function () {
8090 listenerMap.set(entry.id, entry);
8091 },
8092 cancelActiveListeners: function () {
8093 entry.pending.forEach(function (controller, _, set) {
8094 if (controller !== internalTaskController) {
8095 abortControllerWithReason(controller, listenerCancelled);
8096 set.delete(controller);
8097 }
8098 });
8099 }
8100 })))];
8101 case 2:
8102 _c.sent();
8103 return [3 /*break*/, 6];
8104 case 3:
8105 listenerError_1 = _c.sent();
8106 if (!(listenerError_1 instanceof TaskAbortError)) {
8107 safelyNotifyError(onError, listenerError_1, {
8108 raisedBy: "effect"
8109 });
8110 }
8111 return [3 /*break*/, 6];
8112 case 4: return [4 /*yield*/, Promise.allSettled(autoJoinPromises)];
8113 case 5:
8114 _c.sent();
8115 abortControllerWithReason(internalTaskController, listenerCompleted);
8116 entry.pending.delete(internalTaskController);
8117 return [7 /*endfinally*/];
8118 case 6: return [2 /*return*/];
8119 }
8120 });
8121 }); };
8122 var clearListenerMiddleware = createClearListenerMiddleware(listenerMap);
8123 var middleware = function (api) { return function (next) { return function (action) {
8124 if (!isAction(action)) {
8125 return next(action);
8126 }
8127 if (addListener.match(action)) {
8128 return startListening(action.payload);
8129 }
8130 if (clearAllListeners.match(action)) {
8131 clearListenerMiddleware();
8132 return;
8133 }
8134 if (removeListener.match(action)) {
8135 return stopListening(action.payload);
8136 }
8137 var originalState = api.getState();
8138 var getOriginalState = function () {
8139 if (originalState === INTERNAL_NIL_TOKEN) {
8140 throw new Error(alm + ": getOriginalState can only be called synchronously");
8141 }
8142 return originalState;
8143 };
8144 var result;
8145 try {
8146 result = next(action);
8147 if (listenerMap.size > 0) {
8148 var currentState = api.getState();
8149 var listenerEntries = Array.from(listenerMap.values());
8150 for (var _i = 0, listenerEntries_1 = listenerEntries; _i < listenerEntries_1.length; _i++) {
8151 var entry = listenerEntries_1[_i];
8152 var runListener = false;
8153 try {
8154 runListener = entry.predicate(action, currentState, originalState);
8155 }
8156 catch (predicateError) {
8157 runListener = false;
8158 safelyNotifyError(onError, predicateError, {
8159 raisedBy: "predicate"
8160 });
8161 }
8162 if (!runListener) {
8163 continue;
8164 }
8165 notifyListener(entry, action, api, getOriginalState);
8166 }
8167 }
8168 }
8169 finally {
8170 originalState = INTERNAL_NIL_TOKEN;
8171 }
8172 return result;
8173 }; }; };
8174 return {
8175 middleware: middleware,
8176 startListening: startListening,
8177 stopListening: stopListening,
8178 clearListeners: clearListenerMiddleware
8179 };
8180 }
8181 // src/autoBatchEnhancer.ts
8182 var SHOULD_AUTOBATCH = "RTK_autoBatch";
8183 var prepareAutoBatched = function () { return function (payload) {
8184 var _c;
8185 return ({
8186 payload: payload,
8187 meta: (_c = {}, _c[SHOULD_AUTOBATCH] = true, _c)
8188 });
8189 }; };
8190 var promise;
8191 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 () {
8192 throw err;
8193 }, 0); }); };
8194 var createQueueWithTimer = function (timeout) {
8195 return function (notify) {
8196 setTimeout(notify, timeout);
8197 };
8198 };
8199 var rAF = typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10);
8200 var autoBatchEnhancer = function (options) {
8201 if (options === void 0) { options = { type: "raf" }; }
8202 return function (next) { return function () {
8203 var args = [];
8204 for (var _i = 0; _i < arguments.length; _i++) {
8205 args[_i] = arguments[_i];
8206 }
8207 var store = next.apply(void 0, args);
8208 var notifying = true;
8209 var shouldNotifyAtEndOfTick = false;
8210 var notificationQueued = false;
8211 var listeners = new Set();
8212 var queueCallback = options.type === "tick" ? queueMicrotaskShim : options.type === "raf" ? rAF : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
8213 var notifyListeners = function () {
8214 notificationQueued = false;
8215 if (shouldNotifyAtEndOfTick) {
8216 shouldNotifyAtEndOfTick = false;
8217 listeners.forEach(function (l) { return l(); });
8218 }
8219 };
8220 return Object.assign({}, store, {
8221 subscribe: function (listener2) {
8222 var wrappedListener = function () { return notifying && listener2(); };
8223 var unsubscribe = store.subscribe(wrappedListener);
8224 listeners.add(listener2);
8225 return function () {
8226 unsubscribe();
8227 listeners.delete(listener2);
8228 };
8229 },
8230 dispatch: function (action) {
8231 var _a;
8232 try {
8233 notifying = !((_a = action == null ? void 0 : action.meta) == null ? void 0 : _a[SHOULD_AUTOBATCH]);
8234 shouldNotifyAtEndOfTick = !notifying;
8235 if (shouldNotifyAtEndOfTick) {
8236 if (!notificationQueued) {
8237 notificationQueued = true;
8238 queueCallback(notifyListeners);
8239 }
8240 }
8241 return store.dispatch(action);
8242 }
8243 finally {
8244 notifying = true;
8245 }
8246 }
8247 });
8248 }; };
8249 };
8250 // src/index.ts
8251 (0,immer__WEBPACK_IMPORTED_MODULE_0__.enableES5)();
8252
8253 //# sourceMappingURL=redux-toolkit.esm.js.map
8254
8255 /***/ }),
8256
8257 /***/ "../node_modules/immer/dist/immer.esm.mjs":
8258 /*!************************************************!*\
8259 !*** ../node_modules/immer/dist/immer.esm.mjs ***!
8260 \************************************************/
8261 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8262
8263 "use strict";
8264 __webpack_require__.r(__webpack_exports__);
8265 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8266 /* harmony export */ Immer: () => (/* binding */ un),
8267 /* harmony export */ applyPatches: () => (/* binding */ pn),
8268 /* harmony export */ castDraft: () => (/* binding */ K),
8269 /* harmony export */ castImmutable: () => (/* binding */ $),
8270 /* harmony export */ createDraft: () => (/* binding */ ln),
8271 /* harmony export */ current: () => (/* binding */ R),
8272 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
8273 /* harmony export */ enableAllPlugins: () => (/* binding */ J),
8274 /* harmony export */ enableES5: () => (/* binding */ F),
8275 /* harmony export */ enableMapSet: () => (/* binding */ C),
8276 /* harmony export */ enablePatches: () => (/* binding */ T),
8277 /* harmony export */ finishDraft: () => (/* binding */ dn),
8278 /* harmony export */ freeze: () => (/* binding */ d),
8279 /* harmony export */ immerable: () => (/* binding */ L),
8280 /* harmony export */ isDraft: () => (/* binding */ r),
8281 /* harmony export */ isDraftable: () => (/* binding */ t),
8282 /* harmony export */ nothing: () => (/* binding */ H),
8283 /* harmony export */ original: () => (/* binding */ e),
8284 /* harmony export */ produce: () => (/* binding */ fn),
8285 /* harmony export */ produceWithPatches: () => (/* binding */ cn),
8286 /* harmony export */ setAutoFreeze: () => (/* binding */ sn),
8287 /* harmony export */ setUseProxies: () => (/* binding */ vn)
8288 /* harmony export */ });
8289 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
8290 }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);
8291 //# sourceMappingURL=immer.esm.js.map
8292
8293
8294 /***/ }),
8295
8296 /***/ "../node_modules/mixpanel-browser/dist/mixpanel.module.js":
8297 /*!****************************************************************!*\
8298 !*** ../node_modules/mixpanel-browser/dist/mixpanel.module.js ***!
8299 \****************************************************************/
8300 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8301
8302 "use strict";
8303 __webpack_require__.r(__webpack_exports__);
8304 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8305 /* harmony export */ "default": () => (/* binding */ mixpanel)
8306 /* harmony export */ });
8307 // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
8308 var win;
8309 if (typeof(window) === 'undefined') {
8310 var loc = {
8311 hostname: ''
8312 };
8313 win = {
8314 crypto: {randomUUID: function() {throw Error('unsupported');}},
8315 navigator: { userAgent: '', onLine: true },
8316 document: {
8317 createElement: function() { return {}; },
8318 location: loc,
8319 referrer: ''
8320 },
8321 screen: { width: 0, height: 0 },
8322 location: loc,
8323 addEventListener: function() {},
8324 removeEventListener: function() {}
8325 };
8326 } else {
8327 win = window;
8328 }
8329
8330 function _array_like_to_array(arr, len) {
8331 if (len == null || len > arr.length) len = arr.length;
8332 for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8333 return arr2;
8334 }
8335 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8336 try {
8337 var info = gen[key](arg);
8338 var value = info.value;
8339 } catch (error) {
8340 reject(error);
8341 return;
8342 }
8343 if (info.done) {
8344 resolve(value);
8345 } else {
8346 Promise.resolve(value).then(_next, _throw);
8347 }
8348 }
8349 function _async_to_generator(fn) {
8350 return function() {
8351 var self = this, args = arguments;
8352 return new Promise(function(resolve, reject) {
8353 var gen = fn.apply(self, args);
8354 function _next(value) {
8355 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8356 }
8357 function _throw(err) {
8358 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8359 }
8360 _next(undefined);
8361 });
8362 };
8363 }
8364 function _construct(Parent, args, Class) {
8365 if (_is_native_reflect_construct()) {
8366 _construct = Reflect.construct;
8367 } else {
8368 _construct = function construct(Parent, args, Class) {
8369 var a = [
8370 null
8371 ];
8372 a.push.apply(a, args);
8373 var Constructor = Function.bind.apply(Parent, a);
8374 var instance = new Constructor();
8375 if (Class) _set_prototype_of(instance, Class.prototype);
8376 return instance;
8377 };
8378 }
8379 return _construct.apply(null, arguments);
8380 }
8381 function _defineProperties(target, props) {
8382 for(var i = 0; i < props.length; i++){
8383 var descriptor = props[i];
8384 descriptor.enumerable = descriptor.enumerable || false;
8385 descriptor.configurable = true;
8386 if ("value" in descriptor) descriptor.writable = true;
8387 Object.defineProperty(target, descriptor.key, descriptor);
8388 }
8389 }
8390 function _create_class(Constructor, protoProps, staticProps) {
8391 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
8392 return Constructor;
8393 }
8394 function _extends() {
8395 _extends = Object.assign || function(target) {
8396 for(var i = 1; i < arguments.length; i++){
8397 var source = arguments[i];
8398 for(var key in source){
8399 if (Object.prototype.hasOwnProperty.call(source, key)) {
8400 target[key] = source[key];
8401 }
8402 }
8403 }
8404 return target;
8405 };
8406 return _extends.apply(this, arguments);
8407 }
8408 function _get_prototype_of(o) {
8409 _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
8410 return o.__proto__ || Object.getPrototypeOf(o);
8411 };
8412 return _get_prototype_of(o);
8413 }
8414 function _inherits(subClass, superClass) {
8415 if (typeof superClass !== "function" && superClass !== null) {
8416 throw new TypeError("Super expression must either be null or a function");
8417 }
8418 subClass.prototype = Object.create(superClass && superClass.prototype, {
8419 constructor: {
8420 value: subClass,
8421 writable: true,
8422 configurable: true
8423 }
8424 });
8425 if (superClass) _set_prototype_of(subClass, superClass);
8426 }
8427 function _instanceof(left, right) {
8428 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
8429 return !!right[Symbol.hasInstance](left);
8430 } else {
8431 return left instanceof right;
8432 }
8433 }
8434 function _is_native_function(fn) {
8435 return Function.toString.call(fn).indexOf("[native code]") !== -1;
8436 }
8437 function _object_without_properties_loose(source, excluded) {
8438 if (source == null) return {};
8439 var target = {};
8440 var sourceKeys = Object.keys(source);
8441 var key, i;
8442 for(i = 0; i < sourceKeys.length; i++){
8443 key = sourceKeys[i];
8444 if (excluded.indexOf(key) >= 0) continue;
8445 target[key] = source[key];
8446 }
8447 return target;
8448 }
8449 function _set_prototype_of(o, p) {
8450 _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
8451 o.__proto__ = p;
8452 return o;
8453 };
8454 return _set_prototype_of(o, p);
8455 }
8456 function _type_of(obj) {
8457 "@swc/helpers - typeof";
8458 return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
8459 }
8460 function _unsupported_iterable_to_array(o, minLen) {
8461 if (!o) return;
8462 if (typeof o === "string") return _array_like_to_array(o, minLen);
8463 var n = Object.prototype.toString.call(o).slice(8, -1);
8464 if (n === "Object" && o.constructor) n = o.constructor.name;
8465 if (n === "Map" || n === "Set") return Array.from(n);
8466 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
8467 }
8468 function _wrap_native_super(Class) {
8469 var _cache = typeof Map === "function" ? new Map() : undefined;
8470 _wrap_native_super = function wrapNativeSuper(Class) {
8471 if (Class === null || !_is_native_function(Class)) return Class;
8472 if (typeof Class !== "function") {
8473 throw new TypeError("Super expression must either be null or a function");
8474 }
8475 if (typeof _cache !== "undefined") {
8476 if (_cache.has(Class)) return _cache.get(Class);
8477 _cache.set(Class, Wrapper);
8478 }
8479 function Wrapper() {
8480 return _construct(Class, arguments, _get_prototype_of(this).constructor);
8481 }
8482 Wrapper.prototype = Object.create(Class.prototype, {
8483 constructor: {
8484 value: Wrapper,
8485 enumerable: false,
8486 writable: true,
8487 configurable: true
8488 }
8489 });
8490 return _set_prototype_of(Wrapper, Class);
8491 };
8492 return _wrap_native_super(Class);
8493 }
8494 function _is_native_reflect_construct() {
8495 try {
8496 var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
8497 } catch (_) {}
8498 return (_is_native_reflect_construct = function() {
8499 return !!result;
8500 })();
8501 }
8502 function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
8503 var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
8504 if (it) return (it = it.call(o)).next.bind(it);
8505 if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike) {
8506 if (it) o = it;
8507 var i = 0;
8508 return function() {
8509 if (i >= o.length) {
8510 return {
8511 done: true
8512 };
8513 }
8514 return {
8515 done: false,
8516 value: o[i++]
8517 };
8518 };
8519 }
8520 throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8521 }
8522 function _ts_generator(thisArg, body) {
8523 var f, y, t, g, _ = {
8524 label: 0,
8525 sent: function() {
8526 if (t[0] & 1) throw t[1];
8527 return t[1];
8528 },
8529 trys: [],
8530 ops: []
8531 };
8532 return g = {
8533 next: verb(0),
8534 "throw": verb(1),
8535 "return": verb(2)
8536 }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
8537 return this;
8538 }), g;
8539 function verb(n) {
8540 return function(v) {
8541 return step([
8542 n,
8543 v
8544 ]);
8545 };
8546 }
8547 function step(op) {
8548 if (f) throw new TypeError("Generator is already executing.");
8549 while(_)try {
8550 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;
8551 if (y = 0, t) op = [
8552 op[0] & 2,
8553 t.value
8554 ];
8555 switch(op[0]){
8556 case 0:
8557 case 1:
8558 t = op;
8559 break;
8560 case 4:
8561 _.label++;
8562 return {
8563 value: op[1],
8564 done: false
8565 };
8566 case 5:
8567 _.label++;
8568 y = op[1];
8569 op = [
8570 0
8571 ];
8572 continue;
8573 case 7:
8574 op = _.ops.pop();
8575 _.trys.pop();
8576 continue;
8577 default:
8578 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
8579 _ = 0;
8580 continue;
8581 }
8582 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
8583 _.label = op[1];
8584 break;
8585 }
8586 if (op[0] === 6 && _.label < t[1]) {
8587 _.label = t[1];
8588 t = op;
8589 break;
8590 }
8591 if (t && _.label < t[2]) {
8592 _.label = t[2];
8593 _.ops.push(op);
8594 break;
8595 }
8596 if (t[2]) _.ops.pop();
8597 _.trys.pop();
8598 continue;
8599 }
8600 op = body.call(thisArg, _);
8601 } catch (e) {
8602 op = [
8603 6,
8604 e
8605 ];
8606 y = 0;
8607 } finally{
8608 f = t = 0;
8609 }
8610 if (op[0] & 5) throw op[1];
8611 return {
8612 value: op[0] ? op[1] : void 0,
8613 done: true
8614 };
8615 }
8616 }
8617 function _ts_values(o) {
8618 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
8619 if (m) return m.call(o);
8620 if (o && typeof o.length === "number") return {
8621 next: function() {
8622 if (o && i >= o.length) o = void 0;
8623 return {
8624 value: o && o[i++],
8625 done: !o
8626 };
8627 }
8628 };
8629 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
8630 }
8631 var __defProp = Object.defineProperty;
8632 var __defNormalProp = function(obj, key, value) {
8633 return key in obj ? __defProp(obj, key, {
8634 enumerable: true,
8635 configurable: true,
8636 writable: true,
8637 value: value
8638 }) : obj[key] = value;
8639 };
8640 var __publicField = function(obj, key, value) {
8641 return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
8642 };
8643 var _a;
8644 var __defProp$1 = Object.defineProperty;
8645 var __defNormalProp$1 = function(obj, key, value) {
8646 return key in obj ? __defProp$1(obj, key, {
8647 enumerable: true,
8648 configurable: true,
8649 writable: true,
8650 value: value
8651 }) : obj[key] = value;
8652 };
8653 var __publicField$1 = function(obj, key, value) {
8654 return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
8655 };
8656 var NodeType$3 = /* @__PURE__ */ function(NodeType2) {
8657 NodeType2[NodeType2["Document"] = 0] = "Document";
8658 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
8659 NodeType2[NodeType2["Element"] = 2] = "Element";
8660 NodeType2[NodeType2["Text"] = 3] = "Text";
8661 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
8662 NodeType2[NodeType2["Comment"] = 5] = "Comment";
8663 return NodeType2;
8664 }(NodeType$3 || {});
8665 var testableAccessors$1 = {
8666 Node: [
8667 "childNodes",
8668 "parentNode",
8669 "parentElement",
8670 "textContent"
8671 ],
8672 ShadowRoot: [
8673 "host",
8674 "styleSheets"
8675 ],
8676 Element: [
8677 "shadowRoot",
8678 "querySelector",
8679 "querySelectorAll"
8680 ],
8681 MutationObserver: []
8682 };
8683 var testableMethods$1 = {
8684 Node: [
8685 "contains",
8686 "getRootNode"
8687 ],
8688 ShadowRoot: [
8689 "getSelection"
8690 ],
8691 Element: [],
8692 MutationObserver: [
8693 "constructor"
8694 ]
8695 };
8696 var untaintedBasePrototype$1 = {};
8697 var isAngularZonePresent$1 = function() {
8698 return !!globalThis.Zone;
8699 };
8700 function getUntaintedPrototype$1(key) {
8701 if (untaintedBasePrototype$1[key]) return untaintedBasePrototype$1[key];
8702 var defaultObj = globalThis[key];
8703 var defaultPrototype = defaultObj.prototype;
8704 var accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
8705 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
8706 accessorNames.every(function(accessor) {
8707 var _a2, _b;
8708 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
8709 }));
8710 var methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
8711 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
8712 function(method) {
8713 var _a2;
8714 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
8715 }));
8716 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent$1()) {
8717 untaintedBasePrototype$1[key] = defaultObj.prototype;
8718 return defaultObj.prototype;
8719 }
8720 try {
8721 var iframeEl = document.createElement("iframe");
8722 document.body.appendChild(iframeEl);
8723 var win = iframeEl.contentWindow;
8724 if (!win) return defaultObj.prototype;
8725 var untaintedObject = win[key].prototype;
8726 document.body.removeChild(iframeEl);
8727 if (!untaintedObject) return defaultPrototype;
8728 return untaintedBasePrototype$1[key] = untaintedObject;
8729 } catch (e) {
8730 return defaultPrototype;
8731 }
8732 }
8733 var untaintedAccessorCache$1 = {};
8734 function getUntaintedAccessor$1(key, instance, accessor) {
8735 var _a2;
8736 var cacheKey = key + "." + String(accessor);
8737 if (untaintedAccessorCache$1[cacheKey]) return untaintedAccessorCache$1[cacheKey].call(instance);
8738 var untaintedPrototype = getUntaintedPrototype$1(key);
8739 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
8740 if (!untaintedAccessor) return instance[accessor];
8741 untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
8742 return untaintedAccessor.call(instance);
8743 }
8744 var untaintedMethodCache$1 = {};
8745 function getUntaintedMethod$1(key, instance, method) {
8746 var cacheKey = key + "." + String(method);
8747 if (untaintedMethodCache$1[cacheKey]) return untaintedMethodCache$1[cacheKey].bind(instance);
8748 var untaintedPrototype = getUntaintedPrototype$1(key);
8749 var untaintedMethod = untaintedPrototype[method];
8750 if (typeof untaintedMethod !== "function") return instance[method];
8751 untaintedMethodCache$1[cacheKey] = untaintedMethod;
8752 return untaintedMethod.bind(instance);
8753 }
8754 function childNodes$1(n2) {
8755 return getUntaintedAccessor$1("Node", n2, "childNodes");
8756 }
8757 function parentNode$1(n2) {
8758 return getUntaintedAccessor$1("Node", n2, "parentNode");
8759 }
8760 function parentElement$1(n2) {
8761 return getUntaintedAccessor$1("Node", n2, "parentElement");
8762 }
8763 function textContent$1(n2) {
8764 return getUntaintedAccessor$1("Node", n2, "textContent");
8765 }
8766 function contains$1(n2, other) {
8767 return getUntaintedMethod$1("Node", n2, "contains")(other);
8768 }
8769 function getRootNode$1(n2) {
8770 return getUntaintedMethod$1("Node", n2, "getRootNode")();
8771 }
8772 function host$1(n2) {
8773 if (!n2 || !("host" in n2)) return null;
8774 return getUntaintedAccessor$1("ShadowRoot", n2, "host");
8775 }
8776 function styleSheets$1(n2) {
8777 return n2.styleSheets;
8778 }
8779 function shadowRoot$1(n2) {
8780 if (!n2 || !("shadowRoot" in n2)) return null;
8781 return getUntaintedAccessor$1("Element", n2, "shadowRoot");
8782 }
8783 function querySelector$1(n2, selectors) {
8784 return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
8785 }
8786 function querySelectorAll$1(n2, selectors) {
8787 return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
8788 }
8789 function mutationObserverCtor$1() {
8790 return getUntaintedPrototype$1("MutationObserver").constructor;
8791 }
8792 function patch$1(source, name, replacement) {
8793 try {
8794 if (!(name in source)) {
8795 return function() {};
8796 }
8797 var original = source[name];
8798 var wrapped = replacement(original);
8799 if (typeof wrapped === "function") {
8800 wrapped.prototype = wrapped.prototype || {};
8801 Object.defineProperties(wrapped, {
8802 __rrweb_original__: {
8803 enumerable: false,
8804 value: original
8805 }
8806 });
8807 }
8808 source[name] = wrapped;
8809 return function() {
8810 source[name] = original;
8811 };
8812 } catch (e) {
8813 return function() {};
8814 }
8815 }
8816 var index$1 = {
8817 childNodes: childNodes$1,
8818 parentNode: parentNode$1,
8819 parentElement: parentElement$1,
8820 textContent: textContent$1,
8821 contains: contains$1,
8822 getRootNode: getRootNode$1,
8823 host: host$1,
8824 styleSheets: styleSheets$1,
8825 shadowRoot: shadowRoot$1,
8826 querySelector: querySelector$1,
8827 querySelectorAll: querySelectorAll$1,
8828 mutationObserver: mutationObserverCtor$1,
8829 patch: patch$1
8830 };
8831 function isElement(n2) {
8832 return n2.nodeType === n2.ELEMENT_NODE;
8833 }
8834 function isShadowRoot(n2) {
8835 var hostEl = // anchor and textarea elements also have a `host` property
8836 // but only shadow roots have a `mode` property
8837 n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null;
8838 return Boolean(hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2);
8839 }
8840 function isNativeShadowDom(shadowRoot2) {
8841 return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
8842 }
8843 function fixBrowserCompatibilityIssuesInCSS(cssText) {
8844 if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
8845 cssText = cssText.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;");
8846 }
8847 return cssText;
8848 }
8849 function escapeImportStatement(rule2) {
8850 var cssText = rule2.cssText;
8851 if (cssText.split('"').length < 3) return cssText;
8852 var statement = [
8853 "@import",
8854 "url(" + JSON.stringify(rule2.href) + ")"
8855 ];
8856 if (rule2.layerName === "") {
8857 statement.push("layer");
8858 } else if (rule2.layerName) {
8859 statement.push("layer(" + rule2.layerName + ")");
8860 }
8861 if (rule2.supportsText) {
8862 statement.push("supports(" + rule2.supportsText + ")");
8863 }
8864 if (rule2.media.length) {
8865 statement.push(rule2.media.mediaText);
8866 }
8867 return statement.join(" ") + ";";
8868 }
8869 function stringifyStylesheet(s2) {
8870 try {
8871 var rules2 = s2.rules || s2.cssRules;
8872 if (!rules2) {
8873 return null;
8874 }
8875 var sheetHref = s2.href;
8876 if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
8877 sheetHref = s2.ownerNode.ownerDocument.location.href;
8878 }
8879 var stringifiedRules = Array.from(rules2, function(rule2) {
8880 return stringifyRule(rule2, sheetHref);
8881 }).join("");
8882 return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
8883 } catch (error) {
8884 return null;
8885 }
8886 }
8887 function stringifyRule(rule2, sheetHref) {
8888 if (isCSSImportRule(rule2)) {
8889 var importStringified;
8890 try {
8891 importStringified = // we can access the imported stylesheet rules directly
8892 stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
8893 escapeImportStatement(rule2);
8894 } catch (error) {
8895 importStringified = rule2.cssText;
8896 }
8897 if (rule2.styleSheet.href) {
8898 return absolutifyURLs(importStringified, rule2.styleSheet.href);
8899 }
8900 return importStringified;
8901 } else {
8902 var ruleStringified = rule2.cssText;
8903 if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
8904 ruleStringified = fixSafariColons(ruleStringified);
8905 }
8906 if (sheetHref) {
8907 return absolutifyURLs(ruleStringified, sheetHref);
8908 }
8909 return ruleStringified;
8910 }
8911 }
8912 function fixSafariColons(cssStringified) {
8913 var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
8914 return cssStringified.replace(regex, "$1\\$2");
8915 }
8916 function isCSSImportRule(rule2) {
8917 return "styleSheet" in rule2;
8918 }
8919 function isCSSStyleRule(rule2) {
8920 return "selectorText" in rule2;
8921 }
8922 var Mirror = /*#__PURE__*/ function() {
8923 function Mirror() {
8924 __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
8925 __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
8926 }
8927 var _proto = Mirror.prototype;
8928 _proto.getId = function getId(n2) {
8929 var _a2;
8930 if (!n2) return -1;
8931 var id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id;
8932 return id != null ? id : -1;
8933 };
8934 _proto.getNode = function getNode(id) {
8935 return this.idNodeMap.get(id) || null;
8936 };
8937 _proto.getIds = function getIds() {
8938 return Array.from(this.idNodeMap.keys());
8939 };
8940 _proto.getMeta = function getMeta(n2) {
8941 return this.nodeMetaMap.get(n2) || null;
8942 };
8943 // removes the node from idNodeMap
8944 // doesn't remove the node from nodeMetaMap
8945 _proto.removeNodeFromMap = function removeNodeFromMap(n2) {
8946 var _this = this;
8947 var id = this.getId(n2);
8948 this.idNodeMap.delete(id);
8949 if (n2.childNodes) {
8950 n2.childNodes.forEach(function(childNode) {
8951 return _this.removeNodeFromMap(childNode);
8952 });
8953 }
8954 };
8955 _proto.has = function has(id) {
8956 return this.idNodeMap.has(id);
8957 };
8958 _proto.hasNode = function hasNode(node2) {
8959 return this.nodeMetaMap.has(node2);
8960 };
8961 _proto.add = function add(n2, meta) {
8962 var id = meta.id;
8963 this.idNodeMap.set(id, n2);
8964 this.nodeMetaMap.set(n2, meta);
8965 };
8966 _proto.replace = function replace(id, n2) {
8967 var oldNode = this.getNode(id);
8968 if (oldNode) {
8969 var meta = this.nodeMetaMap.get(oldNode);
8970 if (meta) this.nodeMetaMap.set(n2, meta);
8971 }
8972 this.idNodeMap.set(id, n2);
8973 };
8974 _proto.reset = function reset() {
8975 this.idNodeMap = /* @__PURE__ */ new Map();
8976 this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
8977 };
8978 return Mirror;
8979 }();
8980 function createMirror$2() {
8981 return new Mirror();
8982 }
8983 function maskInputValue(param) {
8984 var element = param.element, maskInputOptions = param.maskInputOptions, tagName = param.tagName, type = param.type, value = param.value, maskInputFn = param.maskInputFn;
8985 var text = value || "";
8986 var actualType = type && toLowerCase(type);
8987 if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
8988 if (maskInputFn) {
8989 text = maskInputFn(text, element);
8990 } else {
8991 text = "*".repeat(text.length);
8992 }
8993 }
8994 return text;
8995 }
8996 function toLowerCase(str) {
8997 return str.toLowerCase();
8998 }
8999 var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
9000 function is2DCanvasBlank(canvas) {
9001 var ctx = canvas.getContext("2d");
9002 if (!ctx) return true;
9003 var chunkSize = 50;
9004 for(var x2 = 0; x2 < canvas.width; x2 += chunkSize){
9005 for(var y = 0; y < canvas.height; y += chunkSize){
9006 var getImageData = ctx.getImageData;
9007 var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
9008 var pixelBuffer = new Uint32Array(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
9009 originalGetImageData.call(ctx, x2, y, Math.min(chunkSize, canvas.width - x2), Math.min(chunkSize, canvas.height - y)).data.buffer);
9010 if (pixelBuffer.some(function(pixel) {
9011 return pixel !== 0;
9012 })) return false;
9013 }
9014 }
9015 return true;
9016 }
9017 function getInputType(element) {
9018 var type = element.type;
9019 return element.hasAttribute("data-rr-is-password") ? "password" : type ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
9020 toLowerCase(type) : null;
9021 }
9022 function extractFileExtension(path, baseURL) {
9023 var url;
9024 try {
9025 url = new URL(path, baseURL != null ? baseURL : window.location.href);
9026 } catch (err) {
9027 return null;
9028 }
9029 var regex = /\.([0-9a-z]+)(?:$)/i;
9030 var match = url.pathname.match(regex);
9031 var _ref;
9032 return (_ref = match == null ? void 0 : match[1]) != null ? _ref : null;
9033 }
9034 function extractOrigin(url) {
9035 var origin = "";
9036 if (url.indexOf("//") > -1) {
9037 origin = url.split("/").slice(0, 3).join("/");
9038 } else {
9039 origin = url.split("/")[0];
9040 }
9041 origin = origin.split("?")[0];
9042 return origin;
9043 }
9044 var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
9045 var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
9046 var URL_WWW_MATCH = /^www\..*/i;
9047 var DATA_URI = /^(data:)([^,]*),(.*)/i;
9048 function absolutifyURLs(cssText, href) {
9049 return (cssText || "").replace(URL_IN_CSS_REF, function(origin, quote1, path1, quote2, path2, path3) {
9050 var filePath = path1 || path2 || path3;
9051 var maybeQuote = quote1 || quote2 || "";
9052 if (!filePath) {
9053 return origin;
9054 }
9055 if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
9056 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9057 }
9058 if (DATA_URI.test(filePath)) {
9059 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9060 }
9061 if (filePath[0] === "/") {
9062 return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
9063 }
9064 var stack = href.split("/");
9065 var parts = filePath.split("/");
9066 stack.pop();
9067 for(var _iterator = _create_for_of_iterator_helper_loose(parts), _step; !(_step = _iterator()).done;){
9068 var part = _step.value;
9069 if (part === ".") {
9070 continue;
9071 } else if (part === "..") {
9072 stack.pop();
9073 } else {
9074 stack.push(part);
9075 }
9076 }
9077 return "url(" + maybeQuote + stack.join("/") + maybeQuote + ")";
9078 });
9079 }
9080 function normalizeCssString(cssText, _testNoPxNorm) {
9081 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9082 if (_testNoPxNorm) {
9083 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
9084 } else {
9085 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
9086 }
9087 }
9088 function splitCssText(cssText, style, _testNoPxNorm) {
9089 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9090 var childNodes2 = Array.from(style.childNodes);
9091 var splits = [];
9092 var iterCount = 0;
9093 if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
9094 var cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
9095 var normFactor = cssTextNorm.length / cssText.length;
9096 for(var i2 = 1; i2 < childNodes2.length; i2++){
9097 if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
9098 var textContentNorm = normalizeCssString(childNodes2[i2].textContent, _testNoPxNorm);
9099 var jLimit = 100;
9100 var j = 3;
9101 for(; j < textContentNorm.length; j++){
9102 if (// keep consuming css identifiers (to get a decent chunk more quickly)
9103 textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
9104 textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1) {
9105 continue;
9106 }
9107 break;
9108 }
9109 for(; j < textContentNorm.length; j++){
9110 var startSubstring = textContentNorm.substring(0, j);
9111 var cssNormSplits = cssTextNorm.split(startSubstring);
9112 var splitNorm = -1;
9113 if (cssNormSplits.length === 2) {
9114 splitNorm = cssNormSplits[0].length;
9115 } else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
9116 splitNorm = cssTextNorm.indexOf(startSubstring, 1);
9117 } else if (cssNormSplits.length === 1) {
9118 startSubstring = startSubstring.substring(0, startSubstring.length - 1);
9119 cssNormSplits = cssTextNorm.split(startSubstring);
9120 if (cssNormSplits.length <= 1) {
9121 splits.push(cssText);
9122 return splits;
9123 }
9124 j = jLimit + 1;
9125 } else if (j === textContentNorm.length - 1) {
9126 splitNorm = cssTextNorm.indexOf(startSubstring);
9127 }
9128 if (cssNormSplits.length >= 2 && j > jLimit) {
9129 var prevTextContent = childNodes2[i2 - 1].textContent;
9130 if (prevTextContent && typeof prevTextContent === "string") {
9131 var prevMinLength = normalizeCssString(prevTextContent).length;
9132 splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
9133 }
9134 if (splitNorm === -1) {
9135 splitNorm = cssNormSplits[0].length;
9136 }
9137 }
9138 if (splitNorm !== -1) {
9139 var k = Math.floor(splitNorm / normFactor);
9140 for(; k > 0 && k < cssText.length;){
9141 iterCount += 1;
9142 if (iterCount > 50 * childNodes2.length) {
9143 splits.push(cssText);
9144 return splits;
9145 }
9146 var normPart = normalizeCssString(cssText.substring(0, k), _testNoPxNorm);
9147 if (normPart.length === splitNorm) {
9148 splits.push(cssText.substring(0, k));
9149 cssText = cssText.substring(k);
9150 cssTextNorm = cssTextNorm.substring(splitNorm);
9151 break;
9152 } else if (normPart.length < splitNorm) {
9153 k += Math.max(1, Math.floor((splitNorm - normPart.length) / normFactor));
9154 } else {
9155 k -= Math.max(1, Math.floor((normPart.length - splitNorm) * normFactor));
9156 }
9157 }
9158 break;
9159 }
9160 }
9161 }
9162 }
9163 }
9164 splits.push(cssText);
9165 return splits;
9166 }
9167 function markCssSplits(cssText, style) {
9168 return splitCssText(cssText, style).join("/* rr_split */");
9169 }
9170 var _id = 1;
9171 var tagNameRegex = new RegExp("[^a-z0-9-_:]");
9172 var IGNORED_NODE = -2;
9173 function genId() {
9174 return _id++;
9175 }
9176 function getValidTagName$1(element) {
9177 if (_instanceof(element, HTMLFormElement)) {
9178 return "form";
9179 }
9180 var processedTagName = toLowerCase(element.tagName);
9181 if (tagNameRegex.test(processedTagName)) {
9182 return "div";
9183 }
9184 return processedTagName;
9185 }
9186 var canvasService;
9187 var canvasCtx;
9188 var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
9189 var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
9190 function getAbsoluteSrcsetString(doc, attributeValue) {
9191 if (attributeValue.trim() === "") {
9192 return attributeValue;
9193 }
9194 var pos = 0;
9195 function collectCharacters(regEx) {
9196 var chars2;
9197 var match = regEx.exec(attributeValue.substring(pos));
9198 if (match) {
9199 chars2 = match[0];
9200 pos += chars2.length;
9201 return chars2;
9202 }
9203 return "";
9204 }
9205 var output = [];
9206 while(true){
9207 collectCharacters(SRCSET_COMMAS_OR_SPACES);
9208 if (pos >= attributeValue.length) {
9209 break;
9210 }
9211 var url = collectCharacters(SRCSET_NOT_SPACES);
9212 if (url.slice(-1) === ",") {
9213 url = absoluteToDoc(doc, url.substring(0, url.length - 1));
9214 output.push(url);
9215 } else {
9216 var descriptorsStr = "";
9217 url = absoluteToDoc(doc, url);
9218 var inParens = false;
9219 while(true){
9220 var c2 = attributeValue.charAt(pos);
9221 if (c2 === "") {
9222 output.push((url + descriptorsStr).trim());
9223 break;
9224 } else if (!inParens) {
9225 if (c2 === ",") {
9226 pos += 1;
9227 output.push((url + descriptorsStr).trim());
9228 break;
9229 } else if (c2 === "(") {
9230 inParens = true;
9231 }
9232 } else {
9233 if (c2 === ")") {
9234 inParens = false;
9235 }
9236 }
9237 descriptorsStr += c2;
9238 pos += 1;
9239 }
9240 }
9241 }
9242 return output.join(", ");
9243 }
9244 var cachedDocument = /* @__PURE__ */ new WeakMap();
9245 function absoluteToDoc(doc, attributeValue) {
9246 if (!attributeValue || attributeValue.trim() === "") {
9247 return attributeValue;
9248 }
9249 return getHref(doc, attributeValue);
9250 }
9251 function isSVGElement(el) {
9252 return Boolean(el.tagName === "svg" || el.ownerSVGElement);
9253 }
9254 function getHref(doc, customHref) {
9255 var a2 = cachedDocument.get(doc);
9256 if (!a2) {
9257 a2 = doc.createElement("a");
9258 cachedDocument.set(doc, a2);
9259 }
9260 if (!customHref) {
9261 customHref = "";
9262 } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
9263 return customHref;
9264 }
9265 a2.setAttribute("href", customHref);
9266 return a2.href;
9267 }
9268 function transformAttribute(doc, tagName, name, value) {
9269 if (!value) {
9270 return value;
9271 }
9272 if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
9273 return absoluteToDoc(doc, value);
9274 } else if (name === "xlink:href" && value[0] !== "#") {
9275 return absoluteToDoc(doc, value);
9276 } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
9277 return absoluteToDoc(doc, value);
9278 } else if (name === "srcset") {
9279 return getAbsoluteSrcsetString(doc, value);
9280 } else if (name === "style") {
9281 return absolutifyURLs(value, getHref(doc));
9282 } else if (tagName === "object" && name === "data") {
9283 return absoluteToDoc(doc, value);
9284 }
9285 return value;
9286 }
9287 function ignoreAttribute(tagName, name, _value) {
9288 return (tagName === "video" || tagName === "audio") && name === "autoplay";
9289 }
9290 function _isBlockedElement(element, blockClass, blockSelector) {
9291 try {
9292 if (typeof blockClass === "string") {
9293 if (element.classList.contains(blockClass)) {
9294 return true;
9295 }
9296 } else {
9297 for(var eIndex = element.classList.length; eIndex--;){
9298 var className = element.classList[eIndex];
9299 if (blockClass.test(className)) {
9300 return true;
9301 }
9302 }
9303 }
9304 if (blockSelector) {
9305 return element.matches(blockSelector);
9306 }
9307 } catch (e2) {}
9308 return false;
9309 }
9310 function classMatchesRegex(node2, regex, checkAncestors) {
9311 if (!node2) return false;
9312 if (node2.nodeType !== node2.ELEMENT_NODE) {
9313 if (!checkAncestors) return false;
9314 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9315 }
9316 for(var eIndex = node2.classList.length; eIndex--;){
9317 var className = node2.classList[eIndex];
9318 if (regex.test(className)) {
9319 return true;
9320 }
9321 }
9322 if (!checkAncestors) return false;
9323 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9324 }
9325 function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
9326 var el;
9327 if (isElement(node2)) {
9328 el = node2;
9329 if (!index$1.childNodes(el).length) {
9330 return false;
9331 }
9332 } else if (index$1.parentElement(node2) === null) {
9333 return false;
9334 } else {
9335 el = index$1.parentElement(node2);
9336 }
9337 try {
9338 if (typeof maskTextClass === "string") {
9339 if (checkAncestors) {
9340 if (el.closest("." + maskTextClass)) return true;
9341 } else {
9342 if (el.classList.contains(maskTextClass)) return true;
9343 }
9344 } else {
9345 if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
9346 }
9347 if (maskTextSelector) {
9348 if (checkAncestors) {
9349 if (el.closest(maskTextSelector)) return true;
9350 } else {
9351 if (el.matches(maskTextSelector)) return true;
9352 }
9353 }
9354 } catch (e2) {}
9355 return false;
9356 }
9357 function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
9358 var win = iframeEl.contentWindow;
9359 if (!win) {
9360 return;
9361 }
9362 var fired = false;
9363 var readyState;
9364 try {
9365 readyState = win.document.readyState;
9366 } catch (error) {
9367 return;
9368 }
9369 if (readyState !== "complete") {
9370 var timer = setTimeout(function() {
9371 if (!fired) {
9372 listener();
9373 fired = true;
9374 }
9375 }, iframeLoadTimeout);
9376 iframeEl.addEventListener("load", function() {
9377 clearTimeout(timer);
9378 fired = true;
9379 listener();
9380 });
9381 return;
9382 }
9383 var blankUrl = "about:blank";
9384 if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
9385 setTimeout(listener, 0);
9386 return iframeEl.addEventListener("load", listener);
9387 }
9388 iframeEl.addEventListener("load", listener);
9389 }
9390 function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
9391 var fired = false;
9392 var styleSheetLoaded;
9393 try {
9394 styleSheetLoaded = link.sheet;
9395 } catch (error) {
9396 return;
9397 }
9398 if (styleSheetLoaded) return;
9399 var timer = setTimeout(function() {
9400 if (!fired) {
9401 listener();
9402 fired = true;
9403 }
9404 }, styleSheetLoadTimeout);
9405 link.addEventListener("load", function() {
9406 clearTimeout(timer);
9407 fired = true;
9408 listener();
9409 });
9410 }
9411 function serializeNode(n2, options) {
9412 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;
9413 var rootId = getRootId(doc, mirror2);
9414 switch(n2.nodeType){
9415 case n2.DOCUMENT_NODE:
9416 if (n2.compatMode !== "CSS1Compat") {
9417 return {
9418 type: NodeType$3.Document,
9419 childNodes: [],
9420 compatMode: n2.compatMode
9421 };
9422 } else {
9423 return {
9424 type: NodeType$3.Document,
9425 childNodes: []
9426 };
9427 }
9428 case n2.DOCUMENT_TYPE_NODE:
9429 return {
9430 type: NodeType$3.DocumentType,
9431 name: n2.name,
9432 publicId: n2.publicId,
9433 systemId: n2.systemId,
9434 rootId: rootId
9435 };
9436 case n2.ELEMENT_NODE:
9437 return serializeElementNode(n2, {
9438 doc: doc,
9439 blockClass: blockClass,
9440 blockSelector: blockSelector,
9441 inlineStylesheet: inlineStylesheet,
9442 maskInputOptions: maskInputOptions,
9443 maskInputFn: maskInputFn,
9444 dataURLOptions: dataURLOptions,
9445 inlineImages: inlineImages,
9446 recordCanvas: recordCanvas,
9447 keepIframeSrcFn: keepIframeSrcFn,
9448 newlyAddedElement: newlyAddedElement,
9449 rootId: rootId
9450 });
9451 case n2.TEXT_NODE:
9452 return serializeTextNode(n2, {
9453 doc: doc,
9454 needsMask: needsMask,
9455 maskTextFn: maskTextFn,
9456 rootId: rootId,
9457 cssCaptured: cssCaptured
9458 });
9459 case n2.CDATA_SECTION_NODE:
9460 return {
9461 type: NodeType$3.CDATA,
9462 textContent: "",
9463 rootId: rootId
9464 };
9465 case n2.COMMENT_NODE:
9466 return {
9467 type: NodeType$3.Comment,
9468 textContent: index$1.textContent(n2) || "",
9469 rootId: rootId
9470 };
9471 default:
9472 return false;
9473 }
9474 }
9475 function getRootId(doc, mirror2) {
9476 if (!mirror2.hasNode(doc)) return void 0;
9477 var docId = mirror2.getId(doc);
9478 return docId === 1 ? void 0 : docId;
9479 }
9480 function serializeTextNode(n2, options) {
9481 var needsMask = options.needsMask, maskTextFn = options.maskTextFn, rootId = options.rootId, cssCaptured = options.cssCaptured;
9482 var parent = index$1.parentNode(n2);
9483 var parentTagName = parent && parent.tagName;
9484 var textContent2 = "";
9485 var isStyle = parentTagName === "STYLE" ? true : void 0;
9486 var isScript = parentTagName === "SCRIPT" ? true : void 0;
9487 if (isScript) {
9488 textContent2 = "SCRIPT_PLACEHOLDER";
9489 } else if (!cssCaptured) {
9490 textContent2 = index$1.textContent(n2);
9491 if (isStyle && textContent2) {
9492 textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
9493 }
9494 }
9495 if (!isStyle && !isScript && textContent2 && needsMask) {
9496 textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
9497 }
9498 return {
9499 type: NodeType$3.Text,
9500 textContent: textContent2 || "",
9501 rootId: rootId
9502 };
9503 }
9504 function serializeElementNode(n2, options) {
9505 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;
9506 var needBlock = _isBlockedElement(n2, blockClass, blockSelector);
9507 var tagName = getValidTagName$1(n2);
9508 var attributes = {};
9509 var len = n2.attributes.length;
9510 for(var i2 = 0; i2 < len; i2++){
9511 var attr = n2.attributes[i2];
9512 if (!ignoreAttribute(tagName, attr.name, attr.value)) {
9513 attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
9514 }
9515 }
9516 if (tagName === "link" && inlineStylesheet) {
9517 var stylesheet = Array.from(doc.styleSheets).find(function(s2) {
9518 return s2.href === n2.href;
9519 });
9520 var cssText = null;
9521 if (stylesheet) {
9522 cssText = stringifyStylesheet(stylesheet);
9523 }
9524 if (cssText) {
9525 delete attributes.rel;
9526 delete attributes.href;
9527 attributes._cssText = cssText;
9528 }
9529 }
9530 if (tagName === "style" && n2.sheet) {
9531 var cssText1 = stringifyStylesheet(n2.sheet);
9532 if (cssText1) {
9533 if (n2.childNodes.length > 1) {
9534 cssText1 = markCssSplits(cssText1, n2);
9535 }
9536 attributes._cssText = cssText1;
9537 }
9538 }
9539 if (tagName === "input" || tagName === "textarea" || tagName === "select") {
9540 var value = n2.value;
9541 var checked = n2.checked;
9542 if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
9543 attributes.value = maskInputValue({
9544 element: n2,
9545 type: getInputType(n2),
9546 tagName: tagName,
9547 value: value,
9548 maskInputOptions: maskInputOptions,
9549 maskInputFn: maskInputFn
9550 });
9551 } else if (checked) {
9552 attributes.checked = checked;
9553 }
9554 }
9555 if (tagName === "option") {
9556 if (n2.selected && !maskInputOptions["select"]) {
9557 attributes.selected = true;
9558 } else {
9559 delete attributes.selected;
9560 }
9561 }
9562 if (tagName === "dialog" && n2.open) {
9563 attributes.rr_open_mode = n2.matches("dialog:modal") ? "modal" : "non-modal";
9564 }
9565 if (tagName === "canvas" && recordCanvas) {
9566 if (n2.__context === "2d") {
9567 if (!is2DCanvasBlank(n2)) {
9568 attributes.rr_dataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9569 }
9570 } else if (!("__context" in n2)) {
9571 var canvasDataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9572 var blankCanvas = doc.createElement("canvas");
9573 blankCanvas.width = n2.width;
9574 blankCanvas.height = n2.height;
9575 var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9576 if (canvasDataURL !== blankCanvasDataURL) {
9577 attributes.rr_dataURL = canvasDataURL;
9578 }
9579 }
9580 }
9581 if (tagName === "img" && inlineImages) {
9582 if (!canvasService) {
9583 canvasService = doc.createElement("canvas");
9584 canvasCtx = canvasService.getContext("2d");
9585 }
9586 var image = n2;
9587 var imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
9588 var priorCrossOrigin = image.crossOrigin;
9589 var recordInlineImage = function() {
9590 image.removeEventListener("load", recordInlineImage);
9591 try {
9592 canvasService.width = image.naturalWidth;
9593 canvasService.height = image.naturalHeight;
9594 canvasCtx.drawImage(image, 0, 0);
9595 attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9596 } catch (err) {
9597 if (image.crossOrigin !== "anonymous") {
9598 image.crossOrigin = "anonymous";
9599 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
9600 else image.addEventListener("load", recordInlineImage);
9601 return;
9602 } else {
9603 console.warn("Cannot inline img src=" + imageSrc + "! Error: " + err);
9604 }
9605 }
9606 if (image.crossOrigin === "anonymous") {
9607 priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
9608 }
9609 };
9610 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
9611 else image.addEventListener("load", recordInlineImage);
9612 }
9613 if (tagName === "audio" || tagName === "video") {
9614 var mediaAttributes = attributes;
9615 mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
9616 mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
9617 mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
9618 mediaAttributes.rr_mediaMuted = n2.muted;
9619 mediaAttributes.rr_mediaLoop = n2.loop;
9620 mediaAttributes.rr_mediaVolume = n2.volume;
9621 }
9622 if (!newlyAddedElement) {
9623 if (n2.scrollLeft) {
9624 attributes.rr_scrollLeft = n2.scrollLeft;
9625 }
9626 if (n2.scrollTop) {
9627 attributes.rr_scrollTop = n2.scrollTop;
9628 }
9629 }
9630 if (needBlock) {
9631 var _n2_getBoundingClientRect = n2.getBoundingClientRect(), width = _n2_getBoundingClientRect.width, height = _n2_getBoundingClientRect.height;
9632 attributes = {
9633 class: attributes.class,
9634 rr_width: "" + width + "px",
9635 rr_height: "" + height + "px"
9636 };
9637 }
9638 if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
9639 if (!n2.contentDocument) {
9640 attributes.rr_src = attributes.src;
9641 }
9642 delete attributes.src;
9643 }
9644 var isCustomElement;
9645 try {
9646 if (customElements.get(tagName)) isCustomElement = true;
9647 } catch (e2) {}
9648 return {
9649 type: NodeType$3.Element,
9650 tagName: tagName,
9651 attributes: attributes,
9652 childNodes: [],
9653 isSVG: isSVGElement(n2) || void 0,
9654 needBlock: needBlock,
9655 rootId: rootId,
9656 isCustom: isCustomElement
9657 };
9658 }
9659 function lowerIfExists(maybeAttr) {
9660 if (maybeAttr === void 0 || maybeAttr === null) {
9661 return "";
9662 } else {
9663 return maybeAttr.toLowerCase();
9664 }
9665 }
9666 function slimDOMExcluded(sn, slimDOMOptions) {
9667 if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
9668 return true;
9669 } else if (sn.type === NodeType$3.Element) {
9670 if (slimDOMOptions.script && // script tag
9671 (sn.tagName === "script" || // (module)preload link
9672 sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
9673 sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
9674 return true;
9675 } 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"))) {
9676 return true;
9677 } else if (sn.tagName === "meta") {
9678 if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
9679 return true;
9680 } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
9681 lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
9682 return true;
9683 } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
9684 return true;
9685 } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
9686 return true;
9687 } 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:/))) {
9688 return true;
9689 } 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")) {
9690 return true;
9691 }
9692 }
9693 }
9694 return false;
9695 }
9696 function serializeNodeWithId(n2, options) {
9697 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() {
9698 return false;
9699 } : _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;
9700 var needsMask = options.needsMask;
9701 var _options_preserveWhiteSpace = options.preserveWhiteSpace, preserveWhiteSpace = _options_preserveWhiteSpace === void 0 ? true : _options_preserveWhiteSpace;
9702 if (!needsMask) {
9703 var checkAncestors = needsMask === void 0;
9704 needsMask = needMaskingText(n2, maskTextClass, maskTextSelector, checkAncestors);
9705 }
9706 var _serializedNode = serializeNode(n2, {
9707 doc: doc,
9708 mirror: mirror2,
9709 blockClass: blockClass,
9710 blockSelector: blockSelector,
9711 needsMask: needsMask,
9712 inlineStylesheet: inlineStylesheet,
9713 maskInputOptions: maskInputOptions,
9714 maskTextFn: maskTextFn,
9715 maskInputFn: maskInputFn,
9716 dataURLOptions: dataURLOptions,
9717 inlineImages: inlineImages,
9718 recordCanvas: recordCanvas,
9719 keepIframeSrcFn: keepIframeSrcFn,
9720 newlyAddedElement: newlyAddedElement,
9721 cssCaptured: cssCaptured
9722 });
9723 if (!_serializedNode) {
9724 console.warn(n2, "not serialized");
9725 return null;
9726 }
9727 var id;
9728 if (mirror2.hasNode(n2)) {
9729 id = mirror2.getId(n2);
9730 } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
9731 id = IGNORED_NODE;
9732 } else {
9733 id = genId();
9734 }
9735 var serializedNode = Object.assign(_serializedNode, {
9736 id: id
9737 });
9738 mirror2.add(n2, serializedNode);
9739 if (id === IGNORED_NODE) {
9740 return null;
9741 }
9742 if (onSerialize) {
9743 onSerialize(n2);
9744 }
9745 var recordChild = !skipChild;
9746 if (serializedNode.type === NodeType$3.Element) {
9747 recordChild = recordChild && !serializedNode.needBlock;
9748 delete serializedNode.needBlock;
9749 var shadowRootEl = index$1.shadowRoot(n2);
9750 if (shadowRootEl && isNativeShadowDom(shadowRootEl)) serializedNode.isShadowHost = true;
9751 }
9752 if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
9753 if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
9754 preserveWhiteSpace = false;
9755 }
9756 var bypassOptions = {
9757 doc: doc,
9758 mirror: mirror2,
9759 blockClass: blockClass,
9760 blockSelector: blockSelector,
9761 needsMask: needsMask,
9762 maskTextClass: maskTextClass,
9763 maskTextSelector: maskTextSelector,
9764 skipChild: skipChild,
9765 inlineStylesheet: inlineStylesheet,
9766 maskInputOptions: maskInputOptions,
9767 maskTextFn: maskTextFn,
9768 maskInputFn: maskInputFn,
9769 slimDOMOptions: slimDOMOptions,
9770 dataURLOptions: dataURLOptions,
9771 inlineImages: inlineImages,
9772 recordCanvas: recordCanvas,
9773 preserveWhiteSpace: preserveWhiteSpace,
9774 onSerialize: onSerialize,
9775 onIframeLoad: onIframeLoad,
9776 iframeLoadTimeout: iframeLoadTimeout,
9777 onStylesheetLoad: onStylesheetLoad,
9778 stylesheetLoadTimeout: stylesheetLoadTimeout,
9779 keepIframeSrcFn: keepIframeSrcFn,
9780 cssCaptured: false
9781 };
9782 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
9783 else {
9784 if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
9785 bypassOptions.cssCaptured = true;
9786 }
9787 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(n2))), _step; !(_step = _iterator()).done;){
9788 var childN = _step.value;
9789 var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
9790 if (serializedChildNode) {
9791 serializedNode.childNodes.push(serializedChildNode);
9792 }
9793 }
9794 }
9795 var shadowRootEl1 = null;
9796 if (isElement(n2) && (shadowRootEl1 = index$1.shadowRoot(n2))) {
9797 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(shadowRootEl1))), _step1; !(_step1 = _iterator1()).done;){
9798 var childN1 = _step1.value;
9799 var serializedChildNode1 = serializeNodeWithId(childN1, bypassOptions);
9800 if (serializedChildNode1) {
9801 isNativeShadowDom(shadowRootEl1) && (serializedChildNode1.isShadow = true);
9802 serializedNode.childNodes.push(serializedChildNode1);
9803 }
9804 }
9805 }
9806 }
9807 var parent = index$1.parentNode(n2);
9808 if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
9809 serializedNode.isShadow = true;
9810 }
9811 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
9812 onceIframeLoaded(n2, function() {
9813 var iframeDoc = n2.contentDocument;
9814 if (iframeDoc && onIframeLoad) {
9815 var serializedIframeNode = serializeNodeWithId(iframeDoc, {
9816 doc: iframeDoc,
9817 mirror: mirror2,
9818 blockClass: blockClass,
9819 blockSelector: blockSelector,
9820 needsMask: needsMask,
9821 maskTextClass: maskTextClass,
9822 maskTextSelector: maskTextSelector,
9823 skipChild: false,
9824 inlineStylesheet: inlineStylesheet,
9825 maskInputOptions: maskInputOptions,
9826 maskTextFn: maskTextFn,
9827 maskInputFn: maskInputFn,
9828 slimDOMOptions: slimDOMOptions,
9829 dataURLOptions: dataURLOptions,
9830 inlineImages: inlineImages,
9831 recordCanvas: recordCanvas,
9832 preserveWhiteSpace: preserveWhiteSpace,
9833 onSerialize: onSerialize,
9834 onIframeLoad: onIframeLoad,
9835 iframeLoadTimeout: iframeLoadTimeout,
9836 onStylesheetLoad: onStylesheetLoad,
9837 stylesheetLoadTimeout: stylesheetLoadTimeout,
9838 keepIframeSrcFn: keepIframeSrcFn
9839 });
9840 if (serializedIframeNode) {
9841 onIframeLoad(n2, serializedIframeNode);
9842 }
9843 }
9844 }, iframeLoadTimeout);
9845 }
9846 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")) {
9847 onceStylesheetLoaded(n2, function() {
9848 if (onStylesheetLoad) {
9849 var serializedLinkNode = serializeNodeWithId(n2, {
9850 doc: doc,
9851 mirror: mirror2,
9852 blockClass: blockClass,
9853 blockSelector: blockSelector,
9854 needsMask: needsMask,
9855 maskTextClass: maskTextClass,
9856 maskTextSelector: maskTextSelector,
9857 skipChild: false,
9858 inlineStylesheet: inlineStylesheet,
9859 maskInputOptions: maskInputOptions,
9860 maskTextFn: maskTextFn,
9861 maskInputFn: maskInputFn,
9862 slimDOMOptions: slimDOMOptions,
9863 dataURLOptions: dataURLOptions,
9864 inlineImages: inlineImages,
9865 recordCanvas: recordCanvas,
9866 preserveWhiteSpace: preserveWhiteSpace,
9867 onSerialize: onSerialize,
9868 onIframeLoad: onIframeLoad,
9869 iframeLoadTimeout: iframeLoadTimeout,
9870 onStylesheetLoad: onStylesheetLoad,
9871 stylesheetLoadTimeout: stylesheetLoadTimeout,
9872 keepIframeSrcFn: keepIframeSrcFn
9873 });
9874 if (serializedLinkNode) {
9875 onStylesheetLoad(n2, serializedLinkNode);
9876 }
9877 }
9878 }, stylesheetLoadTimeout);
9879 }
9880 return serializedNode;
9881 }
9882 function snapshot(n2, options) {
9883 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() {
9884 return false;
9885 } : _ref_keepIframeSrcFn;
9886 var maskInputOptions = maskAllInputs === true ? {
9887 color: true,
9888 date: true,
9889 "datetime-local": true,
9890 email: true,
9891 month: true,
9892 number: true,
9893 range: true,
9894 search: true,
9895 tel: true,
9896 text: true,
9897 time: true,
9898 url: true,
9899 week: true,
9900 textarea: true,
9901 select: true,
9902 password: true,
9903 hidden: true
9904 } : maskAllInputs === false ? {
9905 password: true
9906 } : maskAllInputs;
9907 var slimDOMOptions = slimDOM === true || slimDOM === "all" ? // if true: set of sensible options that should not throw away any information
9908 {
9909 script: true,
9910 comment: true,
9911 headFavicon: true,
9912 headWhitespace: true,
9913 headMetaDescKeywords: slimDOM === "all",
9914 // destructive
9915 headMetaSocial: true,
9916 headMetaRobots: true,
9917 headMetaHttpEquiv: true,
9918 headMetaAuthorship: true,
9919 headMetaVerification: true
9920 } : slimDOM === false ? {} : slimDOM;
9921 return serializeNodeWithId(n2, {
9922 doc: n2,
9923 mirror: mirror2,
9924 blockClass: blockClass,
9925 blockSelector: blockSelector,
9926 maskTextClass: maskTextClass,
9927 maskTextSelector: maskTextSelector,
9928 skipChild: false,
9929 inlineStylesheet: inlineStylesheet,
9930 maskInputOptions: maskInputOptions,
9931 maskTextFn: maskTextFn,
9932 maskInputFn: maskInputFn,
9933 slimDOMOptions: slimDOMOptions,
9934 dataURLOptions: dataURLOptions,
9935 inlineImages: inlineImages,
9936 recordCanvas: recordCanvas,
9937 preserveWhiteSpace: preserveWhiteSpace,
9938 onSerialize: onSerialize,
9939 onIframeLoad: onIframeLoad,
9940 iframeLoadTimeout: iframeLoadTimeout,
9941 onStylesheetLoad: onStylesheetLoad,
9942 stylesheetLoadTimeout: stylesheetLoadTimeout,
9943 keepIframeSrcFn: keepIframeSrcFn,
9944 newlyAddedElement: false
9945 });
9946 }
9947 function getDefaultExportFromCjs$1(x2) {
9948 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
9949 }
9950 function getAugmentedNamespace$1(n2) {
9951 if (n2.__esModule) return n2;
9952 var f2 = n2.default;
9953 if (typeof f2 == "function") {
9954 var a2 = function a22() {
9955 if (_instanceof(this, a22)) {
9956 return Reflect.construct(f2, arguments, this.constructor);
9957 }
9958 return f2.apply(this, arguments);
9959 };
9960 a2.prototype = f2.prototype;
9961 } else a2 = {};
9962 Object.defineProperty(a2, "__esModule", {
9963 value: true
9964 });
9965 Object.keys(n2).forEach(function(k) {
9966 var d = Object.getOwnPropertyDescriptor(n2, k);
9967 Object.defineProperty(a2, k, d.get ? d : {
9968 enumerable: true,
9969 get: function get() {
9970 return n2[k];
9971 }
9972 });
9973 });
9974 return a2;
9975 }
9976 var picocolors_browser$1 = {
9977 exports: {}
9978 };
9979 var x$1 = String;
9980 var create$1 = function create$1() {
9981 return {
9982 isColorSupported: false,
9983 reset: x$1,
9984 bold: x$1,
9985 dim: x$1,
9986 italic: x$1,
9987 underline: x$1,
9988 inverse: x$1,
9989 hidden: x$1,
9990 strikethrough: x$1,
9991 black: x$1,
9992 red: x$1,
9993 green: x$1,
9994 yellow: x$1,
9995 blue: x$1,
9996 magenta: x$1,
9997 cyan: x$1,
9998 white: x$1,
9999 gray: x$1,
10000 bgBlack: x$1,
10001 bgRed: x$1,
10002 bgGreen: x$1,
10003 bgYellow: x$1,
10004 bgBlue: x$1,
10005 bgMagenta: x$1,
10006 bgCyan: x$1,
10007 bgWhite: x$1
10008 };
10009 };
10010 picocolors_browser$1.exports = create$1();
10011 picocolors_browser$1.exports.createColors = create$1;
10012 var picocolors_browserExports$1 = picocolors_browser$1.exports;
10013 var __viteBrowserExternal$2 = {};
10014 var __viteBrowserExternal$1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10015 __proto__: null,
10016 default: __viteBrowserExternal$2
10017 }, Symbol.toStringTag, {
10018 value: "Module"
10019 }));
10020 var require$$2$1 = /* @__PURE__ */ getAugmentedNamespace$1(__viteBrowserExternal$1$1);
10021 var pico$1 = picocolors_browserExports$1;
10022 var terminalHighlight$1$1 = require$$2$1;
10023 var CssSyntaxError$3$1 = /*#__PURE__*/ function(Error1) {
10024 _inherits(CssSyntaxError, Error1);
10025 function CssSyntaxError(message, line, column, source, file, plugin22) {
10026 var _this;
10027 _this = Error1.call(this, message) || this;
10028 _this.name = "CssSyntaxError";
10029 _this.reason = message;
10030 if (file) {
10031 _this.file = file;
10032 }
10033 if (source) {
10034 _this.source = source;
10035 }
10036 if (plugin22) {
10037 _this.plugin = plugin22;
10038 }
10039 if (typeof line !== "undefined" && typeof column !== "undefined") {
10040 if (typeof line === "number") {
10041 _this.line = line;
10042 _this.column = column;
10043 } else {
10044 _this.line = line.line;
10045 _this.column = line.column;
10046 _this.endLine = column.line;
10047 _this.endColumn = column.column;
10048 }
10049 }
10050 _this.setMessage();
10051 if (Error.captureStackTrace) {
10052 Error.captureStackTrace(_this, CssSyntaxError);
10053 }
10054 return _this;
10055 }
10056 var _proto = CssSyntaxError.prototype;
10057 _proto.setMessage = function setMessage() {
10058 this.message = this.plugin ? this.plugin + ": " : "";
10059 this.message += this.file ? this.file : "<css input>";
10060 if (typeof this.line !== "undefined") {
10061 this.message += ":" + this.line + ":" + this.column;
10062 }
10063 this.message += ": " + this.reason;
10064 };
10065 _proto.showSourceCode = function showSourceCode(color) {
10066 var _this = this;
10067 if (!this.source) return "";
10068 var css = this.source;
10069 if (color == null) color = pico$1.isColorSupported;
10070 if (terminalHighlight$1$1) {
10071 if (color) css = terminalHighlight$1$1(css);
10072 }
10073 var lines = css.split(/\r?\n/);
10074 var start = Math.max(this.line - 3, 0);
10075 var end = Math.min(this.line + 2, lines.length);
10076 var maxWidth = String(end).length;
10077 var mark, aside;
10078 if (color) {
10079 var _pico$1_createColors = pico$1.createColors(true), bold = _pico$1_createColors.bold, gray = _pico$1_createColors.gray, red = _pico$1_createColors.red;
10080 mark = function(text) {
10081 return bold(red(text));
10082 };
10083 aside = function(text) {
10084 return gray(text);
10085 };
10086 } else {
10087 mark = aside = function(str) {
10088 return str;
10089 };
10090 }
10091 return lines.slice(start, end).map(function(line, index2) {
10092 var number = start + 1 + index2;
10093 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
10094 if (number === _this.line) {
10095 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
10096 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
10097 }
10098 return " " + aside(gutter) + line;
10099 }).join("\n");
10100 };
10101 _proto.toString = function toString() {
10102 var code = this.showSourceCode();
10103 if (code) {
10104 code = "\n\n" + code + "\n";
10105 }
10106 return this.name + ": " + this.message + code;
10107 };
10108 return CssSyntaxError;
10109 }(_wrap_native_super(Error));
10110 var cssSyntaxError$1 = CssSyntaxError$3$1;
10111 CssSyntaxError$3$1.default = CssSyntaxError$3$1;
10112 var symbols$1 = {};
10113 symbols$1.isClean = Symbol("isClean");
10114 symbols$1.my = Symbol("my");
10115 var DEFAULT_RAW$1 = {
10116 after: "\n",
10117 beforeClose: "\n",
10118 beforeComment: "\n",
10119 beforeDecl: "\n",
10120 beforeOpen: " ",
10121 beforeRule: "\n",
10122 colon: ": ",
10123 commentLeft: " ",
10124 commentRight: " ",
10125 emptyBody: "",
10126 indent: " ",
10127 semicolon: false
10128 };
10129 function capitalize$1(str) {
10130 return str[0].toUpperCase() + str.slice(1);
10131 }
10132 var Stringifier$2$1 = /*#__PURE__*/ function() {
10133 function Stringifier(builder) {
10134 this.builder = builder;
10135 }
10136 var _proto = Stringifier.prototype;
10137 _proto.atrule = function atrule(node2, semicolon) {
10138 var name = "@" + node2.name;
10139 var params = node2.params ? this.rawValue(node2, "params") : "";
10140 if (typeof node2.raws.afterName !== "undefined") {
10141 name += node2.raws.afterName;
10142 } else if (params) {
10143 name += " ";
10144 }
10145 if (node2.nodes) {
10146 this.block(node2, name + params);
10147 } else {
10148 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
10149 this.builder(name + params + end, node2);
10150 }
10151 };
10152 _proto.beforeAfter = function beforeAfter(node2, detect) {
10153 var value;
10154 if (node2.type === "decl") {
10155 value = this.raw(node2, null, "beforeDecl");
10156 } else if (node2.type === "comment") {
10157 value = this.raw(node2, null, "beforeComment");
10158 } else if (detect === "before") {
10159 value = this.raw(node2, null, "beforeRule");
10160 } else {
10161 value = this.raw(node2, null, "beforeClose");
10162 }
10163 var buf = node2.parent;
10164 var depth = 0;
10165 while(buf && buf.type !== "root"){
10166 depth += 1;
10167 buf = buf.parent;
10168 }
10169 if (value.includes("\n")) {
10170 var indent = this.raw(node2, null, "indent");
10171 if (indent.length) {
10172 for(var step = 0; step < depth; step++)value += indent;
10173 }
10174 }
10175 return value;
10176 };
10177 _proto.block = function block(node2, start) {
10178 var between = this.raw(node2, "between", "beforeOpen");
10179 this.builder(start + between + "{", node2, "start");
10180 var after;
10181 if (node2.nodes && node2.nodes.length) {
10182 this.body(node2);
10183 after = this.raw(node2, "after");
10184 } else {
10185 after = this.raw(node2, "after", "emptyBody");
10186 }
10187 if (after) this.builder(after);
10188 this.builder("}", node2, "end");
10189 };
10190 _proto.body = function body(node2) {
10191 var last = node2.nodes.length - 1;
10192 while(last > 0){
10193 if (node2.nodes[last].type !== "comment") break;
10194 last -= 1;
10195 }
10196 var semicolon = this.raw(node2, "semicolon");
10197 for(var i2 = 0; i2 < node2.nodes.length; i2++){
10198 var child = node2.nodes[i2];
10199 var before = this.raw(child, "before");
10200 if (before) this.builder(before);
10201 this.stringify(child, last !== i2 || semicolon);
10202 }
10203 };
10204 _proto.comment = function comment(node2) {
10205 var left = this.raw(node2, "left", "commentLeft");
10206 var right = this.raw(node2, "right", "commentRight");
10207 this.builder("/*" + left + node2.text + right + "*/", node2);
10208 };
10209 _proto.decl = function decl(node2, semicolon) {
10210 var between = this.raw(node2, "between", "colon");
10211 var string = node2.prop + between + this.rawValue(node2, "value");
10212 if (node2.important) {
10213 string += node2.raws.important || " !important";
10214 }
10215 if (semicolon) string += ";";
10216 this.builder(string, node2);
10217 };
10218 _proto.document = function document1(node2) {
10219 this.body(node2);
10220 };
10221 _proto.raw = function raw(node2, own, detect) {
10222 var value;
10223 if (!detect) detect = own;
10224 if (own) {
10225 value = node2.raws[own];
10226 if (typeof value !== "undefined") return value;
10227 }
10228 var parent = node2.parent;
10229 if (detect === "before") {
10230 if (!parent || parent.type === "root" && parent.first === node2) {
10231 return "";
10232 }
10233 if (parent && parent.type === "document") {
10234 return "";
10235 }
10236 }
10237 if (!parent) return DEFAULT_RAW$1[detect];
10238 var root2 = node2.root();
10239 if (!root2.rawCache) root2.rawCache = {};
10240 if (typeof root2.rawCache[detect] !== "undefined") {
10241 return root2.rawCache[detect];
10242 }
10243 if (detect === "before" || detect === "after") {
10244 return this.beforeAfter(node2, detect);
10245 } else {
10246 var method = "raw" + capitalize$1(detect);
10247 if (this[method]) {
10248 value = this[method](root2, node2);
10249 } else {
10250 root2.walk(function(i2) {
10251 value = i2.raws[own];
10252 if (typeof value !== "undefined") return false;
10253 });
10254 }
10255 }
10256 if (typeof value === "undefined") value = DEFAULT_RAW$1[detect];
10257 root2.rawCache[detect] = value;
10258 return value;
10259 };
10260 _proto.rawBeforeClose = function rawBeforeClose(root2) {
10261 var value;
10262 root2.walk(function(i2) {
10263 if (i2.nodes && i2.nodes.length > 0) {
10264 if (typeof i2.raws.after !== "undefined") {
10265 value = i2.raws.after;
10266 if (value.includes("\n")) {
10267 value = value.replace(/[^\n]+$/, "");
10268 }
10269 return false;
10270 }
10271 }
10272 });
10273 if (value) value = value.replace(/\S/g, "");
10274 return value;
10275 };
10276 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
10277 var value;
10278 root2.walkComments(function(i2) {
10279 if (typeof i2.raws.before !== "undefined") {
10280 value = i2.raws.before;
10281 if (value.includes("\n")) {
10282 value = value.replace(/[^\n]+$/, "");
10283 }
10284 return false;
10285 }
10286 });
10287 if (typeof value === "undefined") {
10288 value = this.raw(node2, null, "beforeDecl");
10289 } else if (value) {
10290 value = value.replace(/\S/g, "");
10291 }
10292 return value;
10293 };
10294 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
10295 var value;
10296 root2.walkDecls(function(i2) {
10297 if (typeof i2.raws.before !== "undefined") {
10298 value = i2.raws.before;
10299 if (value.includes("\n")) {
10300 value = value.replace(/[^\n]+$/, "");
10301 }
10302 return false;
10303 }
10304 });
10305 if (typeof value === "undefined") {
10306 value = this.raw(node2, null, "beforeRule");
10307 } else if (value) {
10308 value = value.replace(/\S/g, "");
10309 }
10310 return value;
10311 };
10312 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
10313 var value;
10314 root2.walk(function(i2) {
10315 if (i2.type !== "decl") {
10316 value = i2.raws.between;
10317 if (typeof value !== "undefined") return false;
10318 }
10319 });
10320 return value;
10321 };
10322 _proto.rawBeforeRule = function rawBeforeRule(root2) {
10323 var value;
10324 root2.walk(function(i2) {
10325 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
10326 if (typeof i2.raws.before !== "undefined") {
10327 value = i2.raws.before;
10328 if (value.includes("\n")) {
10329 value = value.replace(/[^\n]+$/, "");
10330 }
10331 return false;
10332 }
10333 }
10334 });
10335 if (value) value = value.replace(/\S/g, "");
10336 return value;
10337 };
10338 _proto.rawColon = function rawColon(root2) {
10339 var value;
10340 root2.walkDecls(function(i2) {
10341 if (typeof i2.raws.between !== "undefined") {
10342 value = i2.raws.between.replace(/[^\s:]/g, "");
10343 return false;
10344 }
10345 });
10346 return value;
10347 };
10348 _proto.rawEmptyBody = function rawEmptyBody(root2) {
10349 var value;
10350 root2.walk(function(i2) {
10351 if (i2.nodes && i2.nodes.length === 0) {
10352 value = i2.raws.after;
10353 if (typeof value !== "undefined") return false;
10354 }
10355 });
10356 return value;
10357 };
10358 _proto.rawIndent = function rawIndent(root2) {
10359 if (root2.raws.indent) return root2.raws.indent;
10360 var value;
10361 root2.walk(function(i2) {
10362 var p = i2.parent;
10363 if (p && p !== root2 && p.parent && p.parent === root2) {
10364 if (typeof i2.raws.before !== "undefined") {
10365 var parts = i2.raws.before.split("\n");
10366 value = parts[parts.length - 1];
10367 value = value.replace(/\S/g, "");
10368 return false;
10369 }
10370 }
10371 });
10372 return value;
10373 };
10374 _proto.rawSemicolon = function rawSemicolon(root2) {
10375 var value;
10376 root2.walk(function(i2) {
10377 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
10378 value = i2.raws.semicolon;
10379 if (typeof value !== "undefined") return false;
10380 }
10381 });
10382 return value;
10383 };
10384 _proto.rawValue = function rawValue(node2, prop) {
10385 var value = node2[prop];
10386 var raw = node2.raws[prop];
10387 if (raw && raw.value === value) {
10388 return raw.raw;
10389 }
10390 return value;
10391 };
10392 _proto.root = function root(node2) {
10393 this.body(node2);
10394 if (node2.raws.after) this.builder(node2.raws.after);
10395 };
10396 _proto.rule = function rule(node2) {
10397 this.block(node2, this.rawValue(node2, "selector"));
10398 if (node2.raws.ownSemicolon) {
10399 this.builder(node2.raws.ownSemicolon, node2, "end");
10400 }
10401 };
10402 _proto.stringify = function stringify(node2, semicolon) {
10403 if (!this[node2.type]) {
10404 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
10405 }
10406 this[node2.type](node2, semicolon);
10407 };
10408 return Stringifier;
10409 }();
10410 var stringifier$1 = Stringifier$2$1;
10411 Stringifier$2$1.default = Stringifier$2$1;
10412 var Stringifier$1$1 = stringifier$1;
10413 function stringify$4$1(node2, builder) {
10414 var str = new Stringifier$1$1(builder);
10415 str.stringify(node2);
10416 }
10417 var stringify_1$1 = stringify$4$1;
10418 stringify$4$1.default = stringify$4$1;
10419 var isClean$2$1 = symbols$1.isClean, my$2$1 = symbols$1.my;
10420 var CssSyntaxError$2$1 = cssSyntaxError$1;
10421 var Stringifier2$1 = stringifier$1;
10422 var stringify$3$1 = stringify_1$1;
10423 function cloneNode$1(obj, parent) {
10424 var cloned = new obj.constructor();
10425 for(var i2 in obj){
10426 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
10427 continue;
10428 }
10429 if (i2 === "proxyCache") continue;
10430 var value = obj[i2];
10431 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
10432 if (i2 === "parent" && type === "object") {
10433 if (parent) cloned[i2] = parent;
10434 } else if (i2 === "source") {
10435 cloned[i2] = value;
10436 } else if (Array.isArray(value)) {
10437 cloned[i2] = value.map(function(j) {
10438 return cloneNode$1(j, cloned);
10439 });
10440 } else {
10441 if (type === "object" && value !== null) value = cloneNode$1(value);
10442 cloned[i2] = value;
10443 }
10444 }
10445 return cloned;
10446 }
10447 var Node$4$1 = /*#__PURE__*/ function() {
10448 function Node2(defaults) {
10449 if (defaults === void 0) defaults = {};
10450 this.raws = {};
10451 this[isClean$2$1] = false;
10452 this[my$2$1] = true;
10453 for(var name in defaults){
10454 if (name === "nodes") {
10455 this.nodes = [];
10456 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
10457 var node2 = _step.value;
10458 if (typeof node2.clone === "function") {
10459 this.append(node2.clone());
10460 } else {
10461 this.append(node2);
10462 }
10463 }
10464 } else {
10465 this[name] = defaults[name];
10466 }
10467 }
10468 }
10469 var _proto = Node2.prototype;
10470 _proto.addToError = function addToError(error) {
10471 error.postcssNode = this;
10472 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
10473 var s2 = this.source;
10474 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
10475 }
10476 return error;
10477 };
10478 _proto.after = function after(add) {
10479 this.parent.insertAfter(this, add);
10480 return this;
10481 };
10482 _proto.assign = function assign(overrides) {
10483 if (overrides === void 0) overrides = {};
10484 for(var name in overrides){
10485 this[name] = overrides[name];
10486 }
10487 return this;
10488 };
10489 _proto.before = function before(add) {
10490 this.parent.insertBefore(this, add);
10491 return this;
10492 };
10493 _proto.cleanRaws = function cleanRaws(keepBetween) {
10494 delete this.raws.before;
10495 delete this.raws.after;
10496 if (!keepBetween) delete this.raws.between;
10497 };
10498 _proto.clone = function clone(overrides) {
10499 if (overrides === void 0) overrides = {};
10500 var cloned = cloneNode$1(this);
10501 for(var name in overrides){
10502 cloned[name] = overrides[name];
10503 }
10504 return cloned;
10505 };
10506 _proto.cloneAfter = function cloneAfter(overrides) {
10507 if (overrides === void 0) overrides = {};
10508 var cloned = this.clone(overrides);
10509 this.parent.insertAfter(this, cloned);
10510 return cloned;
10511 };
10512 _proto.cloneBefore = function cloneBefore(overrides) {
10513 if (overrides === void 0) overrides = {};
10514 var cloned = this.clone(overrides);
10515 this.parent.insertBefore(this, cloned);
10516 return cloned;
10517 };
10518 _proto.error = function error(message, opts) {
10519 if (opts === void 0) opts = {};
10520 if (this.source) {
10521 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
10522 return this.source.input.error(message, {
10523 column: start.column,
10524 line: start.line
10525 }, {
10526 column: end.column,
10527 line: end.line
10528 }, opts);
10529 }
10530 return new CssSyntaxError$2$1(message);
10531 };
10532 _proto.getProxyProcessor = function getProxyProcessor() {
10533 return {
10534 get: function get(node2, prop) {
10535 if (prop === "proxyOf") {
10536 return node2;
10537 } else if (prop === "root") {
10538 return function() {
10539 return node2.root().toProxy();
10540 };
10541 } else {
10542 return node2[prop];
10543 }
10544 },
10545 set: function set(node2, prop, value) {
10546 if (node2[prop] === value) return true;
10547 node2[prop] = value;
10548 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
10549 node2.markDirty();
10550 }
10551 return true;
10552 }
10553 };
10554 };
10555 _proto.markDirty = function markDirty() {
10556 if (this[isClean$2$1]) {
10557 this[isClean$2$1] = false;
10558 var next = this;
10559 while(next = next.parent){
10560 next[isClean$2$1] = false;
10561 }
10562 }
10563 };
10564 _proto.next = function next() {
10565 if (!this.parent) return void 0;
10566 var index2 = this.parent.index(this);
10567 return this.parent.nodes[index2 + 1];
10568 };
10569 _proto.positionBy = function positionBy(opts, stringRepresentation) {
10570 var pos = this.source.start;
10571 if (opts.index) {
10572 pos = this.positionInside(opts.index, stringRepresentation);
10573 } else if (opts.word) {
10574 stringRepresentation = this.toString();
10575 var index2 = stringRepresentation.indexOf(opts.word);
10576 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
10577 }
10578 return pos;
10579 };
10580 _proto.positionInside = function positionInside(index2, stringRepresentation) {
10581 var string = stringRepresentation || this.toString();
10582 var column = this.source.start.column;
10583 var line = this.source.start.line;
10584 for(var i2 = 0; i2 < index2; i2++){
10585 if (string[i2] === "\n") {
10586 column = 1;
10587 line += 1;
10588 } else {
10589 column += 1;
10590 }
10591 }
10592 return {
10593 column: column,
10594 line: line
10595 };
10596 };
10597 _proto.prev = function prev() {
10598 if (!this.parent) return void 0;
10599 var index2 = this.parent.index(this);
10600 return this.parent.nodes[index2 - 1];
10601 };
10602 _proto.rangeBy = function rangeBy(opts) {
10603 var start = {
10604 column: this.source.start.column,
10605 line: this.source.start.line
10606 };
10607 var end = this.source.end ? {
10608 column: this.source.end.column + 1,
10609 line: this.source.end.line
10610 } : {
10611 column: start.column + 1,
10612 line: start.line
10613 };
10614 if (opts.word) {
10615 var stringRepresentation = this.toString();
10616 var index2 = stringRepresentation.indexOf(opts.word);
10617 if (index2 !== -1) {
10618 start = this.positionInside(index2, stringRepresentation);
10619 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
10620 }
10621 } else {
10622 if (opts.start) {
10623 start = {
10624 column: opts.start.column,
10625 line: opts.start.line
10626 };
10627 } else if (opts.index) {
10628 start = this.positionInside(opts.index);
10629 }
10630 if (opts.end) {
10631 end = {
10632 column: opts.end.column,
10633 line: opts.end.line
10634 };
10635 } else if (typeof opts.endIndex === "number") {
10636 end = this.positionInside(opts.endIndex);
10637 } else if (opts.index) {
10638 end = this.positionInside(opts.index + 1);
10639 }
10640 }
10641 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
10642 end = {
10643 column: start.column + 1,
10644 line: start.line
10645 };
10646 }
10647 return {
10648 end: end,
10649 start: start
10650 };
10651 };
10652 _proto.raw = function raw(prop, defaultType) {
10653 var str = new Stringifier2$1();
10654 return str.raw(this, prop, defaultType);
10655 };
10656 _proto.remove = function remove() {
10657 if (this.parent) {
10658 this.parent.removeChild(this);
10659 }
10660 this.parent = void 0;
10661 return this;
10662 };
10663 _proto.replaceWith = function replaceWith() {
10664 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
10665 nodes[_key] = arguments[_key];
10666 }
10667 if (this.parent) {
10668 var bookmark = this;
10669 var foundSelf = false;
10670 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
10671 var node2 = _step.value;
10672 if (node2 === this) {
10673 foundSelf = true;
10674 } else if (foundSelf) {
10675 this.parent.insertAfter(bookmark, node2);
10676 bookmark = node2;
10677 } else {
10678 this.parent.insertBefore(bookmark, node2);
10679 }
10680 }
10681 if (!foundSelf) {
10682 this.remove();
10683 }
10684 }
10685 return this;
10686 };
10687 _proto.root = function root() {
10688 var result2 = this;
10689 while(result2.parent && result2.parent.type !== "document"){
10690 result2 = result2.parent;
10691 }
10692 return result2;
10693 };
10694 _proto.toJSON = function toJSON(_, inputs) {
10695 var fixed = {};
10696 var emitInputs = inputs == null;
10697 inputs = inputs || /* @__PURE__ */ new Map();
10698 var inputsNextIndex = 0;
10699 for(var name in this){
10700 if (!Object.prototype.hasOwnProperty.call(this, name)) {
10701 continue;
10702 }
10703 if (name === "parent" || name === "proxyCache") continue;
10704 var value = this[name];
10705 if (Array.isArray(value)) {
10706 fixed[name] = value.map(function(i2) {
10707 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
10708 return i2.toJSON(null, inputs);
10709 } else {
10710 return i2;
10711 }
10712 });
10713 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
10714 fixed[name] = value.toJSON(null, inputs);
10715 } else if (name === "source") {
10716 var inputId = inputs.get(value.input);
10717 if (inputId == null) {
10718 inputId = inputsNextIndex;
10719 inputs.set(value.input, inputsNextIndex);
10720 inputsNextIndex++;
10721 }
10722 fixed[name] = {
10723 end: value.end,
10724 inputId: inputId,
10725 start: value.start
10726 };
10727 } else {
10728 fixed[name] = value;
10729 }
10730 }
10731 if (emitInputs) {
10732 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
10733 return input2.toJSON();
10734 });
10735 }
10736 return fixed;
10737 };
10738 _proto.toProxy = function toProxy() {
10739 if (!this.proxyCache) {
10740 this.proxyCache = new Proxy(this, this.getProxyProcessor());
10741 }
10742 return this.proxyCache;
10743 };
10744 _proto.toString = function toString(stringifier2) {
10745 if (stringifier2 === void 0) stringifier2 = stringify$3$1;
10746 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
10747 var result2 = "";
10748 stringifier2(this, function(i2) {
10749 result2 += i2;
10750 });
10751 return result2;
10752 };
10753 _proto.warn = function warn(result2, text, opts) {
10754 var data = {
10755 node: this
10756 };
10757 for(var i2 in opts)data[i2] = opts[i2];
10758 return result2.warn(text, data);
10759 };
10760 _create_class(Node2, [
10761 {
10762 key: "proxyOf",
10763 get: function get() {
10764 return this;
10765 }
10766 }
10767 ]);
10768 return Node2;
10769 }();
10770 var node$1 = Node$4$1;
10771 Node$4$1.default = Node$4$1;
10772 var Node$3$1 = node$1;
10773 var Declaration$4$1 = /*#__PURE__*/ function(Node$3$1) {
10774 _inherits(Declaration, Node$3$1);
10775 function Declaration(defaults) {
10776 var _this;
10777 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
10778 defaults = _extends({}, defaults, {
10779 value: String(defaults.value)
10780 });
10781 }
10782 _this = Node$3$1.call(this, defaults) || this;
10783 _this.type = "decl";
10784 return _this;
10785 }
10786 _create_class(Declaration, [
10787 {
10788 key: "variable",
10789 get: function get() {
10790 return this.prop.startsWith("--") || this.prop[0] === "$";
10791 }
10792 }
10793 ]);
10794 return Declaration;
10795 }(Node$3$1);
10796 var declaration$1 = Declaration$4$1;
10797 Declaration$4$1.default = Declaration$4$1;
10798 var urlAlphabet$1 = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
10799 var nanoid$1$1 = function(size) {
10800 if (size === void 0) size = 21;
10801 var id = "";
10802 var i2 = size;
10803 while(i2--){
10804 id += urlAlphabet$1[Math.random() * 64 | 0];
10805 }
10806 return id;
10807 };
10808 var nonSecure$1 = {
10809 nanoid: nanoid$1$1};
10810 var SourceMapConsumer$2$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$2$1 = require$$2$1.SourceMapGenerator;
10811 var existsSync$1 = require$$2$1.existsSync, readFileSync$1 = require$$2$1.readFileSync;
10812 var dirname$1$1 = require$$2$1.dirname, join$1 = require$$2$1.join;
10813 function fromBase64$1(str) {
10814 if (Buffer) {
10815 return Buffer.from(str, "base64").toString();
10816 } else {
10817 return window.atob(str);
10818 }
10819 }
10820 var PreviousMap$2$1 = /*#__PURE__*/ function() {
10821 function PreviousMap(css, opts) {
10822 if (opts.map === false) return;
10823 this.loadAnnotation(css);
10824 this.inline = this.startWith(this.annotation, "data:");
10825 var prev = opts.map ? opts.map.prev : void 0;
10826 var text = this.loadMap(opts.from, prev);
10827 if (!this.mapFile && opts.from) {
10828 this.mapFile = opts.from;
10829 }
10830 if (this.mapFile) this.root = dirname$1$1(this.mapFile);
10831 if (text) this.text = text;
10832 }
10833 var _proto = PreviousMap.prototype;
10834 _proto.consumer = function consumer() {
10835 if (!this.consumerCache) {
10836 this.consumerCache = new SourceMapConsumer$2$1(this.text);
10837 }
10838 return this.consumerCache;
10839 };
10840 _proto.decodeInline = function decodeInline(text) {
10841 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
10842 var baseUri = /^data:application\/json;base64,/;
10843 var charsetUri = /^data:application\/json;charset=utf-?8,/;
10844 var uri = /^data:application\/json,/;
10845 if (charsetUri.test(text) || uri.test(text)) {
10846 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
10847 }
10848 if (baseCharsetUri.test(text) || baseUri.test(text)) {
10849 return fromBase64$1(text.substr(RegExp.lastMatch.length));
10850 }
10851 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
10852 throw new Error("Unsupported source map encoding " + encoding);
10853 };
10854 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
10855 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
10856 };
10857 _proto.isMap = function isMap(map) {
10858 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
10859 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
10860 };
10861 _proto.loadAnnotation = function loadAnnotation(css) {
10862 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
10863 if (!comments) return;
10864 var start = css.lastIndexOf(comments.pop());
10865 var end = css.indexOf("*/", start);
10866 if (start > -1 && end > -1) {
10867 this.annotation = this.getAnnotationURL(css.substring(start, end));
10868 }
10869 };
10870 _proto.loadFile = function loadFile(path) {
10871 this.root = dirname$1$1(path);
10872 if (existsSync$1(path)) {
10873 this.mapFile = path;
10874 return readFileSync$1(path, "utf-8").toString().trim();
10875 }
10876 };
10877 _proto.loadMap = function loadMap(file, prev) {
10878 if (prev === false) return false;
10879 if (prev) {
10880 if (typeof prev === "string") {
10881 return prev;
10882 } else if (typeof prev === "function") {
10883 var prevPath = prev(file);
10884 if (prevPath) {
10885 var map = this.loadFile(prevPath);
10886 if (!map) {
10887 throw new Error("Unable to load previous source map: " + prevPath.toString());
10888 }
10889 return map;
10890 }
10891 } else if (_instanceof(prev, SourceMapConsumer$2$1)) {
10892 return SourceMapGenerator$2$1.fromSourceMap(prev).toString();
10893 } else if (_instanceof(prev, SourceMapGenerator$2$1)) {
10894 return prev.toString();
10895 } else if (this.isMap(prev)) {
10896 return JSON.stringify(prev);
10897 } else {
10898 throw new Error("Unsupported previous source map format: " + prev.toString());
10899 }
10900 } else if (this.inline) {
10901 return this.decodeInline(this.annotation);
10902 } else if (this.annotation) {
10903 var map1 = this.annotation;
10904 if (file) map1 = join$1(dirname$1$1(file), map1);
10905 return this.loadFile(map1);
10906 }
10907 };
10908 _proto.startWith = function startWith(string, start) {
10909 if (!string) return false;
10910 return string.substr(0, start.length) === start;
10911 };
10912 _proto.withContent = function withContent() {
10913 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
10914 };
10915 return PreviousMap;
10916 }();
10917 var previousMap$1 = PreviousMap$2$1;
10918 PreviousMap$2$1.default = PreviousMap$2$1;
10919 var SourceMapConsumer$1$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$1$1 = require$$2$1.SourceMapGenerator;
10920 var fileURLToPath$1 = require$$2$1.fileURLToPath, pathToFileURL$1$1 = require$$2$1.pathToFileURL;
10921 var isAbsolute$1 = require$$2$1.isAbsolute, resolve$1$1 = require$$2$1.resolve;
10922 var nanoid$2 = nonSecure$1.nanoid;
10923 var terminalHighlight$2 = require$$2$1;
10924 var CssSyntaxError$1$1 = cssSyntaxError$1;
10925 var PreviousMap$1$1 = previousMap$1;
10926 var fromOffsetCache$1 = Symbol("fromOffsetCache");
10927 var sourceMapAvailable$1$1 = Boolean(SourceMapConsumer$1$1 && SourceMapGenerator$1$1);
10928 var pathAvailable$1$1 = Boolean(resolve$1$1 && isAbsolute$1);
10929 var Input$4$1 = /*#__PURE__*/ function() {
10930 function Input(css, opts) {
10931 if (opts === void 0) opts = {};
10932 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
10933 throw new Error("PostCSS received " + css + " instead of CSS string");
10934 }
10935 this.css = css.toString();
10936 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
10937 this.hasBOM = true;
10938 this.css = this.css.slice(1);
10939 } else {
10940 this.hasBOM = false;
10941 }
10942 if (opts.from) {
10943 if (!pathAvailable$1$1 || /^\w+:\/\//.test(opts.from) || isAbsolute$1(opts.from)) {
10944 this.file = opts.from;
10945 } else {
10946 this.file = resolve$1$1(opts.from);
10947 }
10948 }
10949 if (pathAvailable$1$1 && sourceMapAvailable$1$1) {
10950 var map = new PreviousMap$1$1(this.css, opts);
10951 if (map.text) {
10952 this.map = map;
10953 var file = map.consumer().file;
10954 if (!this.file && file) this.file = this.mapResolve(file);
10955 }
10956 }
10957 if (!this.file) {
10958 this.id = "<input css " + nanoid$2(6) + ">";
10959 }
10960 if (this.map) this.map.file = this.from;
10961 }
10962 var _proto = Input.prototype;
10963 _proto.error = function error(message, line, column, opts) {
10964 if (opts === void 0) opts = {};
10965 var result2, endLine, endColumn;
10966 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
10967 var start = line;
10968 var end = column;
10969 if (typeof start.offset === "number") {
10970 var pos = this.fromOffset(start.offset);
10971 line = pos.line;
10972 column = pos.col;
10973 } else {
10974 line = start.line;
10975 column = start.column;
10976 }
10977 if (typeof end.offset === "number") {
10978 var pos1 = this.fromOffset(end.offset);
10979 endLine = pos1.line;
10980 endColumn = pos1.col;
10981 } else {
10982 endLine = end.line;
10983 endColumn = end.column;
10984 }
10985 } else if (!column) {
10986 var pos2 = this.fromOffset(line);
10987 line = pos2.line;
10988 column = pos2.col;
10989 }
10990 var origin = this.origin(line, column, endLine, endColumn);
10991 if (origin) {
10992 result2 = new CssSyntaxError$1$1(message, origin.endLine === void 0 ? origin.line : {
10993 column: origin.column,
10994 line: origin.line
10995 }, origin.endLine === void 0 ? origin.column : {
10996 column: origin.endColumn,
10997 line: origin.endLine
10998 }, origin.source, origin.file, opts.plugin);
10999 } else {
11000 result2 = new CssSyntaxError$1$1(message, endLine === void 0 ? line : {
11001 column: column,
11002 line: line
11003 }, endLine === void 0 ? column : {
11004 column: endColumn,
11005 line: endLine
11006 }, this.css, this.file, opts.plugin);
11007 }
11008 result2.input = {
11009 column: column,
11010 endColumn: endColumn,
11011 endLine: endLine,
11012 line: line,
11013 source: this.css
11014 };
11015 if (this.file) {
11016 if (pathToFileURL$1$1) {
11017 result2.input.url = pathToFileURL$1$1(this.file).toString();
11018 }
11019 result2.input.file = this.file;
11020 }
11021 return result2;
11022 };
11023 _proto.fromOffset = function fromOffset(offset) {
11024 var lastLine, lineToIndex;
11025 if (!this[fromOffsetCache$1]) {
11026 var lines = this.css.split("\n");
11027 lineToIndex = new Array(lines.length);
11028 var prevIndex = 0;
11029 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
11030 lineToIndex[i2] = prevIndex;
11031 prevIndex += lines[i2].length + 1;
11032 }
11033 this[fromOffsetCache$1] = lineToIndex;
11034 } else {
11035 lineToIndex = this[fromOffsetCache$1];
11036 }
11037 lastLine = lineToIndex[lineToIndex.length - 1];
11038 var min = 0;
11039 if (offset >= lastLine) {
11040 min = lineToIndex.length - 1;
11041 } else {
11042 var max = lineToIndex.length - 2;
11043 var mid;
11044 while(min < max){
11045 mid = min + (max - min >> 1);
11046 if (offset < lineToIndex[mid]) {
11047 max = mid - 1;
11048 } else if (offset >= lineToIndex[mid + 1]) {
11049 min = mid + 1;
11050 } else {
11051 min = mid;
11052 break;
11053 }
11054 }
11055 }
11056 return {
11057 col: offset - lineToIndex[min] + 1,
11058 line: min + 1
11059 };
11060 };
11061 _proto.mapResolve = function mapResolve(file) {
11062 if (/^\w+:\/\//.test(file)) {
11063 return file;
11064 }
11065 return resolve$1$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
11066 };
11067 _proto.origin = function origin(line, column, endLine, endColumn) {
11068 if (!this.map) return false;
11069 var consumer = this.map.consumer();
11070 var from = consumer.originalPositionFor({
11071 column: column,
11072 line: line
11073 });
11074 if (!from.source) return false;
11075 var to;
11076 if (typeof endLine === "number") {
11077 to = consumer.originalPositionFor({
11078 column: endColumn,
11079 line: endLine
11080 });
11081 }
11082 var fromUrl;
11083 if (isAbsolute$1(from.source)) {
11084 fromUrl = pathToFileURL$1$1(from.source);
11085 } else {
11086 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1$1(this.map.mapFile));
11087 }
11088 var result2 = {
11089 column: from.column,
11090 endColumn: to && to.column,
11091 endLine: to && to.line,
11092 line: from.line,
11093 url: fromUrl.toString()
11094 };
11095 if (fromUrl.protocol === "file:") {
11096 if (fileURLToPath$1) {
11097 result2.file = fileURLToPath$1(fromUrl);
11098 } else {
11099 throw new Error("file: protocol is not available in this PostCSS build");
11100 }
11101 }
11102 var source = consumer.sourceContentFor(from.source);
11103 if (source) result2.source = source;
11104 return result2;
11105 };
11106 _proto.toJSON = function toJSON() {
11107 var json = {};
11108 for(var _i = 0, _iter = [
11109 "hasBOM",
11110 "css",
11111 "file",
11112 "id"
11113 ]; _i < _iter.length; _i++){
11114 var name = _iter[_i];
11115 if (this[name] != null) {
11116 json[name] = this[name];
11117 }
11118 }
11119 if (this.map) {
11120 json.map = _extends({}, this.map);
11121 if (json.map.consumerCache) {
11122 json.map.consumerCache = void 0;
11123 }
11124 }
11125 return json;
11126 };
11127 _create_class(Input, [
11128 {
11129 key: "from",
11130 get: function get() {
11131 return this.file || this.id;
11132 }
11133 }
11134 ]);
11135 return Input;
11136 }();
11137 var input$1 = Input$4$1;
11138 Input$4$1.default = Input$4$1;
11139 if (terminalHighlight$2 && terminalHighlight$2.registerInput) {
11140 terminalHighlight$2.registerInput(Input$4$1);
11141 }
11142 var SourceMapConsumer$3 = require$$2$1.SourceMapConsumer, SourceMapGenerator$3 = require$$2$1.SourceMapGenerator;
11143 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;
11144 var pathToFileURL$2 = require$$2$1.pathToFileURL;
11145 var Input$3$1 = input$1;
11146 var sourceMapAvailable$2 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$3);
11147 var pathAvailable$2 = Boolean(dirname$2 && resolve$2 && relative$1 && sep$1);
11148 var MapGenerator$2$1 = /*#__PURE__*/ function() {
11149 function MapGenerator(stringify2, root2, opts, cssString) {
11150 this.stringify = stringify2;
11151 this.mapOpts = opts.map || {};
11152 this.root = root2;
11153 this.opts = opts;
11154 this.css = cssString;
11155 this.originalCSS = cssString;
11156 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
11157 this.memoizedFileURLs = /* @__PURE__ */ new Map();
11158 this.memoizedPaths = /* @__PURE__ */ new Map();
11159 this.memoizedURLs = /* @__PURE__ */ new Map();
11160 }
11161 var _proto = MapGenerator.prototype;
11162 _proto.addAnnotation = function addAnnotation() {
11163 var content;
11164 if (this.isInline()) {
11165 content = "data:application/json;base64," + this.toBase64(this.map.toString());
11166 } else if (typeof this.mapOpts.annotation === "string") {
11167 content = this.mapOpts.annotation;
11168 } else if (typeof this.mapOpts.annotation === "function") {
11169 content = this.mapOpts.annotation(this.opts.to, this.root);
11170 } else {
11171 content = this.outputFile() + ".map";
11172 }
11173 var eol = "\n";
11174 if (this.css.includes("\r\n")) eol = "\r\n";
11175 this.css += eol + "/*# sourceMappingURL=" + content + " */";
11176 };
11177 _proto.applyPrevMaps = function applyPrevMaps() {
11178 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
11179 var prev = _step.value;
11180 var from = this.toUrl(this.path(prev.file));
11181 var root2 = prev.root || dirname$2(prev.file);
11182 var map = void 0;
11183 if (this.mapOpts.sourcesContent === false) {
11184 map = new SourceMapConsumer$3(prev.text);
11185 if (map.sourcesContent) {
11186 map.sourcesContent = null;
11187 }
11188 } else {
11189 map = prev.consumer();
11190 }
11191 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
11192 }
11193 };
11194 _proto.clearAnnotation = function clearAnnotation() {
11195 if (this.mapOpts.annotation === false) return;
11196 if (this.root) {
11197 var node2;
11198 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
11199 node2 = this.root.nodes[i2];
11200 if (node2.type !== "comment") continue;
11201 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
11202 this.root.removeChild(i2);
11203 }
11204 }
11205 } else if (this.css) {
11206 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
11207 }
11208 };
11209 _proto.generate = function generate() {
11210 this.clearAnnotation();
11211 if (pathAvailable$2 && sourceMapAvailable$2 && this.isMap()) {
11212 return this.generateMap();
11213 } else {
11214 var result2 = "";
11215 this.stringify(this.root, function(i2) {
11216 result2 += i2;
11217 });
11218 return [
11219 result2
11220 ];
11221 }
11222 };
11223 _proto.generateMap = function generateMap() {
11224 if (this.root) {
11225 this.generateString();
11226 } else if (this.previous().length === 1) {
11227 var prev = this.previous()[0].consumer();
11228 prev.file = this.outputFile();
11229 this.map = SourceMapGenerator$3.fromSourceMap(prev, {
11230 ignoreInvalidMapping: true
11231 });
11232 } else {
11233 this.map = new SourceMapGenerator$3({
11234 file: this.outputFile(),
11235 ignoreInvalidMapping: true
11236 });
11237 this.map.addMapping({
11238 generated: {
11239 column: 0,
11240 line: 1
11241 },
11242 original: {
11243 column: 0,
11244 line: 1
11245 },
11246 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
11247 });
11248 }
11249 if (this.isSourcesContent()) this.setSourcesContent();
11250 if (this.root && this.previous().length > 0) this.applyPrevMaps();
11251 if (this.isAnnotation()) this.addAnnotation();
11252 if (this.isInline()) {
11253 return [
11254 this.css
11255 ];
11256 } else {
11257 return [
11258 this.css,
11259 this.map
11260 ];
11261 }
11262 };
11263 _proto.generateString = function generateString() {
11264 var _this = this;
11265 this.css = "";
11266 this.map = new SourceMapGenerator$3({
11267 file: this.outputFile(),
11268 ignoreInvalidMapping: true
11269 });
11270 var line = 1;
11271 var column = 1;
11272 var noSource = "<no source>";
11273 var mapping = {
11274 generated: {
11275 column: 0,
11276 line: 0
11277 },
11278 original: {
11279 column: 0,
11280 line: 0
11281 },
11282 source: ""
11283 };
11284 var lines, last;
11285 this.stringify(this.root, function(str, node2, type) {
11286 _this.css += str;
11287 if (node2 && type !== "end") {
11288 mapping.generated.line = line;
11289 mapping.generated.column = column - 1;
11290 if (node2.source && node2.source.start) {
11291 mapping.source = _this.sourcePath(node2);
11292 mapping.original.line = node2.source.start.line;
11293 mapping.original.column = node2.source.start.column - 1;
11294 _this.map.addMapping(mapping);
11295 } else {
11296 mapping.source = noSource;
11297 mapping.original.line = 1;
11298 mapping.original.column = 0;
11299 _this.map.addMapping(mapping);
11300 }
11301 }
11302 lines = str.match(/\n/g);
11303 if (lines) {
11304 line += lines.length;
11305 last = str.lastIndexOf("\n");
11306 column = str.length - last;
11307 } else {
11308 column += str.length;
11309 }
11310 if (node2 && type !== "start") {
11311 var p = node2.parent || {
11312 raws: {}
11313 };
11314 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
11315 if (!childless || node2 !== p.last || p.raws.semicolon) {
11316 if (node2.source && node2.source.end) {
11317 mapping.source = _this.sourcePath(node2);
11318 mapping.original.line = node2.source.end.line;
11319 mapping.original.column = node2.source.end.column - 1;
11320 mapping.generated.line = line;
11321 mapping.generated.column = column - 2;
11322 _this.map.addMapping(mapping);
11323 } else {
11324 mapping.source = noSource;
11325 mapping.original.line = 1;
11326 mapping.original.column = 0;
11327 mapping.generated.line = line;
11328 mapping.generated.column = column - 1;
11329 _this.map.addMapping(mapping);
11330 }
11331 }
11332 }
11333 });
11334 };
11335 _proto.isAnnotation = function isAnnotation() {
11336 if (this.isInline()) {
11337 return true;
11338 }
11339 if (typeof this.mapOpts.annotation !== "undefined") {
11340 return this.mapOpts.annotation;
11341 }
11342 if (this.previous().length) {
11343 return this.previous().some(function(i2) {
11344 return i2.annotation;
11345 });
11346 }
11347 return true;
11348 };
11349 _proto.isInline = function isInline() {
11350 if (typeof this.mapOpts.inline !== "undefined") {
11351 return this.mapOpts.inline;
11352 }
11353 var annotation = this.mapOpts.annotation;
11354 if (typeof annotation !== "undefined" && annotation !== true) {
11355 return false;
11356 }
11357 if (this.previous().length) {
11358 return this.previous().some(function(i2) {
11359 return i2.inline;
11360 });
11361 }
11362 return true;
11363 };
11364 _proto.isMap = function isMap() {
11365 if (typeof this.opts.map !== "undefined") {
11366 return !!this.opts.map;
11367 }
11368 return this.previous().length > 0;
11369 };
11370 _proto.isSourcesContent = function isSourcesContent() {
11371 if (typeof this.mapOpts.sourcesContent !== "undefined") {
11372 return this.mapOpts.sourcesContent;
11373 }
11374 if (this.previous().length) {
11375 return this.previous().some(function(i2) {
11376 return i2.withContent();
11377 });
11378 }
11379 return true;
11380 };
11381 _proto.outputFile = function outputFile() {
11382 if (this.opts.to) {
11383 return this.path(this.opts.to);
11384 } else if (this.opts.from) {
11385 return this.path(this.opts.from);
11386 } else {
11387 return "to.css";
11388 }
11389 };
11390 _proto.path = function path(file) {
11391 if (this.mapOpts.absolute) return file;
11392 if (file.charCodeAt(0) === 60) return file;
11393 if (/^\w+:\/\//.test(file)) return file;
11394 var cached = this.memoizedPaths.get(file);
11395 if (cached) return cached;
11396 var from = this.opts.to ? dirname$2(this.opts.to) : ".";
11397 if (typeof this.mapOpts.annotation === "string") {
11398 from = dirname$2(resolve$2(from, this.mapOpts.annotation));
11399 }
11400 var path = relative$1(from, file);
11401 this.memoizedPaths.set(file, path);
11402 return path;
11403 };
11404 _proto.previous = function previous() {
11405 var _this = this;
11406 if (!this.previousMaps) {
11407 this.previousMaps = [];
11408 if (this.root) {
11409 this.root.walk(function(node2) {
11410 if (node2.source && node2.source.input.map) {
11411 var map = node2.source.input.map;
11412 if (!_this.previousMaps.includes(map)) {
11413 _this.previousMaps.push(map);
11414 }
11415 }
11416 });
11417 } else {
11418 var input2 = new Input$3$1(this.originalCSS, this.opts);
11419 if (input2.map) this.previousMaps.push(input2.map);
11420 }
11421 }
11422 return this.previousMaps;
11423 };
11424 _proto.setSourcesContent = function setSourcesContent() {
11425 var _this = this;
11426 var already = {};
11427 if (this.root) {
11428 this.root.walk(function(node2) {
11429 if (node2.source) {
11430 var from = node2.source.input.from;
11431 if (from && !already[from]) {
11432 already[from] = true;
11433 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
11434 _this.map.setSourceContent(fromUrl, node2.source.input.css);
11435 }
11436 }
11437 });
11438 } else if (this.css) {
11439 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
11440 this.map.setSourceContent(from, this.css);
11441 }
11442 };
11443 _proto.sourcePath = function sourcePath(node2) {
11444 if (this.mapOpts.from) {
11445 return this.toUrl(this.mapOpts.from);
11446 } else if (this.usesFileUrls) {
11447 return this.toFileUrl(node2.source.input.from);
11448 } else {
11449 return this.toUrl(this.path(node2.source.input.from));
11450 }
11451 };
11452 _proto.toBase64 = function toBase64(str) {
11453 if (Buffer) {
11454 return Buffer.from(str).toString("base64");
11455 } else {
11456 return window.btoa(unescape(encodeURIComponent(str)));
11457 }
11458 };
11459 _proto.toFileUrl = function toFileUrl(path) {
11460 var cached = this.memoizedFileURLs.get(path);
11461 if (cached) return cached;
11462 if (pathToFileURL$2) {
11463 var fileURL = pathToFileURL$2(path).toString();
11464 this.memoizedFileURLs.set(path, fileURL);
11465 return fileURL;
11466 } else {
11467 throw new Error("`map.absolute` option is not available in this PostCSS build");
11468 }
11469 };
11470 _proto.toUrl = function toUrl(path) {
11471 var cached = this.memoizedURLs.get(path);
11472 if (cached) return cached;
11473 if (sep$1 === "\\") {
11474 path = path.replace(/\\/g, "/");
11475 }
11476 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
11477 this.memoizedURLs.set(path, url);
11478 return url;
11479 };
11480 return MapGenerator;
11481 }();
11482 var mapGenerator$1 = MapGenerator$2$1;
11483 var Node$2$1 = node$1;
11484 var Comment$4$1 = /*#__PURE__*/ function(Node$2$1) {
11485 _inherits(Comment, Node$2$1);
11486 function Comment(defaults) {
11487 var _this;
11488 _this = Node$2$1.call(this, defaults) || this;
11489 _this.type = "comment";
11490 return _this;
11491 }
11492 return Comment;
11493 }(Node$2$1);
11494 var comment$1 = Comment$4$1;
11495 Comment$4$1.default = Comment$4$1;
11496 var isClean$1$1 = symbols$1.isClean, my$1$1 = symbols$1.my;
11497 var Declaration$3$1 = declaration$1;
11498 var Comment$3$1 = comment$1;
11499 var Node$1$1 = node$1;
11500 var parse$4$1, Rule$4$1, AtRule$4$1, Root$6$1;
11501 function cleanSource$1(nodes) {
11502 return nodes.map(function(i2) {
11503 if (i2.nodes) i2.nodes = cleanSource$1(i2.nodes);
11504 delete i2.source;
11505 return i2;
11506 });
11507 }
11508 function markDirtyUp$1(node2) {
11509 node2[isClean$1$1] = false;
11510 if (node2.proxyOf.nodes) {
11511 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
11512 var i2 = _step.value;
11513 markDirtyUp$1(i2);
11514 }
11515 }
11516 }
11517 var Container$7$1 = /*#__PURE__*/ function(Node$1$1) {
11518 _inherits(Container, Node$1$1);
11519 function Container() {
11520 return Node$1$1.apply(this, arguments) || this;
11521 }
11522 var _proto = Container.prototype;
11523 _proto.append = function append() {
11524 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
11525 children[_key] = arguments[_key];
11526 }
11527 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
11528 var child = _step.value;
11529 var nodes = this.normalize(child, this.last);
11530 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11531 var node2 = _step1.value;
11532 this.proxyOf.nodes.push(node2);
11533 }
11534 }
11535 this.markDirty();
11536 return this;
11537 };
11538 _proto.cleanRaws = function cleanRaws(keepBetween) {
11539 Node$1$1.prototype.cleanRaws.call(this, keepBetween);
11540 if (this.nodes) {
11541 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
11542 var node2 = _step.value;
11543 node2.cleanRaws(keepBetween);
11544 }
11545 }
11546 };
11547 _proto.each = function each(callback) {
11548 if (!this.proxyOf.nodes) return void 0;
11549 var iterator = this.getIterator();
11550 var index2, result2;
11551 while(this.indexes[iterator] < this.proxyOf.nodes.length){
11552 index2 = this.indexes[iterator];
11553 result2 = callback(this.proxyOf.nodes[index2], index2);
11554 if (result2 === false) break;
11555 this.indexes[iterator] += 1;
11556 }
11557 delete this.indexes[iterator];
11558 return result2;
11559 };
11560 _proto.every = function every(condition) {
11561 return this.nodes.every(condition);
11562 };
11563 _proto.getIterator = function getIterator() {
11564 if (!this.lastEach) this.lastEach = 0;
11565 if (!this.indexes) this.indexes = {};
11566 this.lastEach += 1;
11567 var iterator = this.lastEach;
11568 this.indexes[iterator] = 0;
11569 return iterator;
11570 };
11571 _proto.getProxyProcessor = function getProxyProcessor() {
11572 return {
11573 get: function get(node2, prop) {
11574 if (prop === "proxyOf") {
11575 return node2;
11576 } else if (!node2[prop]) {
11577 return node2[prop];
11578 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
11579 return function() {
11580 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
11581 args[_key] = arguments[_key];
11582 }
11583 var _node2;
11584 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
11585 if (typeof i2 === "function") {
11586 return function(child, index2) {
11587 return i2(child.toProxy(), index2);
11588 };
11589 } else {
11590 return i2;
11591 }
11592 })));
11593 };
11594 } else if (prop === "every" || prop === "some") {
11595 return function(cb) {
11596 return node2[prop](function(child) {
11597 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
11598 other[_key - 1] = arguments[_key];
11599 }
11600 return cb.apply(void 0, [].concat([
11601 child.toProxy()
11602 ], other));
11603 });
11604 };
11605 } else if (prop === "root") {
11606 return function() {
11607 return node2.root().toProxy();
11608 };
11609 } else if (prop === "nodes") {
11610 return node2.nodes.map(function(i2) {
11611 return i2.toProxy();
11612 });
11613 } else if (prop === "first" || prop === "last") {
11614 return node2[prop].toProxy();
11615 } else {
11616 return node2[prop];
11617 }
11618 },
11619 set: function set(node2, prop, value) {
11620 if (node2[prop] === value) return true;
11621 node2[prop] = value;
11622 if (prop === "name" || prop === "params" || prop === "selector") {
11623 node2.markDirty();
11624 }
11625 return true;
11626 }
11627 };
11628 };
11629 _proto.index = function index(child) {
11630 if (typeof child === "number") return child;
11631 if (child.proxyOf) child = child.proxyOf;
11632 return this.proxyOf.nodes.indexOf(child);
11633 };
11634 _proto.insertAfter = function insertAfter(exist, add) {
11635 var existIndex = this.index(exist);
11636 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
11637 existIndex = this.index(exist);
11638 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11639 var node2 = _step.value;
11640 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
11641 }
11642 var index2;
11643 for(var id in this.indexes){
11644 index2 = this.indexes[id];
11645 if (existIndex < index2) {
11646 this.indexes[id] = index2 + nodes.length;
11647 }
11648 }
11649 this.markDirty();
11650 return this;
11651 };
11652 _proto.insertBefore = function insertBefore(exist, add) {
11653 var existIndex = this.index(exist);
11654 var type = existIndex === 0 ? "prepend" : false;
11655 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
11656 existIndex = this.index(exist);
11657 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11658 var node2 = _step.value;
11659 this.proxyOf.nodes.splice(existIndex, 0, node2);
11660 }
11661 var index2;
11662 for(var id in this.indexes){
11663 index2 = this.indexes[id];
11664 if (existIndex <= index2) {
11665 this.indexes[id] = index2 + nodes.length;
11666 }
11667 }
11668 this.markDirty();
11669 return this;
11670 };
11671 _proto.normalize = function normalize(nodes, sample) {
11672 var _this = this;
11673 if (typeof nodes === "string") {
11674 nodes = cleanSource$1(parse$4$1(nodes).nodes);
11675 } else if (typeof nodes === "undefined") {
11676 nodes = [];
11677 } else if (Array.isArray(nodes)) {
11678 nodes = nodes.slice(0);
11679 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11680 var i2 = _step.value;
11681 if (i2.parent) i2.parent.removeChild(i2, "ignore");
11682 }
11683 } else if (nodes.type === "root" && this.type !== "document") {
11684 nodes = nodes.nodes.slice(0);
11685 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11686 var i21 = _step1.value;
11687 if (i21.parent) i21.parent.removeChild(i21, "ignore");
11688 }
11689 } else if (nodes.type) {
11690 nodes = [
11691 nodes
11692 ];
11693 } else if (nodes.prop) {
11694 if (typeof nodes.value === "undefined") {
11695 throw new Error("Value field is missed in node creation");
11696 } else if (typeof nodes.value !== "string") {
11697 nodes.value = String(nodes.value);
11698 }
11699 nodes = [
11700 new Declaration$3$1(nodes)
11701 ];
11702 } else if (nodes.selector) {
11703 nodes = [
11704 new Rule$4$1(nodes)
11705 ];
11706 } else if (nodes.name) {
11707 nodes = [
11708 new AtRule$4$1(nodes)
11709 ];
11710 } else if (nodes.text) {
11711 nodes = [
11712 new Comment$3$1(nodes)
11713 ];
11714 } else {
11715 throw new Error("Unknown node type in node creation");
11716 }
11717 var processed = nodes.map(function(i2) {
11718 if (!i2[my$1$1]) Container.rebuild(i2);
11719 i2 = i2.proxyOf;
11720 if (i2.parent) i2.parent.removeChild(i2);
11721 if (i2[isClean$1$1]) markDirtyUp$1(i2);
11722 if (typeof i2.raws.before === "undefined") {
11723 if (sample && typeof sample.raws.before !== "undefined") {
11724 i2.raws.before = sample.raws.before.replace(/\S/g, "");
11725 }
11726 }
11727 i2.parent = _this.proxyOf;
11728 return i2;
11729 });
11730 return processed;
11731 };
11732 _proto.prepend = function prepend() {
11733 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
11734 children[_key] = arguments[_key];
11735 }
11736 children = children.reverse();
11737 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
11738 var child = _step.value;
11739 var nodes = this.normalize(child, this.first, "prepend").reverse();
11740 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11741 var node2 = _step1.value;
11742 this.proxyOf.nodes.unshift(node2);
11743 }
11744 for(var id in this.indexes){
11745 this.indexes[id] = this.indexes[id] + nodes.length;
11746 }
11747 }
11748 this.markDirty();
11749 return this;
11750 };
11751 _proto.push = function push(child) {
11752 child.parent = this;
11753 this.proxyOf.nodes.push(child);
11754 return this;
11755 };
11756 _proto.removeAll = function removeAll() {
11757 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
11758 var node2 = _step.value;
11759 node2.parent = void 0;
11760 }
11761 this.proxyOf.nodes = [];
11762 this.markDirty();
11763 return this;
11764 };
11765 _proto.removeChild = function removeChild(child) {
11766 child = this.index(child);
11767 this.proxyOf.nodes[child].parent = void 0;
11768 this.proxyOf.nodes.splice(child, 1);
11769 var index2;
11770 for(var id in this.indexes){
11771 index2 = this.indexes[id];
11772 if (index2 >= child) {
11773 this.indexes[id] = index2 - 1;
11774 }
11775 }
11776 this.markDirty();
11777 return this;
11778 };
11779 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
11780 if (!callback) {
11781 callback = opts;
11782 opts = {};
11783 }
11784 this.walkDecls(function(decl) {
11785 if (opts.props && !opts.props.includes(decl.prop)) return;
11786 if (opts.fast && !decl.value.includes(opts.fast)) return;
11787 decl.value = decl.value.replace(pattern, callback);
11788 });
11789 this.markDirty();
11790 return this;
11791 };
11792 _proto.some = function some(condition) {
11793 return this.nodes.some(condition);
11794 };
11795 _proto.walk = function walk(callback) {
11796 return this.each(function(child, i2) {
11797 var result2;
11798 try {
11799 result2 = callback(child, i2);
11800 } catch (e2) {
11801 throw child.addToError(e2);
11802 }
11803 if (result2 !== false && child.walk) {
11804 result2 = child.walk(callback);
11805 }
11806 return result2;
11807 });
11808 };
11809 _proto.walkAtRules = function walkAtRules(name, callback) {
11810 if (!callback) {
11811 callback = name;
11812 return this.walk(function(child, i2) {
11813 if (child.type === "atrule") {
11814 return callback(child, i2);
11815 }
11816 });
11817 }
11818 if (_instanceof(name, RegExp)) {
11819 return this.walk(function(child, i2) {
11820 if (child.type === "atrule" && name.test(child.name)) {
11821 return callback(child, i2);
11822 }
11823 });
11824 }
11825 return this.walk(function(child, i2) {
11826 if (child.type === "atrule" && child.name === name) {
11827 return callback(child, i2);
11828 }
11829 });
11830 };
11831 _proto.walkComments = function walkComments(callback) {
11832 return this.walk(function(child, i2) {
11833 if (child.type === "comment") {
11834 return callback(child, i2);
11835 }
11836 });
11837 };
11838 _proto.walkDecls = function walkDecls(prop, callback) {
11839 if (!callback) {
11840 callback = prop;
11841 return this.walk(function(child, i2) {
11842 if (child.type === "decl") {
11843 return callback(child, i2);
11844 }
11845 });
11846 }
11847 if (_instanceof(prop, RegExp)) {
11848 return this.walk(function(child, i2) {
11849 if (child.type === "decl" && prop.test(child.prop)) {
11850 return callback(child, i2);
11851 }
11852 });
11853 }
11854 return this.walk(function(child, i2) {
11855 if (child.type === "decl" && child.prop === prop) {
11856 return callback(child, i2);
11857 }
11858 });
11859 };
11860 _proto.walkRules = function walkRules(selector, callback) {
11861 if (!callback) {
11862 callback = selector;
11863 return this.walk(function(child, i2) {
11864 if (child.type === "rule") {
11865 return callback(child, i2);
11866 }
11867 });
11868 }
11869 if (_instanceof(selector, RegExp)) {
11870 return this.walk(function(child, i2) {
11871 if (child.type === "rule" && selector.test(child.selector)) {
11872 return callback(child, i2);
11873 }
11874 });
11875 }
11876 return this.walk(function(child, i2) {
11877 if (child.type === "rule" && child.selector === selector) {
11878 return callback(child, i2);
11879 }
11880 });
11881 };
11882 _create_class(Container, [
11883 {
11884 key: "first",
11885 get: function get() {
11886 if (!this.proxyOf.nodes) return void 0;
11887 return this.proxyOf.nodes[0];
11888 }
11889 },
11890 {
11891 key: "last",
11892 get: function get() {
11893 if (!this.proxyOf.nodes) return void 0;
11894 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
11895 }
11896 }
11897 ]);
11898 return Container;
11899 }(Node$1$1);
11900 Container$7$1.registerParse = function(dependant) {
11901 parse$4$1 = dependant;
11902 };
11903 Container$7$1.registerRule = function(dependant) {
11904 Rule$4$1 = dependant;
11905 };
11906 Container$7$1.registerAtRule = function(dependant) {
11907 AtRule$4$1 = dependant;
11908 };
11909 Container$7$1.registerRoot = function(dependant) {
11910 Root$6$1 = dependant;
11911 };
11912 var container$1 = Container$7$1;
11913 Container$7$1.default = Container$7$1;
11914 Container$7$1.rebuild = function(node2) {
11915 if (node2.type === "atrule") {
11916 Object.setPrototypeOf(node2, AtRule$4$1.prototype);
11917 } else if (node2.type === "rule") {
11918 Object.setPrototypeOf(node2, Rule$4$1.prototype);
11919 } else if (node2.type === "decl") {
11920 Object.setPrototypeOf(node2, Declaration$3$1.prototype);
11921 } else if (node2.type === "comment") {
11922 Object.setPrototypeOf(node2, Comment$3$1.prototype);
11923 } else if (node2.type === "root") {
11924 Object.setPrototypeOf(node2, Root$6$1.prototype);
11925 }
11926 node2[my$1$1] = true;
11927 if (node2.nodes) {
11928 node2.nodes.forEach(function(child) {
11929 Container$7$1.rebuild(child);
11930 });
11931 }
11932 };
11933 var Container$6$1 = container$1;
11934 var LazyResult$4$1, Processor$3$1;
11935 var Document$3$1 = /*#__PURE__*/ function(Container$6$1) {
11936 _inherits(Document2, Container$6$1);
11937 function Document2(defaults) {
11938 var _this;
11939 _this = Container$6$1.call(this, _extends({
11940 type: "document"
11941 }, defaults)) || this;
11942 if (!_this.nodes) {
11943 _this.nodes = [];
11944 }
11945 return _this;
11946 }
11947 var _proto = Document2.prototype;
11948 _proto.toResult = function toResult(opts) {
11949 if (opts === void 0) opts = {};
11950 var lazy = new LazyResult$4$1(new Processor$3$1(), this, opts);
11951 return lazy.stringify();
11952 };
11953 return Document2;
11954 }(Container$6$1);
11955 Document$3$1.registerLazyResult = function(dependant) {
11956 LazyResult$4$1 = dependant;
11957 };
11958 Document$3$1.registerProcessor = function(dependant) {
11959 Processor$3$1 = dependant;
11960 };
11961 var document$1$1 = Document$3$1;
11962 Document$3$1.default = Document$3$1;
11963 var printed$1 = {};
11964 var warnOnce$2$1 = function warnOnce(message) {
11965 if (printed$1[message]) return;
11966 printed$1[message] = true;
11967 if (typeof console !== "undefined" && console.warn) {
11968 console.warn(message);
11969 }
11970 };
11971 var Warning$2$1 = /*#__PURE__*/ function() {
11972 function Warning(text, opts) {
11973 if (opts === void 0) opts = {};
11974 this.type = "warning";
11975 this.text = text;
11976 if (opts.node && opts.node.source) {
11977 var range = opts.node.rangeBy(opts);
11978 this.line = range.start.line;
11979 this.column = range.start.column;
11980 this.endLine = range.end.line;
11981 this.endColumn = range.end.column;
11982 }
11983 for(var opt in opts)this[opt] = opts[opt];
11984 }
11985 var _proto = Warning.prototype;
11986 _proto.toString = function toString() {
11987 if (this.node) {
11988 return this.node.error(this.text, {
11989 index: this.index,
11990 plugin: this.plugin,
11991 word: this.word
11992 }).message;
11993 }
11994 if (this.plugin) {
11995 return this.plugin + ": " + this.text;
11996 }
11997 return this.text;
11998 };
11999 return Warning;
12000 }();
12001 var warning$1 = Warning$2$1;
12002 Warning$2$1.default = Warning$2$1;
12003 var Warning$1$1 = warning$1;
12004 var Result$3$1 = /*#__PURE__*/ function() {
12005 function Result(processor2, root2, opts) {
12006 this.processor = processor2;
12007 this.messages = [];
12008 this.root = root2;
12009 this.opts = opts;
12010 this.css = void 0;
12011 this.map = void 0;
12012 }
12013 var _proto = Result.prototype;
12014 _proto.toString = function toString() {
12015 return this.css;
12016 };
12017 _proto.warn = function warn(text, opts) {
12018 if (opts === void 0) opts = {};
12019 if (!opts.plugin) {
12020 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
12021 opts.plugin = this.lastPlugin.postcssPlugin;
12022 }
12023 }
12024 var warning2 = new Warning$1$1(text, opts);
12025 this.messages.push(warning2);
12026 return warning2;
12027 };
12028 _proto.warnings = function warnings() {
12029 return this.messages.filter(function(i2) {
12030 return i2.type === "warning";
12031 });
12032 };
12033 _create_class(Result, [
12034 {
12035 key: "content",
12036 get: function get() {
12037 return this.css;
12038 }
12039 }
12040 ]);
12041 return Result;
12042 }();
12043 var result$1 = Result$3$1;
12044 Result$3$1.default = Result$3$1;
12045 var SINGLE_QUOTE$1 = "'".charCodeAt(0);
12046 var DOUBLE_QUOTE$1 = '"'.charCodeAt(0);
12047 var BACKSLASH$1 = "\\".charCodeAt(0);
12048 var SLASH$1 = "/".charCodeAt(0);
12049 var NEWLINE$1 = "\n".charCodeAt(0);
12050 var SPACE$1 = " ".charCodeAt(0);
12051 var FEED$1 = "\f".charCodeAt(0);
12052 var TAB$1 = " ".charCodeAt(0);
12053 var CR$1 = "\r".charCodeAt(0);
12054 var OPEN_SQUARE$1 = "[".charCodeAt(0);
12055 var CLOSE_SQUARE$1 = "]".charCodeAt(0);
12056 var OPEN_PARENTHESES$1 = "(".charCodeAt(0);
12057 var CLOSE_PARENTHESES$1 = ")".charCodeAt(0);
12058 var OPEN_CURLY$1 = "{".charCodeAt(0);
12059 var CLOSE_CURLY$1 = "}".charCodeAt(0);
12060 var SEMICOLON$1 = ";".charCodeAt(0);
12061 var ASTERISK$1 = "*".charCodeAt(0);
12062 var COLON$1 = ":".charCodeAt(0);
12063 var AT$1 = "@".charCodeAt(0);
12064 var RE_AT_END$1 = /[\t\n\f\r "#'()/;[\\\]{}]/g;
12065 var RE_WORD_END$1 = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
12066 var RE_BAD_BRACKET$1 = /.[\r\n"'(/\\]/;
12067 var RE_HEX_ESCAPE$1 = /[\da-f]/i;
12068 var tokenize$1 = function tokenizer(input2, options) {
12069 if (options === void 0) options = {};
12070 var css = input2.css.valueOf();
12071 var ignore = options.ignoreErrors;
12072 var code, next, quote, content, escape;
12073 var escaped, escapePos, prev, n2, currentToken;
12074 var length = css.length;
12075 var pos = 0;
12076 var buffer = [];
12077 var returned = [];
12078 function position() {
12079 return pos;
12080 }
12081 function unclosed(what) {
12082 throw input2.error("Unclosed " + what, pos);
12083 }
12084 function endOfFile() {
12085 return returned.length === 0 && pos >= length;
12086 }
12087 function nextToken(opts) {
12088 if (returned.length) return returned.pop();
12089 if (pos >= length) return;
12090 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
12091 code = css.charCodeAt(pos);
12092 switch(code){
12093 case NEWLINE$1:
12094 case SPACE$1:
12095 case TAB$1:
12096 case CR$1:
12097 case FEED$1:
12098 {
12099 next = pos;
12100 do {
12101 next += 1;
12102 code = css.charCodeAt(next);
12103 }while (code === SPACE$1 || code === NEWLINE$1 || code === TAB$1 || code === CR$1 || code === FEED$1);
12104 currentToken = [
12105 "space",
12106 css.slice(pos, next)
12107 ];
12108 pos = next - 1;
12109 break;
12110 }
12111 case OPEN_SQUARE$1:
12112 case CLOSE_SQUARE$1:
12113 case OPEN_CURLY$1:
12114 case CLOSE_CURLY$1:
12115 case COLON$1:
12116 case SEMICOLON$1:
12117 case CLOSE_PARENTHESES$1:
12118 {
12119 var controlChar = String.fromCharCode(code);
12120 currentToken = [
12121 controlChar,
12122 controlChar,
12123 pos
12124 ];
12125 break;
12126 }
12127 case OPEN_PARENTHESES$1:
12128 {
12129 prev = buffer.length ? buffer.pop()[1] : "";
12130 n2 = css.charCodeAt(pos + 1);
12131 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) {
12132 next = pos;
12133 do {
12134 escaped = false;
12135 next = css.indexOf(")", next + 1);
12136 if (next === -1) {
12137 if (ignore || ignoreUnclosed) {
12138 next = pos;
12139 break;
12140 } else {
12141 unclosed("bracket");
12142 }
12143 }
12144 escapePos = next;
12145 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12146 escapePos -= 1;
12147 escaped = !escaped;
12148 }
12149 }while (escaped);
12150 currentToken = [
12151 "brackets",
12152 css.slice(pos, next + 1),
12153 pos,
12154 next
12155 ];
12156 pos = next;
12157 } else {
12158 next = css.indexOf(")", pos + 1);
12159 content = css.slice(pos, next + 1);
12160 if (next === -1 || RE_BAD_BRACKET$1.test(content)) {
12161 currentToken = [
12162 "(",
12163 "(",
12164 pos
12165 ];
12166 } else {
12167 currentToken = [
12168 "brackets",
12169 content,
12170 pos,
12171 next
12172 ];
12173 pos = next;
12174 }
12175 }
12176 break;
12177 }
12178 case SINGLE_QUOTE$1:
12179 case DOUBLE_QUOTE$1:
12180 {
12181 quote = code === SINGLE_QUOTE$1 ? "'" : '"';
12182 next = pos;
12183 do {
12184 escaped = false;
12185 next = css.indexOf(quote, next + 1);
12186 if (next === -1) {
12187 if (ignore || ignoreUnclosed) {
12188 next = pos + 1;
12189 break;
12190 } else {
12191 unclosed("string");
12192 }
12193 }
12194 escapePos = next;
12195 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12196 escapePos -= 1;
12197 escaped = !escaped;
12198 }
12199 }while (escaped);
12200 currentToken = [
12201 "string",
12202 css.slice(pos, next + 1),
12203 pos,
12204 next
12205 ];
12206 pos = next;
12207 break;
12208 }
12209 case AT$1:
12210 {
12211 RE_AT_END$1.lastIndex = pos + 1;
12212 RE_AT_END$1.test(css);
12213 if (RE_AT_END$1.lastIndex === 0) {
12214 next = css.length - 1;
12215 } else {
12216 next = RE_AT_END$1.lastIndex - 2;
12217 }
12218 currentToken = [
12219 "at-word",
12220 css.slice(pos, next + 1),
12221 pos,
12222 next
12223 ];
12224 pos = next;
12225 break;
12226 }
12227 case BACKSLASH$1:
12228 {
12229 next = pos;
12230 escape = true;
12231 while(css.charCodeAt(next + 1) === BACKSLASH$1){
12232 next += 1;
12233 escape = !escape;
12234 }
12235 code = css.charCodeAt(next + 1);
12236 if (escape && code !== SLASH$1 && code !== SPACE$1 && code !== NEWLINE$1 && code !== TAB$1 && code !== CR$1 && code !== FEED$1) {
12237 next += 1;
12238 if (RE_HEX_ESCAPE$1.test(css.charAt(next))) {
12239 while(RE_HEX_ESCAPE$1.test(css.charAt(next + 1))){
12240 next += 1;
12241 }
12242 if (css.charCodeAt(next + 1) === SPACE$1) {
12243 next += 1;
12244 }
12245 }
12246 }
12247 currentToken = [
12248 "word",
12249 css.slice(pos, next + 1),
12250 pos,
12251 next
12252 ];
12253 pos = next;
12254 break;
12255 }
12256 default:
12257 {
12258 if (code === SLASH$1 && css.charCodeAt(pos + 1) === ASTERISK$1) {
12259 next = css.indexOf("*/", pos + 2) + 1;
12260 if (next === 0) {
12261 if (ignore || ignoreUnclosed) {
12262 next = css.length;
12263 } else {
12264 unclosed("comment");
12265 }
12266 }
12267 currentToken = [
12268 "comment",
12269 css.slice(pos, next + 1),
12270 pos,
12271 next
12272 ];
12273 pos = next;
12274 } else {
12275 RE_WORD_END$1.lastIndex = pos + 1;
12276 RE_WORD_END$1.test(css);
12277 if (RE_WORD_END$1.lastIndex === 0) {
12278 next = css.length - 1;
12279 } else {
12280 next = RE_WORD_END$1.lastIndex - 2;
12281 }
12282 currentToken = [
12283 "word",
12284 css.slice(pos, next + 1),
12285 pos,
12286 next
12287 ];
12288 buffer.push(currentToken);
12289 pos = next;
12290 }
12291 break;
12292 }
12293 }
12294 pos++;
12295 return currentToken;
12296 }
12297 function back(token) {
12298 returned.push(token);
12299 }
12300 return {
12301 back: back,
12302 endOfFile: endOfFile,
12303 nextToken: nextToken,
12304 position: position
12305 };
12306 };
12307 var Container$5$1 = container$1;
12308 var AtRule$3$1 = /*#__PURE__*/ function(Container$5$1) {
12309 _inherits(AtRule, Container$5$1);
12310 function AtRule(defaults) {
12311 var _this;
12312 _this = Container$5$1.call(this, defaults) || this;
12313 _this.type = "atrule";
12314 return _this;
12315 }
12316 var _proto = AtRule.prototype;
12317 _proto.append = function append() {
12318 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12319 children[_key] = arguments[_key];
12320 }
12321 var _Container$5$1_prototype_append;
12322 if (!this.proxyOf.nodes) this.nodes = [];
12323 return (_Container$5$1_prototype_append = Container$5$1.prototype.append).call.apply(_Container$5$1_prototype_append, [].concat([
12324 this
12325 ], children));
12326 };
12327 _proto.prepend = function prepend() {
12328 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12329 children[_key] = arguments[_key];
12330 }
12331 var _Container$5$1_prototype_prepend;
12332 if (!this.proxyOf.nodes) this.nodes = [];
12333 return (_Container$5$1_prototype_prepend = Container$5$1.prototype.prepend).call.apply(_Container$5$1_prototype_prepend, [].concat([
12334 this
12335 ], children));
12336 };
12337 return AtRule;
12338 }(Container$5$1);
12339 var atRule$1 = AtRule$3$1;
12340 AtRule$3$1.default = AtRule$3$1;
12341 Container$5$1.registerAtRule(AtRule$3$1);
12342 var Container$4$1 = container$1;
12343 var LazyResult$3$1, Processor$2$1;
12344 var Root$5$1 = /*#__PURE__*/ function(Container$4$1) {
12345 _inherits(Root, Container$4$1);
12346 function Root(defaults) {
12347 var _this;
12348 _this = Container$4$1.call(this, defaults) || this;
12349 _this.type = "root";
12350 if (!_this.nodes) _this.nodes = [];
12351 return _this;
12352 }
12353 var _proto = Root.prototype;
12354 _proto.normalize = function normalize(child, sample, type) {
12355 var nodes = Container$4$1.prototype.normalize.call(this, child);
12356 if (sample) {
12357 if (type === "prepend") {
12358 if (this.nodes.length > 1) {
12359 sample.raws.before = this.nodes[1].raws.before;
12360 } else {
12361 delete sample.raws.before;
12362 }
12363 } else if (this.first !== sample) {
12364 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12365 var node2 = _step.value;
12366 node2.raws.before = sample.raws.before;
12367 }
12368 }
12369 }
12370 return nodes;
12371 };
12372 _proto.removeChild = function removeChild(child, ignore) {
12373 var index2 = this.index(child);
12374 if (!ignore && index2 === 0 && this.nodes.length > 1) {
12375 this.nodes[1].raws.before = this.nodes[index2].raws.before;
12376 }
12377 return Container$4$1.prototype.removeChild.call(this, child);
12378 };
12379 _proto.toResult = function toResult(opts) {
12380 if (opts === void 0) opts = {};
12381 var lazy = new LazyResult$3$1(new Processor$2$1(), this, opts);
12382 return lazy.stringify();
12383 };
12384 return Root;
12385 }(Container$4$1);
12386 Root$5$1.registerLazyResult = function(dependant) {
12387 LazyResult$3$1 = dependant;
12388 };
12389 Root$5$1.registerProcessor = function(dependant) {
12390 Processor$2$1 = dependant;
12391 };
12392 var root$1 = Root$5$1;
12393 Root$5$1.default = Root$5$1;
12394 Container$4$1.registerRoot(Root$5$1);
12395 var list$2$1 = {
12396 comma: function comma(string) {
12397 return list$2$1.split(string, [
12398 ","
12399 ], true);
12400 },
12401 space: function space(string) {
12402 var spaces = [
12403 " ",
12404 "\n",
12405 " "
12406 ];
12407 return list$2$1.split(string, spaces);
12408 },
12409 split: function split(string, separators, last) {
12410 var array = [];
12411 var current = "";
12412 var split = false;
12413 var func = 0;
12414 var inQuote = false;
12415 var prevQuote = "";
12416 var escape = false;
12417 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
12418 var letter = _step.value;
12419 if (escape) {
12420 escape = false;
12421 } else if (letter === "\\") {
12422 escape = true;
12423 } else if (inQuote) {
12424 if (letter === prevQuote) {
12425 inQuote = false;
12426 }
12427 } else if (letter === '"' || letter === "'") {
12428 inQuote = true;
12429 prevQuote = letter;
12430 } else if (letter === "(") {
12431 func += 1;
12432 } else if (letter === ")") {
12433 if (func > 0) func -= 1;
12434 } else if (func === 0) {
12435 if (separators.includes(letter)) split = true;
12436 }
12437 if (split) {
12438 if (current !== "") array.push(current.trim());
12439 current = "";
12440 split = false;
12441 } else {
12442 current += letter;
12443 }
12444 }
12445 if (last || current !== "") array.push(current.trim());
12446 return array;
12447 }
12448 };
12449 var list_1$1 = list$2$1;
12450 list$2$1.default = list$2$1;
12451 var Container$3$1 = container$1;
12452 var list$1$1 = list_1$1;
12453 var Rule$3$1 = /*#__PURE__*/ function(Container$3$1) {
12454 _inherits(Rule, Container$3$1);
12455 function Rule(defaults) {
12456 var _this;
12457 _this = Container$3$1.call(this, defaults) || this;
12458 _this.type = "rule";
12459 if (!_this.nodes) _this.nodes = [];
12460 return _this;
12461 }
12462 _create_class(Rule, [
12463 {
12464 key: "selectors",
12465 get: function get() {
12466 return list$1$1.comma(this.selector);
12467 },
12468 set: function set(values) {
12469 var match = this.selector ? this.selector.match(/,\s*/) : null;
12470 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
12471 this.selector = values.join(sep2);
12472 }
12473 }
12474 ]);
12475 return Rule;
12476 }(Container$3$1);
12477 var rule$1 = Rule$3$1;
12478 Rule$3$1.default = Rule$3$1;
12479 Container$3$1.registerRule(Rule$3$1);
12480 var Declaration$2$1 = declaration$1;
12481 var tokenizer2$1 = tokenize$1;
12482 var Comment$2$1 = comment$1;
12483 var AtRule$2$1 = atRule$1;
12484 var Root$4$1 = root$1;
12485 var Rule$2$1 = rule$1;
12486 var SAFE_COMMENT_NEIGHBOR$1 = {
12487 empty: true,
12488 space: true
12489 };
12490 function findLastWithPosition$1(tokens) {
12491 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
12492 var token = tokens[i2];
12493 var pos = token[3] || token[2];
12494 if (pos) return pos;
12495 }
12496 }
12497 var Parser$1$1 = /*#__PURE__*/ function() {
12498 function Parser(input2) {
12499 this.input = input2;
12500 this.root = new Root$4$1();
12501 this.current = this.root;
12502 this.spaces = "";
12503 this.semicolon = false;
12504 this.createTokenizer();
12505 this.root.source = {
12506 input: input2,
12507 start: {
12508 column: 1,
12509 line: 1,
12510 offset: 0
12511 }
12512 };
12513 }
12514 var _proto = Parser.prototype;
12515 _proto.atrule = function atrule(token) {
12516 var node2 = new AtRule$2$1();
12517 node2.name = token[1].slice(1);
12518 if (node2.name === "") {
12519 this.unnamedAtrule(node2, token);
12520 }
12521 this.init(node2, token[2]);
12522 var type;
12523 var prev;
12524 var shift;
12525 var last = false;
12526 var open = false;
12527 var params = [];
12528 var brackets = [];
12529 while(!this.tokenizer.endOfFile()){
12530 token = this.tokenizer.nextToken();
12531 type = token[0];
12532 if (type === "(" || type === "[") {
12533 brackets.push(type === "(" ? ")" : "]");
12534 } else if (type === "{" && brackets.length > 0) {
12535 brackets.push("}");
12536 } else if (type === brackets[brackets.length - 1]) {
12537 brackets.pop();
12538 }
12539 if (brackets.length === 0) {
12540 if (type === ";") {
12541 node2.source.end = this.getPosition(token[2]);
12542 node2.source.end.offset++;
12543 this.semicolon = true;
12544 break;
12545 } else if (type === "{") {
12546 open = true;
12547 break;
12548 } else if (type === "}") {
12549 if (params.length > 0) {
12550 shift = params.length - 1;
12551 prev = params[shift];
12552 while(prev && prev[0] === "space"){
12553 prev = params[--shift];
12554 }
12555 if (prev) {
12556 node2.source.end = this.getPosition(prev[3] || prev[2]);
12557 node2.source.end.offset++;
12558 }
12559 }
12560 this.end(token);
12561 break;
12562 } else {
12563 params.push(token);
12564 }
12565 } else {
12566 params.push(token);
12567 }
12568 if (this.tokenizer.endOfFile()) {
12569 last = true;
12570 break;
12571 }
12572 }
12573 node2.raws.between = this.spacesAndCommentsFromEnd(params);
12574 if (params.length) {
12575 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
12576 this.raw(node2, "params", params);
12577 if (last) {
12578 token = params[params.length - 1];
12579 node2.source.end = this.getPosition(token[3] || token[2]);
12580 node2.source.end.offset++;
12581 this.spaces = node2.raws.between;
12582 node2.raws.between = "";
12583 }
12584 } else {
12585 node2.raws.afterName = "";
12586 node2.params = "";
12587 }
12588 if (open) {
12589 node2.nodes = [];
12590 this.current = node2;
12591 }
12592 };
12593 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
12594 var colon = this.colon(tokens);
12595 if (colon === false) return;
12596 var founded = 0;
12597 var token;
12598 for(var j = colon - 1; j >= 0; j--){
12599 token = tokens[j];
12600 if (token[0] !== "space") {
12601 founded += 1;
12602 if (founded === 2) break;
12603 }
12604 }
12605 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
12606 };
12607 _proto.colon = function colon(tokens) {
12608 var brackets = 0;
12609 var token, type, prev;
12610 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
12611 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
12612 token = element;
12613 type = token[0];
12614 if (type === "(") {
12615 brackets += 1;
12616 }
12617 if (type === ")") {
12618 brackets -= 1;
12619 }
12620 if (brackets === 0 && type === ":") {
12621 if (!prev) {
12622 this.doubleColon(token);
12623 } else if (prev[0] === "word" && prev[1] === "progid") {
12624 continue;
12625 } else {
12626 return i2;
12627 }
12628 }
12629 prev = token;
12630 }
12631 return false;
12632 };
12633 _proto.comment = function comment(token) {
12634 var node2 = new Comment$2$1();
12635 this.init(node2, token[2]);
12636 node2.source.end = this.getPosition(token[3] || token[2]);
12637 node2.source.end.offset++;
12638 var text = token[1].slice(2, -2);
12639 if (/^\s*$/.test(text)) {
12640 node2.text = "";
12641 node2.raws.left = text;
12642 node2.raws.right = "";
12643 } else {
12644 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
12645 node2.text = match[2];
12646 node2.raws.left = match[1];
12647 node2.raws.right = match[3];
12648 }
12649 };
12650 _proto.createTokenizer = function createTokenizer() {
12651 this.tokenizer = tokenizer2$1(this.input);
12652 };
12653 _proto.decl = function decl(tokens, customProperty) {
12654 var node2 = new Declaration$2$1();
12655 this.init(node2, tokens[0][2]);
12656 var last = tokens[tokens.length - 1];
12657 if (last[0] === ";") {
12658 this.semicolon = true;
12659 tokens.pop();
12660 }
12661 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition$1(tokens));
12662 node2.source.end.offset++;
12663 while(tokens[0][0] !== "word"){
12664 if (tokens.length === 1) this.unknownWord(tokens);
12665 node2.raws.before += tokens.shift()[1];
12666 }
12667 node2.source.start = this.getPosition(tokens[0][2]);
12668 node2.prop = "";
12669 while(tokens.length){
12670 var type = tokens[0][0];
12671 if (type === ":" || type === "space" || type === "comment") {
12672 break;
12673 }
12674 node2.prop += tokens.shift()[1];
12675 }
12676 node2.raws.between = "";
12677 var token;
12678 while(tokens.length){
12679 token = tokens.shift();
12680 if (token[0] === ":") {
12681 node2.raws.between += token[1];
12682 break;
12683 } else {
12684 if (token[0] === "word" && /\w/.test(token[1])) {
12685 this.unknownWord([
12686 token
12687 ]);
12688 }
12689 node2.raws.between += token[1];
12690 }
12691 }
12692 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
12693 node2.raws.before += node2.prop[0];
12694 node2.prop = node2.prop.slice(1);
12695 }
12696 var firstSpaces = [];
12697 var next;
12698 while(tokens.length){
12699 next = tokens[0][0];
12700 if (next !== "space" && next !== "comment") break;
12701 firstSpaces.push(tokens.shift());
12702 }
12703 this.precheckMissedSemicolon(tokens);
12704 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
12705 token = tokens[i2];
12706 if (token[1].toLowerCase() === "!important") {
12707 node2.important = true;
12708 var string = this.stringFrom(tokens, i2);
12709 string = this.spacesFromEnd(tokens) + string;
12710 if (string !== " !important") node2.raws.important = string;
12711 break;
12712 } else if (token[1].toLowerCase() === "important") {
12713 var cache = tokens.slice(0);
12714 var str = "";
12715 for(var j = i2; j > 0; j--){
12716 var type1 = cache[j][0];
12717 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
12718 break;
12719 }
12720 str = cache.pop()[1] + str;
12721 }
12722 if (str.trim().indexOf("!") === 0) {
12723 node2.important = true;
12724 node2.raws.important = str;
12725 tokens = cache;
12726 }
12727 }
12728 if (token[0] !== "space" && token[0] !== "comment") {
12729 break;
12730 }
12731 }
12732 var hasWord = tokens.some(function(i2) {
12733 return i2[0] !== "space" && i2[0] !== "comment";
12734 });
12735 if (hasWord) {
12736 node2.raws.between += firstSpaces.map(function(i2) {
12737 return i2[1];
12738 }).join("");
12739 firstSpaces = [];
12740 }
12741 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
12742 if (node2.value.includes(":") && !customProperty) {
12743 this.checkMissedSemicolon(tokens);
12744 }
12745 };
12746 _proto.doubleColon = function doubleColon(token) {
12747 throw this.input.error("Double colon", {
12748 offset: token[2]
12749 }, {
12750 offset: token[2] + token[1].length
12751 });
12752 };
12753 _proto.emptyRule = function emptyRule(token) {
12754 var node2 = new Rule$2$1();
12755 this.init(node2, token[2]);
12756 node2.selector = "";
12757 node2.raws.between = "";
12758 this.current = node2;
12759 };
12760 _proto.end = function end(token) {
12761 if (this.current.nodes && this.current.nodes.length) {
12762 this.current.raws.semicolon = this.semicolon;
12763 }
12764 this.semicolon = false;
12765 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
12766 this.spaces = "";
12767 if (this.current.parent) {
12768 this.current.source.end = this.getPosition(token[2]);
12769 this.current.source.end.offset++;
12770 this.current = this.current.parent;
12771 } else {
12772 this.unexpectedClose(token);
12773 }
12774 };
12775 _proto.endFile = function endFile() {
12776 if (this.current.parent) this.unclosedBlock();
12777 if (this.current.nodes && this.current.nodes.length) {
12778 this.current.raws.semicolon = this.semicolon;
12779 }
12780 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
12781 this.root.source.end = this.getPosition(this.tokenizer.position());
12782 };
12783 _proto.freeSemicolon = function freeSemicolon(token) {
12784 this.spaces += token[1];
12785 if (this.current.nodes) {
12786 var prev = this.current.nodes[this.current.nodes.length - 1];
12787 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
12788 prev.raws.ownSemicolon = this.spaces;
12789 this.spaces = "";
12790 }
12791 }
12792 };
12793 // Helpers
12794 _proto.getPosition = function getPosition(offset) {
12795 var pos = this.input.fromOffset(offset);
12796 return {
12797 column: pos.col,
12798 line: pos.line,
12799 offset: offset
12800 };
12801 };
12802 _proto.init = function init(node2, offset) {
12803 this.current.push(node2);
12804 node2.source = {
12805 input: this.input,
12806 start: this.getPosition(offset)
12807 };
12808 node2.raws.before = this.spaces;
12809 this.spaces = "";
12810 if (node2.type !== "comment") this.semicolon = false;
12811 };
12812 _proto.other = function other(start) {
12813 var end = false;
12814 var type = null;
12815 var colon = false;
12816 var bracket = null;
12817 var brackets = [];
12818 var customProperty = start[1].startsWith("--");
12819 var tokens = [];
12820 var token = start;
12821 while(token){
12822 type = token[0];
12823 tokens.push(token);
12824 if (type === "(" || type === "[") {
12825 if (!bracket) bracket = token;
12826 brackets.push(type === "(" ? ")" : "]");
12827 } else if (customProperty && colon && type === "{") {
12828 if (!bracket) bracket = token;
12829 brackets.push("}");
12830 } else if (brackets.length === 0) {
12831 if (type === ";") {
12832 if (colon) {
12833 this.decl(tokens, customProperty);
12834 return;
12835 } else {
12836 break;
12837 }
12838 } else if (type === "{") {
12839 this.rule(tokens);
12840 return;
12841 } else if (type === "}") {
12842 this.tokenizer.back(tokens.pop());
12843 end = true;
12844 break;
12845 } else if (type === ":") {
12846 colon = true;
12847 }
12848 } else if (type === brackets[brackets.length - 1]) {
12849 brackets.pop();
12850 if (brackets.length === 0) bracket = null;
12851 }
12852 token = this.tokenizer.nextToken();
12853 }
12854 if (this.tokenizer.endOfFile()) end = true;
12855 if (brackets.length > 0) this.unclosedBracket(bracket);
12856 if (end && colon) {
12857 if (!customProperty) {
12858 while(tokens.length){
12859 token = tokens[tokens.length - 1][0];
12860 if (token !== "space" && token !== "comment") break;
12861 this.tokenizer.back(tokens.pop());
12862 }
12863 }
12864 this.decl(tokens, customProperty);
12865 } else {
12866 this.unknownWord(tokens);
12867 }
12868 };
12869 _proto.parse = function parse() {
12870 var token;
12871 while(!this.tokenizer.endOfFile()){
12872 token = this.tokenizer.nextToken();
12873 switch(token[0]){
12874 case "space":
12875 this.spaces += token[1];
12876 break;
12877 case ";":
12878 this.freeSemicolon(token);
12879 break;
12880 case "}":
12881 this.end(token);
12882 break;
12883 case "comment":
12884 this.comment(token);
12885 break;
12886 case "at-word":
12887 this.atrule(token);
12888 break;
12889 case "{":
12890 this.emptyRule(token);
12891 break;
12892 default:
12893 this.other(token);
12894 break;
12895 }
12896 }
12897 this.endFile();
12898 };
12899 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
12900 _proto.raw = function raw(node2, prop, tokens, customProperty) {
12901 var token, type;
12902 var length = tokens.length;
12903 var value = "";
12904 var clean = true;
12905 var next, prev;
12906 for(var i2 = 0; i2 < length; i2 += 1){
12907 token = tokens[i2];
12908 type = token[0];
12909 if (type === "space" && i2 === length - 1 && !customProperty) {
12910 clean = false;
12911 } else if (type === "comment") {
12912 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
12913 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
12914 if (!SAFE_COMMENT_NEIGHBOR$1[prev] && !SAFE_COMMENT_NEIGHBOR$1[next]) {
12915 if (value.slice(-1) === ",") {
12916 clean = false;
12917 } else {
12918 value += token[1];
12919 }
12920 } else {
12921 clean = false;
12922 }
12923 } else {
12924 value += token[1];
12925 }
12926 }
12927 if (!clean) {
12928 var raw = tokens.reduce(function(all, i2) {
12929 return all + i2[1];
12930 }, "");
12931 node2.raws[prop] = {
12932 raw: raw,
12933 value: value
12934 };
12935 }
12936 node2[prop] = value;
12937 };
12938 _proto.rule = function rule(tokens) {
12939 tokens.pop();
12940 var node2 = new Rule$2$1();
12941 this.init(node2, tokens[0][2]);
12942 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
12943 this.raw(node2, "selector", tokens);
12944 this.current = node2;
12945 };
12946 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
12947 var lastTokenType;
12948 var spaces = "";
12949 while(tokens.length){
12950 lastTokenType = tokens[tokens.length - 1][0];
12951 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
12952 spaces = tokens.pop()[1] + spaces;
12953 }
12954 return spaces;
12955 };
12956 // Errors
12957 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
12958 var next;
12959 var spaces = "";
12960 while(tokens.length){
12961 next = tokens[0][0];
12962 if (next !== "space" && next !== "comment") break;
12963 spaces += tokens.shift()[1];
12964 }
12965 return spaces;
12966 };
12967 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
12968 var lastTokenType;
12969 var spaces = "";
12970 while(tokens.length){
12971 lastTokenType = tokens[tokens.length - 1][0];
12972 if (lastTokenType !== "space") break;
12973 spaces = tokens.pop()[1] + spaces;
12974 }
12975 return spaces;
12976 };
12977 _proto.stringFrom = function stringFrom(tokens, from) {
12978 var result2 = "";
12979 for(var i2 = from; i2 < tokens.length; i2++){
12980 result2 += tokens[i2][1];
12981 }
12982 tokens.splice(from, tokens.length - from);
12983 return result2;
12984 };
12985 _proto.unclosedBlock = function unclosedBlock() {
12986 var pos = this.current.source.start;
12987 throw this.input.error("Unclosed block", pos.line, pos.column);
12988 };
12989 _proto.unclosedBracket = function unclosedBracket(bracket) {
12990 throw this.input.error("Unclosed bracket", {
12991 offset: bracket[2]
12992 }, {
12993 offset: bracket[2] + 1
12994 });
12995 };
12996 _proto.unexpectedClose = function unexpectedClose(token) {
12997 throw this.input.error("Unexpected }", {
12998 offset: token[2]
12999 }, {
13000 offset: token[2] + 1
13001 });
13002 };
13003 _proto.unknownWord = function unknownWord(tokens) {
13004 throw this.input.error("Unknown word", {
13005 offset: tokens[0][2]
13006 }, {
13007 offset: tokens[0][2] + tokens[0][1].length
13008 });
13009 };
13010 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
13011 throw this.input.error("At-rule without name", {
13012 offset: token[2]
13013 }, {
13014 offset: token[2] + token[1].length
13015 });
13016 };
13017 return Parser;
13018 }();
13019 var parser$1 = Parser$1$1;
13020 var Container$2$1 = container$1;
13021 var Parser2$1 = parser$1;
13022 var Input$2$1 = input$1;
13023 function parse$3$1(css, opts) {
13024 var input2 = new Input$2$1(css, opts);
13025 var parser2 = new Parser2$1(input2);
13026 try {
13027 parser2.parse();
13028 } catch (e2) {
13029 if (true) {
13030 if (e2.name === "CssSyntaxError" && opts && opts.from) {
13031 if (/\.scss$/i.test(opts.from)) {
13032 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
13033 } else if (/\.sass/i.test(opts.from)) {
13034 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
13035 } else if (/\.less$/i.test(opts.from)) {
13036 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
13037 }
13038 }
13039 }
13040 throw e2;
13041 }
13042 return parser2.root;
13043 }
13044 var parse_1$1 = parse$3$1;
13045 parse$3$1.default = parse$3$1;
13046 Container$2$1.registerParse(parse$3$1);
13047 var isClean$3 = symbols$1.isClean, my$3 = symbols$1.my;
13048 var MapGenerator$1$1 = mapGenerator$1;
13049 var stringify$2$1 = stringify_1$1;
13050 var Container$1$1 = container$1;
13051 var Document$2$1 = document$1$1;
13052 var warnOnce$1$1 = warnOnce$2$1;
13053 var Result$2$1 = result$1;
13054 var parse$2$1 = parse_1$1;
13055 var Root$3$1 = root$1;
13056 var TYPE_TO_CLASS_NAME$1 = {
13057 atrule: "AtRule",
13058 comment: "Comment",
13059 decl: "Declaration",
13060 document: "Document",
13061 root: "Root",
13062 rule: "Rule"
13063 };
13064 var PLUGIN_PROPS$1 = {
13065 AtRule: true,
13066 AtRuleExit: true,
13067 Comment: true,
13068 CommentExit: true,
13069 Declaration: true,
13070 DeclarationExit: true,
13071 Document: true,
13072 DocumentExit: true,
13073 Once: true,
13074 OnceExit: true,
13075 postcssPlugin: true,
13076 prepare: true,
13077 Root: true,
13078 RootExit: true,
13079 Rule: true,
13080 RuleExit: true
13081 };
13082 var NOT_VISITORS$1 = {
13083 Once: true,
13084 postcssPlugin: true,
13085 prepare: true
13086 };
13087 var CHILDREN$1 = 0;
13088 function isPromise$1(obj) {
13089 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
13090 }
13091 function getEvents$1(node2) {
13092 var key = false;
13093 var type = TYPE_TO_CLASS_NAME$1[node2.type];
13094 if (node2.type === "decl") {
13095 key = node2.prop.toLowerCase();
13096 } else if (node2.type === "atrule") {
13097 key = node2.name.toLowerCase();
13098 }
13099 if (key && node2.append) {
13100 return [
13101 type,
13102 type + "-" + key,
13103 CHILDREN$1,
13104 type + "Exit",
13105 type + "Exit-" + key
13106 ];
13107 } else if (key) {
13108 return [
13109 type,
13110 type + "-" + key,
13111 type + "Exit",
13112 type + "Exit-" + key
13113 ];
13114 } else if (node2.append) {
13115 return [
13116 type,
13117 CHILDREN$1,
13118 type + "Exit"
13119 ];
13120 } else {
13121 return [
13122 type,
13123 type + "Exit"
13124 ];
13125 }
13126 }
13127 function toStack$1(node2) {
13128 var events;
13129 if (node2.type === "document") {
13130 events = [
13131 "Document",
13132 CHILDREN$1,
13133 "DocumentExit"
13134 ];
13135 } else if (node2.type === "root") {
13136 events = [
13137 "Root",
13138 CHILDREN$1,
13139 "RootExit"
13140 ];
13141 } else {
13142 events = getEvents$1(node2);
13143 }
13144 return {
13145 eventIndex: 0,
13146 events: events,
13147 iterator: 0,
13148 node: node2,
13149 visitorIndex: 0,
13150 visitors: []
13151 };
13152 }
13153 function cleanMarks$1(node2) {
13154 node2[isClean$3] = false;
13155 if (node2.nodes) node2.nodes.forEach(function(i2) {
13156 return cleanMarks$1(i2);
13157 });
13158 return node2;
13159 }
13160 var postcss$2$1 = {};
13161 var LazyResult$2$1 = /*#__PURE__*/ function() {
13162 function LazyResult(processor2, css, opts) {
13163 var _this = this;
13164 this.stringified = false;
13165 this.processed = false;
13166 var root2;
13167 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
13168 root2 = cleanMarks$1(css);
13169 } else if (_instanceof(css, LazyResult) || _instanceof(css, Result$2$1)) {
13170 root2 = cleanMarks$1(css.root);
13171 if (css.map) {
13172 if (typeof opts.map === "undefined") opts.map = {};
13173 if (!opts.map.inline) opts.map.inline = false;
13174 opts.map.prev = css.map;
13175 }
13176 } else {
13177 var parser2 = parse$2$1;
13178 if (opts.syntax) parser2 = opts.syntax.parse;
13179 if (opts.parser) parser2 = opts.parser;
13180 if (parser2.parse) parser2 = parser2.parse;
13181 try {
13182 root2 = parser2(css, opts);
13183 } catch (error) {
13184 this.processed = true;
13185 this.error = error;
13186 }
13187 if (root2 && !root2[my$3]) {
13188 Container$1$1.rebuild(root2);
13189 }
13190 }
13191 this.result = new Result$2$1(processor2, root2, opts);
13192 this.helpers = _extends({}, postcss$2$1, {
13193 postcss: postcss$2$1,
13194 result: this.result
13195 });
13196 this.plugins = this.processor.plugins.map(function(plugin22) {
13197 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
13198 return _extends({}, plugin22, plugin22.prepare(_this.result));
13199 } else {
13200 return plugin22;
13201 }
13202 });
13203 }
13204 var _proto = LazyResult.prototype;
13205 _proto.async = function async() {
13206 if (this.error) return Promise.reject(this.error);
13207 if (this.processed) return Promise.resolve(this.result);
13208 if (!this.processing) {
13209 this.processing = this.runAsync();
13210 }
13211 return this.processing;
13212 };
13213 _proto.catch = function _catch(onRejected) {
13214 return this.async().catch(onRejected);
13215 };
13216 _proto.finally = function _finally(onFinally) {
13217 return this.async().then(onFinally, onFinally);
13218 };
13219 _proto.getAsyncError = function getAsyncError() {
13220 throw new Error("Use process(css).then(cb) to work with async plugins");
13221 };
13222 _proto.handleError = function handleError(error, node2) {
13223 var plugin22 = this.result.lastPlugin;
13224 try {
13225 if (node2) node2.addToError(error);
13226 this.error = error;
13227 if (error.name === "CssSyntaxError" && !error.plugin) {
13228 error.plugin = plugin22.postcssPlugin;
13229 error.setMessage();
13230 } else if (plugin22.postcssVersion) {
13231 if (true) {
13232 var pluginName = plugin22.postcssPlugin;
13233 var pluginVer = plugin22.postcssVersion;
13234 var runtimeVer = this.result.processor.version;
13235 var a2 = pluginVer.split(".");
13236 var b = runtimeVer.split(".");
13237 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
13238 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.");
13239 }
13240 }
13241 }
13242 } catch (err) {
13243 if (console && console.error) console.error(err);
13244 }
13245 return error;
13246 };
13247 _proto.prepareVisitors = function prepareVisitors() {
13248 var _this = this;
13249 this.listeners = {};
13250 var add = function(plugin22, type, cb) {
13251 if (!_this.listeners[type]) _this.listeners[type] = [];
13252 _this.listeners[type].push([
13253 plugin22,
13254 cb
13255 ]);
13256 };
13257 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13258 var plugin22 = _step.value;
13259 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
13260 for(var event in plugin22){
13261 if (!PLUGIN_PROPS$1[event] && /^[A-Z]/.test(event)) {
13262 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
13263 }
13264 if (!NOT_VISITORS$1[event]) {
13265 if (_type_of(plugin22[event]) === "object") {
13266 for(var filter in plugin22[event]){
13267 if (filter === "*") {
13268 add(plugin22, event, plugin22[event][filter]);
13269 } else {
13270 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
13271 }
13272 }
13273 } else if (typeof plugin22[event] === "function") {
13274 add(plugin22, event, plugin22[event]);
13275 }
13276 }
13277 }
13278 }
13279 }
13280 this.hasListener = Object.keys(this.listeners).length > 0;
13281 };
13282 _proto.runAsync = function runAsync() {
13283 var _this = this;
13284 return _async_to_generator(function() {
13285 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
13286 return _ts_generator(this, function(_state) {
13287 switch(_state.label){
13288 case 0:
13289 _this.plugin = 0;
13290 i2 = 0;
13291 _state.label = 1;
13292 case 1:
13293 if (!(i2 < _this.plugins.length)) return [
13294 3,
13295 6
13296 ];
13297 plugin22 = _this.plugins[i2];
13298 promise = _this.runOnRoot(plugin22);
13299 if (!isPromise$1(promise)) return [
13300 3,
13301 5
13302 ];
13303 _state.label = 2;
13304 case 2:
13305 _state.trys.push([
13306 2,
13307 4,
13308 ,
13309 5
13310 ]);
13311 return [
13312 4,
13313 promise
13314 ];
13315 case 3:
13316 _state.sent();
13317 return [
13318 3,
13319 5
13320 ];
13321 case 4:
13322 error = _state.sent();
13323 throw _this.handleError(error);
13324 case 5:
13325 i2++;
13326 return [
13327 3,
13328 1
13329 ];
13330 case 6:
13331 _this.prepareVisitors();
13332 if (!_this.hasListener) return [
13333 3,
13334 18
13335 ];
13336 root2 = _this.result.root;
13337 _state.label = 7;
13338 case 7:
13339 if (!!root2[isClean$3]) return [
13340 3,
13341 14
13342 ];
13343 root2[isClean$3] = true;
13344 stack = [
13345 toStack$1(root2)
13346 ];
13347 _state.label = 8;
13348 case 8:
13349 if (!(stack.length > 0)) return [
13350 3,
13351 13
13352 ];
13353 promise1 = _this.visitTick(stack);
13354 if (!isPromise$1(promise1)) return [
13355 3,
13356 12
13357 ];
13358 _state.label = 9;
13359 case 9:
13360 _state.trys.push([
13361 9,
13362 11,
13363 ,
13364 12
13365 ]);
13366 return [
13367 4,
13368 promise1
13369 ];
13370 case 10:
13371 _state.sent();
13372 return [
13373 3,
13374 12
13375 ];
13376 case 11:
13377 e2 = _state.sent();
13378 node2 = stack[stack.length - 1].node;
13379 throw _this.handleError(e2, node2);
13380 case 12:
13381 return [
13382 3,
13383 8
13384 ];
13385 case 13:
13386 return [
13387 3,
13388 7
13389 ];
13390 case 14:
13391 if (!_this.listeners.OnceExit) return [
13392 3,
13393 18
13394 ];
13395 _loop = function() {
13396 var _step_value, plugin22, visitor, roots, e2;
13397 return _ts_generator(this, function(_state) {
13398 switch(_state.label){
13399 case 0:
13400 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13401 _this.result.lastPlugin = plugin22;
13402 _state.label = 1;
13403 case 1:
13404 _state.trys.push([
13405 1,
13406 6,
13407 ,
13408 7
13409 ]);
13410 if (!(root2.type === "document")) return [
13411 3,
13412 3
13413 ];
13414 roots = root2.nodes.map(function(subRoot) {
13415 return visitor(subRoot, _this.helpers);
13416 });
13417 return [
13418 4,
13419 Promise.all(roots)
13420 ];
13421 case 2:
13422 _state.sent();
13423 return [
13424 3,
13425 5
13426 ];
13427 case 3:
13428 return [
13429 4,
13430 visitor(root2, _this.helpers)
13431 ];
13432 case 4:
13433 _state.sent();
13434 _state.label = 5;
13435 case 5:
13436 return [
13437 3,
13438 7
13439 ];
13440 case 6:
13441 e2 = _state.sent();
13442 throw _this.handleError(e2);
13443 case 7:
13444 return [
13445 2
13446 ];
13447 }
13448 });
13449 };
13450 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
13451 _state.label = 15;
13452 case 15:
13453 if (!!(_step = _iterator()).done) return [
13454 3,
13455 18
13456 ];
13457 return [
13458 5,
13459 _ts_values(_loop())
13460 ];
13461 case 16:
13462 _state.sent();
13463 _state.label = 17;
13464 case 17:
13465 return [
13466 3,
13467 15
13468 ];
13469 case 18:
13470 _this.processed = true;
13471 return [
13472 2,
13473 _this.stringify()
13474 ];
13475 }
13476 });
13477 })();
13478 };
13479 _proto.runOnRoot = function runOnRoot(plugin22) {
13480 var _this = this;
13481 this.result.lastPlugin = plugin22;
13482 try {
13483 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
13484 if (this.result.root.type === "document") {
13485 var roots = this.result.root.nodes.map(function(root2) {
13486 return plugin22.Once(root2, _this.helpers);
13487 });
13488 if (isPromise$1(roots[0])) {
13489 return Promise.all(roots);
13490 }
13491 return roots;
13492 }
13493 return plugin22.Once(this.result.root, this.helpers);
13494 } else if (typeof plugin22 === "function") {
13495 return plugin22(this.result.root, this.result);
13496 }
13497 } catch (error) {
13498 throw this.handleError(error);
13499 }
13500 };
13501 _proto.stringify = function stringify() {
13502 if (this.error) throw this.error;
13503 if (this.stringified) return this.result;
13504 this.stringified = true;
13505 this.sync();
13506 var opts = this.result.opts;
13507 var str = stringify$2$1;
13508 if (opts.syntax) str = opts.syntax.stringify;
13509 if (opts.stringifier) str = opts.stringifier;
13510 if (str.stringify) str = str.stringify;
13511 var map = new MapGenerator$1$1(str, this.result.root, this.result.opts);
13512 var data = map.generate();
13513 this.result.css = data[0];
13514 this.result.map = data[1];
13515 return this.result;
13516 };
13517 _proto.sync = function sync() {
13518 if (this.error) throw this.error;
13519 if (this.processed) return this.result;
13520 this.processed = true;
13521 if (this.processing) {
13522 throw this.getAsyncError();
13523 }
13524 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13525 var plugin22 = _step.value;
13526 var promise = this.runOnRoot(plugin22);
13527 if (isPromise$1(promise)) {
13528 throw this.getAsyncError();
13529 }
13530 }
13531 this.prepareVisitors();
13532 if (this.hasListener) {
13533 var root2 = this.result.root;
13534 while(!root2[isClean$3]){
13535 root2[isClean$3] = true;
13536 this.walkSync(root2);
13537 }
13538 if (this.listeners.OnceExit) {
13539 if (root2.type === "document") {
13540 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
13541 var subRoot = _step1.value;
13542 this.visitSync(this.listeners.OnceExit, subRoot);
13543 }
13544 } else {
13545 this.visitSync(this.listeners.OnceExit, root2);
13546 }
13547 }
13548 }
13549 return this.result;
13550 };
13551 _proto.then = function then(onFulfilled, onRejected) {
13552 if (true) {
13553 if (!("from" in this.opts)) {
13554 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.");
13555 }
13556 }
13557 return this.async().then(onFulfilled, onRejected);
13558 };
13559 _proto.toString = function toString() {
13560 return this.css;
13561 };
13562 _proto.visitSync = function visitSync(visitors, node2) {
13563 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
13564 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13565 this.result.lastPlugin = plugin22;
13566 var promise = void 0;
13567 try {
13568 promise = visitor(node2, this.helpers);
13569 } catch (e2) {
13570 throw this.handleError(e2, node2.proxyOf);
13571 }
13572 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
13573 return true;
13574 }
13575 if (isPromise$1(promise)) {
13576 throw this.getAsyncError();
13577 }
13578 }
13579 };
13580 _proto.visitTick = function visitTick(stack) {
13581 var visit2 = stack[stack.length - 1];
13582 var node2 = visit2.node, visitors = visit2.visitors;
13583 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
13584 stack.pop();
13585 return;
13586 }
13587 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
13588 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
13589 visit2.visitorIndex += 1;
13590 if (visit2.visitorIndex === visitors.length) {
13591 visit2.visitors = [];
13592 visit2.visitorIndex = 0;
13593 }
13594 this.result.lastPlugin = plugin22;
13595 try {
13596 return visitor(node2.toProxy(), this.helpers);
13597 } catch (e2) {
13598 throw this.handleError(e2, node2);
13599 }
13600 }
13601 if (visit2.iterator !== 0) {
13602 var iterator = visit2.iterator;
13603 var child;
13604 while(child = node2.nodes[node2.indexes[iterator]]){
13605 node2.indexes[iterator] += 1;
13606 if (!child[isClean$3]) {
13607 child[isClean$3] = true;
13608 stack.push(toStack$1(child));
13609 return;
13610 }
13611 }
13612 visit2.iterator = 0;
13613 delete node2.indexes[iterator];
13614 }
13615 var events = visit2.events;
13616 while(visit2.eventIndex < events.length){
13617 var event = events[visit2.eventIndex];
13618 visit2.eventIndex += 1;
13619 if (event === CHILDREN$1) {
13620 if (node2.nodes && node2.nodes.length) {
13621 node2[isClean$3] = true;
13622 visit2.iterator = node2.getIterator();
13623 }
13624 return;
13625 } else if (this.listeners[event]) {
13626 visit2.visitors = this.listeners[event];
13627 return;
13628 }
13629 }
13630 stack.pop();
13631 };
13632 _proto.walkSync = function walkSync(node2) {
13633 var _this = this;
13634 node2[isClean$3] = true;
13635 var events = getEvents$1(node2);
13636 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
13637 var event = _step.value;
13638 if (event === CHILDREN$1) {
13639 if (node2.nodes) {
13640 node2.each(function(child) {
13641 if (!child[isClean$3]) _this.walkSync(child);
13642 });
13643 }
13644 } else {
13645 var visitors = this.listeners[event];
13646 if (visitors) {
13647 if (this.visitSync(visitors, node2.toProxy())) return;
13648 }
13649 }
13650 }
13651 };
13652 _proto.warnings = function warnings() {
13653 return this.sync().warnings();
13654 };
13655 _create_class(LazyResult, [
13656 {
13657 key: "content",
13658 get: function get() {
13659 return this.stringify().content;
13660 }
13661 },
13662 {
13663 key: "css",
13664 get: function get() {
13665 return this.stringify().css;
13666 }
13667 },
13668 {
13669 key: "map",
13670 get: function get() {
13671 return this.stringify().map;
13672 }
13673 },
13674 {
13675 key: "messages",
13676 get: function get() {
13677 return this.sync().messages;
13678 }
13679 },
13680 {
13681 key: "opts",
13682 get: function get() {
13683 return this.result.opts;
13684 }
13685 },
13686 {
13687 key: "processor",
13688 get: function get() {
13689 return this.result.processor;
13690 }
13691 },
13692 {
13693 key: "root",
13694 get: function get() {
13695 return this.sync().root;
13696 }
13697 },
13698 {
13699 key: Symbol.toStringTag,
13700 get: function get() {
13701 return "LazyResult";
13702 }
13703 }
13704 ]);
13705 return LazyResult;
13706 }();
13707 LazyResult$2$1.registerPostcss = function(dependant) {
13708 postcss$2$1 = dependant;
13709 };
13710 var lazyResult$1 = LazyResult$2$1;
13711 LazyResult$2$1.default = LazyResult$2$1;
13712 Root$3$1.registerLazyResult(LazyResult$2$1);
13713 Document$2$1.registerLazyResult(LazyResult$2$1);
13714 var MapGenerator2$1 = mapGenerator$1;
13715 var stringify$1$1 = stringify_1$1;
13716 var warnOnce2$1 = warnOnce$2$1;
13717 var parse$1$1 = parse_1$1;
13718 var Result$1$1 = result$1;
13719 var NoWorkResult$1$1 = /*#__PURE__*/ function() {
13720 function NoWorkResult(processor2, css, opts) {
13721 css = css.toString();
13722 this.stringified = false;
13723 this._processor = processor2;
13724 this._css = css;
13725 this._opts = opts;
13726 this._map = void 0;
13727 var root2;
13728 var str = stringify$1$1;
13729 this.result = new Result$1$1(this._processor, root2, this._opts);
13730 this.result.css = css;
13731 var self = this;
13732 Object.defineProperty(this.result, "root", {
13733 get: function get() {
13734 return self.root;
13735 }
13736 });
13737 var map = new MapGenerator2$1(str, root2, this._opts, css);
13738 if (map.isMap()) {
13739 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
13740 if (generatedCSS) {
13741 this.result.css = generatedCSS;
13742 }
13743 if (generatedMap) {
13744 this.result.map = generatedMap;
13745 }
13746 } else {
13747 map.clearAnnotation();
13748 this.result.css = map.css;
13749 }
13750 }
13751 var _proto = NoWorkResult.prototype;
13752 _proto.async = function async() {
13753 if (this.error) return Promise.reject(this.error);
13754 return Promise.resolve(this.result);
13755 };
13756 _proto.catch = function _catch(onRejected) {
13757 return this.async().catch(onRejected);
13758 };
13759 _proto.finally = function _finally(onFinally) {
13760 return this.async().then(onFinally, onFinally);
13761 };
13762 _proto.sync = function sync() {
13763 if (this.error) throw this.error;
13764 return this.result;
13765 };
13766 _proto.then = function then(onFulfilled, onRejected) {
13767 if (true) {
13768 if (!("from" in this._opts)) {
13769 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.");
13770 }
13771 }
13772 return this.async().then(onFulfilled, onRejected);
13773 };
13774 _proto.toString = function toString() {
13775 return this._css;
13776 };
13777 _proto.warnings = function warnings() {
13778 return [];
13779 };
13780 _create_class(NoWorkResult, [
13781 {
13782 key: "content",
13783 get: function get() {
13784 return this.result.css;
13785 }
13786 },
13787 {
13788 key: "css",
13789 get: function get() {
13790 return this.result.css;
13791 }
13792 },
13793 {
13794 key: "map",
13795 get: function get() {
13796 return this.result.map;
13797 }
13798 },
13799 {
13800 key: "messages",
13801 get: function get() {
13802 return [];
13803 }
13804 },
13805 {
13806 key: "opts",
13807 get: function get() {
13808 return this.result.opts;
13809 }
13810 },
13811 {
13812 key: "processor",
13813 get: function get() {
13814 return this.result.processor;
13815 }
13816 },
13817 {
13818 key: "root",
13819 get: function get() {
13820 if (this._root) {
13821 return this._root;
13822 }
13823 var root2;
13824 var parser2 = parse$1$1;
13825 try {
13826 root2 = parser2(this._css, this._opts);
13827 } catch (error) {
13828 this.error = error;
13829 }
13830 if (this.error) {
13831 throw this.error;
13832 } else {
13833 this._root = root2;
13834 return root2;
13835 }
13836 }
13837 },
13838 {
13839 key: Symbol.toStringTag,
13840 get: function get() {
13841 return "NoWorkResult";
13842 }
13843 }
13844 ]);
13845 return NoWorkResult;
13846 }();
13847 var noWorkResult$1 = NoWorkResult$1$1;
13848 NoWorkResult$1$1.default = NoWorkResult$1$1;
13849 var NoWorkResult2$1 = noWorkResult$1;
13850 var LazyResult$1$1 = lazyResult$1;
13851 var Document$1$1 = document$1$1;
13852 var Root$2$1 = root$1;
13853 var Processor$1$1 = /*#__PURE__*/ function() {
13854 function Processor(plugins) {
13855 if (plugins === void 0) plugins = [];
13856 this.version = "8.4.38";
13857 this.plugins = this.normalize(plugins);
13858 }
13859 var _proto = Processor.prototype;
13860 _proto.normalize = function normalize(plugins) {
13861 var normalized = [];
13862 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
13863 var i2 = _step.value;
13864 if (i2.postcss === true) {
13865 i2 = i2();
13866 } else if (i2.postcss) {
13867 i2 = i2.postcss;
13868 }
13869 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
13870 normalized = normalized.concat(i2.plugins);
13871 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
13872 normalized.push(i2);
13873 } else if (typeof i2 === "function") {
13874 normalized.push(i2);
13875 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
13876 if (true) {
13877 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.");
13878 }
13879 } else {
13880 throw new Error(i2 + " is not a PostCSS plugin");
13881 }
13882 }
13883 return normalized;
13884 };
13885 _proto.process = function process1(css, opts) {
13886 if (opts === void 0) opts = {};
13887 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
13888 return new NoWorkResult2$1(this, css, opts);
13889 } else {
13890 return new LazyResult$1$1(this, css, opts);
13891 }
13892 };
13893 _proto.use = function use(plugin22) {
13894 this.plugins = this.plugins.concat(this.normalize([
13895 plugin22
13896 ]));
13897 return this;
13898 };
13899 return Processor;
13900 }();
13901 var processor$1 = Processor$1$1;
13902 Processor$1$1.default = Processor$1$1;
13903 Root$2$1.registerProcessor(Processor$1$1);
13904 Document$1$1.registerProcessor(Processor$1$1);
13905 var Declaration$1$1 = declaration$1;
13906 var PreviousMap2$1 = previousMap$1;
13907 var Comment$1$1 = comment$1;
13908 var AtRule$1$1 = atRule$1;
13909 var Input$1$1 = input$1;
13910 var Root$1$1 = root$1;
13911 var Rule$1$1 = rule$1;
13912 function fromJSON$1$1(json, inputs) {
13913 if (Array.isArray(json)) return json.map(function(n2) {
13914 return fromJSON$1$1(n2);
13915 });
13916 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
13917 "inputs"
13918 ]);
13919 if (ownInputs) {
13920 inputs = [];
13921 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
13922 var input2 = _step.value;
13923 var inputHydrated = _extends({}, input2, {
13924 __proto__: Input$1$1.prototype
13925 });
13926 if (inputHydrated.map) {
13927 inputHydrated.map = _extends({}, inputHydrated.map, {
13928 __proto__: PreviousMap2$1.prototype
13929 });
13930 }
13931 inputs.push(inputHydrated);
13932 }
13933 }
13934 if (defaults.nodes) {
13935 defaults.nodes = json.nodes.map(function(n2) {
13936 return fromJSON$1$1(n2, inputs);
13937 });
13938 }
13939 if (defaults.source) {
13940 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
13941 "inputId"
13942 ]);
13943 defaults.source = source;
13944 if (inputId != null) {
13945 defaults.source.input = inputs[inputId];
13946 }
13947 }
13948 if (defaults.type === "root") {
13949 return new Root$1$1(defaults);
13950 } else if (defaults.type === "decl") {
13951 return new Declaration$1$1(defaults);
13952 } else if (defaults.type === "rule") {
13953 return new Rule$1$1(defaults);
13954 } else if (defaults.type === "comment") {
13955 return new Comment$1$1(defaults);
13956 } else if (defaults.type === "atrule") {
13957 return new AtRule$1$1(defaults);
13958 } else {
13959 throw new Error("Unknown node type: " + json.type);
13960 }
13961 }
13962 var fromJSON_1$1 = fromJSON$1$1;
13963 fromJSON$1$1.default = fromJSON$1$1;
13964 var CssSyntaxError2$1 = cssSyntaxError$1;
13965 var Declaration2$1 = declaration$1;
13966 var LazyResult2$1 = lazyResult$1;
13967 var Container2$1 = container$1;
13968 var Processor2$1 = processor$1;
13969 var stringify$5 = stringify_1$1;
13970 var fromJSON$2 = fromJSON_1$1;
13971 var Document22 = document$1$1;
13972 var Warning2$1 = warning$1;
13973 var Comment2$1 = comment$1;
13974 var AtRule2$1 = atRule$1;
13975 var Result2$1 = result$1;
13976 var Input2$1 = input$1;
13977 var parse$5 = parse_1$1;
13978 var list$3 = list_1$1;
13979 var Rule2$1 = rule$1;
13980 var Root2$1 = root$1;
13981 var Node2$1 = node$1;
13982 function postcss$3() {
13983 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
13984 plugins[_key] = arguments[_key];
13985 }
13986 if (plugins.length === 1 && Array.isArray(plugins[0])) {
13987 plugins = plugins[0];
13988 }
13989 return new Processor2$1(plugins);
13990 }
13991 postcss$3.plugin = function plugin(name, initializer) {
13992 var warningPrinted = false;
13993 function creator() {
13994 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
13995 args[_key] = arguments[_key];
13996 }
13997 if (console && console.warn && !warningPrinted) {
13998 warningPrinted = true;
13999 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
14000 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
14001 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
14002 }
14003 }
14004 var transformer = initializer.apply(void 0, [].concat(args));
14005 transformer.postcssPlugin = name;
14006 transformer.postcssVersion = new Processor2$1().version;
14007 return transformer;
14008 }
14009 var cache;
14010 Object.defineProperty(creator, "postcss", {
14011 get: function get() {
14012 if (!cache) cache = creator();
14013 return cache;
14014 }
14015 });
14016 creator.process = function(css, processOpts, pluginOpts) {
14017 return postcss$3([
14018 creator(pluginOpts)
14019 ]).process(css, processOpts);
14020 };
14021 return creator;
14022 };
14023 postcss$3.stringify = stringify$5;
14024 postcss$3.parse = parse$5;
14025 postcss$3.fromJSON = fromJSON$2;
14026 postcss$3.list = list$3;
14027 postcss$3.comment = function(defaults) {
14028 return new Comment2$1(defaults);
14029 };
14030 postcss$3.atRule = function(defaults) {
14031 return new AtRule2$1(defaults);
14032 };
14033 postcss$3.decl = function(defaults) {
14034 return new Declaration2$1(defaults);
14035 };
14036 postcss$3.rule = function(defaults) {
14037 return new Rule2$1(defaults);
14038 };
14039 postcss$3.root = function(defaults) {
14040 return new Root2$1(defaults);
14041 };
14042 postcss$3.document = function(defaults) {
14043 return new Document22(defaults);
14044 };
14045 postcss$3.CssSyntaxError = CssSyntaxError2$1;
14046 postcss$3.Declaration = Declaration2$1;
14047 postcss$3.Container = Container2$1;
14048 postcss$3.Processor = Processor2$1;
14049 postcss$3.Document = Document22;
14050 postcss$3.Comment = Comment2$1;
14051 postcss$3.Warning = Warning2$1;
14052 postcss$3.AtRule = AtRule2$1;
14053 postcss$3.Result = Result2$1;
14054 postcss$3.Input = Input2$1;
14055 postcss$3.Rule = Rule2$1;
14056 postcss$3.Root = Root2$1;
14057 postcss$3.Node = Node2$1;
14058 LazyResult2$1.registerPostcss(postcss$3);
14059 var postcss_1$1 = postcss$3;
14060 postcss$3.default = postcss$3;
14061 var postcss$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(postcss_1$1);
14062 postcss$1$1.stringify;
14063 postcss$1$1.fromJSON;
14064 postcss$1$1.plugin;
14065 postcss$1$1.parse;
14066 postcss$1$1.list;
14067 postcss$1$1.document;
14068 postcss$1$1.comment;
14069 postcss$1$1.atRule;
14070 postcss$1$1.rule;
14071 postcss$1$1.decl;
14072 postcss$1$1.root;
14073 postcss$1$1.CssSyntaxError;
14074 postcss$1$1.Declaration;
14075 postcss$1$1.Container;
14076 postcss$1$1.Processor;
14077 postcss$1$1.Document;
14078 postcss$1$1.Comment;
14079 postcss$1$1.Warning;
14080 postcss$1$1.AtRule;
14081 postcss$1$1.Result;
14082 postcss$1$1.Input;
14083 postcss$1$1.Rule;
14084 postcss$1$1.Root;
14085 postcss$1$1.Node;
14086 var __defProp2 = Object.defineProperty;
14087 var __defNormalProp2 = function(obj, key, value) {
14088 return key in obj ? __defProp2(obj, key, {
14089 enumerable: true,
14090 configurable: true,
14091 writable: true,
14092 value: value
14093 }) : obj[key] = value;
14094 };
14095 var __publicField2 = function(obj, key, value) {
14096 return __defNormalProp2(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
14097 };
14098 function getDefaultExportFromCjs(x2) {
14099 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
14100 }
14101 function getAugmentedNamespace(n2) {
14102 if (n2.__esModule) return n2;
14103 var f2 = n2.default;
14104 if (typeof f2 == "function") {
14105 var a2 = function a22() {
14106 if (_instanceof(this, a22)) {
14107 return Reflect.construct(f2, arguments, this.constructor);
14108 }
14109 return f2.apply(this, arguments);
14110 };
14111 a2.prototype = f2.prototype;
14112 } else a2 = {};
14113 Object.defineProperty(a2, "__esModule", {
14114 value: true
14115 });
14116 Object.keys(n2).forEach(function(k) {
14117 var d = Object.getOwnPropertyDescriptor(n2, k);
14118 Object.defineProperty(a2, k, d.get ? d : {
14119 enumerable: true,
14120 get: function get() {
14121 return n2[k];
14122 }
14123 });
14124 });
14125 return a2;
14126 }
14127 var picocolors_browser = {
14128 exports: {}
14129 };
14130 var x = String;
14131 var create = function create() {
14132 return {
14133 isColorSupported: false,
14134 reset: x,
14135 bold: x,
14136 dim: x,
14137 italic: x,
14138 underline: x,
14139 inverse: x,
14140 hidden: x,
14141 strikethrough: x,
14142 black: x,
14143 red: x,
14144 green: x,
14145 yellow: x,
14146 blue: x,
14147 magenta: x,
14148 cyan: x,
14149 white: x,
14150 gray: x,
14151 bgBlack: x,
14152 bgRed: x,
14153 bgGreen: x,
14154 bgYellow: x,
14155 bgBlue: x,
14156 bgMagenta: x,
14157 bgCyan: x,
14158 bgWhite: x
14159 };
14160 };
14161 picocolors_browser.exports = create();
14162 picocolors_browser.exports.createColors = create;
14163 var picocolors_browserExports = picocolors_browser.exports;
14164 var __viteBrowserExternal = {};
14165 var __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
14166 __proto__: null,
14167 default: __viteBrowserExternal
14168 }, Symbol.toStringTag, {
14169 value: "Module"
14170 }));
14171 var require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
14172 var pico = picocolors_browserExports;
14173 var terminalHighlight$1 = require$$2;
14174 var CssSyntaxError$3 = /*#__PURE__*/ function(Error1) {
14175 _inherits(CssSyntaxError2, Error1);
14176 function CssSyntaxError2(message, line, column, source, file, plugin22) {
14177 var _this;
14178 _this = Error1.call(this, message) || this;
14179 _this.name = "CssSyntaxError";
14180 _this.reason = message;
14181 if (file) {
14182 _this.file = file;
14183 }
14184 if (source) {
14185 _this.source = source;
14186 }
14187 if (plugin22) {
14188 _this.plugin = plugin22;
14189 }
14190 if (typeof line !== "undefined" && typeof column !== "undefined") {
14191 if (typeof line === "number") {
14192 _this.line = line;
14193 _this.column = column;
14194 } else {
14195 _this.line = line.line;
14196 _this.column = line.column;
14197 _this.endLine = column.line;
14198 _this.endColumn = column.column;
14199 }
14200 }
14201 _this.setMessage();
14202 if (Error.captureStackTrace) {
14203 Error.captureStackTrace(_this, CssSyntaxError2);
14204 }
14205 return _this;
14206 }
14207 var _proto = CssSyntaxError2.prototype;
14208 _proto.setMessage = function setMessage() {
14209 this.message = this.plugin ? this.plugin + ": " : "";
14210 this.message += this.file ? this.file : "<css input>";
14211 if (typeof this.line !== "undefined") {
14212 this.message += ":" + this.line + ":" + this.column;
14213 }
14214 this.message += ": " + this.reason;
14215 };
14216 _proto.showSourceCode = function showSourceCode(color) {
14217 var _this = this;
14218 if (!this.source) return "";
14219 var css = this.source;
14220 if (color == null) color = pico.isColorSupported;
14221 if (terminalHighlight$1) {
14222 if (color) css = terminalHighlight$1(css);
14223 }
14224 var lines = css.split(/\r?\n/);
14225 var start = Math.max(this.line - 3, 0);
14226 var end = Math.min(this.line + 2, lines.length);
14227 var maxWidth = String(end).length;
14228 var mark, aside;
14229 if (color) {
14230 var _pico_createColors = pico.createColors(true), bold = _pico_createColors.bold, gray = _pico_createColors.gray, red = _pico_createColors.red;
14231 mark = function(text) {
14232 return bold(red(text));
14233 };
14234 aside = function(text) {
14235 return gray(text);
14236 };
14237 } else {
14238 mark = aside = function(str) {
14239 return str;
14240 };
14241 }
14242 return lines.slice(start, end).map(function(line, index2) {
14243 var number = start + 1 + index2;
14244 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
14245 if (number === _this.line) {
14246 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
14247 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
14248 }
14249 return " " + aside(gutter) + line;
14250 }).join("\n");
14251 };
14252 _proto.toString = function toString() {
14253 var code = this.showSourceCode();
14254 if (code) {
14255 code = "\n\n" + code + "\n";
14256 }
14257 return this.name + ": " + this.message + code;
14258 };
14259 return CssSyntaxError2;
14260 }(_wrap_native_super(Error));
14261 var cssSyntaxError = CssSyntaxError$3;
14262 CssSyntaxError$3.default = CssSyntaxError$3;
14263 var symbols = {};
14264 symbols.isClean = Symbol("isClean");
14265 symbols.my = Symbol("my");
14266 var DEFAULT_RAW = {
14267 after: "\n",
14268 beforeClose: "\n",
14269 beforeComment: "\n",
14270 beforeDecl: "\n",
14271 beforeOpen: " ",
14272 beforeRule: "\n",
14273 colon: ": ",
14274 commentLeft: " ",
14275 commentRight: " ",
14276 emptyBody: "",
14277 indent: " ",
14278 semicolon: false
14279 };
14280 function capitalize(str) {
14281 return str[0].toUpperCase() + str.slice(1);
14282 }
14283 var Stringifier$2 = /*#__PURE__*/ function() {
14284 function Stringifier2(builder) {
14285 this.builder = builder;
14286 }
14287 var _proto = Stringifier2.prototype;
14288 _proto.atrule = function atrule(node2, semicolon) {
14289 var name = "@" + node2.name;
14290 var params = node2.params ? this.rawValue(node2, "params") : "";
14291 if (typeof node2.raws.afterName !== "undefined") {
14292 name += node2.raws.afterName;
14293 } else if (params) {
14294 name += " ";
14295 }
14296 if (node2.nodes) {
14297 this.block(node2, name + params);
14298 } else {
14299 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
14300 this.builder(name + params + end, node2);
14301 }
14302 };
14303 _proto.beforeAfter = function beforeAfter(node2, detect) {
14304 var value;
14305 if (node2.type === "decl") {
14306 value = this.raw(node2, null, "beforeDecl");
14307 } else if (node2.type === "comment") {
14308 value = this.raw(node2, null, "beforeComment");
14309 } else if (detect === "before") {
14310 value = this.raw(node2, null, "beforeRule");
14311 } else {
14312 value = this.raw(node2, null, "beforeClose");
14313 }
14314 var buf = node2.parent;
14315 var depth = 0;
14316 while(buf && buf.type !== "root"){
14317 depth += 1;
14318 buf = buf.parent;
14319 }
14320 if (value.includes("\n")) {
14321 var indent = this.raw(node2, null, "indent");
14322 if (indent.length) {
14323 for(var step = 0; step < depth; step++)value += indent;
14324 }
14325 }
14326 return value;
14327 };
14328 _proto.block = function block(node2, start) {
14329 var between = this.raw(node2, "between", "beforeOpen");
14330 this.builder(start + between + "{", node2, "start");
14331 var after;
14332 if (node2.nodes && node2.nodes.length) {
14333 this.body(node2);
14334 after = this.raw(node2, "after");
14335 } else {
14336 after = this.raw(node2, "after", "emptyBody");
14337 }
14338 if (after) this.builder(after);
14339 this.builder("}", node2, "end");
14340 };
14341 _proto.body = function body(node2) {
14342 var last = node2.nodes.length - 1;
14343 while(last > 0){
14344 if (node2.nodes[last].type !== "comment") break;
14345 last -= 1;
14346 }
14347 var semicolon = this.raw(node2, "semicolon");
14348 for(var i2 = 0; i2 < node2.nodes.length; i2++){
14349 var child = node2.nodes[i2];
14350 var before = this.raw(child, "before");
14351 if (before) this.builder(before);
14352 this.stringify(child, last !== i2 || semicolon);
14353 }
14354 };
14355 _proto.comment = function comment(node2) {
14356 var left = this.raw(node2, "left", "commentLeft");
14357 var right = this.raw(node2, "right", "commentRight");
14358 this.builder("/*" + left + node2.text + right + "*/", node2);
14359 };
14360 _proto.decl = function decl(node2, semicolon) {
14361 var between = this.raw(node2, "between", "colon");
14362 var string = node2.prop + between + this.rawValue(node2, "value");
14363 if (node2.important) {
14364 string += node2.raws.important || " !important";
14365 }
14366 if (semicolon) string += ";";
14367 this.builder(string, node2);
14368 };
14369 _proto.document = function document1(node2) {
14370 this.body(node2);
14371 };
14372 _proto.raw = function raw(node2, own, detect) {
14373 var value;
14374 if (!detect) detect = own;
14375 if (own) {
14376 value = node2.raws[own];
14377 if (typeof value !== "undefined") return value;
14378 }
14379 var parent = node2.parent;
14380 if (detect === "before") {
14381 if (!parent || parent.type === "root" && parent.first === node2) {
14382 return "";
14383 }
14384 if (parent && parent.type === "document") {
14385 return "";
14386 }
14387 }
14388 if (!parent) return DEFAULT_RAW[detect];
14389 var root2 = node2.root();
14390 if (!root2.rawCache) root2.rawCache = {};
14391 if (typeof root2.rawCache[detect] !== "undefined") {
14392 return root2.rawCache[detect];
14393 }
14394 if (detect === "before" || detect === "after") {
14395 return this.beforeAfter(node2, detect);
14396 } else {
14397 var method = "raw" + capitalize(detect);
14398 if (this[method]) {
14399 value = this[method](root2, node2);
14400 } else {
14401 root2.walk(function(i2) {
14402 value = i2.raws[own];
14403 if (typeof value !== "undefined") return false;
14404 });
14405 }
14406 }
14407 if (typeof value === "undefined") value = DEFAULT_RAW[detect];
14408 root2.rawCache[detect] = value;
14409 return value;
14410 };
14411 _proto.rawBeforeClose = function rawBeforeClose(root2) {
14412 var value;
14413 root2.walk(function(i2) {
14414 if (i2.nodes && i2.nodes.length > 0) {
14415 if (typeof i2.raws.after !== "undefined") {
14416 value = i2.raws.after;
14417 if (value.includes("\n")) {
14418 value = value.replace(/[^\n]+$/, "");
14419 }
14420 return false;
14421 }
14422 }
14423 });
14424 if (value) value = value.replace(/\S/g, "");
14425 return value;
14426 };
14427 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
14428 var value;
14429 root2.walkComments(function(i2) {
14430 if (typeof i2.raws.before !== "undefined") {
14431 value = i2.raws.before;
14432 if (value.includes("\n")) {
14433 value = value.replace(/[^\n]+$/, "");
14434 }
14435 return false;
14436 }
14437 });
14438 if (typeof value === "undefined") {
14439 value = this.raw(node2, null, "beforeDecl");
14440 } else if (value) {
14441 value = value.replace(/\S/g, "");
14442 }
14443 return value;
14444 };
14445 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
14446 var value;
14447 root2.walkDecls(function(i2) {
14448 if (typeof i2.raws.before !== "undefined") {
14449 value = i2.raws.before;
14450 if (value.includes("\n")) {
14451 value = value.replace(/[^\n]+$/, "");
14452 }
14453 return false;
14454 }
14455 });
14456 if (typeof value === "undefined") {
14457 value = this.raw(node2, null, "beforeRule");
14458 } else if (value) {
14459 value = value.replace(/\S/g, "");
14460 }
14461 return value;
14462 };
14463 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
14464 var value;
14465 root2.walk(function(i2) {
14466 if (i2.type !== "decl") {
14467 value = i2.raws.between;
14468 if (typeof value !== "undefined") return false;
14469 }
14470 });
14471 return value;
14472 };
14473 _proto.rawBeforeRule = function rawBeforeRule(root2) {
14474 var value;
14475 root2.walk(function(i2) {
14476 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
14477 if (typeof i2.raws.before !== "undefined") {
14478 value = i2.raws.before;
14479 if (value.includes("\n")) {
14480 value = value.replace(/[^\n]+$/, "");
14481 }
14482 return false;
14483 }
14484 }
14485 });
14486 if (value) value = value.replace(/\S/g, "");
14487 return value;
14488 };
14489 _proto.rawColon = function rawColon(root2) {
14490 var value;
14491 root2.walkDecls(function(i2) {
14492 if (typeof i2.raws.between !== "undefined") {
14493 value = i2.raws.between.replace(/[^\s:]/g, "");
14494 return false;
14495 }
14496 });
14497 return value;
14498 };
14499 _proto.rawEmptyBody = function rawEmptyBody(root2) {
14500 var value;
14501 root2.walk(function(i2) {
14502 if (i2.nodes && i2.nodes.length === 0) {
14503 value = i2.raws.after;
14504 if (typeof value !== "undefined") return false;
14505 }
14506 });
14507 return value;
14508 };
14509 _proto.rawIndent = function rawIndent(root2) {
14510 if (root2.raws.indent) return root2.raws.indent;
14511 var value;
14512 root2.walk(function(i2) {
14513 var p = i2.parent;
14514 if (p && p !== root2 && p.parent && p.parent === root2) {
14515 if (typeof i2.raws.before !== "undefined") {
14516 var parts = i2.raws.before.split("\n");
14517 value = parts[parts.length - 1];
14518 value = value.replace(/\S/g, "");
14519 return false;
14520 }
14521 }
14522 });
14523 return value;
14524 };
14525 _proto.rawSemicolon = function rawSemicolon(root2) {
14526 var value;
14527 root2.walk(function(i2) {
14528 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
14529 value = i2.raws.semicolon;
14530 if (typeof value !== "undefined") return false;
14531 }
14532 });
14533 return value;
14534 };
14535 _proto.rawValue = function rawValue(node2, prop) {
14536 var value = node2[prop];
14537 var raw = node2.raws[prop];
14538 if (raw && raw.value === value) {
14539 return raw.raw;
14540 }
14541 return value;
14542 };
14543 _proto.root = function root(node2) {
14544 this.body(node2);
14545 if (node2.raws.after) this.builder(node2.raws.after);
14546 };
14547 _proto.rule = function rule(node2) {
14548 this.block(node2, this.rawValue(node2, "selector"));
14549 if (node2.raws.ownSemicolon) {
14550 this.builder(node2.raws.ownSemicolon, node2, "end");
14551 }
14552 };
14553 _proto.stringify = function stringify(node2, semicolon) {
14554 if (!this[node2.type]) {
14555 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
14556 }
14557 this[node2.type](node2, semicolon);
14558 };
14559 return Stringifier2;
14560 }();
14561 var stringifier = Stringifier$2;
14562 Stringifier$2.default = Stringifier$2;
14563 var Stringifier$1 = stringifier;
14564 function stringify$4(node2, builder) {
14565 var str = new Stringifier$1(builder);
14566 str.stringify(node2);
14567 }
14568 var stringify_1 = stringify$4;
14569 stringify$4.default = stringify$4;
14570 var isClean$2 = symbols.isClean, my$2 = symbols.my;
14571 var CssSyntaxError$2 = cssSyntaxError;
14572 var Stringifier22 = stringifier;
14573 var stringify$3 = stringify_1;
14574 function cloneNode(obj, parent) {
14575 var cloned = new obj.constructor();
14576 for(var i2 in obj){
14577 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
14578 continue;
14579 }
14580 if (i2 === "proxyCache") continue;
14581 var value = obj[i2];
14582 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
14583 if (i2 === "parent" && type === "object") {
14584 if (parent) cloned[i2] = parent;
14585 } else if (i2 === "source") {
14586 cloned[i2] = value;
14587 } else if (Array.isArray(value)) {
14588 cloned[i2] = value.map(function(j) {
14589 return cloneNode(j, cloned);
14590 });
14591 } else {
14592 if (type === "object" && value !== null) value = cloneNode(value);
14593 cloned[i2] = value;
14594 }
14595 }
14596 return cloned;
14597 }
14598 var Node$4 = /*#__PURE__*/ function() {
14599 function Node3(defaults) {
14600 if (defaults === void 0) defaults = {};
14601 this.raws = {};
14602 this[isClean$2] = false;
14603 this[my$2] = true;
14604 for(var name in defaults){
14605 if (name === "nodes") {
14606 this.nodes = [];
14607 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
14608 var node2 = _step.value;
14609 if (typeof node2.clone === "function") {
14610 this.append(node2.clone());
14611 } else {
14612 this.append(node2);
14613 }
14614 }
14615 } else {
14616 this[name] = defaults[name];
14617 }
14618 }
14619 }
14620 var _proto = Node3.prototype;
14621 _proto.addToError = function addToError(error) {
14622 error.postcssNode = this;
14623 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
14624 var s2 = this.source;
14625 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
14626 }
14627 return error;
14628 };
14629 _proto.after = function after(add) {
14630 this.parent.insertAfter(this, add);
14631 return this;
14632 };
14633 _proto.assign = function assign(overrides) {
14634 if (overrides === void 0) overrides = {};
14635 for(var name in overrides){
14636 this[name] = overrides[name];
14637 }
14638 return this;
14639 };
14640 _proto.before = function before(add) {
14641 this.parent.insertBefore(this, add);
14642 return this;
14643 };
14644 _proto.cleanRaws = function cleanRaws(keepBetween) {
14645 delete this.raws.before;
14646 delete this.raws.after;
14647 if (!keepBetween) delete this.raws.between;
14648 };
14649 _proto.clone = function clone(overrides) {
14650 if (overrides === void 0) overrides = {};
14651 var cloned = cloneNode(this);
14652 for(var name in overrides){
14653 cloned[name] = overrides[name];
14654 }
14655 return cloned;
14656 };
14657 _proto.cloneAfter = function cloneAfter(overrides) {
14658 if (overrides === void 0) overrides = {};
14659 var cloned = this.clone(overrides);
14660 this.parent.insertAfter(this, cloned);
14661 return cloned;
14662 };
14663 _proto.cloneBefore = function cloneBefore(overrides) {
14664 if (overrides === void 0) overrides = {};
14665 var cloned = this.clone(overrides);
14666 this.parent.insertBefore(this, cloned);
14667 return cloned;
14668 };
14669 _proto.error = function error(message, opts) {
14670 if (opts === void 0) opts = {};
14671 if (this.source) {
14672 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
14673 return this.source.input.error(message, {
14674 column: start.column,
14675 line: start.line
14676 }, {
14677 column: end.column,
14678 line: end.line
14679 }, opts);
14680 }
14681 return new CssSyntaxError$2(message);
14682 };
14683 _proto.getProxyProcessor = function getProxyProcessor() {
14684 return {
14685 get: function get(node2, prop) {
14686 if (prop === "proxyOf") {
14687 return node2;
14688 } else if (prop === "root") {
14689 return function() {
14690 return node2.root().toProxy();
14691 };
14692 } else {
14693 return node2[prop];
14694 }
14695 },
14696 set: function set(node2, prop, value) {
14697 if (node2[prop] === value) return true;
14698 node2[prop] = value;
14699 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
14700 node2.markDirty();
14701 }
14702 return true;
14703 }
14704 };
14705 };
14706 _proto.markDirty = function markDirty() {
14707 if (this[isClean$2]) {
14708 this[isClean$2] = false;
14709 var next = this;
14710 while(next = next.parent){
14711 next[isClean$2] = false;
14712 }
14713 }
14714 };
14715 _proto.next = function next() {
14716 if (!this.parent) return void 0;
14717 var index2 = this.parent.index(this);
14718 return this.parent.nodes[index2 + 1];
14719 };
14720 _proto.positionBy = function positionBy(opts, stringRepresentation) {
14721 var pos = this.source.start;
14722 if (opts.index) {
14723 pos = this.positionInside(opts.index, stringRepresentation);
14724 } else if (opts.word) {
14725 stringRepresentation = this.toString();
14726 var index2 = stringRepresentation.indexOf(opts.word);
14727 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
14728 }
14729 return pos;
14730 };
14731 _proto.positionInside = function positionInside(index2, stringRepresentation) {
14732 var string = stringRepresentation || this.toString();
14733 var column = this.source.start.column;
14734 var line = this.source.start.line;
14735 for(var i2 = 0; i2 < index2; i2++){
14736 if (string[i2] === "\n") {
14737 column = 1;
14738 line += 1;
14739 } else {
14740 column += 1;
14741 }
14742 }
14743 return {
14744 column: column,
14745 line: line
14746 };
14747 };
14748 _proto.prev = function prev() {
14749 if (!this.parent) return void 0;
14750 var index2 = this.parent.index(this);
14751 return this.parent.nodes[index2 - 1];
14752 };
14753 _proto.rangeBy = function rangeBy(opts) {
14754 var start = {
14755 column: this.source.start.column,
14756 line: this.source.start.line
14757 };
14758 var end = this.source.end ? {
14759 column: this.source.end.column + 1,
14760 line: this.source.end.line
14761 } : {
14762 column: start.column + 1,
14763 line: start.line
14764 };
14765 if (opts.word) {
14766 var stringRepresentation = this.toString();
14767 var index2 = stringRepresentation.indexOf(opts.word);
14768 if (index2 !== -1) {
14769 start = this.positionInside(index2, stringRepresentation);
14770 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
14771 }
14772 } else {
14773 if (opts.start) {
14774 start = {
14775 column: opts.start.column,
14776 line: opts.start.line
14777 };
14778 } else if (opts.index) {
14779 start = this.positionInside(opts.index);
14780 }
14781 if (opts.end) {
14782 end = {
14783 column: opts.end.column,
14784 line: opts.end.line
14785 };
14786 } else if (typeof opts.endIndex === "number") {
14787 end = this.positionInside(opts.endIndex);
14788 } else if (opts.index) {
14789 end = this.positionInside(opts.index + 1);
14790 }
14791 }
14792 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
14793 end = {
14794 column: start.column + 1,
14795 line: start.line
14796 };
14797 }
14798 return {
14799 end: end,
14800 start: start
14801 };
14802 };
14803 _proto.raw = function raw(prop, defaultType) {
14804 var str = new Stringifier22();
14805 return str.raw(this, prop, defaultType);
14806 };
14807 _proto.remove = function remove() {
14808 if (this.parent) {
14809 this.parent.removeChild(this);
14810 }
14811 this.parent = void 0;
14812 return this;
14813 };
14814 _proto.replaceWith = function replaceWith() {
14815 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
14816 nodes[_key] = arguments[_key];
14817 }
14818 if (this.parent) {
14819 var bookmark = this;
14820 var foundSelf = false;
14821 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
14822 var node2 = _step.value;
14823 if (node2 === this) {
14824 foundSelf = true;
14825 } else if (foundSelf) {
14826 this.parent.insertAfter(bookmark, node2);
14827 bookmark = node2;
14828 } else {
14829 this.parent.insertBefore(bookmark, node2);
14830 }
14831 }
14832 if (!foundSelf) {
14833 this.remove();
14834 }
14835 }
14836 return this;
14837 };
14838 _proto.root = function root() {
14839 var result2 = this;
14840 while(result2.parent && result2.parent.type !== "document"){
14841 result2 = result2.parent;
14842 }
14843 return result2;
14844 };
14845 _proto.toJSON = function toJSON(_, inputs) {
14846 var fixed = {};
14847 var emitInputs = inputs == null;
14848 inputs = inputs || /* @__PURE__ */ new Map();
14849 var inputsNextIndex = 0;
14850 for(var name in this){
14851 if (!Object.prototype.hasOwnProperty.call(this, name)) {
14852 continue;
14853 }
14854 if (name === "parent" || name === "proxyCache") continue;
14855 var value = this[name];
14856 if (Array.isArray(value)) {
14857 fixed[name] = value.map(function(i2) {
14858 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
14859 return i2.toJSON(null, inputs);
14860 } else {
14861 return i2;
14862 }
14863 });
14864 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
14865 fixed[name] = value.toJSON(null, inputs);
14866 } else if (name === "source") {
14867 var inputId = inputs.get(value.input);
14868 if (inputId == null) {
14869 inputId = inputsNextIndex;
14870 inputs.set(value.input, inputsNextIndex);
14871 inputsNextIndex++;
14872 }
14873 fixed[name] = {
14874 end: value.end,
14875 inputId: inputId,
14876 start: value.start
14877 };
14878 } else {
14879 fixed[name] = value;
14880 }
14881 }
14882 if (emitInputs) {
14883 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
14884 return input2.toJSON();
14885 });
14886 }
14887 return fixed;
14888 };
14889 _proto.toProxy = function toProxy() {
14890 if (!this.proxyCache) {
14891 this.proxyCache = new Proxy(this, this.getProxyProcessor());
14892 }
14893 return this.proxyCache;
14894 };
14895 _proto.toString = function toString(stringifier2) {
14896 if (stringifier2 === void 0) stringifier2 = stringify$3;
14897 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
14898 var result2 = "";
14899 stringifier2(this, function(i2) {
14900 result2 += i2;
14901 });
14902 return result2;
14903 };
14904 _proto.warn = function warn(result2, text, opts) {
14905 var data = {
14906 node: this
14907 };
14908 for(var i2 in opts)data[i2] = opts[i2];
14909 return result2.warn(text, data);
14910 };
14911 _create_class(Node3, [
14912 {
14913 key: "proxyOf",
14914 get: function get() {
14915 return this;
14916 }
14917 }
14918 ]);
14919 return Node3;
14920 }();
14921 var node = Node$4;
14922 Node$4.default = Node$4;
14923 var Node$3 = node;
14924 var Declaration$4 = /*#__PURE__*/ function(Node$3) {
14925 _inherits(Declaration2, Node$3);
14926 function Declaration2(defaults) {
14927 var _this;
14928 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
14929 defaults = _extends({}, defaults, {
14930 value: String(defaults.value)
14931 });
14932 }
14933 _this = Node$3.call(this, defaults) || this;
14934 _this.type = "decl";
14935 return _this;
14936 }
14937 _create_class(Declaration2, [
14938 {
14939 key: "variable",
14940 get: function get() {
14941 return this.prop.startsWith("--") || this.prop[0] === "$";
14942 }
14943 }
14944 ]);
14945 return Declaration2;
14946 }(Node$3);
14947 var declaration = Declaration$4;
14948 Declaration$4.default = Declaration$4;
14949 var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
14950 var nanoid$1 = function(size) {
14951 if (size === void 0) size = 21;
14952 var id = "";
14953 var i2 = size;
14954 while(i2--){
14955 id += urlAlphabet[Math.random() * 64 | 0];
14956 }
14957 return id;
14958 };
14959 var nonSecure = {
14960 nanoid: nanoid$1};
14961 var SourceMapConsumer$2 = require$$2.SourceMapConsumer, SourceMapGenerator$2 = require$$2.SourceMapGenerator;
14962 var existsSync = require$$2.existsSync, readFileSync = require$$2.readFileSync;
14963 var dirname$1 = require$$2.dirname, join = require$$2.join;
14964 function fromBase64(str) {
14965 if (Buffer) {
14966 return Buffer.from(str, "base64").toString();
14967 } else {
14968 return window.atob(str);
14969 }
14970 }
14971 var PreviousMap$2 = /*#__PURE__*/ function() {
14972 function PreviousMap2(css, opts) {
14973 if (opts.map === false) return;
14974 this.loadAnnotation(css);
14975 this.inline = this.startWith(this.annotation, "data:");
14976 var prev = opts.map ? opts.map.prev : void 0;
14977 var text = this.loadMap(opts.from, prev);
14978 if (!this.mapFile && opts.from) {
14979 this.mapFile = opts.from;
14980 }
14981 if (this.mapFile) this.root = dirname$1(this.mapFile);
14982 if (text) this.text = text;
14983 }
14984 var _proto = PreviousMap2.prototype;
14985 _proto.consumer = function consumer() {
14986 if (!this.consumerCache) {
14987 this.consumerCache = new SourceMapConsumer$2(this.text);
14988 }
14989 return this.consumerCache;
14990 };
14991 _proto.decodeInline = function decodeInline(text) {
14992 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
14993 var baseUri = /^data:application\/json;base64,/;
14994 var charsetUri = /^data:application\/json;charset=utf-?8,/;
14995 var uri = /^data:application\/json,/;
14996 if (charsetUri.test(text) || uri.test(text)) {
14997 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
14998 }
14999 if (baseCharsetUri.test(text) || baseUri.test(text)) {
15000 return fromBase64(text.substr(RegExp.lastMatch.length));
15001 }
15002 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
15003 throw new Error("Unsupported source map encoding " + encoding);
15004 };
15005 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
15006 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
15007 };
15008 _proto.isMap = function isMap(map) {
15009 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
15010 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
15011 };
15012 _proto.loadAnnotation = function loadAnnotation(css) {
15013 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
15014 if (!comments) return;
15015 var start = css.lastIndexOf(comments.pop());
15016 var end = css.indexOf("*/", start);
15017 if (start > -1 && end > -1) {
15018 this.annotation = this.getAnnotationURL(css.substring(start, end));
15019 }
15020 };
15021 _proto.loadFile = function loadFile(path) {
15022 this.root = dirname$1(path);
15023 if (existsSync(path)) {
15024 this.mapFile = path;
15025 return readFileSync(path, "utf-8").toString().trim();
15026 }
15027 };
15028 _proto.loadMap = function loadMap(file, prev) {
15029 if (prev === false) return false;
15030 if (prev) {
15031 if (typeof prev === "string") {
15032 return prev;
15033 } else if (typeof prev === "function") {
15034 var prevPath = prev(file);
15035 if (prevPath) {
15036 var map = this.loadFile(prevPath);
15037 if (!map) {
15038 throw new Error("Unable to load previous source map: " + prevPath.toString());
15039 }
15040 return map;
15041 }
15042 } else if (_instanceof(prev, SourceMapConsumer$2)) {
15043 return SourceMapGenerator$2.fromSourceMap(prev).toString();
15044 } else if (_instanceof(prev, SourceMapGenerator$2)) {
15045 return prev.toString();
15046 } else if (this.isMap(prev)) {
15047 return JSON.stringify(prev);
15048 } else {
15049 throw new Error("Unsupported previous source map format: " + prev.toString());
15050 }
15051 } else if (this.inline) {
15052 return this.decodeInline(this.annotation);
15053 } else if (this.annotation) {
15054 var map1 = this.annotation;
15055 if (file) map1 = join(dirname$1(file), map1);
15056 return this.loadFile(map1);
15057 }
15058 };
15059 _proto.startWith = function startWith(string, start) {
15060 if (!string) return false;
15061 return string.substr(0, start.length) === start;
15062 };
15063 _proto.withContent = function withContent() {
15064 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
15065 };
15066 return PreviousMap2;
15067 }();
15068 var previousMap = PreviousMap$2;
15069 PreviousMap$2.default = PreviousMap$2;
15070 var SourceMapConsumer$1 = require$$2.SourceMapConsumer, SourceMapGenerator$1 = require$$2.SourceMapGenerator;
15071 var fileURLToPath = require$$2.fileURLToPath, pathToFileURL$1 = require$$2.pathToFileURL;
15072 var isAbsolute = require$$2.isAbsolute, resolve$1 = require$$2.resolve;
15073 var nanoid = nonSecure.nanoid;
15074 var terminalHighlight = require$$2;
15075 var CssSyntaxError$1 = cssSyntaxError;
15076 var PreviousMap$1 = previousMap;
15077 var fromOffsetCache = Symbol("fromOffsetCache");
15078 var sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
15079 var pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
15080 var Input$4 = /*#__PURE__*/ function() {
15081 function Input2(css, opts) {
15082 if (opts === void 0) opts = {};
15083 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
15084 throw new Error("PostCSS received " + css + " instead of CSS string");
15085 }
15086 this.css = css.toString();
15087 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
15088 this.hasBOM = true;
15089 this.css = this.css.slice(1);
15090 } else {
15091 this.hasBOM = false;
15092 }
15093 if (opts.from) {
15094 if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
15095 this.file = opts.from;
15096 } else {
15097 this.file = resolve$1(opts.from);
15098 }
15099 }
15100 if (pathAvailable$1 && sourceMapAvailable$1) {
15101 var map = new PreviousMap$1(this.css, opts);
15102 if (map.text) {
15103 this.map = map;
15104 var file = map.consumer().file;
15105 if (!this.file && file) this.file = this.mapResolve(file);
15106 }
15107 }
15108 if (!this.file) {
15109 this.id = "<input css " + nanoid(6) + ">";
15110 }
15111 if (this.map) this.map.file = this.from;
15112 }
15113 var _proto = Input2.prototype;
15114 _proto.error = function error(message, line, column, opts) {
15115 if (opts === void 0) opts = {};
15116 var result2, endLine, endColumn;
15117 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
15118 var start = line;
15119 var end = column;
15120 if (typeof start.offset === "number") {
15121 var pos = this.fromOffset(start.offset);
15122 line = pos.line;
15123 column = pos.col;
15124 } else {
15125 line = start.line;
15126 column = start.column;
15127 }
15128 if (typeof end.offset === "number") {
15129 var pos1 = this.fromOffset(end.offset);
15130 endLine = pos1.line;
15131 endColumn = pos1.col;
15132 } else {
15133 endLine = end.line;
15134 endColumn = end.column;
15135 }
15136 } else if (!column) {
15137 var pos2 = this.fromOffset(line);
15138 line = pos2.line;
15139 column = pos2.col;
15140 }
15141 var origin = this.origin(line, column, endLine, endColumn);
15142 if (origin) {
15143 result2 = new CssSyntaxError$1(message, origin.endLine === void 0 ? origin.line : {
15144 column: origin.column,
15145 line: origin.line
15146 }, origin.endLine === void 0 ? origin.column : {
15147 column: origin.endColumn,
15148 line: origin.endLine
15149 }, origin.source, origin.file, opts.plugin);
15150 } else {
15151 result2 = new CssSyntaxError$1(message, endLine === void 0 ? line : {
15152 column: column,
15153 line: line
15154 }, endLine === void 0 ? column : {
15155 column: endColumn,
15156 line: endLine
15157 }, this.css, this.file, opts.plugin);
15158 }
15159 result2.input = {
15160 column: column,
15161 endColumn: endColumn,
15162 endLine: endLine,
15163 line: line,
15164 source: this.css
15165 };
15166 if (this.file) {
15167 if (pathToFileURL$1) {
15168 result2.input.url = pathToFileURL$1(this.file).toString();
15169 }
15170 result2.input.file = this.file;
15171 }
15172 return result2;
15173 };
15174 _proto.fromOffset = function fromOffset(offset) {
15175 var lastLine, lineToIndex;
15176 if (!this[fromOffsetCache]) {
15177 var lines = this.css.split("\n");
15178 lineToIndex = new Array(lines.length);
15179 var prevIndex = 0;
15180 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
15181 lineToIndex[i2] = prevIndex;
15182 prevIndex += lines[i2].length + 1;
15183 }
15184 this[fromOffsetCache] = lineToIndex;
15185 } else {
15186 lineToIndex = this[fromOffsetCache];
15187 }
15188 lastLine = lineToIndex[lineToIndex.length - 1];
15189 var min = 0;
15190 if (offset >= lastLine) {
15191 min = lineToIndex.length - 1;
15192 } else {
15193 var max = lineToIndex.length - 2;
15194 var mid;
15195 while(min < max){
15196 mid = min + (max - min >> 1);
15197 if (offset < lineToIndex[mid]) {
15198 max = mid - 1;
15199 } else if (offset >= lineToIndex[mid + 1]) {
15200 min = mid + 1;
15201 } else {
15202 min = mid;
15203 break;
15204 }
15205 }
15206 }
15207 return {
15208 col: offset - lineToIndex[min] + 1,
15209 line: min + 1
15210 };
15211 };
15212 _proto.mapResolve = function mapResolve(file) {
15213 if (/^\w+:\/\//.test(file)) {
15214 return file;
15215 }
15216 return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
15217 };
15218 _proto.origin = function origin(line, column, endLine, endColumn) {
15219 if (!this.map) return false;
15220 var consumer = this.map.consumer();
15221 var from = consumer.originalPositionFor({
15222 column: column,
15223 line: line
15224 });
15225 if (!from.source) return false;
15226 var to;
15227 if (typeof endLine === "number") {
15228 to = consumer.originalPositionFor({
15229 column: endColumn,
15230 line: endLine
15231 });
15232 }
15233 var fromUrl;
15234 if (isAbsolute(from.source)) {
15235 fromUrl = pathToFileURL$1(from.source);
15236 } else {
15237 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile));
15238 }
15239 var result2 = {
15240 column: from.column,
15241 endColumn: to && to.column,
15242 endLine: to && to.line,
15243 line: from.line,
15244 url: fromUrl.toString()
15245 };
15246 if (fromUrl.protocol === "file:") {
15247 if (fileURLToPath) {
15248 result2.file = fileURLToPath(fromUrl);
15249 } else {
15250 throw new Error("file: protocol is not available in this PostCSS build");
15251 }
15252 }
15253 var source = consumer.sourceContentFor(from.source);
15254 if (source) result2.source = source;
15255 return result2;
15256 };
15257 _proto.toJSON = function toJSON() {
15258 var json = {};
15259 for(var _i = 0, _iter = [
15260 "hasBOM",
15261 "css",
15262 "file",
15263 "id"
15264 ]; _i < _iter.length; _i++){
15265 var name = _iter[_i];
15266 if (this[name] != null) {
15267 json[name] = this[name];
15268 }
15269 }
15270 if (this.map) {
15271 json.map = _extends({}, this.map);
15272 if (json.map.consumerCache) {
15273 json.map.consumerCache = void 0;
15274 }
15275 }
15276 return json;
15277 };
15278 _create_class(Input2, [
15279 {
15280 key: "from",
15281 get: function get() {
15282 return this.file || this.id;
15283 }
15284 }
15285 ]);
15286 return Input2;
15287 }();
15288 var input = Input$4;
15289 Input$4.default = Input$4;
15290 if (terminalHighlight && terminalHighlight.registerInput) {
15291 terminalHighlight.registerInput(Input$4);
15292 }
15293 var SourceMapConsumer = require$$2.SourceMapConsumer, SourceMapGenerator = require$$2.SourceMapGenerator;
15294 var dirname = require$$2.dirname, relative = require$$2.relative, resolve$3 = require$$2.resolve, sep = require$$2.sep;
15295 var pathToFileURL = require$$2.pathToFileURL;
15296 var Input$3 = input;
15297 var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
15298 var pathAvailable = Boolean(dirname && resolve$3 && relative && sep);
15299 var MapGenerator$2 = /*#__PURE__*/ function() {
15300 function MapGenerator2(stringify2, root2, opts, cssString) {
15301 this.stringify = stringify2;
15302 this.mapOpts = opts.map || {};
15303 this.root = root2;
15304 this.opts = opts;
15305 this.css = cssString;
15306 this.originalCSS = cssString;
15307 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
15308 this.memoizedFileURLs = /* @__PURE__ */ new Map();
15309 this.memoizedPaths = /* @__PURE__ */ new Map();
15310 this.memoizedURLs = /* @__PURE__ */ new Map();
15311 }
15312 var _proto = MapGenerator2.prototype;
15313 _proto.addAnnotation = function addAnnotation() {
15314 var content;
15315 if (this.isInline()) {
15316 content = "data:application/json;base64," + this.toBase64(this.map.toString());
15317 } else if (typeof this.mapOpts.annotation === "string") {
15318 content = this.mapOpts.annotation;
15319 } else if (typeof this.mapOpts.annotation === "function") {
15320 content = this.mapOpts.annotation(this.opts.to, this.root);
15321 } else {
15322 content = this.outputFile() + ".map";
15323 }
15324 var eol = "\n";
15325 if (this.css.includes("\r\n")) eol = "\r\n";
15326 this.css += eol + "/*# sourceMappingURL=" + content + " */";
15327 };
15328 _proto.applyPrevMaps = function applyPrevMaps() {
15329 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
15330 var prev = _step.value;
15331 var from = this.toUrl(this.path(prev.file));
15332 var root2 = prev.root || dirname(prev.file);
15333 var map = void 0;
15334 if (this.mapOpts.sourcesContent === false) {
15335 map = new SourceMapConsumer(prev.text);
15336 if (map.sourcesContent) {
15337 map.sourcesContent = null;
15338 }
15339 } else {
15340 map = prev.consumer();
15341 }
15342 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
15343 }
15344 };
15345 _proto.clearAnnotation = function clearAnnotation() {
15346 if (this.mapOpts.annotation === false) return;
15347 if (this.root) {
15348 var node2;
15349 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
15350 node2 = this.root.nodes[i2];
15351 if (node2.type !== "comment") continue;
15352 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
15353 this.root.removeChild(i2);
15354 }
15355 }
15356 } else if (this.css) {
15357 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
15358 }
15359 };
15360 _proto.generate = function generate() {
15361 this.clearAnnotation();
15362 if (pathAvailable && sourceMapAvailable && this.isMap()) {
15363 return this.generateMap();
15364 } else {
15365 var result2 = "";
15366 this.stringify(this.root, function(i2) {
15367 result2 += i2;
15368 });
15369 return [
15370 result2
15371 ];
15372 }
15373 };
15374 _proto.generateMap = function generateMap() {
15375 if (this.root) {
15376 this.generateString();
15377 } else if (this.previous().length === 1) {
15378 var prev = this.previous()[0].consumer();
15379 prev.file = this.outputFile();
15380 this.map = SourceMapGenerator.fromSourceMap(prev, {
15381 ignoreInvalidMapping: true
15382 });
15383 } else {
15384 this.map = new SourceMapGenerator({
15385 file: this.outputFile(),
15386 ignoreInvalidMapping: true
15387 });
15388 this.map.addMapping({
15389 generated: {
15390 column: 0,
15391 line: 1
15392 },
15393 original: {
15394 column: 0,
15395 line: 1
15396 },
15397 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
15398 });
15399 }
15400 if (this.isSourcesContent()) this.setSourcesContent();
15401 if (this.root && this.previous().length > 0) this.applyPrevMaps();
15402 if (this.isAnnotation()) this.addAnnotation();
15403 if (this.isInline()) {
15404 return [
15405 this.css
15406 ];
15407 } else {
15408 return [
15409 this.css,
15410 this.map
15411 ];
15412 }
15413 };
15414 _proto.generateString = function generateString() {
15415 var _this = this;
15416 this.css = "";
15417 this.map = new SourceMapGenerator({
15418 file: this.outputFile(),
15419 ignoreInvalidMapping: true
15420 });
15421 var line = 1;
15422 var column = 1;
15423 var noSource = "<no source>";
15424 var mapping = {
15425 generated: {
15426 column: 0,
15427 line: 0
15428 },
15429 original: {
15430 column: 0,
15431 line: 0
15432 },
15433 source: ""
15434 };
15435 var lines, last;
15436 this.stringify(this.root, function(str, node2, type) {
15437 _this.css += str;
15438 if (node2 && type !== "end") {
15439 mapping.generated.line = line;
15440 mapping.generated.column = column - 1;
15441 if (node2.source && node2.source.start) {
15442 mapping.source = _this.sourcePath(node2);
15443 mapping.original.line = node2.source.start.line;
15444 mapping.original.column = node2.source.start.column - 1;
15445 _this.map.addMapping(mapping);
15446 } else {
15447 mapping.source = noSource;
15448 mapping.original.line = 1;
15449 mapping.original.column = 0;
15450 _this.map.addMapping(mapping);
15451 }
15452 }
15453 lines = str.match(/\n/g);
15454 if (lines) {
15455 line += lines.length;
15456 last = str.lastIndexOf("\n");
15457 column = str.length - last;
15458 } else {
15459 column += str.length;
15460 }
15461 if (node2 && type !== "start") {
15462 var p = node2.parent || {
15463 raws: {}
15464 };
15465 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
15466 if (!childless || node2 !== p.last || p.raws.semicolon) {
15467 if (node2.source && node2.source.end) {
15468 mapping.source = _this.sourcePath(node2);
15469 mapping.original.line = node2.source.end.line;
15470 mapping.original.column = node2.source.end.column - 1;
15471 mapping.generated.line = line;
15472 mapping.generated.column = column - 2;
15473 _this.map.addMapping(mapping);
15474 } else {
15475 mapping.source = noSource;
15476 mapping.original.line = 1;
15477 mapping.original.column = 0;
15478 mapping.generated.line = line;
15479 mapping.generated.column = column - 1;
15480 _this.map.addMapping(mapping);
15481 }
15482 }
15483 }
15484 });
15485 };
15486 _proto.isAnnotation = function isAnnotation() {
15487 if (this.isInline()) {
15488 return true;
15489 }
15490 if (typeof this.mapOpts.annotation !== "undefined") {
15491 return this.mapOpts.annotation;
15492 }
15493 if (this.previous().length) {
15494 return this.previous().some(function(i2) {
15495 return i2.annotation;
15496 });
15497 }
15498 return true;
15499 };
15500 _proto.isInline = function isInline() {
15501 if (typeof this.mapOpts.inline !== "undefined") {
15502 return this.mapOpts.inline;
15503 }
15504 var annotation = this.mapOpts.annotation;
15505 if (typeof annotation !== "undefined" && annotation !== true) {
15506 return false;
15507 }
15508 if (this.previous().length) {
15509 return this.previous().some(function(i2) {
15510 return i2.inline;
15511 });
15512 }
15513 return true;
15514 };
15515 _proto.isMap = function isMap() {
15516 if (typeof this.opts.map !== "undefined") {
15517 return !!this.opts.map;
15518 }
15519 return this.previous().length > 0;
15520 };
15521 _proto.isSourcesContent = function isSourcesContent() {
15522 if (typeof this.mapOpts.sourcesContent !== "undefined") {
15523 return this.mapOpts.sourcesContent;
15524 }
15525 if (this.previous().length) {
15526 return this.previous().some(function(i2) {
15527 return i2.withContent();
15528 });
15529 }
15530 return true;
15531 };
15532 _proto.outputFile = function outputFile() {
15533 if (this.opts.to) {
15534 return this.path(this.opts.to);
15535 } else if (this.opts.from) {
15536 return this.path(this.opts.from);
15537 } else {
15538 return "to.css";
15539 }
15540 };
15541 _proto.path = function path(file) {
15542 if (this.mapOpts.absolute) return file;
15543 if (file.charCodeAt(0) === 60) return file;
15544 if (/^\w+:\/\//.test(file)) return file;
15545 var cached = this.memoizedPaths.get(file);
15546 if (cached) return cached;
15547 var from = this.opts.to ? dirname(this.opts.to) : ".";
15548 if (typeof this.mapOpts.annotation === "string") {
15549 from = dirname(resolve$3(from, this.mapOpts.annotation));
15550 }
15551 var path = relative(from, file);
15552 this.memoizedPaths.set(file, path);
15553 return path;
15554 };
15555 _proto.previous = function previous() {
15556 var _this = this;
15557 if (!this.previousMaps) {
15558 this.previousMaps = [];
15559 if (this.root) {
15560 this.root.walk(function(node2) {
15561 if (node2.source && node2.source.input.map) {
15562 var map = node2.source.input.map;
15563 if (!_this.previousMaps.includes(map)) {
15564 _this.previousMaps.push(map);
15565 }
15566 }
15567 });
15568 } else {
15569 var input2 = new Input$3(this.originalCSS, this.opts);
15570 if (input2.map) this.previousMaps.push(input2.map);
15571 }
15572 }
15573 return this.previousMaps;
15574 };
15575 _proto.setSourcesContent = function setSourcesContent() {
15576 var _this = this;
15577 var already = {};
15578 if (this.root) {
15579 this.root.walk(function(node2) {
15580 if (node2.source) {
15581 var from = node2.source.input.from;
15582 if (from && !already[from]) {
15583 already[from] = true;
15584 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
15585 _this.map.setSourceContent(fromUrl, node2.source.input.css);
15586 }
15587 }
15588 });
15589 } else if (this.css) {
15590 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
15591 this.map.setSourceContent(from, this.css);
15592 }
15593 };
15594 _proto.sourcePath = function sourcePath(node2) {
15595 if (this.mapOpts.from) {
15596 return this.toUrl(this.mapOpts.from);
15597 } else if (this.usesFileUrls) {
15598 return this.toFileUrl(node2.source.input.from);
15599 } else {
15600 return this.toUrl(this.path(node2.source.input.from));
15601 }
15602 };
15603 _proto.toBase64 = function toBase64(str) {
15604 if (Buffer) {
15605 return Buffer.from(str).toString("base64");
15606 } else {
15607 return window.btoa(unescape(encodeURIComponent(str)));
15608 }
15609 };
15610 _proto.toFileUrl = function toFileUrl(path) {
15611 var cached = this.memoizedFileURLs.get(path);
15612 if (cached) return cached;
15613 if (pathToFileURL) {
15614 var fileURL = pathToFileURL(path).toString();
15615 this.memoizedFileURLs.set(path, fileURL);
15616 return fileURL;
15617 } else {
15618 throw new Error("`map.absolute` option is not available in this PostCSS build");
15619 }
15620 };
15621 _proto.toUrl = function toUrl(path) {
15622 var cached = this.memoizedURLs.get(path);
15623 if (cached) return cached;
15624 if (sep === "\\") {
15625 path = path.replace(/\\/g, "/");
15626 }
15627 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
15628 this.memoizedURLs.set(path, url);
15629 return url;
15630 };
15631 return MapGenerator2;
15632 }();
15633 var mapGenerator = MapGenerator$2;
15634 var Node$2 = node;
15635 var Comment$4 = /*#__PURE__*/ function(Node$2) {
15636 _inherits(Comment2, Node$2);
15637 function Comment2(defaults) {
15638 var _this;
15639 _this = Node$2.call(this, defaults) || this;
15640 _this.type = "comment";
15641 return _this;
15642 }
15643 return Comment2;
15644 }(Node$2);
15645 var comment = Comment$4;
15646 Comment$4.default = Comment$4;
15647 var isClean$1 = symbols.isClean, my$1 = symbols.my;
15648 var Declaration$3 = declaration;
15649 var Comment$3 = comment;
15650 var Node$1 = node;
15651 var parse$4, Rule$4, AtRule$4, Root$6;
15652 function cleanSource(nodes) {
15653 return nodes.map(function(i2) {
15654 if (i2.nodes) i2.nodes = cleanSource(i2.nodes);
15655 delete i2.source;
15656 return i2;
15657 });
15658 }
15659 function markDirtyUp(node2) {
15660 node2[isClean$1] = false;
15661 if (node2.proxyOf.nodes) {
15662 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
15663 var i2 = _step.value;
15664 markDirtyUp(i2);
15665 }
15666 }
15667 }
15668 var Container$7 = /*#__PURE__*/ function(Node$1) {
15669 _inherits(Container2, Node$1);
15670 function Container2() {
15671 return Node$1.apply(this, arguments) || this;
15672 }
15673 var _proto = Container2.prototype;
15674 _proto.append = function append() {
15675 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
15676 children[_key] = arguments[_key];
15677 }
15678 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
15679 var child = _step.value;
15680 var nodes = this.normalize(child, this.last);
15681 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15682 var node2 = _step1.value;
15683 this.proxyOf.nodes.push(node2);
15684 }
15685 }
15686 this.markDirty();
15687 return this;
15688 };
15689 _proto.cleanRaws = function cleanRaws(keepBetween) {
15690 Node$1.prototype.cleanRaws.call(this, keepBetween);
15691 if (this.nodes) {
15692 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
15693 var node2 = _step.value;
15694 node2.cleanRaws(keepBetween);
15695 }
15696 }
15697 };
15698 _proto.each = function each(callback) {
15699 if (!this.proxyOf.nodes) return void 0;
15700 var iterator = this.getIterator();
15701 var index2, result2;
15702 while(this.indexes[iterator] < this.proxyOf.nodes.length){
15703 index2 = this.indexes[iterator];
15704 result2 = callback(this.proxyOf.nodes[index2], index2);
15705 if (result2 === false) break;
15706 this.indexes[iterator] += 1;
15707 }
15708 delete this.indexes[iterator];
15709 return result2;
15710 };
15711 _proto.every = function every(condition) {
15712 return this.nodes.every(condition);
15713 };
15714 _proto.getIterator = function getIterator() {
15715 if (!this.lastEach) this.lastEach = 0;
15716 if (!this.indexes) this.indexes = {};
15717 this.lastEach += 1;
15718 var iterator = this.lastEach;
15719 this.indexes[iterator] = 0;
15720 return iterator;
15721 };
15722 _proto.getProxyProcessor = function getProxyProcessor() {
15723 return {
15724 get: function get(node2, prop) {
15725 if (prop === "proxyOf") {
15726 return node2;
15727 } else if (!node2[prop]) {
15728 return node2[prop];
15729 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
15730 return function() {
15731 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
15732 args[_key] = arguments[_key];
15733 }
15734 var _node2;
15735 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
15736 if (typeof i2 === "function") {
15737 return function(child, index2) {
15738 return i2(child.toProxy(), index2);
15739 };
15740 } else {
15741 return i2;
15742 }
15743 })));
15744 };
15745 } else if (prop === "every" || prop === "some") {
15746 return function(cb) {
15747 return node2[prop](function(child) {
15748 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
15749 other[_key - 1] = arguments[_key];
15750 }
15751 return cb.apply(void 0, [].concat([
15752 child.toProxy()
15753 ], other));
15754 });
15755 };
15756 } else if (prop === "root") {
15757 return function() {
15758 return node2.root().toProxy();
15759 };
15760 } else if (prop === "nodes") {
15761 return node2.nodes.map(function(i2) {
15762 return i2.toProxy();
15763 });
15764 } else if (prop === "first" || prop === "last") {
15765 return node2[prop].toProxy();
15766 } else {
15767 return node2[prop];
15768 }
15769 },
15770 set: function set(node2, prop, value) {
15771 if (node2[prop] === value) return true;
15772 node2[prop] = value;
15773 if (prop === "name" || prop === "params" || prop === "selector") {
15774 node2.markDirty();
15775 }
15776 return true;
15777 }
15778 };
15779 };
15780 _proto.index = function index(child) {
15781 if (typeof child === "number") return child;
15782 if (child.proxyOf) child = child.proxyOf;
15783 return this.proxyOf.nodes.indexOf(child);
15784 };
15785 _proto.insertAfter = function insertAfter(exist, add) {
15786 var existIndex = this.index(exist);
15787 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
15788 existIndex = this.index(exist);
15789 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15790 var node2 = _step.value;
15791 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
15792 }
15793 var index2;
15794 for(var id in this.indexes){
15795 index2 = this.indexes[id];
15796 if (existIndex < index2) {
15797 this.indexes[id] = index2 + nodes.length;
15798 }
15799 }
15800 this.markDirty();
15801 return this;
15802 };
15803 _proto.insertBefore = function insertBefore(exist, add) {
15804 var existIndex = this.index(exist);
15805 var type = existIndex === 0 ? "prepend" : false;
15806 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
15807 existIndex = this.index(exist);
15808 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15809 var node2 = _step.value;
15810 this.proxyOf.nodes.splice(existIndex, 0, node2);
15811 }
15812 var index2;
15813 for(var id in this.indexes){
15814 index2 = this.indexes[id];
15815 if (existIndex <= index2) {
15816 this.indexes[id] = index2 + nodes.length;
15817 }
15818 }
15819 this.markDirty();
15820 return this;
15821 };
15822 _proto.normalize = function normalize(nodes, sample) {
15823 var _this = this;
15824 if (typeof nodes === "string") {
15825 nodes = cleanSource(parse$4(nodes).nodes);
15826 } else if (typeof nodes === "undefined") {
15827 nodes = [];
15828 } else if (Array.isArray(nodes)) {
15829 nodes = nodes.slice(0);
15830 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15831 var i2 = _step.value;
15832 if (i2.parent) i2.parent.removeChild(i2, "ignore");
15833 }
15834 } else if (nodes.type === "root" && this.type !== "document") {
15835 nodes = nodes.nodes.slice(0);
15836 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15837 var i21 = _step1.value;
15838 if (i21.parent) i21.parent.removeChild(i21, "ignore");
15839 }
15840 } else if (nodes.type) {
15841 nodes = [
15842 nodes
15843 ];
15844 } else if (nodes.prop) {
15845 if (typeof nodes.value === "undefined") {
15846 throw new Error("Value field is missed in node creation");
15847 } else if (typeof nodes.value !== "string") {
15848 nodes.value = String(nodes.value);
15849 }
15850 nodes = [
15851 new Declaration$3(nodes)
15852 ];
15853 } else if (nodes.selector) {
15854 nodes = [
15855 new Rule$4(nodes)
15856 ];
15857 } else if (nodes.name) {
15858 nodes = [
15859 new AtRule$4(nodes)
15860 ];
15861 } else if (nodes.text) {
15862 nodes = [
15863 new Comment$3(nodes)
15864 ];
15865 } else {
15866 throw new Error("Unknown node type in node creation");
15867 }
15868 var processed = nodes.map(function(i2) {
15869 if (!i2[my$1]) Container2.rebuild(i2);
15870 i2 = i2.proxyOf;
15871 if (i2.parent) i2.parent.removeChild(i2);
15872 if (i2[isClean$1]) markDirtyUp(i2);
15873 if (typeof i2.raws.before === "undefined") {
15874 if (sample && typeof sample.raws.before !== "undefined") {
15875 i2.raws.before = sample.raws.before.replace(/\S/g, "");
15876 }
15877 }
15878 i2.parent = _this.proxyOf;
15879 return i2;
15880 });
15881 return processed;
15882 };
15883 _proto.prepend = function prepend() {
15884 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
15885 children[_key] = arguments[_key];
15886 }
15887 children = children.reverse();
15888 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
15889 var child = _step.value;
15890 var nodes = this.normalize(child, this.first, "prepend").reverse();
15891 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15892 var node2 = _step1.value;
15893 this.proxyOf.nodes.unshift(node2);
15894 }
15895 for(var id in this.indexes){
15896 this.indexes[id] = this.indexes[id] + nodes.length;
15897 }
15898 }
15899 this.markDirty();
15900 return this;
15901 };
15902 _proto.push = function push(child) {
15903 child.parent = this;
15904 this.proxyOf.nodes.push(child);
15905 return this;
15906 };
15907 _proto.removeAll = function removeAll() {
15908 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
15909 var node2 = _step.value;
15910 node2.parent = void 0;
15911 }
15912 this.proxyOf.nodes = [];
15913 this.markDirty();
15914 return this;
15915 };
15916 _proto.removeChild = function removeChild(child) {
15917 child = this.index(child);
15918 this.proxyOf.nodes[child].parent = void 0;
15919 this.proxyOf.nodes.splice(child, 1);
15920 var index2;
15921 for(var id in this.indexes){
15922 index2 = this.indexes[id];
15923 if (index2 >= child) {
15924 this.indexes[id] = index2 - 1;
15925 }
15926 }
15927 this.markDirty();
15928 return this;
15929 };
15930 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
15931 if (!callback) {
15932 callback = opts;
15933 opts = {};
15934 }
15935 this.walkDecls(function(decl) {
15936 if (opts.props && !opts.props.includes(decl.prop)) return;
15937 if (opts.fast && !decl.value.includes(opts.fast)) return;
15938 decl.value = decl.value.replace(pattern, callback);
15939 });
15940 this.markDirty();
15941 return this;
15942 };
15943 _proto.some = function some(condition) {
15944 return this.nodes.some(condition);
15945 };
15946 _proto.walk = function walk(callback) {
15947 return this.each(function(child, i2) {
15948 var result2;
15949 try {
15950 result2 = callback(child, i2);
15951 } catch (e2) {
15952 throw child.addToError(e2);
15953 }
15954 if (result2 !== false && child.walk) {
15955 result2 = child.walk(callback);
15956 }
15957 return result2;
15958 });
15959 };
15960 _proto.walkAtRules = function walkAtRules(name, callback) {
15961 if (!callback) {
15962 callback = name;
15963 return this.walk(function(child, i2) {
15964 if (child.type === "atrule") {
15965 return callback(child, i2);
15966 }
15967 });
15968 }
15969 if (_instanceof(name, RegExp)) {
15970 return this.walk(function(child, i2) {
15971 if (child.type === "atrule" && name.test(child.name)) {
15972 return callback(child, i2);
15973 }
15974 });
15975 }
15976 return this.walk(function(child, i2) {
15977 if (child.type === "atrule" && child.name === name) {
15978 return callback(child, i2);
15979 }
15980 });
15981 };
15982 _proto.walkComments = function walkComments(callback) {
15983 return this.walk(function(child, i2) {
15984 if (child.type === "comment") {
15985 return callback(child, i2);
15986 }
15987 });
15988 };
15989 _proto.walkDecls = function walkDecls(prop, callback) {
15990 if (!callback) {
15991 callback = prop;
15992 return this.walk(function(child, i2) {
15993 if (child.type === "decl") {
15994 return callback(child, i2);
15995 }
15996 });
15997 }
15998 if (_instanceof(prop, RegExp)) {
15999 return this.walk(function(child, i2) {
16000 if (child.type === "decl" && prop.test(child.prop)) {
16001 return callback(child, i2);
16002 }
16003 });
16004 }
16005 return this.walk(function(child, i2) {
16006 if (child.type === "decl" && child.prop === prop) {
16007 return callback(child, i2);
16008 }
16009 });
16010 };
16011 _proto.walkRules = function walkRules(selector, callback) {
16012 if (!callback) {
16013 callback = selector;
16014 return this.walk(function(child, i2) {
16015 if (child.type === "rule") {
16016 return callback(child, i2);
16017 }
16018 });
16019 }
16020 if (_instanceof(selector, RegExp)) {
16021 return this.walk(function(child, i2) {
16022 if (child.type === "rule" && selector.test(child.selector)) {
16023 return callback(child, i2);
16024 }
16025 });
16026 }
16027 return this.walk(function(child, i2) {
16028 if (child.type === "rule" && child.selector === selector) {
16029 return callback(child, i2);
16030 }
16031 });
16032 };
16033 _create_class(Container2, [
16034 {
16035 key: "first",
16036 get: function get() {
16037 if (!this.proxyOf.nodes) return void 0;
16038 return this.proxyOf.nodes[0];
16039 }
16040 },
16041 {
16042 key: "last",
16043 get: function get() {
16044 if (!this.proxyOf.nodes) return void 0;
16045 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
16046 }
16047 }
16048 ]);
16049 return Container2;
16050 }(Node$1);
16051 Container$7.registerParse = function(dependant) {
16052 parse$4 = dependant;
16053 };
16054 Container$7.registerRule = function(dependant) {
16055 Rule$4 = dependant;
16056 };
16057 Container$7.registerAtRule = function(dependant) {
16058 AtRule$4 = dependant;
16059 };
16060 Container$7.registerRoot = function(dependant) {
16061 Root$6 = dependant;
16062 };
16063 var container = Container$7;
16064 Container$7.default = Container$7;
16065 Container$7.rebuild = function(node2) {
16066 if (node2.type === "atrule") {
16067 Object.setPrototypeOf(node2, AtRule$4.prototype);
16068 } else if (node2.type === "rule") {
16069 Object.setPrototypeOf(node2, Rule$4.prototype);
16070 } else if (node2.type === "decl") {
16071 Object.setPrototypeOf(node2, Declaration$3.prototype);
16072 } else if (node2.type === "comment") {
16073 Object.setPrototypeOf(node2, Comment$3.prototype);
16074 } else if (node2.type === "root") {
16075 Object.setPrototypeOf(node2, Root$6.prototype);
16076 }
16077 node2[my$1] = true;
16078 if (node2.nodes) {
16079 node2.nodes.forEach(function(child) {
16080 Container$7.rebuild(child);
16081 });
16082 }
16083 };
16084 var Container$6 = container;
16085 var LazyResult$4, Processor$3;
16086 var Document$3 = /*#__PURE__*/ function(Container$6) {
16087 _inherits(Document23, Container$6);
16088 function Document23(defaults) {
16089 var _this;
16090 _this = Container$6.call(this, _extends({
16091 type: "document"
16092 }, defaults)) || this;
16093 if (!_this.nodes) {
16094 _this.nodes = [];
16095 }
16096 return _this;
16097 }
16098 var _proto = Document23.prototype;
16099 _proto.toResult = function toResult(opts) {
16100 if (opts === void 0) opts = {};
16101 var lazy = new LazyResult$4(new Processor$3(), this, opts);
16102 return lazy.stringify();
16103 };
16104 return Document23;
16105 }(Container$6);
16106 Document$3.registerLazyResult = function(dependant) {
16107 LazyResult$4 = dependant;
16108 };
16109 Document$3.registerProcessor = function(dependant) {
16110 Processor$3 = dependant;
16111 };
16112 var document$1$2 = Document$3;
16113 Document$3.default = Document$3;
16114 var printed = {};
16115 var warnOnce$2 = function warnOnce2(message) {
16116 if (printed[message]) return;
16117 printed[message] = true;
16118 if (typeof console !== "undefined" && console.warn) {
16119 console.warn(message);
16120 }
16121 };
16122 var Warning$2 = /*#__PURE__*/ function() {
16123 function Warning2(text, opts) {
16124 if (opts === void 0) opts = {};
16125 this.type = "warning";
16126 this.text = text;
16127 if (opts.node && opts.node.source) {
16128 var range = opts.node.rangeBy(opts);
16129 this.line = range.start.line;
16130 this.column = range.start.column;
16131 this.endLine = range.end.line;
16132 this.endColumn = range.end.column;
16133 }
16134 for(var opt in opts)this[opt] = opts[opt];
16135 }
16136 var _proto = Warning2.prototype;
16137 _proto.toString = function toString() {
16138 if (this.node) {
16139 return this.node.error(this.text, {
16140 index: this.index,
16141 plugin: this.plugin,
16142 word: this.word
16143 }).message;
16144 }
16145 if (this.plugin) {
16146 return this.plugin + ": " + this.text;
16147 }
16148 return this.text;
16149 };
16150 return Warning2;
16151 }();
16152 var warning = Warning$2;
16153 Warning$2.default = Warning$2;
16154 var Warning$1 = warning;
16155 var Result$3 = /*#__PURE__*/ function() {
16156 function Result2(processor2, root2, opts) {
16157 this.processor = processor2;
16158 this.messages = [];
16159 this.root = root2;
16160 this.opts = opts;
16161 this.css = void 0;
16162 this.map = void 0;
16163 }
16164 var _proto = Result2.prototype;
16165 _proto.toString = function toString() {
16166 return this.css;
16167 };
16168 _proto.warn = function warn(text, opts) {
16169 if (opts === void 0) opts = {};
16170 if (!opts.plugin) {
16171 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
16172 opts.plugin = this.lastPlugin.postcssPlugin;
16173 }
16174 }
16175 var warning2 = new Warning$1(text, opts);
16176 this.messages.push(warning2);
16177 return warning2;
16178 };
16179 _proto.warnings = function warnings() {
16180 return this.messages.filter(function(i2) {
16181 return i2.type === "warning";
16182 });
16183 };
16184 _create_class(Result2, [
16185 {
16186 key: "content",
16187 get: function get() {
16188 return this.css;
16189 }
16190 }
16191 ]);
16192 return Result2;
16193 }();
16194 var result = Result$3;
16195 Result$3.default = Result$3;
16196 var SINGLE_QUOTE = "'".charCodeAt(0);
16197 var DOUBLE_QUOTE = '"'.charCodeAt(0);
16198 var BACKSLASH = "\\".charCodeAt(0);
16199 var SLASH = "/".charCodeAt(0);
16200 var NEWLINE = "\n".charCodeAt(0);
16201 var SPACE = " ".charCodeAt(0);
16202 var FEED = "\f".charCodeAt(0);
16203 var TAB = " ".charCodeAt(0);
16204 var CR = "\r".charCodeAt(0);
16205 var OPEN_SQUARE = "[".charCodeAt(0);
16206 var CLOSE_SQUARE = "]".charCodeAt(0);
16207 var OPEN_PARENTHESES = "(".charCodeAt(0);
16208 var CLOSE_PARENTHESES = ")".charCodeAt(0);
16209 var OPEN_CURLY = "{".charCodeAt(0);
16210 var CLOSE_CURLY = "}".charCodeAt(0);
16211 var SEMICOLON = ";".charCodeAt(0);
16212 var ASTERISK = "*".charCodeAt(0);
16213 var COLON = ":".charCodeAt(0);
16214 var AT = "@".charCodeAt(0);
16215 var RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
16216 var RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
16217 var RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
16218 var RE_HEX_ESCAPE = /[\da-f]/i;
16219 var tokenize = function tokenizer2(input2, options) {
16220 if (options === void 0) options = {};
16221 var css = input2.css.valueOf();
16222 var ignore = options.ignoreErrors;
16223 var code, next, quote, content, escape;
16224 var escaped, escapePos, prev, n2, currentToken;
16225 var length = css.length;
16226 var pos = 0;
16227 var buffer = [];
16228 var returned = [];
16229 function position() {
16230 return pos;
16231 }
16232 function unclosed(what) {
16233 throw input2.error("Unclosed " + what, pos);
16234 }
16235 function endOfFile() {
16236 return returned.length === 0 && pos >= length;
16237 }
16238 function nextToken(opts) {
16239 if (returned.length) return returned.pop();
16240 if (pos >= length) return;
16241 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
16242 code = css.charCodeAt(pos);
16243 switch(code){
16244 case NEWLINE:
16245 case SPACE:
16246 case TAB:
16247 case CR:
16248 case FEED:
16249 {
16250 next = pos;
16251 do {
16252 next += 1;
16253 code = css.charCodeAt(next);
16254 }while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED);
16255 currentToken = [
16256 "space",
16257 css.slice(pos, next)
16258 ];
16259 pos = next - 1;
16260 break;
16261 }
16262 case OPEN_SQUARE:
16263 case CLOSE_SQUARE:
16264 case OPEN_CURLY:
16265 case CLOSE_CURLY:
16266 case COLON:
16267 case SEMICOLON:
16268 case CLOSE_PARENTHESES:
16269 {
16270 var controlChar = String.fromCharCode(code);
16271 currentToken = [
16272 controlChar,
16273 controlChar,
16274 pos
16275 ];
16276 break;
16277 }
16278 case OPEN_PARENTHESES:
16279 {
16280 prev = buffer.length ? buffer.pop()[1] : "";
16281 n2 = css.charCodeAt(pos + 1);
16282 if (prev === "url" && n2 !== SINGLE_QUOTE && n2 !== DOUBLE_QUOTE && n2 !== SPACE && n2 !== NEWLINE && n2 !== TAB && n2 !== FEED && n2 !== CR) {
16283 next = pos;
16284 do {
16285 escaped = false;
16286 next = css.indexOf(")", next + 1);
16287 if (next === -1) {
16288 if (ignore || ignoreUnclosed) {
16289 next = pos;
16290 break;
16291 } else {
16292 unclosed("bracket");
16293 }
16294 }
16295 escapePos = next;
16296 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16297 escapePos -= 1;
16298 escaped = !escaped;
16299 }
16300 }while (escaped);
16301 currentToken = [
16302 "brackets",
16303 css.slice(pos, next + 1),
16304 pos,
16305 next
16306 ];
16307 pos = next;
16308 } else {
16309 next = css.indexOf(")", pos + 1);
16310 content = css.slice(pos, next + 1);
16311 if (next === -1 || RE_BAD_BRACKET.test(content)) {
16312 currentToken = [
16313 "(",
16314 "(",
16315 pos
16316 ];
16317 } else {
16318 currentToken = [
16319 "brackets",
16320 content,
16321 pos,
16322 next
16323 ];
16324 pos = next;
16325 }
16326 }
16327 break;
16328 }
16329 case SINGLE_QUOTE:
16330 case DOUBLE_QUOTE:
16331 {
16332 quote = code === SINGLE_QUOTE ? "'" : '"';
16333 next = pos;
16334 do {
16335 escaped = false;
16336 next = css.indexOf(quote, next + 1);
16337 if (next === -1) {
16338 if (ignore || ignoreUnclosed) {
16339 next = pos + 1;
16340 break;
16341 } else {
16342 unclosed("string");
16343 }
16344 }
16345 escapePos = next;
16346 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16347 escapePos -= 1;
16348 escaped = !escaped;
16349 }
16350 }while (escaped);
16351 currentToken = [
16352 "string",
16353 css.slice(pos, next + 1),
16354 pos,
16355 next
16356 ];
16357 pos = next;
16358 break;
16359 }
16360 case AT:
16361 {
16362 RE_AT_END.lastIndex = pos + 1;
16363 RE_AT_END.test(css);
16364 if (RE_AT_END.lastIndex === 0) {
16365 next = css.length - 1;
16366 } else {
16367 next = RE_AT_END.lastIndex - 2;
16368 }
16369 currentToken = [
16370 "at-word",
16371 css.slice(pos, next + 1),
16372 pos,
16373 next
16374 ];
16375 pos = next;
16376 break;
16377 }
16378 case BACKSLASH:
16379 {
16380 next = pos;
16381 escape = true;
16382 while(css.charCodeAt(next + 1) === BACKSLASH){
16383 next += 1;
16384 escape = !escape;
16385 }
16386 code = css.charCodeAt(next + 1);
16387 if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
16388 next += 1;
16389 if (RE_HEX_ESCAPE.test(css.charAt(next))) {
16390 while(RE_HEX_ESCAPE.test(css.charAt(next + 1))){
16391 next += 1;
16392 }
16393 if (css.charCodeAt(next + 1) === SPACE) {
16394 next += 1;
16395 }
16396 }
16397 }
16398 currentToken = [
16399 "word",
16400 css.slice(pos, next + 1),
16401 pos,
16402 next
16403 ];
16404 pos = next;
16405 break;
16406 }
16407 default:
16408 {
16409 if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
16410 next = css.indexOf("*/", pos + 2) + 1;
16411 if (next === 0) {
16412 if (ignore || ignoreUnclosed) {
16413 next = css.length;
16414 } else {
16415 unclosed("comment");
16416 }
16417 }
16418 currentToken = [
16419 "comment",
16420 css.slice(pos, next + 1),
16421 pos,
16422 next
16423 ];
16424 pos = next;
16425 } else {
16426 RE_WORD_END.lastIndex = pos + 1;
16427 RE_WORD_END.test(css);
16428 if (RE_WORD_END.lastIndex === 0) {
16429 next = css.length - 1;
16430 } else {
16431 next = RE_WORD_END.lastIndex - 2;
16432 }
16433 currentToken = [
16434 "word",
16435 css.slice(pos, next + 1),
16436 pos,
16437 next
16438 ];
16439 buffer.push(currentToken);
16440 pos = next;
16441 }
16442 break;
16443 }
16444 }
16445 pos++;
16446 return currentToken;
16447 }
16448 function back(token) {
16449 returned.push(token);
16450 }
16451 return {
16452 back: back,
16453 endOfFile: endOfFile,
16454 nextToken: nextToken,
16455 position: position
16456 };
16457 };
16458 var Container$5 = container;
16459 var AtRule$3 = /*#__PURE__*/ function(Container$5) {
16460 _inherits(AtRule2, Container$5);
16461 function AtRule2(defaults) {
16462 var _this;
16463 _this = Container$5.call(this, defaults) || this;
16464 _this.type = "atrule";
16465 return _this;
16466 }
16467 var _proto = AtRule2.prototype;
16468 _proto.append = function append() {
16469 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16470 children[_key] = arguments[_key];
16471 }
16472 var _Container$5_prototype_append;
16473 if (!this.proxyOf.nodes) this.nodes = [];
16474 return (_Container$5_prototype_append = Container$5.prototype.append).call.apply(_Container$5_prototype_append, [].concat([
16475 this
16476 ], children));
16477 };
16478 _proto.prepend = function prepend() {
16479 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16480 children[_key] = arguments[_key];
16481 }
16482 var _Container$5_prototype_prepend;
16483 if (!this.proxyOf.nodes) this.nodes = [];
16484 return (_Container$5_prototype_prepend = Container$5.prototype.prepend).call.apply(_Container$5_prototype_prepend, [].concat([
16485 this
16486 ], children));
16487 };
16488 return AtRule2;
16489 }(Container$5);
16490 var atRule = AtRule$3;
16491 AtRule$3.default = AtRule$3;
16492 Container$5.registerAtRule(AtRule$3);
16493 var Container$4 = container;
16494 var LazyResult$3, Processor$2;
16495 var Root$5 = /*#__PURE__*/ function(Container$4) {
16496 _inherits(Root2, Container$4);
16497 function Root2(defaults) {
16498 var _this;
16499 _this = Container$4.call(this, defaults) || this;
16500 _this.type = "root";
16501 if (!_this.nodes) _this.nodes = [];
16502 return _this;
16503 }
16504 var _proto = Root2.prototype;
16505 _proto.normalize = function normalize(child, sample, type) {
16506 var nodes = Container$4.prototype.normalize.call(this, child);
16507 if (sample) {
16508 if (type === "prepend") {
16509 if (this.nodes.length > 1) {
16510 sample.raws.before = this.nodes[1].raws.before;
16511 } else {
16512 delete sample.raws.before;
16513 }
16514 } else if (this.first !== sample) {
16515 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16516 var node2 = _step.value;
16517 node2.raws.before = sample.raws.before;
16518 }
16519 }
16520 }
16521 return nodes;
16522 };
16523 _proto.removeChild = function removeChild(child, ignore) {
16524 var index2 = this.index(child);
16525 if (!ignore && index2 === 0 && this.nodes.length > 1) {
16526 this.nodes[1].raws.before = this.nodes[index2].raws.before;
16527 }
16528 return Container$4.prototype.removeChild.call(this, child);
16529 };
16530 _proto.toResult = function toResult(opts) {
16531 if (opts === void 0) opts = {};
16532 var lazy = new LazyResult$3(new Processor$2(), this, opts);
16533 return lazy.stringify();
16534 };
16535 return Root2;
16536 }(Container$4);
16537 Root$5.registerLazyResult = function(dependant) {
16538 LazyResult$3 = dependant;
16539 };
16540 Root$5.registerProcessor = function(dependant) {
16541 Processor$2 = dependant;
16542 };
16543 var root = Root$5;
16544 Root$5.default = Root$5;
16545 Container$4.registerRoot(Root$5);
16546 var list$2 = {
16547 comma: function comma(string) {
16548 return list$2.split(string, [
16549 ","
16550 ], true);
16551 },
16552 space: function space(string) {
16553 var spaces = [
16554 " ",
16555 "\n",
16556 " "
16557 ];
16558 return list$2.split(string, spaces);
16559 },
16560 split: function split(string, separators, last) {
16561 var array = [];
16562 var current = "";
16563 var split = false;
16564 var func = 0;
16565 var inQuote = false;
16566 var prevQuote = "";
16567 var escape = false;
16568 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
16569 var letter = _step.value;
16570 if (escape) {
16571 escape = false;
16572 } else if (letter === "\\") {
16573 escape = true;
16574 } else if (inQuote) {
16575 if (letter === prevQuote) {
16576 inQuote = false;
16577 }
16578 } else if (letter === '"' || letter === "'") {
16579 inQuote = true;
16580 prevQuote = letter;
16581 } else if (letter === "(") {
16582 func += 1;
16583 } else if (letter === ")") {
16584 if (func > 0) func -= 1;
16585 } else if (func === 0) {
16586 if (separators.includes(letter)) split = true;
16587 }
16588 if (split) {
16589 if (current !== "") array.push(current.trim());
16590 current = "";
16591 split = false;
16592 } else {
16593 current += letter;
16594 }
16595 }
16596 if (last || current !== "") array.push(current.trim());
16597 return array;
16598 }
16599 };
16600 var list_1 = list$2;
16601 list$2.default = list$2;
16602 var Container$3 = container;
16603 var list$1 = list_1;
16604 var Rule$3 = /*#__PURE__*/ function(Container$3) {
16605 _inherits(Rule2, Container$3);
16606 function Rule2(defaults) {
16607 var _this;
16608 _this = Container$3.call(this, defaults) || this;
16609 _this.type = "rule";
16610 if (!_this.nodes) _this.nodes = [];
16611 return _this;
16612 }
16613 _create_class(Rule2, [
16614 {
16615 key: "selectors",
16616 get: function get() {
16617 return list$1.comma(this.selector);
16618 },
16619 set: function set(values) {
16620 var match = this.selector ? this.selector.match(/,\s*/) : null;
16621 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
16622 this.selector = values.join(sep2);
16623 }
16624 }
16625 ]);
16626 return Rule2;
16627 }(Container$3);
16628 var rule = Rule$3;
16629 Rule$3.default = Rule$3;
16630 Container$3.registerRule(Rule$3);
16631 var Declaration$2 = declaration;
16632 var tokenizer22 = tokenize;
16633 var Comment$2 = comment;
16634 var AtRule$2 = atRule;
16635 var Root$4 = root;
16636 var Rule$2 = rule;
16637 var SAFE_COMMENT_NEIGHBOR = {
16638 empty: true,
16639 space: true
16640 };
16641 function findLastWithPosition(tokens) {
16642 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
16643 var token = tokens[i2];
16644 var pos = token[3] || token[2];
16645 if (pos) return pos;
16646 }
16647 }
16648 var Parser$1 = /*#__PURE__*/ function() {
16649 function Parser2(input2) {
16650 this.input = input2;
16651 this.root = new Root$4();
16652 this.current = this.root;
16653 this.spaces = "";
16654 this.semicolon = false;
16655 this.createTokenizer();
16656 this.root.source = {
16657 input: input2,
16658 start: {
16659 column: 1,
16660 line: 1,
16661 offset: 0
16662 }
16663 };
16664 }
16665 var _proto = Parser2.prototype;
16666 _proto.atrule = function atrule(token) {
16667 var node2 = new AtRule$2();
16668 node2.name = token[1].slice(1);
16669 if (node2.name === "") {
16670 this.unnamedAtrule(node2, token);
16671 }
16672 this.init(node2, token[2]);
16673 var type;
16674 var prev;
16675 var shift;
16676 var last = false;
16677 var open = false;
16678 var params = [];
16679 var brackets = [];
16680 while(!this.tokenizer.endOfFile()){
16681 token = this.tokenizer.nextToken();
16682 type = token[0];
16683 if (type === "(" || type === "[") {
16684 brackets.push(type === "(" ? ")" : "]");
16685 } else if (type === "{" && brackets.length > 0) {
16686 brackets.push("}");
16687 } else if (type === brackets[brackets.length - 1]) {
16688 brackets.pop();
16689 }
16690 if (brackets.length === 0) {
16691 if (type === ";") {
16692 node2.source.end = this.getPosition(token[2]);
16693 node2.source.end.offset++;
16694 this.semicolon = true;
16695 break;
16696 } else if (type === "{") {
16697 open = true;
16698 break;
16699 } else if (type === "}") {
16700 if (params.length > 0) {
16701 shift = params.length - 1;
16702 prev = params[shift];
16703 while(prev && prev[0] === "space"){
16704 prev = params[--shift];
16705 }
16706 if (prev) {
16707 node2.source.end = this.getPosition(prev[3] || prev[2]);
16708 node2.source.end.offset++;
16709 }
16710 }
16711 this.end(token);
16712 break;
16713 } else {
16714 params.push(token);
16715 }
16716 } else {
16717 params.push(token);
16718 }
16719 if (this.tokenizer.endOfFile()) {
16720 last = true;
16721 break;
16722 }
16723 }
16724 node2.raws.between = this.spacesAndCommentsFromEnd(params);
16725 if (params.length) {
16726 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
16727 this.raw(node2, "params", params);
16728 if (last) {
16729 token = params[params.length - 1];
16730 node2.source.end = this.getPosition(token[3] || token[2]);
16731 node2.source.end.offset++;
16732 this.spaces = node2.raws.between;
16733 node2.raws.between = "";
16734 }
16735 } else {
16736 node2.raws.afterName = "";
16737 node2.params = "";
16738 }
16739 if (open) {
16740 node2.nodes = [];
16741 this.current = node2;
16742 }
16743 };
16744 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
16745 var colon = this.colon(tokens);
16746 if (colon === false) return;
16747 var founded = 0;
16748 var token;
16749 for(var j = colon - 1; j >= 0; j--){
16750 token = tokens[j];
16751 if (token[0] !== "space") {
16752 founded += 1;
16753 if (founded === 2) break;
16754 }
16755 }
16756 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
16757 };
16758 _proto.colon = function colon(tokens) {
16759 var brackets = 0;
16760 var token, type, prev;
16761 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
16762 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
16763 token = element;
16764 type = token[0];
16765 if (type === "(") {
16766 brackets += 1;
16767 }
16768 if (type === ")") {
16769 brackets -= 1;
16770 }
16771 if (brackets === 0 && type === ":") {
16772 if (!prev) {
16773 this.doubleColon(token);
16774 } else if (prev[0] === "word" && prev[1] === "progid") {
16775 continue;
16776 } else {
16777 return i2;
16778 }
16779 }
16780 prev = token;
16781 }
16782 return false;
16783 };
16784 _proto.comment = function comment(token) {
16785 var node2 = new Comment$2();
16786 this.init(node2, token[2]);
16787 node2.source.end = this.getPosition(token[3] || token[2]);
16788 node2.source.end.offset++;
16789 var text = token[1].slice(2, -2);
16790 if (/^\s*$/.test(text)) {
16791 node2.text = "";
16792 node2.raws.left = text;
16793 node2.raws.right = "";
16794 } else {
16795 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
16796 node2.text = match[2];
16797 node2.raws.left = match[1];
16798 node2.raws.right = match[3];
16799 }
16800 };
16801 _proto.createTokenizer = function createTokenizer() {
16802 this.tokenizer = tokenizer22(this.input);
16803 };
16804 _proto.decl = function decl(tokens, customProperty) {
16805 var node2 = new Declaration$2();
16806 this.init(node2, tokens[0][2]);
16807 var last = tokens[tokens.length - 1];
16808 if (last[0] === ";") {
16809 this.semicolon = true;
16810 tokens.pop();
16811 }
16812 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition(tokens));
16813 node2.source.end.offset++;
16814 while(tokens[0][0] !== "word"){
16815 if (tokens.length === 1) this.unknownWord(tokens);
16816 node2.raws.before += tokens.shift()[1];
16817 }
16818 node2.source.start = this.getPosition(tokens[0][2]);
16819 node2.prop = "";
16820 while(tokens.length){
16821 var type = tokens[0][0];
16822 if (type === ":" || type === "space" || type === "comment") {
16823 break;
16824 }
16825 node2.prop += tokens.shift()[1];
16826 }
16827 node2.raws.between = "";
16828 var token;
16829 while(tokens.length){
16830 token = tokens.shift();
16831 if (token[0] === ":") {
16832 node2.raws.between += token[1];
16833 break;
16834 } else {
16835 if (token[0] === "word" && /\w/.test(token[1])) {
16836 this.unknownWord([
16837 token
16838 ]);
16839 }
16840 node2.raws.between += token[1];
16841 }
16842 }
16843 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
16844 node2.raws.before += node2.prop[0];
16845 node2.prop = node2.prop.slice(1);
16846 }
16847 var firstSpaces = [];
16848 var next;
16849 while(tokens.length){
16850 next = tokens[0][0];
16851 if (next !== "space" && next !== "comment") break;
16852 firstSpaces.push(tokens.shift());
16853 }
16854 this.precheckMissedSemicolon(tokens);
16855 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
16856 token = tokens[i2];
16857 if (token[1].toLowerCase() === "!important") {
16858 node2.important = true;
16859 var string = this.stringFrom(tokens, i2);
16860 string = this.spacesFromEnd(tokens) + string;
16861 if (string !== " !important") node2.raws.important = string;
16862 break;
16863 } else if (token[1].toLowerCase() === "important") {
16864 var cache = tokens.slice(0);
16865 var str = "";
16866 for(var j = i2; j > 0; j--){
16867 var type1 = cache[j][0];
16868 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
16869 break;
16870 }
16871 str = cache.pop()[1] + str;
16872 }
16873 if (str.trim().indexOf("!") === 0) {
16874 node2.important = true;
16875 node2.raws.important = str;
16876 tokens = cache;
16877 }
16878 }
16879 if (token[0] !== "space" && token[0] !== "comment") {
16880 break;
16881 }
16882 }
16883 var hasWord = tokens.some(function(i2) {
16884 return i2[0] !== "space" && i2[0] !== "comment";
16885 });
16886 if (hasWord) {
16887 node2.raws.between += firstSpaces.map(function(i2) {
16888 return i2[1];
16889 }).join("");
16890 firstSpaces = [];
16891 }
16892 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
16893 if (node2.value.includes(":") && !customProperty) {
16894 this.checkMissedSemicolon(tokens);
16895 }
16896 };
16897 _proto.doubleColon = function doubleColon(token) {
16898 throw this.input.error("Double colon", {
16899 offset: token[2]
16900 }, {
16901 offset: token[2] + token[1].length
16902 });
16903 };
16904 _proto.emptyRule = function emptyRule(token) {
16905 var node2 = new Rule$2();
16906 this.init(node2, token[2]);
16907 node2.selector = "";
16908 node2.raws.between = "";
16909 this.current = node2;
16910 };
16911 _proto.end = function end(token) {
16912 if (this.current.nodes && this.current.nodes.length) {
16913 this.current.raws.semicolon = this.semicolon;
16914 }
16915 this.semicolon = false;
16916 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
16917 this.spaces = "";
16918 if (this.current.parent) {
16919 this.current.source.end = this.getPosition(token[2]);
16920 this.current.source.end.offset++;
16921 this.current = this.current.parent;
16922 } else {
16923 this.unexpectedClose(token);
16924 }
16925 };
16926 _proto.endFile = function endFile() {
16927 if (this.current.parent) this.unclosedBlock();
16928 if (this.current.nodes && this.current.nodes.length) {
16929 this.current.raws.semicolon = this.semicolon;
16930 }
16931 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
16932 this.root.source.end = this.getPosition(this.tokenizer.position());
16933 };
16934 _proto.freeSemicolon = function freeSemicolon(token) {
16935 this.spaces += token[1];
16936 if (this.current.nodes) {
16937 var prev = this.current.nodes[this.current.nodes.length - 1];
16938 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
16939 prev.raws.ownSemicolon = this.spaces;
16940 this.spaces = "";
16941 }
16942 }
16943 };
16944 // Helpers
16945 _proto.getPosition = function getPosition(offset) {
16946 var pos = this.input.fromOffset(offset);
16947 return {
16948 column: pos.col,
16949 line: pos.line,
16950 offset: offset
16951 };
16952 };
16953 _proto.init = function init(node2, offset) {
16954 this.current.push(node2);
16955 node2.source = {
16956 input: this.input,
16957 start: this.getPosition(offset)
16958 };
16959 node2.raws.before = this.spaces;
16960 this.spaces = "";
16961 if (node2.type !== "comment") this.semicolon = false;
16962 };
16963 _proto.other = function other(start) {
16964 var end = false;
16965 var type = null;
16966 var colon = false;
16967 var bracket = null;
16968 var brackets = [];
16969 var customProperty = start[1].startsWith("--");
16970 var tokens = [];
16971 var token = start;
16972 while(token){
16973 type = token[0];
16974 tokens.push(token);
16975 if (type === "(" || type === "[") {
16976 if (!bracket) bracket = token;
16977 brackets.push(type === "(" ? ")" : "]");
16978 } else if (customProperty && colon && type === "{") {
16979 if (!bracket) bracket = token;
16980 brackets.push("}");
16981 } else if (brackets.length === 0) {
16982 if (type === ";") {
16983 if (colon) {
16984 this.decl(tokens, customProperty);
16985 return;
16986 } else {
16987 break;
16988 }
16989 } else if (type === "{") {
16990 this.rule(tokens);
16991 return;
16992 } else if (type === "}") {
16993 this.tokenizer.back(tokens.pop());
16994 end = true;
16995 break;
16996 } else if (type === ":") {
16997 colon = true;
16998 }
16999 } else if (type === brackets[brackets.length - 1]) {
17000 brackets.pop();
17001 if (brackets.length === 0) bracket = null;
17002 }
17003 token = this.tokenizer.nextToken();
17004 }
17005 if (this.tokenizer.endOfFile()) end = true;
17006 if (brackets.length > 0) this.unclosedBracket(bracket);
17007 if (end && colon) {
17008 if (!customProperty) {
17009 while(tokens.length){
17010 token = tokens[tokens.length - 1][0];
17011 if (token !== "space" && token !== "comment") break;
17012 this.tokenizer.back(tokens.pop());
17013 }
17014 }
17015 this.decl(tokens, customProperty);
17016 } else {
17017 this.unknownWord(tokens);
17018 }
17019 };
17020 _proto.parse = function parse() {
17021 var token;
17022 while(!this.tokenizer.endOfFile()){
17023 token = this.tokenizer.nextToken();
17024 switch(token[0]){
17025 case "space":
17026 this.spaces += token[1];
17027 break;
17028 case ";":
17029 this.freeSemicolon(token);
17030 break;
17031 case "}":
17032 this.end(token);
17033 break;
17034 case "comment":
17035 this.comment(token);
17036 break;
17037 case "at-word":
17038 this.atrule(token);
17039 break;
17040 case "{":
17041 this.emptyRule(token);
17042 break;
17043 default:
17044 this.other(token);
17045 break;
17046 }
17047 }
17048 this.endFile();
17049 };
17050 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
17051 _proto.raw = function raw(node2, prop, tokens, customProperty) {
17052 var token, type;
17053 var length = tokens.length;
17054 var value = "";
17055 var clean = true;
17056 var next, prev;
17057 for(var i2 = 0; i2 < length; i2 += 1){
17058 token = tokens[i2];
17059 type = token[0];
17060 if (type === "space" && i2 === length - 1 && !customProperty) {
17061 clean = false;
17062 } else if (type === "comment") {
17063 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
17064 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
17065 if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
17066 if (value.slice(-1) === ",") {
17067 clean = false;
17068 } else {
17069 value += token[1];
17070 }
17071 } else {
17072 clean = false;
17073 }
17074 } else {
17075 value += token[1];
17076 }
17077 }
17078 if (!clean) {
17079 var raw = tokens.reduce(function(all, i2) {
17080 return all + i2[1];
17081 }, "");
17082 node2.raws[prop] = {
17083 raw: raw,
17084 value: value
17085 };
17086 }
17087 node2[prop] = value;
17088 };
17089 _proto.rule = function rule(tokens) {
17090 tokens.pop();
17091 var node2 = new Rule$2();
17092 this.init(node2, tokens[0][2]);
17093 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
17094 this.raw(node2, "selector", tokens);
17095 this.current = node2;
17096 };
17097 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
17098 var lastTokenType;
17099 var spaces = "";
17100 while(tokens.length){
17101 lastTokenType = tokens[tokens.length - 1][0];
17102 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
17103 spaces = tokens.pop()[1] + spaces;
17104 }
17105 return spaces;
17106 };
17107 // Errors
17108 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
17109 var next;
17110 var spaces = "";
17111 while(tokens.length){
17112 next = tokens[0][0];
17113 if (next !== "space" && next !== "comment") break;
17114 spaces += tokens.shift()[1];
17115 }
17116 return spaces;
17117 };
17118 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
17119 var lastTokenType;
17120 var spaces = "";
17121 while(tokens.length){
17122 lastTokenType = tokens[tokens.length - 1][0];
17123 if (lastTokenType !== "space") break;
17124 spaces = tokens.pop()[1] + spaces;
17125 }
17126 return spaces;
17127 };
17128 _proto.stringFrom = function stringFrom(tokens, from) {
17129 var result2 = "";
17130 for(var i2 = from; i2 < tokens.length; i2++){
17131 result2 += tokens[i2][1];
17132 }
17133 tokens.splice(from, tokens.length - from);
17134 return result2;
17135 };
17136 _proto.unclosedBlock = function unclosedBlock() {
17137 var pos = this.current.source.start;
17138 throw this.input.error("Unclosed block", pos.line, pos.column);
17139 };
17140 _proto.unclosedBracket = function unclosedBracket(bracket) {
17141 throw this.input.error("Unclosed bracket", {
17142 offset: bracket[2]
17143 }, {
17144 offset: bracket[2] + 1
17145 });
17146 };
17147 _proto.unexpectedClose = function unexpectedClose(token) {
17148 throw this.input.error("Unexpected }", {
17149 offset: token[2]
17150 }, {
17151 offset: token[2] + 1
17152 });
17153 };
17154 _proto.unknownWord = function unknownWord(tokens) {
17155 throw this.input.error("Unknown word", {
17156 offset: tokens[0][2]
17157 }, {
17158 offset: tokens[0][2] + tokens[0][1].length
17159 });
17160 };
17161 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
17162 throw this.input.error("At-rule without name", {
17163 offset: token[2]
17164 }, {
17165 offset: token[2] + token[1].length
17166 });
17167 };
17168 return Parser2;
17169 }();
17170 var parser = Parser$1;
17171 var Container$2 = container;
17172 var Parser22 = parser;
17173 var Input$2 = input;
17174 function parse$3(css, opts) {
17175 var input2 = new Input$2(css, opts);
17176 var parser2 = new Parser22(input2);
17177 try {
17178 parser2.parse();
17179 } catch (e2) {
17180 if (true) {
17181 if (e2.name === "CssSyntaxError" && opts && opts.from) {
17182 if (/\.scss$/i.test(opts.from)) {
17183 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
17184 } else if (/\.sass/i.test(opts.from)) {
17185 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
17186 } else if (/\.less$/i.test(opts.from)) {
17187 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
17188 }
17189 }
17190 }
17191 throw e2;
17192 }
17193 return parser2.root;
17194 }
17195 var parse_1 = parse$3;
17196 parse$3.default = parse$3;
17197 Container$2.registerParse(parse$3);
17198 var isClean = symbols.isClean, my = symbols.my;
17199 var MapGenerator$1 = mapGenerator;
17200 var stringify$2 = stringify_1;
17201 var Container$1 = container;
17202 var Document$2 = document$1$2;
17203 var warnOnce$1 = warnOnce$2;
17204 var Result$2 = result;
17205 var parse$2 = parse_1;
17206 var Root$3 = root;
17207 var TYPE_TO_CLASS_NAME = {
17208 atrule: "AtRule",
17209 comment: "Comment",
17210 decl: "Declaration",
17211 document: "Document",
17212 root: "Root",
17213 rule: "Rule"
17214 };
17215 var PLUGIN_PROPS = {
17216 AtRule: true,
17217 AtRuleExit: true,
17218 Comment: true,
17219 CommentExit: true,
17220 Declaration: true,
17221 DeclarationExit: true,
17222 Document: true,
17223 DocumentExit: true,
17224 Once: true,
17225 OnceExit: true,
17226 postcssPlugin: true,
17227 prepare: true,
17228 Root: true,
17229 RootExit: true,
17230 Rule: true,
17231 RuleExit: true
17232 };
17233 var NOT_VISITORS = {
17234 Once: true,
17235 postcssPlugin: true,
17236 prepare: true
17237 };
17238 var CHILDREN = 0;
17239 function isPromise(obj) {
17240 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
17241 }
17242 function getEvents(node2) {
17243 var key = false;
17244 var type = TYPE_TO_CLASS_NAME[node2.type];
17245 if (node2.type === "decl") {
17246 key = node2.prop.toLowerCase();
17247 } else if (node2.type === "atrule") {
17248 key = node2.name.toLowerCase();
17249 }
17250 if (key && node2.append) {
17251 return [
17252 type,
17253 type + "-" + key,
17254 CHILDREN,
17255 type + "Exit",
17256 type + "Exit-" + key
17257 ];
17258 } else if (key) {
17259 return [
17260 type,
17261 type + "-" + key,
17262 type + "Exit",
17263 type + "Exit-" + key
17264 ];
17265 } else if (node2.append) {
17266 return [
17267 type,
17268 CHILDREN,
17269 type + "Exit"
17270 ];
17271 } else {
17272 return [
17273 type,
17274 type + "Exit"
17275 ];
17276 }
17277 }
17278 function toStack(node2) {
17279 var events;
17280 if (node2.type === "document") {
17281 events = [
17282 "Document",
17283 CHILDREN,
17284 "DocumentExit"
17285 ];
17286 } else if (node2.type === "root") {
17287 events = [
17288 "Root",
17289 CHILDREN,
17290 "RootExit"
17291 ];
17292 } else {
17293 events = getEvents(node2);
17294 }
17295 return {
17296 eventIndex: 0,
17297 events: events,
17298 iterator: 0,
17299 node: node2,
17300 visitorIndex: 0,
17301 visitors: []
17302 };
17303 }
17304 function cleanMarks(node2) {
17305 node2[isClean] = false;
17306 if (node2.nodes) node2.nodes.forEach(function(i2) {
17307 return cleanMarks(i2);
17308 });
17309 return node2;
17310 }
17311 var postcss$2 = {};
17312 var LazyResult$2 = /*#__PURE__*/ function() {
17313 function LazyResult2(processor2, css, opts) {
17314 var _this = this;
17315 this.stringified = false;
17316 this.processed = false;
17317 var root2;
17318 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
17319 root2 = cleanMarks(css);
17320 } else if (_instanceof(css, LazyResult2) || _instanceof(css, Result$2)) {
17321 root2 = cleanMarks(css.root);
17322 if (css.map) {
17323 if (typeof opts.map === "undefined") opts.map = {};
17324 if (!opts.map.inline) opts.map.inline = false;
17325 opts.map.prev = css.map;
17326 }
17327 } else {
17328 var parser2 = parse$2;
17329 if (opts.syntax) parser2 = opts.syntax.parse;
17330 if (opts.parser) parser2 = opts.parser;
17331 if (parser2.parse) parser2 = parser2.parse;
17332 try {
17333 root2 = parser2(css, opts);
17334 } catch (error) {
17335 this.processed = true;
17336 this.error = error;
17337 }
17338 if (root2 && !root2[my]) {
17339 Container$1.rebuild(root2);
17340 }
17341 }
17342 this.result = new Result$2(processor2, root2, opts);
17343 this.helpers = _extends({}, postcss$2, {
17344 postcss: postcss$2,
17345 result: this.result
17346 });
17347 this.plugins = this.processor.plugins.map(function(plugin22) {
17348 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
17349 return _extends({}, plugin22, plugin22.prepare(_this.result));
17350 } else {
17351 return plugin22;
17352 }
17353 });
17354 }
17355 var _proto = LazyResult2.prototype;
17356 _proto.async = function async() {
17357 if (this.error) return Promise.reject(this.error);
17358 if (this.processed) return Promise.resolve(this.result);
17359 if (!this.processing) {
17360 this.processing = this.runAsync();
17361 }
17362 return this.processing;
17363 };
17364 _proto.catch = function _catch(onRejected) {
17365 return this.async().catch(onRejected);
17366 };
17367 _proto.finally = function _finally(onFinally) {
17368 return this.async().then(onFinally, onFinally);
17369 };
17370 _proto.getAsyncError = function getAsyncError() {
17371 throw new Error("Use process(css).then(cb) to work with async plugins");
17372 };
17373 _proto.handleError = function handleError(error, node2) {
17374 var plugin22 = this.result.lastPlugin;
17375 try {
17376 if (node2) node2.addToError(error);
17377 this.error = error;
17378 if (error.name === "CssSyntaxError" && !error.plugin) {
17379 error.plugin = plugin22.postcssPlugin;
17380 error.setMessage();
17381 } else if (plugin22.postcssVersion) {
17382 if (true) {
17383 var pluginName = plugin22.postcssPlugin;
17384 var pluginVer = plugin22.postcssVersion;
17385 var runtimeVer = this.result.processor.version;
17386 var a2 = pluginVer.split(".");
17387 var b = runtimeVer.split(".");
17388 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
17389 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.");
17390 }
17391 }
17392 }
17393 } catch (err) {
17394 if (console && console.error) console.error(err);
17395 }
17396 return error;
17397 };
17398 _proto.prepareVisitors = function prepareVisitors() {
17399 var _this = this;
17400 this.listeners = {};
17401 var add = function(plugin22, type, cb) {
17402 if (!_this.listeners[type]) _this.listeners[type] = [];
17403 _this.listeners[type].push([
17404 plugin22,
17405 cb
17406 ]);
17407 };
17408 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17409 var plugin22 = _step.value;
17410 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
17411 for(var event in plugin22){
17412 if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
17413 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
17414 }
17415 if (!NOT_VISITORS[event]) {
17416 if (_type_of(plugin22[event]) === "object") {
17417 for(var filter in plugin22[event]){
17418 if (filter === "*") {
17419 add(plugin22, event, plugin22[event][filter]);
17420 } else {
17421 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
17422 }
17423 }
17424 } else if (typeof plugin22[event] === "function") {
17425 add(plugin22, event, plugin22[event]);
17426 }
17427 }
17428 }
17429 }
17430 }
17431 this.hasListener = Object.keys(this.listeners).length > 0;
17432 };
17433 _proto.runAsync = function runAsync() {
17434 var _this = this;
17435 return _async_to_generator(function() {
17436 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
17437 return _ts_generator(this, function(_state) {
17438 switch(_state.label){
17439 case 0:
17440 _this.plugin = 0;
17441 i2 = 0;
17442 _state.label = 1;
17443 case 1:
17444 if (!(i2 < _this.plugins.length)) return [
17445 3,
17446 6
17447 ];
17448 plugin22 = _this.plugins[i2];
17449 promise = _this.runOnRoot(plugin22);
17450 if (!isPromise(promise)) return [
17451 3,
17452 5
17453 ];
17454 _state.label = 2;
17455 case 2:
17456 _state.trys.push([
17457 2,
17458 4,
17459 ,
17460 5
17461 ]);
17462 return [
17463 4,
17464 promise
17465 ];
17466 case 3:
17467 _state.sent();
17468 return [
17469 3,
17470 5
17471 ];
17472 case 4:
17473 error = _state.sent();
17474 throw _this.handleError(error);
17475 case 5:
17476 i2++;
17477 return [
17478 3,
17479 1
17480 ];
17481 case 6:
17482 _this.prepareVisitors();
17483 if (!_this.hasListener) return [
17484 3,
17485 18
17486 ];
17487 root2 = _this.result.root;
17488 _state.label = 7;
17489 case 7:
17490 if (!!root2[isClean]) return [
17491 3,
17492 14
17493 ];
17494 root2[isClean] = true;
17495 stack = [
17496 toStack(root2)
17497 ];
17498 _state.label = 8;
17499 case 8:
17500 if (!(stack.length > 0)) return [
17501 3,
17502 13
17503 ];
17504 promise1 = _this.visitTick(stack);
17505 if (!isPromise(promise1)) return [
17506 3,
17507 12
17508 ];
17509 _state.label = 9;
17510 case 9:
17511 _state.trys.push([
17512 9,
17513 11,
17514 ,
17515 12
17516 ]);
17517 return [
17518 4,
17519 promise1
17520 ];
17521 case 10:
17522 _state.sent();
17523 return [
17524 3,
17525 12
17526 ];
17527 case 11:
17528 e2 = _state.sent();
17529 node2 = stack[stack.length - 1].node;
17530 throw _this.handleError(e2, node2);
17531 case 12:
17532 return [
17533 3,
17534 8
17535 ];
17536 case 13:
17537 return [
17538 3,
17539 7
17540 ];
17541 case 14:
17542 if (!_this.listeners.OnceExit) return [
17543 3,
17544 18
17545 ];
17546 _loop = function() {
17547 var _step_value, plugin22, visitor, roots, e2;
17548 return _ts_generator(this, function(_state) {
17549 switch(_state.label){
17550 case 0:
17551 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
17552 _this.result.lastPlugin = plugin22;
17553 _state.label = 1;
17554 case 1:
17555 _state.trys.push([
17556 1,
17557 6,
17558 ,
17559 7
17560 ]);
17561 if (!(root2.type === "document")) return [
17562 3,
17563 3
17564 ];
17565 roots = root2.nodes.map(function(subRoot) {
17566 return visitor(subRoot, _this.helpers);
17567 });
17568 return [
17569 4,
17570 Promise.all(roots)
17571 ];
17572 case 2:
17573 _state.sent();
17574 return [
17575 3,
17576 5
17577 ];
17578 case 3:
17579 return [
17580 4,
17581 visitor(root2, _this.helpers)
17582 ];
17583 case 4:
17584 _state.sent();
17585 _state.label = 5;
17586 case 5:
17587 return [
17588 3,
17589 7
17590 ];
17591 case 6:
17592 e2 = _state.sent();
17593 throw _this.handleError(e2);
17594 case 7:
17595 return [
17596 2
17597 ];
17598 }
17599 });
17600 };
17601 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
17602 _state.label = 15;
17603 case 15:
17604 if (!!(_step = _iterator()).done) return [
17605 3,
17606 18
17607 ];
17608 return [
17609 5,
17610 _ts_values(_loop())
17611 ];
17612 case 16:
17613 _state.sent();
17614 _state.label = 17;
17615 case 17:
17616 return [
17617 3,
17618 15
17619 ];
17620 case 18:
17621 _this.processed = true;
17622 return [
17623 2,
17624 _this.stringify()
17625 ];
17626 }
17627 });
17628 })();
17629 };
17630 _proto.runOnRoot = function runOnRoot(plugin22) {
17631 var _this = this;
17632 this.result.lastPlugin = plugin22;
17633 try {
17634 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
17635 if (this.result.root.type === "document") {
17636 var roots = this.result.root.nodes.map(function(root2) {
17637 return plugin22.Once(root2, _this.helpers);
17638 });
17639 if (isPromise(roots[0])) {
17640 return Promise.all(roots);
17641 }
17642 return roots;
17643 }
17644 return plugin22.Once(this.result.root, this.helpers);
17645 } else if (typeof plugin22 === "function") {
17646 return plugin22(this.result.root, this.result);
17647 }
17648 } catch (error) {
17649 throw this.handleError(error);
17650 }
17651 };
17652 _proto.stringify = function stringify() {
17653 if (this.error) throw this.error;
17654 if (this.stringified) return this.result;
17655 this.stringified = true;
17656 this.sync();
17657 var opts = this.result.opts;
17658 var str = stringify$2;
17659 if (opts.syntax) str = opts.syntax.stringify;
17660 if (opts.stringifier) str = opts.stringifier;
17661 if (str.stringify) str = str.stringify;
17662 var map = new MapGenerator$1(str, this.result.root, this.result.opts);
17663 var data = map.generate();
17664 this.result.css = data[0];
17665 this.result.map = data[1];
17666 return this.result;
17667 };
17668 _proto.sync = function sync() {
17669 if (this.error) throw this.error;
17670 if (this.processed) return this.result;
17671 this.processed = true;
17672 if (this.processing) {
17673 throw this.getAsyncError();
17674 }
17675 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17676 var plugin22 = _step.value;
17677 var promise = this.runOnRoot(plugin22);
17678 if (isPromise(promise)) {
17679 throw this.getAsyncError();
17680 }
17681 }
17682 this.prepareVisitors();
17683 if (this.hasListener) {
17684 var root2 = this.result.root;
17685 while(!root2[isClean]){
17686 root2[isClean] = true;
17687 this.walkSync(root2);
17688 }
17689 if (this.listeners.OnceExit) {
17690 if (root2.type === "document") {
17691 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
17692 var subRoot = _step1.value;
17693 this.visitSync(this.listeners.OnceExit, subRoot);
17694 }
17695 } else {
17696 this.visitSync(this.listeners.OnceExit, root2);
17697 }
17698 }
17699 }
17700 return this.result;
17701 };
17702 _proto.then = function then(onFulfilled, onRejected) {
17703 if (true) {
17704 if (!("from" in this.opts)) {
17705 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.");
17706 }
17707 }
17708 return this.async().then(onFulfilled, onRejected);
17709 };
17710 _proto.toString = function toString() {
17711 return this.css;
17712 };
17713 _proto.visitSync = function visitSync(visitors, node2) {
17714 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
17715 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
17716 this.result.lastPlugin = plugin22;
17717 var promise = void 0;
17718 try {
17719 promise = visitor(node2, this.helpers);
17720 } catch (e2) {
17721 throw this.handleError(e2, node2.proxyOf);
17722 }
17723 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
17724 return true;
17725 }
17726 if (isPromise(promise)) {
17727 throw this.getAsyncError();
17728 }
17729 }
17730 };
17731 _proto.visitTick = function visitTick(stack) {
17732 var visit2 = stack[stack.length - 1];
17733 var node2 = visit2.node, visitors = visit2.visitors;
17734 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
17735 stack.pop();
17736 return;
17737 }
17738 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
17739 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
17740 visit2.visitorIndex += 1;
17741 if (visit2.visitorIndex === visitors.length) {
17742 visit2.visitors = [];
17743 visit2.visitorIndex = 0;
17744 }
17745 this.result.lastPlugin = plugin22;
17746 try {
17747 return visitor(node2.toProxy(), this.helpers);
17748 } catch (e2) {
17749 throw this.handleError(e2, node2);
17750 }
17751 }
17752 if (visit2.iterator !== 0) {
17753 var iterator = visit2.iterator;
17754 var child;
17755 while(child = node2.nodes[node2.indexes[iterator]]){
17756 node2.indexes[iterator] += 1;
17757 if (!child[isClean]) {
17758 child[isClean] = true;
17759 stack.push(toStack(child));
17760 return;
17761 }
17762 }
17763 visit2.iterator = 0;
17764 delete node2.indexes[iterator];
17765 }
17766 var events = visit2.events;
17767 while(visit2.eventIndex < events.length){
17768 var event = events[visit2.eventIndex];
17769 visit2.eventIndex += 1;
17770 if (event === CHILDREN) {
17771 if (node2.nodes && node2.nodes.length) {
17772 node2[isClean] = true;
17773 visit2.iterator = node2.getIterator();
17774 }
17775 return;
17776 } else if (this.listeners[event]) {
17777 visit2.visitors = this.listeners[event];
17778 return;
17779 }
17780 }
17781 stack.pop();
17782 };
17783 _proto.walkSync = function walkSync(node2) {
17784 var _this = this;
17785 node2[isClean] = true;
17786 var events = getEvents(node2);
17787 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
17788 var event = _step.value;
17789 if (event === CHILDREN) {
17790 if (node2.nodes) {
17791 node2.each(function(child) {
17792 if (!child[isClean]) _this.walkSync(child);
17793 });
17794 }
17795 } else {
17796 var visitors = this.listeners[event];
17797 if (visitors) {
17798 if (this.visitSync(visitors, node2.toProxy())) return;
17799 }
17800 }
17801 }
17802 };
17803 _proto.warnings = function warnings() {
17804 return this.sync().warnings();
17805 };
17806 _create_class(LazyResult2, [
17807 {
17808 key: "content",
17809 get: function get() {
17810 return this.stringify().content;
17811 }
17812 },
17813 {
17814 key: "css",
17815 get: function get() {
17816 return this.stringify().css;
17817 }
17818 },
17819 {
17820 key: "map",
17821 get: function get() {
17822 return this.stringify().map;
17823 }
17824 },
17825 {
17826 key: "messages",
17827 get: function get() {
17828 return this.sync().messages;
17829 }
17830 },
17831 {
17832 key: "opts",
17833 get: function get() {
17834 return this.result.opts;
17835 }
17836 },
17837 {
17838 key: "processor",
17839 get: function get() {
17840 return this.result.processor;
17841 }
17842 },
17843 {
17844 key: "root",
17845 get: function get() {
17846 return this.sync().root;
17847 }
17848 },
17849 {
17850 key: Symbol.toStringTag,
17851 get: function get() {
17852 return "LazyResult";
17853 }
17854 }
17855 ]);
17856 return LazyResult2;
17857 }();
17858 LazyResult$2.registerPostcss = function(dependant) {
17859 postcss$2 = dependant;
17860 };
17861 var lazyResult = LazyResult$2;
17862 LazyResult$2.default = LazyResult$2;
17863 Root$3.registerLazyResult(LazyResult$2);
17864 Document$2.registerLazyResult(LazyResult$2);
17865 var MapGenerator22 = mapGenerator;
17866 var stringify$1 = stringify_1;
17867 var warnOnce22 = warnOnce$2;
17868 var parse$1 = parse_1;
17869 var Result$1 = result;
17870 var NoWorkResult$1 = /*#__PURE__*/ function() {
17871 function NoWorkResult2(processor2, css, opts) {
17872 css = css.toString();
17873 this.stringified = false;
17874 this._processor = processor2;
17875 this._css = css;
17876 this._opts = opts;
17877 this._map = void 0;
17878 var root2;
17879 var str = stringify$1;
17880 this.result = new Result$1(this._processor, root2, this._opts);
17881 this.result.css = css;
17882 var self = this;
17883 Object.defineProperty(this.result, "root", {
17884 get: function get() {
17885 return self.root;
17886 }
17887 });
17888 var map = new MapGenerator22(str, root2, this._opts, css);
17889 if (map.isMap()) {
17890 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
17891 if (generatedCSS) {
17892 this.result.css = generatedCSS;
17893 }
17894 if (generatedMap) {
17895 this.result.map = generatedMap;
17896 }
17897 } else {
17898 map.clearAnnotation();
17899 this.result.css = map.css;
17900 }
17901 }
17902 var _proto = NoWorkResult2.prototype;
17903 _proto.async = function async() {
17904 if (this.error) return Promise.reject(this.error);
17905 return Promise.resolve(this.result);
17906 };
17907 _proto.catch = function _catch(onRejected) {
17908 return this.async().catch(onRejected);
17909 };
17910 _proto.finally = function _finally(onFinally) {
17911 return this.async().then(onFinally, onFinally);
17912 };
17913 _proto.sync = function sync() {
17914 if (this.error) throw this.error;
17915 return this.result;
17916 };
17917 _proto.then = function then(onFulfilled, onRejected) {
17918 if (true) {
17919 if (!("from" in this._opts)) {
17920 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.");
17921 }
17922 }
17923 return this.async().then(onFulfilled, onRejected);
17924 };
17925 _proto.toString = function toString() {
17926 return this._css;
17927 };
17928 _proto.warnings = function warnings() {
17929 return [];
17930 };
17931 _create_class(NoWorkResult2, [
17932 {
17933 key: "content",
17934 get: function get() {
17935 return this.result.css;
17936 }
17937 },
17938 {
17939 key: "css",
17940 get: function get() {
17941 return this.result.css;
17942 }
17943 },
17944 {
17945 key: "map",
17946 get: function get() {
17947 return this.result.map;
17948 }
17949 },
17950 {
17951 key: "messages",
17952 get: function get() {
17953 return [];
17954 }
17955 },
17956 {
17957 key: "opts",
17958 get: function get() {
17959 return this.result.opts;
17960 }
17961 },
17962 {
17963 key: "processor",
17964 get: function get() {
17965 return this.result.processor;
17966 }
17967 },
17968 {
17969 key: "root",
17970 get: function get() {
17971 if (this._root) {
17972 return this._root;
17973 }
17974 var root2;
17975 var parser2 = parse$1;
17976 try {
17977 root2 = parser2(this._css, this._opts);
17978 } catch (error) {
17979 this.error = error;
17980 }
17981 if (this.error) {
17982 throw this.error;
17983 } else {
17984 this._root = root2;
17985 return root2;
17986 }
17987 }
17988 },
17989 {
17990 key: Symbol.toStringTag,
17991 get: function get() {
17992 return "NoWorkResult";
17993 }
17994 }
17995 ]);
17996 return NoWorkResult2;
17997 }();
17998 var noWorkResult = NoWorkResult$1;
17999 NoWorkResult$1.default = NoWorkResult$1;
18000 var NoWorkResult22 = noWorkResult;
18001 var LazyResult$1 = lazyResult;
18002 var Document$1 = document$1$2;
18003 var Root$2 = root;
18004 var Processor$1 = /*#__PURE__*/ function() {
18005 function Processor2(plugins) {
18006 if (plugins === void 0) plugins = [];
18007 this.version = "8.4.38";
18008 this.plugins = this.normalize(plugins);
18009 }
18010 var _proto = Processor2.prototype;
18011 _proto.normalize = function normalize(plugins) {
18012 var normalized = [];
18013 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
18014 var i2 = _step.value;
18015 if (i2.postcss === true) {
18016 i2 = i2();
18017 } else if (i2.postcss) {
18018 i2 = i2.postcss;
18019 }
18020 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
18021 normalized = normalized.concat(i2.plugins);
18022 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
18023 normalized.push(i2);
18024 } else if (typeof i2 === "function") {
18025 normalized.push(i2);
18026 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
18027 if (true) {
18028 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.");
18029 }
18030 } else {
18031 throw new Error(i2 + " is not a PostCSS plugin");
18032 }
18033 }
18034 return normalized;
18035 };
18036 _proto.process = function process1(css, opts) {
18037 if (opts === void 0) opts = {};
18038 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
18039 return new NoWorkResult22(this, css, opts);
18040 } else {
18041 return new LazyResult$1(this, css, opts);
18042 }
18043 };
18044 _proto.use = function use(plugin22) {
18045 this.plugins = this.plugins.concat(this.normalize([
18046 plugin22
18047 ]));
18048 return this;
18049 };
18050 return Processor2;
18051 }();
18052 var processor = Processor$1;
18053 Processor$1.default = Processor$1;
18054 Root$2.registerProcessor(Processor$1);
18055 Document$1.registerProcessor(Processor$1);
18056 var Declaration$1 = declaration;
18057 var PreviousMap22 = previousMap;
18058 var Comment$1 = comment;
18059 var AtRule$1 = atRule;
18060 var Input$1 = input;
18061 var Root$1 = root;
18062 var Rule$1 = rule;
18063 function fromJSON$1(json, inputs) {
18064 if (Array.isArray(json)) return json.map(function(n2) {
18065 return fromJSON$1(n2);
18066 });
18067 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
18068 "inputs"
18069 ]);
18070 if (ownInputs) {
18071 inputs = [];
18072 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
18073 var input2 = _step.value;
18074 var inputHydrated = _extends({}, input2, {
18075 __proto__: Input$1.prototype
18076 });
18077 if (inputHydrated.map) {
18078 inputHydrated.map = _extends({}, inputHydrated.map, {
18079 __proto__: PreviousMap22.prototype
18080 });
18081 }
18082 inputs.push(inputHydrated);
18083 }
18084 }
18085 if (defaults.nodes) {
18086 defaults.nodes = json.nodes.map(function(n2) {
18087 return fromJSON$1(n2, inputs);
18088 });
18089 }
18090 if (defaults.source) {
18091 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
18092 "inputId"
18093 ]);
18094 defaults.source = source;
18095 if (inputId != null) {
18096 defaults.source.input = inputs[inputId];
18097 }
18098 }
18099 if (defaults.type === "root") {
18100 return new Root$1(defaults);
18101 } else if (defaults.type === "decl") {
18102 return new Declaration$1(defaults);
18103 } else if (defaults.type === "rule") {
18104 return new Rule$1(defaults);
18105 } else if (defaults.type === "comment") {
18106 return new Comment$1(defaults);
18107 } else if (defaults.type === "atrule") {
18108 return new AtRule$1(defaults);
18109 } else {
18110 throw new Error("Unknown node type: " + json.type);
18111 }
18112 }
18113 var fromJSON_1 = fromJSON$1;
18114 fromJSON$1.default = fromJSON$1;
18115 var CssSyntaxError22 = cssSyntaxError;
18116 var Declaration22 = declaration;
18117 var LazyResult22 = lazyResult;
18118 var Container22 = container;
18119 var Processor22 = processor;
18120 var stringify = stringify_1;
18121 var fromJSON = fromJSON_1;
18122 var Document222 = document$1$2;
18123 var Warning22 = warning;
18124 var Comment22 = comment;
18125 var AtRule22 = atRule;
18126 var Result22 = result;
18127 var Input22 = input;
18128 var parse = parse_1;
18129 var list = list_1;
18130 var Rule22 = rule;
18131 var Root22 = root;
18132 var Node22 = node;
18133 function postcss() {
18134 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
18135 plugins[_key] = arguments[_key];
18136 }
18137 if (plugins.length === 1 && Array.isArray(plugins[0])) {
18138 plugins = plugins[0];
18139 }
18140 return new Processor22(plugins);
18141 }
18142 postcss.plugin = function plugin2(name, initializer) {
18143 var warningPrinted = false;
18144 function creator() {
18145 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18146 args[_key] = arguments[_key];
18147 }
18148 if (console && console.warn && !warningPrinted) {
18149 warningPrinted = true;
18150 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
18151 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
18152 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
18153 }
18154 }
18155 var transformer = initializer.apply(void 0, [].concat(args));
18156 transformer.postcssPlugin = name;
18157 transformer.postcssVersion = new Processor22().version;
18158 return transformer;
18159 }
18160 var cache;
18161 Object.defineProperty(creator, "postcss", {
18162 get: function get() {
18163 if (!cache) cache = creator();
18164 return cache;
18165 }
18166 });
18167 creator.process = function(css, processOpts, pluginOpts) {
18168 return postcss([
18169 creator(pluginOpts)
18170 ]).process(css, processOpts);
18171 };
18172 return creator;
18173 };
18174 postcss.stringify = stringify;
18175 postcss.parse = parse;
18176 postcss.fromJSON = fromJSON;
18177 postcss.list = list;
18178 postcss.comment = function(defaults) {
18179 return new Comment22(defaults);
18180 };
18181 postcss.atRule = function(defaults) {
18182 return new AtRule22(defaults);
18183 };
18184 postcss.decl = function(defaults) {
18185 return new Declaration22(defaults);
18186 };
18187 postcss.rule = function(defaults) {
18188 return new Rule22(defaults);
18189 };
18190 postcss.root = function(defaults) {
18191 return new Root22(defaults);
18192 };
18193 postcss.document = function(defaults) {
18194 return new Document222(defaults);
18195 };
18196 postcss.CssSyntaxError = CssSyntaxError22;
18197 postcss.Declaration = Declaration22;
18198 postcss.Container = Container22;
18199 postcss.Processor = Processor22;
18200 postcss.Document = Document222;
18201 postcss.Comment = Comment22;
18202 postcss.Warning = Warning22;
18203 postcss.AtRule = AtRule22;
18204 postcss.Result = Result22;
18205 postcss.Input = Input22;
18206 postcss.Rule = Rule22;
18207 postcss.Root = Root22;
18208 postcss.Node = Node22;
18209 LazyResult22.registerPostcss(postcss);
18210 var postcss_1 = postcss;
18211 postcss.default = postcss;
18212 var postcss$1 = /* @__PURE__ */ getDefaultExportFromCjs(postcss_1);
18213 postcss$1.stringify;
18214 postcss$1.fromJSON;
18215 postcss$1.plugin;
18216 postcss$1.parse;
18217 postcss$1.list;
18218 postcss$1.document;
18219 postcss$1.comment;
18220 postcss$1.atRule;
18221 postcss$1.rule;
18222 postcss$1.decl;
18223 postcss$1.root;
18224 postcss$1.CssSyntaxError;
18225 postcss$1.Declaration;
18226 postcss$1.Container;
18227 postcss$1.Processor;
18228 postcss$1.Document;
18229 postcss$1.Comment;
18230 postcss$1.Warning;
18231 postcss$1.AtRule;
18232 postcss$1.Result;
18233 postcss$1.Input;
18234 postcss$1.Rule;
18235 postcss$1.Root;
18236 postcss$1.Node;
18237 var BaseRRNode = /*#__PURE__*/ function() {
18238 function BaseRRNode() {
18239 for(var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++){
18240 _args[_key] = arguments[_key];
18241 }
18242 __publicField2(this, "parentElement", null);
18243 __publicField2(this, "parentNode", null);
18244 __publicField2(this, "ownerDocument");
18245 __publicField2(this, "firstChild", null);
18246 __publicField2(this, "lastChild", null);
18247 __publicField2(this, "previousSibling", null);
18248 __publicField2(this, "nextSibling", null);
18249 __publicField2(this, "ELEMENT_NODE", 1);
18250 __publicField2(this, "TEXT_NODE", 3);
18251 __publicField2(this, "nodeType");
18252 __publicField2(this, "nodeName");
18253 __publicField2(this, "RRNodeType");
18254 }
18255 var _proto = BaseRRNode.prototype;
18256 _proto.contains = function contains(node2) {
18257 if (!_instanceof(node2, BaseRRNode)) return false;
18258 else if (node2.ownerDocument !== this.ownerDocument) return false;
18259 else if (node2 === this) return true;
18260 while(node2.parentNode){
18261 if (node2.parentNode === this) return true;
18262 node2 = node2.parentNode;
18263 }
18264 return false;
18265 };
18266 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18267 _proto.appendChild = function appendChild(_newChild) {
18268 throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.");
18269 };
18270 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18271 _proto.insertBefore = function insertBefore(_newChild, _refChild) {
18272 throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.");
18273 };
18274 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18275 _proto.removeChild = function removeChild(_node) {
18276 throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.");
18277 };
18278 _proto.toString = function toString() {
18279 return "RRNode";
18280 };
18281 _create_class(BaseRRNode, [
18282 {
18283 key: "childNodes",
18284 get: function get() {
18285 var childNodes2 = [];
18286 var childIterator = this.firstChild;
18287 while(childIterator){
18288 childNodes2.push(childIterator);
18289 childIterator = childIterator.nextSibling;
18290 }
18291 return childNodes2;
18292 }
18293 }
18294 ]);
18295 return BaseRRNode;
18296 }();
18297 var testableAccessors = {
18298 Node: [
18299 "childNodes",
18300 "parentNode",
18301 "parentElement",
18302 "textContent"
18303 ],
18304 ShadowRoot: [
18305 "host",
18306 "styleSheets"
18307 ],
18308 Element: [
18309 "shadowRoot",
18310 "querySelector",
18311 "querySelectorAll"
18312 ],
18313 MutationObserver: []
18314 };
18315 var testableMethods = {
18316 Node: [
18317 "contains",
18318 "getRootNode"
18319 ],
18320 ShadowRoot: [
18321 "getSelection"
18322 ],
18323 Element: [],
18324 MutationObserver: [
18325 "constructor"
18326 ]
18327 };
18328 var untaintedBasePrototype = {};
18329 var isAngularZonePresent = function() {
18330 return !!globalThis.Zone;
18331 };
18332 function getUntaintedPrototype(key) {
18333 if (untaintedBasePrototype[key]) return untaintedBasePrototype[key];
18334 var defaultObj = globalThis[key];
18335 var defaultPrototype = defaultObj.prototype;
18336 var accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
18337 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
18338 accessorNames.every(function(accessor) {
18339 var _a2, _b;
18340 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
18341 }));
18342 var methodNames = key in testableMethods ? testableMethods[key] : void 0;
18343 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
18344 function(method) {
18345 var _a2;
18346 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
18347 }));
18348 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {
18349 untaintedBasePrototype[key] = defaultObj.prototype;
18350 return defaultObj.prototype;
18351 }
18352 try {
18353 var iframeEl = document.createElement("iframe");
18354 document.body.appendChild(iframeEl);
18355 var win = iframeEl.contentWindow;
18356 if (!win) return defaultObj.prototype;
18357 var untaintedObject = win[key].prototype;
18358 document.body.removeChild(iframeEl);
18359 if (!untaintedObject) return defaultPrototype;
18360 return untaintedBasePrototype[key] = untaintedObject;
18361 } catch (e) {
18362 return defaultPrototype;
18363 }
18364 }
18365 var untaintedAccessorCache = {};
18366 function getUntaintedAccessor(key, instance, accessor) {
18367 var _a2;
18368 var cacheKey = key + "." + String(accessor);
18369 if (untaintedAccessorCache[cacheKey]) return untaintedAccessorCache[cacheKey].call(instance);
18370 var untaintedPrototype = getUntaintedPrototype(key);
18371 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
18372 if (!untaintedAccessor) return instance[accessor];
18373 untaintedAccessorCache[cacheKey] = untaintedAccessor;
18374 return untaintedAccessor.call(instance);
18375 }
18376 var untaintedMethodCache = {};
18377 function getUntaintedMethod(key, instance, method) {
18378 var cacheKey = key + "." + String(method);
18379 if (untaintedMethodCache[cacheKey]) return untaintedMethodCache[cacheKey].bind(instance);
18380 var untaintedPrototype = getUntaintedPrototype(key);
18381 var untaintedMethod = untaintedPrototype[method];
18382 if (typeof untaintedMethod !== "function") return instance[method];
18383 untaintedMethodCache[cacheKey] = untaintedMethod;
18384 return untaintedMethod.bind(instance);
18385 }
18386 function childNodes(n2) {
18387 return getUntaintedAccessor("Node", n2, "childNodes");
18388 }
18389 function parentNode(n2) {
18390 return getUntaintedAccessor("Node", n2, "parentNode");
18391 }
18392 function parentElement(n2) {
18393 return getUntaintedAccessor("Node", n2, "parentElement");
18394 }
18395 function textContent(n2) {
18396 return getUntaintedAccessor("Node", n2, "textContent");
18397 }
18398 function contains(n2, other) {
18399 return getUntaintedMethod("Node", n2, "contains")(other);
18400 }
18401 function getRootNode(n2) {
18402 return getUntaintedMethod("Node", n2, "getRootNode")();
18403 }
18404 function host(n2) {
18405 if (!n2 || !("host" in n2)) return null;
18406 return getUntaintedAccessor("ShadowRoot", n2, "host");
18407 }
18408 function styleSheets(n2) {
18409 return n2.styleSheets;
18410 }
18411 function shadowRoot(n2) {
18412 if (!n2 || !("shadowRoot" in n2)) return null;
18413 return getUntaintedAccessor("Element", n2, "shadowRoot");
18414 }
18415 function querySelector(n2, selectors) {
18416 return getUntaintedAccessor("Element", n2, "querySelector")(selectors);
18417 }
18418 function querySelectorAll(n2, selectors) {
18419 return getUntaintedAccessor("Element", n2, "querySelectorAll")(selectors);
18420 }
18421 function mutationObserverCtor() {
18422 return getUntaintedPrototype("MutationObserver").constructor;
18423 }
18424 function patch(source, name, replacement) {
18425 try {
18426 if (!(name in source)) {
18427 return function() {};
18428 }
18429 var original = source[name];
18430 var wrapped = replacement(original);
18431 if (typeof wrapped === "function") {
18432 wrapped.prototype = wrapped.prototype || {};
18433 Object.defineProperties(wrapped, {
18434 __rrweb_original__: {
18435 enumerable: false,
18436 value: original
18437 }
18438 });
18439 }
18440 source[name] = wrapped;
18441 return function() {
18442 source[name] = original;
18443 };
18444 } catch (e) {
18445 return function() {};
18446 }
18447 }
18448 var index = {
18449 childNodes: childNodes,
18450 parentNode: parentNode,
18451 parentElement: parentElement,
18452 textContent: textContent,
18453 contains: contains,
18454 getRootNode: getRootNode,
18455 host: host,
18456 styleSheets: styleSheets,
18457 shadowRoot: shadowRoot,
18458 querySelector: querySelector,
18459 querySelectorAll: querySelectorAll,
18460 mutationObserver: mutationObserverCtor,
18461 patch: patch
18462 };
18463 function on(type, fn, target) {
18464 if (target === void 0) target = document;
18465 var options = {
18466 capture: true,
18467 passive: true
18468 };
18469 target.addEventListener(type, fn, options);
18470 return function() {
18471 return target.removeEventListener(type, fn, options);
18472 };
18473 }
18474 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.";
18475 var _mirror = {
18476 map: {},
18477 getId: function getId() {
18478 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18479 return -1;
18480 },
18481 getNode: function getNode() {
18482 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18483 return null;
18484 },
18485 removeNodeFromMap: function removeNodeFromMap() {
18486 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18487 },
18488 has: function has() {
18489 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18490 return false;
18491 },
18492 reset: function reset() {
18493 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18494 }
18495 };
18496 if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
18497 _mirror = new Proxy(_mirror, {
18498 get: function get(target, prop, receiver) {
18499 if (prop === "map") {
18500 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18501 }
18502 return Reflect.get(target, prop, receiver);
18503 }
18504 });
18505 }
18506 function throttle(func, wait, options) {
18507 if (options === void 0) options = {};
18508 var timeout = null;
18509 var previous = 0;
18510 return function() {
18511 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18512 args[_key] = arguments[_key];
18513 }
18514 var now = Date.now();
18515 if (!previous && options.leading === false) {
18516 previous = now;
18517 }
18518 var remaining = wait - (now - previous);
18519 var context = this;
18520 if (remaining <= 0 || remaining > wait) {
18521 if (timeout) {
18522 clearTimeout(timeout);
18523 timeout = null;
18524 }
18525 previous = now;
18526 func.apply(context, args);
18527 } else if (!timeout && options.trailing !== false) {
18528 timeout = setTimeout(function() {
18529 previous = options.leading === false ? 0 : Date.now();
18530 timeout = null;
18531 func.apply(context, args);
18532 }, remaining);
18533 }
18534 };
18535 }
18536 function hookSetter(target, key, d, isRevoked, win) {
18537 if (win === void 0) win = window;
18538 var original = win.Object.getOwnPropertyDescriptor(target, key);
18539 win.Object.defineProperty(target, key, isRevoked ? d : {
18540 set: function set(value) {
18541 var _this = this;
18542 setTimeout(function() {
18543 d.set.call(_this, value);
18544 }, 0);
18545 if (original && original.set) {
18546 original.set.call(this, value);
18547 }
18548 }
18549 });
18550 return function() {
18551 return hookSetter(target, key, original || {}, true);
18552 };
18553 }
18554 var nowTimestamp = Date.now;
18555 if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
18556 nowTimestamp = function() {
18557 return /* @__PURE__ */ new Date().getTime();
18558 };
18559 }
18560 function getWindowScroll(win) {
18561 var _a2, _b, _c, _d;
18562 var doc = win.document;
18563 return {
18564 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,
18565 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
18566 };
18567 }
18568 function getWindowHeight() {
18569 return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
18570 }
18571 function getWindowWidth() {
18572 return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
18573 }
18574 function closestElementOfNode(node2) {
18575 if (!node2) {
18576 return null;
18577 }
18578 var el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index.parentElement(node2);
18579 return el;
18580 }
18581 function isBlocked(node2, blockClass, blockSelector, checkAncestors) {
18582 if (!node2) {
18583 return false;
18584 }
18585 var el = closestElementOfNode(node2);
18586 if (!el) {
18587 return false;
18588 }
18589 try {
18590 if (typeof blockClass === "string") {
18591 if (el.classList.contains(blockClass)) return true;
18592 if (checkAncestors && el.closest("." + blockClass) !== null) return true;
18593 } else {
18594 if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
18595 }
18596 } catch (e2) {}
18597 if (blockSelector) {
18598 if (el.matches(blockSelector)) return true;
18599 if (checkAncestors && el.closest(blockSelector) !== null) return true;
18600 }
18601 return false;
18602 }
18603 function isSerialized(n2, mirror2) {
18604 return mirror2.getId(n2) !== -1;
18605 }
18606 function isIgnored(n2, mirror2, slimDOMOptions) {
18607 if (n2.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
18608 return true;
18609 }
18610 return mirror2.getId(n2) === IGNORED_NODE;
18611 }
18612 function isAncestorRemoved(target, mirror2) {
18613 if (isShadowRoot(target)) {
18614 return false;
18615 }
18616 var id = mirror2.getId(target);
18617 if (!mirror2.has(id)) {
18618 return true;
18619 }
18620 var parent = index.parentNode(target);
18621 if (parent && parent.nodeType === target.DOCUMENT_NODE) {
18622 return false;
18623 }
18624 if (!parent) {
18625 return true;
18626 }
18627 return isAncestorRemoved(parent, mirror2);
18628 }
18629 function legacy_isTouchEvent(event) {
18630 return Boolean(event.changedTouches);
18631 }
18632 function polyfill$1(win) {
18633 if (win === void 0) win = window;
18634 if ("NodeList" in win && !win.NodeList.prototype.forEach) {
18635 win.NodeList.prototype.forEach = Array.prototype.forEach;
18636 }
18637 if ("DOMTokenList" in win && !win.DOMTokenList.prototype.forEach) {
18638 win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
18639 }
18640 }
18641 function isSerializedIframe(n2, mirror2) {
18642 return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
18643 }
18644 function isSerializedStylesheet(n2, mirror2) {
18645 return Boolean(n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2));
18646 }
18647 function hasShadowRoot(n2) {
18648 if (!n2) return false;
18649 if (_instanceof(n2, BaseRRNode) && "shadowRoot" in n2) {
18650 return Boolean(n2.shadowRoot);
18651 }
18652 return Boolean(index.shadowRoot(n2));
18653 }
18654 var StyleSheetMirror = /*#__PURE__*/ function() {
18655 function StyleSheetMirror() {
18656 __publicField(this, "id", 1);
18657 __publicField(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
18658 __publicField(this, "idStyleMap", /* @__PURE__ */ new Map());
18659 }
18660 var _proto = StyleSheetMirror.prototype;
18661 _proto.getId = function getId(stylesheet) {
18662 var _this_styleIDMap_get;
18663 return (_this_styleIDMap_get = this.styleIDMap.get(stylesheet)) != null ? _this_styleIDMap_get : -1;
18664 };
18665 _proto.has = function has(stylesheet) {
18666 return this.styleIDMap.has(stylesheet);
18667 };
18668 /**
18669 * @returns If the stylesheet is in the mirror, returns the id of the stylesheet. If not, return the new assigned id.
18670 */ _proto.add = function add(stylesheet, id) {
18671 if (this.has(stylesheet)) return this.getId(stylesheet);
18672 var newId;
18673 if (id === void 0) {
18674 newId = this.id++;
18675 } else newId = id;
18676 this.styleIDMap.set(stylesheet, newId);
18677 this.idStyleMap.set(newId, stylesheet);
18678 return newId;
18679 };
18680 _proto.getStyle = function getStyle(id) {
18681 return this.idStyleMap.get(id) || null;
18682 };
18683 _proto.reset = function reset() {
18684 this.styleIDMap = /* @__PURE__ */ new WeakMap();
18685 this.idStyleMap = /* @__PURE__ */ new Map();
18686 this.id = 1;
18687 };
18688 _proto.generateId = function generateId() {
18689 return this.id++;
18690 };
18691 return StyleSheetMirror;
18692 }();
18693 function getShadowHost(n2) {
18694 var _a2;
18695 var shadowHost = null;
18696 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));
18697 return shadowHost;
18698 }
18699 function getRootShadowHost(n2) {
18700 var rootShadowHost = n2;
18701 var shadowHost;
18702 while(shadowHost = getShadowHost(rootShadowHost))rootShadowHost = shadowHost;
18703 return rootShadowHost;
18704 }
18705 function shadowHostInDom(n2) {
18706 var doc = n2.ownerDocument;
18707 if (!doc) return false;
18708 var shadowHost = getRootShadowHost(n2);
18709 return index.contains(doc, shadowHost);
18710 }
18711 function inDom(n2) {
18712 var doc = n2.ownerDocument;
18713 if (!doc) return false;
18714 return index.contains(doc, n2) || shadowHostInDom(n2);
18715 }
18716 var EventType = /* @__PURE__ */ function(EventType2) {
18717 EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
18718 EventType2[EventType2["Load"] = 1] = "Load";
18719 EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
18720 EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
18721 EventType2[EventType2["Meta"] = 4] = "Meta";
18722 EventType2[EventType2["Custom"] = 5] = "Custom";
18723 EventType2[EventType2["Plugin"] = 6] = "Plugin";
18724 return EventType2;
18725 }(EventType || {});
18726 var IncrementalSource = /* @__PURE__ */ function(IncrementalSource2) {
18727 IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
18728 IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
18729 IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
18730 IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
18731 IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
18732 IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
18733 IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
18734 IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
18735 IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
18736 IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
18737 IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
18738 IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
18739 IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
18740 IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
18741 IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
18742 IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
18743 IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
18744 return IncrementalSource2;
18745 }(IncrementalSource || {});
18746 var MouseInteractions = /* @__PURE__ */ function(MouseInteractions2) {
18747 MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
18748 MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
18749 MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
18750 MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
18751 MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
18752 MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
18753 MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
18754 MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
18755 MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
18756 MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
18757 MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
18758 return MouseInteractions2;
18759 }(MouseInteractions || {});
18760 var PointerTypes = /* @__PURE__ */ function(PointerTypes2) {
18761 PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
18762 PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
18763 PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
18764 return PointerTypes2;
18765 }(PointerTypes || {});
18766 var CanvasContext = /* @__PURE__ */ function(CanvasContext2) {
18767 CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
18768 CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
18769 CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
18770 return CanvasContext2;
18771 }(CanvasContext || {});
18772 var MediaInteractions = /* @__PURE__ */ function(MediaInteractions2) {
18773 MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
18774 MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
18775 MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
18776 MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
18777 MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
18778 return MediaInteractions2;
18779 }(MediaInteractions || {});
18780 var NodeType = /* @__PURE__ */ function(NodeType2) {
18781 NodeType2[NodeType2["Document"] = 0] = "Document";
18782 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
18783 NodeType2[NodeType2["Element"] = 2] = "Element";
18784 NodeType2[NodeType2["Text"] = 3] = "Text";
18785 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
18786 NodeType2[NodeType2["Comment"] = 5] = "Comment";
18787 return NodeType2;
18788 }(NodeType || {});
18789 function isNodeInLinkedList(n2) {
18790 return "__ln" in n2;
18791 }
18792 var DoubleLinkedList = /*#__PURE__*/ function() {
18793 function DoubleLinkedList() {
18794 __publicField(this, "length", 0);
18795 __publicField(this, "head", null);
18796 __publicField(this, "tail", null);
18797 }
18798 var _proto = DoubleLinkedList.prototype;
18799 _proto.get = function get(position) {
18800 if (position >= this.length) {
18801 throw new Error("Position outside of list range");
18802 }
18803 var current = this.head;
18804 for(var index2 = 0; index2 < position; index2++){
18805 current = (current == null ? void 0 : current.next) || null;
18806 }
18807 return current;
18808 };
18809 _proto.addNode = function addNode(n2) {
18810 var node2 = {
18811 value: n2,
18812 previous: null,
18813 next: null
18814 };
18815 n2.__ln = node2;
18816 if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
18817 var current = n2.previousSibling.__ln.next;
18818 node2.next = current;
18819 node2.previous = n2.previousSibling.__ln;
18820 n2.previousSibling.__ln.next = node2;
18821 if (current) {
18822 current.previous = node2;
18823 }
18824 } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
18825 var current1 = n2.nextSibling.__ln.previous;
18826 node2.previous = current1;
18827 node2.next = n2.nextSibling.__ln;
18828 n2.nextSibling.__ln.previous = node2;
18829 if (current1) {
18830 current1.next = node2;
18831 }
18832 } else {
18833 if (this.head) {
18834 this.head.previous = node2;
18835 }
18836 node2.next = this.head;
18837 this.head = node2;
18838 }
18839 if (node2.next === null) {
18840 this.tail = node2;
18841 }
18842 this.length++;
18843 };
18844 _proto.removeNode = function removeNode(n2) {
18845 var current = n2.__ln;
18846 if (!this.head) {
18847 return;
18848 }
18849 if (!current.previous) {
18850 this.head = current.next;
18851 if (this.head) {
18852 this.head.previous = null;
18853 } else {
18854 this.tail = null;
18855 }
18856 } else {
18857 current.previous.next = current.next;
18858 if (current.next) {
18859 current.next.previous = current.previous;
18860 } else {
18861 this.tail = current.previous;
18862 }
18863 }
18864 if (n2.__ln) {
18865 delete n2.__ln;
18866 }
18867 this.length--;
18868 };
18869 return DoubleLinkedList;
18870 }();
18871 var moveKey = function(id, parentId) {
18872 return id + "@" + parentId;
18873 };
18874 var MutationBuffer = /*#__PURE__*/ function() {
18875 function MutationBuffer() {
18876 var _this = this;
18877 __publicField(this, "frozen", false);
18878 __publicField(this, "locked", false);
18879 __publicField(this, "texts", []);
18880 __publicField(this, "attributes", []);
18881 __publicField(this, "attributeMap", /* @__PURE__ */ new WeakMap());
18882 __publicField(this, "removes", []);
18883 __publicField(this, "mapRemoves", []);
18884 __publicField(this, "movedMap", {});
18885 /**
18886 * the browser MutationObserver emits multiple mutations after
18887 * a delay for performance reasons, making tracing added nodes hard
18888 * in our `processMutations` callback function.
18889 * For example, if we append an element el_1 into body, and then append
18890 * another element el_2 into el_1, these two mutations may be passed to the
18891 * callback function together when the two operations were done.
18892 * Generally we need to trace child nodes of newly added nodes, but in this
18893 * case if we count el_2 as el_1's child node in the first mutation record,
18894 * then we will count el_2 again in the second mutation record which was
18895 * duplicated.
18896 * To avoid of duplicate counting added nodes, we use a Set to store
18897 * added nodes and its child nodes during iterate mutation records. Then
18898 * collect added nodes from the Set which have no duplicate copy. But
18899 * this also causes newly added nodes will not be serialized with id ASAP,
18900 * which means all the id related calculation should be lazy too.
18901 */ __publicField(this, "addedSet", /* @__PURE__ */ new Set());
18902 __publicField(this, "movedSet", /* @__PURE__ */ new Set());
18903 __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
18904 __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
18905 __publicField(this, "mutationCb");
18906 __publicField(this, "blockClass");
18907 __publicField(this, "blockSelector");
18908 __publicField(this, "maskTextClass");
18909 __publicField(this, "maskTextSelector");
18910 __publicField(this, "inlineStylesheet");
18911 __publicField(this, "maskInputOptions");
18912 __publicField(this, "maskTextFn");
18913 __publicField(this, "maskInputFn");
18914 __publicField(this, "keepIframeSrcFn");
18915 __publicField(this, "recordCanvas");
18916 __publicField(this, "inlineImages");
18917 __publicField(this, "slimDOMOptions");
18918 __publicField(this, "dataURLOptions");
18919 __publicField(this, "doc");
18920 __publicField(this, "mirror");
18921 __publicField(this, "iframeManager");
18922 __publicField(this, "stylesheetManager");
18923 __publicField(this, "shadowDomManager");
18924 __publicField(this, "canvasManager");
18925 __publicField(this, "processedNodeManager");
18926 __publicField(this, "unattachedDoc");
18927 __publicField(this, "processMutations", function(mutations) {
18928 mutations.forEach(_this.processMutation);
18929 _this.emit();
18930 });
18931 __publicField(this, "emit", function() {
18932 if (_this.frozen || _this.locked) {
18933 return;
18934 }
18935 var adds = [];
18936 var addedIds = /* @__PURE__ */ new Set();
18937 var addList = new DoubleLinkedList();
18938 var getNextId = function(n2) {
18939 var ns = n2;
18940 var nextId = IGNORED_NODE;
18941 while(nextId === IGNORED_NODE){
18942 ns = ns && ns.nextSibling;
18943 nextId = ns && _this.mirror.getId(ns);
18944 }
18945 return nextId;
18946 };
18947 var pushAdd = function(n2) {
18948 var parent = index.parentNode(n2);
18949 if (!parent || !inDom(n2)) {
18950 return;
18951 }
18952 var cssCaptured = false;
18953 if (n2.nodeType === Node.TEXT_NODE) {
18954 var parentTag = parent.tagName;
18955 if (parentTag === "TEXTAREA") {
18956 return;
18957 } else if (parentTag === "STYLE" && _this.addedSet.has(parent)) {
18958 cssCaptured = true;
18959 }
18960 }
18961 var parentId = isShadowRoot(parent) ? _this.mirror.getId(getShadowHost(n2)) : _this.mirror.getId(parent);
18962 var nextId = getNextId(n2);
18963 if (parentId === -1 || nextId === -1) {
18964 return addList.addNode(n2);
18965 }
18966 var sn = serializeNodeWithId(n2, {
18967 doc: _this.doc,
18968 mirror: _this.mirror,
18969 blockClass: _this.blockClass,
18970 blockSelector: _this.blockSelector,
18971 maskTextClass: _this.maskTextClass,
18972 maskTextSelector: _this.maskTextSelector,
18973 skipChild: true,
18974 newlyAddedElement: true,
18975 inlineStylesheet: _this.inlineStylesheet,
18976 maskInputOptions: _this.maskInputOptions,
18977 maskTextFn: _this.maskTextFn,
18978 maskInputFn: _this.maskInputFn,
18979 slimDOMOptions: _this.slimDOMOptions,
18980 dataURLOptions: _this.dataURLOptions,
18981 recordCanvas: _this.recordCanvas,
18982 inlineImages: _this.inlineImages,
18983 onSerialize: function(currentN) {
18984 if (isSerializedIframe(currentN, _this.mirror)) {
18985 _this.iframeManager.addIframe(currentN);
18986 }
18987 if (isSerializedStylesheet(currentN, _this.mirror)) {
18988 _this.stylesheetManager.trackLinkElement(currentN);
18989 }
18990 if (hasShadowRoot(n2)) {
18991 _this.shadowDomManager.addShadowRoot(index.shadowRoot(n2), _this.doc);
18992 }
18993 },
18994 onIframeLoad: function(iframe, childSn) {
18995 _this.iframeManager.attachIframe(iframe, childSn);
18996 _this.shadowDomManager.observeAttachShadow(iframe);
18997 },
18998 onStylesheetLoad: function(link, childSn) {
18999 _this.stylesheetManager.attachLinkElement(link, childSn);
19000 },
19001 cssCaptured: cssCaptured
19002 });
19003 if (sn) {
19004 adds.push({
19005 parentId: parentId,
19006 nextId: nextId,
19007 node: sn
19008 });
19009 addedIds.add(sn.id);
19010 }
19011 };
19012 while(_this.mapRemoves.length){
19013 _this.mirror.removeNodeFromMap(_this.mapRemoves.shift());
19014 }
19015 for(var _iterator = _create_for_of_iterator_helper_loose(_this.movedSet), _step; !(_step = _iterator()).done;){
19016 var n2 = _step.value;
19017 if (isParentRemoved(_this.removesSubTreeCache, n2, _this.mirror) && !_this.movedSet.has(index.parentNode(n2))) {
19018 continue;
19019 }
19020 pushAdd(n2);
19021 }
19022 for(var _iterator1 = _create_for_of_iterator_helper_loose(_this.addedSet), _step1; !(_step1 = _iterator1()).done;){
19023 var n21 = _step1.value;
19024 if (!isAncestorInSet(_this.droppedSet, n21) && !isParentRemoved(_this.removesSubTreeCache, n21, _this.mirror)) {
19025 pushAdd(n21);
19026 } else if (isAncestorInSet(_this.movedSet, n21)) {
19027 pushAdd(n21);
19028 } else {
19029 _this.droppedSet.add(n21);
19030 }
19031 }
19032 var candidate = null;
19033 while(addList.length){
19034 var node2 = null;
19035 if (candidate) {
19036 var parentId = _this.mirror.getId(index.parentNode(candidate.value));
19037 var nextId = getNextId(candidate.value);
19038 if (parentId !== -1 && nextId !== -1) {
19039 node2 = candidate;
19040 }
19041 }
19042 if (!node2) {
19043 var tailNode = addList.tail;
19044 while(tailNode){
19045 var _node = tailNode;
19046 tailNode = tailNode.previous;
19047 if (_node) {
19048 var parentId1 = _this.mirror.getId(index.parentNode(_node.value));
19049 var nextId1 = getNextId(_node.value);
19050 if (nextId1 === -1) continue;
19051 else if (parentId1 !== -1) {
19052 node2 = _node;
19053 break;
19054 } else {
19055 var unhandledNode = _node.value;
19056 var parent = index.parentNode(unhandledNode);
19057 if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
19058 var shadowHost = index.host(parent);
19059 var parentId2 = _this.mirror.getId(shadowHost);
19060 if (parentId2 !== -1) {
19061 node2 = _node;
19062 break;
19063 }
19064 }
19065 }
19066 }
19067 }
19068 }
19069 if (!node2) {
19070 while(addList.head){
19071 addList.removeNode(addList.head.value);
19072 }
19073 break;
19074 }
19075 candidate = node2.previous;
19076 addList.removeNode(node2.value);
19077 pushAdd(node2.value);
19078 }
19079 var payload = {
19080 texts: _this.texts.map(function(text) {
19081 var n2 = text.node;
19082 var parent = index.parentNode(n2);
19083 if (parent && parent.tagName === "TEXTAREA") {
19084 _this.genTextAreaValueMutation(parent);
19085 }
19086 return {
19087 id: _this.mirror.getId(n2),
19088 value: text.value
19089 };
19090 }).filter(function(text) {
19091 return !addedIds.has(text.id);
19092 }).filter(function(text) {
19093 return _this.mirror.has(text.id);
19094 }),
19095 attributes: _this.attributes.map(function(attribute) {
19096 var attributes = attribute.attributes;
19097 if (typeof attributes.style === "string") {
19098 var diffAsStr = JSON.stringify(attribute.styleDiff);
19099 var unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
19100 if (diffAsStr.length < attributes.style.length) {
19101 if ((diffAsStr + unchangedAsStr).split("var(").length === attributes.style.split("var(").length) {
19102 attributes.style = attribute.styleDiff;
19103 }
19104 }
19105 }
19106 return {
19107 id: _this.mirror.getId(attribute.node),
19108 attributes: attributes
19109 };
19110 }).filter(function(attribute) {
19111 return !addedIds.has(attribute.id);
19112 }).filter(function(attribute) {
19113 return _this.mirror.has(attribute.id);
19114 }),
19115 removes: _this.removes,
19116 adds: adds
19117 };
19118 if (!payload.texts.length && !payload.attributes.length && !payload.removes.length && !payload.adds.length) {
19119 return;
19120 }
19121 _this.texts = [];
19122 _this.attributes = [];
19123 _this.attributeMap = /* @__PURE__ */ new WeakMap();
19124 _this.removes = [];
19125 _this.addedSet = /* @__PURE__ */ new Set();
19126 _this.movedSet = /* @__PURE__ */ new Set();
19127 _this.droppedSet = /* @__PURE__ */ new Set();
19128 _this.removesSubTreeCache = /* @__PURE__ */ new Set();
19129 _this.movedMap = {};
19130 _this.mutationCb(payload);
19131 });
19132 __publicField(this, "genTextAreaValueMutation", function(textarea) {
19133 var item = _this.attributeMap.get(textarea);
19134 if (!item) {
19135 item = {
19136 node: textarea,
19137 attributes: {},
19138 styleDiff: {},
19139 _unchangedStyles: {}
19140 };
19141 _this.attributes.push(item);
19142 _this.attributeMap.set(textarea, item);
19143 }
19144 var value = Array.from(index.childNodes(textarea), function(cn) {
19145 return index.textContent(cn) || "";
19146 }).join("");
19147 item.attributes.value = maskInputValue({
19148 element: textarea,
19149 maskInputOptions: _this.maskInputOptions,
19150 tagName: textarea.tagName,
19151 type: getInputType(textarea),
19152 value: value,
19153 maskInputFn: _this.maskInputFn
19154 });
19155 });
19156 __publicField(this, "processMutation", function(m) {
19157 if (isIgnored(m.target, _this.mirror, _this.slimDOMOptions)) {
19158 return;
19159 }
19160 switch(m.type){
19161 case "characterData":
19162 {
19163 var value = index.textContent(m.target);
19164 if (!isBlocked(m.target, _this.blockClass, _this.blockSelector, false) && value !== m.oldValue) {
19165 _this.texts.push({
19166 value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, true) && value ? _this.maskTextFn ? _this.maskTextFn(value, closestElementOfNode(m.target)) : value.replace(/[\S]/g, "*") : value,
19167 node: m.target
19168 });
19169 }
19170 break;
19171 }
19172 case "attributes":
19173 {
19174 var target = m.target;
19175 var attributeName = m.attributeName;
19176 var value1 = m.target.getAttribute(attributeName);
19177 if (attributeName === "value") {
19178 var type = getInputType(target);
19179 value1 = maskInputValue({
19180 element: target,
19181 maskInputOptions: _this.maskInputOptions,
19182 tagName: target.tagName,
19183 type: type,
19184 value: value1,
19185 maskInputFn: _this.maskInputFn
19186 });
19187 }
19188 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || value1 === m.oldValue) {
19189 return;
19190 }
19191 var item = _this.attributeMap.get(m.target);
19192 if (target.tagName === "IFRAME" && attributeName === "src" && !_this.keepIframeSrcFn(value1)) {
19193 if (!target.contentDocument) {
19194 attributeName = "rr_src";
19195 } else {
19196 return;
19197 }
19198 }
19199 if (!item) {
19200 item = {
19201 node: m.target,
19202 attributes: {},
19203 styleDiff: {},
19204 _unchangedStyles: {}
19205 };
19206 _this.attributes.push(item);
19207 _this.attributeMap.set(m.target, item);
19208 }
19209 if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
19210 target.setAttribute("data-rr-is-password", "true");
19211 }
19212 if (!ignoreAttribute(target.tagName, attributeName)) {
19213 item.attributes[attributeName] = transformAttribute(_this.doc, toLowerCase(target.tagName), toLowerCase(attributeName), value1);
19214 if (attributeName === "style") {
19215 if (!_this.unattachedDoc) {
19216 try {
19217 _this.unattachedDoc = document.implementation.createHTMLDocument();
19218 } catch (e2) {
19219 _this.unattachedDoc = _this.doc;
19220 }
19221 }
19222 var old = _this.unattachedDoc.createElement("span");
19223 if (m.oldValue) {
19224 old.setAttribute("style", m.oldValue);
19225 }
19226 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(target.style)), _step; !(_step = _iterator()).done;){
19227 var pname = _step.value;
19228 var newValue = target.style.getPropertyValue(pname);
19229 var newPriority = target.style.getPropertyPriority(pname);
19230 if (newValue !== old.style.getPropertyValue(pname) || newPriority !== old.style.getPropertyPriority(pname)) {
19231 if (newPriority === "") {
19232 item.styleDiff[pname] = newValue;
19233 } else {
19234 item.styleDiff[pname] = [
19235 newValue,
19236 newPriority
19237 ];
19238 }
19239 } else {
19240 item._unchangedStyles[pname] = [
19241 newValue,
19242 newPriority
19243 ];
19244 }
19245 }
19246 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(old.style)), _step1; !(_step1 = _iterator1()).done;){
19247 var pname1 = _step1.value;
19248 if (target.style.getPropertyValue(pname1) === "") {
19249 item.styleDiff[pname1] = false;
19250 }
19251 }
19252 } else if (attributeName === "open" && target.tagName === "DIALOG") {
19253 if (target.matches("dialog:modal")) {
19254 item.attributes["rr_open_mode"] = "modal";
19255 } else {
19256 item.attributes["rr_open_mode"] = "non-modal";
19257 }
19258 }
19259 }
19260 break;
19261 }
19262 case "childList":
19263 {
19264 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, true)) return;
19265 if (m.target.tagName === "TEXTAREA") {
19266 _this.genTextAreaValueMutation(m.target);
19267 return;
19268 }
19269 m.addedNodes.forEach(function(n2) {
19270 return _this.genAdds(n2, m.target);
19271 });
19272 m.removedNodes.forEach(function(n2) {
19273 var nodeId = _this.mirror.getId(n2);
19274 var parentId = isShadowRoot(m.target) ? _this.mirror.getId(index.host(m.target)) : _this.mirror.getId(m.target);
19275 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || isIgnored(n2, _this.mirror, _this.slimDOMOptions) || !isSerialized(n2, _this.mirror)) {
19276 return;
19277 }
19278 if (_this.addedSet.has(n2)) {
19279 deepDelete(_this.addedSet, n2);
19280 _this.droppedSet.add(n2);
19281 } else if (_this.addedSet.has(m.target) && nodeId === -1) ;
19282 else if (isAncestorRemoved(m.target, _this.mirror)) ;
19283 else if (_this.movedSet.has(n2) && _this.movedMap[moveKey(nodeId, parentId)]) {
19284 deepDelete(_this.movedSet, n2);
19285 } else {
19286 _this.removes.push({
19287 parentId: parentId,
19288 id: nodeId,
19289 isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
19290 });
19291 processRemoves(n2, _this.removesSubTreeCache);
19292 }
19293 _this.mapRemoves.push(n2);
19294 });
19295 break;
19296 }
19297 }
19298 });
19299 /**
19300 * Make sure you check if `n`'s parent is blocked before calling this function
19301 * */ __publicField(this, "genAdds", function(n2, target) {
19302 if (_this.processedNodeManager.inOtherBuffer(n2, _this)) return;
19303 if (_this.addedSet.has(n2) || _this.movedSet.has(n2)) return;
19304 if (_this.mirror.hasNode(n2)) {
19305 if (isIgnored(n2, _this.mirror, _this.slimDOMOptions)) {
19306 return;
19307 }
19308 _this.movedSet.add(n2);
19309 var targetId = null;
19310 if (target && _this.mirror.hasNode(target)) {
19311 targetId = _this.mirror.getId(target);
19312 }
19313 if (targetId && targetId !== -1) {
19314 _this.movedMap[moveKey(_this.mirror.getId(n2), targetId)] = true;
19315 }
19316 } else {
19317 _this.addedSet.add(n2);
19318 _this.droppedSet.delete(n2);
19319 }
19320 if (!isBlocked(n2, _this.blockClass, _this.blockSelector, false)) {
19321 index.childNodes(n2).forEach(function(childN) {
19322 return _this.genAdds(childN);
19323 });
19324 if (hasShadowRoot(n2)) {
19325 index.childNodes(index.shadowRoot(n2)).forEach(function(childN) {
19326 _this.processedNodeManager.add(childN, _this);
19327 _this.genAdds(childN, n2);
19328 });
19329 }
19330 }
19331 });
19332 }
19333 var _proto = MutationBuffer.prototype;
19334 _proto.init = function init(options) {
19335 var _this = this;
19336 [
19337 "mutationCb",
19338 "blockClass",
19339 "blockSelector",
19340 "maskTextClass",
19341 "maskTextSelector",
19342 "inlineStylesheet",
19343 "maskInputOptions",
19344 "maskTextFn",
19345 "maskInputFn",
19346 "keepIframeSrcFn",
19347 "recordCanvas",
19348 "inlineImages",
19349 "slimDOMOptions",
19350 "dataURLOptions",
19351 "doc",
19352 "mirror",
19353 "iframeManager",
19354 "stylesheetManager",
19355 "shadowDomManager",
19356 "canvasManager",
19357 "processedNodeManager"
19358 ].forEach(function(key) {
19359 _this[key] = options[key];
19360 });
19361 };
19362 _proto.freeze = function freeze() {
19363 this.frozen = true;
19364 this.canvasManager.freeze();
19365 };
19366 _proto.unfreeze = function unfreeze() {
19367 this.frozen = false;
19368 this.canvasManager.unfreeze();
19369 this.emit();
19370 };
19371 _proto.isFrozen = function isFrozen() {
19372 return this.frozen;
19373 };
19374 _proto.lock = function lock() {
19375 this.locked = true;
19376 this.canvasManager.lock();
19377 };
19378 _proto.unlock = function unlock() {
19379 this.locked = false;
19380 this.canvasManager.unlock();
19381 this.emit();
19382 };
19383 _proto.reset = function reset() {
19384 this.shadowDomManager.reset();
19385 this.canvasManager.reset();
19386 };
19387 return MutationBuffer;
19388 }();
19389 function deepDelete(addsSet, n2) {
19390 addsSet.delete(n2);
19391 index.childNodes(n2).forEach(function(childN) {
19392 return deepDelete(addsSet, childN);
19393 });
19394 }
19395 function processRemoves(n2, cache) {
19396 var queue = [
19397 n2
19398 ];
19399 while(queue.length){
19400 var next = queue.pop();
19401 if (cache.has(next)) continue;
19402 cache.add(next);
19403 index.childNodes(next).forEach(function(n22) {
19404 return queue.push(n22);
19405 });
19406 }
19407 return;
19408 }
19409 function isParentRemoved(removes, n2, mirror2) {
19410 if (removes.size === 0) return false;
19411 return _isParentRemoved(removes, n2);
19412 }
19413 function _isParentRemoved(removes, n2, _mirror2) {
19414 var node2 = index.parentNode(n2);
19415 if (!node2) return false;
19416 return removes.has(node2);
19417 }
19418 function isAncestorInSet(set, n2) {
19419 if (set.size === 0) return false;
19420 return _isAncestorInSet(set, n2);
19421 }
19422 function _isAncestorInSet(set, n2) {
19423 var parent = index.parentNode(n2);
19424 if (!parent) {
19425 return false;
19426 }
19427 if (set.has(parent)) {
19428 return true;
19429 }
19430 return _isAncestorInSet(set, parent);
19431 }
19432 var errorHandler;
19433 function registerErrorHandler(handler) {
19434 errorHandler = handler;
19435 }
19436 function unregisterErrorHandler() {
19437 errorHandler = void 0;
19438 }
19439 var callbackWrapper = function(cb) {
19440 if (!errorHandler) {
19441 return cb;
19442 }
19443 var rrwebWrapped = function() {
19444 for(var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++){
19445 rest[_key] = arguments[_key];
19446 }
19447 try {
19448 return cb.apply(void 0, [].concat(rest));
19449 } catch (error) {
19450 if (errorHandler && errorHandler(error) === true) {
19451 return;
19452 }
19453 throw error;
19454 }
19455 };
19456 return rrwebWrapped;
19457 };
19458 var mutationBuffers = [];
19459 function getEventTarget(event) {
19460 try {
19461 if ("composedPath" in event) {
19462 var path = event.composedPath();
19463 if (path.length) {
19464 return path[0];
19465 }
19466 } else if ("path" in event && event.path.length) {
19467 return event.path[0];
19468 }
19469 } catch (e) {}
19470 return event && event.target;
19471 }
19472 function initMutationObserver(options, rootEl) {
19473 var mutationBuffer = new MutationBuffer();
19474 mutationBuffers.push(mutationBuffer);
19475 mutationBuffer.init(options);
19476 var observer = new (mutationObserverCtor())(callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer)));
19477 observer.observe(rootEl, {
19478 attributes: true,
19479 attributeOldValue: true,
19480 characterData: true,
19481 characterDataOldValue: true,
19482 childList: true,
19483 subtree: true
19484 });
19485 return observer;
19486 }
19487 function initMoveObserver(param) {
19488 var mousemoveCb = param.mousemoveCb, sampling = param.sampling, doc = param.doc, mirror2 = param.mirror;
19489 if (sampling.mousemove === false) {
19490 return function() {};
19491 }
19492 var threshold = typeof sampling.mousemove === "number" ? sampling.mousemove : 50;
19493 var callbackThreshold = typeof sampling.mousemoveCallback === "number" ? sampling.mousemoveCallback : 500;
19494 var positions = [];
19495 var timeBaseline;
19496 var wrappedCb = throttle(callbackWrapper(function(source) {
19497 var totalOffset = Date.now() - timeBaseline;
19498 mousemoveCb(positions.map(function(p) {
19499 p.timeOffset -= totalOffset;
19500 return p;
19501 }), source);
19502 positions = [];
19503 timeBaseline = null;
19504 }), callbackThreshold);
19505 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
19506 var target = getEventTarget(evt);
19507 var _ref = legacy_isTouchEvent(evt) ? evt.changedTouches[0] : evt, clientX = _ref.clientX, clientY = _ref.clientY;
19508 if (!timeBaseline) {
19509 timeBaseline = nowTimestamp();
19510 }
19511 positions.push({
19512 x: clientX,
19513 y: clientY,
19514 id: mirror2.getId(target),
19515 timeOffset: nowTimestamp() - timeBaseline
19516 });
19517 wrappedCb(typeof DragEvent !== "undefined" && _instanceof(evt, DragEvent) ? IncrementalSource.Drag : _instanceof(evt, MouseEvent) ? IncrementalSource.MouseMove : IncrementalSource.TouchMove);
19518 }), threshold, {
19519 trailing: false
19520 }));
19521 var handlers = [
19522 on("mousemove", updatePosition, doc),
19523 on("touchmove", updatePosition, doc),
19524 on("drag", updatePosition, doc)
19525 ];
19526 return callbackWrapper(function() {
19527 handlers.forEach(function(h) {
19528 return h();
19529 });
19530 });
19531 }
19532 function initMouseInteractionObserver(param) {
19533 var mouseInteractionCb = param.mouseInteractionCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
19534 if (sampling.mouseInteraction === false) {
19535 return function() {};
19536 }
19537 var disableMap = sampling.mouseInteraction === true || sampling.mouseInteraction === void 0 ? {} : sampling.mouseInteraction;
19538 var handlers = [];
19539 var currentPointerType = null;
19540 var getHandler = function(eventKey) {
19541 return function(event) {
19542 var target = getEventTarget(event);
19543 if (isBlocked(target, blockClass, blockSelector, true)) {
19544 return;
19545 }
19546 var pointerType = null;
19547 var thisEventKey = eventKey;
19548 if ("pointerType" in event) {
19549 switch(event.pointerType){
19550 case "mouse":
19551 pointerType = PointerTypes.Mouse;
19552 break;
19553 case "touch":
19554 pointerType = PointerTypes.Touch;
19555 break;
19556 case "pen":
19557 pointerType = PointerTypes.Pen;
19558 break;
19559 }
19560 if (pointerType === PointerTypes.Touch) {
19561 if (MouseInteractions[eventKey] === MouseInteractions.MouseDown) {
19562 thisEventKey = "TouchStart";
19563 } else if (MouseInteractions[eventKey] === MouseInteractions.MouseUp) {
19564 thisEventKey = "TouchEnd";
19565 }
19566 } else if (pointerType === PointerTypes.Pen) ;
19567 } else if (legacy_isTouchEvent(event)) {
19568 pointerType = PointerTypes.Touch;
19569 }
19570 if (pointerType !== null) {
19571 currentPointerType = pointerType;
19572 if (thisEventKey.startsWith("Touch") && pointerType === PointerTypes.Touch || thisEventKey.startsWith("Mouse") && pointerType === PointerTypes.Mouse) {
19573 pointerType = null;
19574 }
19575 } else if (MouseInteractions[eventKey] === MouseInteractions.Click) {
19576 pointerType = currentPointerType;
19577 currentPointerType = null;
19578 }
19579 var e2 = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
19580 if (!e2) {
19581 return;
19582 }
19583 var id = mirror2.getId(target);
19584 var clientX = e2.clientX, clientY = e2.clientY;
19585 callbackWrapper(mouseInteractionCb)(_extends({
19586 type: MouseInteractions[thisEventKey],
19587 id: id,
19588 x: clientX,
19589 y: clientY
19590 }, pointerType !== null && {
19591 pointerType: pointerType
19592 }));
19593 };
19594 };
19595 Object.keys(MouseInteractions).filter(function(key) {
19596 return Number.isNaN(Number(key)) && !key.endsWith("_Departed") && disableMap[key] !== false;
19597 }).forEach(function(eventKey) {
19598 var eventName = toLowerCase(eventKey);
19599 var handler = getHandler(eventKey);
19600 if (window.PointerEvent) {
19601 switch(MouseInteractions[eventKey]){
19602 case MouseInteractions.MouseDown:
19603 case MouseInteractions.MouseUp:
19604 eventName = eventName.replace("mouse", "pointer");
19605 break;
19606 case MouseInteractions.TouchStart:
19607 case MouseInteractions.TouchEnd:
19608 return;
19609 }
19610 }
19611 handlers.push(on(eventName, handler, doc));
19612 });
19613 return callbackWrapper(function() {
19614 handlers.forEach(function(h) {
19615 return h();
19616 });
19617 });
19618 }
19619 function initScrollObserver(param) {
19620 var scrollCb = param.scrollCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
19621 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
19622 var target = getEventTarget(evt);
19623 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
19624 return;
19625 }
19626 var id = mirror2.getId(target);
19627 if (target === doc && doc.defaultView) {
19628 var scrollLeftTop = getWindowScroll(doc.defaultView);
19629 scrollCb({
19630 id: id,
19631 x: scrollLeftTop.left,
19632 y: scrollLeftTop.top
19633 });
19634 } else {
19635 scrollCb({
19636 id: id,
19637 x: target.scrollLeft,
19638 y: target.scrollTop
19639 });
19640 }
19641 }), sampling.scroll || 100));
19642 return on("scroll", updatePosition, doc);
19643 }
19644 function initViewportResizeObserver(param, param1) {
19645 var viewportResizeCb = param.viewportResizeCb;
19646 var win = param1.win;
19647 var lastH = -1;
19648 var lastW = -1;
19649 var updateDimension = callbackWrapper(throttle(callbackWrapper(function() {
19650 var height = getWindowHeight();
19651 var width = getWindowWidth();
19652 if (lastH !== height || lastW !== width) {
19653 viewportResizeCb({
19654 width: Number(width),
19655 height: Number(height)
19656 });
19657 lastH = height;
19658 lastW = width;
19659 }
19660 }), 200));
19661 return on("resize", updateDimension, win);
19662 }
19663 var INPUT_TAGS = [
19664 "INPUT",
19665 "TEXTAREA",
19666 "SELECT"
19667 ];
19668 var lastInputValueMap = /* @__PURE__ */ new WeakMap();
19669 function initInputObserver(param) {
19670 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;
19671 function eventHandler(event) {
19672 var target = getEventTarget(event);
19673 var userTriggered = event.isTrusted;
19674 var tagName = target && target.tagName;
19675 if (target && tagName === "OPTION") {
19676 target = index.parentElement(target);
19677 }
19678 if (!target || !tagName || INPUT_TAGS.indexOf(tagName) < 0 || isBlocked(target, blockClass, blockSelector, true)) {
19679 return;
19680 }
19681 if (target.classList.contains(ignoreClass) || ignoreSelector && target.matches(ignoreSelector)) {
19682 return;
19683 }
19684 var text = target.value;
19685 var isChecked = false;
19686 var type = getInputType(target) || "";
19687 if (type === "radio" || type === "checkbox") {
19688 isChecked = target.checked;
19689 } else if (maskInputOptions[tagName.toLowerCase()] || maskInputOptions[type]) {
19690 text = maskInputValue({
19691 element: target,
19692 maskInputOptions: maskInputOptions,
19693 tagName: tagName,
19694 type: type,
19695 value: text,
19696 maskInputFn: maskInputFn
19697 });
19698 }
19699 cbWithDedup(target, userTriggeredOnInput ? {
19700 text: text,
19701 isChecked: isChecked,
19702 userTriggered: userTriggered
19703 } : {
19704 text: text,
19705 isChecked: isChecked
19706 });
19707 var name = target.name;
19708 if (type === "radio" && name && isChecked) {
19709 doc.querySelectorAll('input[type="radio"][name="' + name + '"]').forEach(function(el) {
19710 if (el !== target) {
19711 var text2 = el.value;
19712 cbWithDedup(el, userTriggeredOnInput ? {
19713 text: text2,
19714 isChecked: !isChecked,
19715 userTriggered: false
19716 } : {
19717 text: text2,
19718 isChecked: !isChecked
19719 });
19720 }
19721 });
19722 }
19723 }
19724 function cbWithDedup(target, v2) {
19725 var lastInputValue = lastInputValueMap.get(target);
19726 if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
19727 lastInputValueMap.set(target, v2);
19728 var id = mirror2.getId(target);
19729 callbackWrapper(inputCb)(_extends({}, v2, {
19730 id: id
19731 }));
19732 }
19733 }
19734 var events = sampling.input === "last" ? [
19735 "change"
19736 ] : [
19737 "input",
19738 "change"
19739 ];
19740 var handlers = events.map(function(eventName) {
19741 return on(eventName, callbackWrapper(eventHandler), doc);
19742 });
19743 var currentWindow = doc.defaultView;
19744 if (!currentWindow) {
19745 return function() {
19746 handlers.forEach(function(h) {
19747 return h();
19748 });
19749 };
19750 }
19751 var propertyDescriptor = currentWindow.Object.getOwnPropertyDescriptor(currentWindow.HTMLInputElement.prototype, "value");
19752 var hookProperties = [
19753 [
19754 currentWindow.HTMLInputElement.prototype,
19755 "value"
19756 ],
19757 [
19758 currentWindow.HTMLInputElement.prototype,
19759 "checked"
19760 ],
19761 [
19762 currentWindow.HTMLSelectElement.prototype,
19763 "value"
19764 ],
19765 [
19766 currentWindow.HTMLTextAreaElement.prototype,
19767 "value"
19768 ],
19769 // Some UI library use selectedIndex to set select value
19770 [
19771 currentWindow.HTMLSelectElement.prototype,
19772 "selectedIndex"
19773 ],
19774 [
19775 currentWindow.HTMLOptionElement.prototype,
19776 "selected"
19777 ]
19778 ];
19779 if (propertyDescriptor && propertyDescriptor.set) {
19780 var _handlers;
19781 (_handlers = handlers).push.apply(_handlers, [].concat(hookProperties.map(function(p) {
19782 return hookSetter(p[0], p[1], {
19783 set: function set() {
19784 callbackWrapper(eventHandler)({
19785 target: this,
19786 isTrusted: false
19787 });
19788 }
19789 }, false, currentWindow);
19790 })));
19791 }
19792 return callbackWrapper(function() {
19793 handlers.forEach(function(h) {
19794 return h();
19795 });
19796 });
19797 }
19798 function getNestedCSSRulePositions(rule2) {
19799 var positions = [];
19800 function recurse(childRule, pos) {
19801 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)) {
19802 var rules2 = Array.from(childRule.parentRule.cssRules);
19803 var index2 = rules2.indexOf(childRule);
19804 pos.unshift(index2);
19805 } else if (childRule.parentStyleSheet) {
19806 var rules21 = Array.from(childRule.parentStyleSheet.cssRules);
19807 var index21 = rules21.indexOf(childRule);
19808 pos.unshift(index21);
19809 }
19810 return pos;
19811 }
19812 return recurse(rule2, positions);
19813 }
19814 function getIdAndStyleId(sheet, mirror2, styleMirror) {
19815 var id, styleId;
19816 if (!sheet) return {};
19817 if (sheet.ownerNode) id = mirror2.getId(sheet.ownerNode);
19818 else styleId = styleMirror.getId(sheet);
19819 return {
19820 styleId: styleId,
19821 id: id
19822 };
19823 }
19824 function initStyleSheetObserver(param, param1) {
19825 var styleSheetRuleCb = param.styleSheetRuleCb, mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
19826 var win = param1.win;
19827 if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
19828 return function() {};
19829 }
19830 var insertRule = win.CSSStyleSheet.prototype.insertRule;
19831 win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
19832 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19833 var rule2 = argumentsList[0], index2 = argumentsList[1];
19834 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19835 if (id && id !== -1 || styleId && styleId !== -1) {
19836 styleSheetRuleCb({
19837 id: id,
19838 styleId: styleId,
19839 adds: [
19840 {
19841 rule: rule2,
19842 index: index2
19843 }
19844 ]
19845 });
19846 }
19847 return target.apply(thisArg, argumentsList);
19848 })
19849 });
19850 win.CSSStyleSheet.prototype.addRule = function(selector, styleBlock, index2) {
19851 if (index2 === void 0) index2 = this.cssRules.length;
19852 var rule2 = selector + " { " + styleBlock + " }";
19853 return win.CSSStyleSheet.prototype.insertRule.apply(this, [
19854 rule2,
19855 index2
19856 ]);
19857 };
19858 var deleteRule = win.CSSStyleSheet.prototype.deleteRule;
19859 win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
19860 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19861 var index2 = argumentsList[0];
19862 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19863 if (id && id !== -1 || styleId && styleId !== -1) {
19864 styleSheetRuleCb({
19865 id: id,
19866 styleId: styleId,
19867 removes: [
19868 {
19869 index: index2
19870 }
19871 ]
19872 });
19873 }
19874 return target.apply(thisArg, argumentsList);
19875 })
19876 });
19877 win.CSSStyleSheet.prototype.removeRule = function(index2) {
19878 return win.CSSStyleSheet.prototype.deleteRule.apply(this, [
19879 index2
19880 ]);
19881 };
19882 var replace;
19883 if (win.CSSStyleSheet.prototype.replace) {
19884 replace = win.CSSStyleSheet.prototype.replace;
19885 win.CSSStyleSheet.prototype.replace = new Proxy(replace, {
19886 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19887 var text = argumentsList[0];
19888 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19889 if (id && id !== -1 || styleId && styleId !== -1) {
19890 styleSheetRuleCb({
19891 id: id,
19892 styleId: styleId,
19893 replace: text
19894 });
19895 }
19896 return target.apply(thisArg, argumentsList);
19897 })
19898 });
19899 }
19900 var replaceSync;
19901 if (win.CSSStyleSheet.prototype.replaceSync) {
19902 replaceSync = win.CSSStyleSheet.prototype.replaceSync;
19903 win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {
19904 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19905 var text = argumentsList[0];
19906 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19907 if (id && id !== -1 || styleId && styleId !== -1) {
19908 styleSheetRuleCb({
19909 id: id,
19910 styleId: styleId,
19911 replaceSync: text
19912 });
19913 }
19914 return target.apply(thisArg, argumentsList);
19915 })
19916 });
19917 }
19918 var supportedNestedCSSRuleTypes = {};
19919 if (canMonkeyPatchNestedCSSRule("CSSGroupingRule")) {
19920 supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
19921 } else {
19922 if (canMonkeyPatchNestedCSSRule("CSSMediaRule")) {
19923 supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
19924 }
19925 if (canMonkeyPatchNestedCSSRule("CSSConditionRule")) {
19926 supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
19927 }
19928 if (canMonkeyPatchNestedCSSRule("CSSSupportsRule")) {
19929 supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
19930 }
19931 }
19932 var unmodifiedFunctions = {};
19933 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
19934 var typeKey = param[0], type = param[1];
19935 unmodifiedFunctions[typeKey] = {
19936 // eslint-disable-next-line @typescript-eslint/unbound-method
19937 insertRule: type.prototype.insertRule,
19938 // eslint-disable-next-line @typescript-eslint/unbound-method
19939 deleteRule: type.prototype.deleteRule
19940 };
19941 type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
19942 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19943 var rule2 = argumentsList[0], index2 = argumentsList[1];
19944 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19945 if (id && id !== -1 || styleId && styleId !== -1) {
19946 styleSheetRuleCb({
19947 id: id,
19948 styleId: styleId,
19949 adds: [
19950 {
19951 rule: rule2,
19952 index: [].concat(getNestedCSSRulePositions(thisArg), [
19953 index2 || 0
19954 ])
19955 }
19956 ]
19957 });
19958 }
19959 return target.apply(thisArg, argumentsList);
19960 })
19961 });
19962 type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
19963 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19964 var index2 = argumentsList[0];
19965 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19966 if (id && id !== -1 || styleId && styleId !== -1) {
19967 styleSheetRuleCb({
19968 id: id,
19969 styleId: styleId,
19970 removes: [
19971 {
19972 index: [].concat(getNestedCSSRulePositions(thisArg), [
19973 index2
19974 ])
19975 }
19976 ]
19977 });
19978 }
19979 return target.apply(thisArg, argumentsList);
19980 })
19981 });
19982 });
19983 return callbackWrapper(function() {
19984 win.CSSStyleSheet.prototype.insertRule = insertRule;
19985 win.CSSStyleSheet.prototype.deleteRule = deleteRule;
19986 replace && (win.CSSStyleSheet.prototype.replace = replace);
19987 replaceSync && (win.CSSStyleSheet.prototype.replaceSync = replaceSync);
19988 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
19989 var typeKey = param[0], type = param[1];
19990 type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
19991 type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
19992 });
19993 });
19994 }
19995 function initAdoptedStyleSheetObserver(param, host2) {
19996 var mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
19997 var _a2, _b, _c;
19998 var hostId = null;
19999 if (host2.nodeName === "#document") hostId = mirror2.getId(host2);
20000 else hostId = mirror2.getId(index.host(host2));
20001 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;
20002 var originalPropertyDescriptor = (patchTarget == null ? void 0 : patchTarget.prototype) ? Object.getOwnPropertyDescriptor(patchTarget == null ? void 0 : patchTarget.prototype, "adoptedStyleSheets") : void 0;
20003 if (hostId === null || hostId === -1 || !patchTarget || !originalPropertyDescriptor) return function() {};
20004 Object.defineProperty(host2, "adoptedStyleSheets", {
20005 configurable: originalPropertyDescriptor.configurable,
20006 enumerable: originalPropertyDescriptor.enumerable,
20007 get: function get() {
20008 var _a3;
20009 return (_a3 = originalPropertyDescriptor.get) == null ? void 0 : _a3.call(this);
20010 },
20011 set: function set(sheets) {
20012 var _a3;
20013 var result2 = (_a3 = originalPropertyDescriptor.set) == null ? void 0 : _a3.call(this, sheets);
20014 if (hostId !== null && hostId !== -1) {
20015 try {
20016 stylesheetManager.adoptStyleSheets(sheets, hostId);
20017 } catch (e2) {}
20018 }
20019 return result2;
20020 }
20021 });
20022 return callbackWrapper(function() {
20023 Object.defineProperty(host2, "adoptedStyleSheets", {
20024 configurable: originalPropertyDescriptor.configurable,
20025 enumerable: originalPropertyDescriptor.enumerable,
20026 // eslint-disable-next-line @typescript-eslint/unbound-method
20027 get: originalPropertyDescriptor.get,
20028 // eslint-disable-next-line @typescript-eslint/unbound-method
20029 set: originalPropertyDescriptor.set
20030 });
20031 });
20032 }
20033 function initStyleDeclarationObserver(param, param1) {
20034 var styleDeclarationCb = param.styleDeclarationCb, mirror2 = param.mirror, ignoreCSSAttributes = param.ignoreCSSAttributes, stylesheetManager = param.stylesheetManager;
20035 var win = param1.win;
20036 var setProperty = win.CSSStyleDeclaration.prototype.setProperty;
20037 win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
20038 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20039 var _a2;
20040 var property = argumentsList[0], value = argumentsList[1], priority = argumentsList[2];
20041 if (ignoreCSSAttributes.has(property)) {
20042 return setProperty.apply(thisArg, [
20043 property,
20044 value,
20045 priority
20046 ]);
20047 }
20048 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20049 if (id && id !== -1 || styleId && styleId !== -1) {
20050 styleDeclarationCb({
20051 id: id,
20052 styleId: styleId,
20053 set: {
20054 property: property,
20055 value: value,
20056 priority: priority
20057 },
20058 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20059 index: getNestedCSSRulePositions(thisArg.parentRule)
20060 });
20061 }
20062 return target.apply(thisArg, argumentsList);
20063 })
20064 });
20065 var removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
20066 win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
20067 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20068 var _a2;
20069 var property = argumentsList[0];
20070 if (ignoreCSSAttributes.has(property)) {
20071 return removeProperty.apply(thisArg, [
20072 property
20073 ]);
20074 }
20075 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20076 if (id && id !== -1 || styleId && styleId !== -1) {
20077 styleDeclarationCb({
20078 id: id,
20079 styleId: styleId,
20080 remove: {
20081 property: property
20082 },
20083 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20084 index: getNestedCSSRulePositions(thisArg.parentRule)
20085 });
20086 }
20087 return target.apply(thisArg, argumentsList);
20088 })
20089 });
20090 return callbackWrapper(function() {
20091 win.CSSStyleDeclaration.prototype.setProperty = setProperty;
20092 win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
20093 });
20094 }
20095 function initMediaInteractionObserver(param) {
20096 var mediaInteractionCb = param.mediaInteractionCb, blockClass = param.blockClass, blockSelector = param.blockSelector, mirror2 = param.mirror, sampling = param.sampling, doc = param.doc;
20097 var handler = callbackWrapper(function(type) {
20098 return throttle(callbackWrapper(function(event) {
20099 var target = getEventTarget(event);
20100 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20101 return;
20102 }
20103 var currentTime = target.currentTime, volume = target.volume, muted = target.muted, playbackRate = target.playbackRate, loop = target.loop;
20104 mediaInteractionCb({
20105 type: type,
20106 id: mirror2.getId(target),
20107 currentTime: currentTime,
20108 volume: volume,
20109 muted: muted,
20110 playbackRate: playbackRate,
20111 loop: loop
20112 });
20113 }), sampling.media || 500);
20114 });
20115 var handlers = [
20116 on("play", handler(MediaInteractions.Play), doc),
20117 on("pause", handler(MediaInteractions.Pause), doc),
20118 on("seeked", handler(MediaInteractions.Seeked), doc),
20119 on("volumechange", handler(MediaInteractions.VolumeChange), doc),
20120 on("ratechange", handler(MediaInteractions.RateChange), doc)
20121 ];
20122 return callbackWrapper(function() {
20123 handlers.forEach(function(h) {
20124 return h();
20125 });
20126 });
20127 }
20128 function initFontObserver(param) {
20129 var fontCb = param.fontCb, doc = param.doc;
20130 var win = doc.defaultView;
20131 if (!win) {
20132 return function() {};
20133 }
20134 var handlers = [];
20135 var fontMap = /* @__PURE__ */ new WeakMap();
20136 var originalFontFace = win.FontFace;
20137 win.FontFace = function FontFace2(family, source, descriptors) {
20138 var fontFace = new originalFontFace(family, source, descriptors);
20139 fontMap.set(fontFace, {
20140 family: family,
20141 buffer: typeof source !== "string",
20142 descriptors: descriptors,
20143 fontSource: typeof source === "string" ? source : JSON.stringify(Array.from(new Uint8Array(source)))
20144 });
20145 return fontFace;
20146 };
20147 var restoreHandler = patch(doc.fonts, "add", function(original) {
20148 return function(fontFace) {
20149 setTimeout(callbackWrapper(function() {
20150 var p = fontMap.get(fontFace);
20151 if (p) {
20152 fontCb(p);
20153 fontMap.delete(fontFace);
20154 }
20155 }), 0);
20156 return original.apply(this, [
20157 fontFace
20158 ]);
20159 };
20160 });
20161 handlers.push(function() {
20162 win.FontFace = originalFontFace;
20163 });
20164 handlers.push(restoreHandler);
20165 return callbackWrapper(function() {
20166 handlers.forEach(function(h) {
20167 return h();
20168 });
20169 });
20170 }
20171 function initSelectionObserver(param) {
20172 var doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, selectionCb = param.selectionCb;
20173 var collapsed = true;
20174 var updateSelection = callbackWrapper(function() {
20175 var selection = doc.getSelection();
20176 if (!selection || collapsed && (selection == null ? void 0 : selection.isCollapsed)) return;
20177 collapsed = selection.isCollapsed || false;
20178 var ranges = [];
20179 var count = selection.rangeCount || 0;
20180 for(var i2 = 0; i2 < count; i2++){
20181 var range = selection.getRangeAt(i2);
20182 var startContainer = range.startContainer, startOffset = range.startOffset, endContainer = range.endContainer, endOffset = range.endOffset;
20183 var blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
20184 if (blocked) continue;
20185 ranges.push({
20186 start: mirror2.getId(startContainer),
20187 startOffset: startOffset,
20188 end: mirror2.getId(endContainer),
20189 endOffset: endOffset
20190 });
20191 }
20192 selectionCb({
20193 ranges: ranges
20194 });
20195 });
20196 updateSelection();
20197 return on("selectionchange", updateSelection);
20198 }
20199 function initCustomElementObserver(param) {
20200 var doc = param.doc, customElementCb = param.customElementCb;
20201 var win = doc.defaultView;
20202 if (!win || !win.customElements) return function() {};
20203 var restoreHandler = patch(win.customElements, "define", function(original) {
20204 return function(name, constructor, options) {
20205 try {
20206 customElementCb({
20207 define: {
20208 name: name
20209 }
20210 });
20211 } catch (e2) {
20212 console.warn("Custom element callback failed for " + name);
20213 }
20214 return original.apply(this, [
20215 name,
20216 constructor,
20217 options
20218 ]);
20219 };
20220 });
20221 return restoreHandler;
20222 }
20223 function mergeHooks(o2, hooks) {
20224 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;
20225 o2.mutationCb = function() {
20226 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20227 p[_key] = arguments[_key];
20228 }
20229 if (hooks.mutation) {
20230 var _hooks;
20231 (_hooks = hooks).mutation.apply(_hooks, [].concat(p));
20232 }
20233 mutationCb.apply(void 0, [].concat(p));
20234 };
20235 o2.mousemoveCb = function() {
20236 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20237 p[_key] = arguments[_key];
20238 }
20239 if (hooks.mousemove) {
20240 var _hooks;
20241 (_hooks = hooks).mousemove.apply(_hooks, [].concat(p));
20242 }
20243 mousemoveCb.apply(void 0, [].concat(p));
20244 };
20245 o2.mouseInteractionCb = function() {
20246 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20247 p[_key] = arguments[_key];
20248 }
20249 if (hooks.mouseInteraction) {
20250 var _hooks;
20251 (_hooks = hooks).mouseInteraction.apply(_hooks, [].concat(p));
20252 }
20253 mouseInteractionCb.apply(void 0, [].concat(p));
20254 };
20255 o2.scrollCb = function() {
20256 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20257 p[_key] = arguments[_key];
20258 }
20259 if (hooks.scroll) {
20260 var _hooks;
20261 (_hooks = hooks).scroll.apply(_hooks, [].concat(p));
20262 }
20263 scrollCb.apply(void 0, [].concat(p));
20264 };
20265 o2.viewportResizeCb = function() {
20266 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20267 p[_key] = arguments[_key];
20268 }
20269 if (hooks.viewportResize) {
20270 var _hooks;
20271 (_hooks = hooks).viewportResize.apply(_hooks, [].concat(p));
20272 }
20273 viewportResizeCb.apply(void 0, [].concat(p));
20274 };
20275 o2.inputCb = function() {
20276 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20277 p[_key] = arguments[_key];
20278 }
20279 if (hooks.input) {
20280 var _hooks;
20281 (_hooks = hooks).input.apply(_hooks, [].concat(p));
20282 }
20283 inputCb.apply(void 0, [].concat(p));
20284 };
20285 o2.mediaInteractionCb = function() {
20286 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20287 p[_key] = arguments[_key];
20288 }
20289 if (hooks.mediaInteaction) {
20290 var _hooks;
20291 (_hooks = hooks).mediaInteaction.apply(_hooks, [].concat(p));
20292 }
20293 mediaInteractionCb.apply(void 0, [].concat(p));
20294 };
20295 o2.styleSheetRuleCb = function() {
20296 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20297 p[_key] = arguments[_key];
20298 }
20299 if (hooks.styleSheetRule) {
20300 var _hooks;
20301 (_hooks = hooks).styleSheetRule.apply(_hooks, [].concat(p));
20302 }
20303 styleSheetRuleCb.apply(void 0, [].concat(p));
20304 };
20305 o2.styleDeclarationCb = function() {
20306 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20307 p[_key] = arguments[_key];
20308 }
20309 if (hooks.styleDeclaration) {
20310 var _hooks;
20311 (_hooks = hooks).styleDeclaration.apply(_hooks, [].concat(p));
20312 }
20313 styleDeclarationCb.apply(void 0, [].concat(p));
20314 };
20315 o2.canvasMutationCb = function() {
20316 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20317 p[_key] = arguments[_key];
20318 }
20319 if (hooks.canvasMutation) {
20320 var _hooks;
20321 (_hooks = hooks).canvasMutation.apply(_hooks, [].concat(p));
20322 }
20323 canvasMutationCb.apply(void 0, [].concat(p));
20324 };
20325 o2.fontCb = function() {
20326 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20327 p[_key] = arguments[_key];
20328 }
20329 if (hooks.font) {
20330 var _hooks;
20331 (_hooks = hooks).font.apply(_hooks, [].concat(p));
20332 }
20333 fontCb.apply(void 0, [].concat(p));
20334 };
20335 o2.selectionCb = function() {
20336 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20337 p[_key] = arguments[_key];
20338 }
20339 if (hooks.selection) {
20340 var _hooks;
20341 (_hooks = hooks).selection.apply(_hooks, [].concat(p));
20342 }
20343 selectionCb.apply(void 0, [].concat(p));
20344 };
20345 o2.customElementCb = function() {
20346 for(var _len = arguments.length, c2 = new Array(_len), _key = 0; _key < _len; _key++){
20347 c2[_key] = arguments[_key];
20348 }
20349 if (hooks.customElement) {
20350 var _hooks;
20351 (_hooks = hooks).customElement.apply(_hooks, [].concat(c2));
20352 }
20353 customElementCb.apply(void 0, [].concat(c2));
20354 };
20355 }
20356 function initObservers(o2, hooks) {
20357 if (hooks === void 0) hooks = {};
20358 var currentWindow = o2.doc.defaultView;
20359 if (!currentWindow) {
20360 return function() {};
20361 }
20362 mergeHooks(o2, hooks);
20363 var mutationObserver;
20364 if (o2.recordDOM) {
20365 mutationObserver = initMutationObserver(o2, o2.doc);
20366 }
20367 var mousemoveHandler = initMoveObserver(o2);
20368 var mouseInteractionHandler = initMouseInteractionObserver(o2);
20369 var scrollHandler = initScrollObserver(o2);
20370 var viewportResizeHandler = initViewportResizeObserver(o2, {
20371 win: currentWindow
20372 });
20373 var inputHandler = initInputObserver(o2);
20374 var mediaInteractionHandler = initMediaInteractionObserver(o2);
20375 var styleSheetObserver = function() {};
20376 var adoptedStyleSheetObserver = function() {};
20377 var styleDeclarationObserver = function() {};
20378 var fontObserver = function() {};
20379 if (o2.recordDOM) {
20380 styleSheetObserver = initStyleSheetObserver(o2, {
20381 win: currentWindow
20382 });
20383 adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o2, o2.doc);
20384 styleDeclarationObserver = initStyleDeclarationObserver(o2, {
20385 win: currentWindow
20386 });
20387 if (o2.collectFonts) {
20388 fontObserver = initFontObserver(o2);
20389 }
20390 }
20391 var selectionObserver = initSelectionObserver(o2);
20392 var customElementObserver = initCustomElementObserver(o2);
20393 var pluginHandlers = [];
20394 for(var _iterator = _create_for_of_iterator_helper_loose(o2.plugins), _step; !(_step = _iterator()).done;){
20395 var plugin3 = _step.value;
20396 pluginHandlers.push(plugin3.observer(plugin3.callback, currentWindow, plugin3.options));
20397 }
20398 return callbackWrapper(function() {
20399 mutationBuffers.forEach(function(b) {
20400 return b.reset();
20401 });
20402 mutationObserver == null ? void 0 : mutationObserver.disconnect();
20403 mousemoveHandler();
20404 mouseInteractionHandler();
20405 scrollHandler();
20406 viewportResizeHandler();
20407 inputHandler();
20408 mediaInteractionHandler();
20409 styleSheetObserver();
20410 adoptedStyleSheetObserver();
20411 styleDeclarationObserver();
20412 fontObserver();
20413 selectionObserver();
20414 customElementObserver();
20415 pluginHandlers.forEach(function(h) {
20416 return h();
20417 });
20418 });
20419 }
20420 function hasNestedCSSRule(prop) {
20421 return typeof window[prop] !== "undefined";
20422 }
20423 function canMonkeyPatchNestedCSSRule(prop) {
20424 return Boolean(typeof window[prop] !== "undefined" && // Note: Generally, this check _shouldn't_ be necessary
20425 // However, in some scenarios (e.g. jsdom) this can sometimes fail, so we check for it here
20426 window[prop].prototype && "insertRule" in window[prop].prototype && "deleteRule" in window[prop].prototype);
20427 }
20428 var CrossOriginIframeMirror = /*#__PURE__*/ function() {
20429 function CrossOriginIframeMirror(generateIdFn) {
20430 __publicField(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
20431 __publicField(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
20432 this.generateIdFn = generateIdFn;
20433 }
20434 var _proto = CrossOriginIframeMirror.prototype;
20435 _proto.getId = function getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) {
20436 var idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe);
20437 var remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe);
20438 var id = idToRemoteIdMap.get(remoteId);
20439 if (!id) {
20440 id = this.generateIdFn();
20441 idToRemoteIdMap.set(remoteId, id);
20442 remoteIdToIdMap.set(id, remoteId);
20443 }
20444 return id;
20445 };
20446 _proto.getIds = function getIds(iframe, remoteId) {
20447 var _this = this;
20448 var idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);
20449 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20450 return remoteId.map(function(id) {
20451 return _this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap);
20452 });
20453 };
20454 _proto.getRemoteId = function getRemoteId(iframe, id, map) {
20455 var remoteIdToIdMap = map || this.getRemoteIdToIdMap(iframe);
20456 if (typeof id !== "number") return id;
20457 var remoteId = remoteIdToIdMap.get(id);
20458 if (!remoteId) return -1;
20459 return remoteId;
20460 };
20461 _proto.getRemoteIds = function getRemoteIds(iframe, ids) {
20462 var _this = this;
20463 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20464 return ids.map(function(id) {
20465 return _this.getRemoteId(iframe, id, remoteIdToIdMap);
20466 });
20467 };
20468 _proto.reset = function reset(iframe) {
20469 if (!iframe) {
20470 this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap();
20471 this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
20472 return;
20473 }
20474 this.iframeIdToRemoteIdMap.delete(iframe);
20475 this.iframeRemoteIdToIdMap.delete(iframe);
20476 };
20477 _proto.getIdToRemoteIdMap = function getIdToRemoteIdMap(iframe) {
20478 var idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe);
20479 if (!idToRemoteIdMap) {
20480 idToRemoteIdMap = /* @__PURE__ */ new Map();
20481 this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap);
20482 }
20483 return idToRemoteIdMap;
20484 };
20485 _proto.getRemoteIdToIdMap = function getRemoteIdToIdMap(iframe) {
20486 var remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe);
20487 if (!remoteIdToIdMap) {
20488 remoteIdToIdMap = /* @__PURE__ */ new Map();
20489 this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap);
20490 }
20491 return remoteIdToIdMap;
20492 };
20493 return CrossOriginIframeMirror;
20494 }();
20495 var IframeManager = /*#__PURE__*/ function() {
20496 function IframeManager(options) {
20497 __publicField(this, "iframes", /* @__PURE__ */ new WeakMap());
20498 __publicField(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
20499 __publicField(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
20500 __publicField(this, "crossOriginIframeStyleMirror");
20501 __publicField(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
20502 __publicField(this, "mirror");
20503 __publicField(this, "mutationCb");
20504 __publicField(this, "wrappedEmit");
20505 __publicField(this, "loadListener");
20506 __publicField(this, "stylesheetManager");
20507 __publicField(this, "recordCrossOriginIframes");
20508 this.mutationCb = options.mutationCb;
20509 this.wrappedEmit = options.wrappedEmit;
20510 this.stylesheetManager = options.stylesheetManager;
20511 this.recordCrossOriginIframes = options.recordCrossOriginIframes;
20512 this.crossOriginIframeStyleMirror = new CrossOriginIframeMirror(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror));
20513 this.mirror = options.mirror;
20514 if (this.recordCrossOriginIframes) {
20515 window.addEventListener("message", this.handleMessage.bind(this));
20516 }
20517 }
20518 var _proto = IframeManager.prototype;
20519 _proto.addIframe = function addIframe(iframeEl) {
20520 this.iframes.set(iframeEl, true);
20521 if (iframeEl.contentWindow) this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
20522 };
20523 _proto.addLoadListener = function addLoadListener(cb) {
20524 this.loadListener = cb;
20525 };
20526 _proto.attachIframe = function attachIframe(iframeEl, childSn) {
20527 var _a2, _b;
20528 this.mutationCb({
20529 adds: [
20530 {
20531 parentId: this.mirror.getId(iframeEl),
20532 nextId: null,
20533 node: childSn
20534 }
20535 ],
20536 removes: [],
20537 texts: [],
20538 attributes: [],
20539 isAttachIframe: true
20540 });
20541 if (this.recordCrossOriginIframes) (_a2 = iframeEl.contentWindow) == null ? void 0 : _a2.addEventListener("message", this.handleMessage.bind(this));
20542 (_b = this.loadListener) == null ? void 0 : _b.call(this, iframeEl);
20543 if (iframeEl.contentDocument && iframeEl.contentDocument.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0) this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
20544 };
20545 _proto.handleMessage = function handleMessage(message) {
20546 var crossOriginMessageEvent = message;
20547 if (crossOriginMessageEvent.data.type !== "rrweb" || // To filter out the rrweb messages which are forwarded by some sites.
20548 crossOriginMessageEvent.origin !== crossOriginMessageEvent.data.origin) return;
20549 var iframeSourceWindow = message.source;
20550 if (!iframeSourceWindow) return;
20551 var iframeEl = this.crossOriginIframeMap.get(message.source);
20552 if (!iframeEl) return;
20553 var transformedEvent = this.transformCrossOriginEvent(iframeEl, crossOriginMessageEvent.data.event);
20554 if (transformedEvent) this.wrappedEmit(transformedEvent, crossOriginMessageEvent.data.isCheckout);
20555 };
20556 _proto.transformCrossOriginEvent = function transformCrossOriginEvent(iframeEl, e2) {
20557 var _this = this;
20558 var _a2;
20559 switch(e2.type){
20560 case EventType.FullSnapshot:
20561 {
20562 this.crossOriginIframeMirror.reset(iframeEl);
20563 this.crossOriginIframeStyleMirror.reset(iframeEl);
20564 this.replaceIdOnNode(e2.data.node, iframeEl);
20565 var rootId = e2.data.node.id;
20566 this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
20567 this.patchRootIdOnNode(e2.data.node, rootId);
20568 return {
20569 timestamp: e2.timestamp,
20570 type: EventType.IncrementalSnapshot,
20571 data: {
20572 source: IncrementalSource.Mutation,
20573 adds: [
20574 {
20575 parentId: this.mirror.getId(iframeEl),
20576 nextId: null,
20577 node: e2.data.node
20578 }
20579 ],
20580 removes: [],
20581 texts: [],
20582 attributes: [],
20583 isAttachIframe: true
20584 }
20585 };
20586 }
20587 case EventType.Meta:
20588 case EventType.Load:
20589 case EventType.DomContentLoaded:
20590 {
20591 return false;
20592 }
20593 case EventType.Plugin:
20594 {
20595 return e2;
20596 }
20597 case EventType.Custom:
20598 {
20599 this.replaceIds(e2.data.payload, iframeEl, [
20600 "id",
20601 "parentId",
20602 "previousId",
20603 "nextId"
20604 ]);
20605 return e2;
20606 }
20607 case EventType.IncrementalSnapshot:
20608 {
20609 switch(e2.data.source){
20610 case IncrementalSource.Mutation:
20611 {
20612 e2.data.adds.forEach(function(n2) {
20613 _this.replaceIds(n2, iframeEl, [
20614 "parentId",
20615 "nextId",
20616 "previousId"
20617 ]);
20618 _this.replaceIdOnNode(n2.node, iframeEl);
20619 var rootId = _this.crossOriginIframeRootIdMap.get(iframeEl);
20620 rootId && _this.patchRootIdOnNode(n2.node, rootId);
20621 });
20622 e2.data.removes.forEach(function(n2) {
20623 _this.replaceIds(n2, iframeEl, [
20624 "parentId",
20625 "id"
20626 ]);
20627 });
20628 e2.data.attributes.forEach(function(n2) {
20629 _this.replaceIds(n2, iframeEl, [
20630 "id"
20631 ]);
20632 });
20633 e2.data.texts.forEach(function(n2) {
20634 _this.replaceIds(n2, iframeEl, [
20635 "id"
20636 ]);
20637 });
20638 return e2;
20639 }
20640 case IncrementalSource.Drag:
20641 case IncrementalSource.TouchMove:
20642 case IncrementalSource.MouseMove:
20643 {
20644 e2.data.positions.forEach(function(p) {
20645 _this.replaceIds(p, iframeEl, [
20646 "id"
20647 ]);
20648 });
20649 return e2;
20650 }
20651 case IncrementalSource.ViewportResize:
20652 {
20653 return false;
20654 }
20655 case IncrementalSource.MediaInteraction:
20656 case IncrementalSource.MouseInteraction:
20657 case IncrementalSource.Scroll:
20658 case IncrementalSource.CanvasMutation:
20659 case IncrementalSource.Input:
20660 {
20661 this.replaceIds(e2.data, iframeEl, [
20662 "id"
20663 ]);
20664 return e2;
20665 }
20666 case IncrementalSource.StyleSheetRule:
20667 case IncrementalSource.StyleDeclaration:
20668 {
20669 this.replaceIds(e2.data, iframeEl, [
20670 "id"
20671 ]);
20672 this.replaceStyleIds(e2.data, iframeEl, [
20673 "styleId"
20674 ]);
20675 return e2;
20676 }
20677 case IncrementalSource.Font:
20678 {
20679 return e2;
20680 }
20681 case IncrementalSource.Selection:
20682 {
20683 e2.data.ranges.forEach(function(range) {
20684 _this.replaceIds(range, iframeEl, [
20685 "start",
20686 "end"
20687 ]);
20688 });
20689 return e2;
20690 }
20691 case IncrementalSource.AdoptedStyleSheet:
20692 {
20693 this.replaceIds(e2.data, iframeEl, [
20694 "id"
20695 ]);
20696 this.replaceStyleIds(e2.data, iframeEl, [
20697 "styleIds"
20698 ]);
20699 (_a2 = e2.data.styles) == null ? void 0 : _a2.forEach(function(style) {
20700 _this.replaceStyleIds(style, iframeEl, [
20701 "styleId"
20702 ]);
20703 });
20704 return e2;
20705 }
20706 }
20707 }
20708 }
20709 return false;
20710 };
20711 _proto.replace = function replace(iframeMirror, obj, iframeEl, keys) {
20712 for(var _iterator = _create_for_of_iterator_helper_loose(keys), _step; !(_step = _iterator()).done;){
20713 var key = _step.value;
20714 if (!Array.isArray(obj[key]) && typeof obj[key] !== "number") continue;
20715 if (Array.isArray(obj[key])) {
20716 obj[key] = iframeMirror.getIds(iframeEl, obj[key]);
20717 } else {
20718 obj[key] = iframeMirror.getId(iframeEl, obj[key]);
20719 }
20720 }
20721 return obj;
20722 };
20723 _proto.replaceIds = function replaceIds(obj, iframeEl, keys) {
20724 return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);
20725 };
20726 _proto.replaceStyleIds = function replaceStyleIds(obj, iframeEl, keys) {
20727 return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
20728 };
20729 _proto.replaceIdOnNode = function replaceIdOnNode(node2, iframeEl) {
20730 var _this = this;
20731 this.replaceIds(node2, iframeEl, [
20732 "id",
20733 "rootId"
20734 ]);
20735 if ("childNodes" in node2) {
20736 node2.childNodes.forEach(function(child) {
20737 _this.replaceIdOnNode(child, iframeEl);
20738 });
20739 }
20740 };
20741 _proto.patchRootIdOnNode = function patchRootIdOnNode(node2, rootId) {
20742 var _this = this;
20743 if (node2.type !== NodeType.Document && !node2.rootId) node2.rootId = rootId;
20744 if ("childNodes" in node2) {
20745 node2.childNodes.forEach(function(child) {
20746 _this.patchRootIdOnNode(child, rootId);
20747 });
20748 }
20749 };
20750 return IframeManager;
20751 }();
20752 var ShadowDomManager = /*#__PURE__*/ function() {
20753 function ShadowDomManager(options) {
20754 __publicField(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
20755 __publicField(this, "mutationCb");
20756 __publicField(this, "scrollCb");
20757 __publicField(this, "bypassOptions");
20758 __publicField(this, "mirror");
20759 __publicField(this, "restoreHandlers", []);
20760 this.mutationCb = options.mutationCb;
20761 this.scrollCb = options.scrollCb;
20762 this.bypassOptions = options.bypassOptions;
20763 this.mirror = options.mirror;
20764 this.init();
20765 }
20766 var _proto = ShadowDomManager.prototype;
20767 _proto.init = function init() {
20768 this.reset();
20769 this.patchAttachShadow(Element, document);
20770 };
20771 _proto.addShadowRoot = function addShadowRoot(shadowRoot2, doc) {
20772 var _this = this;
20773 if (!isNativeShadowDom(shadowRoot2)) return;
20774 if (this.shadowDoms.has(shadowRoot2)) return;
20775 this.shadowDoms.add(shadowRoot2);
20776 var observer = initMutationObserver(_extends({}, this.bypassOptions, {
20777 doc: doc,
20778 mutationCb: this.mutationCb,
20779 mirror: this.mirror,
20780 shadowDomManager: this
20781 }), shadowRoot2);
20782 this.restoreHandlers.push(function() {
20783 return observer.disconnect();
20784 });
20785 this.restoreHandlers.push(initScrollObserver(_extends({}, this.bypassOptions, {
20786 scrollCb: this.scrollCb,
20787 // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813
20788 // scroll is not allowed to pass the boundary, so we need to listen the shadow document
20789 doc: shadowRoot2,
20790 mirror: this.mirror
20791 })));
20792 setTimeout(function() {
20793 if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0) _this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot2.adoptedStyleSheets, _this.mirror.getId(index.host(shadowRoot2)));
20794 _this.restoreHandlers.push(initAdoptedStyleSheetObserver({
20795 mirror: _this.mirror,
20796 stylesheetManager: _this.bypassOptions.stylesheetManager
20797 }, shadowRoot2));
20798 }, 0);
20799 };
20800 /**
20801 * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
20802 */ _proto.observeAttachShadow = function observeAttachShadow(iframeElement) {
20803 if (!iframeElement.contentWindow || !iframeElement.contentDocument) return;
20804 this.patchAttachShadow(iframeElement.contentWindow.Element, iframeElement.contentDocument);
20805 };
20806 /**
20807 * Patch 'attachShadow' to observe newly added shadow doms.
20808 */ _proto.patchAttachShadow = function patchAttachShadow(element, doc) {
20809 var manager = this;
20810 this.restoreHandlers.push(patch(element.prototype, "attachShadow", function(original) {
20811 return function(option) {
20812 var sRoot = original.call(this, option);
20813 var shadowRootEl = index.shadowRoot(this);
20814 if (shadowRootEl && inDom(this)) manager.addShadowRoot(shadowRootEl, doc);
20815 return sRoot;
20816 };
20817 }));
20818 };
20819 _proto.reset = function reset() {
20820 this.restoreHandlers.forEach(function(handler) {
20821 try {
20822 handler();
20823 } catch (e2) {}
20824 });
20825 this.restoreHandlers = [];
20826 this.shadowDoms = /* @__PURE__ */ new WeakSet();
20827 };
20828 return ShadowDomManager;
20829 }();
20830 var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
20831 var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
20832 for(var i$1 = 0; i$1 < chars.length; i$1++){
20833 lookup[chars.charCodeAt(i$1)] = i$1;
20834 }
20835 var encode = function encode(arraybuffer) {
20836 var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
20837 for(i2 = 0; i2 < len; i2 += 3){
20838 base64 += chars[bytes[i2] >> 2];
20839 base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
20840 base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
20841 base64 += chars[bytes[i2 + 2] & 63];
20842 }
20843 if (len % 3 === 2) {
20844 base64 = base64.substring(0, base64.length - 1) + "=";
20845 } else if (len % 3 === 1) {
20846 base64 = base64.substring(0, base64.length - 2) + "==";
20847 }
20848 return base64;
20849 };
20850 var canvasVarMap = /* @__PURE__ */ new Map();
20851 function variableListFor$1(ctx, ctor) {
20852 var contextMap = canvasVarMap.get(ctx);
20853 if (!contextMap) {
20854 contextMap = /* @__PURE__ */ new Map();
20855 canvasVarMap.set(ctx, contextMap);
20856 }
20857 if (!contextMap.has(ctor)) {
20858 contextMap.set(ctor, []);
20859 }
20860 return contextMap.get(ctor);
20861 }
20862 var saveWebGLVar = function(value, win, ctx) {
20863 if (!value || !(isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object")) return;
20864 var name = value.constructor.name;
20865 var list2 = variableListFor$1(ctx, name);
20866 var index2 = list2.indexOf(value);
20867 if (index2 === -1) {
20868 index2 = list2.length;
20869 list2.push(value);
20870 }
20871 return index2;
20872 };
20873 function serializeArg(value, win, ctx) {
20874 if (_instanceof(value, Array)) {
20875 return value.map(function(arg) {
20876 return serializeArg(arg, win, ctx);
20877 });
20878 } else if (value === null) {
20879 return value;
20880 } 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)) {
20881 var name = value.constructor.name;
20882 return {
20883 rr_type: name,
20884 args: [
20885 Object.values(value)
20886 ]
20887 };
20888 } else if (// SharedArrayBuffer disabled on most browsers due to spectre.
20889 // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer
20890 // value instanceof SharedArrayBuffer ||
20891 _instanceof(value, ArrayBuffer)) {
20892 var name1 = value.constructor.name;
20893 var base64 = encode(value);
20894 return {
20895 rr_type: name1,
20896 base64: base64
20897 };
20898 } else if (_instanceof(value, DataView)) {
20899 var name2 = value.constructor.name;
20900 return {
20901 rr_type: name2,
20902 args: [
20903 serializeArg(value.buffer, win, ctx),
20904 value.byteOffset,
20905 value.byteLength
20906 ]
20907 };
20908 } else if (_instanceof(value, HTMLImageElement)) {
20909 var name3 = value.constructor.name;
20910 var src = value.src;
20911 return {
20912 rr_type: name3,
20913 src: src
20914 };
20915 } else if (_instanceof(value, HTMLCanvasElement)) {
20916 var name4 = "HTMLImageElement";
20917 var src1 = value.toDataURL();
20918 return {
20919 rr_type: name4,
20920 src: src1
20921 };
20922 } else if (_instanceof(value, ImageData)) {
20923 var name5 = value.constructor.name;
20924 return {
20925 rr_type: name5,
20926 args: [
20927 serializeArg(value.data, win, ctx),
20928 value.width,
20929 value.height
20930 ]
20931 };
20932 } else if (isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
20933 var name6 = value.constructor.name;
20934 var index2 = saveWebGLVar(value, win, ctx);
20935 return {
20936 rr_type: name6,
20937 index: index2
20938 };
20939 }
20940 return value;
20941 }
20942 var serializeArgs = function(args, win, ctx) {
20943 return args.map(function(arg) {
20944 return serializeArg(arg, win, ctx);
20945 });
20946 };
20947 var isInstanceOfWebGLObject = function(value, win) {
20948 var webGLConstructorNames = [
20949 "WebGLActiveInfo",
20950 "WebGLBuffer",
20951 "WebGLFramebuffer",
20952 "WebGLProgram",
20953 "WebGLRenderbuffer",
20954 "WebGLShader",
20955 "WebGLShaderPrecisionFormat",
20956 "WebGLTexture",
20957 "WebGLUniformLocation",
20958 "WebGLVertexArrayObject",
20959 // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.
20960 "WebGLVertexArrayObjectOES"
20961 ];
20962 var supportedWebGLConstructorNames = webGLConstructorNames.filter(function(name) {
20963 return typeof win[name] === "function";
20964 });
20965 return Boolean(supportedWebGLConstructorNames.find(function(name) {
20966 return _instanceof(value, win[name]);
20967 }));
20968 };
20969 function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
20970 var _loop = function() {
20971 var prop = _step.value;
20972 try {
20973 if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
20974 return "continue";
20975 }
20976 var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
20977 return function() {
20978 var _this = this;
20979 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
20980 args[_key] = arguments[_key];
20981 }
20982 if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
20983 setTimeout(function() {
20984 var recordArgs = serializeArgs(args, win, _this);
20985 cb(_this.canvas, {
20986 type: CanvasContext["2D"],
20987 property: prop,
20988 args: recordArgs
20989 });
20990 }, 0);
20991 }
20992 return original.apply(this, args);
20993 };
20994 });
20995 handlers.push(restoreHandler);
20996 } catch (e) {
20997 var hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
20998 set: function set(v2) {
20999 cb(this.canvas, {
21000 type: CanvasContext["2D"],
21001 property: prop,
21002 args: [
21003 v2
21004 ],
21005 setter: true
21006 });
21007 }
21008 });
21009 handlers.push(hookHandler);
21010 }
21011 };
21012 var handlers = [];
21013 var props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
21014 for(var _iterator = _create_for_of_iterator_helper_loose(props2D), _step; !(_step = _iterator()).done;)_loop();
21015 return function() {
21016 handlers.forEach(function(h) {
21017 return h();
21018 });
21019 };
21020 }
21021 function getNormalizedContextName(contextType) {
21022 return contextType === "experimental-webgl" ? "webgl" : contextType;
21023 }
21024 function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
21025 var handlers = [];
21026 try {
21027 var restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
21028 return function(contextType) {
21029 for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
21030 args[_key - 1] = arguments[_key];
21031 }
21032 if (!isBlocked(this, blockClass, blockSelector, true)) {
21033 var ctxName = getNormalizedContextName(contextType);
21034 if (!("__context" in this)) this.__context = ctxName;
21035 if (setPreserveDrawingBufferToTrue && [
21036 "webgl",
21037 "webgl2"
21038 ].includes(ctxName)) {
21039 if (args[0] && _type_of(args[0]) === "object") {
21040 var contextAttributes = args[0];
21041 if (!contextAttributes.preserveDrawingBuffer) {
21042 contextAttributes.preserveDrawingBuffer = true;
21043 }
21044 } else {
21045 args.splice(0, 1, {
21046 preserveDrawingBuffer: true
21047 });
21048 }
21049 }
21050 }
21051 return original.apply(this, [].concat([
21052 contextType
21053 ], args));
21054 };
21055 });
21056 handlers.push(restoreHandler);
21057 } catch (e) {
21058 console.error("failed to patch HTMLCanvasElement.prototype.getContext");
21059 }
21060 return function() {
21061 handlers.forEach(function(h) {
21062 return h();
21063 });
21064 };
21065 }
21066 function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
21067 var _loop = function() {
21068 var prop = _step.value;
21069 if (//prop.startsWith('get') || // e.g. getProgramParameter, but too risky
21070 [
21071 "isContextLost",
21072 "canvas",
21073 "drawingBufferWidth",
21074 "drawingBufferHeight"
21075 ].includes(prop)) {
21076 return "continue";
21077 }
21078 try {
21079 if (typeof prototype[prop] !== "function") {
21080 return "continue";
21081 }
21082 var restoreHandler = patch(prototype, prop, function(original) {
21083 return function() {
21084 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21085 args[_key] = arguments[_key];
21086 }
21087 var result2 = original.apply(this, args);
21088 saveWebGLVar(result2, win, this);
21089 if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
21090 var recordArgs = serializeArgs(args, win, this);
21091 var mutation = {
21092 type: type,
21093 property: prop,
21094 args: recordArgs
21095 };
21096 cb(this.canvas, mutation);
21097 }
21098 return result2;
21099 };
21100 });
21101 handlers.push(restoreHandler);
21102 } catch (e) {
21103 var hookHandler = hookSetter(prototype, prop, {
21104 set: function set(v2) {
21105 cb(this.canvas, {
21106 type: type,
21107 property: prop,
21108 args: [
21109 v2
21110 ],
21111 setter: true
21112 });
21113 }
21114 });
21115 handlers.push(hookHandler);
21116 }
21117 };
21118 var handlers = [];
21119 var props = Object.getOwnPropertyNames(prototype);
21120 for(var _iterator = _create_for_of_iterator_helper_loose(props), _step; !(_step = _iterator()).done;)_loop();
21121 return handlers;
21122 }
21123 function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
21124 var _handlers;
21125 var handlers = [];
21126 (_handlers = handlers).push.apply(_handlers, [].concat(patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, blockSelector, win)));
21127 if (typeof win.WebGL2RenderingContext !== "undefined") {
21128 var _handlers1;
21129 (_handlers1 = handlers).push.apply(_handlers1, [].concat(patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, blockSelector, win)));
21130 }
21131 return function() {
21132 handlers.forEach(function(h) {
21133 return h();
21134 });
21135 };
21136 }
21137 var encodedJs = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=";
21138 var decodeBase64 = function(base64) {
21139 return Uint8Array.from(atob(base64), function(c2) {
21140 return c2.charCodeAt(0);
21141 });
21142 };
21143 var blob = typeof window !== "undefined" && window.Blob && new Blob([
21144 decodeBase64(encodedJs)
21145 ], {
21146 type: "text/javascript;charset=utf-8"
21147 });
21148 function WorkerWrapper(options) {
21149 var objURL;
21150 try {
21151 objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
21152 if (!objURL) throw "";
21153 var worker = new Worker(objURL, {
21154 name: options == null ? void 0 : options.name
21155 });
21156 worker.addEventListener("error", function() {
21157 (window.URL || window.webkitURL).revokeObjectURL(objURL);
21158 });
21159 return worker;
21160 } catch (e2) {
21161 return new Worker("data:text/javascript;base64," + encodedJs, {
21162 name: options == null ? void 0 : options.name
21163 });
21164 } finally{
21165 objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
21166 }
21167 }
21168 var CanvasManager = /*#__PURE__*/ function() {
21169 function CanvasManager(options) {
21170 var _this = this;
21171 __publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
21172 __publicField(this, "rafStamps", {
21173 latestId: 0,
21174 invokeId: null
21175 });
21176 __publicField(this, "mirror");
21177 __publicField(this, "mutationCb");
21178 __publicField(this, "resetObservers");
21179 __publicField(this, "frozen", false);
21180 __publicField(this, "locked", false);
21181 __publicField(this, "processMutation", function(target, mutation) {
21182 var newFrame = _this.rafStamps.invokeId && _this.rafStamps.latestId !== _this.rafStamps.invokeId;
21183 if (newFrame || !_this.rafStamps.invokeId) _this.rafStamps.invokeId = _this.rafStamps.latestId;
21184 if (!_this.pendingCanvasMutations.has(target)) {
21185 _this.pendingCanvasMutations.set(target, []);
21186 }
21187 _this.pendingCanvasMutations.get(target).push(mutation);
21188 });
21189 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;
21190 this.mutationCb = options.mutationCb;
21191 this.mirror = options.mirror;
21192 if (recordCanvas && sampling === "all") this.initCanvasMutationObserver(win, blockClass, blockSelector);
21193 if (recordCanvas && typeof sampling === "number") this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
21194 dataURLOptions: dataURLOptions
21195 });
21196 }
21197 var _proto = CanvasManager.prototype;
21198 _proto.reset = function reset() {
21199 this.pendingCanvasMutations.clear();
21200 this.resetObservers && this.resetObservers();
21201 };
21202 _proto.freeze = function freeze() {
21203 this.frozen = true;
21204 };
21205 _proto.unfreeze = function unfreeze() {
21206 this.frozen = false;
21207 };
21208 _proto.lock = function lock() {
21209 this.locked = true;
21210 };
21211 _proto.unlock = function unlock() {
21212 this.locked = false;
21213 };
21214 _proto.initCanvasFPSObserver = function initCanvasFPSObserver(fps, win, blockClass, blockSelector, options) {
21215 var _this = this;
21216 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, true);
21217 var snapshotInProgressMap = /* @__PURE__ */ new Map();
21218 var worker = new WorkerWrapper();
21219 worker.onmessage = function(e2) {
21220 var id = e2.data.id;
21221 snapshotInProgressMap.set(id, false);
21222 if (!("base64" in e2.data)) return;
21223 var _e2_data = e2.data, base64 = _e2_data.base64, type = _e2_data.type, width = _e2_data.width, height = _e2_data.height;
21224 _this.mutationCb({
21225 id: id,
21226 type: CanvasContext["2D"],
21227 commands: [
21228 {
21229 property: "clearRect",
21230 // wipe canvas
21231 args: [
21232 0,
21233 0,
21234 width,
21235 height
21236 ]
21237 },
21238 {
21239 property: "drawImage",
21240 // draws (semi-transparent) image
21241 args: [
21242 {
21243 rr_type: "ImageBitmap",
21244 args: [
21245 {
21246 rr_type: "Blob",
21247 data: [
21248 {
21249 rr_type: "ArrayBuffer",
21250 base64: base64
21251 }
21252 ],
21253 type: type
21254 }
21255 ]
21256 },
21257 0,
21258 0
21259 ]
21260 }
21261 ]
21262 });
21263 };
21264 var timeBetweenSnapshots = 1e3 / fps;
21265 var lastSnapshotTime = 0;
21266 var rafId;
21267 var getCanvas = function() {
21268 var matchedCanvas = [];
21269 win.document.querySelectorAll("canvas").forEach(function(canvas) {
21270 if (!isBlocked(canvas, blockClass, blockSelector, true)) {
21271 matchedCanvas.push(canvas);
21272 }
21273 });
21274 return matchedCanvas;
21275 };
21276 var takeCanvasSnapshots = function(timestamp) {
21277 if (lastSnapshotTime && timestamp - lastSnapshotTime < timeBetweenSnapshots) {
21278 rafId = requestAnimationFrame(takeCanvasSnapshots);
21279 return;
21280 }
21281 lastSnapshotTime = timestamp;
21282 var _this1 = _this;
21283 getCanvas().forEach(/*#__PURE__*/ _async_to_generator(function(canvas) {
21284 var _a2, id, context, bitmap;
21285 return _ts_generator(this, function(_state) {
21286 switch(_state.label){
21287 case 0:
21288 id = _this1.mirror.getId(canvas);
21289 if (snapshotInProgressMap.get(id)) return [
21290 2
21291 ];
21292 if (canvas.width === 0 || canvas.height === 0) return [
21293 2
21294 ];
21295 snapshotInProgressMap.set(id, true);
21296 if ([
21297 "webgl",
21298 "webgl2"
21299 ].includes(canvas.__context)) {
21300 context = canvas.getContext(canvas.__context);
21301 if (((_a2 = context == null ? void 0 : context.getContextAttributes()) == null ? void 0 : _a2.preserveDrawingBuffer) === false) {
21302 context.clear(context.COLOR_BUFFER_BIT);
21303 }
21304 }
21305 return [
21306 4,
21307 createImageBitmap(canvas)
21308 ];
21309 case 1:
21310 bitmap = _state.sent();
21311 worker.postMessage({
21312 id: id,
21313 bitmap: bitmap,
21314 width: canvas.width,
21315 height: canvas.height,
21316 dataURLOptions: options.dataURLOptions
21317 }, [
21318 bitmap
21319 ]);
21320 return [
21321 2
21322 ];
21323 }
21324 });
21325 }));
21326 rafId = requestAnimationFrame(takeCanvasSnapshots);
21327 };
21328 rafId = requestAnimationFrame(takeCanvasSnapshots);
21329 this.resetObservers = function() {
21330 canvasContextReset();
21331 cancelAnimationFrame(rafId);
21332 };
21333 };
21334 _proto.initCanvasMutationObserver = function initCanvasMutationObserver(win, blockClass, blockSelector) {
21335 this.startRAFTimestamping();
21336 this.startPendingCanvasMutationFlusher();
21337 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, false);
21338 var canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21339 var canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21340 this.resetObservers = function() {
21341 canvasContextReset();
21342 canvas2DReset();
21343 canvasWebGL1and2Reset();
21344 };
21345 };
21346 _proto.startPendingCanvasMutationFlusher = function startPendingCanvasMutationFlusher() {
21347 var _this = this;
21348 requestAnimationFrame(function() {
21349 return _this.flushPendingCanvasMutations();
21350 });
21351 };
21352 _proto.startRAFTimestamping = function startRAFTimestamping() {
21353 var _this = this;
21354 var setLatestRAFTimestamp = function(timestamp) {
21355 _this.rafStamps.latestId = timestamp;
21356 requestAnimationFrame(setLatestRAFTimestamp);
21357 };
21358 requestAnimationFrame(setLatestRAFTimestamp);
21359 };
21360 _proto.flushPendingCanvasMutations = function flushPendingCanvasMutations() {
21361 var _this = this;
21362 this.pendingCanvasMutations.forEach(function(_values, canvas) {
21363 var id = _this.mirror.getId(canvas);
21364 _this.flushPendingCanvasMutationFor(canvas, id);
21365 });
21366 requestAnimationFrame(function() {
21367 return _this.flushPendingCanvasMutations();
21368 });
21369 };
21370 _proto.flushPendingCanvasMutationFor = function flushPendingCanvasMutationFor(canvas, id) {
21371 if (this.frozen || this.locked) {
21372 return;
21373 }
21374 var valuesWithType = this.pendingCanvasMutations.get(canvas);
21375 if (!valuesWithType || id === -1) return;
21376 var values = valuesWithType.map(function(value) {
21377 value.type; var rest = _object_without_properties_loose(value, [
21378 "type"
21379 ]);
21380 return rest;
21381 });
21382 var type = valuesWithType[0].type;
21383 this.mutationCb({
21384 id: id,
21385 type: type,
21386 commands: values
21387 });
21388 this.pendingCanvasMutations.delete(canvas);
21389 };
21390 return CanvasManager;
21391 }();
21392 var StylesheetManager = /*#__PURE__*/ function() {
21393 function StylesheetManager(options) {
21394 __publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
21395 __publicField(this, "mutationCb");
21396 __publicField(this, "adoptedStyleSheetCb");
21397 __publicField(this, "styleMirror", new StyleSheetMirror());
21398 this.mutationCb = options.mutationCb;
21399 this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
21400 }
21401 var _proto = StylesheetManager.prototype;
21402 _proto.attachLinkElement = function attachLinkElement(linkEl, childSn) {
21403 if ("_cssText" in childSn.attributes) this.mutationCb({
21404 adds: [],
21405 removes: [],
21406 texts: [],
21407 attributes: [
21408 {
21409 id: childSn.id,
21410 attributes: childSn.attributes
21411 }
21412 ]
21413 });
21414 this.trackLinkElement(linkEl);
21415 };
21416 _proto.trackLinkElement = function trackLinkElement(linkEl) {
21417 if (this.trackedLinkElements.has(linkEl)) return;
21418 this.trackedLinkElements.add(linkEl);
21419 this.trackStylesheetInLinkElement(linkEl);
21420 };
21421 _proto.adoptStyleSheets = function adoptStyleSheets(sheets, hostId) {
21422 var _this, _loop = function() {
21423 var sheet = _step.value;
21424 var styleId = void 0;
21425 if (!_this.styleMirror.has(sheet)) {
21426 styleId = _this.styleMirror.add(sheet);
21427 styles.push({
21428 styleId: styleId,
21429 rules: Array.from(sheet.rules || CSSRule, function(r2, index2) {
21430 return {
21431 rule: stringifyRule(r2, sheet.href),
21432 index: index2
21433 };
21434 })
21435 });
21436 } else styleId = _this.styleMirror.getId(sheet);
21437 adoptedStyleSheetData.styleIds.push(styleId);
21438 };
21439 if (sheets.length === 0) return;
21440 var adoptedStyleSheetData = {
21441 id: hostId,
21442 styleIds: []
21443 };
21444 var styles = [];
21445 for(var _iterator = _create_for_of_iterator_helper_loose(sheets), _step; !(_step = _iterator()).done;)_this = this, _loop();
21446 if (styles.length > 0) adoptedStyleSheetData.styles = styles;
21447 this.adoptedStyleSheetCb(adoptedStyleSheetData);
21448 };
21449 _proto.reset = function reset() {
21450 this.styleMirror.reset();
21451 this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
21452 };
21453 // TODO: take snapshot on stylesheet reload by applying event listener
21454 _proto.trackStylesheetInLinkElement = function trackStylesheetInLinkElement(_linkEl) {};
21455 return StylesheetManager;
21456 }();
21457 var ProcessedNodeManager = /*#__PURE__*/ function() {
21458 function ProcessedNodeManager() {
21459 __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap());
21460 __publicField(this, "active", false);
21461 }
21462 var _proto = ProcessedNodeManager.prototype;
21463 _proto.inOtherBuffer = function inOtherBuffer(node2, thisBuffer) {
21464 var buffers = this.nodeMap.get(node2);
21465 return buffers && Array.from(buffers).some(function(buffer) {
21466 return buffer !== thisBuffer;
21467 });
21468 };
21469 _proto.add = function add(node2, buffer) {
21470 var _this = this;
21471 if (!this.active) {
21472 this.active = true;
21473 requestAnimationFrame(function() {
21474 _this.nodeMap = /* @__PURE__ */ new WeakMap();
21475 _this.active = false;
21476 });
21477 }
21478 this.nodeMap.set(node2, (this.nodeMap.get(node2) || /* @__PURE__ */ new Set()).add(buffer));
21479 };
21480 _proto.destroy = function destroy() {};
21481 return ProcessedNodeManager;
21482 }();
21483 var wrappedEmit;
21484 var takeFullSnapshot$1;
21485 var canvasManager;
21486 var recording = false;
21487 try {
21488 if (Array.from([
21489 1
21490 ], function(x2) {
21491 return x2 * 2;
21492 })[0] !== 2) {
21493 var cleanFrame = document.createElement("iframe");
21494 document.body.appendChild(cleanFrame);
21495 Array.from = ((_a = cleanFrame.contentWindow) == null ? void 0 : _a.Array.from) || Array.from;
21496 document.body.removeChild(cleanFrame);
21497 }
21498 } catch (err) {
21499 console.debug("Unable to override Array.from", err);
21500 }
21501 var mirror = createMirror$2();
21502 function record(options) {
21503 if (options === void 0) options = {};
21504 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() {
21505 return false;
21506 } : _options_keepIframeSrcFn, _options_ignoreCSSAttributes = options.ignoreCSSAttributes, ignoreCSSAttributes = _options_ignoreCSSAttributes === void 0 ? /* @__PURE__ */ new Set([]) : _options_ignoreCSSAttributes, errorHandler2 = options.errorHandler;
21507 registerErrorHandler(errorHandler2);
21508 var inEmittingFrame = recordCrossOriginIframes ? window.parent === window : true;
21509 var passEmitsToParent = false;
21510 if (!inEmittingFrame) {
21511 try {
21512 if (window.parent.document) {
21513 passEmitsToParent = false;
21514 }
21515 } catch (e2) {
21516 passEmitsToParent = true;
21517 }
21518 }
21519 if (inEmittingFrame && !emit) {
21520 throw new Error("emit function is required");
21521 }
21522 if (!inEmittingFrame && !passEmitsToParent) {
21523 return function() {};
21524 }
21525 if (mousemoveWait !== void 0 && sampling.mousemove === void 0) {
21526 sampling.mousemove = mousemoveWait;
21527 }
21528 mirror.reset();
21529 var maskInputOptions = maskAllInputs === true ? {
21530 color: true,
21531 date: true,
21532 "datetime-local": true,
21533 email: true,
21534 month: true,
21535 number: true,
21536 range: true,
21537 search: true,
21538 tel: true,
21539 text: true,
21540 time: true,
21541 url: true,
21542 week: true,
21543 textarea: true,
21544 select: true,
21545 password: true,
21546 hidden: true
21547 } : _maskInputOptions !== void 0 ? _maskInputOptions : {
21548 password: true
21549 };
21550 var slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
21551 script: true,
21552 comment: true,
21553 headFavicon: true,
21554 headWhitespace: true,
21555 headMetaSocial: true,
21556 headMetaRobots: true,
21557 headMetaHttpEquiv: true,
21558 headMetaVerification: true,
21559 // the following are off for slimDOMOptions === true,
21560 // as they destroy some (hidden) info:
21561 headMetaAuthorship: _slimDOMOptions === "all",
21562 headMetaDescKeywords: _slimDOMOptions === "all",
21563 headTitleMutations: _slimDOMOptions === "all"
21564 } : _slimDOMOptions ? _slimDOMOptions : {};
21565 polyfill$1();
21566 var lastFullSnapshotEvent;
21567 var incrementalSnapshotCount = 0;
21568 var eventProcessor = function(e2) {
21569 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
21570 var plugin3 = _step.value;
21571 if (plugin3.eventProcessor) {
21572 e2 = plugin3.eventProcessor(e2);
21573 }
21574 }
21575 if (packFn && // Disable packing events which will be emitted to parent frames.
21576 !passEmitsToParent) {
21577 e2 = packFn(e2);
21578 }
21579 return e2;
21580 };
21581 wrappedEmit = function(r2, isCheckout) {
21582 var _a2;
21583 var e2 = r2;
21584 e2.timestamp = nowTimestamp();
21585 if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
21586 mutationBuffers.forEach(function(buf) {
21587 return buf.unfreeze();
21588 });
21589 }
21590 if (inEmittingFrame) {
21591 emit == null ? void 0 : emit(eventProcessor(e2), isCheckout);
21592 } else if (passEmitsToParent) {
21593 var message = {
21594 type: "rrweb",
21595 event: eventProcessor(e2),
21596 origin: window.location.origin,
21597 isCheckout: isCheckout
21598 };
21599 window.parent.postMessage(message, "*");
21600 }
21601 if (e2.type === EventType.FullSnapshot) {
21602 lastFullSnapshotEvent = e2;
21603 incrementalSnapshotCount = 0;
21604 } else if (e2.type === EventType.IncrementalSnapshot) {
21605 if (e2.data.source === IncrementalSource.Mutation && e2.data.isAttachIframe) {
21606 return;
21607 }
21608 incrementalSnapshotCount++;
21609 var exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
21610 var exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
21611 if (exceedCount || exceedTime) {
21612 takeFullSnapshot$1(true);
21613 }
21614 }
21615 };
21616 var wrappedMutationEmit = function(m) {
21617 wrappedEmit({
21618 type: EventType.IncrementalSnapshot,
21619 data: _extends({
21620 source: IncrementalSource.Mutation
21621 }, m)
21622 });
21623 };
21624 var wrappedScrollEmit = function(p) {
21625 return wrappedEmit({
21626 type: EventType.IncrementalSnapshot,
21627 data: _extends({
21628 source: IncrementalSource.Scroll
21629 }, p)
21630 });
21631 };
21632 var wrappedCanvasMutationEmit = function(p) {
21633 return wrappedEmit({
21634 type: EventType.IncrementalSnapshot,
21635 data: _extends({
21636 source: IncrementalSource.CanvasMutation
21637 }, p)
21638 });
21639 };
21640 var wrappedAdoptedStyleSheetEmit = function(a2) {
21641 return wrappedEmit({
21642 type: EventType.IncrementalSnapshot,
21643 data: _extends({
21644 source: IncrementalSource.AdoptedStyleSheet
21645 }, a2)
21646 });
21647 };
21648 var stylesheetManager = new StylesheetManager({
21649 mutationCb: wrappedMutationEmit,
21650 adoptedStyleSheetCb: wrappedAdoptedStyleSheetEmit
21651 });
21652 var iframeManager = new IframeManager({
21653 mirror: mirror,
21654 mutationCb: wrappedMutationEmit,
21655 stylesheetManager: stylesheetManager,
21656 recordCrossOriginIframes: recordCrossOriginIframes,
21657 wrappedEmit: wrappedEmit
21658 });
21659 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
21660 var plugin3 = _step.value;
21661 if (plugin3.getMirror) plugin3.getMirror({
21662 nodeMirror: mirror,
21663 crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,
21664 crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror
21665 });
21666 }
21667 var processedNodeManager = new ProcessedNodeManager();
21668 canvasManager = new CanvasManager({
21669 recordCanvas: recordCanvas,
21670 mutationCb: wrappedCanvasMutationEmit,
21671 win: window,
21672 blockClass: blockClass,
21673 blockSelector: blockSelector,
21674 mirror: mirror,
21675 sampling: sampling.canvas,
21676 dataURLOptions: dataURLOptions
21677 });
21678 var shadowDomManager = new ShadowDomManager({
21679 mutationCb: wrappedMutationEmit,
21680 scrollCb: wrappedScrollEmit,
21681 bypassOptions: {
21682 blockClass: blockClass,
21683 blockSelector: blockSelector,
21684 maskTextClass: maskTextClass,
21685 maskTextSelector: maskTextSelector,
21686 inlineStylesheet: inlineStylesheet,
21687 maskInputOptions: maskInputOptions,
21688 dataURLOptions: dataURLOptions,
21689 maskTextFn: maskTextFn,
21690 maskInputFn: maskInputFn,
21691 recordCanvas: recordCanvas,
21692 inlineImages: inlineImages,
21693 sampling: sampling,
21694 slimDOMOptions: slimDOMOptions,
21695 iframeManager: iframeManager,
21696 stylesheetManager: stylesheetManager,
21697 canvasManager: canvasManager,
21698 keepIframeSrcFn: keepIframeSrcFn,
21699 processedNodeManager: processedNodeManager
21700 },
21701 mirror: mirror
21702 });
21703 takeFullSnapshot$1 = function(isCheckout) {
21704 if (isCheckout === void 0) isCheckout = false;
21705 if (!recordDOM) {
21706 return;
21707 }
21708 wrappedEmit({
21709 type: EventType.Meta,
21710 data: {
21711 href: window.location.href,
21712 width: getWindowWidth(),
21713 height: getWindowHeight()
21714 }
21715 }, isCheckout);
21716 stylesheetManager.reset();
21717 shadowDomManager.init();
21718 mutationBuffers.forEach(function(buf) {
21719 return buf.lock();
21720 });
21721 var node2 = snapshot(document, {
21722 mirror: mirror,
21723 blockClass: blockClass,
21724 blockSelector: blockSelector,
21725 maskTextClass: maskTextClass,
21726 maskTextSelector: maskTextSelector,
21727 inlineStylesheet: inlineStylesheet,
21728 maskAllInputs: maskInputOptions,
21729 maskTextFn: maskTextFn,
21730 maskInputFn: maskInputFn,
21731 slimDOM: slimDOMOptions,
21732 dataURLOptions: dataURLOptions,
21733 recordCanvas: recordCanvas,
21734 inlineImages: inlineImages,
21735 onSerialize: function(n2) {
21736 if (isSerializedIframe(n2, mirror)) {
21737 iframeManager.addIframe(n2);
21738 }
21739 if (isSerializedStylesheet(n2, mirror)) {
21740 stylesheetManager.trackLinkElement(n2);
21741 }
21742 if (hasShadowRoot(n2)) {
21743 shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
21744 }
21745 },
21746 onIframeLoad: function(iframe, childSn) {
21747 iframeManager.attachIframe(iframe, childSn);
21748 shadowDomManager.observeAttachShadow(iframe);
21749 },
21750 onStylesheetLoad: function(linkEl, childSn) {
21751 stylesheetManager.attachLinkElement(linkEl, childSn);
21752 },
21753 keepIframeSrcFn: keepIframeSrcFn
21754 });
21755 if (!node2) {
21756 return console.warn("Failed to snapshot the document");
21757 }
21758 wrappedEmit({
21759 type: EventType.FullSnapshot,
21760 data: {
21761 node: node2,
21762 initialOffset: getWindowScroll(window)
21763 }
21764 }, isCheckout);
21765 mutationBuffers.forEach(function(buf) {
21766 return buf.unlock();
21767 });
21768 if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0) stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.getId(document));
21769 };
21770 try {
21771 var handlers = [];
21772 var observe = function(doc) {
21773 var _a2;
21774 return callbackWrapper(initObservers)({
21775 mutationCb: wrappedMutationEmit,
21776 mousemoveCb: function(positions, source) {
21777 return wrappedEmit({
21778 type: EventType.IncrementalSnapshot,
21779 data: {
21780 source: source,
21781 positions: positions
21782 }
21783 });
21784 },
21785 mouseInteractionCb: function(d) {
21786 return wrappedEmit({
21787 type: EventType.IncrementalSnapshot,
21788 data: _extends({
21789 source: IncrementalSource.MouseInteraction
21790 }, d)
21791 });
21792 },
21793 scrollCb: wrappedScrollEmit,
21794 viewportResizeCb: function(d) {
21795 return wrappedEmit({
21796 type: EventType.IncrementalSnapshot,
21797 data: _extends({
21798 source: IncrementalSource.ViewportResize
21799 }, d)
21800 });
21801 },
21802 inputCb: function(v2) {
21803 return wrappedEmit({
21804 type: EventType.IncrementalSnapshot,
21805 data: _extends({
21806 source: IncrementalSource.Input
21807 }, v2)
21808 });
21809 },
21810 mediaInteractionCb: function(p) {
21811 return wrappedEmit({
21812 type: EventType.IncrementalSnapshot,
21813 data: _extends({
21814 source: IncrementalSource.MediaInteraction
21815 }, p)
21816 });
21817 },
21818 styleSheetRuleCb: function(r2) {
21819 return wrappedEmit({
21820 type: EventType.IncrementalSnapshot,
21821 data: _extends({
21822 source: IncrementalSource.StyleSheetRule
21823 }, r2)
21824 });
21825 },
21826 styleDeclarationCb: function(r2) {
21827 return wrappedEmit({
21828 type: EventType.IncrementalSnapshot,
21829 data: _extends({
21830 source: IncrementalSource.StyleDeclaration
21831 }, r2)
21832 });
21833 },
21834 canvasMutationCb: wrappedCanvasMutationEmit,
21835 fontCb: function(p) {
21836 return wrappedEmit({
21837 type: EventType.IncrementalSnapshot,
21838 data: _extends({
21839 source: IncrementalSource.Font
21840 }, p)
21841 });
21842 },
21843 selectionCb: function(p) {
21844 wrappedEmit({
21845 type: EventType.IncrementalSnapshot,
21846 data: _extends({
21847 source: IncrementalSource.Selection
21848 }, p)
21849 });
21850 },
21851 customElementCb: function(c2) {
21852 wrappedEmit({
21853 type: EventType.IncrementalSnapshot,
21854 data: _extends({
21855 source: IncrementalSource.CustomElement
21856 }, c2)
21857 });
21858 },
21859 blockClass: blockClass,
21860 ignoreClass: ignoreClass,
21861 ignoreSelector: ignoreSelector,
21862 maskTextClass: maskTextClass,
21863 maskTextSelector: maskTextSelector,
21864 maskInputOptions: maskInputOptions,
21865 inlineStylesheet: inlineStylesheet,
21866 sampling: sampling,
21867 recordDOM: recordDOM,
21868 recordCanvas: recordCanvas,
21869 inlineImages: inlineImages,
21870 userTriggeredOnInput: userTriggeredOnInput,
21871 collectFonts: collectFonts,
21872 doc: doc,
21873 maskInputFn: maskInputFn,
21874 maskTextFn: maskTextFn,
21875 keepIframeSrcFn: keepIframeSrcFn,
21876 blockSelector: blockSelector,
21877 slimDOMOptions: slimDOMOptions,
21878 dataURLOptions: dataURLOptions,
21879 mirror: mirror,
21880 iframeManager: iframeManager,
21881 stylesheetManager: stylesheetManager,
21882 shadowDomManager: shadowDomManager,
21883 processedNodeManager: processedNodeManager,
21884 canvasManager: canvasManager,
21885 ignoreCSSAttributes: ignoreCSSAttributes,
21886 plugins: ((_a2 = plugins == null ? void 0 : plugins.filter(function(p) {
21887 return p.observer;
21888 })) == null ? void 0 : _a2.map(function(p) {
21889 return {
21890 observer: p.observer,
21891 options: p.options,
21892 callback: function(payload) {
21893 return wrappedEmit({
21894 type: EventType.Plugin,
21895 data: {
21896 plugin: p.name,
21897 payload: payload
21898 }
21899 });
21900 }
21901 };
21902 })) || []
21903 }, hooks);
21904 };
21905 iframeManager.addLoadListener(function(iframeEl) {
21906 try {
21907 handlers.push(observe(iframeEl.contentDocument));
21908 } catch (error) {
21909 console.warn(error);
21910 }
21911 });
21912 var init = function() {
21913 takeFullSnapshot$1();
21914 handlers.push(observe(document));
21915 recording = true;
21916 };
21917 if (document.readyState === "interactive" || document.readyState === "complete") {
21918 init();
21919 } else {
21920 handlers.push(on("DOMContentLoaded", function() {
21921 wrappedEmit({
21922 type: EventType.DomContentLoaded,
21923 data: {}
21924 });
21925 if (recordAfter === "DOMContentLoaded") init();
21926 }));
21927 handlers.push(on("load", function() {
21928 wrappedEmit({
21929 type: EventType.Load,
21930 data: {}
21931 });
21932 if (recordAfter === "load") init();
21933 }, window));
21934 }
21935 return function() {
21936 handlers.forEach(function(handler) {
21937 try {
21938 handler();
21939 } catch (error) {
21940 var msg = String(error).toLowerCase();
21941 if (!msg.includes("cross-origin")) {
21942 console.warn(error);
21943 }
21944 }
21945 });
21946 processedNodeManager.destroy();
21947 recording = false;
21948 unregisterErrorHandler();
21949 };
21950 } catch (error) {
21951 console.warn(error);
21952 }
21953 }
21954 record.addCustomEvent = function(tag, payload) {
21955 if (!recording) {
21956 throw new Error("please add custom event after start recording");
21957 }
21958 wrappedEmit({
21959 type: EventType.Custom,
21960 data: {
21961 tag: tag,
21962 payload: payload
21963 }
21964 });
21965 };
21966 record.freezePage = function() {
21967 mutationBuffers.forEach(function(buf) {
21968 return buf.freeze();
21969 });
21970 };
21971 record.takeFullSnapshot = function(isCheckout) {
21972 if (!recording) {
21973 throw new Error("please take full snapshot after start recording");
21974 }
21975 takeFullSnapshot$1(isCheckout);
21976 };
21977 record.mirror = mirror;
21978 var n;
21979 !function(t2) {
21980 t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
21981 }(n || (n = {}));
21982 record.addCustomEvent;
21983 record.freezePage;
21984 record.takeFullSnapshot;
21985
21986 var setImmediate = win['setImmediate'];
21987 var builtInProp, cycle, schedulingQueue,
21988 ToString = Object.prototype.toString,
21989 timer = (typeof setImmediate !== 'undefined') ?
21990 function timer(fn) { return setImmediate(fn); } :
21991 setTimeout;
21992
21993 // dammit, IE8.
21994 try {
21995 Object.defineProperty({},'x',{});
21996 builtInProp = function builtInProp(obj,name,val,config) {
21997 return Object.defineProperty(obj,name,{
21998 value: val,
21999 writable: true,
22000 configurable: config !== false
22001 });
22002 };
22003 }
22004 catch (err) {
22005 builtInProp = function builtInProp(obj,name,val) {
22006 obj[name] = val;
22007 return obj;
22008 };
22009 }
22010
22011 // Note: using a queue instead of array for efficiency
22012 schedulingQueue = (function Queue() {
22013 var first, last, item;
22014
22015 function Item(fn,self) {
22016 this.fn = fn;
22017 this.self = self;
22018 this.next = void 0;
22019 }
22020
22021 return {
22022 add: function add(fn,self) {
22023 item = new Item(fn,self);
22024 if (last) {
22025 last.next = item;
22026 }
22027 else {
22028 first = item;
22029 }
22030 last = item;
22031 item = void 0;
22032 },
22033 drain: function drain() {
22034 var f = first;
22035 first = last = cycle = void 0;
22036
22037 while (f) {
22038 f.fn.call(f.self);
22039 f = f.next;
22040 }
22041 }
22042 };
22043 })();
22044
22045 function schedule(fn,self) {
22046 schedulingQueue.add(fn,self);
22047 if (!cycle) {
22048 cycle = timer(schedulingQueue.drain);
22049 }
22050 }
22051
22052 // promise duck typing
22053 function isThenable(o) {
22054 var _then, oType = typeof o;
22055
22056 if (o !== null && (oType === 'object' || oType === 'function')) {
22057 _then = o.then;
22058 }
22059 return typeof _then === 'function' ? _then : false;
22060 }
22061
22062 function notify() {
22063 for (var i=0; i<this.chain.length; i++) {
22064 notifyIsolated(
22065 this,
22066 (this.state === 1) ? this.chain[i].success : this.chain[i].failure,
22067 this.chain[i]
22068 );
22069 }
22070 this.chain.length = 0;
22071 }
22072
22073 // NOTE: This is a separate function to isolate
22074 // the `try..catch` so that other code can be
22075 // optimized better
22076 function notifyIsolated(self,cb,chain) {
22077 var ret, _then;
22078 try {
22079 if (cb === false) {
22080 chain.reject(self.msg);
22081 }
22082 else {
22083 if (cb === true) {
22084 ret = self.msg;
22085 }
22086 else {
22087 ret = cb.call(void 0,self.msg);
22088 }
22089
22090 if (ret === chain.promise) {
22091 chain.reject(TypeError('Promise-chain cycle'));
22092 }
22093 // eslint-disable-next-line no-cond-assign
22094 else if (_then = isThenable(ret)) {
22095 _then.call(ret,chain.resolve,chain.reject);
22096 }
22097 else {
22098 chain.resolve(ret);
22099 }
22100 }
22101 }
22102 catch (err) {
22103 chain.reject(err);
22104 }
22105 }
22106
22107 function resolve(msg) {
22108 var _then, self = this;
22109
22110 // already triggered?
22111 if (self.triggered) { return; }
22112
22113 self.triggered = true;
22114
22115 // unwrap
22116 if (self.def) {
22117 self = self.def;
22118 }
22119
22120 try {
22121 // eslint-disable-next-line no-cond-assign
22122 if (_then = isThenable(msg)) {
22123 schedule(function(){
22124 var defWrapper = new MakeDefWrapper(self);
22125 try {
22126 _then.call(msg,
22127 function $resolve$(){ resolve.apply(defWrapper,arguments); },
22128 function $reject$(){ reject.apply(defWrapper,arguments); }
22129 );
22130 }
22131 catch (err) {
22132 reject.call(defWrapper,err);
22133 }
22134 });
22135 }
22136 else {
22137 self.msg = msg;
22138 self.state = 1;
22139 if (self.chain.length > 0) {
22140 schedule(notify,self);
22141 }
22142 }
22143 }
22144 catch (err) {
22145 reject.call(new MakeDefWrapper(self),err);
22146 }
22147 }
22148
22149 function reject(msg) {
22150 var self = this;
22151
22152 // already triggered?
22153 if (self.triggered) { return; }
22154
22155 self.triggered = true;
22156
22157 // unwrap
22158 if (self.def) {
22159 self = self.def;
22160 }
22161
22162 self.msg = msg;
22163 self.state = 2;
22164 if (self.chain.length > 0) {
22165 schedule(notify,self);
22166 }
22167 }
22168
22169 function iteratePromises(Constructor,arr,resolver,rejecter) {
22170 for (var idx=0; idx<arr.length; idx++) {
22171 (function IIFE(idx){
22172 Constructor.resolve(arr[idx])
22173 .then(
22174 function $resolver$(msg){
22175 resolver(idx,msg);
22176 },
22177 rejecter
22178 );
22179 })(idx);
22180 }
22181 }
22182
22183 function MakeDefWrapper(self) {
22184 this.def = self;
22185 this.triggered = false;
22186 }
22187
22188 function MakeDef(self) {
22189 this.promise = self;
22190 this.state = 0;
22191 this.triggered = false;
22192 this.chain = [];
22193 this.msg = void 0;
22194 }
22195
22196 function NpoPromise(executor) {
22197 if (typeof executor !== 'function') {
22198 throw TypeError('Not a function');
22199 }
22200
22201 if (this['__NPO__'] !== 0) {
22202 throw TypeError('Not a promise');
22203 }
22204
22205 // instance shadowing the inherited "brand"
22206 // to signal an already "initialized" promise
22207 this['__NPO__'] = 1;
22208
22209 var def = new MakeDef(this);
22210
22211 this['then'] = function then(success,failure) {
22212 var o = {
22213 success: typeof success === 'function' ? success : true,
22214 failure: typeof failure === 'function' ? failure : false
22215 };
22216 // Note: `then(..)` itself can be borrowed to be used against
22217 // a different promise constructor for making the chained promise,
22218 // by substituting a different `this` binding.
22219 o.promise = new this.constructor(function extractChain(resolve,reject) {
22220 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22221 throw TypeError('Not a function');
22222 }
22223
22224 o.resolve = resolve;
22225 o.reject = reject;
22226 });
22227 def.chain.push(o);
22228
22229 if (def.state !== 0) {
22230 schedule(notify,def);
22231 }
22232
22233 return o.promise;
22234 };
22235 this['catch'] = function $catch$(failure) {
22236 return this.then(void 0,failure);
22237 };
22238
22239 try {
22240 executor.call(
22241 void 0,
22242 function publicResolve(msg){
22243 resolve.call(def,msg);
22244 },
22245 function publicReject(msg) {
22246 reject.call(def,msg);
22247 }
22248 );
22249 }
22250 catch (err) {
22251 reject.call(def,err);
22252 }
22253 }
22254
22255 var PromisePrototype = builtInProp({},'constructor',NpoPromise,
22256 /*configurable=*/false
22257 );
22258
22259 // Note: Android 4 cannot use `Object.defineProperty(..)` here
22260 NpoPromise.prototype = PromisePrototype;
22261
22262 // built-in "brand" to signal an "uninitialized" promise
22263 builtInProp(PromisePrototype,'__NPO__',0,
22264 /*configurable=*/false
22265 );
22266
22267 builtInProp(NpoPromise,'resolve',function Promise$resolve(msg) {
22268 var Constructor = this;
22269
22270 // spec mandated checks
22271 // note: best "isPromise" check that's practical for now
22272 if (msg && typeof msg === 'object' && msg['__NPO__'] === 1) {
22273 return msg;
22274 }
22275
22276 return new Constructor(function executor(resolve,reject){
22277 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22278 throw TypeError('Not a function');
22279 }
22280
22281 resolve(msg);
22282 });
22283 });
22284
22285 builtInProp(NpoPromise,'reject',function Promise$reject(msg) {
22286 return new this(function executor(resolve,reject){
22287 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22288 throw TypeError('Not a function');
22289 }
22290
22291 reject(msg);
22292 });
22293 });
22294
22295 builtInProp(NpoPromise,'all',function Promise$all(arr) {
22296 var Constructor = this;
22297
22298 // spec mandated checks
22299 if (ToString.call(arr) !== '[object Array]') {
22300 return Constructor.reject(TypeError('Not an array'));
22301 }
22302 if (arr.length === 0) {
22303 return Constructor.resolve([]);
22304 }
22305
22306 return new Constructor(function executor(resolve,reject){
22307 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22308 throw TypeError('Not a function');
22309 }
22310
22311 var len = arr.length, msgs = Array(len), count = 0;
22312
22313 iteratePromises(Constructor,arr,function resolver(idx,msg) {
22314 msgs[idx] = msg;
22315 if (++count === len) {
22316 resolve(msgs);
22317 }
22318 },reject);
22319 });
22320 });
22321
22322 builtInProp(NpoPromise,'race',function Promise$race(arr) {
22323 var Constructor = this;
22324
22325 // spec mandated checks
22326 if (ToString.call(arr) !== '[object Array]') {
22327 return Constructor.reject(TypeError('Not an array'));
22328 }
22329
22330 return new Constructor(function executor(resolve,reject){
22331 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22332 throw TypeError('Not a function');
22333 }
22334
22335 iteratePromises(Constructor,arr,function resolver(idx,msg){
22336 resolve(msg);
22337 },reject);
22338 });
22339 });
22340
22341 var PromisePolyfill;
22342 if (typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]') !== -1) {
22343 PromisePolyfill = Promise;
22344 } else {
22345 PromisePolyfill = NpoPromise;
22346 }
22347
22348 var Config = {
22349 DEBUG: false,
22350 LIB_VERSION: '2.71.1'
22351 };
22352
22353 /* eslint camelcase: "off", eqeqeq: "off" */
22354
22355 // Maximum allowed session recording length
22356 var MAX_RECORDING_MS = 24 * 60 * 60 * 1000; // 24 hours
22357 // Maximum allowed value for minimum session recording length
22358 var MAX_VALUE_FOR_MIN_RECORDING_MS = 8 * 1000; // 8 seconds
22359
22360 /*
22361 * Saved references to long variable names, so that closure compiler can
22362 * minimize file size.
22363 */
22364
22365 var ArrayProto = Array.prototype,
22366 FuncProto = Function.prototype,
22367 ObjProto = Object.prototype,
22368 slice = ArrayProto.slice,
22369 toString = ObjProto.toString,
22370 hasOwnProperty = ObjProto.hasOwnProperty,
22371 windowConsole = win.console,
22372 navigator = win.navigator,
22373 document$1 = win.document,
22374 windowOpera = win.opera,
22375 screen = win.screen,
22376 userAgent = navigator.userAgent;
22377
22378 var nativeBind = FuncProto.bind,
22379 nativeForEach = ArrayProto.forEach,
22380 nativeIndexOf = ArrayProto.indexOf,
22381 nativeMap = ArrayProto.map,
22382 nativeIsArray = Array.isArray,
22383 breaker = {};
22384
22385 var _ = {
22386 trim: function(str) {
22387 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
22388 return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
22389 }
22390 };
22391
22392 // Console override
22393 var console$1 = {
22394 /** @type {function(...*)} */
22395 log: function() {
22396 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22397 try {
22398 windowConsole.log.apply(windowConsole, arguments);
22399 } catch (err) {
22400 _.each(arguments, function(arg) {
22401 windowConsole.log(arg);
22402 });
22403 }
22404 }
22405 },
22406 /** @type {function(...*)} */
22407 warn: function() {
22408 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22409 var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
22410 try {
22411 windowConsole.warn.apply(windowConsole, args);
22412 } catch (err) {
22413 _.each(args, function(arg) {
22414 windowConsole.warn(arg);
22415 });
22416 }
22417 }
22418 },
22419 /** @type {function(...*)} */
22420 error: function() {
22421 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22422 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22423 try {
22424 windowConsole.error.apply(windowConsole, args);
22425 } catch (err) {
22426 _.each(args, function(arg) {
22427 windowConsole.error(arg);
22428 });
22429 }
22430 }
22431 },
22432 /** @type {function(...*)} */
22433 critical: function() {
22434 if (!_.isUndefined(windowConsole) && windowConsole) {
22435 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22436 try {
22437 windowConsole.error.apply(windowConsole, args);
22438 } catch (err) {
22439 _.each(args, function(arg) {
22440 windowConsole.error(arg);
22441 });
22442 }
22443 }
22444 }
22445 };
22446
22447 var log_func_with_prefix = function(func, prefix) {
22448 return function() {
22449 arguments[0] = '[' + prefix + '] ' + arguments[0];
22450 return func.apply(console$1, arguments);
22451 };
22452 };
22453 var console_with_prefix = function(prefix) {
22454 return {
22455 log: log_func_with_prefix(console$1.log, prefix),
22456 error: log_func_with_prefix(console$1.error, prefix),
22457 critical: log_func_with_prefix(console$1.critical, prefix)
22458 };
22459 };
22460
22461
22462 var safewrap = function(f) {
22463 return function() {
22464 try {
22465 return f.apply(this, arguments);
22466 } catch (e) {
22467 console$1.critical('Implementation error. Please turn on debug and contact [email protected].');
22468 if (Config.DEBUG){
22469 console$1.critical(e);
22470 }
22471 }
22472 };
22473 };
22474
22475 var safewrapClass = function(klass) {
22476 var proto = klass.prototype;
22477 for (var func in proto) {
22478 if (typeof(proto[func]) === 'function') {
22479 proto[func] = safewrap(proto[func]);
22480 }
22481 }
22482 };
22483
22484
22485 // UNDERSCORE
22486 // Embed part of the Underscore Library
22487 _.bind = function(func, context) {
22488 var args, bound;
22489 if (nativeBind && func.bind === nativeBind) {
22490 return nativeBind.apply(func, slice.call(arguments, 1));
22491 }
22492 if (!_.isFunction(func)) {
22493 throw new TypeError();
22494 }
22495 args = slice.call(arguments, 2);
22496 bound = function() {
22497 if (!(this instanceof bound)) {
22498 return func.apply(context, args.concat(slice.call(arguments)));
22499 }
22500 var ctor = {};
22501 ctor.prototype = func.prototype;
22502 var self = new ctor();
22503 ctor.prototype = null;
22504 var result = func.apply(self, args.concat(slice.call(arguments)));
22505 if (Object(result) === result) {
22506 return result;
22507 }
22508 return self;
22509 };
22510 return bound;
22511 };
22512
22513 /**
22514 * @param {*=} obj
22515 * @param {function(...*)=} iterator
22516 * @param {Object=} context
22517 */
22518 _.each = function(obj, iterator, context) {
22519 if (obj === null || obj === undefined) {
22520 return;
22521 }
22522 if (nativeForEach && obj.forEach === nativeForEach) {
22523 obj.forEach(iterator, context);
22524 } else if (obj.length === +obj.length) {
22525 for (var i = 0, l = obj.length; i < l; i++) {
22526 if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
22527 return;
22528 }
22529 }
22530 } else {
22531 for (var key in obj) {
22532 if (hasOwnProperty.call(obj, key)) {
22533 if (iterator.call(context, obj[key], key, obj) === breaker) {
22534 return;
22535 }
22536 }
22537 }
22538 }
22539 };
22540
22541 _.extend = function(obj) {
22542 _.each(slice.call(arguments, 1), function(source) {
22543 for (var prop in source) {
22544 if (source[prop] !== void 0) {
22545 obj[prop] = source[prop];
22546 }
22547 }
22548 });
22549 return obj;
22550 };
22551
22552 _.isArray = nativeIsArray || function(obj) {
22553 return toString.call(obj) === '[object Array]';
22554 };
22555
22556 // from a comment on http://dbj.org/dbj/?p=286
22557 // fails on only one very rare and deliberate custom object:
22558 // var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
22559 _.isFunction = function(f) {
22560 try {
22561 return /^\s*\bfunction\b/.test(f);
22562 } catch (x) {
22563 return false;
22564 }
22565 };
22566
22567 _.isArguments = function(obj) {
22568 return !!(obj && hasOwnProperty.call(obj, 'callee'));
22569 };
22570
22571 _.toArray = function(iterable) {
22572 if (!iterable) {
22573 return [];
22574 }
22575 if (iterable.toArray) {
22576 return iterable.toArray();
22577 }
22578 if (_.isArray(iterable)) {
22579 return slice.call(iterable);
22580 }
22581 if (_.isArguments(iterable)) {
22582 return slice.call(iterable);
22583 }
22584 return _.values(iterable);
22585 };
22586
22587 _.map = function(arr, callback, context) {
22588 if (nativeMap && arr.map === nativeMap) {
22589 return arr.map(callback, context);
22590 } else {
22591 var results = [];
22592 _.each(arr, function(item) {
22593 results.push(callback.call(context, item));
22594 });
22595 return results;
22596 }
22597 };
22598
22599 _.keys = function(obj) {
22600 var results = [];
22601 if (obj === null) {
22602 return results;
22603 }
22604 _.each(obj, function(value, key) {
22605 results[results.length] = key;
22606 });
22607 return results;
22608 };
22609
22610 _.values = function(obj) {
22611 var results = [];
22612 if (obj === null) {
22613 return results;
22614 }
22615 _.each(obj, function(value) {
22616 results[results.length] = value;
22617 });
22618 return results;
22619 };
22620
22621 _.include = function(obj, target) {
22622 var found = false;
22623 if (obj === null) {
22624 return found;
22625 }
22626 if (nativeIndexOf && obj.indexOf === nativeIndexOf) {
22627 return obj.indexOf(target) != -1;
22628 }
22629 _.each(obj, function(value) {
22630 if (found || (found = (value === target))) {
22631 return breaker;
22632 }
22633 });
22634 return found;
22635 };
22636
22637 _.includes = function(str, needle) {
22638 return str.indexOf(needle) !== -1;
22639 };
22640
22641 // Underscore Addons
22642 _.inherit = function(subclass, superclass) {
22643 subclass.prototype = new superclass();
22644 subclass.prototype.constructor = subclass;
22645 subclass.superclass = superclass.prototype;
22646 return subclass;
22647 };
22648
22649 _.isObject = function(obj) {
22650 return (obj === Object(obj) && !_.isArray(obj));
22651 };
22652
22653 _.isEmptyObject = function(obj) {
22654 if (_.isObject(obj)) {
22655 for (var key in obj) {
22656 if (hasOwnProperty.call(obj, key)) {
22657 return false;
22658 }
22659 }
22660 return true;
22661 }
22662 return false;
22663 };
22664
22665 _.isUndefined = function(obj) {
22666 return obj === void 0;
22667 };
22668
22669 _.isString = function(obj) {
22670 return toString.call(obj) == '[object String]';
22671 };
22672
22673 _.isDate = function(obj) {
22674 return toString.call(obj) == '[object Date]';
22675 };
22676
22677 _.isNumber = function(obj) {
22678 return toString.call(obj) == '[object Number]';
22679 };
22680
22681 _.isElement = function(obj) {
22682 return !!(obj && obj.nodeType === 1);
22683 };
22684
22685 _.encodeDates = function(obj) {
22686 _.each(obj, function(v, k) {
22687 if (_.isDate(v)) {
22688 obj[k] = _.formatDate(v);
22689 } else if (_.isObject(v)) {
22690 obj[k] = _.encodeDates(v); // recurse
22691 }
22692 });
22693 return obj;
22694 };
22695
22696 _.timestamp = function() {
22697 Date.now = Date.now || function() {
22698 return +new Date;
22699 };
22700 return Date.now();
22701 };
22702
22703 _.formatDate = function(d) {
22704 // YYYY-MM-DDTHH:MM:SS in UTC
22705 function pad(n) {
22706 return n < 10 ? '0' + n : n;
22707 }
22708 return d.getUTCFullYear() + '-' +
22709 pad(d.getUTCMonth() + 1) + '-' +
22710 pad(d.getUTCDate()) + 'T' +
22711 pad(d.getUTCHours()) + ':' +
22712 pad(d.getUTCMinutes()) + ':' +
22713 pad(d.getUTCSeconds());
22714 };
22715
22716 _.strip_empty_properties = function(p) {
22717 var ret = {};
22718 _.each(p, function(v, k) {
22719 if (_.isString(v) && v.length > 0) {
22720 ret[k] = v;
22721 }
22722 });
22723 return ret;
22724 };
22725
22726 /*
22727 * this function returns a copy of object after truncating it. If
22728 * passed an Array or Object it will iterate through obj and
22729 * truncate all the values recursively.
22730 */
22731 _.truncate = function(obj, length) {
22732 var ret;
22733
22734 if (typeof(obj) === 'string') {
22735 ret = obj.slice(0, length);
22736 } else if (_.isArray(obj)) {
22737 ret = [];
22738 _.each(obj, function(val) {
22739 ret.push(_.truncate(val, length));
22740 });
22741 } else if (_.isObject(obj)) {
22742 ret = {};
22743 _.each(obj, function(val, key) {
22744 ret[key] = _.truncate(val, length);
22745 });
22746 } else {
22747 ret = obj;
22748 }
22749
22750 return ret;
22751 };
22752
22753 _.JSONEncode = (function() {
22754 return function(mixed_val) {
22755 var value = mixed_val;
22756 var quote = function(string) {
22757 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
22758 var meta = { // table of character substitutions
22759 '\b': '\\b',
22760 '\t': '\\t',
22761 '\n': '\\n',
22762 '\f': '\\f',
22763 '\r': '\\r',
22764 '"': '\\"',
22765 '\\': '\\\\'
22766 };
22767
22768 escapable.lastIndex = 0;
22769 return escapable.test(string) ?
22770 '"' + string.replace(escapable, function(a) {
22771 var c = meta[a];
22772 return typeof c === 'string' ? c :
22773 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
22774 }) + '"' :
22775 '"' + string + '"';
22776 };
22777
22778 var str = function(key, holder) {
22779 var gap = '';
22780 var indent = ' ';
22781 var i = 0; // The loop counter.
22782 var k = ''; // The member key.
22783 var v = ''; // The member value.
22784 var length = 0;
22785 var mind = gap;
22786 var partial = [];
22787 var value = holder[key];
22788
22789 // If the value has a toJSON method, call it to obtain a replacement value.
22790 if (value && typeof value === 'object' &&
22791 typeof value.toJSON === 'function') {
22792 value = value.toJSON(key);
22793 }
22794
22795 // What happens next depends on the value's type.
22796 switch (typeof value) {
22797 case 'string':
22798 return quote(value);
22799
22800 case 'number':
22801 // JSON numbers must be finite. Encode non-finite numbers as null.
22802 return isFinite(value) ? String(value) : 'null';
22803
22804 case 'boolean':
22805 case 'null':
22806 // If the value is a boolean or null, convert it to a string. Note:
22807 // typeof null does not produce 'null'. The case is included here in
22808 // the remote chance that this gets fixed someday.
22809
22810 return String(value);
22811
22812 case 'object':
22813 // If the type is 'object', we might be dealing with an object or an array or
22814 // null.
22815 // Due to a specification blunder in ECMAScript, typeof null is 'object',
22816 // so watch out for that case.
22817 if (!value) {
22818 return 'null';
22819 }
22820
22821 // Make an array to hold the partial results of stringifying this object value.
22822 gap += indent;
22823 partial = [];
22824
22825 // Is the value an array?
22826 if (toString.apply(value) === '[object Array]') {
22827 // The value is an array. Stringify every element. Use null as a placeholder
22828 // for non-JSON values.
22829
22830 length = value.length;
22831 for (i = 0; i < length; i += 1) {
22832 partial[i] = str(i, value) || 'null';
22833 }
22834
22835 // Join all of the elements together, separated with commas, and wrap them in
22836 // brackets.
22837 v = partial.length === 0 ? '[]' :
22838 gap ? '[\n' + gap +
22839 partial.join(',\n' + gap) + '\n' +
22840 mind + ']' :
22841 '[' + partial.join(',') + ']';
22842 gap = mind;
22843 return v;
22844 }
22845
22846 // Iterate through all of the keys in the object.
22847 for (k in value) {
22848 if (hasOwnProperty.call(value, k)) {
22849 v = str(k, value);
22850 if (v) {
22851 partial.push(quote(k) + (gap ? ': ' : ':') + v);
22852 }
22853 }
22854 }
22855
22856 // Join all of the member texts together, separated with commas,
22857 // and wrap them in braces.
22858 v = partial.length === 0 ? '{}' :
22859 gap ? '{' + partial.join(',') + '' +
22860 mind + '}' : '{' + partial.join(',') + '}';
22861 gap = mind;
22862 return v;
22863 }
22864 };
22865
22866 // Make a fake root object containing our value under the key of ''.
22867 // Return the result of stringifying the value.
22868 return str('', {
22869 '': value
22870 });
22871 };
22872 })();
22873
22874 /**
22875 * From https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
22876 * Slightly modified to throw a real Error rather than a POJO
22877 */
22878 _.JSONDecode = (function() {
22879 var at, // The index of the current character
22880 ch, // The current character
22881 escapee = {
22882 '"': '"',
22883 '\\': '\\',
22884 '/': '/',
22885 'b': '\b',
22886 'f': '\f',
22887 'n': '\n',
22888 'r': '\r',
22889 't': '\t'
22890 },
22891 text,
22892 error = function(m) {
22893 var e = new SyntaxError(m);
22894 e.at = at;
22895 e.text = text;
22896 throw e;
22897 },
22898 next = function(c) {
22899 // If a c parameter is provided, verify that it matches the current character.
22900 if (c && c !== ch) {
22901 error('Expected \'' + c + '\' instead of \'' + ch + '\'');
22902 }
22903 // Get the next character. When there are no more characters,
22904 // return the empty string.
22905 ch = text.charAt(at);
22906 at += 1;
22907 return ch;
22908 },
22909 number = function() {
22910 // Parse a number value.
22911 var number,
22912 string = '';
22913
22914 if (ch === '-') {
22915 string = '-';
22916 next('-');
22917 }
22918 while (ch >= '0' && ch <= '9') {
22919 string += ch;
22920 next();
22921 }
22922 if (ch === '.') {
22923 string += '.';
22924 while (next() && ch >= '0' && ch <= '9') {
22925 string += ch;
22926 }
22927 }
22928 if (ch === 'e' || ch === 'E') {
22929 string += ch;
22930 next();
22931 if (ch === '-' || ch === '+') {
22932 string += ch;
22933 next();
22934 }
22935 while (ch >= '0' && ch <= '9') {
22936 string += ch;
22937 next();
22938 }
22939 }
22940 number = +string;
22941 if (!isFinite(number)) {
22942 error('Bad number');
22943 } else {
22944 return number;
22945 }
22946 },
22947
22948 string = function() {
22949 // Parse a string value.
22950 var hex,
22951 i,
22952 string = '',
22953 uffff;
22954 // When parsing for string values, we must look for " and \ characters.
22955 if (ch === '"') {
22956 while (next()) {
22957 if (ch === '"') {
22958 next();
22959 return string;
22960 }
22961 if (ch === '\\') {
22962 next();
22963 if (ch === 'u') {
22964 uffff = 0;
22965 for (i = 0; i < 4; i += 1) {
22966 hex = parseInt(next(), 16);
22967 if (!isFinite(hex)) {
22968 break;
22969 }
22970 uffff = uffff * 16 + hex;
22971 }
22972 string += String.fromCharCode(uffff);
22973 } else if (typeof escapee[ch] === 'string') {
22974 string += escapee[ch];
22975 } else {
22976 break;
22977 }
22978 } else {
22979 string += ch;
22980 }
22981 }
22982 }
22983 error('Bad string');
22984 },
22985 white = function() {
22986 // Skip whitespace.
22987 while (ch && ch <= ' ') {
22988 next();
22989 }
22990 },
22991 word = function() {
22992 // true, false, or null.
22993 switch (ch) {
22994 case 't':
22995 next('t');
22996 next('r');
22997 next('u');
22998 next('e');
22999 return true;
23000 case 'f':
23001 next('f');
23002 next('a');
23003 next('l');
23004 next('s');
23005 next('e');
23006 return false;
23007 case 'n':
23008 next('n');
23009 next('u');
23010 next('l');
23011 next('l');
23012 return null;
23013 }
23014 error('Unexpected "' + ch + '"');
23015 },
23016 value, // Placeholder for the value function.
23017 array = function() {
23018 // Parse an array value.
23019 var array = [];
23020
23021 if (ch === '[') {
23022 next('[');
23023 white();
23024 if (ch === ']') {
23025 next(']');
23026 return array; // empty array
23027 }
23028 while (ch) {
23029 array.push(value());
23030 white();
23031 if (ch === ']') {
23032 next(']');
23033 return array;
23034 }
23035 next(',');
23036 white();
23037 }
23038 }
23039 error('Bad array');
23040 },
23041 object = function() {
23042 // Parse an object value.
23043 var key,
23044 object = {};
23045
23046 if (ch === '{') {
23047 next('{');
23048 white();
23049 if (ch === '}') {
23050 next('}');
23051 return object; // empty object
23052 }
23053 while (ch) {
23054 key = string();
23055 white();
23056 next(':');
23057 if (Object.hasOwnProperty.call(object, key)) {
23058 error('Duplicate key "' + key + '"');
23059 }
23060 object[key] = value();
23061 white();
23062 if (ch === '}') {
23063 next('}');
23064 return object;
23065 }
23066 next(',');
23067 white();
23068 }
23069 }
23070 error('Bad object');
23071 };
23072
23073 value = function() {
23074 // Parse a JSON value. It could be an object, an array, a string,
23075 // a number, or a word.
23076 white();
23077 switch (ch) {
23078 case '{':
23079 return object();
23080 case '[':
23081 return array();
23082 case '"':
23083 return string();
23084 case '-':
23085 return number();
23086 default:
23087 return ch >= '0' && ch <= '9' ? number() : word();
23088 }
23089 };
23090
23091 // Return the json_parse function. It will have access to all of the
23092 // above functions and variables.
23093 return function(source) {
23094 var result;
23095
23096 text = source;
23097 at = 0;
23098 ch = ' ';
23099 result = value();
23100 white();
23101 if (ch) {
23102 error('Syntax error');
23103 }
23104
23105 return result;
23106 };
23107 })();
23108
23109 _.base64Encode = function(data) {
23110 var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
23111 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
23112 ac = 0,
23113 enc = '',
23114 tmp_arr = [];
23115
23116 if (!data) {
23117 return data;
23118 }
23119
23120 data = _.utf8Encode(data);
23121
23122 do { // pack three octets into four hexets
23123 o1 = data.charCodeAt(i++);
23124 o2 = data.charCodeAt(i++);
23125 o3 = data.charCodeAt(i++);
23126
23127 bits = o1 << 16 | o2 << 8 | o3;
23128
23129 h1 = bits >> 18 & 0x3f;
23130 h2 = bits >> 12 & 0x3f;
23131 h3 = bits >> 6 & 0x3f;
23132 h4 = bits & 0x3f;
23133
23134 // use hexets to index into b64, and append result to encoded string
23135 tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
23136 } while (i < data.length);
23137
23138 enc = tmp_arr.join('');
23139
23140 switch (data.length % 3) {
23141 case 1:
23142 enc = enc.slice(0, -2) + '==';
23143 break;
23144 case 2:
23145 enc = enc.slice(0, -1) + '=';
23146 break;
23147 }
23148
23149 return enc;
23150 };
23151
23152 _.utf8Encode = function(string) {
23153 string = (string + '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
23154
23155 var utftext = '',
23156 start,
23157 end;
23158 var stringl = 0,
23159 n;
23160
23161 start = end = 0;
23162 stringl = string.length;
23163
23164 for (n = 0; n < stringl; n++) {
23165 var c1 = string.charCodeAt(n);
23166 var enc = null;
23167
23168 if (c1 < 128) {
23169 end++;
23170 } else if ((c1 > 127) && (c1 < 2048)) {
23171 enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128);
23172 } else {
23173 enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128);
23174 }
23175 if (enc !== null) {
23176 if (end > start) {
23177 utftext += string.substring(start, end);
23178 }
23179 utftext += enc;
23180 start = end = n + 1;
23181 }
23182 }
23183
23184 if (end > start) {
23185 utftext += string.substring(start, string.length);
23186 }
23187
23188 return utftext;
23189 };
23190
23191 _.UUID = function() {
23192 try {
23193 // use native Crypto API when available
23194 return win['crypto']['randomUUID']();
23195 } catch (err) {
23196 // fall back to generating our own UUID
23197 // based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
23198 var uuid = new Array(36);
23199 for (var i = 0; i < 36; i++) {
23200 uuid[i] = Math.floor(Math.random() * 16);
23201 }
23202 uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
23203 uuid[19] = uuid[19] &= -5; // set bit 6 of clock-seq-and-reserved to zero
23204 uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
23205 uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
23206
23207 return _.map(uuid, function(x) {
23208 return x.toString(16);
23209 }).join('');
23210 }
23211 };
23212
23213 // _.isBlockedUA()
23214 // This is to block various web spiders from executing our JS and
23215 // sending false tracking data
23216 var BLOCKED_UA_STRS = [
23217 'ahrefsbot',
23218 'ahrefssiteaudit',
23219 'amazonbot',
23220 'baiduspider',
23221 'bingbot',
23222 'bingpreview',
23223 'chrome-lighthouse',
23224 'facebookexternal',
23225 'petalbot',
23226 'pinterest',
23227 'screaming frog',
23228 'yahoo! slurp',
23229 'yandex',
23230
23231 // a whole bunch of goog-specific crawlers
23232 // https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
23233 'adsbot-google',
23234 'apis-google',
23235 'duplexweb-google',
23236 'feedfetcher-google',
23237 'google favicon',
23238 'google web preview',
23239 'google-read-aloud',
23240 'googlebot',
23241 'googleweblight',
23242 'mediapartners-google',
23243 'storebot-google'
23244 ];
23245 _.isBlockedUA = function(ua) {
23246 var i;
23247 ua = ua.toLowerCase();
23248 for (i = 0; i < BLOCKED_UA_STRS.length; i++) {
23249 if (ua.indexOf(BLOCKED_UA_STRS[i]) !== -1) {
23250 return true;
23251 }
23252 }
23253 return false;
23254 };
23255
23256 /**
23257 * @param {Object=} formdata
23258 * @param {string=} arg_separator
23259 */
23260 _.HTTPBuildQuery = function(formdata, arg_separator) {
23261 var use_val, use_key, tmp_arr = [];
23262
23263 if (_.isUndefined(arg_separator)) {
23264 arg_separator = '&';
23265 }
23266
23267 _.each(formdata, function(val, key) {
23268 use_val = encodeURIComponent(val.toString());
23269 use_key = encodeURIComponent(key);
23270 tmp_arr[tmp_arr.length] = use_key + '=' + use_val;
23271 });
23272
23273 return tmp_arr.join(arg_separator);
23274 };
23275
23276 _.getQueryParam = function(url, param) {
23277 // Expects a raw URL
23278
23279 param = param.replace(/[[]/g, '\\[').replace(/[\]]/g, '\\]');
23280 var regexS = '[\\?&]' + param + '=([^&#]*)',
23281 regex = new RegExp(regexS),
23282 results = regex.exec(url);
23283 if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
23284 return '';
23285 } else {
23286 var result = results[1];
23287 try {
23288 result = decodeURIComponent(result);
23289 } catch(err) {
23290 console$1.error('Skipping decoding for malformed query param: ' + result);
23291 }
23292 return result.replace(/\+/g, ' ');
23293 }
23294 };
23295
23296
23297 // _.cookie
23298 // Methods partially borrowed from quirksmode.org/js/cookies.html
23299 _.cookie = {
23300 get: function(name) {
23301 var nameEQ = name + '=';
23302 var ca = document$1.cookie.split(';');
23303 for (var i = 0; i < ca.length; i++) {
23304 var c = ca[i];
23305 while (c.charAt(0) == ' ') {
23306 c = c.substring(1, c.length);
23307 }
23308 if (c.indexOf(nameEQ) === 0) {
23309 return decodeURIComponent(c.substring(nameEQ.length, c.length));
23310 }
23311 }
23312 return null;
23313 },
23314
23315 parse: function(name) {
23316 var cookie;
23317 try {
23318 cookie = _.JSONDecode(_.cookie.get(name)) || {};
23319 } catch (err) {
23320 // noop
23321 }
23322 return cookie;
23323 },
23324
23325 set_seconds: function(name, value, seconds, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23326 var cdomain = '',
23327 expires = '',
23328 secure = '';
23329
23330 if (domain_override) {
23331 cdomain = '; domain=' + domain_override;
23332 } else if (is_cross_subdomain) {
23333 var domain = extract_domain(document$1.location.hostname);
23334 cdomain = domain ? '; domain=.' + domain : '';
23335 }
23336
23337 if (seconds) {
23338 var date = new Date();
23339 date.setTime(date.getTime() + (seconds * 1000));
23340 expires = '; expires=' + date.toGMTString();
23341 }
23342
23343 if (is_cross_site) {
23344 is_secure = true;
23345 secure = '; SameSite=None';
23346 }
23347 if (is_secure) {
23348 secure += '; secure';
23349 }
23350
23351 document$1.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23352 },
23353
23354 set: function(name, value, days, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23355 var cdomain = '', expires = '', secure = '';
23356
23357 if (domain_override) {
23358 cdomain = '; domain=' + domain_override;
23359 } else if (is_cross_subdomain) {
23360 var domain = extract_domain(document$1.location.hostname);
23361 cdomain = domain ? '; domain=.' + domain : '';
23362 }
23363
23364 if (days) {
23365 var date = new Date();
23366 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
23367 expires = '; expires=' + date.toGMTString();
23368 }
23369
23370 if (is_cross_site) {
23371 is_secure = true;
23372 secure = '; SameSite=None';
23373 }
23374 if (is_secure) {
23375 secure += '; secure';
23376 }
23377
23378 var new_cookie_val = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23379 document$1.cookie = new_cookie_val;
23380 return new_cookie_val;
23381 },
23382
23383 remove: function(name, is_cross_subdomain, domain_override) {
23384 _.cookie.set(name, '', -1, is_cross_subdomain, false, false, domain_override);
23385 }
23386 };
23387
23388 var _testStorageSupported = function (storage) {
23389 var supported = true;
23390 try {
23391 var key = '__mplss_' + cheap_guid(8),
23392 val = 'xyz';
23393 storage.setItem(key, val);
23394 if (storage.getItem(key) !== val) {
23395 supported = false;
23396 }
23397 storage.removeItem(key);
23398 } catch (err) {
23399 supported = false;
23400 }
23401 return supported;
23402 };
23403
23404 var _localStorageSupported = null;
23405 var localStorageSupported = function(storage, forceCheck) {
23406 if (_localStorageSupported !== null && !forceCheck) {
23407 return _localStorageSupported;
23408 }
23409 return _localStorageSupported = _testStorageSupported(storage || win.localStorage);
23410 };
23411
23412 var _sessionStorageSupported = null;
23413 var sessionStorageSupported = function(storage, forceCheck) {
23414 if (_sessionStorageSupported !== null && !forceCheck) {
23415 return _sessionStorageSupported;
23416 }
23417 return _sessionStorageSupported = _testStorageSupported(storage || win.sessionStorage);
23418 };
23419
23420 function _storageWrapper(storage, name, is_supported_fn) {
23421 var log_error = function(msg) {
23422 console$1.error(name + ' error: ' + msg);
23423 };
23424
23425 return {
23426 is_supported: function(forceCheck) {
23427 var supported = is_supported_fn(storage, forceCheck);
23428 if (!supported) {
23429 console$1.error(name + ' unsupported');
23430 }
23431 return supported;
23432 },
23433 error: log_error,
23434 get: function(key) {
23435 try {
23436 return storage.getItem(key);
23437 } catch (err) {
23438 log_error(err);
23439 }
23440 return null;
23441 },
23442 parse: function(key) {
23443 try {
23444 return _.JSONDecode(storage.getItem(key)) || {};
23445 } catch (err) {
23446 // noop
23447 }
23448 return null;
23449 },
23450 set: function(key, value) {
23451 try {
23452 storage.setItem(key, value);
23453 } catch (err) {
23454 log_error(err);
23455 }
23456 },
23457 remove: function(key) {
23458 try {
23459 storage.removeItem(key);
23460 } catch (err) {
23461 log_error(err);
23462 }
23463 }
23464 };
23465 }
23466
23467 _.localStorage = _storageWrapper(win.localStorage, 'localStorage', localStorageSupported);
23468 _.sessionStorage = _storageWrapper(win.sessionStorage, 'sessionStorage', sessionStorageSupported);
23469
23470 _.register_event = (function() {
23471 // written by Dean Edwards, 2005
23472 // with input from Tino Zijdel - [email protected]
23473 // with input from Carl Sverre - [email protected]
23474 // with input from Mixpanel
23475 // http://dean.edwards.name/weblog/2005/10/add-event/
23476 // https://gist.github.com/1930440
23477
23478 /**
23479 * @param {Object} element
23480 * @param {string} type
23481 * @param {function(...*)} handler
23482 * @param {boolean=} oldSchool
23483 * @param {boolean=} useCapture
23484 */
23485 var register_event = function(element, type, handler, oldSchool, useCapture) {
23486 if (!element) {
23487 console$1.error('No valid element provided to register_event');
23488 return;
23489 }
23490
23491 if (element.addEventListener && !oldSchool) {
23492 element.addEventListener(type, handler, !!useCapture);
23493 } else {
23494 var ontype = 'on' + type;
23495 var old_handler = element[ontype]; // can be undefined
23496 element[ontype] = makeHandler(element, handler, old_handler);
23497 }
23498 };
23499
23500 function makeHandler(element, new_handler, old_handlers) {
23501 var handler = function(event) {
23502 event = event || fixEvent(win.event);
23503
23504 // this basically happens in firefox whenever another script
23505 // overwrites the onload callback and doesn't pass the event
23506 // object to previously defined callbacks. All the browsers
23507 // that don't define window.event implement addEventListener
23508 // so the dom_loaded handler will still be fired as usual.
23509 if (!event) {
23510 return undefined;
23511 }
23512
23513 var ret = true;
23514 var old_result, new_result;
23515
23516 if (_.isFunction(old_handlers)) {
23517 old_result = old_handlers(event);
23518 }
23519 new_result = new_handler.call(element, event);
23520
23521 if ((false === old_result) || (false === new_result)) {
23522 ret = false;
23523 }
23524
23525 return ret;
23526 };
23527
23528 return handler;
23529 }
23530
23531 function fixEvent(event) {
23532 if (event) {
23533 event.preventDefault = fixEvent.preventDefault;
23534 event.stopPropagation = fixEvent.stopPropagation;
23535 }
23536 return event;
23537 }
23538 fixEvent.preventDefault = function() {
23539 this.returnValue = false;
23540 };
23541 fixEvent.stopPropagation = function() {
23542 this.cancelBubble = true;
23543 };
23544
23545 return register_event;
23546 })();
23547
23548
23549 var TOKEN_MATCH_REGEX = new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');
23550
23551 _.dom_query = (function() {
23552 /* document.getElementsBySelector(selector)
23553 - returns an array of element objects from the current document
23554 matching the CSS selector. Selectors can contain element names,
23555 class names and ids and can be nested. For example:
23556
23557 elements = document.getElementsBySelector('div#main p a.external')
23558
23559 Will return an array of all 'a' elements with 'external' in their
23560 class attribute that are contained inside 'p' elements that are
23561 contained inside the 'div' element which has id="main"
23562
23563 New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
23564 See http://www.w3.org/TR/css3-selectors/#attribute-selectors
23565
23566 Version 0.4 - Simon Willison, March 25th 2003
23567 -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
23568 -- Opera 7 fails
23569
23570 Version 0.5 - Carl Sverre, Jan 7th 2013
23571 -- Now uses jQuery-esque `hasClass` for testing class name
23572 equality. This fixes a bug related to '-' characters being
23573 considered not part of a 'word' in regex.
23574 */
23575
23576 function getAllChildren(e) {
23577 // Returns all children of element. Workaround required for IE5/Windows. Ugh.
23578 return e.all ? e.all : e.getElementsByTagName('*');
23579 }
23580
23581 var bad_whitespace = /[\t\r\n]/g;
23582
23583 function hasClass(elem, selector) {
23584 var className = ' ' + selector + ' ';
23585 return ((' ' + elem.className + ' ').replace(bad_whitespace, ' ').indexOf(className) >= 0);
23586 }
23587
23588 function getElementsBySelector(selector) {
23589 // Attempt to fail gracefully in lesser browsers
23590 if (!document$1.getElementsByTagName) {
23591 return [];
23592 }
23593 // Split selector in to tokens
23594 var tokens = selector.split(' ');
23595 var token, bits, tagName, found, foundCount, i, j, k, elements, currentContextIndex;
23596 var currentContext = [document$1];
23597 for (i = 0; i < tokens.length; i++) {
23598 token = tokens[i].replace(/^\s+/, '').replace(/\s+$/, '');
23599 if (token.indexOf('#') > -1) {
23600 // Token is an ID selector
23601 bits = token.split('#');
23602 tagName = bits[0];
23603 var id = bits[1];
23604 var element = document$1.getElementById(id);
23605 if (!element || (tagName && element.nodeName.toLowerCase() != tagName)) {
23606 // element not found or tag with that ID not found, return false
23607 return [];
23608 }
23609 // Set currentContext to contain just this element
23610 currentContext = [element];
23611 continue; // Skip to next token
23612 }
23613 if (token.indexOf('.') > -1) {
23614 // Token contains a class selector
23615 bits = token.split('.');
23616 tagName = bits[0];
23617 var className = bits[1];
23618 if (!tagName) {
23619 tagName = '*';
23620 }
23621 // Get elements matching tag, filter them for class selector
23622 found = [];
23623 foundCount = 0;
23624 for (j = 0; j < currentContext.length; j++) {
23625 if (tagName == '*') {
23626 elements = getAllChildren(currentContext[j]);
23627 } else {
23628 elements = currentContext[j].getElementsByTagName(tagName);
23629 }
23630 for (k = 0; k < elements.length; k++) {
23631 found[foundCount++] = elements[k];
23632 }
23633 }
23634 currentContext = [];
23635 currentContextIndex = 0;
23636 for (j = 0; j < found.length; j++) {
23637 if (found[j].className &&
23638 _.isString(found[j].className) && // some SVG elements have classNames which are not strings
23639 hasClass(found[j], className)
23640 ) {
23641 currentContext[currentContextIndex++] = found[j];
23642 }
23643 }
23644 continue; // Skip to next token
23645 }
23646 // Code to deal with attribute selectors
23647 var token_match = token.match(TOKEN_MATCH_REGEX);
23648 if (token_match) {
23649 tagName = token_match[1];
23650 var attrName = token_match[2];
23651 var attrOperator = token_match[3];
23652 var attrValue = token_match[4];
23653 if (!tagName) {
23654 tagName = '*';
23655 }
23656 // Grab all of the tagName elements within current context
23657 found = [];
23658 foundCount = 0;
23659 for (j = 0; j < currentContext.length; j++) {
23660 if (tagName == '*') {
23661 elements = getAllChildren(currentContext[j]);
23662 } else {
23663 elements = currentContext[j].getElementsByTagName(tagName);
23664 }
23665 for (k = 0; k < elements.length; k++) {
23666 found[foundCount++] = elements[k];
23667 }
23668 }
23669 currentContext = [];
23670 currentContextIndex = 0;
23671 var checkFunction; // This function will be used to filter the elements
23672 switch (attrOperator) {
23673 case '=': // Equality
23674 checkFunction = function(e) {
23675 return (e.getAttribute(attrName) == attrValue);
23676 };
23677 break;
23678 case '~': // Match one of space seperated words
23679 checkFunction = function(e) {
23680 return (e.getAttribute(attrName).match(new RegExp('\\b' + attrValue + '\\b')));
23681 };
23682 break;
23683 case '|': // Match start with value followed by optional hyphen
23684 checkFunction = function(e) {
23685 return (e.getAttribute(attrName).match(new RegExp('^' + attrValue + '-?')));
23686 };
23687 break;
23688 case '^': // Match starts with value
23689 checkFunction = function(e) {
23690 return (e.getAttribute(attrName).indexOf(attrValue) === 0);
23691 };
23692 break;
23693 case '$': // Match ends with value - fails with "Warning" in Opera 7
23694 checkFunction = function(e) {
23695 return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length);
23696 };
23697 break;
23698 case '*': // Match ends with value
23699 checkFunction = function(e) {
23700 return (e.getAttribute(attrName).indexOf(attrValue) > -1);
23701 };
23702 break;
23703 default:
23704 // Just test for existence of attribute
23705 checkFunction = function(e) {
23706 return e.getAttribute(attrName);
23707 };
23708 }
23709 currentContext = [];
23710 currentContextIndex = 0;
23711 for (j = 0; j < found.length; j++) {
23712 if (checkFunction(found[j])) {
23713 currentContext[currentContextIndex++] = found[j];
23714 }
23715 }
23716 // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
23717 continue; // Skip to next token
23718 }
23719 // If we get here, token is JUST an element (not a class or ID selector)
23720 tagName = token;
23721 found = [];
23722 foundCount = 0;
23723 for (j = 0; j < currentContext.length; j++) {
23724 elements = currentContext[j].getElementsByTagName(tagName);
23725 for (k = 0; k < elements.length; k++) {
23726 found[foundCount++] = elements[k];
23727 }
23728 }
23729 currentContext = found;
23730 }
23731 return currentContext;
23732 }
23733
23734 return function(query) {
23735 if (_.isElement(query)) {
23736 return [query];
23737 } else if (_.isObject(query) && !_.isUndefined(query.length)) {
23738 return query;
23739 } else {
23740 return getElementsBySelector.call(this, query);
23741 }
23742 };
23743 })();
23744
23745 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'];
23746 var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'sccid', 'ttclid', 'twclid', 'wbraid'];
23747
23748 _.info = {
23749 campaignParams: function(default_value) {
23750 var kw = '',
23751 params = {};
23752 _.each(CAMPAIGN_KEYWORDS, function(kwkey) {
23753 kw = _.getQueryParam(document$1.URL, kwkey);
23754 if (kw.length) {
23755 params[kwkey] = kw;
23756 } else if (default_value !== undefined) {
23757 params[kwkey] = default_value;
23758 }
23759 });
23760
23761 return params;
23762 },
23763
23764 clickParams: function() {
23765 var id = '',
23766 params = {};
23767 _.each(CLICK_IDS, function(idkey) {
23768 id = _.getQueryParam(document$1.URL, idkey);
23769 if (id.length) {
23770 params[idkey] = id;
23771 }
23772 });
23773
23774 return params;
23775 },
23776
23777 marketingParams: function() {
23778 return _.extend(_.info.campaignParams(), _.info.clickParams());
23779 },
23780
23781 searchEngine: function(referrer) {
23782 if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
23783 return 'google';
23784 } else if (referrer.search('https?://(.*)bing.com') === 0) {
23785 return 'bing';
23786 } else if (referrer.search('https?://(.*)yahoo.com') === 0) {
23787 return 'yahoo';
23788 } else if (referrer.search('https?://(.*)duckduckgo.com') === 0) {
23789 return 'duckduckgo';
23790 } else {
23791 return null;
23792 }
23793 },
23794
23795 searchInfo: function(referrer) {
23796 var search = _.info.searchEngine(referrer),
23797 param = (search != 'yahoo') ? 'q' : 'p',
23798 ret = {};
23799
23800 if (search !== null) {
23801 ret['$search_engine'] = search;
23802
23803 var keyword = _.getQueryParam(referrer, param);
23804 if (keyword.length) {
23805 ret['mp_keyword'] = keyword;
23806 }
23807 }
23808
23809 return ret;
23810 },
23811
23812 /**
23813 * This function detects which browser is running this script.
23814 * The order of the checks are important since many user agents
23815 * include key words used in later checks.
23816 */
23817 browser: function(user_agent, vendor, opera) {
23818 vendor = vendor || ''; // vendor is undefined for at least IE9
23819 if (opera || _.includes(user_agent, ' OPR/')) {
23820 if (_.includes(user_agent, 'Mini')) {
23821 return 'Opera Mini';
23822 }
23823 return 'Opera';
23824 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
23825 return 'BlackBerry';
23826 } else if (_.includes(user_agent, 'IEMobile') || _.includes(user_agent, 'WPDesktop')) {
23827 return 'Internet Explorer Mobile';
23828 } else if (_.includes(user_agent, 'SamsungBrowser/')) {
23829 // https://developer.samsung.com/internet/user-agent-string-format
23830 return 'Samsung Internet';
23831 } else if (_.includes(user_agent, 'Edge') || _.includes(user_agent, 'Edg/')) {
23832 return 'Microsoft Edge';
23833 } else if (_.includes(user_agent, 'FBIOS')) {
23834 return 'Facebook Mobile';
23835 } else if (_.includes(user_agent, 'Whale/')) {
23836 // https://user-agents.net/browsers/whale-browser
23837 return 'Whale Browser';
23838 } else if (_.includes(user_agent, 'Chrome')) {
23839 return 'Chrome';
23840 } else if (_.includes(user_agent, 'CriOS')) {
23841 return 'Chrome iOS';
23842 } else if (_.includes(user_agent, 'UCWEB') || _.includes(user_agent, 'UCBrowser')) {
23843 return 'UC Browser';
23844 } else if (_.includes(user_agent, 'FxiOS')) {
23845 return 'Firefox iOS';
23846 } else if (_.includes(vendor, 'Apple')) {
23847 if (_.includes(user_agent, 'Mobile')) {
23848 return 'Mobile Safari';
23849 }
23850 return 'Safari';
23851 } else if (_.includes(user_agent, 'Android')) {
23852 return 'Android Mobile';
23853 } else if (_.includes(user_agent, 'Konqueror')) {
23854 return 'Konqueror';
23855 } else if (_.includes(user_agent, 'Firefox')) {
23856 return 'Firefox';
23857 } else if (_.includes(user_agent, 'MSIE') || _.includes(user_agent, 'Trident/')) {
23858 return 'Internet Explorer';
23859 } else if (_.includes(user_agent, 'Gecko')) {
23860 return 'Mozilla';
23861 } else {
23862 return '';
23863 }
23864 },
23865
23866 /**
23867 * This function detects which browser version is running this script,
23868 * parsing major and minor version (e.g., 42.1). User agent strings from:
23869 * http://www.useragentstring.com/pages/useragentstring.php
23870 */
23871 browserVersion: function(userAgent, vendor, opera) {
23872 var browser = _.info.browser(userAgent, vendor, opera);
23873 var versionRegexs = {
23874 'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/,
23875 'Microsoft Edge': /Edge?\/(\d+(\.\d+)?)/,
23876 'Chrome': /Chrome\/(\d+(\.\d+)?)/,
23877 'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/,
23878 'UC Browser' : /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,
23879 'Safari': /Version\/(\d+(\.\d+)?)/,
23880 'Mobile Safari': /Version\/(\d+(\.\d+)?)/,
23881 'Opera': /(Opera|OPR)\/(\d+(\.\d+)?)/,
23882 'Firefox': /Firefox\/(\d+(\.\d+)?)/,
23883 'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/,
23884 'Konqueror': /Konqueror:(\d+(\.\d+)?)/,
23885 'BlackBerry': /BlackBerry (\d+(\.\d+)?)/,
23886 'Android Mobile': /android\s(\d+(\.\d+)?)/,
23887 'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
23888 'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
23889 'Mozilla': /rv:(\d+(\.\d+)?)/,
23890 'Whale Browser': /Whale\/(\d+(\.\d+)?)/
23891 };
23892 var regex = versionRegexs[browser];
23893 if (regex === undefined) {
23894 return null;
23895 }
23896 var matches = userAgent.match(regex);
23897 if (!matches) {
23898 return null;
23899 }
23900 return parseFloat(matches[matches.length - 2]);
23901 },
23902
23903 os: function() {
23904 var a = userAgent;
23905 if (/Windows/i.test(a)) {
23906 if (/Phone/.test(a) || /WPDesktop/.test(a)) {
23907 return 'Windows Phone';
23908 }
23909 return 'Windows';
23910 } else if (/(iPhone|iPad|iPod)/.test(a)) {
23911 return 'iOS';
23912 } else if (/Android/.test(a)) {
23913 return 'Android';
23914 } else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {
23915 return 'BlackBerry';
23916 } else if (/Mac/i.test(a)) {
23917 return 'Mac OS X';
23918 } else if (/Linux/.test(a)) {
23919 return 'Linux';
23920 } else if (/CrOS/.test(a)) {
23921 return 'Chrome OS';
23922 } else {
23923 return '';
23924 }
23925 },
23926
23927 device: function(user_agent) {
23928 if (/Windows Phone/i.test(user_agent) || /WPDesktop/.test(user_agent)) {
23929 return 'Windows Phone';
23930 } else if (/iPad/.test(user_agent)) {
23931 return 'iPad';
23932 } else if (/iPod/.test(user_agent)) {
23933 return 'iPod Touch';
23934 } else if (/iPhone/.test(user_agent)) {
23935 return 'iPhone';
23936 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
23937 return 'BlackBerry';
23938 } else if (/Android/.test(user_agent)) {
23939 return 'Android';
23940 } else {
23941 return '';
23942 }
23943 },
23944
23945 referringDomain: function(referrer) {
23946 var split = referrer.split('/');
23947 if (split.length >= 3) {
23948 return split[2];
23949 }
23950 return '';
23951 },
23952
23953 currentUrl: function() {
23954 return win.location.href;
23955 },
23956
23957 properties: function(extra_props) {
23958 if (typeof extra_props !== 'object') {
23959 extra_props = {};
23960 }
23961 return _.extend(_.strip_empty_properties({
23962 '$os': _.info.os(),
23963 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
23964 '$referrer': document$1.referrer,
23965 '$referring_domain': _.info.referringDomain(document$1.referrer),
23966 '$device': _.info.device(userAgent)
23967 }), {
23968 '$current_url': _.info.currentUrl(),
23969 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera),
23970 '$screen_height': screen.height,
23971 '$screen_width': screen.width,
23972 'mp_lib': 'web',
23973 '$lib_version': Config.LIB_VERSION,
23974 '$insert_id': cheap_guid(),
23975 'time': _.timestamp() / 1000 // epoch time in seconds
23976 }, _.strip_empty_properties(extra_props));
23977 },
23978
23979 people_properties: function() {
23980 return _.extend(_.strip_empty_properties({
23981 '$os': _.info.os(),
23982 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera)
23983 }), {
23984 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera)
23985 });
23986 },
23987
23988 mpPageViewProperties: function() {
23989 return _.strip_empty_properties({
23990 'current_page_title': document$1.title,
23991 'current_domain': win.location.hostname,
23992 'current_url_path': win.location.pathname,
23993 'current_url_protocol': win.location.protocol,
23994 'current_url_search': win.location.search
23995 });
23996 }
23997 };
23998
23999 /**
24000 * Returns a throttled function that will only run at most every `waitMs` and returns a promise that resolves with the next invocation.
24001 * Throttled calls will build up a batch of args and invoke the callback with all args since the last invocation.
24002 */
24003 var batchedThrottle = function (fn, waitMs) {
24004 var timeoutPromise = null;
24005 var throttledItems = [];
24006 return function (item) {
24007 var self = this;
24008 throttledItems.push(item);
24009
24010 if (!timeoutPromise) {
24011 timeoutPromise = new PromisePolyfill(function (resolve) {
24012 setTimeout(function () {
24013 var returnValue = fn.apply(self, [throttledItems]);
24014 timeoutPromise = null;
24015 throttledItems = [];
24016 resolve(returnValue);
24017 }, waitMs);
24018 });
24019 }
24020 return timeoutPromise;
24021 };
24022 };
24023
24024 var cheap_guid = function(maxlen) {
24025 var guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
24026 return maxlen ? guid.substring(0, maxlen) : guid;
24027 };
24028
24029 /**
24030 * Generates a W3C traceparent header for easy interop with distributed tracing systems i.e Open Telemetry
24031 * https://www.w3.org/TR/trace-context/#traceparent-header
24032 */
24033 var generateTraceparent = function() {
24034 var traceID = _.UUID().replace(/-/g, '');
24035 var parentID = _.UUID().replace(/-/g, '').substring(0, 16);
24036
24037 // Sampled trace
24038 var traceFlags = '01';
24039
24040 return '00-' + traceID + '-' + parentID + '-' + traceFlags;
24041 };
24042
24043 // naive way to extract domain name (example.com) from full hostname (my.sub.example.com)
24044 var SIMPLE_DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]*\.[a-z]+$/i;
24045 // this next one attempts to account for some ccSLDs, e.g. extracting oxford.ac.uk from www.oxford.ac.uk
24046 var DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;
24047 /**
24048 * Attempts to extract main domain name from full hostname, using a few blunt heuristics. For
24049 * common TLDs like .com/.org that always have a simple SLD.TLD structure (example.com), we
24050 * simply extract the last two .-separated parts of the hostname (SIMPLE_DOMAIN_MATCH_REGEX).
24051 * For others, we attempt to account for short ccSLD+TLD combos (.ac.uk) with the legacy
24052 * DOMAIN_MATCH_REGEX (kept to maintain backwards compatibility with existing Mixpanel
24053 * integrations). The only _reliable_ way to extract domain from hostname is with an up-to-date
24054 * list like at https://publicsuffix.org/ so for cases that this helper fails at, the SDK
24055 * offers the 'cookie_domain' config option to set it explicitly.
24056 * @example
24057 * extract_domain('my.sub.example.com')
24058 * // 'example.com'
24059 */
24060 var extract_domain = function(hostname) {
24061 var domain_regex = DOMAIN_MATCH_REGEX;
24062 var parts = hostname.split('.');
24063 var tld = parts[parts.length - 1];
24064 if (tld.length > 4 || tld === 'com' || tld === 'org') {
24065 domain_regex = SIMPLE_DOMAIN_MATCH_REGEX;
24066 }
24067 var matches = hostname.match(domain_regex);
24068 return matches ? matches[0] : '';
24069 };
24070
24071 /**
24072 * Check whether we have network connection. default to true for browsers that don't support navigator.onLine (IE)
24073 * @returns {boolean}
24074 */
24075 var isOnline = function() {
24076 var onLine = win.navigator['onLine'];
24077 return _.isUndefined(onLine) || onLine;
24078 };
24079
24080 var NOOP_FUNC = function () {};
24081
24082 var JSONStringify = null, JSONParse = null;
24083 if (typeof JSON !== 'undefined') {
24084 JSONStringify = JSON.stringify;
24085 JSONParse = JSON.parse;
24086 }
24087 JSONStringify = JSONStringify || _.JSONEncode;
24088 JSONParse = JSONParse || _.JSONDecode;
24089
24090 // UNMINIFIED EXPORTS (for closure compiler)
24091 _['info'] = _.info;
24092 _['info']['browser'] = _.info.browser;
24093 _['info']['browserVersion'] = _.info.browserVersion;
24094 _['info']['device'] = _.info.device;
24095 _['info']['properties'] = _.info.properties;
24096 _['isBlockedUA'] = _.isBlockedUA;
24097 _['isEmptyObject'] = _.isEmptyObject;
24098 _['isObject'] = _.isObject;
24099 _['JSONDecode'] = _.JSONDecode;
24100 _['JSONEncode'] = _.JSONEncode;
24101 _['toArray'] = _.toArray;
24102 _['NPO'] = NpoPromise;
24103
24104 var MIXPANEL_DB_NAME = 'mixpanelBrowserDb';
24105
24106 var RECORDING_EVENTS_STORE_NAME = 'mixpanelRecordingEvents';
24107 var RECORDING_REGISTRY_STORE_NAME = 'mixpanelRecordingRegistry';
24108
24109 // note: increment the version number when adding new object stores
24110 var DB_VERSION = 1;
24111 var OBJECT_STORES = [RECORDING_EVENTS_STORE_NAME, RECORDING_REGISTRY_STORE_NAME];
24112
24113 /**
24114 * @type {import('./wrapper').StorageWrapper}
24115 */
24116 var IDBStorageWrapper = function (storeName) {
24117 /**
24118 * @type {Promise<IDBDatabase>|null}
24119 */
24120 this.dbPromise = null;
24121 this.storeName = storeName;
24122 };
24123
24124 IDBStorageWrapper.prototype._openDb = function () {
24125 return new PromisePolyfill(function (resolve, reject) {
24126 var openRequest = win.indexedDB.open(MIXPANEL_DB_NAME, DB_VERSION);
24127 openRequest['onerror'] = function () {
24128 reject(openRequest.error);
24129 };
24130
24131 openRequest['onsuccess'] = function () {
24132 resolve(openRequest.result);
24133 };
24134
24135 openRequest['onupgradeneeded'] = function (ev) {
24136 var db = ev.target.result;
24137
24138 OBJECT_STORES.forEach(function (storeName) {
24139 db.createObjectStore(storeName);
24140 });
24141 };
24142 });
24143 };
24144
24145 IDBStorageWrapper.prototype.init = function () {
24146 if (!win.indexedDB) {
24147 return PromisePolyfill.reject('indexedDB is not supported in this browser');
24148 }
24149
24150 if (!this.dbPromise) {
24151 this.dbPromise = this._openDb();
24152 }
24153
24154 return this.dbPromise
24155 .then(function (dbOrError) {
24156 if (dbOrError instanceof win['IDBDatabase']) {
24157 return PromisePolyfill.resolve();
24158 } else {
24159 return PromisePolyfill.reject(dbOrError);
24160 }
24161 });
24162 };
24163
24164 IDBStorageWrapper.prototype.isInitialized = function () {
24165 return !!this.dbPromise;
24166 };
24167
24168 /**
24169 * @param {IDBTransactionMode} mode
24170 * @param {function(IDBObjectStore): void} storeCb
24171 */
24172 IDBStorageWrapper.prototype.makeTransaction = function (mode, storeCb) {
24173 var storeName = this.storeName;
24174 var doTransaction = function (db) {
24175 return new PromisePolyfill(function (resolve, reject) {
24176 var transaction = db.transaction(storeName, mode);
24177 transaction.oncomplete = function () {
24178 resolve(transaction);
24179 };
24180 transaction.onabort = transaction.onerror = function () {
24181 reject(transaction.error);
24182 };
24183
24184 storeCb(transaction.objectStore(storeName));
24185 });
24186 };
24187
24188 return this.dbPromise
24189 .then(doTransaction)
24190 .catch(function (err) {
24191 if (err && err['name'] === 'InvalidStateError') {
24192 // try reopening the DB if the connection is closed
24193 this.dbPromise = this._openDb();
24194 return this.dbPromise.then(doTransaction);
24195 } else {
24196 return PromisePolyfill.reject(err);
24197 }
24198 }.bind(this));
24199 };
24200
24201 IDBStorageWrapper.prototype.setItem = function (key, value) {
24202 return this.makeTransaction('readwrite', function (objectStore) {
24203 objectStore.put(value, key);
24204 });
24205 };
24206
24207 IDBStorageWrapper.prototype.getItem = function (key) {
24208 var req;
24209 return this.makeTransaction('readonly', function (objectStore) {
24210 req = objectStore.get(key);
24211 }).then(function () {
24212 return req.result;
24213 });
24214 };
24215
24216 IDBStorageWrapper.prototype.removeItem = function (key) {
24217 return this.makeTransaction('readwrite', function (objectStore) {
24218 objectStore.delete(key);
24219 });
24220 };
24221
24222 IDBStorageWrapper.prototype.getAll = function () {
24223 var req;
24224 return this.makeTransaction('readonly', function (objectStore) {
24225 req = objectStore.getAll();
24226 }).then(function () {
24227 return req.result;
24228 });
24229 };
24230
24231 /**
24232 * GDPR utils
24233 *
24234 * The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
24235 * and privacy for all individuals within the European Union. It addresses the export of personal
24236 * data outside the EU. The GDPR aims primarily to give control back to citizens and residents
24237 * over their personal data and to simplify the regulatory environment for international business
24238 * by unifying the regulation within the EU.
24239 *
24240 * This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
24241 * These functions are used internally by the SDK and are not intended to be publicly exposed.
24242 */
24243
24244
24245 /**
24246 * A function used to track a Mixpanel event (e.g. MixpanelLib.track)
24247 * @callback trackFunction
24248 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
24249 * @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.
24250 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
24251 */
24252
24253 /** Public **/
24254
24255 var GDPR_DEFAULT_PERSISTENCE_PREFIX = '__mp_opt_in_out_';
24256
24257 /**
24258 * Opt the user in to data tracking and cookies/localstorage for the given token
24259 * @param {string} token - Mixpanel project tracking token
24260 * @param {Object} [options]
24261 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24262 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24263 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24264 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24265 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24266 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24267 * @param {string} [options.cookieDomain] - custom cookie domain
24268 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24269 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24270 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24271 */
24272 function optIn(token, options) {
24273 _optInOut(true, token, options);
24274 }
24275
24276 /**
24277 * Opt the user out of data tracking and cookies/localstorage for the given token
24278 * @param {string} token - Mixpanel project tracking token
24279 * @param {Object} [options]
24280 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24281 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24282 * @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires
24283 * @param {string} [options.cookieDomain] - custom cookie domain
24284 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24285 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not
24286 * @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not
24287 */
24288 function optOut(token, options) {
24289 _optInOut(false, token, options);
24290 }
24291
24292 /**
24293 * Check whether the user has opted in to data tracking and cookies/localstorage for the given token
24294 * @param {string} token - Mixpanel project tracking token
24295 * @param {Object} [options]
24296 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24297 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24298 * @returns {boolean} whether the user has opted in to the given opt type
24299 */
24300 function hasOptedIn(token, options) {
24301 return _getStorageValue(token, options) === '1';
24302 }
24303
24304 /**
24305 * Check whether the user has opted out of data tracking and cookies/localstorage for the given token
24306 * @param {string} token - Mixpanel project tracking token
24307 * @param {Object} [options]
24308 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24309 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24310 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24311 * @returns {boolean} whether the user has opted out of the given opt type
24312 */
24313 function hasOptedOut(token, options) {
24314 if (_hasDoNotTrackFlagOn(options)) {
24315 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"');
24316 return true;
24317 }
24318 var optedOut = _getStorageValue(token, options) === '0';
24319 if (optedOut) {
24320 console$1.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
24321 }
24322 return optedOut;
24323 }
24324
24325 /**
24326 * Wrap a MixpanelLib method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24327 * If the user has opted out, return early instead of executing the method.
24328 * If a callback argument was provided, execute it passing the 0 error code.
24329 * @param {function} method - wrapped method to be executed if the user has not opted out
24330 * @returns {*} the result of executing method OR undefined if the user has opted out
24331 */
24332 function addOptOutCheckMixpanelLib(method) {
24333 return _addOptOutCheck(method, function(name) {
24334 return this.get_config(name);
24335 });
24336 }
24337
24338 /**
24339 * Wrap a MixpanelPeople method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24340 * If the user has opted out, return early instead of executing the method.
24341 * If a callback argument was provided, execute it passing the 0 error code.
24342 * @param {function} method - wrapped method to be executed if the user has not opted out
24343 * @returns {*} the result of executing method OR undefined if the user has opted out
24344 */
24345 function addOptOutCheckMixpanelPeople(method) {
24346 return _addOptOutCheck(method, function(name) {
24347 return this._get_config(name);
24348 });
24349 }
24350
24351 /**
24352 * Wrap a MixpanelGroup method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24353 * If the user has opted out, return early instead of executing the method.
24354 * If a callback argument was provided, execute it passing the 0 error code.
24355 * @param {function} method - wrapped method to be executed if the user has not opted out
24356 * @returns {*} the result of executing method OR undefined if the user has opted out
24357 */
24358 function addOptOutCheckMixpanelGroup(method) {
24359 return _addOptOutCheck(method, function(name) {
24360 return this._get_config(name);
24361 });
24362 }
24363
24364 /**
24365 * Clear the user's opt in/out status of data tracking and cookies/localstorage for the given token
24366 * @param {string} token - Mixpanel project tracking token
24367 * @param {Object} [options]
24368 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24369 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24370 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24371 * @param {string} [options.cookieDomain] - custom cookie domain
24372 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24373 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24374 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24375 */
24376 function clearOptInOut(token, options) {
24377 options = options || {};
24378 _getStorage(options).remove(
24379 _getStorageKey(token, options), !!options.crossSubdomainCookie, options.cookieDomain
24380 );
24381 }
24382
24383 /** Private **/
24384
24385 /**
24386 * Get storage util
24387 * @param {Object} [options]
24388 * @param {string} [options.persistenceType]
24389 * @returns {object} either _.cookie or _.localstorage
24390 */
24391 function _getStorage(options) {
24392 options = options || {};
24393 return options.persistenceType === 'localStorage' ? _.localStorage : _.cookie;
24394 }
24395
24396 /**
24397 * Get the name of the cookie that is used for the given opt type (tracking, cookie, etc.)
24398 * @param {string} token - Mixpanel project tracking token
24399 * @param {Object} [options]
24400 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24401 * @returns {string} the name of the cookie for the given opt type
24402 */
24403 function _getStorageKey(token, options) {
24404 options = options || {};
24405 return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
24406 }
24407
24408 /**
24409 * Get the value of the cookie that is used for the given opt type (tracking, cookie, etc.)
24410 * @param {string} token - Mixpanel project tracking token
24411 * @param {Object} [options]
24412 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24413 * @returns {string} the value of the cookie for the given opt type
24414 */
24415 function _getStorageValue(token, options) {
24416 return _getStorage(options).get(_getStorageKey(token, options));
24417 }
24418
24419 /**
24420 * Check whether the user has set the DNT/doNotTrack setting to true in their browser
24421 * @param {Object} [options]
24422 * @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests
24423 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24424 * @returns {boolean} whether the DNT setting is true
24425 */
24426 function _hasDoNotTrackFlagOn(options) {
24427 if (options && options.ignoreDnt) {
24428 return false;
24429 }
24430 var win$1 = (options && options.window) || win;
24431 var nav = win$1['navigator'] || {};
24432 var hasDntOn = false;
24433
24434 _.each([
24435 nav['doNotTrack'], // standard
24436 nav['msDoNotTrack'],
24437 win$1['doNotTrack']
24438 ], function(dntValue) {
24439 if (_.includes([true, 1, '1', 'yes'], dntValue)) {
24440 hasDntOn = true;
24441 }
24442 });
24443
24444 return hasDntOn;
24445 }
24446
24447 /**
24448 * Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type
24449 * @param {boolean} optValue - whether to opt the user in or out for the given opt type
24450 * @param {string} token - Mixpanel project tracking token
24451 * @param {Object} [options]
24452 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24453 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24454 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24455 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24456 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24457 * @param {string} [options.cookieDomain] - custom cookie domain
24458 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24459 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24460 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24461 */
24462 function _optInOut(optValue, token, options) {
24463 if (!_.isString(token) || !token.length) {
24464 console$1.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token');
24465 return;
24466 }
24467
24468 options = options || {};
24469
24470 _getStorage(options).set(
24471 _getStorageKey(token, options),
24472 optValue ? 1 : 0,
24473 _.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
24474 !!options.crossSubdomainCookie,
24475 !!options.secureCookie,
24476 !!options.crossSiteCookie,
24477 options.cookieDomain
24478 );
24479
24480 if (options.track && optValue) { // only track event if opting in (optValue=true)
24481 options.track(options.trackEventName || '$opt_in', options.trackProperties, {
24482 'send_immediately': true
24483 });
24484 }
24485 }
24486
24487 /**
24488 * Wrap a method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24489 * If the user has opted out, return early instead of executing the method.
24490 * If a callback argument was provided, execute it passing the 0 error code.
24491 * @param {function} method - wrapped method to be executed if the user has not opted out
24492 * @param {function} getConfigValue - getter function for the Mixpanel API token and other options to be used with opt-out check
24493 * @returns {*} the result of executing method OR undefined if the user has opted out
24494 */
24495 function _addOptOutCheck(method, getConfigValue) {
24496 return function() {
24497 var optedOut = false;
24498
24499 try {
24500 var token = getConfigValue.call(this, 'token');
24501 var ignoreDnt = getConfigValue.call(this, 'ignore_dnt');
24502 var persistenceType = getConfigValue.call(this, 'opt_out_tracking_persistence_type');
24503 var persistencePrefix = getConfigValue.call(this, 'opt_out_tracking_cookie_prefix');
24504 var win = getConfigValue.call(this, 'window'); // used to override window during browser tests
24505
24506 if (token) { // if there was an issue getting the token, continue method execution as normal
24507 optedOut = hasOptedOut(token, {
24508 ignoreDnt: ignoreDnt,
24509 persistenceType: persistenceType,
24510 persistencePrefix: persistencePrefix,
24511 window: win
24512 });
24513 }
24514 } catch(err) {
24515 console$1.error('Unexpected error when checking tracking opt-out status: ' + err);
24516 }
24517
24518 if (!optedOut) {
24519 return method.apply(this, arguments);
24520 }
24521
24522 var callback = arguments[arguments.length - 1];
24523 if (typeof(callback) === 'function') {
24524 callback(0);
24525 }
24526
24527 return;
24528 };
24529 }
24530
24531 var logger$6 = console_with_prefix('lock');
24532
24533 /**
24534 * SharedLock: a mutex built on HTML5 localStorage, to ensure that only one browser
24535 * window/tab at a time will be able to access shared resources.
24536 *
24537 * Based on the Alur and Taubenfeld fast lock
24538 * (http://www.cs.rochester.edu/research/synchronization/pseudocode/fastlock.html)
24539 * with an added timeout to ensure there will be eventual progress in the event
24540 * that a window is closed in the middle of the callback.
24541 *
24542 * Implementation based on the original version by David Wolever (https://github.com/wolever)
24543 * at https://gist.github.com/wolever/5fd7573d1ef6166e8f8c4af286a69432.
24544 *
24545 * @example
24546 * const myLock = new SharedLock('some-key');
24547 * myLock.withLock(function() {
24548 * console.log('I hold the mutex!');
24549 * });
24550 *
24551 * @constructor
24552 */
24553 var SharedLock = function(key, options) {
24554 options = options || {};
24555
24556 this.storageKey = key;
24557 this.storage = options.storage || win.localStorage;
24558 this.pollIntervalMS = options.pollIntervalMS || 100;
24559 this.timeoutMS = options.timeoutMS || 2000;
24560
24561 // dependency-inject promise implementation for testing purposes
24562 this.promiseImpl = options.promiseImpl || PromisePolyfill;
24563 };
24564
24565 // pass in a specific pid to test contention scenarios; otherwise
24566 // it is chosen randomly for each acquisition attempt
24567 SharedLock.prototype.withLock = function(lockedCB, pid) {
24568 var Promise = this.promiseImpl;
24569 return new Promise(_.bind(function (resolve, reject) {
24570 var i = pid || (new Date().getTime() + '|' + Math.random());
24571 var startTime = new Date().getTime();
24572 var key = this.storageKey;
24573 var pollIntervalMS = this.pollIntervalMS;
24574 var timeoutMS = this.timeoutMS;
24575 var storage = this.storage;
24576
24577 var keyX = key + ':X';
24578 var keyY = key + ':Y';
24579 var keyZ = key + ':Z';
24580
24581 var delay = function(cb) {
24582 if (new Date().getTime() - startTime > timeoutMS) {
24583 logger$6.error('Timeout waiting for mutex on ' + key + '; clearing lock. [' + i + ']');
24584 storage.removeItem(keyZ);
24585 storage.removeItem(keyY);
24586 loop();
24587 return;
24588 }
24589 setTimeout(function() {
24590 try {
24591 cb();
24592 } catch(err) {
24593 reject(err);
24594 }
24595 }, pollIntervalMS * (Math.random() + 0.1));
24596 };
24597
24598 var waitFor = function(predicate, cb) {
24599 if (predicate()) {
24600 cb();
24601 } else {
24602 delay(function() {
24603 waitFor(predicate, cb);
24604 });
24605 }
24606 };
24607
24608 var getSetY = function() {
24609 var valY = storage.getItem(keyY);
24610 if (valY && valY !== i) { // if Y == i then this process already has the lock (useful for test cases)
24611 return false;
24612 } else {
24613 storage.setItem(keyY, i);
24614 if (storage.getItem(keyY) === i) {
24615 return true;
24616 } else {
24617 if (!localStorageSupported(storage, true)) {
24618 reject(new Error('localStorage support dropped while acquiring lock'));
24619 }
24620 return false;
24621 }
24622 }
24623 };
24624
24625 var loop = function() {
24626 storage.setItem(keyX, i);
24627
24628 waitFor(getSetY, function() {
24629 if (storage.getItem(keyX) === i) {
24630 criticalSection();
24631 return;
24632 }
24633
24634 delay(function() {
24635 if (storage.getItem(keyY) !== i) {
24636 loop();
24637 return;
24638 }
24639 waitFor(function() {
24640 return !storage.getItem(keyZ);
24641 }, criticalSection);
24642 });
24643 });
24644 };
24645
24646 var criticalSection = function() {
24647 storage.setItem(keyZ, '1');
24648 var removeLock = function () {
24649 storage.removeItem(keyZ);
24650 if (storage.getItem(keyY) === i) {
24651 storage.removeItem(keyY);
24652 }
24653 if (storage.getItem(keyX) === i) {
24654 storage.removeItem(keyX);
24655 }
24656 };
24657
24658 lockedCB()
24659 .then(function (ret) {
24660 removeLock();
24661 resolve(ret);
24662 })
24663 .catch(function (err) {
24664 removeLock();
24665 reject(err);
24666 });
24667 };
24668
24669 try {
24670 if (localStorageSupported(storage, true)) {
24671 loop();
24672 } else {
24673 throw new Error('localStorage support check failed');
24674 }
24675 } catch(err) {
24676 reject(err);
24677 }
24678 }, this));
24679 };
24680
24681 /**
24682 * @type {import('./wrapper').StorageWrapper}
24683 */
24684 var LocalStorageWrapper = function (storageOverride) {
24685 this.storage = storageOverride || win.localStorage;
24686 };
24687
24688 LocalStorageWrapper.prototype.init = function () {
24689 return PromisePolyfill.resolve();
24690 };
24691
24692 LocalStorageWrapper.prototype.isInitialized = function () {
24693 return true;
24694 };
24695
24696 LocalStorageWrapper.prototype.setItem = function (key, value) {
24697 return new PromisePolyfill(_.bind(function (resolve, reject) {
24698 try {
24699 this.storage.setItem(key, JSONStringify(value));
24700 } catch (e) {
24701 reject(e);
24702 }
24703 resolve();
24704 }, this));
24705 };
24706
24707 LocalStorageWrapper.prototype.getItem = function (key) {
24708 return new PromisePolyfill(_.bind(function (resolve, reject) {
24709 var item;
24710 try {
24711 item = JSONParse(this.storage.getItem(key));
24712 } catch (e) {
24713 reject(e);
24714 }
24715 resolve(item);
24716 }, this));
24717 };
24718
24719 LocalStorageWrapper.prototype.removeItem = function (key) {
24720 return new PromisePolyfill(_.bind(function (resolve, reject) {
24721 try {
24722 this.storage.removeItem(key);
24723 } catch (e) {
24724 reject(e);
24725 }
24726 resolve();
24727 }, this));
24728 };
24729
24730 var logger$5 = console_with_prefix('batch');
24731
24732 /**
24733 * RequestQueue: queue for batching API requests with localStorage backup for retries.
24734 * Maintains an in-memory queue which represents the source of truth for the current
24735 * page, but also writes all items out to a copy in the browser's localStorage, which
24736 * can be read on subsequent pageloads and retried. For batchability, all the request
24737 * items in the queue should be of the same type (events, people updates, group updates)
24738 * so they can be sent in a single request to the same API endpoint.
24739 *
24740 * LocalStorage keying and locking: In order for reloads and subsequent pageloads of
24741 * the same site to access the same persisted data, they must share the same localStorage
24742 * key (for instance based on project token and queue type). Therefore access to the
24743 * localStorage entry is guarded by an asynchronous mutex (SharedLock) to prevent
24744 * simultaneously open windows/tabs from overwriting each other's data (which would lead
24745 * to data loss in some situations).
24746 * @constructor
24747 */
24748 var RequestQueue = function (storageKey, options) {
24749 options = options || {};
24750 this.storageKey = storageKey;
24751 this.usePersistence = options.usePersistence;
24752 if (this.usePersistence) {
24753 this.queueStorage = options.queueStorage || new LocalStorageWrapper();
24754 this.lock = new SharedLock(storageKey, {
24755 storage: options.sharedLockStorage || win.localStorage,
24756 timeoutMS: options.sharedLockTimeoutMS,
24757 });
24758 }
24759 this.reportError = options.errorReporter || _.bind(logger$5.error, logger$5);
24760
24761 this.pid = options.pid || null; // pass pid to test out storage lock contention scenarios
24762
24763 this.memQueue = [];
24764 this.initialized = false;
24765
24766 if (options.enqueueThrottleMs) {
24767 this.enqueuePersisted = batchedThrottle(_.bind(this._enqueuePersisted, this), options.enqueueThrottleMs);
24768 } else {
24769 this.enqueuePersisted = _.bind(function (queueEntry) {
24770 return this._enqueuePersisted([queueEntry]);
24771 }, this);
24772 }
24773 };
24774
24775 RequestQueue.prototype.ensureInit = function () {
24776 if (this.initialized || !this.usePersistence) {
24777 return PromisePolyfill.resolve();
24778 }
24779
24780 return this.queueStorage
24781 .init()
24782 .then(_.bind(function () {
24783 this.initialized = true;
24784 }, this))
24785 .catch(_.bind(function (err) {
24786 this.reportError('Error initializing queue persistence. Disabling persistence', err);
24787 this.initialized = true;
24788 this.usePersistence = false;
24789 }, this));
24790 };
24791
24792 /**
24793 * Add one item to queues (memory and localStorage). The queued entry includes
24794 * the given item along with an auto-generated ID and a "flush-after" timestamp.
24795 * It is expected that the item will be sent over the network and dequeued
24796 * before the flush-after time; if this doesn't happen it is considered orphaned
24797 * (e.g., the original tab where it was enqueued got closed before it could be
24798 * sent) and the item can be sent by any tab that finds it in localStorage.
24799 *
24800 * The final callback param is called with a param indicating success or
24801 * failure of the enqueue operation; it is asynchronous because the localStorage
24802 * lock is asynchronous.
24803 */
24804 RequestQueue.prototype.enqueue = function (item, flushInterval) {
24805 var queueEntry = {
24806 'id': cheap_guid(),
24807 'flushAfter': new Date().getTime() + flushInterval * 2,
24808 'payload': item
24809 };
24810
24811 if (!this.usePersistence) {
24812 this.memQueue.push(queueEntry);
24813 return PromisePolyfill.resolve(true);
24814 } else {
24815 return this.enqueuePersisted(queueEntry);
24816 }
24817 };
24818
24819 RequestQueue.prototype._enqueuePersisted = function (queueEntries) {
24820 var enqueueItem = _.bind(function () {
24821 return this.ensureInit()
24822 .then(_.bind(function () {
24823 return this.readFromStorage();
24824 }, this))
24825 .then(_.bind(function (storedQueue) {
24826 return this.saveToStorage(storedQueue.concat(queueEntries));
24827 }, this))
24828 .then(_.bind(function (succeeded) {
24829 // only add to in-memory queue when storage succeeds
24830 if (succeeded) {
24831 this.memQueue = this.memQueue.concat(queueEntries);
24832 }
24833
24834 return succeeded;
24835 }, this))
24836 .catch(_.bind(function (err) {
24837 this.reportError('Error enqueueing items', err, queueEntries);
24838 return false;
24839 }, this));
24840 }, this);
24841
24842 return this.lock
24843 .withLock(enqueueItem, this.pid)
24844 .catch(_.bind(function (err) {
24845 this.reportError('Error acquiring storage lock', err);
24846 return false;
24847 }, this));
24848 };
24849
24850 /**
24851 * Read out the given number of queue entries. If this.memQueue
24852 * has fewer than batchSize items, then look for "orphaned" items
24853 * in the persisted queue (items where the 'flushAfter' time has
24854 * already passed).
24855 */
24856 RequestQueue.prototype.fillBatch = function (batchSize) {
24857 var batch = this.memQueue.slice(0, batchSize);
24858 if (this.usePersistence && batch.length < batchSize) {
24859 // don't need lock just to read events; localStorage is thread-safe
24860 // and the worst that could happen is a duplicate send of some
24861 // orphaned events, which will be deduplicated on the server side
24862 return this.ensureInit()
24863 .then(_.bind(function () {
24864 return this.readFromStorage();
24865 }, this))
24866 .then(_.bind(function (storedQueue) {
24867 if (storedQueue.length) {
24868 // item IDs already in batch; don't duplicate out of storage
24869 var idsInBatch = {}; // poor man's Set
24870 _.each(batch, function (item) {
24871 idsInBatch[item['id']] = true;
24872 });
24873
24874 for (var i = 0; i < storedQueue.length; i++) {
24875 var item = storedQueue[i];
24876 if (new Date().getTime() > item['flushAfter'] && !idsInBatch[item['id']]) {
24877 item.orphaned = true;
24878 batch.push(item);
24879 if (batch.length >= batchSize) {
24880 break;
24881 }
24882 }
24883 }
24884 }
24885
24886 return batch;
24887 }, this));
24888 } else {
24889 return PromisePolyfill.resolve(batch);
24890 }
24891 };
24892
24893 /**
24894 * Remove items with matching 'id' from array (immutably)
24895 * also remove any item without a valid id (e.g., malformed
24896 * storage entries).
24897 */
24898 var filterOutIDsAndInvalid = function (items, idSet) {
24899 var filteredItems = [];
24900 _.each(items, function (item) {
24901 if (item['id'] && !idSet[item['id']]) {
24902 filteredItems.push(item);
24903 }
24904 });
24905 return filteredItems;
24906 };
24907
24908 /**
24909 * Remove items with matching IDs from both in-memory queue
24910 * and persisted queue
24911 */
24912 RequestQueue.prototype.removeItemsByID = function (ids) {
24913 var idSet = {}; // poor man's Set
24914 _.each(ids, function (id) {
24915 idSet[id] = true;
24916 });
24917
24918 this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
24919 if (!this.usePersistence) {
24920 return PromisePolyfill.resolve(true);
24921 } else {
24922 var removeFromStorage = _.bind(function () {
24923 return this.ensureInit()
24924 .then(_.bind(function () {
24925 return this.readFromStorage();
24926 }, this))
24927 .then(_.bind(function (storedQueue) {
24928 storedQueue = filterOutIDsAndInvalid(storedQueue, idSet);
24929 return this.saveToStorage(storedQueue);
24930 }, this))
24931 .then(_.bind(function () {
24932 return this.readFromStorage();
24933 }, this))
24934 .then(_.bind(function (storedQueue) {
24935 // an extra check: did storage report success but somehow
24936 // the items are still there?
24937 for (var i = 0; i < storedQueue.length; i++) {
24938 var item = storedQueue[i];
24939 if (item['id'] && !!idSet[item['id']]) {
24940 throw new Error('Item not removed from storage');
24941 }
24942 }
24943 return true;
24944 }, this))
24945 .catch(_.bind(function (err) {
24946 this.reportError('Error removing items', err, ids);
24947 return false;
24948 }, this));
24949 }, this);
24950
24951 return this.lock
24952 .withLock(removeFromStorage, this.pid)
24953 .catch(_.bind(function (err) {
24954 this.reportError('Error acquiring storage lock', err);
24955 if (!localStorageSupported(this.lock.storage, true)) {
24956 // Looks like localStorage writes have stopped working sometime after
24957 // initialization (probably full), and so nobody can acquire locks
24958 // anymore. Consider it temporarily safe to remove items without the
24959 // lock, since nobody's writing successfully anyway.
24960 return removeFromStorage()
24961 .then(_.bind(function (success) {
24962 if (!success) {
24963 // OK, we couldn't even write out the smaller queue. Try clearing it
24964 // entirely.
24965 return this.queueStorage.removeItem(this.storageKey).then(function () {
24966 return success;
24967 });
24968 }
24969 return success;
24970 }, this))
24971 .catch(_.bind(function (err) {
24972 this.reportError('Error clearing queue', err);
24973 return false;
24974 }, this));
24975 } else {
24976 return false;
24977 }
24978 }, this));
24979 }
24980 };
24981
24982 // internal helper for RequestQueue.updatePayloads
24983 var updatePayloads = function (existingItems, itemsToUpdate) {
24984 var newItems = [];
24985 _.each(existingItems, function (item) {
24986 var id = item['id'];
24987 if (id in itemsToUpdate) {
24988 var newPayload = itemsToUpdate[id];
24989 if (newPayload !== null) {
24990 item['payload'] = newPayload;
24991 newItems.push(item);
24992 }
24993 } else {
24994 // no update
24995 newItems.push(item);
24996 }
24997 });
24998 return newItems;
24999 };
25000
25001 /**
25002 * Update payloads of given items in both in-memory queue and
25003 * persisted queue. Items set to null are removed from queues.
25004 */
25005 RequestQueue.prototype.updatePayloads = function (itemsToUpdate) {
25006 this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
25007 if (!this.usePersistence) {
25008 return PromisePolyfill.resolve(true);
25009 } else {
25010 return this.lock
25011 .withLock(_.bind(function lockAcquired() {
25012 return this.ensureInit()
25013 .then(_.bind(function () {
25014 return this.readFromStorage();
25015 }, this))
25016 .then(_.bind(function (storedQueue) {
25017 storedQueue = updatePayloads(storedQueue, itemsToUpdate);
25018 return this.saveToStorage(storedQueue);
25019 }, this))
25020 .catch(_.bind(function (err) {
25021 this.reportError('Error updating items', itemsToUpdate, err);
25022 return false;
25023 }, this));
25024 }, this), this.pid)
25025 .catch(_.bind(function (err) {
25026 this.reportError('Error acquiring storage lock', err);
25027 return false;
25028 }, this));
25029 }
25030 };
25031
25032 /**
25033 * Read and parse items array from localStorage entry, handling
25034 * malformed/missing data if necessary.
25035 */
25036 RequestQueue.prototype.readFromStorage = function () {
25037 return this.ensureInit()
25038 .then(_.bind(function () {
25039 return this.queueStorage.getItem(this.storageKey);
25040 }, this))
25041 .then(_.bind(function (storageEntry) {
25042 if (storageEntry) {
25043 if (!_.isArray(storageEntry)) {
25044 this.reportError('Invalid storage entry:', storageEntry);
25045 storageEntry = null;
25046 }
25047 }
25048 return storageEntry || [];
25049 }, this))
25050 .catch(_.bind(function (err) {
25051 this.reportError('Error retrieving queue', err);
25052 return [];
25053 }, this));
25054 };
25055
25056 /**
25057 * Serialize the given items array to localStorage.
25058 */
25059 RequestQueue.prototype.saveToStorage = function (queue) {
25060 return this.ensureInit()
25061 .then(_.bind(function () {
25062 return this.queueStorage.setItem(this.storageKey, queue);
25063 }, this))
25064 .then(function () {
25065 return true;
25066 })
25067 .catch(_.bind(function (err) {
25068 this.reportError('Error saving queue', err);
25069 return false;
25070 }, this));
25071 };
25072
25073 /**
25074 * Clear out queues (memory and localStorage).
25075 */
25076 RequestQueue.prototype.clear = function () {
25077 this.memQueue = [];
25078
25079 if (this.usePersistence) {
25080 return this.ensureInit()
25081 .then(_.bind(function () {
25082 return this.queueStorage.removeItem(this.storageKey);
25083 }, this));
25084 } else {
25085 return PromisePolyfill.resolve();
25086 }
25087 };
25088
25089 // maximum interval between request retries after exponential backoff
25090 var MAX_RETRY_INTERVAL_MS = 10 * 60 * 1000; // 10 minutes
25091
25092 var logger$4 = console_with_prefix('batch');
25093
25094 /**
25095 * RequestBatcher: manages the queueing, flushing, retry etc of requests of one
25096 * type (events, people, groups).
25097 * Uses RequestQueue to manage the backing store.
25098 * @constructor
25099 */
25100 var RequestBatcher = function(storageKey, options) {
25101 this.errorReporter = options.errorReporter;
25102 this.queue = new RequestQueue(storageKey, {
25103 errorReporter: _.bind(this.reportError, this),
25104 queueStorage: options.queueStorage,
25105 sharedLockStorage: options.sharedLockStorage,
25106 sharedLockTimeoutMS: options.sharedLockTimeoutMS,
25107 usePersistence: options.usePersistence,
25108 enqueueThrottleMs: options.enqueueThrottleMs
25109 });
25110
25111 this.libConfig = options.libConfig;
25112 this.sendRequest = options.sendRequestFunc;
25113 this.beforeSendHook = options.beforeSendHook;
25114 this.stopAllBatching = options.stopAllBatchingFunc;
25115
25116 // seed variable batch size + flush interval with configured values
25117 this.batchSize = this.libConfig['batch_size'];
25118 this.flushInterval = this.libConfig['batch_flush_interval_ms'];
25119
25120 this.stopped = !this.libConfig['batch_autostart'];
25121 this.consecutiveRemovalFailures = 0;
25122
25123 // extra client-side dedupe
25124 this.itemIdsSentSuccessfully = {};
25125
25126 // Make the flush occur at the interval specified by flushIntervalMs, default behavior will attempt consecutive flushes
25127 // as long as the queue is not empty. This is useful for high-frequency events like Session Replay where we might end up
25128 // in a request loop and get ratelimited by the server.
25129 this.flushOnlyOnInterval = options.flushOnlyOnInterval || false;
25130
25131 this._flushPromise = null;
25132 };
25133
25134 /**
25135 * Add one item to queue.
25136 */
25137 RequestBatcher.prototype.enqueue = function(item) {
25138 return this.queue.enqueue(item, this.flushInterval);
25139 };
25140
25141 /**
25142 * Start flushing batches at the configured time interval. Must call
25143 * this method upon SDK init in order to send anything over the network.
25144 */
25145 RequestBatcher.prototype.start = function() {
25146 this.stopped = false;
25147 this.consecutiveRemovalFailures = 0;
25148 return this.flush();
25149 };
25150
25151 /**
25152 * Stop flushing batches. Can be restarted by calling start().
25153 */
25154 RequestBatcher.prototype.stop = function() {
25155 this.stopped = true;
25156 if (this.timeoutID) {
25157 clearTimeout(this.timeoutID);
25158 this.timeoutID = null;
25159 }
25160 };
25161
25162 /**
25163 * Clear out queue.
25164 */
25165 RequestBatcher.prototype.clear = function() {
25166 return this.queue.clear();
25167 };
25168
25169 /**
25170 * Restore batch size configuration to whatever is set in the main SDK.
25171 */
25172 RequestBatcher.prototype.resetBatchSize = function() {
25173 this.batchSize = this.libConfig['batch_size'];
25174 };
25175
25176 /**
25177 * Restore flush interval time configuration to whatever is set in the main SDK.
25178 */
25179 RequestBatcher.prototype.resetFlush = function() {
25180 this.scheduleFlush(this.libConfig['batch_flush_interval_ms']);
25181 };
25182
25183 /**
25184 * Schedule the next flush in the given number of milliseconds.
25185 */
25186 RequestBatcher.prototype.scheduleFlush = function(flushMS) {
25187 this.flushInterval = flushMS;
25188 if (!this.stopped) { // don't schedule anymore if batching has been stopped
25189 this.timeoutID = setTimeout(_.bind(function() {
25190 if (!this.stopped) {
25191 this._flushPromise = this.flush();
25192 }
25193 }, this), this.flushInterval);
25194 }
25195 };
25196
25197 /**
25198 * Send a request using the sendRequest callback, but promisified.
25199 * TODO: sendRequest should be promisified in the first place.
25200 */
25201 RequestBatcher.prototype.sendRequestPromise = function(data, options) {
25202 return new PromisePolyfill(_.bind(function(resolve) {
25203 this.sendRequest(data, options, resolve);
25204 }, this));
25205 };
25206
25207
25208 /**
25209 * Flush one batch to network. Depending on success/failure modes, it will either
25210 * remove the batch from the queue or leave it in for retry, and schedule the next
25211 * flush. In cases of most network or API failures, it will back off exponentially
25212 * when retrying.
25213 * @param {Object} [options]
25214 * @param {boolean} [options.sendBeacon] - whether to send batch with
25215 * navigator.sendBeacon (only useful for sending batches before page unloads, as
25216 * sendBeacon offers no callbacks or status indications)
25217 */
25218 RequestBatcher.prototype.flush = function(options) {
25219 if (this.requestInProgress) {
25220 logger$4.log('Flush: Request already in progress');
25221 return PromisePolyfill.resolve();
25222 }
25223
25224 this.requestInProgress = true;
25225
25226 options = options || {};
25227 var timeoutMS = this.libConfig['batch_request_timeout_ms'];
25228 var startTime = new Date().getTime();
25229 var currentBatchSize = this.batchSize;
25230
25231 return this.queue.fillBatch(currentBatchSize)
25232 .then(_.bind(function(batch) {
25233
25234 // if there's more items in the queue than the batch size, attempt
25235 // to flush again after the current batch is done.
25236 var attemptSecondaryFlush = batch.length === currentBatchSize;
25237 var dataForRequest = [];
25238 var transformedItems = {};
25239 _.each(batch, function(item) {
25240 var payload = item['payload'];
25241 if (this.beforeSendHook && !item.orphaned) {
25242 payload = this.beforeSendHook(payload);
25243 }
25244 if (payload) {
25245 // mp_sent_by_lib_version prop captures which lib version actually
25246 // sends each event (regardless of which version originally queued
25247 // it for sending)
25248 if (payload['event'] && payload['properties']) {
25249 payload['properties'] = _.extend(
25250 {},
25251 payload['properties'],
25252 {'mp_sent_by_lib_version': Config.LIB_VERSION}
25253 );
25254 }
25255 var addPayload = true;
25256 var itemId = item['id'];
25257 if (itemId) {
25258 if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
25259 this.reportError('[dupe] item ID sent too many times, not sending', {
25260 item: item,
25261 batchSize: batch.length,
25262 timesSent: this.itemIdsSentSuccessfully[itemId]
25263 });
25264 addPayload = false;
25265 }
25266 } else {
25267 this.reportError('[dupe] found item with no ID', {item: item});
25268 }
25269
25270 if (addPayload) {
25271 dataForRequest.push(payload);
25272 }
25273 }
25274 transformedItems[item['id']] = payload;
25275 }, this);
25276
25277 if (dataForRequest.length < 1) {
25278 this.requestInProgress = false;
25279 this.resetFlush();
25280 return PromisePolyfill.resolve(); // nothing to do
25281 }
25282
25283 var removeItemsFromQueue = _.bind(function () {
25284 return this.queue
25285 .removeItemsByID(
25286 _.map(batch, function (item) {
25287 return item['id'];
25288 })
25289 )
25290 .then(_.bind(function (succeeded) {
25291 // client-side dedupe
25292 _.each(batch, _.bind(function(item) {
25293 var itemId = item['id'];
25294 if (itemId) {
25295 this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
25296 this.itemIdsSentSuccessfully[itemId]++;
25297 if (this.itemIdsSentSuccessfully[itemId] > 5) {
25298 this.reportError('[dupe] item ID sent too many times', {
25299 item: item,
25300 batchSize: batch.length,
25301 timesSent: this.itemIdsSentSuccessfully[itemId]
25302 });
25303 }
25304 } else {
25305 this.reportError('[dupe] found item with no ID while removing', {item: item});
25306 }
25307 }, this));
25308
25309 if (succeeded) {
25310 this.consecutiveRemovalFailures = 0;
25311 if (this.flushOnlyOnInterval && !attemptSecondaryFlush) {
25312 this.resetFlush(); // schedule next batch with a delay
25313 return PromisePolyfill.resolve();
25314 } else {
25315 return this.flush(); // handle next batch if the queue isn't empty
25316 }
25317 } else {
25318 if (++this.consecutiveRemovalFailures > 5) {
25319 this.reportError('Too many queue failures; disabling batching system.');
25320 this.stopAllBatching();
25321 } else {
25322 this.resetFlush();
25323 }
25324 return PromisePolyfill.resolve();
25325 }
25326 }, this));
25327 }, this);
25328
25329 var batchSendCallback = _.bind(function(res) {
25330 this.requestInProgress = false;
25331
25332 try {
25333
25334 // handle API response in a try-catch to make sure we can reset the
25335 // flush operation if something goes wrong
25336
25337 if (options.unloading) {
25338 // update persisted data to include hook transformations
25339 return this.queue.updatePayloads(transformedItems);
25340 } else if (
25341 _.isObject(res) &&
25342 res.error === 'timeout' &&
25343 new Date().getTime() - startTime >= timeoutMS
25344 ) {
25345 this.reportError('Network timeout; retrying');
25346 return this.flush();
25347 } else if (
25348 _.isObject(res) &&
25349 (
25350 res.httpStatusCode >= 500
25351 || res.httpStatusCode === 429
25352 || (res.httpStatusCode <= 0 && !isOnline())
25353 || res.error === 'timeout'
25354 )
25355 ) {
25356 // network or API error, or 429 Too Many Requests, retry
25357 var retryMS = this.flushInterval * 2;
25358 if (res.retryAfter) {
25359 retryMS = (parseInt(res.retryAfter, 10) * 1000) || retryMS;
25360 }
25361 retryMS = Math.min(MAX_RETRY_INTERVAL_MS, retryMS);
25362 this.reportError('Error; retry in ' + retryMS + ' ms');
25363 this.scheduleFlush(retryMS);
25364 return PromisePolyfill.resolve();
25365 } else if (_.isObject(res) && res.httpStatusCode === 413) {
25366 // 413 Payload Too Large
25367 if (batch.length > 1) {
25368 var halvedBatchSize = Math.max(1, Math.floor(currentBatchSize / 2));
25369 this.batchSize = Math.min(this.batchSize, halvedBatchSize, batch.length - 1);
25370 this.reportError('413 response; reducing batch size to ' + this.batchSize);
25371 this.resetFlush();
25372 return PromisePolyfill.resolve();
25373 } else {
25374 this.reportError('Single-event request too large; dropping', batch);
25375 this.resetBatchSize();
25376 return removeItemsFromQueue();
25377 }
25378 } else {
25379 // successful network request+response; remove each item in batch from queue
25380 // (even if it was e.g. a 400, in which case retrying won't help)
25381 return removeItemsFromQueue();
25382 }
25383 } catch(err) {
25384 this.reportError('Error handling API response', err);
25385 this.resetFlush();
25386 }
25387 }, this);
25388 var requestOptions = {
25389 method: 'POST',
25390 verbose: true,
25391 ignore_json_errors: true, // eslint-disable-line camelcase
25392 timeout_ms: timeoutMS // eslint-disable-line camelcase
25393 };
25394 if (options.unloading) {
25395 requestOptions.transport = 'sendBeacon';
25396 }
25397 logger$4.log('MIXPANEL REQUEST:', dataForRequest);
25398 return this.sendRequestPromise(dataForRequest, requestOptions).then(batchSendCallback);
25399 }, this))
25400 .catch(_.bind(function(err) {
25401 this.reportError('Error flushing request queue', err);
25402 this.resetFlush();
25403 }, this));
25404 };
25405
25406 /**
25407 * Log error to global logger and optional user-defined logger.
25408 */
25409 RequestBatcher.prototype.reportError = function(msg, err) {
25410 logger$4.error.apply(logger$4.error, arguments);
25411 if (this.errorReporter) {
25412 try {
25413 if (!(err instanceof Error)) {
25414 err = new Error(msg);
25415 }
25416 this.errorReporter(msg, err);
25417 } catch(err) {
25418 logger$4.error(err);
25419 }
25420 }
25421 };
25422
25423 /**
25424 * @param {import('./session-recording').SerializedRecording} serializedRecording
25425 * @returns {boolean}
25426 */
25427 var isRecordingExpired = function(serializedRecording) {
25428 var now = Date.now();
25429 return !serializedRecording || now > serializedRecording['maxExpires'] || now > serializedRecording['idleExpires'];
25430 };
25431
25432 var RECORD_ENQUEUE_THROTTLE_MS = 250;
25433
25434 var logger$3 = console_with_prefix('recorder');
25435 var CompressionStream = win['CompressionStream'];
25436
25437 var RECORDER_BATCHER_LIB_CONFIG = {
25438 'batch_size': 1000,
25439 'batch_flush_interval_ms': 10 * 1000,
25440 'batch_request_timeout_ms': 90 * 1000,
25441 'batch_autostart': true
25442 };
25443
25444 var ACTIVE_SOURCES = new Set([
25445 IncrementalSource.MouseMove,
25446 IncrementalSource.MouseInteraction,
25447 IncrementalSource.Scroll,
25448 IncrementalSource.ViewportResize,
25449 IncrementalSource.Input,
25450 IncrementalSource.TouchMove,
25451 IncrementalSource.MediaInteraction,
25452 IncrementalSource.Drag,
25453 IncrementalSource.Selection,
25454 ]);
25455
25456 function isUserEvent(ev) {
25457 return ev.type === EventType.IncrementalSnapshot && ACTIVE_SOURCES.has(ev.data.source);
25458 }
25459
25460 /**
25461 * @typedef {Object} SerializedRecording
25462 * @property {number} idleExpires
25463 * @property {number} maxExpires
25464 * @property {number} replayStartTime
25465 * @property {number} seqNo
25466 * @property {string} batchStartUrl
25467 * @property {string} replayId
25468 * @property {string} tabId
25469 * @property {string} replayStartUrl
25470 */
25471
25472 /**
25473 * @typedef {Object} SessionRecordingOptions
25474 * @property {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
25475 * @property {String} [options.replayId] - unique uuid for a single replay
25476 * @property {Function} [options.onIdleTimeout] - callback when a recording reaches idle timeout
25477 * @property {Function} [options.onMaxLengthReached] - callback when a recording reaches its maximum length
25478 * @property {Function} [options.rrwebRecord] - rrweb's `record` function
25479 * @property {Function} [options.onBatchSent] - callback when a batch of events is sent to the server
25480 * @property {Storage} [options.sharedLockStorage] - optional storage for shared lock, used for test dependency injection
25481 * optional properties for deserialization:
25482 * @property {number} idleExpires
25483 * @property {number} maxExpires
25484 * @property {number} replayStartTime
25485 * @property {number} seqNo
25486 * @property {string} batchStartUrl
25487 * @property {string} replayStartUrl
25488 */
25489
25490 /**
25491 * @typedef {Object} UserIdInfo
25492 * @property {string} distinct_id
25493 * @property {string} user_id
25494 * @property {string} device_id
25495 */
25496
25497
25498 /**
25499 * This class encapsulates a single session recording and its lifecycle.
25500 * @param {SessionRecordingOptions} options
25501 */
25502 var SessionRecording = function(options) {
25503 this._mixpanel = options.mixpanelInstance;
25504 this._onIdleTimeout = options.onIdleTimeout || NOOP_FUNC;
25505 this._onMaxLengthReached = options.onMaxLengthReached || NOOP_FUNC;
25506 this._onBatchSent = options.onBatchSent || NOOP_FUNC;
25507 this._rrwebRecord = options.rrwebRecord || null;
25508
25509 // internal rrweb stopRecording function
25510 this._stopRecording = null;
25511 this.replayId = options.replayId;
25512
25513 this.batchStartUrl = options.batchStartUrl || null;
25514 this.replayStartUrl = options.replayStartUrl || null;
25515 this.idleExpires = options.idleExpires || null;
25516 this.maxExpires = options.maxExpires || null;
25517 this.replayStartTime = options.replayStartTime || null;
25518 this.seqNo = options.seqNo || 0;
25519
25520 this.idleTimeoutId = null;
25521 this.maxTimeoutId = null;
25522
25523 this.recordMaxMs = MAX_RECORDING_MS;
25524 this.recordMinMs = 0;
25525
25526 // disable persistence if localStorage is not supported
25527 // request-queue will automatically disable persistence if indexedDB fails to initialize
25528 var usePersistence = localStorageSupported(options.sharedLockStorage, true) && !this.getConfig('disable_persistence');
25529
25530 // each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
25531 this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
25532 this.queueStorage = new IDBStorageWrapper(RECORDING_EVENTS_STORE_NAME);
25533 this.batcher = new RequestBatcher(this.batcherKey, {
25534 errorReporter: this.reportError.bind(this),
25535 flushOnlyOnInterval: true,
25536 libConfig: RECORDER_BATCHER_LIB_CONFIG,
25537 sendRequestFunc: this.flushEventsWithOptOut.bind(this),
25538 queueStorage: this.queueStorage,
25539 sharedLockStorage: options.sharedLockStorage,
25540 usePersistence: usePersistence,
25541 stopAllBatchingFunc: this.stopRecording.bind(this),
25542
25543 // increased throttle and shared lock timeout because recording events are very high frequency.
25544 // this will minimize the amount of lock contention between enqueued events.
25545 // for session recordings there is a lock for each tab anyway, so there's no risk of deadlock between tabs.
25546 enqueueThrottleMs: RECORD_ENQUEUE_THROTTLE_MS,
25547 sharedLockTimeoutMS: 10 * 1000,
25548 });
25549 };
25550
25551 /**
25552 * @returns {UserIdInfo}
25553 */
25554 SessionRecording.prototype.getUserIdInfo = function () {
25555 if (this.finalFlushUserIdInfo) {
25556 return this.finalFlushUserIdInfo;
25557 }
25558
25559 var userIdInfo = {
25560 'distinct_id': String(this._mixpanel.get_distinct_id()),
25561 };
25562
25563 // send ID management props if they exist
25564 var deviceId = this._mixpanel.get_property('$device_id');
25565 if (deviceId) {
25566 userIdInfo['$device_id'] = deviceId;
25567 }
25568 var userId = this._mixpanel.get_property('$user_id');
25569 if (userId) {
25570 userIdInfo['$user_id'] = userId;
25571 }
25572 return userIdInfo;
25573 };
25574
25575 SessionRecording.prototype.unloadPersistedData = function () {
25576 this.batcher.stop();
25577 return this.batcher.flush()
25578 .then(function () {
25579 return this.queueStorage.removeItem(this.batcherKey);
25580 }.bind(this));
25581 };
25582
25583 SessionRecording.prototype.getConfig = function(configVar) {
25584 return this._mixpanel.get_config(configVar);
25585 };
25586
25587 // Alias for getConfig, used by the common addOptOutCheckMixpanelLib function which
25588 // reaches into this class instance and expects the snake case version of the function.
25589 // eslint-disable-next-line camelcase
25590 SessionRecording.prototype.get_config = function(configVar) {
25591 return this.getConfig(configVar);
25592 };
25593
25594 SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
25595 if (this._rrwebRecord === null) {
25596 this.reportError('rrweb record function not provided. ');
25597 return;
25598 }
25599
25600 if (this._stopRecording !== null) {
25601 logger$3.log('Recording already in progress, skipping startRecording.');
25602 return;
25603 }
25604
25605 this.recordMaxMs = this.getConfig('record_max_ms');
25606 if (this.recordMaxMs > MAX_RECORDING_MS) {
25607 this.recordMaxMs = MAX_RECORDING_MS;
25608 logger$3.critical('record_max_ms cannot be greater than ' + MAX_RECORDING_MS + 'ms. Capping value.');
25609 }
25610
25611 if (!this.maxExpires) {
25612 this.maxExpires = new Date().getTime() + this.recordMaxMs;
25613 }
25614
25615 this.recordMinMs = this.getConfig('record_min_ms');
25616 if (this.recordMinMs > MAX_VALUE_FOR_MIN_RECORDING_MS) {
25617 this.recordMinMs = MAX_VALUE_FOR_MIN_RECORDING_MS;
25618 logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
25619 }
25620
25621 if (!this.replayStartTime) {
25622 this.replayStartTime = new Date().getTime();
25623 this.batchStartUrl = _.info.currentUrl();
25624 this.replayStartUrl = _.info.currentUrl();
25625 }
25626
25627 if (shouldStopBatcher || this.recordMinMs > 0) {
25628 // the primary case for shouldStopBatcher is when we're starting recording after a reset
25629 // and don't want to send anything over the network until there's
25630 // actual user activity
25631 // this also applies if the minimum recording length has not been hit yet
25632 // so that we don't send data until we know the recording will be long enough
25633 this.batcher.stop();
25634 } else {
25635 this.batcher.start();
25636 }
25637
25638 var resetIdleTimeout = function () {
25639 clearTimeout(this.idleTimeoutId);
25640 var idleTimeoutMs = this.getConfig('record_idle_timeout_ms');
25641 this.idleTimeoutId = setTimeout(this._onIdleTimeout, idleTimeoutMs);
25642 this.idleExpires = new Date().getTime() + idleTimeoutMs;
25643 }.bind(this);
25644 resetIdleTimeout();
25645
25646 var blockSelector = this.getConfig('record_block_selector');
25647 if (blockSelector === '' || blockSelector === null) {
25648 blockSelector = undefined;
25649 }
25650
25651 try {
25652 this._stopRecording = this._rrwebRecord({
25653 'emit': function (ev) {
25654 if (this.idleExpires && this.idleExpires < ev.timestamp) {
25655 this._onIdleTimeout();
25656 return;
25657 }
25658 if (isUserEvent(ev)) {
25659 if (this.batcher.stopped && new Date().getTime() - this.replayStartTime >= this.recordMinMs) {
25660 // start flushing again after user activity
25661 this.batcher.start();
25662 }
25663 resetIdleTimeout();
25664 }
25665 // promise only used to await during tests
25666 this.__enqueuePromise = this.batcher.enqueue(ev);
25667 }.bind(this),
25668 'blockClass': this.getConfig('record_block_class'),
25669 'blockSelector': blockSelector,
25670 'collectFonts': this.getConfig('record_collect_fonts'),
25671 'dataURLOptions': { // canvas image options (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL)
25672 'type': 'image/webp',
25673 'quality': 0.6
25674 },
25675 'maskAllInputs': true,
25676 'maskTextClass': this.getConfig('record_mask_text_class'),
25677 'maskTextSelector': this.getConfig('record_mask_text_selector'),
25678 'recordCanvas': this.getConfig('record_canvas'),
25679 'sampling': {
25680 'canvas': 15
25681 }
25682 });
25683 } catch (err) {
25684 this.reportError('Unexpected error when starting rrweb recording.', err);
25685 }
25686
25687 if (typeof this._stopRecording !== 'function') {
25688 this.reportError('rrweb failed to start, skipping this recording.');
25689 this._stopRecording = null;
25690 this.stopRecording(); // stop batcher looping and any timeouts
25691 return;
25692 }
25693
25694 var maxTimeoutMs = this.maxExpires - new Date().getTime();
25695 this.maxTimeoutId = setTimeout(this._onMaxLengthReached.bind(this), maxTimeoutMs);
25696 };
25697
25698 SessionRecording.prototype.stopRecording = function (skipFlush) {
25699 // store the user ID info in case this is getting called in mixpanel.reset()
25700 this.finalFlushUserIdInfo = this.getUserIdInfo();
25701
25702 if (!this.isRrwebStopped()) {
25703 try {
25704 this._stopRecording();
25705 } catch (err) {
25706 this.reportError('Error with rrweb stopRecording', err);
25707 }
25708 this._stopRecording = null;
25709 }
25710
25711 var flushPromise;
25712 if (this.batcher.stopped) {
25713 // never got user activity to flush after reset, so just clear the batcher
25714 flushPromise = this.batcher.clear();
25715 } else if (!skipFlush) {
25716 // flush any remaining events from running batcher
25717 flushPromise = this.batcher.flush();
25718 }
25719 this.batcher.stop();
25720
25721 clearTimeout(this.idleTimeoutId);
25722 clearTimeout(this.maxTimeoutId);
25723 return flushPromise;
25724 };
25725
25726 SessionRecording.prototype.isRrwebStopped = function () {
25727 return this._stopRecording === null;
25728 };
25729
25730
25731 /**
25732 * Flushes the current batch of events to the server, but passes an opt-out callback to make sure
25733 * we stop recording and dump any queued events if the user has opted out.
25734 */
25735 SessionRecording.prototype.flushEventsWithOptOut = function (data, options, cb) {
25736 var onOptOut = function (code) {
25737 // addOptOutCheckMixpanelLib invokes this function with code=0 when the user has opted out
25738 if (code === 0) {
25739 this.stopRecording();
25740 cb({error: 'Tracking has been opted out, stopping recording.'});
25741 }
25742 }.bind(this);
25743
25744 this._flushEvents(data, options, cb, onOptOut);
25745 };
25746
25747 /**
25748 * @returns {SerializedRecording}
25749 */
25750 SessionRecording.prototype.serialize = function () {
25751 // don't break if mixpanel instance was destroyed at some point
25752 var tabId;
25753 try {
25754 tabId = this._mixpanel.get_tab_id();
25755 } catch (e) {
25756 this.reportError('Error getting tab ID for serialization ', e);
25757 tabId = null;
25758 }
25759
25760 return {
25761 'replayId': this.replayId,
25762 'seqNo': this.seqNo,
25763 'replayStartTime': this.replayStartTime,
25764 'batchStartUrl': this.batchStartUrl,
25765 'replayStartUrl': this.replayStartUrl,
25766 'idleExpires': this.idleExpires,
25767 'maxExpires': this.maxExpires,
25768 'tabId': tabId,
25769 };
25770 };
25771
25772
25773 /**
25774 * @static
25775 * @param {SerializedRecording} serializedRecording
25776 * @param {SessionRecordingOptions} options
25777 * @returns {SessionRecording}
25778 */
25779 SessionRecording.deserialize = function (serializedRecording, options) {
25780 var recording = new SessionRecording(_.extend({}, options, {
25781 replayId: serializedRecording['replayId'],
25782 batchStartUrl: serializedRecording['batchStartUrl'],
25783 replayStartUrl: serializedRecording['replayStartUrl'],
25784 idleExpires: serializedRecording['idleExpires'],
25785 maxExpires: serializedRecording['maxExpires'],
25786 replayStartTime: serializedRecording['replayStartTime'],
25787 seqNo: serializedRecording['seqNo'],
25788 sharedLockStorage: options.sharedLockStorage,
25789 }));
25790
25791 return recording;
25792 };
25793
25794 SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, reqBody, callback) {
25795 var onSuccess = function (response, responseBody) {
25796 // Update batch specific props only if the request was successful to guarantee ordering.
25797 // RequestBatcher will always flush the next batch after the previous one succeeds.
25798 // extra check to see if the replay ID has changed so that we don't increment the seqNo on the wrong replay
25799 if (response.status === 200 && this.replayId === currentReplayId) {
25800 this.seqNo++;
25801 this.batchStartUrl = _.info.currentUrl();
25802 }
25803
25804 this._onBatchSent();
25805 callback({
25806 status: 0,
25807 httpStatusCode: response.status,
25808 responseBody: responseBody,
25809 retryAfter: response.headers.get('Retry-After')
25810 });
25811 }.bind(this);
25812 var apiHost = (this._mixpanel.get_api_host && this._mixpanel.get_api_host('record')) || this.getConfig('api_host');
25813 win['fetch'](apiHost + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
25814 'method': 'POST',
25815 'headers': {
25816 'Authorization': 'Basic ' + btoa(this.getConfig('token') + ':'),
25817 'Content-Type': 'application/octet-stream'
25818 },
25819 'body': reqBody,
25820 }).then(function (response) {
25821 response.json().then(function (responseBody) {
25822 onSuccess(response, responseBody);
25823 }).catch(function (error) {
25824 callback({error: error});
25825 });
25826 }).catch(function (error) {
25827 callback({error: error, httpStatusCode: 0});
25828 });
25829 };
25830
25831 SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (data, options, callback) {
25832 var numEvents = data.length;
25833
25834 if (numEvents > 0) {
25835 var replayId = this.replayId;
25836
25837 // each rrweb event has a timestamp - leverage those to get time properties
25838 var batchStartTime = Infinity;
25839 var batchEndTime = -Infinity;
25840 var hasFullSnapshot = false;
25841 for (var i = 0; i < numEvents; i++) {
25842 batchStartTime = Math.min(batchStartTime, data[i].timestamp);
25843 batchEndTime = Math.max(batchEndTime, data[i].timestamp);
25844 if (data[i].type === EventType.FullSnapshot) {
25845 hasFullSnapshot = true;
25846 }
25847 }
25848
25849 if (this.seqNo === 0) {
25850 if (!hasFullSnapshot) {
25851 callback({error: 'First batch does not contain a full snapshot. Aborting recording.'});
25852 this.stopRecording(true);
25853 return;
25854 }
25855 this.replayStartTime = batchStartTime;
25856 } else if (!this.replayStartTime) {
25857 this.reportError('Replay start time not set but seqNo is not 0. Using current batch start time as a fallback.');
25858 this.replayStartTime = batchStartTime;
25859 }
25860
25861 var replayLengthMs = batchEndTime - this.replayStartTime;
25862
25863 var reqParams = {
25864 '$current_url': this.batchStartUrl,
25865 '$lib_version': Config.LIB_VERSION,
25866 'batch_start_time': batchStartTime / 1000,
25867 'mp_lib': 'web',
25868 'replay_id': replayId,
25869 'replay_length_ms': replayLengthMs,
25870 'replay_start_time': this.replayStartTime / 1000,
25871 'replay_start_url': this.replayStartUrl,
25872 'seq': this.seqNo
25873 };
25874 var eventsJson = JSON.stringify(data);
25875 Object.assign(reqParams, this.getUserIdInfo());
25876
25877 if (CompressionStream) {
25878 var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
25879 var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
25880 new Response(gzipStream)
25881 .blob()
25882 .then(function(compressedBlob) {
25883 reqParams['format'] = 'gzip';
25884 this._sendRequest(replayId, reqParams, compressedBlob, callback);
25885 }.bind(this));
25886 } else {
25887 reqParams['format'] = 'body';
25888 this._sendRequest(replayId, reqParams, eventsJson, callback);
25889 }
25890 }
25891 });
25892
25893
25894 SessionRecording.prototype.reportError = function(msg, err) {
25895 logger$3.error.apply(logger$3.error, arguments);
25896 try {
25897 if (!err && !(msg instanceof Error)) {
25898 msg = new Error(msg);
25899 }
25900 this.getConfig('error_reporter')(msg, err);
25901 } catch(err) {
25902 logger$3.error(err);
25903 }
25904 };
25905
25906 /**
25907 * Module for handling the storage and retrieval of recording metadata as well as any active recordings.
25908 * Makes sure that only one tab can be recording at a time.
25909 */
25910 var RecordingRegistry = function (options) {
25911 /** @type {IDBStorageWrapper} */
25912 this.idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
25913 this.errorReporter = options.errorReporter;
25914 this.mixpanelInstance = options.mixpanelInstance;
25915 this.sharedLockStorage = options.sharedLockStorage;
25916 };
25917
25918 RecordingRegistry.prototype.isPersistenceEnabled = function() {
25919 return !this.mixpanelInstance.get_config('disable_persistence');
25920 };
25921
25922 RecordingRegistry.prototype.handleError = function (err) {
25923 this.errorReporter('IndexedDB error: ', err);
25924 };
25925
25926 /**
25927 * @param {import('./session-recording').SerializedRecording} serializedRecording
25928 */
25929 RecordingRegistry.prototype.setActiveRecording = function (serializedRecording) {
25930 if (!this.isPersistenceEnabled()) {
25931 return PromisePolyfill.resolve();
25932 }
25933
25934 var tabId = serializedRecording['tabId'];
25935 if (!tabId) {
25936 console.warn('No tab ID is set, cannot persist recording metadata.');
25937 return PromisePolyfill.resolve();
25938 }
25939
25940 return this.idb.init()
25941 .then(function () {
25942 return this.idb.setItem(tabId, serializedRecording);
25943 }.bind(this))
25944 .catch(this.handleError.bind(this));
25945 };
25946
25947 /**
25948 * @returns {Promise<import('./session-recording').SerializedRecording>}
25949 */
25950 RecordingRegistry.prototype.getActiveRecording = function () {
25951 if (!this.isPersistenceEnabled()) {
25952 return PromisePolyfill.resolve(null);
25953 }
25954
25955 return this.idb.init()
25956 .then(function () {
25957 return this.idb.getItem(this.mixpanelInstance.get_tab_id());
25958 }.bind(this))
25959 .then(function (serializedRecording) {
25960 return isRecordingExpired(serializedRecording) ? null : serializedRecording;
25961 }.bind(this))
25962 .catch(this.handleError.bind(this));
25963 };
25964
25965 RecordingRegistry.prototype.clearActiveRecording = function () {
25966 if (this.isPersistenceEnabled()) {
25967 // mark recording as expired instead of deleting it in case the page unloads mid-flush and doesn't make it to ingestion.
25968 // this will ensure the next pageload will flush the remaining events, but not try to continue the recording.
25969 return this.markActiveRecordingExpired();
25970 } else {
25971 return this.deleteActiveRecording();
25972 }
25973 };
25974
25975 RecordingRegistry.prototype.markActiveRecordingExpired = function () {
25976 return this.getActiveRecording()
25977 .then(function (serializedRecording) {
25978 if (serializedRecording) {
25979 serializedRecording['maxExpires'] = 0;
25980 return this.setActiveRecording(serializedRecording);
25981 }
25982 }.bind(this))
25983 .catch(this.handleError.bind(this));
25984 };
25985
25986 RecordingRegistry.prototype.deleteActiveRecording = function () {
25987 // avoid initializing IDB if this registry instance hasn't already written a recording
25988 if (this.idb.isInitialized()) {
25989 return this.idb.removeItem(this.mixpanelInstance.get_tab_id())
25990 .catch(this.handleError.bind(this));
25991 } else {
25992 return PromisePolyfill.resolve();
25993 }
25994 };
25995
25996 /**
25997 * Flush any inactive recordings from the registry to minimize data loss.
25998 * The main idea here is that we can flush remaining rrweb events on the next page load if a tab is closed mid-batch.
25999 */
26000 RecordingRegistry.prototype.flushInactiveRecordings = function () {
26001 if (!this.isPersistenceEnabled()) {
26002 return PromisePolyfill.resolve([]);
26003 }
26004
26005 return this.idb.init()
26006 .then(function() {
26007 return this.idb.getAll();
26008 }.bind(this))
26009 .then(function (serializedRecordings) {
26010 // clean up any expired recordings from the registry, non-expired ones may be active in other tabs
26011 var unloadPromises = serializedRecordings
26012 .filter(function (serializedRecording) {
26013 return isRecordingExpired(serializedRecording);
26014 })
26015 .map(function (serializedRecording) {
26016 var sessionRecording = SessionRecording.deserialize(serializedRecording, {
26017 mixpanelInstance: this.mixpanelInstance,
26018 sharedLockStorage: this.sharedLockStorage
26019 });
26020 return sessionRecording.unloadPersistedData()
26021 .then(function () {
26022 // expired recording was successfully flushed, we can clean it up from the registry
26023 return this.idb.removeItem(serializedRecording['tabId']);
26024 }.bind(this))
26025 .catch(this.handleError.bind(this));
26026 }.bind(this));
26027
26028 return PromisePolyfill.all(unloadPromises);
26029 }.bind(this))
26030 .catch(this.handleError.bind(this));
26031 };
26032
26033 var logger$2 = console_with_prefix('recorder');
26034
26035 /**
26036 * Recorder API: bundles rrweb and and exposes methods to start and stop recordings.
26037 * @param {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
26038 */
26039 var MixpanelRecorder = function(mixpanelInstance, rrwebRecord, sharedLockStorage) {
26040 this.mixpanelInstance = mixpanelInstance;
26041 this.rrwebRecord = rrwebRecord || record;
26042 this.sharedLockStorage = sharedLockStorage;
26043
26044 /**
26045 * @member {import('./registry').RecordingRegistry}
26046 */
26047 this.recordingRegistry = new RecordingRegistry({
26048 mixpanelInstance: this.mixpanelInstance,
26049 errorReporter: logger$2.error,
26050 sharedLockStorage: sharedLockStorage
26051 });
26052 this._flushInactivePromise = this.recordingRegistry.flushInactiveRecordings();
26053
26054 this.activeRecording = null;
26055 this.stopRecordingInProgress = false;
26056 };
26057
26058 MixpanelRecorder.prototype.startRecording = function(options) {
26059 options = options || {};
26060 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26061 logger$2.log('Recording already in progress, skipping startRecording.');
26062 return;
26063 }
26064
26065 var onIdleTimeout = function () {
26066 logger$2.log('Idle timeout reached, restarting recording.');
26067 this.resetRecording();
26068 }.bind(this);
26069
26070 var onMaxLengthReached = function () {
26071 logger$2.log('Max recording length reached, stopping recording.');
26072 this.resetRecording();
26073 }.bind(this);
26074
26075 var onBatchSent = function () {
26076 this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26077 this['__flushPromise'] = this.activeRecording.batcher._flushPromise;
26078 }.bind(this);
26079
26080 /**
26081 * @type {import('./session-recording').SessionRecordingOptions}
26082 */
26083 var sessionRecordingOptions = {
26084 mixpanelInstance: this.mixpanelInstance,
26085 onBatchSent: onBatchSent,
26086 onIdleTimeout: onIdleTimeout,
26087 onMaxLengthReached: onMaxLengthReached,
26088 replayId: _.UUID(),
26089 rrwebRecord: this.rrwebRecord,
26090 sharedLockStorage: this.sharedLockStorage
26091 };
26092
26093 if (options.activeSerializedRecording) {
26094 this.activeRecording = SessionRecording.deserialize(options.activeSerializedRecording, sessionRecordingOptions);
26095 } else {
26096 this.activeRecording = new SessionRecording(sessionRecordingOptions);
26097 }
26098
26099 this.activeRecording.startRecording(options.shouldStopBatcher);
26100 return this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26101 };
26102
26103 MixpanelRecorder.prototype.stopRecording = function() {
26104 // Prevents activeSerializedRecording from being reused when stopping the recording.
26105 this.stopRecordingInProgress = true;
26106 return this._stopCurrentRecording(false, true).then(function() {
26107 return this.recordingRegistry.clearActiveRecording();
26108 }.bind(this)).then(function() {
26109 this.stopRecordingInProgress = false;
26110 }.bind(this));
26111 };
26112
26113 MixpanelRecorder.prototype.pauseRecording = function() {
26114 return this._stopCurrentRecording(false);
26115 };
26116
26117 MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush, disableActiveRecording) {
26118 if (this.activeRecording) {
26119 var stopRecordingPromise = this.activeRecording.stopRecording(skipFlush);
26120 if (disableActiveRecording) {
26121 this.activeRecording = null;
26122 }
26123 return stopRecordingPromise;
26124 }
26125 return PromisePolyfill.resolve();
26126 };
26127
26128 MixpanelRecorder.prototype.resumeRecording = function (startNewIfInactive) {
26129 if (this.activeRecording && this.activeRecording.isRrwebStopped()) {
26130 this.activeRecording.startRecording(false);
26131 return PromisePolyfill.resolve(null);
26132 }
26133
26134 return this.recordingRegistry.getActiveRecording()
26135 .then(function (activeSerializedRecording) {
26136 if (activeSerializedRecording && !this.stopRecordingInProgress) {
26137 return this.startRecording({activeSerializedRecording: activeSerializedRecording});
26138 } else if (startNewIfInactive) {
26139 return this.startRecording({shouldStopBatcher: false});
26140 } else {
26141 logger$2.log('No resumable recording found.');
26142 return null;
26143 }
26144 }.bind(this));
26145 };
26146
26147
26148 MixpanelRecorder.prototype.resetRecording = function () {
26149 this.stopRecording();
26150 this.startRecording({shouldStopBatcher: true});
26151 };
26152
26153 MixpanelRecorder.prototype.getActiveReplayId = function () {
26154 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26155 return this.activeRecording.replayId;
26156 } else {
26157 return null;
26158 }
26159 };
26160
26161 // getter so that older mixpanel-core versions can still retrieve the replay ID
26162 // when pulling the latest recorder bundle from the CDN
26163 Object.defineProperty(MixpanelRecorder.prototype, 'replayId', {
26164 get: function () {
26165 return this.getActiveReplayId();
26166 }
26167 });
26168
26169 win['__mp_recorder'] = MixpanelRecorder;
26170
26171 // stateless utils
26172 // mostly from https://github.com/mixpanel/mixpanel-js/blob/989ada50f518edab47b9c4fd9535f9fbd5ec5fc0/src/autotrack-utils.js
26173
26174
26175 var EV_CHANGE = 'change';
26176 var EV_CLICK = 'click';
26177 var EV_HASHCHANGE = 'hashchange';
26178 var EV_INPUT = 'input';
26179 var EV_LOAD = 'load';
26180 var EV_MP_LOCATION_CHANGE = 'mp_locationchange';
26181 var EV_POPSTATE = 'popstate';
26182 // TODO scrollend isn't available in Safari: document or polyfill?
26183 var EV_SCROLLEND = 'scrollend';
26184 var EV_SCROLL = 'scroll';
26185 var EV_SELECT = 'select';
26186 var EV_SUBMIT = 'submit';
26187 var EV_TOGGLE = 'toggle';
26188 var EV_VISIBILITYCHANGE = 'visibilitychange';
26189
26190 var CLICK_EVENT_PROPS = [
26191 'clientX', 'clientY',
26192 'offsetX', 'offsetY',
26193 'pageX', 'pageY',
26194 'screenX', 'screenY',
26195 'x', 'y'
26196 ];
26197 var OPT_IN_CLASSES = ['mp-include'];
26198 var OPT_OUT_CLASSES = ['mp-no-track'];
26199 var SENSITIVE_DATA_CLASSES = OPT_OUT_CLASSES.concat(['mp-sensitive']);
26200 var TRACKED_ATTRS = [
26201 'aria-label', 'aria-labelledby', 'aria-describedby',
26202 'href', 'name', 'role', 'title', 'type'
26203 ];
26204
26205 var INTERACTIVE_ARIA_ROLES = {
26206 'button': true,
26207 'checkbox': true,
26208 'combobox': true,
26209 'grid': true,
26210 'link': true,
26211 'listbox': true,
26212 'menu': true,
26213 'menubar': true,
26214 'menuitem': true,
26215 'menuitemcheckbox': true,
26216 'menuitemradio': true,
26217 'navigation': true,
26218 'option': true,
26219 'radio': true,
26220 'radiogroup': true,
26221 'searchbox': true,
26222 'slider': true,
26223 'spinbutton': true,
26224 'switch': true,
26225 'tab': true,
26226 'tablist': true,
26227 'textbox': true,
26228 'tree': true,
26229 'treegrid': true,
26230 'treeitem': true
26231 };
26232
26233 var ALWAYS_NON_INTERACTIVE_TAGS = {
26234 // Document metadata
26235 'base': true,
26236 'head': true,
26237 'html': true,
26238 'link': true,
26239 'meta': true,
26240 'script': true,
26241 'style': true,
26242 'title': true,
26243 // Text formatting
26244 'br': true,
26245 'hr': true,
26246 'wbr': true,
26247 // Other
26248 'noscript': true,
26249 'picture': true,
26250 'source': true,
26251 'template': true,
26252 'track': true
26253 };
26254
26255 // Common container tags that need additional checks
26256 var TEXT_CONTAINER_TAGS = {
26257 'article': true,
26258 'div': true,
26259 'h1': true,
26260 'h2': true,
26261 'h3': true,
26262 'h4': true,
26263 'h5': true,
26264 'h6': true,
26265 'p': true,
26266 'section': true,
26267 'span': true
26268 };
26269
26270 var EVENT_HANDLER_ATTRIBUTES = [
26271 'onclick', 'onmousedown', 'onmouseup', 'onpointerdown', 'onpointerup', 'ontouchend', 'ontouchstart'
26272 ];
26273
26274 var MAX_DEPTH = 5;
26275
26276 var logger$1 = console_with_prefix('autocapture');
26277
26278
26279 function getClasses(el) {
26280 var classes = {};
26281 var classList = getClassName(el).split(' ');
26282 for (var i = 0; i < classList.length; i++) {
26283 var cls = classList[i];
26284 if (cls) {
26285 classes[cls] = true;
26286 }
26287 }
26288 return classes;
26289 }
26290
26291 /*
26292 * Get the className of an element, accounting for edge cases where element.className is an object
26293 * @param {Element} el - element to get the className of
26294 * @returns {string} the element's class
26295 */
26296 function getClassName(el) {
26297 switch(typeof el.className) {
26298 case 'string':
26299 return el.className;
26300 case 'object': // handle cases where className might be SVGAnimatedString or some other type
26301 return el.className.baseVal || el.getAttribute('class') || '';
26302 default: // future proof
26303 return '';
26304 }
26305 }
26306
26307 function getPreviousElementSibling(el) {
26308 if (el.previousElementSibling) {
26309 return el.previousElementSibling;
26310 } else {
26311 do {
26312 el = el.previousSibling;
26313 } while (el && !isElementNode(el));
26314 return el;
26315 }
26316 }
26317
26318 function getPropertiesFromElement(el, ev, blockAttrsSet, extraAttrs, allowElementCallback, allowSelectors) {
26319 var props = {
26320 '$classes': getClassName(el).split(' '),
26321 '$tag_name': el.tagName.toLowerCase()
26322 };
26323 var elId = el.id;
26324 if (elId) {
26325 props['$id'] = elId;
26326 }
26327
26328 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors)) {
26329 _.each(TRACKED_ATTRS.concat(extraAttrs), function(attr) {
26330 if (el.hasAttribute(attr) && !blockAttrsSet[attr]) {
26331 var attrVal = el.getAttribute(attr);
26332 if (shouldTrackValue(attrVal)) {
26333 props['$attr-' + attr] = attrVal;
26334 }
26335 }
26336 });
26337 }
26338
26339 var nthChild = 1;
26340 var nthOfType = 1;
26341 var currentElem = el;
26342 while (currentElem = getPreviousElementSibling(currentElem)) { // eslint-disable-line no-cond-assign
26343 nthChild++;
26344 if (currentElem.tagName === el.tagName) {
26345 nthOfType++;
26346 }
26347 }
26348 props['$nth_child'] = nthChild;
26349 props['$nth_of_type'] = nthOfType;
26350
26351 return props;
26352 }
26353
26354 function getPropsForDOMEvent(ev, config) {
26355 var allowElementCallback = config.allowElementCallback;
26356 var allowSelectors = config.allowSelectors || [];
26357 var blockAttrs = config.blockAttrs || [];
26358 var blockElementCallback = config.blockElementCallback;
26359 var blockSelectors = config.blockSelectors || [];
26360 var captureTextContent = config.captureTextContent || false;
26361 var captureExtraAttrs = config.captureExtraAttrs || [];
26362 var capturedForHeatMap = config.capturedForHeatMap || false;
26363
26364 // convert array to set every time, as the config may have changed
26365 var blockAttrsSet = {};
26366 _.each(blockAttrs, function(attr) {
26367 blockAttrsSet[attr] = true;
26368 });
26369
26370 var props = null;
26371
26372 var target = typeof ev.target === 'undefined' ? ev.srcElement : ev.target;
26373 if (isTextNode(target)) { // defeat Safari bug (see: http://www.quirksmode.org/js/events_properties.html)
26374 target = target.parentNode;
26375 }
26376
26377 if (
26378 shouldTrackDomEvent(target, ev) &&
26379 isElementAllowed(target, ev, allowElementCallback, allowSelectors) &&
26380 !isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26381 ) {
26382 var targetElementList = [target];
26383 var curEl = target;
26384 while (curEl.parentNode && !isTag(curEl, 'body')) {
26385 targetElementList.push(curEl.parentNode);
26386 curEl = curEl.parentNode;
26387 }
26388
26389 var elementsJson = [];
26390 var href, explicitNoTrack = false;
26391 _.each(targetElementList, function(el) {
26392 var shouldTrackDetails = shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors);
26393
26394 // if the element or a parent element is an anchor tag
26395 // include the href as a property
26396 if (!blockAttrsSet['href'] && el.tagName.toLowerCase() === 'a') {
26397 href = el.getAttribute('href');
26398 href = shouldTrackDetails && shouldTrackValue(href) && href;
26399 }
26400
26401 if (isElementBlocked(el, ev, blockElementCallback, blockSelectors)) {
26402 explicitNoTrack = true;
26403 }
26404
26405 elementsJson.push(getPropertiesFromElement(el, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors));
26406 }, this);
26407
26408 if (!explicitNoTrack) {
26409 var docElement = document$1['documentElement'];
26410 props = {
26411 '$event_type': ev.type,
26412 '$host': win.location.host,
26413 '$pathname': win.location.pathname,
26414 '$elements': elementsJson,
26415 '$el_attr__href': href,
26416 '$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
26417 '$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0),
26418 '$pageHeight': document$1['body']['offsetHeight'] || 0,
26419 '$pageWidth': document$1['body']['offsetWidth'] || 0,
26420 };
26421 _.each(captureExtraAttrs, function(attr) {
26422 if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
26423 var attrVal = target.getAttribute(attr);
26424 if (shouldTrackValue(attrVal)) {
26425 props['$el_attr__' + attr] = attrVal;
26426 }
26427 }
26428 });
26429
26430 if (captureTextContent) {
26431 elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26432 if (elementText && elementText.length) {
26433 props['$el_text'] = elementText;
26434 }
26435 }
26436
26437 if (ev.type === EV_CLICK) {
26438 _.each(CLICK_EVENT_PROPS, function(prop) {
26439 if (prop in ev) {
26440 props['$' + prop] = ev[prop];
26441 }
26442 });
26443 if (capturedForHeatMap) {
26444 props['$captured_for_heatmap'] = true;
26445 }
26446 target = guessRealClickTarget(ev);
26447 }
26448 // prioritize text content from "real" click target if different from original target
26449 if (captureTextContent) {
26450 var elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26451 if (elementText && elementText.length) {
26452 props['$el_text'] = elementText;
26453 }
26454 }
26455
26456 if (target) {
26457 // target may have been recalculated; check allowlists and blocklists again
26458 if (
26459 !isElementAllowed(target, ev, allowElementCallback, allowSelectors) ||
26460 isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26461 ) {
26462 return null;
26463 }
26464
26465 var targetProps = getPropertiesFromElement(target, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors);
26466 props['$target'] = targetProps;
26467 // pull up more props onto main event props
26468 props['$el_classes'] = targetProps['$classes'];
26469 _.extend(props, _.strip_empty_properties({
26470 '$el_id': targetProps['$id'],
26471 '$el_tag_name': targetProps['$tag_name']
26472 }));
26473 }
26474 }
26475 }
26476
26477 return props;
26478 }
26479
26480
26481 /**
26482 * Get the direct text content of an element, protecting against sensitive data collection.
26483 * Concats textContent of each of the element's text node children; this avoids potential
26484 * collection of sensitive data that could happen if we used element.textContent and the
26485 * element had sensitive child elements, since element.textContent includes child content.
26486 * Scrubs values that look like they could be sensitive (i.e. cc or ssn number).
26487 * @param {Element} el - element to get the text of
26488 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
26489 * @returns {string} the element's direct text content
26490 */
26491 function getSafeText(el, ev, allowElementCallback, allowSelectors) {
26492 var elText = '';
26493
26494 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) && el.childNodes && el.childNodes.length) {
26495 _.each(el.childNodes, function(child) {
26496 if (isTextNode(child) && child.textContent) {
26497 elText += _.trim(child.textContent)
26498 // scrub potentially sensitive values
26499 .split(/(\s+)/).filter(shouldTrackValue).join('')
26500 // normalize whitespace
26501 .replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ')
26502 // truncate
26503 .substring(0, 255);
26504 }
26505 });
26506 }
26507
26508 return _.trim(elText);
26509 }
26510
26511 function guessRealClickTarget(ev) {
26512 var target = ev.target;
26513 var composedPath = ev['composedPath']();
26514 for (var i = 0; i < composedPath.length; i++) {
26515 var node = composedPath[i];
26516 if (
26517 isTag(node, 'a') ||
26518 isTag(node, 'button') ||
26519 isTag(node, 'input') ||
26520 isTag(node, 'select') ||
26521 (node.getAttribute && node.getAttribute('role') === 'button')
26522 ) {
26523 target = node;
26524 break;
26525 }
26526 if (node === target) {
26527 break;
26528 }
26529 }
26530 return target;
26531 }
26532
26533 function isElementAllowed(el, ev, allowElementCallback, allowSelectors) {
26534 if (allowElementCallback) {
26535 try {
26536 if (!allowElementCallback(el, ev)) {
26537 return false;
26538 }
26539 } catch (err) {
26540 logger$1.critical('Error while checking element in allowElementCallback', err);
26541 return false;
26542 }
26543 }
26544
26545 if (!allowSelectors.length) {
26546 // no allowlist; all elements are fair game
26547 return true;
26548 }
26549
26550 for (var i = 0; i < allowSelectors.length; i++) {
26551 var sel = allowSelectors[i];
26552 try {
26553 if (el['matches'](sel)) {
26554 return true;
26555 }
26556 } catch (err) {
26557 logger$1.critical('Error while checking selector: ' + sel, err);
26558 }
26559 }
26560 return false;
26561 }
26562
26563 function isElementBlocked(el, ev, blockElementCallback, blockSelectors) {
26564 var i;
26565
26566 if (blockElementCallback) {
26567 try {
26568 if (blockElementCallback(el, ev)) {
26569 return true;
26570 }
26571 } catch (err) {
26572 logger$1.critical('Error while checking element in blockElementCallback', err);
26573 return true;
26574 }
26575 }
26576
26577 if (blockSelectors && blockSelectors.length) {
26578 // programmatically prevent tracking of elements that match CSS selectors
26579 for (i = 0; i < blockSelectors.length; i++) {
26580 var sel = blockSelectors[i];
26581 try {
26582 if (el['matches'](sel)) {
26583 return true;
26584 }
26585 } catch (err) {
26586 logger$1.critical('Error while checking selector: ' + sel, err);
26587 }
26588 }
26589 }
26590
26591 // allow users to programmatically prevent tracking of elements by adding default classes such as 'mp-no-track'
26592 var classes = getClasses(el);
26593 for (i = 0; i < OPT_OUT_CLASSES.length; i++) {
26594 if (classes[OPT_OUT_CLASSES[i]]) {
26595 return true;
26596 }
26597 }
26598
26599 return false;
26600 }
26601
26602 /*
26603 * Check whether a DOM node has nodeType Node.ELEMENT_NODE
26604 * @param {Node} node - node to check
26605 * @returns {boolean} whether node is of the correct nodeType
26606 */
26607 function isElementNode(node) {
26608 return node && node.nodeType === 1; // Node.ELEMENT_NODE - use integer constant for browser portability
26609 }
26610
26611 /*
26612 * Check whether an element is of a given tag type.
26613 * Due to potential reference discrepancies (such as the webcomponents.js polyfill),
26614 * we want to match tagNames instead of specific references because something like
26615 * element === document.body won't always work because element might not be a native
26616 * element.
26617 * @param {Element} el - element to check
26618 * @param {string} tag - tag name (e.g., "div")
26619 * @returns {boolean} whether el is of the given tag type
26620 */
26621 function isTag(el, tag) {
26622 return el && el.tagName && el.tagName.toLowerCase() === tag.toLowerCase();
26623 }
26624
26625 /*
26626 * Check whether a DOM node is a TEXT_NODE
26627 * @param {Node} node - node to check
26628 * @returns {boolean} whether node is of type Node.TEXT_NODE
26629 */
26630 function isTextNode(node) {
26631 return node && node.nodeType === 3; // Node.TEXT_NODE - use integer constant for browser portability
26632 }
26633
26634 function minDOMApisSupported() {
26635 try {
26636 var testEl = document$1.createElement('div');
26637 return !!testEl['matches'];
26638 } catch (err) {
26639 return false;
26640 }
26641 }
26642
26643 function weakSetSupported() {
26644 return typeof WeakSet !== 'undefined';
26645 }
26646
26647 /*
26648 * Check whether a DOM event should be "tracked" or if it may contain sensitive data
26649 * using a variety of heuristics.
26650 * @param {Element} el - element to check
26651 * @param {Event} ev - event to check
26652 * @returns {boolean} whether the event should be tracked
26653 */
26654 function shouldTrackDomEvent(el, ev) {
26655 if (!el || isTag(el, 'html') || !isElementNode(el)) {
26656 return false;
26657 }
26658 var tag = el.tagName.toLowerCase();
26659 switch (tag) {
26660 case 'form':
26661 return ev.type === EV_SUBMIT;
26662 case 'input':
26663 if (['button', 'submit'].indexOf(el.getAttribute('type')) === -1) {
26664 return ev.type === EV_CHANGE;
26665 } else {
26666 return ev.type === EV_CLICK;
26667 }
26668 case 'select':
26669 case 'textarea':
26670 return ev.type === EV_CHANGE;
26671 default:
26672 return ev.type === EV_CLICK;
26673 }
26674 }
26675
26676 /*
26677 * Check whether a DOM element should be "tracked" or if it may contain sensitive data
26678 * using a variety of heuristics.
26679 * @param {Element} el - element to check
26680 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
26681 * @returns {boolean} whether the element should be tracked
26682 */
26683 function shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) {
26684 var i;
26685
26686 if (!isElementAllowed(el, ev, allowElementCallback, allowSelectors)) {
26687 return false;
26688 }
26689
26690 for (var curEl = el; curEl.parentNode && !isTag(curEl, 'body'); curEl = curEl.parentNode) {
26691 var classes = getClasses(curEl);
26692 for (i = 0; i < SENSITIVE_DATA_CLASSES.length; i++) {
26693 if (classes[SENSITIVE_DATA_CLASSES[i]]) {
26694 return false;
26695 }
26696 }
26697 }
26698
26699 var elClasses = getClasses(el);
26700 for (i = 0; i < OPT_IN_CLASSES.length; i++) {
26701 if (elClasses[OPT_IN_CLASSES[i]]) {
26702 return true;
26703 }
26704 }
26705
26706 // don't send data from inputs or similar elements since there will always be
26707 // a risk of clientside javascript placing sensitive data in attributes
26708 if (
26709 isTag(el, 'input') ||
26710 isTag(el, 'select') ||
26711 isTag(el, 'textarea') ||
26712 el.getAttribute('contenteditable') === 'true'
26713 ) {
26714 return false;
26715 }
26716
26717 // don't include hidden or password fields
26718 var type = el.type || '';
26719 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"]
26720 switch(type.toLowerCase()) {
26721 case 'hidden':
26722 return false;
26723 case 'password':
26724 return false;
26725 }
26726 }
26727
26728 // filter out data from fields that look like sensitive fields
26729 var name = el.name || el.id || '';
26730 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"]
26731 var sensitiveNameRegex = /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i;
26732 if (sensitiveNameRegex.test(name.replace(/[^a-zA-Z0-9]/g, ''))) {
26733 return false;
26734 }
26735 }
26736
26737 return true;
26738 }
26739
26740
26741 /*
26742 * Check whether a string value should be "tracked" or if it may contain sensitive data
26743 * using a variety of heuristics.
26744 * @param {string} value - string value to check
26745 * @returns {boolean} whether the element should be tracked
26746 */
26747 function shouldTrackValue(value) {
26748 if (value === null || _.isUndefined(value)) {
26749 return false;
26750 }
26751
26752 if (typeof value === 'string') {
26753 value = _.trim(value);
26754
26755 // check to see if input value looks like a credit card number
26756 // see: https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch04s20.html
26757 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}))$/;
26758 if (ccRegex.test((value || '').replace(/[- ]/g, ''))) {
26759 return false;
26760 }
26761
26762 // check to see if input value looks like a social security number
26763 var ssnRegex = /(^\d{3}-?\d{2}-?\d{4}$)/;
26764 if (ssnRegex.test(value)) {
26765 return false;
26766 }
26767 }
26768
26769 return true;
26770 }
26771
26772 /**
26773 * Creates a cross-browser compatible scroll end function with appropriate event listener.
26774 * For browsers that support scrollend, returns the original function with scrollend event.
26775 * For browsers without scrollend support, returns a debounced function that triggers
26776 * 100ms after the last scroll event to simulate scrollend behavior.
26777 * @param {Function} originalFunction - The function to call when scrolling ends
26778 * @returns {Object} Object containing listener function and eventType string
26779 * @returns {Function} returns.listener - The wrapped function to use as event listener
26780 * @returns {string} returns.eventType - The event type to listen for ('scrollend' or 'scroll')
26781 */
26782 function getPolyfillScrollEndFunction(originalFunction) {
26783 var supportsScrollEnd = 'onscrollend' in win;
26784 var polyfillFunction = safewrap(originalFunction);
26785 var polyfillEvent = EV_SCROLLEND;
26786 if (!supportsScrollEnd) {
26787 // Polyfill for browsers without scrollend support: wait 100ms after the last scroll event
26788 // https://developer.chrome.com/blog/scrollend-a-new-javascript-event
26789 var scrollTimer = null;
26790 var scrollDelayMs = 100;
26791
26792 polyfillFunction = safewrap(function() {
26793 clearTimeout(scrollTimer);
26794 scrollTimer = setTimeout(originalFunction, scrollDelayMs);
26795 });
26796
26797 polyfillEvent = EV_SCROLL;
26798 }
26799
26800 return {
26801 listener: polyfillFunction,
26802 eventType: polyfillEvent
26803 };
26804 }
26805
26806 function hasInlineEventHandlers(element) {
26807 for (var i = 0; i < EVENT_HANDLER_ATTRIBUTES.length; i++) {
26808 if (element.hasAttribute(EVENT_HANDLER_ATTRIBUTES[i])) {
26809 return true;
26810 }
26811 }
26812 return false;
26813 }
26814
26815 function hasInteractiveAriaRole(element) {
26816 var role = element.getAttribute('role');
26817 if (!role) return false;
26818
26819 // Handle invalid markup where multiple roles might be specified
26820 // Only the first token is recognized per ARIA spec
26821 var primaryRole = role.trim().split(/\s+/)[0].toLowerCase();
26822
26823 return INTERACTIVE_ARIA_ROLES[primaryRole];
26824 }
26825
26826 function hasAnyInteractivityIndicators(element) {
26827 var tagName = element.tagName.toLowerCase();
26828
26829 // Check for interactive HTML elements
26830 if (tagName === 'button' ||
26831 tagName === 'input' ||
26832 tagName === 'select' ||
26833 tagName === 'textarea' ||
26834 tagName === 'details' ||
26835 tagName === 'dialog') {
26836 return true;
26837 }
26838
26839 if (element.isContentEditable) {
26840 return true;
26841 }
26842
26843 if (element.onclick || element.onmousedown || element.onmouseup || element.ontouchstart || element.ontouchend) {
26844 return true;
26845 }
26846
26847 if (hasInlineEventHandlers(element)) {
26848 return true;
26849 }
26850
26851 if (hasInteractiveAriaRole(element)) {
26852 return true;
26853 }
26854
26855 if (tagName === 'a' && element.hasAttribute('href')) {
26856 return true;
26857 }
26858
26859 if (element.hasAttribute('tabindex')) {
26860 return true;
26861 }
26862
26863 return false;
26864 }
26865
26866
26867 function isDefinitelyNonInteractive(element) {
26868 if (!element || !element.tagName) {
26869 return true;
26870 }
26871
26872 var tagName = element.tagName.toLowerCase();
26873
26874 // These tags are definitely non-interactive
26875 if (ALWAYS_NON_INTERACTIVE_TAGS[tagName]) {
26876 return true;
26877 }
26878
26879 // For all other elements, we can only be certain they're non-interactive if they lack ALL indicators of interactivity
26880 // Check for any signs of interactivity
26881 if (hasAnyInteractivityIndicators(element)) {
26882 return false;
26883 }
26884
26885 // Check parent chain for interactive context
26886 var parent = element.parentElement;
26887 var depth = 0;
26888
26889 while (parent && depth < MAX_DEPTH) {
26890 if (hasAnyInteractivityIndicators(parent)) {
26891 return false; // Element is inside an interactive parent
26892 }
26893
26894 if (parent.getRootNode && parent.getRootNode() !== document$1) {
26895 var root = parent.getRootNode();
26896 if (root.host && hasAnyInteractivityIndicators(root.host)) {
26897 return false; // Inside an interactive shadow host
26898 }
26899 }
26900
26901 parent = parent.parentElement;
26902 depth++;
26903 }
26904
26905 // Pure text containers without any interactive context
26906 if (TEXT_CONTAINER_TAGS[tagName]) {
26907 // These are non-interactive ONLY if they have no interactive indicators (already checked as part of hasAnyInteractivityIndicators)
26908 return true;
26909 }
26910
26911 // Default: we can't be certain it's non-interactive
26912 return false;
26913 }
26914
26915 /** @const */ var DEFAULT_RAGE_CLICK_THRESHOLD_PX = 30;
26916 /** @const */ var DEFAULT_RAGE_CLICK_TIMEOUT_MS = 1000;
26917 /** @const */ var DEFAULT_RAGE_CLICK_CLICK_COUNT = 4;
26918
26919 function RageClickTracker() {
26920 this.clicks = [];
26921 }
26922
26923 RageClickTracker.prototype.isRageClick = function(x, y, options) {
26924 options = options || {};
26925 var thresholdPx = options['threshold_px'] || DEFAULT_RAGE_CLICK_THRESHOLD_PX;
26926 var timeoutMs = options['timeout_ms'] || DEFAULT_RAGE_CLICK_TIMEOUT_MS;
26927 var clickCount = options['click_count'] || DEFAULT_RAGE_CLICK_CLICK_COUNT;
26928 var timestamp = Date.now();
26929
26930 var lastClick = this.clicks[this.clicks.length - 1];
26931 if (
26932 lastClick &&
26933 timestamp - lastClick.timestamp < timeoutMs &&
26934 Math.sqrt(Math.pow(x - lastClick.x, 2) + Math.pow(y - lastClick.y, 2)) < thresholdPx
26935 ) {
26936 this.clicks.push({ x: x, y: y, timestamp: timestamp });
26937 if (this.clicks.length >= clickCount) {
26938 this.clicks = [];
26939 return true;
26940 }
26941 } else {
26942 this.clicks = [{ x: x, y: y, timestamp: timestamp }];
26943 }
26944 return false;
26945 };
26946
26947 function ShadowDOMObserver(changeCallback, observerConfig) {
26948 this.changeCallback = changeCallback || function() {};
26949 this.observerConfig = observerConfig;
26950
26951 this.observedShadowRoots = null;
26952 this.shadowObservers = [];
26953 }
26954
26955 ShadowDOMObserver.prototype.getEventTarget = function(event) {
26956 if (!this.observedShadowRoots) {
26957 return;
26958 }
26959 var path = this.getComposedPath(event);
26960 if (path && path.length) {
26961 return path[0];
26962 }
26963
26964 return event['target'] || event['srcElement'];
26965 };
26966
26967
26968 ShadowDOMObserver.prototype.getComposedPath = function(event) {
26969 if ('composedPath' in event) {
26970 return event['composedPath']();
26971 }
26972
26973 return [];
26974 };
26975 ShadowDOMObserver.prototype.observeFromEvent = function(event) {
26976 if (!this.observedShadowRoots) {
26977 return;
26978 }
26979
26980 var path = this.getComposedPath(event);
26981
26982 // Check each element in path for shadow roots
26983 for (var i = 0; i < path.length; i++) {
26984 var element = path[i];
26985
26986 if (element && element.shadowRoot) {
26987 this.observeShadowRoot(element.shadowRoot);
26988 }
26989 }
26990 };
26991
26992
26993 ShadowDOMObserver.prototype.observeShadowRoot = function(shadowRoot) {
26994 if (!this.observedShadowRoots || this.observedShadowRoots.has(shadowRoot)) {
26995 return;
26996 }
26997
26998 var self = this;
26999
27000 try {
27001 this.observedShadowRoots.add(shadowRoot);
27002
27003 var observer = new window.MutationObserver(function() {
27004 self.changeCallback();
27005 });
27006
27007 observer.observe(shadowRoot, this.observerConfig);
27008 this.shadowObservers.push(observer);
27009 } catch (e) {
27010 logger$1.critical('Error while observing shadow root', e);
27011 }
27012 };
27013
27014
27015 ShadowDOMObserver.prototype.start = function() {
27016 if (this.observedShadowRoots) {
27017 return;
27018 }
27019
27020 if (!weakSetSupported()) {
27021 logger$1.critical('Shadow DOM observation unavailable: WeakSet not supported');
27022 return;
27023 }
27024
27025 this.observedShadowRoots = new WeakSet();
27026 };
27027
27028 ShadowDOMObserver.prototype.stop = function() {
27029 if (!this.observedShadowRoots) {
27030 return;
27031 }
27032
27033 for (var i = 0; i < this.shadowObservers.length; i++) {
27034 try {
27035 this.shadowObservers[i].disconnect();
27036 } catch (e) {
27037 logger$1.critical('Error while disconnecting shadow DOM observer', e);
27038 }
27039 }
27040 this.shadowObservers = [];
27041 this.observedShadowRoots = null;
27042 };
27043
27044 /** @const */ var DEFAULT_DEAD_CLICK_TIMEOUT_MS = 500;
27045 /** @const */ var INTERACTION_EVENTS = [EV_CHANGE, EV_INPUT, EV_SUBMIT, EV_SELECT, EV_TOGGLE];
27046 /** @const */ var LAYOUT_EVENTS = [EV_SCROLLEND];
27047 /** @const */ var NAVIGATION_EVENTS = [EV_HASHCHANGE];
27048 /** @const */ var MUTATION_OBSERVER_CONFIG = {
27049 characterData: true,
27050 childList: true,
27051 subtree: true,
27052 attributes: true,
27053 attributeFilter: ['style', 'class', 'hidden', 'checked', 'selected', 'value', 'display', 'visibility']
27054 };
27055
27056
27057 function DeadClickTracker(onDeadClickCallback) {
27058 this.eventListeners = [];
27059 this.mutationObserver = null;
27060 this.shadowDOMObserver = null;
27061
27062 this.isTracking = false;
27063 this.lastChangeEventTimestamp = 0;
27064 this.pendingClicks = [];
27065 this.onDeadClickCallback = onDeadClickCallback;
27066 this.processingActive = false;
27067 this.processingTimeout = null;
27068 }
27069
27070
27071 DeadClickTracker.prototype.addClick = function(event) {
27072 var element = this.shadowDOMObserver && this.shadowDOMObserver.getEventTarget(event);
27073
27074 if (!element) {
27075 element = event['target'] || event['srcElement'];
27076 }
27077
27078 if (!element || isDefinitelyNonInteractive(element)) {
27079 return false;
27080 }
27081
27082 if (this.shadowDOMObserver) {
27083 this.shadowDOMObserver.observeFromEvent(event);
27084 }
27085 this.pendingClicks.push({
27086 element: element,
27087 event: event,
27088 timestamp: Date.now()
27089 });
27090 return true;
27091 };
27092
27093 DeadClickTracker.prototype.trackClick = function(event, config) {
27094 if (!this.isTracking) {
27095 return false;
27096 }
27097
27098 var added = this.addClick(event);
27099 if (added) {
27100 this.triggerProcessing(config);
27101 }
27102 return added;
27103 };
27104
27105 DeadClickTracker.prototype.getDeadClicks = function(config) {
27106 if (this.pendingClicks.length === 0) {
27107 return [];
27108 }
27109
27110 var timeoutMs = config['timeout_ms'];
27111 var now = Date.now();
27112 var clicksToEvaluate = this.pendingClicks.slice(); // Copy array
27113 this.pendingClicks = []; // Clear original
27114
27115 var deadClicks = [];
27116
27117 for (var i = 0; i < clicksToEvaluate.length; i++) {
27118 var click = clicksToEvaluate[i];
27119
27120 if (now - click.timestamp >= timeoutMs) {
27121 // Click has exceeded timeout, check if it's dead by looking for changes after this specific click
27122 if (!this.hasChangesAfter(click.timestamp)) {
27123 deadClicks.push(click);
27124 }
27125 } else {
27126 // Still pending - add back
27127 this.pendingClicks.push(click);
27128 }
27129 }
27130
27131 return deadClicks;
27132 };
27133
27134 DeadClickTracker.prototype.hasChangesAfter = function(timestamp) {
27135 // 100ms tolerance for race condition between when we record the click and the change event
27136 return this.lastChangeEventTimestamp >= (timestamp - 100);
27137 };
27138
27139 DeadClickTracker.prototype.recordChangeEvent = function() {
27140 this.lastChangeEventTimestamp = Date.now();
27141 };
27142
27143 DeadClickTracker.prototype.triggerProcessing = function(config) {
27144 // Prevent multiple concurrent processing chains
27145 if (this.processingActive) {
27146 return;
27147 }
27148 this.processingActive = true;
27149 this.processRecursively(config);
27150 };
27151
27152 DeadClickTracker.prototype.processRecursively = function(config) {
27153 if (!this.isTracking || !this.onDeadClickCallback) {
27154 this.processingActive = false;
27155 return;
27156 }
27157
27158 var timeoutMs = config['timeout_ms'];
27159 var self = this;
27160
27161 this.processingTimeout = setTimeout(function() {
27162 if (!self.processingActive) {
27163 return;
27164 }
27165
27166 var deadClicks = self.getDeadClicks(config);
27167
27168 for (var i = 0; i < deadClicks.length; i++) {
27169 self.onDeadClickCallback(deadClicks[i].event);
27170 }
27171
27172 if (self.pendingClicks.length > 0) {
27173 self.processRecursively(config);
27174 } else {
27175 self.processingActive = false;
27176 }
27177 }, timeoutMs);
27178 };
27179
27180 DeadClickTracker.prototype.startTracking = function() {
27181 if (this.isTracking) {
27182 return;
27183 }
27184
27185 this.isTracking = true;
27186
27187 var self = this;
27188
27189 INTERACTION_EVENTS.forEach(function(event) {
27190 var handler = function() {
27191 self.recordChangeEvent();
27192 };
27193 document.addEventListener(event, handler, { capture: true, passive: true });
27194 self.eventListeners.push({ target: document, event: event, handler: handler, options: { capture: true, passive: true } });
27195 });
27196 NAVIGATION_EVENTS.forEach(function(event) {
27197 var handler = function() {
27198 self.recordChangeEvent();
27199 };
27200 window.addEventListener(event, handler);
27201 self.eventListeners.push({ target: window, event: event, handler: handler });
27202 });
27203 LAYOUT_EVENTS.forEach(function(event) {
27204 var handler = function() {
27205 self.recordChangeEvent();
27206 };
27207 window.addEventListener(event, handler, { passive: true });
27208 self.eventListeners.push({ target: window, event: event, handler: handler, options: { passive: true } });
27209 });
27210 var selectionHandler = function() {
27211 self.recordChangeEvent();
27212 };
27213 document.addEventListener('selectionchange', selectionHandler);
27214 self.eventListeners.push({ target: document, event: 'selectionchange', handler: selectionHandler });
27215
27216 // Set up MutationObserver
27217 if (window.MutationObserver) {
27218 try {
27219 this.mutationObserver = new window.MutationObserver(function() {
27220 self.recordChangeEvent();
27221 });
27222
27223 this.mutationObserver.observe(document.body || document.documentElement, MUTATION_OBSERVER_CONFIG);
27224 } catch (e) {
27225 logger$1.critical('Error while setting up mutation observer', e);
27226 }
27227 }
27228
27229 // Set up Shadow DOM observer
27230 if (window.customElements) {
27231 try {
27232 this.shadowDOMObserver = new ShadowDOMObserver(
27233 function() {
27234 self.recordChangeEvent();
27235 },
27236 MUTATION_OBSERVER_CONFIG
27237 );
27238 this.shadowDOMObserver.start();
27239 } catch (e) {
27240 logger$1.critical('Error while setting up shadow DOM observer', e);
27241 this.shadowDOMObserver = null;
27242 }
27243 }
27244 };
27245
27246 DeadClickTracker.prototype.stopTracking = function() {
27247 if (!this.isTracking) {
27248 return;
27249 }
27250
27251 this.isTracking = false;
27252 this.pendingClicks = [];
27253 this.lastChangeEventTimestamp = 0;
27254 this.processingActive = false;
27255
27256 if (this.processingTimeout) {
27257 clearTimeout(this.processingTimeout);
27258 this.processingTimeout = null;
27259 }
27260
27261 // Remove all event listeners
27262 for (var i = 0; i < this.eventListeners.length; i++) {
27263 var listener = this.eventListeners[i];
27264 try {
27265 listener.target.removeEventListener(listener.event, listener.handler, listener.options);
27266 } catch (e) {
27267 logger$1.critical('Error while removing event listener', e);
27268 }
27269 }
27270 this.eventListeners = [];
27271
27272 if (this.mutationObserver) {
27273 try {
27274 this.mutationObserver.disconnect();
27275 } catch (e) {
27276 logger$1.critical('Error while disconnecting mutation observer', e);
27277 }
27278 this.mutationObserver = null;
27279 }
27280
27281 if (this.shadowDOMObserver) {
27282 try {
27283 this.shadowDOMObserver.stop();
27284 } catch (e) {
27285 logger$1.critical('Error while stopping shadow DOM observer', e);
27286 }
27287 this.shadowDOMObserver = null;
27288 }
27289 };
27290
27291 var AUTOCAPTURE_CONFIG_KEY = 'autocapture';
27292 var LEGACY_PAGEVIEW_CONFIG_KEY = 'track_pageview';
27293
27294 var PAGEVIEW_OPTION_FULL_URL = 'full-url';
27295 var PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING = 'url-with-path-and-query-string';
27296 var PAGEVIEW_OPTION_URL_WITH_PATH = 'url-with-path';
27297
27298 var CONFIG_ALLOW_ELEMENT_CALLBACK = 'allow_element_callback';
27299 var CONFIG_ALLOW_SELECTORS = 'allow_selectors';
27300 var CONFIG_ALLOW_URL_REGEXES = 'allow_url_regexes';
27301 var CONFIG_BLOCK_ATTRS = 'block_attrs';
27302 var CONFIG_BLOCK_ELEMENT_CALLBACK = 'block_element_callback';
27303 var CONFIG_BLOCK_SELECTORS = 'block_selectors';
27304 var CONFIG_BLOCK_URL_REGEXES = 'block_url_regexes';
27305 var CONFIG_CAPTURE_EXTRA_ATTRS = 'capture_extra_attrs';
27306 var CONFIG_CAPTURE_TEXT_CONTENT = 'capture_text_content';
27307 var CONFIG_SCROLL_CAPTURE_ALL = 'scroll_capture_all';
27308 var CONFIG_SCROLL_CHECKPOINTS = 'scroll_depth_percent_checkpoints';
27309 var CONFIG_TRACK_CLICK = 'click';
27310 var CONFIG_TRACK_DEAD_CLICK = 'dead_click';
27311 var CONFIG_TRACK_INPUT = 'input';
27312 var CONFIG_TRACK_PAGEVIEW = 'pageview';
27313 var CONFIG_TRACK_RAGE_CLICK = 'rage_click';
27314 var CONFIG_TRACK_SCROLL = 'scroll';
27315 var CONFIG_TRACK_PAGE_LEAVE = 'page_leave';
27316 var CONFIG_TRACK_SUBMIT = 'submit';
27317
27318 var CONFIG_DEFAULTS$1 = {};
27319 CONFIG_DEFAULTS$1[CONFIG_ALLOW_SELECTORS] = [];
27320 CONFIG_DEFAULTS$1[CONFIG_ALLOW_URL_REGEXES] = [];
27321 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ATTRS] = [];
27322 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ELEMENT_CALLBACK] = null;
27323 CONFIG_DEFAULTS$1[CONFIG_BLOCK_SELECTORS] = [];
27324 CONFIG_DEFAULTS$1[CONFIG_BLOCK_URL_REGEXES] = [];
27325 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_EXTRA_ATTRS] = [];
27326 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_TEXT_CONTENT] = false;
27327 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CAPTURE_ALL] = false;
27328 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CHECKPOINTS] = [25, 50, 75, 100];
27329 CONFIG_DEFAULTS$1[CONFIG_TRACK_CLICK] = true;
27330 CONFIG_DEFAULTS$1[CONFIG_TRACK_DEAD_CLICK] = true;
27331 CONFIG_DEFAULTS$1[CONFIG_TRACK_INPUT] = true;
27332 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGEVIEW] = PAGEVIEW_OPTION_FULL_URL;
27333 CONFIG_DEFAULTS$1[CONFIG_TRACK_RAGE_CLICK] = true;
27334 CONFIG_DEFAULTS$1[CONFIG_TRACK_SCROLL] = true;
27335 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGE_LEAVE] = false;
27336 CONFIG_DEFAULTS$1[CONFIG_TRACK_SUBMIT] = true;
27337
27338 var DEFAULT_PROPS = {
27339 '$mp_autocapture': true
27340 };
27341
27342 var MP_EV_CLICK = '$mp_click';
27343 var MP_EV_DEAD_CLICK = '$mp_dead_click';
27344 var MP_EV_INPUT = '$mp_input_change';
27345 var MP_EV_RAGE_CLICK = '$mp_rage_click';
27346 var MP_EV_SCROLL = '$mp_scroll';
27347 var MP_EV_SUBMIT = '$mp_submit';
27348 var MP_EV_PAGE_LEAVE = '$mp_page_leave';
27349
27350 /**
27351 * Autocapture: manages automatic event tracking
27352 * @constructor
27353 */
27354 var Autocapture = function(mp) {
27355 this.mp = mp;
27356 this.maxScrollViewDepth = 0;
27357 this.hasTrackedScrollSession = false;
27358 this.previousScrollHeight = 0;
27359 };
27360
27361 Autocapture.prototype.init = function() {
27362 if (!minDOMApisSupported()) {
27363 logger$1.critical('Autocapture unavailable: missing required DOM APIs');
27364 return;
27365 }
27366 this.initPageListeners();
27367 this.initPageviewTracking();
27368 this.initClickTracking();
27369 this.initDeadClickTracking();
27370 this.initInputTracking();
27371 this.initScrollTracking();
27372 this.initSubmitTracking();
27373 this.initRageClickTracking();
27374 this.initPageLeaveTracking();
27375 };
27376
27377 Autocapture.prototype.getFullConfig = function() {
27378 var autocaptureConfig = this.mp.get_config(AUTOCAPTURE_CONFIG_KEY);
27379 if (!autocaptureConfig) {
27380 // Autocapture is completely off
27381 return {};
27382 } else if (_.isObject(autocaptureConfig)) {
27383 return _.extend({}, CONFIG_DEFAULTS$1, autocaptureConfig);
27384 } else {
27385 // Autocapture config is non-object truthy value, return default
27386 return CONFIG_DEFAULTS$1;
27387 }
27388 };
27389
27390 Autocapture.prototype.getConfig = function(key) {
27391 return this.getFullConfig()[key];
27392 };
27393
27394 Autocapture.prototype.currentUrlBlocked = function() {
27395 var i;
27396 var currentUrl = _.info.currentUrl();
27397
27398 var allowUrlRegexes = this.getConfig(CONFIG_ALLOW_URL_REGEXES) || [];
27399 if (allowUrlRegexes.length) {
27400 // we're using an allowlist, only track if current URL matches
27401 var allowed = false;
27402 for (i = 0; i < allowUrlRegexes.length; i++) {
27403 var allowRegex = allowUrlRegexes[i];
27404 try {
27405 if (currentUrl.match(allowRegex)) {
27406 allowed = true;
27407 break;
27408 }
27409 } catch (err) {
27410 logger$1.critical('Error while checking block URL regex: ' + allowRegex, err);
27411 return true;
27412 }
27413 }
27414 if (!allowed) {
27415 // wasn't allowed by any regex
27416 return true;
27417 }
27418 }
27419
27420 var blockUrlRegexes = this.getConfig(CONFIG_BLOCK_URL_REGEXES) || [];
27421 if (!blockUrlRegexes || !blockUrlRegexes.length) {
27422 return false;
27423 }
27424
27425 for (i = 0; i < blockUrlRegexes.length; i++) {
27426 try {
27427 if (currentUrl.match(blockUrlRegexes[i])) {
27428 return true;
27429 }
27430 } catch (err) {
27431 logger$1.critical('Error while checking block URL regex: ' + blockUrlRegexes[i], err);
27432 return true;
27433 }
27434 }
27435 return false;
27436 };
27437
27438 Autocapture.prototype.pageviewTrackingConfig = function() {
27439 // supports both autocapture config and old track_pageview config
27440 if (this.mp.get_config(AUTOCAPTURE_CONFIG_KEY)) {
27441 return this.getConfig(CONFIG_TRACK_PAGEVIEW);
27442 } else {
27443 return this.mp.get_config(LEGACY_PAGEVIEW_CONFIG_KEY);
27444 }
27445 };
27446
27447 // helper for event handlers
27448 Autocapture.prototype.trackDomEvent = function(ev, mpEventName) {
27449 if (this.currentUrlBlocked()) {
27450 return;
27451 }
27452
27453 var isCapturedForHeatMap = this.mp.is_recording_heatmap_data() && (
27454 (mpEventName === MP_EV_CLICK && !this.getConfig(CONFIG_TRACK_CLICK)) ||
27455 (mpEventName === MP_EV_RAGE_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK)) ||
27456 (mpEventName === MP_EV_DEAD_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK))
27457 );
27458
27459 var props = getPropsForDOMEvent(ev, {
27460 allowElementCallback: this.getConfig(CONFIG_ALLOW_ELEMENT_CALLBACK),
27461 allowSelectors: this.getConfig(CONFIG_ALLOW_SELECTORS),
27462 blockAttrs: this.getConfig(CONFIG_BLOCK_ATTRS),
27463 blockElementCallback: this.getConfig(CONFIG_BLOCK_ELEMENT_CALLBACK),
27464 blockSelectors: this.getConfig(CONFIG_BLOCK_SELECTORS),
27465 captureExtraAttrs: this.getConfig(CONFIG_CAPTURE_EXTRA_ATTRS),
27466 captureTextContent: this.getConfig(CONFIG_CAPTURE_TEXT_CONTENT),
27467 capturedForHeatMap: isCapturedForHeatMap,
27468 });
27469 if (props) {
27470 _.extend(props, DEFAULT_PROPS);
27471 this.mp.track(mpEventName, props);
27472 }
27473 };
27474
27475 Autocapture.prototype.initPageListeners = function() {
27476 win.removeEventListener(EV_POPSTATE, this.listenerPopstate);
27477 win.removeEventListener(EV_HASHCHANGE, this.listenerHashchange);
27478
27479 if (!this.pageviewTrackingConfig() && !this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
27480 // These are all the configs that use these listeners
27481 return;
27482 }
27483
27484 this.listenerPopstate = function() {
27485 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27486 };
27487 this.listenerHashchange = function() {
27488 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27489 };
27490
27491 win.addEventListener(EV_POPSTATE, this.listenerPopstate);
27492 win.addEventListener(EV_HASHCHANGE, this.listenerHashchange);
27493 var nativePushState = win.history.pushState;
27494 if (typeof nativePushState === 'function') {
27495 win.history.pushState = function(state, unused, url) {
27496 nativePushState.call(win.history, state, unused, url);
27497 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27498 };
27499 }
27500 var nativeReplaceState = win.history.replaceState;
27501 if (typeof nativeReplaceState === 'function') {
27502 win.history.replaceState = function(state, unused, url) {
27503 nativeReplaceState.call(win.history, state, unused, url);
27504 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27505 };
27506 }
27507 };
27508
27509 Autocapture.prototype._getClickTrackingConfig = function(configKey) {
27510 var config = this.getConfig(configKey);
27511
27512 if (!config) {
27513 return null; // click tracking disabled
27514 }
27515
27516 if (config === true) {
27517 return {}; // use defaults
27518 }
27519
27520 if (typeof config === 'object') {
27521 return config; // use custom configuration
27522 }
27523
27524 return {}; // fallback to defaults for any other truthy value
27525 };
27526
27527 Autocapture.prototype._trackPageLeave = function(ev, currentUrl, currentScrollHeight) {
27528 if (this.hasTrackedScrollSession) {
27529 // User has navigated away already ending their impression.
27530 return;
27531 }
27532
27533 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.is_recording_heatmap_data()) {
27534 return;
27535 }
27536
27537 this.hasTrackedScrollSession = true;
27538 var viewportHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
27539 var scrollPercentage = Math.round(Math.max(this.maxScrollViewDepth - viewportHeight, 0) / (currentScrollHeight - viewportHeight) * 100);
27540 var foldLinePercentage = Math.round((viewportHeight / currentScrollHeight) * 100);
27541 if (currentScrollHeight <= viewportHeight) {
27542 // If the content fits within the viewport, consider it fully scrolled
27543 scrollPercentage = 100;
27544 foldLinePercentage = 100;
27545 }
27546
27547 var props = _.extend({
27548 '$max_scroll_view_depth': this.maxScrollViewDepth,
27549 '$max_scroll_percentage': scrollPercentage,
27550 '$fold_line_percentage': foldLinePercentage,
27551 '$scroll_height': currentScrollHeight,
27552 '$event_type': ev.type,
27553 '$current_url': currentUrl || _.info.currentUrl(),
27554 '$viewportHeight': viewportHeight, // This is the fold line
27555 '$viewportWidth': Math.max(document$1.documentElement.clientWidth, win.innerWidth || 0),
27556 '$captured_for_heatmap': this.mp.is_recording_heatmap_data()
27557 }, DEFAULT_PROPS);
27558
27559 // Send with beacon transport to ensure event is sent before unload
27560 this.mp.track(MP_EV_PAGE_LEAVE, props, {transport: 'sendBeacon'});
27561 };
27562
27563 Autocapture.prototype._initScrollDepthTracking = function() {
27564 win.removeEventListener(EV_SCROLL, this.listenerScrollDepth);
27565 win.removeEventListener(EV_SCROLLEND, this.listenerScrollDepth);
27566
27567 if (!this.mp.get_config('record_heatmap_data')) {
27568 return;
27569 }
27570
27571 logger$1.log('Initializing scroll depth tracking');
27572
27573 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
27574
27575 var updateScrollDepth = function() {
27576 if (this.currentUrlBlocked()) {
27577 return;
27578 }
27579 var scrollViewHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0) + win.scrollY;
27580 if (scrollViewHeight > this.maxScrollViewDepth) {
27581 this.maxScrollViewDepth = scrollViewHeight;
27582 }
27583 this.previousScrollHeight = document$1.body.scrollHeight;
27584 }.bind(this);
27585
27586 var scrollEndPolyfill = getPolyfillScrollEndFunction(updateScrollDepth);
27587 this.listenerScrollDepth = scrollEndPolyfill.listener;
27588 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScrollDepth);
27589 };
27590
27591 Autocapture.prototype.initClickTracking = function() {
27592 win.removeEventListener(EV_CLICK, this.listenerClick);
27593
27594 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.get_config('record_heatmap_data')) {
27595 return;
27596 }
27597 logger$1.log('Initializing click tracking');
27598
27599 this.listenerClick = function(ev) {
27600 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.is_recording_heatmap_data()) {
27601 return;
27602 }
27603 this.trackDomEvent(ev, MP_EV_CLICK);
27604 }.bind(this);
27605 win.addEventListener(EV_CLICK, this.listenerClick);
27606 };
27607
27608 Autocapture.prototype.initDeadClickTracking = function() {
27609 var deadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
27610
27611 if (!deadClickConfig && !this.mp.get_config('record_heatmap_data')) {
27612 this.stopDeadClickTracking();
27613 return;
27614 }
27615
27616 logger$1.log('Initializing dead click tracking');
27617 if (!this._deadClickTracker) {
27618 this._deadClickTracker = new DeadClickTracker(function(deadClickEvent) {
27619 this.trackDomEvent(deadClickEvent, MP_EV_DEAD_CLICK);
27620 }.bind(this));
27621 this._deadClickTracker.startTracking();
27622 }
27623
27624 if (!this.listenerDeadClick) {
27625 this.listenerDeadClick = function(ev) {
27626 var currentDeadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
27627 if (!currentDeadClickConfig && !this.mp.is_recording_heatmap_data()) {
27628 return;
27629 }
27630 if (this.currentUrlBlocked()) {
27631 return;
27632 }
27633 // Normalize config to ensure timeout_ms is always set
27634 var normalizedConfig = currentDeadClickConfig || {};
27635 if (!normalizedConfig['timeout_ms']) {
27636 normalizedConfig['timeout_ms'] = DEFAULT_DEAD_CLICK_TIMEOUT_MS;
27637 }
27638 this._deadClickTracker.trackClick(ev, normalizedConfig);
27639 }.bind(this);
27640 win.addEventListener(EV_CLICK, this.listenerDeadClick);
27641 }
27642 };
27643
27644 Autocapture.prototype.initInputTracking = function() {
27645 win.removeEventListener(EV_CHANGE, this.listenerChange);
27646
27647 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
27648 return;
27649 }
27650 logger$1.log('Initializing input tracking');
27651
27652 this.listenerChange = function(ev) {
27653 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
27654 return;
27655 }
27656 this.trackDomEvent(ev, MP_EV_INPUT);
27657 }.bind(this);
27658 win.addEventListener(EV_CHANGE, this.listenerChange);
27659 };
27660
27661 Autocapture.prototype.initPageviewTracking = function() {
27662 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
27663
27664 if (!this.pageviewTrackingConfig()) {
27665 return;
27666 }
27667 logger$1.log('Initializing pageview tracking');
27668
27669 var previousTrackedUrl = '';
27670 var tracked = false;
27671 if (!this.currentUrlBlocked()) {
27672 tracked = this.mp.track_pageview(DEFAULT_PROPS);
27673 }
27674 if (tracked) {
27675 previousTrackedUrl = _.info.currentUrl();
27676 }
27677
27678 this.listenerLocationchange = safewrap(function() {
27679 if (this.currentUrlBlocked()) {
27680 return;
27681 }
27682
27683 var currentUrl = _.info.currentUrl();
27684 var shouldTrack = false;
27685 var didPathChange = currentUrl.split('#')[0].split('?')[0] !== previousTrackedUrl.split('#')[0].split('?')[0];
27686 var trackPageviewOption = this.pageviewTrackingConfig();
27687 if (trackPageviewOption === PAGEVIEW_OPTION_FULL_URL) {
27688 shouldTrack = currentUrl !== previousTrackedUrl;
27689 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING) {
27690 shouldTrack = currentUrl.split('#')[0] !== previousTrackedUrl.split('#')[0];
27691 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH) {
27692 shouldTrack = didPathChange;
27693 }
27694
27695 if (shouldTrack) {
27696 var tracked = this.mp.track_pageview(DEFAULT_PROPS);
27697 if (tracked) {
27698 previousTrackedUrl = currentUrl;
27699 }
27700 if (didPathChange) {
27701 this.lastScrollCheckpoint = 0;
27702 logger$1.log('Path change: re-initializing scroll depth checkpoints');
27703 }
27704 }
27705 }.bind(this));
27706 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
27707 };
27708
27709 Autocapture.prototype.initRageClickTracking = function() {
27710 win.removeEventListener(EV_CLICK, this.listenerRageClick);
27711
27712 var rageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
27713 if (!rageClickConfig && !this.mp.get_config('record_heatmap_data')) {
27714 return;
27715 }
27716
27717 logger$1.log('Initializing rage click tracking');
27718 if (!this._rageClickTracker) {
27719 this._rageClickTracker = new RageClickTracker();
27720 }
27721
27722 this.listenerRageClick = function(ev) {
27723 var currentRageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
27724 if (!currentRageClickConfig && !this.mp.is_recording_heatmap_data()) {
27725 return;
27726 }
27727
27728 if (this.currentUrlBlocked()) {
27729 return;
27730 }
27731
27732 if (this._rageClickTracker.isRageClick(ev['pageX'], ev['pageY'], currentRageClickConfig)) {
27733 this.trackDomEvent(ev, MP_EV_RAGE_CLICK);
27734 }
27735 }.bind(this);
27736 win.addEventListener(EV_CLICK, this.listenerRageClick);
27737 };
27738
27739 Autocapture.prototype.initScrollTracking = function() {
27740 win.removeEventListener(EV_SCROLLEND, this.listenerScroll);
27741 win.removeEventListener(EV_SCROLL, this.listenerScroll);
27742
27743
27744 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
27745 return;
27746 }
27747 logger$1.log('Initializing scroll tracking');
27748 this.lastScrollCheckpoint = 0;
27749
27750 var scrollTrackFunction = function() {
27751 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
27752 return;
27753 }
27754 if (this.currentUrlBlocked()) {
27755 return;
27756 }
27757
27758 var shouldTrack = this.getConfig(CONFIG_SCROLL_CAPTURE_ALL);
27759 var scrollCheckpoints = (this.getConfig(CONFIG_SCROLL_CHECKPOINTS) || [])
27760 .slice()
27761 .sort(function(a, b) { return a - b; });
27762
27763 var scrollTop = win.scrollY;
27764 var props = _.extend({'$scroll_top': scrollTop}, DEFAULT_PROPS);
27765 try {
27766 var scrollHeight = document$1.body.scrollHeight;
27767 var scrollPercentage = Math.round((scrollTop / (scrollHeight - win.innerHeight)) * 100);
27768 props['$scroll_height'] = scrollHeight;
27769 props['$scroll_percentage'] = scrollPercentage;
27770 if (scrollPercentage > this.lastScrollCheckpoint) {
27771 for (var i = 0; i < scrollCheckpoints.length; i++) {
27772 var checkpoint = scrollCheckpoints[i];
27773 if (
27774 scrollPercentage >= checkpoint &&
27775 this.lastScrollCheckpoint < checkpoint
27776 ) {
27777 props['$scroll_checkpoint'] = checkpoint;
27778 this.lastScrollCheckpoint = checkpoint;
27779 shouldTrack = true;
27780 }
27781 }
27782 }
27783 } catch (err) {
27784 logger$1.critical('Error while calculating scroll percentage', err);
27785 }
27786 if (shouldTrack) {
27787 this.mp.track(MP_EV_SCROLL, props);
27788 }
27789 }.bind(this);
27790
27791 var scrollEndPolyfill = getPolyfillScrollEndFunction(scrollTrackFunction);
27792 this.listenerScroll = scrollEndPolyfill.listener;
27793 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScroll);
27794 };
27795
27796 Autocapture.prototype.initSubmitTracking = function() {
27797 win.removeEventListener(EV_SUBMIT, this.listenerSubmit);
27798
27799 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
27800 return;
27801 }
27802 logger$1.log('Initializing submit tracking');
27803
27804 this.listenerSubmit = function(ev) {
27805 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
27806 return;
27807 }
27808 this.trackDomEvent(ev, MP_EV_SUBMIT);
27809 }.bind(this);
27810 win.addEventListener(EV_SUBMIT, this.listenerSubmit);
27811 };
27812
27813 Autocapture.prototype.initPageLeaveTracking = function() {
27814 // Capture page_leave both when the user navigates away from the page (visibilitychange) as well
27815 // as when they navigate to a different page within the SPA (popstate/pushstate/hashchange).
27816 document$1.removeEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
27817 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
27818 win.removeEventListener(EV_LOAD, this.listenerPageLoad);
27819
27820 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
27821 return;
27822 }
27823
27824 logger$1.log('Initializing page visibility tracking.');
27825 this._initScrollDepthTracking();
27826 var previousTrackedUrl = _.info.currentUrl();
27827
27828 // Initialize previousScrollHeight on `load` which handles async loading
27829 // https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
27830 this.listenerPageLoad = function() {
27831 this.previousScrollHeight = document$1.body.scrollHeight;
27832 }.bind(this);
27833 win.addEventListener(EV_LOAD, this.listenerPageLoad);
27834
27835 // Track page navigation events similar to how initPageviewTracking does it
27836 this.listenerPageLeaveLocationchange = safewrap(function(ev) {
27837 if (this.currentUrlBlocked()) {
27838 return;
27839 }
27840
27841 var currentUrl = _.info.currentUrl();
27842 // Track all URL changes including query string or fragment changes as separate scroll sessions
27843 var shouldTrack = currentUrl !== previousTrackedUrl;
27844
27845 if (shouldTrack) {
27846 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
27847 previousTrackedUrl = currentUrl;
27848 // Fragment navigation should call scroll(end) and trigger listener, don't add window.scrollY here.
27849 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
27850 this.previousScrollHeight = document$1.body.scrollHeight;
27851 this.hasTrackedScrollSession = false;
27852 }
27853 }.bind(this));
27854 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
27855
27856 this.listenerPageLeaveVisibilitychange = function(ev) {
27857 if (document$1.hidden) {
27858 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
27859 }
27860 }.bind(this);
27861 document$1.addEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
27862 };
27863
27864 Autocapture.prototype.stopDeadClickTracking = function() {
27865 if (this.listenerDeadClick) {
27866 win.removeEventListener(EV_CLICK, this.listenerDeadClick);
27867 this.listenerDeadClick = null;
27868 }
27869
27870 if (this._deadClickTracker) {
27871 this._deadClickTracker.stopTracking();
27872 this._deadClickTracker = null;
27873 }
27874 };
27875
27876 // TODO integrate error_reporter from mixpanel instance
27877 safewrapClass(Autocapture);
27878
27879 var logger = console_with_prefix('flags');
27880
27881 var FLAGS_CONFIG_KEY = 'flags';
27882
27883 var CONFIG_CONTEXT = 'context';
27884 var CONFIG_DEFAULTS = {};
27885 CONFIG_DEFAULTS[CONFIG_CONTEXT] = {};
27886
27887 /**
27888 * FeatureFlagManager: support for Mixpanel's feature flagging product
27889 * @constructor
27890 */
27891 var FeatureFlagManager = function(initOptions) {
27892 this.fetch = win['fetch'];
27893 this.getFullApiRoute = initOptions.getFullApiRoute;
27894 this.getMpConfig = initOptions.getConfigFunc;
27895 this.setMpConfig = initOptions.setConfigFunc;
27896 this.getMpProperty = initOptions.getPropertyFunc;
27897 this.track = initOptions.trackingFunc;
27898 };
27899
27900 FeatureFlagManager.prototype.init = function() {
27901 if (!this.minApisSupported()) {
27902 logger.critical('Feature Flags unavailable: missing minimum required APIs');
27903 return;
27904 }
27905
27906 this.flags = null;
27907 this.fetchFlags();
27908
27909 this.trackedFeatures = new Set();
27910 };
27911
27912 FeatureFlagManager.prototype.getFullConfig = function() {
27913 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
27914 if (!ffConfig) {
27915 // flags are completely off
27916 return {};
27917 } else if (_.isObject(ffConfig)) {
27918 return _.extend({}, CONFIG_DEFAULTS, ffConfig);
27919 } else {
27920 // config is non-object truthy value, return default
27921 return CONFIG_DEFAULTS;
27922 }
27923 };
27924
27925 FeatureFlagManager.prototype.getConfig = function(key) {
27926 return this.getFullConfig()[key];
27927 };
27928
27929 FeatureFlagManager.prototype.isSystemEnabled = function() {
27930 return !!this.getMpConfig(FLAGS_CONFIG_KEY);
27931 };
27932
27933 FeatureFlagManager.prototype.updateContext = function(newContext, options) {
27934 if (!this.isSystemEnabled()) {
27935 logger.critical('Feature Flags not enabled, cannot update context');
27936 return Promise.resolve();
27937 }
27938
27939 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
27940 if (!_.isObject(ffConfig)) {
27941 ffConfig = {};
27942 }
27943 var oldContext = (options && options['replace']) ? {} : this.getConfig(CONFIG_CONTEXT);
27944 ffConfig[CONFIG_CONTEXT] = _.extend({}, oldContext, newContext);
27945
27946 this.setMpConfig(FLAGS_CONFIG_KEY, ffConfig);
27947 return this.fetchFlags();
27948 };
27949
27950 FeatureFlagManager.prototype.areFlagsReady = function() {
27951 if (!this.isSystemEnabled()) {
27952 logger.error('Feature Flags not enabled');
27953 }
27954 return !!this.flags;
27955 };
27956
27957 FeatureFlagManager.prototype.fetchFlags = function() {
27958 if (!this.isSystemEnabled()) {
27959 return Promise.resolve();
27960 }
27961
27962 var distinctId = this.getMpProperty('distinct_id');
27963 var deviceId = this.getMpProperty('$device_id');
27964 var traceparent = generateTraceparent();
27965 logger.log('Fetching flags for distinct ID: ' + distinctId);
27966
27967 var context = _.extend({'distinct_id': distinctId, 'device_id': deviceId}, this.getConfig(CONFIG_CONTEXT));
27968 var searchParams = new URLSearchParams();
27969 searchParams.set('context', JSON.stringify(context));
27970 searchParams.set('token', this.getMpConfig('token'));
27971 searchParams.set('mp_lib', 'web');
27972 searchParams.set('$lib_version', Config.LIB_VERSION);
27973 var url = this.getFullApiRoute() + '?' + searchParams.toString();
27974
27975 this._fetchInProgressStartTime = Date.now();
27976 this.fetchPromise = this.fetch.call(win, url, {
27977 'method': 'GET',
27978 'headers': {
27979 'Authorization': 'Basic ' + btoa(this.getMpConfig('token') + ':'),
27980 'traceparent': traceparent
27981 }
27982 }).then(function(response) {
27983 this.markFetchComplete();
27984 return response.json().then(function(responseBody) {
27985 var responseFlags = responseBody['flags'];
27986 if (!responseFlags) {
27987 throw new Error('No flags in API response');
27988 }
27989 var flags = new Map();
27990 _.each(responseFlags, function(data, key) {
27991 flags.set(key, {
27992 'key': data['variant_key'],
27993 'value': data['variant_value'],
27994 'experiment_id': data['experiment_id'],
27995 'is_experiment_active': data['is_experiment_active'],
27996 'is_qa_tester': data['is_qa_tester']
27997 });
27998 });
27999 this.flags = flags;
28000 this._traceparent = traceparent;
28001 }.bind(this)).catch(function(error) {
28002 this.markFetchComplete();
28003 logger.error(error);
28004 }.bind(this));
28005 }.bind(this)).catch(function(error) {
28006 this.markFetchComplete();
28007 logger.error(error);
28008 }.bind(this));
28009
28010 return this.fetchPromise;
28011 };
28012
28013 FeatureFlagManager.prototype.markFetchComplete = function() {
28014 if (!this._fetchInProgressStartTime) {
28015 logger.error('Fetch in progress started time not set, cannot mark fetch complete');
28016 return;
28017 }
28018 this._fetchStartTime = this._fetchInProgressStartTime;
28019 this._fetchCompleteTime = Date.now();
28020 this._fetchLatency = this._fetchCompleteTime - this._fetchStartTime;
28021 this._fetchInProgressStartTime = null;
28022 };
28023
28024 FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
28025 if (!this.fetchPromise) {
28026 return new Promise(function(resolve) {
28027 logger.critical('Feature Flags not initialized');
28028 resolve(fallback);
28029 });
28030 }
28031
28032 return this.fetchPromise.then(function() {
28033 return this.getVariantSync(featureName, fallback);
28034 }.bind(this)).catch(function(error) {
28035 logger.error(error);
28036 return fallback;
28037 });
28038 };
28039
28040 FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
28041 if (!this.areFlagsReady()) {
28042 logger.log('Flags not loaded yet');
28043 return fallback;
28044 }
28045 var feature = this.flags.get(featureName);
28046 if (!feature) {
28047 logger.log('No flag found: "' + featureName + '"');
28048 return fallback;
28049 }
28050 this.trackFeatureCheck(featureName, feature);
28051 return feature;
28052 };
28053
28054 FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
28055 return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
28056 return feature['value'];
28057 }).catch(function(error) {
28058 logger.error(error);
28059 return fallbackValue;
28060 });
28061 };
28062
28063 // TODO remove deprecated method
28064 FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
28065 logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
28066 return this.getVariantValue(featureName, fallbackValue);
28067 };
28068
28069 FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
28070 return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
28071 };
28072
28073 FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
28074 return this.getVariantValue(featureName).then(function() {
28075 return this.isEnabledSync(featureName, fallbackValue);
28076 }.bind(this)).catch(function(error) {
28077 logger.error(error);
28078 return fallbackValue;
28079 });
28080 };
28081
28082 FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
28083 fallbackValue = fallbackValue || false;
28084 var val = this.getVariantValueSync(featureName, fallbackValue);
28085 if (val !== true && val !== false) {
28086 logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
28087 val = fallbackValue;
28088 }
28089 return val;
28090 };
28091
28092 FeatureFlagManager.prototype.trackFeatureCheck = function(featureName, feature) {
28093 if (this.trackedFeatures.has(featureName)) {
28094 return;
28095 }
28096 this.trackedFeatures.add(featureName);
28097
28098 var trackingProperties = {
28099 'Experiment name': featureName,
28100 'Variant name': feature['key'],
28101 '$experiment_type': 'feature_flag',
28102 'Variant fetch start time': new Date(this._fetchStartTime).toISOString(),
28103 'Variant fetch complete time': new Date(this._fetchCompleteTime).toISOString(),
28104 'Variant fetch latency (ms)': this._fetchLatency,
28105 'Variant fetch traceparent': this._traceparent,
28106 };
28107
28108 if (feature['experiment_id'] !== 'undefined') {
28109 trackingProperties['$experiment_id'] = feature['experiment_id'];
28110 }
28111 if (feature['is_experiment_active'] !== 'undefined') {
28112 trackingProperties['$is_experiment_active'] = feature['is_experiment_active'];
28113 }
28114 if (feature['is_qa_tester'] !== 'undefined') {
28115 trackingProperties['$is_qa_tester'] = feature['is_qa_tester'];
28116 }
28117
28118 this.track('$experiment_started', trackingProperties);
28119 };
28120
28121 FeatureFlagManager.prototype.minApisSupported = function() {
28122 return !!this.fetch &&
28123 typeof Promise !== 'undefined' &&
28124 typeof Map !== 'undefined' &&
28125 typeof Set !== 'undefined';
28126 };
28127
28128 safewrapClass(FeatureFlagManager);
28129
28130 FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
28131 FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
28132 FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
28133 FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
28134 FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
28135 FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
28136 FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
28137 FeatureFlagManager.prototype['update_context'] = FeatureFlagManager.prototype.updateContext;
28138
28139 // Deprecated method
28140 FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
28141
28142 /* eslint camelcase: "off" */
28143
28144
28145 /**
28146 * DomTracker Object
28147 * @constructor
28148 */
28149 var DomTracker = function() {};
28150
28151
28152 // interface
28153 DomTracker.prototype.create_properties = function() {};
28154 DomTracker.prototype.event_handler = function() {};
28155 DomTracker.prototype.after_track_handler = function() {};
28156
28157 DomTracker.prototype.init = function(mixpanel_instance) {
28158 this.mp = mixpanel_instance;
28159 return this;
28160 };
28161
28162 /**
28163 * @param {Object|string} query
28164 * @param {string} event_name
28165 * @param {Object=} properties
28166 * @param {function=} user_callback
28167 */
28168 DomTracker.prototype.track = function(query, event_name, properties, user_callback) {
28169 var that = this;
28170 var elements = _.dom_query(query);
28171
28172 if (elements.length === 0) {
28173 console$1.error('The DOM query (' + query + ') returned 0 elements');
28174 return;
28175 }
28176
28177 _.each(elements, function(element) {
28178 _.register_event(element, this.override_event, function(e) {
28179 var options = {};
28180 var props = that.create_properties(properties, this);
28181 var timeout = that.mp.get_config('track_links_timeout');
28182
28183 that.event_handler(e, this, options);
28184
28185 // in case the mixpanel servers don't get back to us in time
28186 window.setTimeout(that.track_callback(user_callback, props, options, true), timeout);
28187
28188 // fire the tracking event
28189 that.mp.track(event_name, props, that.track_callback(user_callback, props, options));
28190 });
28191 }, this);
28192
28193 return true;
28194 };
28195
28196 /**
28197 * @param {function} user_callback
28198 * @param {Object} props
28199 * @param {boolean=} timeout_occured
28200 */
28201 DomTracker.prototype.track_callback = function(user_callback, props, options, timeout_occured) {
28202 timeout_occured = timeout_occured || false;
28203 var that = this;
28204
28205 return function() {
28206 // options is referenced from both callbacks, so we can have
28207 // a 'lock' of sorts to ensure only one fires
28208 if (options.callback_fired) { return; }
28209 options.callback_fired = true;
28210
28211 if (user_callback && user_callback(timeout_occured, props) === false) {
28212 // user can prevent the default functionality by
28213 // returning false from their callback
28214 return;
28215 }
28216
28217 that.after_track_handler(props, options, timeout_occured);
28218 };
28219 };
28220
28221 DomTracker.prototype.create_properties = function(properties, element) {
28222 var props;
28223
28224 if (typeof(properties) === 'function') {
28225 props = properties(element);
28226 } else {
28227 props = _.extend({}, properties);
28228 }
28229
28230 return props;
28231 };
28232
28233 /**
28234 * LinkTracker Object
28235 * @constructor
28236 * @extends DomTracker
28237 */
28238 var LinkTracker = function() {
28239 this.override_event = 'click';
28240 };
28241 _.inherit(LinkTracker, DomTracker);
28242
28243 LinkTracker.prototype.create_properties = function(properties, element) {
28244 var props = LinkTracker.superclass.create_properties.apply(this, arguments);
28245
28246 if (element.href) { props['url'] = element.href; }
28247
28248 return props;
28249 };
28250
28251 LinkTracker.prototype.event_handler = function(evt, element, options) {
28252 options.new_tab = (
28253 evt.which === 2 ||
28254 evt.metaKey ||
28255 evt.ctrlKey ||
28256 element.target === '_blank'
28257 );
28258 options.href = element.href;
28259
28260 if (!options.new_tab) {
28261 evt.preventDefault();
28262 }
28263 };
28264
28265 LinkTracker.prototype.after_track_handler = function(props, options) {
28266 if (options.new_tab) { return; }
28267
28268 setTimeout(function() {
28269 window.location = options.href;
28270 }, 0);
28271 };
28272
28273 /**
28274 * FormTracker Object
28275 * @constructor
28276 * @extends DomTracker
28277 */
28278 var FormTracker = function() {
28279 this.override_event = 'submit';
28280 };
28281 _.inherit(FormTracker, DomTracker);
28282
28283 FormTracker.prototype.event_handler = function(evt, element, options) {
28284 options.element = element;
28285 evt.preventDefault();
28286 };
28287
28288 FormTracker.prototype.after_track_handler = function(props, options) {
28289 setTimeout(function() {
28290 options.element.submit();
28291 }, 0);
28292 };
28293
28294 /* eslint camelcase: "off" */
28295
28296
28297 /** @const */ var SET_ACTION = '$set';
28298 /** @const */ var SET_ONCE_ACTION = '$set_once';
28299 /** @const */ var UNSET_ACTION = '$unset';
28300 /** @const */ var ADD_ACTION = '$add';
28301 /** @const */ var APPEND_ACTION = '$append';
28302 /** @const */ var UNION_ACTION = '$union';
28303 /** @const */ var REMOVE_ACTION = '$remove';
28304 /** @const */ var DELETE_ACTION = '$delete';
28305
28306 // Common internal methods for mixpanel.people and mixpanel.group APIs.
28307 // These methods shouldn't involve network I/O.
28308 var apiActions = {
28309 set_action: function(prop, to) {
28310 var data = {};
28311 var $set = {};
28312 if (_.isObject(prop)) {
28313 _.each(prop, function(v, k) {
28314 if (!this._is_reserved_property(k)) {
28315 $set[k] = v;
28316 }
28317 }, this);
28318 } else {
28319 $set[prop] = to;
28320 }
28321
28322 data[SET_ACTION] = $set;
28323 return data;
28324 },
28325
28326 unset_action: function(prop) {
28327 var data = {};
28328 var $unset = [];
28329 if (!_.isArray(prop)) {
28330 prop = [prop];
28331 }
28332
28333 _.each(prop, function(k) {
28334 if (!this._is_reserved_property(k)) {
28335 $unset.push(k);
28336 }
28337 }, this);
28338
28339 data[UNSET_ACTION] = $unset;
28340 return data;
28341 },
28342
28343 set_once_action: function(prop, to) {
28344 var data = {};
28345 var $set_once = {};
28346 if (_.isObject(prop)) {
28347 _.each(prop, function(v, k) {
28348 if (!this._is_reserved_property(k)) {
28349 $set_once[k] = v;
28350 }
28351 }, this);
28352 } else {
28353 $set_once[prop] = to;
28354 }
28355 data[SET_ONCE_ACTION] = $set_once;
28356 return data;
28357 },
28358
28359 union_action: function(list_name, values) {
28360 var data = {};
28361 var $union = {};
28362 if (_.isObject(list_name)) {
28363 _.each(list_name, function(v, k) {
28364 if (!this._is_reserved_property(k)) {
28365 $union[k] = _.isArray(v) ? v : [v];
28366 }
28367 }, this);
28368 } else {
28369 $union[list_name] = _.isArray(values) ? values : [values];
28370 }
28371 data[UNION_ACTION] = $union;
28372 return data;
28373 },
28374
28375 append_action: function(list_name, value) {
28376 var data = {};
28377 var $append = {};
28378 if (_.isObject(list_name)) {
28379 _.each(list_name, function(v, k) {
28380 if (!this._is_reserved_property(k)) {
28381 $append[k] = v;
28382 }
28383 }, this);
28384 } else {
28385 $append[list_name] = value;
28386 }
28387 data[APPEND_ACTION] = $append;
28388 return data;
28389 },
28390
28391 remove_action: function(list_name, value) {
28392 var data = {};
28393 var $remove = {};
28394 if (_.isObject(list_name)) {
28395 _.each(list_name, function(v, k) {
28396 if (!this._is_reserved_property(k)) {
28397 $remove[k] = v;
28398 }
28399 }, this);
28400 } else {
28401 $remove[list_name] = value;
28402 }
28403 data[REMOVE_ACTION] = $remove;
28404 return data;
28405 },
28406
28407 delete_action: function() {
28408 var data = {};
28409 data[DELETE_ACTION] = '';
28410 return data;
28411 }
28412 };
28413
28414 /* eslint camelcase: "off" */
28415
28416 /**
28417 * Mixpanel Group Object
28418 * @constructor
28419 */
28420 var MixpanelGroup = function() {};
28421
28422 _.extend(MixpanelGroup.prototype, apiActions);
28423
28424 MixpanelGroup.prototype._init = function(mixpanel_instance, group_key, group_id) {
28425 this._mixpanel = mixpanel_instance;
28426 this._group_key = group_key;
28427 this._group_id = group_id;
28428 };
28429
28430 /**
28431 * Set properties on a group.
28432 *
28433 * ### Usage:
28434 *
28435 * mixpanel.get_group('company', 'mixpanel').set('Location', '405 Howard');
28436 *
28437 * // or set multiple properties at once
28438 * mixpanel.get_group('company', 'mixpanel').set({
28439 * 'Location': '405 Howard',
28440 * 'Founded' : 2009,
28441 * });
28442 * // properties can be strings, integers, dates, or lists
28443 *
28444 * @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.
28445 * @param {*} [to] A value to set on the given property name
28446 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28447 */
28448 MixpanelGroup.prototype.set = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28449 var data = this.set_action(prop, to);
28450 if (_.isObject(prop)) {
28451 callback = to;
28452 }
28453 return this._send_request(data, callback);
28454 });
28455
28456 /**
28457 * Set properties on a group, only if they do not yet exist.
28458 * This will not overwrite previous group property values, unlike
28459 * group.set().
28460 *
28461 * ### Usage:
28462 *
28463 * mixpanel.get_group('company', 'mixpanel').set_once('Location', '405 Howard');
28464 *
28465 * // or set multiple properties at once
28466 * mixpanel.get_group('company', 'mixpanel').set_once({
28467 * 'Location': '405 Howard',
28468 * 'Founded' : 2009,
28469 * });
28470 * // properties can be strings, integers, lists or dates
28471 *
28472 * @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.
28473 * @param {*} [to] A value to set on the given property name
28474 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28475 */
28476 MixpanelGroup.prototype.set_once = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28477 var data = this.set_once_action(prop, to);
28478 if (_.isObject(prop)) {
28479 callback = to;
28480 }
28481 return this._send_request(data, callback);
28482 });
28483
28484 /**
28485 * Unset properties on a group permanently.
28486 *
28487 * ### Usage:
28488 *
28489 * mixpanel.get_group('company', 'mixpanel').unset('Founded');
28490 *
28491 * @param {String} prop The name of the property.
28492 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28493 */
28494 MixpanelGroup.prototype.unset = addOptOutCheckMixpanelGroup(function(prop, callback) {
28495 var data = this.unset_action(prop);
28496 return this._send_request(data, callback);
28497 });
28498
28499 /**
28500 * Merge a given list with a list-valued group property, excluding duplicate values.
28501 *
28502 * ### Usage:
28503 *
28504 * // merge a value to a list, creating it if needed
28505 * mixpanel.get_group('company', 'mixpanel').union('Location', ['San Francisco', 'London']);
28506 *
28507 * @param {String} list_name Name of the property.
28508 * @param {Array} values Values to merge with the given property
28509 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28510 */
28511 MixpanelGroup.prototype.union = addOptOutCheckMixpanelGroup(function(list_name, values, callback) {
28512 if (_.isObject(list_name)) {
28513 callback = values;
28514 }
28515 var data = this.union_action(list_name, values);
28516 return this._send_request(data, callback);
28517 });
28518
28519 /**
28520 * Permanently delete a group.
28521 *
28522 * ### Usage:
28523 *
28524 * mixpanel.get_group('company', 'mixpanel').delete();
28525 *
28526 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28527 */
28528 MixpanelGroup.prototype['delete'] = addOptOutCheckMixpanelGroup(function(callback) {
28529 // bracket notation above prevents a minification error related to reserved words
28530 var data = this.delete_action();
28531 return this._send_request(data, callback);
28532 });
28533
28534 /**
28535 * Remove a property from a group. The value will be ignored if doesn't exist.
28536 *
28537 * ### Usage:
28538 *
28539 * mixpanel.get_group('company', 'mixpanel').remove('Location', 'London');
28540 *
28541 * @param {String} list_name Name of the property.
28542 * @param {Object} value Value to remove from the given group property
28543 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28544 */
28545 MixpanelGroup.prototype.remove = addOptOutCheckMixpanelGroup(function(list_name, value, callback) {
28546 var data = this.remove_action(list_name, value);
28547 return this._send_request(data, callback);
28548 });
28549
28550 MixpanelGroup.prototype._send_request = function(data, callback) {
28551 data['$group_key'] = this._group_key;
28552 data['$group_id'] = this._group_id;
28553 data['$token'] = this._get_config('token');
28554
28555 var date_encoded_data = _.encodeDates(data);
28556 return this._mixpanel._track_or_batch({
28557 type: 'groups',
28558 data: date_encoded_data,
28559 endpoint: this._mixpanel.get_api_host('groups') + '/' + this._get_config('api_routes')['groups'],
28560 batcher: this._mixpanel.request_batchers.groups
28561 }, callback);
28562 };
28563
28564 MixpanelGroup.prototype._is_reserved_property = function(prop) {
28565 return prop === '$group_key' || prop === '$group_id';
28566 };
28567
28568 MixpanelGroup.prototype._get_config = function(conf) {
28569 return this._mixpanel.get_config(conf);
28570 };
28571
28572 MixpanelGroup.prototype.toString = function() {
28573 return this._mixpanel.toString() + '.group.' + this._group_key + '.' + this._group_id;
28574 };
28575
28576 // MixpanelGroup Exports
28577 MixpanelGroup.prototype['remove'] = MixpanelGroup.prototype.remove;
28578 MixpanelGroup.prototype['set'] = MixpanelGroup.prototype.set;
28579 MixpanelGroup.prototype['set_once'] = MixpanelGroup.prototype.set_once;
28580 MixpanelGroup.prototype['union'] = MixpanelGroup.prototype.union;
28581 MixpanelGroup.prototype['unset'] = MixpanelGroup.prototype.unset;
28582 MixpanelGroup.prototype['toString'] = MixpanelGroup.prototype.toString;
28583
28584 /* eslint camelcase: "off" */
28585
28586 /**
28587 * Mixpanel People Object
28588 * @constructor
28589 */
28590 var MixpanelPeople = function() {};
28591
28592 _.extend(MixpanelPeople.prototype, apiActions);
28593
28594 MixpanelPeople.prototype._init = function(mixpanel_instance) {
28595 this._mixpanel = mixpanel_instance;
28596 };
28597
28598 /*
28599 * Set properties on a user record.
28600 *
28601 * ### Usage:
28602 *
28603 * mixpanel.people.set('gender', 'm');
28604 *
28605 * // or set multiple properties at once
28606 * mixpanel.people.set({
28607 * 'Company': 'Acme',
28608 * 'Plan': 'Premium',
28609 * 'Upgrade date': new Date()
28610 * });
28611 * // properties can be strings, integers, dates, or lists
28612 *
28613 * @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.
28614 * @param {*} [to] A value to set on the given property name
28615 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28616 */
28617 MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
28618 var data = this.set_action(prop, to);
28619 if (_.isObject(prop)) {
28620 callback = to;
28621 }
28622 // make sure that the referrer info has been updated and saved
28623 if (this._get_config('save_referrer')) {
28624 this._mixpanel['persistence'].update_referrer_info(document.referrer);
28625 }
28626
28627 // update $set object with default people properties
28628 data[SET_ACTION] = _.extend(
28629 {},
28630 _.info.people_properties(),
28631 data[SET_ACTION]
28632 );
28633 return this._send_request(data, callback);
28634 });
28635
28636 /*
28637 * Set properties on a user record, only if they do not yet exist.
28638 * This will not overwrite previous people property values, unlike
28639 * people.set().
28640 *
28641 * ### Usage:
28642 *
28643 * mixpanel.people.set_once('First Login Date', new Date());
28644 *
28645 * // or set multiple properties at once
28646 * mixpanel.people.set_once({
28647 * 'First Login Date': new Date(),
28648 * 'Starting Plan': 'Premium'
28649 * });
28650 *
28651 * // properties can be strings, integers or dates
28652 *
28653 * @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.
28654 * @param {*} [to] A value to set on the given property name
28655 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28656 */
28657 MixpanelPeople.prototype.set_once = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
28658 var data = this.set_once_action(prop, to);
28659 if (_.isObject(prop)) {
28660 callback = to;
28661 }
28662 return this._send_request(data, callback);
28663 });
28664
28665 /*
28666 * Unset properties on a user record (permanently removes the properties and their values from a profile).
28667 *
28668 * ### Usage:
28669 *
28670 * mixpanel.people.unset('gender');
28671 *
28672 * // or unset multiple properties at once
28673 * mixpanel.people.unset(['gender', 'Company']);
28674 *
28675 * @param {Array|String} prop If a string, this is the name of the property. If an array, this is a list of property names.
28676 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28677 */
28678 MixpanelPeople.prototype.unset = addOptOutCheckMixpanelPeople(function(prop, callback) {
28679 var data = this.unset_action(prop);
28680 return this._send_request(data, callback);
28681 });
28682
28683 /*
28684 * Increment/decrement numeric people analytics properties.
28685 *
28686 * ### Usage:
28687 *
28688 * mixpanel.people.increment('page_views', 1);
28689 *
28690 * // or, for convenience, if you're just incrementing a counter by
28691 * // 1, you can simply do
28692 * mixpanel.people.increment('page_views');
28693 *
28694 * // to decrement a counter, pass a negative number
28695 * mixpanel.people.increment('credits_left', -1);
28696 *
28697 * // like mixpanel.people.set(), you can increment multiple
28698 * // properties at once:
28699 * mixpanel.people.increment({
28700 * counter1: 1,
28701 * counter2: 6
28702 * });
28703 *
28704 * @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.
28705 * @param {Number} [by] An amount to increment the given property
28706 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28707 */
28708 MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop, by, callback) {
28709 var data = {};
28710 var $add = {};
28711 if (_.isObject(prop)) {
28712 _.each(prop, function(v, k) {
28713 if (!this._is_reserved_property(k)) {
28714 if (isNaN(parseFloat(v))) {
28715 console$1.error('Invalid increment value passed to mixpanel.people.increment - must be a number');
28716 return;
28717 } else {
28718 $add[k] = v;
28719 }
28720 }
28721 }, this);
28722 callback = by;
28723 } else {
28724 // convenience: mixpanel.people.increment('property'); will
28725 // increment 'property' by 1
28726 if (_.isUndefined(by)) {
28727 by = 1;
28728 }
28729 $add[prop] = by;
28730 }
28731 data[ADD_ACTION] = $add;
28732
28733 return this._send_request(data, callback);
28734 });
28735
28736 /*
28737 * Append a value to a list-valued people analytics property.
28738 *
28739 * ### Usage:
28740 *
28741 * // append a value to a list, creating it if needed
28742 * mixpanel.people.append('pages_visited', 'homepage');
28743 *
28744 * // like mixpanel.people.set(), you can append multiple
28745 * // properties at once:
28746 * mixpanel.people.append({
28747 * list1: 'bob',
28748 * list2: 123
28749 * });
28750 *
28751 * @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.
28752 * @param {*} [value] value An item to append to the list
28753 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28754 */
28755 MixpanelPeople.prototype.append = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
28756 if (_.isObject(list_name)) {
28757 callback = value;
28758 }
28759 var data = this.append_action(list_name, value);
28760 return this._send_request(data, callback);
28761 });
28762
28763 /*
28764 * Remove a value from a list-valued people analytics property.
28765 *
28766 * ### Usage:
28767 *
28768 * mixpanel.people.remove('School', 'UCB');
28769 *
28770 * @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.
28771 * @param {*} [value] value Item to remove from the list
28772 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28773 */
28774 MixpanelPeople.prototype.remove = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
28775 if (_.isObject(list_name)) {
28776 callback = value;
28777 }
28778 var data = this.remove_action(list_name, value);
28779 return this._send_request(data, callback);
28780 });
28781
28782 /*
28783 * Merge a given list with a list-valued people analytics property,
28784 * excluding duplicate values.
28785 *
28786 * ### Usage:
28787 *
28788 * // merge a value to a list, creating it if needed
28789 * mixpanel.people.union('pages_visited', 'homepage');
28790 *
28791 * // like mixpanel.people.set(), you can append multiple
28792 * // properties at once:
28793 * mixpanel.people.union({
28794 * list1: 'bob',
28795 * list2: 123
28796 * });
28797 *
28798 * // like mixpanel.people.append(), you can append multiple
28799 * // values to the same list:
28800 * mixpanel.people.union({
28801 * list1: ['bob', 'billy']
28802 * });
28803 *
28804 * @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.
28805 * @param {*} [value] Value / values to merge with the given property
28806 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28807 */
28808 MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name, values, callback) {
28809 if (_.isObject(list_name)) {
28810 callback = values;
28811 }
28812 var data = this.union_action(list_name, values);
28813 return this._send_request(data, callback);
28814 });
28815
28816 /*
28817 * Record that you have charged the current user a certain amount
28818 * of money. Charges recorded with track_charge() will appear in the
28819 * Mixpanel revenue report.
28820 *
28821 * ### Usage:
28822 *
28823 * // charge a user $50
28824 * mixpanel.people.track_charge(50);
28825 *
28826 * // charge a user $30.50 on the 2nd of january
28827 * mixpanel.people.track_charge(30.50, {
28828 * '$time': new Date('jan 1 2012')
28829 * });
28830 *
28831 * @param {Number} amount The amount of money charged to the current user
28832 * @param {Object} [properties] An associative array of properties associated with the charge
28833 * @param {Function} [callback] If provided, the callback will be called when the server responds
28834 * @deprecated
28835 */
28836 MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
28837 console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
28838 });
28839
28840 /*
28841 * Permanently clear all revenue report transactions from the
28842 * current user's people analytics profile.
28843 *
28844 * ### Usage:
28845 *
28846 * mixpanel.people.clear_charges();
28847 *
28848 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28849 * @deprecated
28850 */
28851 MixpanelPeople.prototype.clear_charges = function(callback) {
28852 return this.set('$transactions', [], callback);
28853 };
28854
28855 /*
28856 * Permanently deletes the current people analytics profile from
28857 * Mixpanel (using the current distinct_id).
28858 *
28859 * ### Usage:
28860 *
28861 * // remove the all data you have stored about the current user
28862 * mixpanel.people.delete_user();
28863 *
28864 */
28865 MixpanelPeople.prototype.delete_user = function() {
28866 if (!this._identify_called()) {
28867 console$1.error('mixpanel.people.delete_user() requires you to call identify() first');
28868 return;
28869 }
28870 var data = {'$delete': this._mixpanel.get_distinct_id()};
28871 return this._send_request(data);
28872 };
28873
28874 MixpanelPeople.prototype.toString = function() {
28875 return this._mixpanel.toString() + '.people';
28876 };
28877
28878 MixpanelPeople.prototype._send_request = function(data, callback) {
28879 data['$token'] = this._get_config('token');
28880 data['$distinct_id'] = this._mixpanel.get_distinct_id();
28881 var device_id = this._mixpanel.get_property('$device_id');
28882 var user_id = this._mixpanel.get_property('$user_id');
28883 var had_persisted_distinct_id = this._mixpanel.get_property('$had_persisted_distinct_id');
28884 if (device_id) {
28885 data['$device_id'] = device_id;
28886 }
28887 if (user_id) {
28888 data['$user_id'] = user_id;
28889 }
28890 if (had_persisted_distinct_id) {
28891 data['$had_persisted_distinct_id'] = had_persisted_distinct_id;
28892 }
28893
28894 var date_encoded_data = _.encodeDates(data);
28895
28896 if (!this._identify_called()) {
28897 this._enqueue(data);
28898 if (!_.isUndefined(callback)) {
28899 if (this._get_config('verbose')) {
28900 callback({status: -1, error: null});
28901 } else {
28902 callback(-1);
28903 }
28904 }
28905 return _.truncate(date_encoded_data, 255);
28906 }
28907
28908 return this._mixpanel._track_or_batch({
28909 type: 'people',
28910 data: date_encoded_data,
28911 endpoint: this._mixpanel.get_api_host('people') + '/' + this._get_config('api_routes')['engage'],
28912 batcher: this._mixpanel.request_batchers.people
28913 }, callback);
28914 };
28915
28916 MixpanelPeople.prototype._get_config = function(conf_var) {
28917 return this._mixpanel.get_config(conf_var);
28918 };
28919
28920 MixpanelPeople.prototype._identify_called = function() {
28921 return this._mixpanel._flags.identify_called === true;
28922 };
28923
28924 // Queue up engage operations if identify hasn't been called yet.
28925 MixpanelPeople.prototype._enqueue = function(data) {
28926 if (SET_ACTION in data) {
28927 this._mixpanel['persistence']._add_to_people_queue(SET_ACTION, data);
28928 } else if (SET_ONCE_ACTION in data) {
28929 this._mixpanel['persistence']._add_to_people_queue(SET_ONCE_ACTION, data);
28930 } else if (UNSET_ACTION in data) {
28931 this._mixpanel['persistence']._add_to_people_queue(UNSET_ACTION, data);
28932 } else if (ADD_ACTION in data) {
28933 this._mixpanel['persistence']._add_to_people_queue(ADD_ACTION, data);
28934 } else if (APPEND_ACTION in data) {
28935 this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, data);
28936 } else if (REMOVE_ACTION in data) {
28937 this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, data);
28938 } else if (UNION_ACTION in data) {
28939 this._mixpanel['persistence']._add_to_people_queue(UNION_ACTION, data);
28940 } else {
28941 console$1.error('Invalid call to _enqueue():', data);
28942 }
28943 };
28944
28945 MixpanelPeople.prototype._flush_one_queue = function(action, action_method, callback, queue_to_params_fn) {
28946 var _this = this;
28947 var queued_data = _.extend({}, this._mixpanel['persistence'].load_queue(action));
28948 var action_params = queued_data;
28949
28950 if (!_.isUndefined(queued_data) && _.isObject(queued_data) && !_.isEmptyObject(queued_data)) {
28951 _this._mixpanel['persistence']._pop_from_people_queue(action, queued_data);
28952 _this._mixpanel['persistence'].save();
28953 if (queue_to_params_fn) {
28954 action_params = queue_to_params_fn(queued_data);
28955 }
28956 action_method.call(_this, action_params, function(response, data) {
28957 // on bad response, we want to add it back to the queue
28958 if (response === 0) {
28959 _this._mixpanel['persistence']._add_to_people_queue(action, queued_data);
28960 }
28961 if (!_.isUndefined(callback)) {
28962 callback(response, data);
28963 }
28964 });
28965 }
28966 };
28967
28968 // Flush queued engage operations - order does not matter,
28969 // and there are network level race conditions anyway
28970 MixpanelPeople.prototype._flush = function(
28971 _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
28972 ) {
28973 var _this = this;
28974
28975 this._flush_one_queue(SET_ACTION, this.set, _set_callback);
28976 this._flush_one_queue(SET_ONCE_ACTION, this.set_once, _set_once_callback);
28977 this._flush_one_queue(UNSET_ACTION, this.unset, _unset_callback, function(queue) { return _.keys(queue); });
28978 this._flush_one_queue(ADD_ACTION, this.increment, _add_callback);
28979 this._flush_one_queue(UNION_ACTION, this.union, _union_callback);
28980
28981 // we have to fire off each $append individually since there is
28982 // no concat method server side
28983 var $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
28984 if (!_.isUndefined($append_queue) && _.isArray($append_queue) && $append_queue.length) {
28985 var $append_item;
28986 var append_callback = function(response, data) {
28987 if (response === 0) {
28988 _this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, $append_item);
28989 }
28990 if (!_.isUndefined(_append_callback)) {
28991 _append_callback(response, data);
28992 }
28993 };
28994 for (var i = $append_queue.length - 1; i >= 0; i--) {
28995 $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
28996 $append_item = $append_queue.pop();
28997 _this._mixpanel['persistence'].save();
28998 if (!_.isEmptyObject($append_item)) {
28999 _this.append($append_item, append_callback);
29000 }
29001 }
29002 }
29003
29004 // same for $remove
29005 var $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29006 if (!_.isUndefined($remove_queue) && _.isArray($remove_queue) && $remove_queue.length) {
29007 var $remove_item;
29008 var remove_callback = function(response, data) {
29009 if (response === 0) {
29010 _this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, $remove_item);
29011 }
29012 if (!_.isUndefined(_remove_callback)) {
29013 _remove_callback(response, data);
29014 }
29015 };
29016 for (var j = $remove_queue.length - 1; j >= 0; j--) {
29017 $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29018 $remove_item = $remove_queue.pop();
29019 _this._mixpanel['persistence'].save();
29020 if (!_.isEmptyObject($remove_item)) {
29021 _this.remove($remove_item, remove_callback);
29022 }
29023 }
29024 }
29025 };
29026
29027 MixpanelPeople.prototype._is_reserved_property = function(prop) {
29028 return prop === '$distinct_id' || prop === '$token' || prop === '$device_id' || prop === '$user_id' || prop === '$had_persisted_distinct_id';
29029 };
29030
29031 // MixpanelPeople Exports
29032 MixpanelPeople.prototype['set'] = MixpanelPeople.prototype.set;
29033 MixpanelPeople.prototype['set_once'] = MixpanelPeople.prototype.set_once;
29034 MixpanelPeople.prototype['unset'] = MixpanelPeople.prototype.unset;
29035 MixpanelPeople.prototype['increment'] = MixpanelPeople.prototype.increment;
29036 MixpanelPeople.prototype['append'] = MixpanelPeople.prototype.append;
29037 MixpanelPeople.prototype['remove'] = MixpanelPeople.prototype.remove;
29038 MixpanelPeople.prototype['union'] = MixpanelPeople.prototype.union;
29039 MixpanelPeople.prototype['track_charge'] = MixpanelPeople.prototype.track_charge;
29040 MixpanelPeople.prototype['clear_charges'] = MixpanelPeople.prototype.clear_charges;
29041 MixpanelPeople.prototype['delete_user'] = MixpanelPeople.prototype.delete_user;
29042 MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
29043
29044 /* eslint camelcase: "off" */
29045
29046
29047 /*
29048 * Constants
29049 */
29050 /** @const */ var SET_QUEUE_KEY = '__mps';
29051 /** @const */ var SET_ONCE_QUEUE_KEY = '__mpso';
29052 /** @const */ var UNSET_QUEUE_KEY = '__mpus';
29053 /** @const */ var ADD_QUEUE_KEY = '__mpa';
29054 /** @const */ var APPEND_QUEUE_KEY = '__mpap';
29055 /** @const */ var REMOVE_QUEUE_KEY = '__mpr';
29056 /** @const */ var UNION_QUEUE_KEY = '__mpu';
29057 // This key is deprecated, but we want to check for it to see whether aliasing is allowed.
29058 /** @const */ var PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id';
29059 /** @const */ var ALIAS_ID_KEY = '__alias';
29060 /** @const */ var EVENT_TIMERS_KEY = '__timers';
29061 /** @const */ var RESERVED_PROPERTIES = [
29062 SET_QUEUE_KEY,
29063 SET_ONCE_QUEUE_KEY,
29064 UNSET_QUEUE_KEY,
29065 ADD_QUEUE_KEY,
29066 APPEND_QUEUE_KEY,
29067 REMOVE_QUEUE_KEY,
29068 UNION_QUEUE_KEY,
29069 PEOPLE_DISTINCT_ID_KEY,
29070 ALIAS_ID_KEY,
29071 EVENT_TIMERS_KEY
29072 ];
29073
29074 /**
29075 * Mixpanel Persistence Object
29076 * @constructor
29077 */
29078 var MixpanelPersistence = function(config) {
29079 this['props'] = {};
29080 this.campaign_params_saved = false;
29081
29082 if (config['persistence_name']) {
29083 this.name = 'mp_' + config['persistence_name'];
29084 } else {
29085 this.name = 'mp_' + config['token'] + '_mixpanel';
29086 }
29087
29088 var storage_type = config['persistence'];
29089 if (storage_type !== 'cookie' && storage_type !== 'localStorage') {
29090 console$1.critical('Unknown persistence type ' + storage_type + '; falling back to cookie');
29091 storage_type = config['persistence'] = 'cookie';
29092 }
29093
29094 if (storage_type === 'localStorage' && _.localStorage.is_supported()) {
29095 this.storage = _.localStorage;
29096 } else {
29097 this.storage = _.cookie;
29098 }
29099
29100 this.load();
29101 this.update_config(config);
29102 this.upgrade();
29103 this.save();
29104 };
29105
29106 MixpanelPersistence.prototype.properties = function() {
29107 var p = {};
29108
29109 this.load();
29110
29111 // Filter out reserved properties
29112 _.each(this['props'], function(v, k) {
29113 if (!_.include(RESERVED_PROPERTIES, k)) {
29114 p[k] = v;
29115 }
29116 });
29117 return p;
29118 };
29119
29120 MixpanelPersistence.prototype.load = function() {
29121 if (this.disabled) { return; }
29122
29123 var entry = this.storage.parse(this.name);
29124
29125 if (entry) {
29126 this['props'] = _.extend({}, entry);
29127 }
29128 };
29129
29130 MixpanelPersistence.prototype.upgrade = function() {
29131 var old_cookie,
29132 old_localstorage;
29133
29134 // if transferring from cookie to localStorage or vice-versa, copy existing
29135 // super properties over to new storage mode
29136 if (this.storage === _.localStorage) {
29137 old_cookie = _.cookie.parse(this.name);
29138
29139 _.cookie.remove(this.name);
29140 _.cookie.remove(this.name, true);
29141
29142 if (old_cookie) {
29143 this.register_once(old_cookie);
29144 }
29145 } else if (this.storage === _.cookie) {
29146 old_localstorage = _.localStorage.parse(this.name);
29147
29148 _.localStorage.remove(this.name);
29149
29150 if (old_localstorage) {
29151 this.register_once(old_localstorage);
29152 }
29153 }
29154 };
29155
29156 MixpanelPersistence.prototype.save = function() {
29157 if (this.disabled) { return; }
29158
29159 this.storage.set(
29160 this.name,
29161 JSONStringify(this['props']),
29162 this.expire_days,
29163 this.cross_subdomain,
29164 this.secure,
29165 this.cross_site,
29166 this.cookie_domain
29167 );
29168 };
29169
29170 MixpanelPersistence.prototype.load_prop = function(key) {
29171 this.load();
29172 return this['props'][key];
29173 };
29174
29175 MixpanelPersistence.prototype.remove = function() {
29176 // remove both domain and subdomain cookies
29177 this.storage.remove(this.name, false, this.cookie_domain);
29178 this.storage.remove(this.name, true, this.cookie_domain);
29179 };
29180
29181 // removes the storage entry and deletes all loaded data
29182 // forced name for tests
29183 MixpanelPersistence.prototype.clear = function() {
29184 this.remove();
29185 this['props'] = {};
29186 };
29187
29188 /**
29189 * @param {Object} props
29190 * @param {*=} default_value
29191 * @param {number=} days
29192 */
29193 MixpanelPersistence.prototype.register_once = function(props, default_value, days) {
29194 if (_.isObject(props)) {
29195 if (typeof(default_value) === 'undefined') { default_value = 'None'; }
29196 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29197
29198 this.load();
29199
29200 _.each(props, function(val, prop) {
29201 if (!this['props'].hasOwnProperty(prop) || this['props'][prop] === default_value) {
29202 this['props'][prop] = val;
29203 }
29204 }, this);
29205
29206 this.save();
29207
29208 return true;
29209 }
29210 return false;
29211 };
29212
29213 /**
29214 * @param {Object} props
29215 * @param {number=} days
29216 */
29217 MixpanelPersistence.prototype.register = function(props, days) {
29218 if (_.isObject(props)) {
29219 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29220
29221 this.load();
29222 _.extend(this['props'], props);
29223 this.save();
29224
29225 return true;
29226 }
29227 return false;
29228 };
29229
29230 MixpanelPersistence.prototype.unregister = function(prop) {
29231 this.load();
29232 if (prop in this['props']) {
29233 delete this['props'][prop];
29234 this.save();
29235 }
29236 };
29237
29238 MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
29239 this.register(_.info.searchInfo(referrer));
29240 };
29241
29242 // EXPORTED METHOD, we test this directly.
29243 MixpanelPersistence.prototype.update_referrer_info = function(referrer) {
29244 // If referrer doesn't exist, we want to note the fact that it was type-in traffic.
29245 this.register_once({
29246 '$initial_referrer': referrer || '$direct',
29247 '$initial_referring_domain': _.info.referringDomain(referrer) || '$direct'
29248 }, '');
29249 };
29250
29251 MixpanelPersistence.prototype.get_referrer_info = function() {
29252 return _.strip_empty_properties({
29253 '$initial_referrer': this['props']['$initial_referrer'],
29254 '$initial_referring_domain': this['props']['$initial_referring_domain']
29255 });
29256 };
29257
29258 MixpanelPersistence.prototype.update_config = function(config) {
29259 this.default_expiry = this.expire_days = config['cookie_expiration'];
29260 this.set_disabled(config['disable_persistence']);
29261 this.set_cookie_domain(config['cookie_domain']);
29262 this.set_cross_site(config['cross_site_cookie']);
29263 this.set_cross_subdomain(config['cross_subdomain_cookie']);
29264 this.set_secure(config['secure_cookie']);
29265 };
29266
29267 MixpanelPersistence.prototype.set_disabled = function(disabled) {
29268 this.disabled = disabled;
29269 if (this.disabled) {
29270 this.remove();
29271 } else {
29272 this.save();
29273 }
29274 };
29275
29276 MixpanelPersistence.prototype.set_cookie_domain = function(cookie_domain) {
29277 if (cookie_domain !== this.cookie_domain) {
29278 this.remove();
29279 this.cookie_domain = cookie_domain;
29280 this.save();
29281 }
29282 };
29283
29284 MixpanelPersistence.prototype.set_cross_site = function(cross_site) {
29285 if (cross_site !== this.cross_site) {
29286 this.cross_site = cross_site;
29287 this.remove();
29288 this.save();
29289 }
29290 };
29291
29292 MixpanelPersistence.prototype.set_cross_subdomain = function(cross_subdomain) {
29293 if (cross_subdomain !== this.cross_subdomain) {
29294 this.cross_subdomain = cross_subdomain;
29295 this.remove();
29296 this.save();
29297 }
29298 };
29299
29300 MixpanelPersistence.prototype.get_cross_subdomain = function() {
29301 return this.cross_subdomain;
29302 };
29303
29304 MixpanelPersistence.prototype.set_secure = function(secure) {
29305 if (secure !== this.secure) {
29306 this.secure = secure ? true : false;
29307 this.remove();
29308 this.save();
29309 }
29310 };
29311
29312 MixpanelPersistence.prototype._add_to_people_queue = function(queue, data) {
29313 var q_key = this._get_queue_key(queue),
29314 q_data = data[queue],
29315 set_q = this._get_or_create_queue(SET_ACTION),
29316 set_once_q = this._get_or_create_queue(SET_ONCE_ACTION),
29317 unset_q = this._get_or_create_queue(UNSET_ACTION),
29318 add_q = this._get_or_create_queue(ADD_ACTION),
29319 union_q = this._get_or_create_queue(UNION_ACTION),
29320 remove_q = this._get_or_create_queue(REMOVE_ACTION, []),
29321 append_q = this._get_or_create_queue(APPEND_ACTION, []);
29322
29323 if (q_key === SET_QUEUE_KEY) {
29324 // Update the set queue - we can override any existing values
29325 _.extend(set_q, q_data);
29326 // if there was a pending increment, override it
29327 // with the set.
29328 this._pop_from_people_queue(ADD_ACTION, q_data);
29329 // if there was a pending union, override it
29330 // with the set.
29331 this._pop_from_people_queue(UNION_ACTION, q_data);
29332 this._pop_from_people_queue(UNSET_ACTION, q_data);
29333 } else if (q_key === SET_ONCE_QUEUE_KEY) {
29334 // only queue the data if there is not already a set_once call for it.
29335 _.each(q_data, function(v, k) {
29336 if (!(k in set_once_q)) {
29337 set_once_q[k] = v;
29338 }
29339 });
29340 this._pop_from_people_queue(UNSET_ACTION, q_data);
29341 } else if (q_key === UNSET_QUEUE_KEY) {
29342 _.each(q_data, function(prop) {
29343
29344 // undo previously-queued actions on this key
29345 _.each([set_q, set_once_q, add_q, union_q], function(enqueued_obj) {
29346 if (prop in enqueued_obj) {
29347 delete enqueued_obj[prop];
29348 }
29349 });
29350 _.each(append_q, function(append_obj) {
29351 if (prop in append_obj) {
29352 delete append_obj[prop];
29353 }
29354 });
29355
29356 unset_q[prop] = true;
29357
29358 });
29359 } else if (q_key === ADD_QUEUE_KEY) {
29360 _.each(q_data, function(v, k) {
29361 // If it exists in the set queue, increment
29362 // the value
29363 if (k in set_q) {
29364 set_q[k] += v;
29365 } else {
29366 // If it doesn't exist, update the add
29367 // queue
29368 if (!(k in add_q)) {
29369 add_q[k] = 0;
29370 }
29371 add_q[k] += v;
29372 }
29373 }, this);
29374 this._pop_from_people_queue(UNSET_ACTION, q_data);
29375 } else if (q_key === UNION_QUEUE_KEY) {
29376 _.each(q_data, function(v, k) {
29377 if (_.isArray(v)) {
29378 if (!(k in union_q)) {
29379 union_q[k] = [];
29380 }
29381 // Prevent duplicate values
29382 _.each(v, function(item) {
29383 if (!_.include(union_q[k], item)) {
29384 union_q[k].push(item);
29385 }
29386 });
29387 }
29388 });
29389 this._pop_from_people_queue(UNSET_ACTION, q_data);
29390 } else if (q_key === REMOVE_QUEUE_KEY) {
29391 remove_q.push(q_data);
29392 this._pop_from_people_queue(APPEND_ACTION, q_data);
29393 } else if (q_key === APPEND_QUEUE_KEY) {
29394 append_q.push(q_data);
29395 this._pop_from_people_queue(UNSET_ACTION, q_data);
29396 }
29397
29398 console$1.log('MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):');
29399 console$1.log(data);
29400
29401 this.save();
29402 };
29403
29404 MixpanelPersistence.prototype._pop_from_people_queue = function(queue, data) {
29405 var q = this['props'][this._get_queue_key(queue)];
29406 if (!_.isUndefined(q)) {
29407 _.each(data, function(v, k) {
29408 if (queue === APPEND_ACTION || queue === REMOVE_ACTION) {
29409 // list actions: only remove if both k+v match
29410 // e.g. remove should not override append in a case like
29411 // append({foo: 'bar'}); remove({foo: 'qux'})
29412 _.each(q, function(queued_action) {
29413 if (queued_action[k] === v) {
29414 delete queued_action[k];
29415 }
29416 });
29417 } else {
29418 delete q[k];
29419 }
29420 }, this);
29421 }
29422 };
29423
29424 MixpanelPersistence.prototype.load_queue = function(queue) {
29425 return this.load_prop(this._get_queue_key(queue));
29426 };
29427
29428 MixpanelPersistence.prototype._get_queue_key = function(queue) {
29429 if (queue === SET_ACTION) {
29430 return SET_QUEUE_KEY;
29431 } else if (queue === SET_ONCE_ACTION) {
29432 return SET_ONCE_QUEUE_KEY;
29433 } else if (queue === UNSET_ACTION) {
29434 return UNSET_QUEUE_KEY;
29435 } else if (queue === ADD_ACTION) {
29436 return ADD_QUEUE_KEY;
29437 } else if (queue === APPEND_ACTION) {
29438 return APPEND_QUEUE_KEY;
29439 } else if (queue === REMOVE_ACTION) {
29440 return REMOVE_QUEUE_KEY;
29441 } else if (queue === UNION_ACTION) {
29442 return UNION_QUEUE_KEY;
29443 } else {
29444 console$1.error('Invalid queue:', queue);
29445 }
29446 };
29447
29448 MixpanelPersistence.prototype._get_or_create_queue = function(queue, default_val) {
29449 var key = this._get_queue_key(queue);
29450 default_val = _.isUndefined(default_val) ? {} : default_val;
29451 return this['props'][key] || (this['props'][key] = default_val);
29452 };
29453
29454 MixpanelPersistence.prototype.set_event_timer = function(event_name, timestamp) {
29455 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29456 timers[event_name] = timestamp;
29457 this['props'][EVENT_TIMERS_KEY] = timers;
29458 this.save();
29459 };
29460
29461 MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
29462 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29463 var timestamp = timers[event_name];
29464 if (!_.isUndefined(timestamp)) {
29465 delete this['props'][EVENT_TIMERS_KEY][event_name];
29466 this.save();
29467 }
29468 return timestamp;
29469 };
29470
29471 /* eslint camelcase: "off" */
29472
29473 /*
29474 * Mixpanel JS Library
29475 *
29476 * Copyright 2012, Mixpanel, Inc. All Rights Reserved
29477 * http://mixpanel.com/
29478 *
29479 * Includes portions of Underscore.js
29480 * http://documentcloud.github.com/underscore/
29481 * (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
29482 * Released under the MIT License.
29483 */
29484
29485 /*
29486 SIMPLE STYLE GUIDE:
29487
29488 this.x === public function
29489 this._x === internal - only use within this file
29490 this.__x === private - only use within the class
29491
29492 Globals should be all caps
29493 */
29494
29495 var init_type; // MODULE or SNIPPET loader
29496 // allow bundlers to specify how extra code (recorder bundle) should be loaded
29497 // eslint-disable-next-line no-unused-vars
29498 var load_extra_bundle = function(src, _onload) {
29499 throw new Error(src + ' not available in this build.');
29500 };
29501
29502 var mixpanel_master; // main mixpanel instance / object
29503 var INIT_MODULE = 0;
29504 var INIT_SNIPPET = 1;
29505
29506 var IDENTITY_FUNC = function(x) {return x;};
29507
29508 /** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
29509 /** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
29510 /** @const */ var PAYLOAD_TYPE_JSON = 'json';
29511 /** @const */ var DEVICE_ID_PREFIX = '$device:';
29512
29513
29514 /*
29515 * Dynamic... constants? Is that an oxymoron?
29516 */
29517 // http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
29518 // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#withCredentials
29519 var USE_XHR = (win.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest());
29520
29521 // IE<10 does not support cross-origin XHR's but script tags
29522 // with defer won't block window.onload; ENQUEUE_REQUESTS
29523 // should only be true for Opera<12
29524 var ENQUEUE_REQUESTS = !USE_XHR && (userAgent.indexOf('MSIE') === -1) && (userAgent.indexOf('Mozilla') === -1);
29525
29526 // save reference to navigator.sendBeacon so it can be minified
29527 var sendBeacon = null;
29528 if (navigator['sendBeacon']) {
29529 sendBeacon = function() {
29530 // late reference to navigator.sendBeacon to allow patching/spying
29531 return navigator['sendBeacon'].apply(navigator, arguments);
29532 };
29533 }
29534
29535 var DEFAULT_API_ROUTES = {
29536 'track': 'track/',
29537 'engage': 'engage/',
29538 'groups': 'groups/',
29539 'record': 'record/',
29540 'flags': 'flags/'
29541 };
29542
29543 /*
29544 * Module-level globals
29545 */
29546 var DEFAULT_CONFIG = {
29547 'api_host': 'https://api-js.mixpanel.com',
29548 'api_hosts': {},
29549 'api_routes': DEFAULT_API_ROUTES,
29550 'api_extra_query_params': {},
29551 'api_method': 'POST',
29552 'api_transport': 'XHR',
29553 'api_payload_format': PAYLOAD_TYPE_BASE64,
29554 'app_host': 'https://mixpanel.com',
29555 'autocapture': false,
29556 'cdn': 'https://cdn.mxpnl.com',
29557 'cross_site_cookie': false,
29558 'cross_subdomain_cookie': true,
29559 'error_reporter': NOOP_FUNC,
29560 'flags': false,
29561 'persistence': 'cookie',
29562 'persistence_name': '',
29563 'cookie_domain': '',
29564 'cookie_name': '',
29565 'loaded': NOOP_FUNC,
29566 'mp_loader': null,
29567 'track_marketing': true,
29568 'track_pageview': false,
29569 'skip_first_touch_marketing': false,
29570 'store_google': true,
29571 'stop_utm_persistence': false,
29572 'save_referrer': true,
29573 'test': false,
29574 'verbose': false,
29575 'img': false,
29576 'debug': false,
29577 'track_links_timeout': 300,
29578 'cookie_expiration': 365,
29579 'upgrade': false,
29580 'disable_persistence': false,
29581 'disable_cookie': false,
29582 'secure_cookie': false,
29583 'ip': true,
29584 'opt_out_tracking_by_default': false,
29585 'opt_out_persistence_by_default': false,
29586 'opt_out_tracking_persistence_type': 'localStorage',
29587 'opt_out_tracking_cookie_prefix': null,
29588 'property_blacklist': [],
29589 'xhr_headers': {}, // { header: value, header2: value }
29590 'ignore_dnt': false,
29591 'batch_requests': true,
29592 'batch_size': 50,
29593 'batch_flush_interval_ms': 5000,
29594 'batch_request_timeout_ms': 90000,
29595 'batch_autostart': true,
29596 'hooks': {},
29597 'record_block_class': new RegExp('^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$'),
29598 'record_block_selector': 'img, video, audio',
29599 'record_canvas': false,
29600 'record_collect_fonts': false,
29601 'record_heatmap_data': false,
29602 'record_idle_timeout_ms': 30 * 60 * 1000, // 30 minutes
29603 'record_mask_text_class': new RegExp('^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$'),
29604 'record_mask_text_selector': '*',
29605 'record_max_ms': MAX_RECORDING_MS,
29606 'record_min_ms': 0,
29607 'record_sessions_percent': 0,
29608 'recorder_src': 'https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js'
29609 };
29610
29611 var DOM_LOADED = false;
29612
29613 /**
29614 * Mixpanel Library Object
29615 * @constructor
29616 */
29617 var MixpanelLib = function() {};
29618
29619
29620 /**
29621 * create_mplib(token:string, config:object, name:string)
29622 *
29623 * This function is used by the init method of MixpanelLib objects
29624 * as well as the main initializer at the end of the JSLib (that
29625 * initializes document.mixpanel as well as any additional instances
29626 * declared before this file has loaded).
29627 */
29628 var create_mplib = function(token, config, name) {
29629 var instance,
29630 target = (name === PRIMARY_INSTANCE_NAME) ? mixpanel_master : mixpanel_master[name];
29631
29632 if (target && init_type === INIT_MODULE) {
29633 instance = target;
29634 } else {
29635 if (target && !_.isArray(target)) {
29636 console$1.error('You have already initialized ' + name);
29637 return;
29638 }
29639 instance = new MixpanelLib();
29640 }
29641
29642 instance._cached_groups = {}; // cache groups in a pool
29643
29644 instance._init(token, config, name);
29645
29646 instance['people'] = new MixpanelPeople();
29647 instance['people']._init(instance);
29648
29649 if (!instance.get_config('skip_first_touch_marketing')) {
29650 // We need null UTM params in the object because
29651 // UTM parameters act as a tuple. If any UTM param
29652 // is present, then we set all UTM params including
29653 // empty ones together
29654 var utm_params = _.info.campaignParams(null);
29655 var initial_utm_params = {};
29656 var has_utm = false;
29657 _.each(utm_params, function(utm_value, utm_key) {
29658 initial_utm_params['initial_' + utm_key] = utm_value;
29659 if (utm_value) {
29660 has_utm = true;
29661 }
29662 });
29663 if (has_utm) {
29664 instance['people'].set_once(initial_utm_params);
29665 }
29666 }
29667
29668 // if any instance on the page has debug = true, we set the
29669 // global debug to be true
29670 Config.DEBUG = Config.DEBUG || instance.get_config('debug');
29671
29672 // if target is not defined, we called init after the lib already
29673 // loaded, so there won't be an array of things to execute
29674 if (!_.isUndefined(target) && _.isArray(target)) {
29675 // Crunch through the people queue first - we queue this data up &
29676 // flush on identify, so it's better to do all these operations first
29677 instance._execute_array.call(instance['people'], target['people']);
29678 instance._execute_array(target);
29679 }
29680
29681 return instance;
29682 };
29683
29684 // Initialization methods
29685
29686 /**
29687 * This function initializes a new instance of the Mixpanel tracking object.
29688 * All new instances are added to the main mixpanel object as sub properties (such as
29689 * mixpanel.library_name) and also returned by this function. To define a
29690 * second instance on the page, you would call:
29691 *
29692 * mixpanel.init('new token', { your: 'config' }, 'library_name');
29693 *
29694 * and use it like so:
29695 *
29696 * mixpanel.library_name.track(...);
29697 *
29698 * @param {String} token Your Mixpanel API token
29699 * @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>.
29700 * @param {String} [name] The name for the new mixpanel instance that you want created
29701 */
29702 MixpanelLib.prototype.init = function (token, config, name) {
29703 if (_.isUndefined(name)) {
29704 this.report_error('You must name your new library: init(token, config, name)');
29705 return;
29706 }
29707 if (name === PRIMARY_INSTANCE_NAME) {
29708 this.report_error('You must initialize the main mixpanel object right after you include the Mixpanel js snippet');
29709 return;
29710 }
29711
29712 var instance = create_mplib(token, config, name);
29713 mixpanel_master[name] = instance;
29714 instance._loaded();
29715
29716 return instance;
29717 };
29718
29719 // mixpanel._init(token:string, config:object, name:string)
29720 //
29721 // This function sets up the current instance of the mixpanel
29722 // library. The difference between this method and the init(...)
29723 // method is this one initializes the actual instance, whereas the
29724 // init(...) method sets up a new library and calls _init on it.
29725 //
29726 MixpanelLib.prototype._init = function(token, config, name) {
29727 config = config || {};
29728
29729 this['__loaded'] = true;
29730 this['config'] = {};
29731
29732 var variable_features = {};
29733
29734 // default to JSON payload for standard mixpanel.com API hosts
29735 if (!('api_payload_format' in config)) {
29736 var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
29737 if (api_host.match(/\.mixpanel\.com/)) {
29738 variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
29739 }
29740 }
29741
29742 this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
29743 'name': name,
29744 'token': token,
29745 'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
29746 }));
29747
29748 this['_jsc'] = NOOP_FUNC;
29749
29750 this.__dom_loaded_queue = [];
29751 this.__request_queue = [];
29752 this.__disabled_events = [];
29753 this._flags = {
29754 'disable_all_events': false,
29755 'identify_called': false
29756 };
29757
29758 // set up request queueing/batching
29759 this.request_batchers = {};
29760 this._batch_requests = this.get_config('batch_requests');
29761 if (this._batch_requests) {
29762 if (!_.localStorage.is_supported(true) || !USE_XHR) {
29763 this._batch_requests = false;
29764 console$1.log('Turning off Mixpanel request-queueing; needs XHR and localStorage support');
29765 _.each(this.get_batcher_configs(), function(batcher_config) {
29766 console$1.log('Clearing batch queue ' + batcher_config.queue_key);
29767 _.localStorage.remove(batcher_config.queue_key);
29768 });
29769 } else {
29770 this.init_batchers();
29771 if (sendBeacon && win.addEventListener) {
29772 // Before page closes or hides (user tabs away etc), attempt to flush any events
29773 // queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
29774 // events will not be removed from the persistent store; if the site is loaded again,
29775 // the events will be flushed again on startup and deduplicated on the Mixpanel server
29776 // side.
29777 // There is no reliable way to capture only page close events, so we lean on the
29778 // visibilitychange and pagehide events as recommended at
29779 // https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event#usage_notes.
29780 // These events fire when the user clicks away from the current page/tab, so will occur
29781 // more frequently than page unload, but are the only mechanism currently for capturing
29782 // this scenario somewhat reliably.
29783 var flush_on_unload = _.bind(function() {
29784 if (!this.request_batchers.events.stopped) {
29785 this.request_batchers.events.flush({unloading: true});
29786 }
29787 }, this);
29788 win.addEventListener('pagehide', function(ev) {
29789 if (ev['persisted']) {
29790 flush_on_unload();
29791 }
29792 });
29793 win.addEventListener('visibilitychange', function() {
29794 if (document$1['visibilityState'] === 'hidden') {
29795 flush_on_unload();
29796 }
29797 });
29798 }
29799 }
29800 }
29801
29802 this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config']);
29803 this.unpersisted_superprops = {};
29804 this._gdpr_init();
29805
29806 var uuid = _.UUID();
29807 if (!this.get_distinct_id()) {
29808 // There is no need to set the distinct id
29809 // or the device id if something was already stored
29810 // in the persitence
29811 this.register_once({
29812 'distinct_id': DEVICE_ID_PREFIX + uuid,
29813 '$device_id': uuid
29814 }, '');
29815 }
29816
29817 this.flags = new FeatureFlagManager({
29818 getFullApiRoute: _.bind(function() {
29819 return this.get_api_host('flags') + '/' + this.get_config('api_routes')['flags'];
29820 }, this),
29821 getConfigFunc: _.bind(this.get_config, this),
29822 setConfigFunc: _.bind(this.set_config, this),
29823 getPropertyFunc: _.bind(this.get_property, this),
29824 trackingFunc: _.bind(this.track, this)
29825 });
29826 this.flags.init();
29827 this['flags'] = this.flags;
29828
29829 this.autocapture = new Autocapture(this);
29830 this.autocapture.init();
29831
29832 this._init_tab_id();
29833 this._check_and_start_session_recording();
29834 };
29835
29836 /**
29837 * Assigns a unique UUID to this tab / window by leveraging sessionStorage.
29838 * This is primarily used for session recording, where data must be isolated to the current tab.
29839 */
29840 MixpanelLib.prototype._init_tab_id = function() {
29841 if (this.get_config('disable_persistence')) {
29842 console$1.log('Tab ID initialization skipped due to disable_persistence config');
29843 } else if (_.sessionStorage.is_supported()) {
29844 try {
29845 var key_suffix = this.get_config('name') + '_' + this.get_config('token');
29846 var tab_id_key = 'mp_tab_id_' + key_suffix;
29847
29848 // A flag is used to determine if sessionStorage is copied over and we need to generate a new tab ID.
29849 // This enforces a unique ID in the cases like duplicated tab, window.open(...)
29850 var should_generate_new_tab_id_key = 'mp_gen_new_tab_id_' + key_suffix;
29851 if (_.sessionStorage.get(should_generate_new_tab_id_key) || !_.sessionStorage.get(tab_id_key)) {
29852 _.sessionStorage.set(tab_id_key, '$tab-' + _.UUID());
29853 }
29854
29855 _.sessionStorage.set(should_generate_new_tab_id_key, '1');
29856 this.tab_id = _.sessionStorage.get(tab_id_key);
29857
29858 // 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,
29859 // but reliable in cases where the user remains in the tab e.g. a refresh or href navigation.
29860 // If the flag is absent, this indicates to the next SDK instance that we can reuse the stored tab_id.
29861 win.addEventListener('beforeunload', function () {
29862 _.sessionStorage.remove(should_generate_new_tab_id_key);
29863 });
29864 } catch(err) {
29865 this.report_error('Error initializing tab id', err);
29866 }
29867 } else {
29868 this.report_error('Session storage is not supported, cannot keep track of unique tab ID.');
29869 }
29870 };
29871
29872 MixpanelLib.prototype.get_tab_id = function () {
29873 return this.tab_id || null;
29874 };
29875
29876 MixpanelLib.prototype._should_load_recorder = function () {
29877 if (this.get_config('disable_persistence')) {
29878 console$1.log('Load recorder check skipped due to disable_persistence config');
29879 return Promise.resolve(false);
29880 }
29881
29882 var recording_registry_idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
29883 var tab_id = this.get_tab_id();
29884 return recording_registry_idb.init()
29885 .then(function () {
29886 return recording_registry_idb.getAll();
29887 })
29888 .then(function (recordings) {
29889 for (var i = 0; i < recordings.length; i++) {
29890 // if there are expired recordings in the registry, we should load the recorder to flush them
29891 // if there's a recording for this tab id, we should load the recorder to continue the recording
29892 if (isRecordingExpired(recordings[i]) || recordings[i]['tabId'] === tab_id) {
29893 return true;
29894 }
29895 }
29896 return false;
29897 })
29898 .catch(_.bind(function (err) {
29899 this.report_error('Error checking recording registry', err);
29900 }, this));
29901 };
29902
29903 MixpanelLib.prototype._check_and_start_session_recording = addOptOutCheckMixpanelLib(function(force_start) {
29904 if (!win['MutationObserver']) {
29905 console$1.critical('Browser does not support MutationObserver; skipping session recording');
29906 return;
29907 }
29908
29909 var loadRecorder = _.bind(function(startNewIfInactive) {
29910 var handleLoadedRecorder = _.bind(function() {
29911 this._recorder = this._recorder || new win['__mp_recorder'](this);
29912 this._recorder['resumeRecording'](startNewIfInactive);
29913 }, this);
29914
29915 if (_.isUndefined(win['__mp_recorder'])) {
29916 load_extra_bundle(this.get_config('recorder_src'), handleLoadedRecorder);
29917 } else {
29918 handleLoadedRecorder();
29919 }
29920 }, this);
29921
29922 /**
29923 * If the user is sampled or start_session_recording is called, we always load the recorder since it's guaranteed a recording should start.
29924 * 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.
29925 */
29926 var is_sampled = this.get_config('record_sessions_percent') > 0 && Math.random() * 100 <= this.get_config('record_sessions_percent');
29927 if (force_start || is_sampled) {
29928 loadRecorder(true);
29929 } else {
29930 this._should_load_recorder()
29931 .then(function (shouldLoad) {
29932 if (shouldLoad) {
29933 loadRecorder(false);
29934 }
29935 });
29936 }
29937 });
29938
29939 MixpanelLib.prototype.start_session_recording = function () {
29940 this._check_and_start_session_recording(true);
29941 };
29942
29943 MixpanelLib.prototype.stop_session_recording = function () {
29944 if (this._recorder) {
29945 return this._recorder['stopRecording']();
29946 }
29947 return Promise.resolve();
29948 };
29949
29950 MixpanelLib.prototype.pause_session_recording = function () {
29951 if (this._recorder) {
29952 return this._recorder['pauseRecording']();
29953 }
29954 return Promise.resolve();
29955 };
29956
29957 MixpanelLib.prototype.resume_session_recording = function () {
29958 if (this._recorder) {
29959 return this._recorder['resumeRecording']();
29960 }
29961 return Promise.resolve();
29962 };
29963
29964 MixpanelLib.prototype.is_recording_heatmap_data = function () {
29965 return this._get_session_replay_id() && this.get_config('record_heatmap_data');
29966 };
29967
29968 MixpanelLib.prototype.get_session_recording_properties = function () {
29969 var props = {};
29970 var replay_id = this._get_session_replay_id();
29971 if (replay_id) {
29972 props['$mp_replay_id'] = replay_id;
29973 }
29974 return props;
29975 };
29976
29977 MixpanelLib.prototype.get_session_replay_url = function () {
29978 var replay_url = null;
29979 var replay_id = this._get_session_replay_id();
29980 if (replay_id) {
29981 var query_params = _.HTTPBuildQuery({
29982 'replay_id': replay_id,
29983 'distinct_id': this.get_distinct_id(),
29984 'token': this.get_config('token')
29985 });
29986 replay_url = 'https://mixpanel.com/projects/replay-redirect?' + query_params;
29987 }
29988 return replay_url;
29989 };
29990
29991 MixpanelLib.prototype._get_session_replay_id = function () {
29992 var replay_id = null;
29993 if (this._recorder) {
29994 replay_id = this._recorder['replayId'];
29995 }
29996 return replay_id || null;
29997 };
29998
29999 // "private" public method to reach into the recorder in test cases
30000 MixpanelLib.prototype.__get_recorder = function () {
30001 return this._recorder;
30002 };
30003
30004 // Private methods
30005
30006 MixpanelLib.prototype._loaded = function() {
30007 this.get_config('loaded')(this);
30008 this._set_default_superprops();
30009 this['people'].set_once(this['persistence'].get_referrer_info());
30010
30011 // `store_google` is now deprecated and previously stored UTM parameters are cleared
30012 // from persistence by default.
30013 if (this.get_config('store_google') && this.get_config('stop_utm_persistence')) {
30014 var utm_params = _.info.campaignParams(null);
30015 _.each(utm_params, function(_utm_value, utm_key) {
30016 // We need to unregister persisted UTM parameters so old values
30017 // are not mixed with the new UTM parameters
30018 this.unregister(utm_key);
30019 }.bind(this));
30020 }
30021 };
30022
30023 // update persistence with info on referrer, UTM params, etc
30024 MixpanelLib.prototype._set_default_superprops = function() {
30025 this['persistence'].update_search_keyword(document$1.referrer);
30026 // Registering super properties for UTM persistence by 'store_google' is deprecated.
30027 if (this.get_config('store_google') && !this.get_config('stop_utm_persistence')) {
30028 this.register(_.info.campaignParams());
30029 }
30030 if (this.get_config('save_referrer')) {
30031 this['persistence'].update_referrer_info(document$1.referrer);
30032 }
30033 };
30034
30035 MixpanelLib.prototype._dom_loaded = function() {
30036 _.each(this.__dom_loaded_queue, function(item) {
30037 this._track_dom.apply(this, item);
30038 }, this);
30039
30040 if (!this.has_opted_out_tracking()) {
30041 _.each(this.__request_queue, function(item) {
30042 this._send_request.apply(this, item);
30043 }, this);
30044 }
30045
30046 delete this.__dom_loaded_queue;
30047 delete this.__request_queue;
30048 };
30049
30050 MixpanelLib.prototype._track_dom = function(DomClass, args) {
30051 if (this.get_config('img')) {
30052 this.report_error('You can\'t use DOM tracking functions with img = true.');
30053 return false;
30054 }
30055
30056 if (!DOM_LOADED) {
30057 this.__dom_loaded_queue.push([DomClass, args]);
30058 return false;
30059 }
30060
30061 var dt = new DomClass().init(this);
30062 return dt.track.apply(dt, args);
30063 };
30064
30065 /**
30066 * _prepare_callback() should be called by callers of _send_request for use
30067 * as the callback argument.
30068 *
30069 * If there is no callback, this returns null.
30070 * If we are going to make XHR/XDR requests, this returns a function.
30071 * If we are going to use script tags, this returns a string to use as the
30072 * callback GET param.
30073 */
30074 MixpanelLib.prototype._prepare_callback = function(callback, data) {
30075 if (_.isUndefined(callback)) {
30076 return null;
30077 }
30078
30079 if (USE_XHR) {
30080 var callback_function = function(response) {
30081 callback(response, data);
30082 };
30083 return callback_function;
30084 } else {
30085 // if the user gives us a callback, we store as a random
30086 // property on this instances jsc function and update our
30087 // callback string to reflect that.
30088 var jsc = this['_jsc'];
30089 var randomized_cb = '' + Math.floor(Math.random() * 100000000);
30090 var callback_string = this.get_config('callback_fn') + '[' + randomized_cb + ']';
30091 jsc[randomized_cb] = function(response) {
30092 delete jsc[randomized_cb];
30093 callback(response, data);
30094 };
30095 return callback_string;
30096 }
30097 };
30098
30099 MixpanelLib.prototype._send_request = function(url, data, options, callback) {
30100 var succeeded = true;
30101
30102 if (ENQUEUE_REQUESTS) {
30103 this.__request_queue.push(arguments);
30104 return succeeded;
30105 }
30106
30107 var DEFAULT_OPTIONS = {
30108 method: this.get_config('api_method'),
30109 transport: this.get_config('api_transport'),
30110 verbose: this.get_config('verbose')
30111 };
30112 var body_data = null;
30113
30114 if (!callback && (_.isFunction(options) || typeof options === 'string')) {
30115 callback = options;
30116 options = null;
30117 }
30118 options = _.extend(DEFAULT_OPTIONS, options || {});
30119 if (!USE_XHR) {
30120 options.method = 'GET';
30121 }
30122 var use_post = options.method === 'POST';
30123 var use_sendBeacon = sendBeacon && use_post && options.transport.toLowerCase() === 'sendbeacon';
30124
30125 // needed to correctly format responses
30126 var verbose_mode = options.verbose;
30127 if (data['verbose']) { verbose_mode = true; }
30128
30129 if (this.get_config('test')) { data['test'] = 1; }
30130 if (verbose_mode) { data['verbose'] = 1; }
30131 if (this.get_config('img')) { data['img'] = 1; }
30132 if (!USE_XHR) {
30133 if (callback) {
30134 data['callback'] = callback;
30135 } else if (verbose_mode || this.get_config('test')) {
30136 // Verbose output (from verbose mode, or an error in test mode) is a json blob,
30137 // which by itself is not valid javascript. Without a callback, this verbose output will
30138 // cause an error when returned via jsonp, so we force a no-op callback param.
30139 // See the ECMA script spec: http://www.ecma-international.org/ecma-262/5.1/#sec-12.4
30140 data['callback'] = '(function(){})';
30141 }
30142 }
30143
30144 data['ip'] = this.get_config('ip')?1:0;
30145 data['_'] = new Date().getTime().toString();
30146
30147 if (use_post) {
30148 body_data = 'data=' + encodeURIComponent(data['data']);
30149 delete data['data'];
30150 }
30151
30152 _.extend(data, this.get_config('api_extra_query_params'));
30153
30154 url += '?' + _.HTTPBuildQuery(data);
30155
30156 var lib = this;
30157 if ('img' in data) {
30158 var img = document$1.createElement('img');
30159 img.src = url;
30160 document$1.body.appendChild(img);
30161 } else if (use_sendBeacon) {
30162 try {
30163 succeeded = sendBeacon(url, body_data);
30164 } catch (e) {
30165 lib.report_error(e);
30166 succeeded = false;
30167 }
30168 try {
30169 if (callback) {
30170 callback(succeeded ? 1 : 0);
30171 }
30172 } catch (e) {
30173 lib.report_error(e);
30174 }
30175 } else if (USE_XHR) {
30176 try {
30177 var req = new XMLHttpRequest();
30178 req.open(options.method, url, true);
30179
30180 var headers = this.get_config('xhr_headers');
30181 if (use_post) {
30182 headers['Content-Type'] = 'application/x-www-form-urlencoded';
30183 }
30184 _.each(headers, function(headerValue, headerName) {
30185 req.setRequestHeader(headerName, headerValue);
30186 });
30187
30188 if (options.timeout_ms && typeof req.timeout !== 'undefined') {
30189 req.timeout = options.timeout_ms;
30190 var start_time = new Date().getTime();
30191 }
30192
30193 // send the mp_optout cookie
30194 // withCredentials cannot be modified until after calling .open on Android and Mobile Safari
30195 req.withCredentials = true;
30196 req.onreadystatechange = function () {
30197 if (req.readyState === 4) { // XMLHttpRequest.DONE == 4, except in safari 4
30198 if (req.status === 200) {
30199 if (callback) {
30200 if (verbose_mode) {
30201 var response;
30202 try {
30203 response = _.JSONDecode(req.responseText);
30204 } catch (e) {
30205 lib.report_error(e);
30206 if (options.ignore_json_errors) {
30207 response = req.responseText;
30208 } else {
30209 return;
30210 }
30211 }
30212 callback(response);
30213 } else {
30214 callback(Number(req.responseText));
30215 }
30216 }
30217 } else {
30218 var error;
30219 if (
30220 req.timeout &&
30221 !req.status &&
30222 new Date().getTime() - start_time >= req.timeout
30223 ) {
30224 error = 'timeout';
30225 } else {
30226 error = 'Bad HTTP status: ' + req.status + ' ' + req.statusText;
30227 }
30228 lib.report_error(error);
30229 if (callback) {
30230 if (verbose_mode) {
30231 var response_headers = req['responseHeaders'] || {};
30232 callback({status: 0, httpStatusCode: req['status'], error: error, retryAfter: response_headers['Retry-After']});
30233 } else {
30234 callback(0);
30235 }
30236 }
30237 }
30238 }
30239 };
30240 req.send(body_data);
30241 } catch (e) {
30242 lib.report_error(e);
30243 succeeded = false;
30244 }
30245 } else {
30246 var script = document$1.createElement('script');
30247 script.type = 'text/javascript';
30248 script.async = true;
30249 script.defer = true;
30250 script.src = url;
30251 var s = document$1.getElementsByTagName('script')[0];
30252 s.parentNode.insertBefore(script, s);
30253 }
30254
30255 return succeeded;
30256 };
30257
30258 /**
30259 * _execute_array() deals with processing any mixpanel function
30260 * calls that were called before the Mixpanel library were loaded
30261 * (and are thus stored in an array so they can be called later)
30262 *
30263 * Note: we fire off all the mixpanel function calls && user defined
30264 * functions BEFORE we fire off mixpanel tracking calls. This is so
30265 * identify/register/set_config calls can properly modify early
30266 * tracking calls.
30267 *
30268 * @param {Array} array
30269 */
30270 MixpanelLib.prototype._execute_array = function(array) {
30271 var fn_name, alias_calls = [], other_calls = [], tracking_calls = [];
30272 _.each(array, function(item) {
30273 if (item) {
30274 fn_name = item[0];
30275 if (_.isArray(fn_name)) {
30276 tracking_calls.push(item); // chained call e.g. mixpanel.get_group().set()
30277 } else if (typeof(item) === 'function') {
30278 item.call(this);
30279 } else if (_.isArray(item) && fn_name === 'alias') {
30280 alias_calls.push(item);
30281 } else if (_.isArray(item) && fn_name.indexOf('track') !== -1 && typeof(this[fn_name]) === 'function') {
30282 tracking_calls.push(item);
30283 } else {
30284 other_calls.push(item);
30285 }
30286 }
30287 }, this);
30288
30289 var execute = function(calls, context) {
30290 _.each(calls, function(item) {
30291 if (_.isArray(item[0])) {
30292 // chained call
30293 var caller = context;
30294 _.each(item, function(call) {
30295 caller = caller[call[0]].apply(caller, call.slice(1));
30296 });
30297 } else {
30298 this[item[0]].apply(this, item.slice(1));
30299 }
30300 }, context);
30301 };
30302
30303 execute(alias_calls, this);
30304 execute(other_calls, this);
30305 execute(tracking_calls, this);
30306 };
30307
30308 // request queueing utils
30309
30310 MixpanelLib.prototype.are_batchers_initialized = function() {
30311 return !!this.request_batchers.events;
30312 };
30313
30314 MixpanelLib.prototype.get_batcher_configs = function() {
30315 var queue_prefix = '__mpq_' + this.get_config('token');
30316 this._batcher_configs = this._batcher_configs || {
30317 events: {type: 'events', api_name: 'track', queue_key: queue_prefix + '_ev'},
30318 people: {type: 'people', api_name: 'engage', queue_key: queue_prefix + '_pp'},
30319 groups: {type: 'groups', api_name: 'groups', queue_key: queue_prefix + '_gr'}
30320 };
30321 return this._batcher_configs;
30322 };
30323
30324 MixpanelLib.prototype.init_batchers = function() {
30325 if (!this.are_batchers_initialized()) {
30326 var batcher_for = _.bind(function(attrs) {
30327 return new RequestBatcher(
30328 attrs.queue_key,
30329 {
30330 libConfig: this['config'],
30331 errorReporter: this.get_config('error_reporter'),
30332 sendRequestFunc: _.bind(function(data, options, cb) {
30333 var api_routes = this.get_config('api_routes');
30334 this._send_request(
30335 this.get_api_host(attrs.api_name) + '/' + api_routes[attrs.api_name],
30336 this._encode_data_for_request(data),
30337 options,
30338 this._prepare_callback(cb, data)
30339 );
30340 }, this),
30341 beforeSendHook: _.bind(function(item) {
30342 return this._run_hook('before_send_' + attrs.type, item);
30343 }, this),
30344 stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
30345 usePersistence: true,
30346 }
30347 );
30348 }, this);
30349 var batcher_configs = this.get_batcher_configs();
30350 this.request_batchers = {
30351 events: batcher_for(batcher_configs.events),
30352 people: batcher_for(batcher_configs.people),
30353 groups: batcher_for(batcher_configs.groups)
30354 };
30355 }
30356 if (this.get_config('batch_autostart')) {
30357 this.start_batch_senders();
30358 }
30359 };
30360
30361 MixpanelLib.prototype.start_batch_senders = function() {
30362 this._batchers_were_started = true;
30363 if (this.are_batchers_initialized()) {
30364 this._batch_requests = true;
30365 _.each(this.request_batchers, function(batcher) {
30366 batcher.start();
30367 });
30368 }
30369 };
30370
30371 MixpanelLib.prototype.stop_batch_senders = function() {
30372 this._batch_requests = false;
30373 _.each(this.request_batchers, function(batcher) {
30374 batcher.stop();
30375 batcher.clear();
30376 });
30377 };
30378
30379 /**
30380 * push() keeps the standard async-array-push
30381 * behavior around after the lib is loaded.
30382 * This is only useful for external integrations that
30383 * do not wish to rely on our convenience methods
30384 * (created in the snippet).
30385 *
30386 * ### Usage:
30387 * mixpanel.push(['register', { a: 'b' }]);
30388 *
30389 * @param {Array} item A [function_name, args...] array to be executed
30390 */
30391 MixpanelLib.prototype.push = function(item) {
30392 this._execute_array([item]);
30393 };
30394
30395 /**
30396 * Disable events on the Mixpanel object. If passed no arguments,
30397 * this function disables tracking of any event. If passed an
30398 * array of event names, those events will be disabled, but other
30399 * events will continue to be tracked.
30400 *
30401 * Note: this function does not stop other mixpanel functions from
30402 * firing, such as register() or people.set().
30403 *
30404 * @param {Array} [events] An array of event names to disable
30405 */
30406 MixpanelLib.prototype.disable = function(events) {
30407 if (typeof(events) === 'undefined') {
30408 this._flags.disable_all_events = true;
30409 } else {
30410 this.__disabled_events = this.__disabled_events.concat(events);
30411 }
30412 };
30413
30414 MixpanelLib.prototype._encode_data_for_request = function(data) {
30415 var encoded_data = JSONStringify(data);
30416 if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
30417 encoded_data = _.base64Encode(encoded_data);
30418 }
30419 return {'data': encoded_data};
30420 };
30421
30422 // internal method for handling track vs batch-enqueue logic
30423 MixpanelLib.prototype._track_or_batch = function(options, callback) {
30424 var truncated_data = _.truncate(options.data, 255);
30425 var endpoint = options.endpoint;
30426 var batcher = options.batcher;
30427 var should_send_immediately = options.should_send_immediately;
30428 var send_request_options = options.send_request_options || {};
30429 callback = callback || NOOP_FUNC;
30430
30431 var request_enqueued_or_initiated = true;
30432 var send_request_immediately = _.bind(function() {
30433 if (!send_request_options.skip_hooks) {
30434 truncated_data = this._run_hook('before_send_' + options.type, truncated_data);
30435 }
30436 if (truncated_data) {
30437 console$1.log('MIXPANEL REQUEST:');
30438 console$1.log(truncated_data);
30439 return this._send_request(
30440 endpoint,
30441 this._encode_data_for_request(truncated_data),
30442 send_request_options,
30443 this._prepare_callback(callback, truncated_data)
30444 );
30445 } else {
30446 return null;
30447 }
30448 }, this);
30449
30450 if (this._batch_requests && !should_send_immediately) {
30451 batcher.enqueue(truncated_data).then(function(succeeded) {
30452 if (succeeded) {
30453 callback(1, truncated_data);
30454 } else {
30455 send_request_immediately();
30456 }
30457 });
30458 } else {
30459 request_enqueued_or_initiated = send_request_immediately();
30460 }
30461
30462 return request_enqueued_or_initiated && truncated_data;
30463 };
30464
30465 /**
30466 * Track an event. This is the most important and
30467 * frequently used Mixpanel function.
30468 *
30469 * ### Usage:
30470 *
30471 * // track an event named 'Registered'
30472 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
30473 *
30474 * // track an event using navigator.sendBeacon
30475 * mixpanel.track('Left page', {'duration_seconds': 35}, {transport: 'sendBeacon'});
30476 *
30477 * To track link clicks or form submissions, see track_links() or track_forms().
30478 *
30479 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
30480 * @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.
30481 * @param {Object} [options] Optional configuration for this track request.
30482 * @param {String} [options.transport] Transport method for network request ('xhr' or 'sendBeacon').
30483 * @param {Boolean} [options.send_immediately] Whether to bypass batching/queueing and send track request immediately.
30484 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
30485 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
30486 * with the tracking payload sent to the API server is returned; otherwise false.
30487 */
30488 MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
30489 if (!callback && typeof options === 'function') {
30490 callback = options;
30491 options = null;
30492 }
30493 options = options || {};
30494 var transport = options['transport']; // external API, don't minify 'transport' prop
30495 if (transport) {
30496 options.transport = transport; // 'transport' prop name can be minified internally
30497 }
30498 var should_send_immediately = options['send_immediately'];
30499 if (typeof callback !== 'function') {
30500 callback = NOOP_FUNC;
30501 }
30502
30503 if (_.isUndefined(event_name)) {
30504 this.report_error('No event name provided to mixpanel.track');
30505 return;
30506 }
30507
30508 if (this._event_is_disabled(event_name)) {
30509 callback(0);
30510 return;
30511 }
30512
30513 // set defaults
30514 properties = _.extend({}, properties);
30515 properties['token'] = this.get_config('token');
30516
30517 // set $duration if time_event was previously called for this event
30518 var start_timestamp = this['persistence'].remove_event_timer(event_name);
30519 if (!_.isUndefined(start_timestamp)) {
30520 var duration_in_ms = new Date().getTime() - start_timestamp;
30521 properties['$duration'] = parseFloat((duration_in_ms / 1000).toFixed(3));
30522 }
30523
30524 this._set_default_superprops();
30525
30526 var marketing_properties = this.get_config('track_marketing')
30527 ? _.info.marketingParams()
30528 : {};
30529
30530 // note: extend writes to the first object, so lets make sure we
30531 // don't write to the persistence properties object and info
30532 // properties object by passing in a new object
30533
30534 // update properties with pageview info and super-properties
30535 properties = _.extend(
30536 {},
30537 _.info.properties({'mp_loader': this.get_config('mp_loader')}),
30538 marketing_properties,
30539 this['persistence'].properties(),
30540 this.unpersisted_superprops,
30541 this.get_session_recording_properties(),
30542 properties
30543 );
30544
30545 var property_blacklist = this.get_config('property_blacklist');
30546 if (_.isArray(property_blacklist)) {
30547 _.each(property_blacklist, function(blacklisted_prop) {
30548 delete properties[blacklisted_prop];
30549 });
30550 } else {
30551 this.report_error('Invalid value for property_blacklist config: ' + property_blacklist);
30552 }
30553
30554 var data = {
30555 'event': event_name,
30556 'properties': properties
30557 };
30558 var ret = this._track_or_batch({
30559 type: 'events',
30560 data: data,
30561 endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
30562 batcher: this.request_batchers.events,
30563 should_send_immediately: should_send_immediately,
30564 send_request_options: options
30565 }, callback);
30566
30567 return ret;
30568 });
30569
30570 /**
30571 * Register the current user into one/many groups.
30572 *
30573 * ### Usage:
30574 *
30575 * mixpanel.set_group('company', ['mixpanel', 'google']) // an array of IDs
30576 * mixpanel.set_group('company', 'mixpanel')
30577 * mixpanel.set_group('company', 128746312)
30578 *
30579 * @param {String} group_key Group key
30580 * @param {Array|String|Number} group_ids An array of group IDs, or a singular group ID
30581 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30582 *
30583 */
30584 MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key, group_ids, callback) {
30585 if (!_.isArray(group_ids)) {
30586 group_ids = [group_ids];
30587 }
30588 var prop = {};
30589 prop[group_key] = group_ids;
30590 this.register(prop);
30591 return this['people'].set(group_key, group_ids, callback);
30592 });
30593
30594 /**
30595 * Add a new group for this user.
30596 *
30597 * ### Usage:
30598 *
30599 * mixpanel.add_group('company', 'mixpanel')
30600 *
30601 * @param {String} group_key Group key
30602 * @param {*} group_id A valid Mixpanel property type
30603 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30604 */
30605 MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
30606 var old_values = this.get_property(group_key);
30607 var prop = {};
30608 if (old_values === undefined) {
30609 prop[group_key] = [group_id];
30610 this.register(prop);
30611 } else {
30612 if (old_values.indexOf(group_id) === -1) {
30613 old_values.push(group_id);
30614 prop[group_key] = old_values;
30615 this.register(prop);
30616 }
30617 }
30618 return this['people'].union(group_key, group_id, callback);
30619 });
30620
30621 /**
30622 * Remove a group from this user.
30623 *
30624 * ### Usage:
30625 *
30626 * mixpanel.remove_group('company', 'mixpanel')
30627 *
30628 * @param {String} group_key Group key
30629 * @param {*} group_id A valid Mixpanel property type
30630 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30631 */
30632 MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
30633 var old_value = this.get_property(group_key);
30634 // if the value doesn't exist, the persistent store is unchanged
30635 if (old_value !== undefined) {
30636 var idx = old_value.indexOf(group_id);
30637 if (idx > -1) {
30638 old_value.splice(idx, 1);
30639 this.register({group_key: old_value});
30640 }
30641 if (old_value.length === 0) {
30642 this.unregister(group_key);
30643 }
30644 }
30645 return this['people'].remove(group_key, group_id, callback);
30646 });
30647
30648 /**
30649 * Track an event with specific groups.
30650 *
30651 * ### Usage:
30652 *
30653 * mixpanel.track_with_groups('purchase', {'product': 'iphone'}, {'University': ['UCB', 'UCLA']})
30654 *
30655 * @param {String} event_name The name of the event (see `mixpanel.track()`)
30656 * @param {Object=} properties A set of properties to include with the event you're sending (see `mixpanel.track()`)
30657 * @param {Object=} groups An object mapping group name keys to one or more values
30658 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30659 */
30660 MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(event_name, properties, groups, callback) {
30661 var tracking_props = _.extend({}, properties || {});
30662 _.each(groups, function(v, k) {
30663 if (v !== null && v !== undefined) {
30664 tracking_props[k] = v;
30665 }
30666 });
30667 return this.track(event_name, tracking_props, callback);
30668 });
30669
30670 MixpanelLib.prototype._create_map_key = function (group_key, group_id) {
30671 return group_key + '_' + JSON.stringify(group_id);
30672 };
30673
30674 MixpanelLib.prototype._remove_group_from_cache = function (group_key, group_id) {
30675 delete this._cached_groups[this._create_map_key(group_key, group_id)];
30676 };
30677
30678 /**
30679 * Look up reference to a Mixpanel group
30680 *
30681 * ### Usage:
30682 *
30683 * mixpanel.get_group(group_key, group_id)
30684 *
30685 * @param {String} group_key Group key
30686 * @param {Object} group_id A valid Mixpanel property type
30687 * @returns {Object} A MixpanelGroup identifier
30688 */
30689 MixpanelLib.prototype.get_group = function (group_key, group_id) {
30690 var map_key = this._create_map_key(group_key, group_id);
30691 var group = this._cached_groups[map_key];
30692 if (group === undefined || group._group_key !== group_key || group._group_id !== group_id) {
30693 group = new MixpanelGroup();
30694 group._init(this, group_key, group_id);
30695 this._cached_groups[map_key] = group;
30696 }
30697 return group;
30698 };
30699
30700 /**
30701 * Track a default Mixpanel page view event, which includes extra default event properties to
30702 * improve page view data.
30703 *
30704 * ### Usage:
30705 *
30706 * // track a default $mp_web_page_view event
30707 * mixpanel.track_pageview();
30708 *
30709 * // track a page view event with additional event properties
30710 * mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
30711 *
30712 * // example approach to track page views on different page types as event properties
30713 * mixpanel.track_pageview({'page': 'pricing'});
30714 * mixpanel.track_pageview({'page': 'homepage'});
30715 *
30716 * // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
30717 * // individual pages on the same site or product. Use cases for custom event_name may be page
30718 * // views on different products or internal applications that are considered completely separate
30719 * mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
30720 *
30721 * ### Notes:
30722 *
30723 * The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
30724 * may be turned on for tracking page loads automatically.
30725 *
30726 * // track only page loads
30727 * mixpanel.init(PROJECT_TOKEN, {track_pageview: true});
30728 *
30729 * // track when the URL changes in any manner
30730 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'full-url'});
30731 *
30732 * // track when the URL changes, ignoring any changes in the hash part
30733 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path-and-query-string'});
30734 *
30735 * // track when the path changes, ignoring any query parameter or hash changes
30736 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path'});
30737 *
30738 * @param {Object} [properties] An optional set of additional properties to send with the page view event
30739 * @param {Object} [options] Page view tracking options
30740 * @param {String} [options.event_name] - Alternate name for the tracking event
30741 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
30742 * with the tracking payload sent to the API server is returned; otherwise false.
30743 */
30744 MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
30745 if (typeof properties !== 'object') {
30746 properties = {};
30747 }
30748 options = options || {};
30749 var event_name = options['event_name'] || '$mp_web_page_view';
30750
30751 var default_page_properties = _.extend(
30752 _.info.mpPageViewProperties(),
30753 _.info.campaignParams(),
30754 _.info.clickParams()
30755 );
30756
30757 var event_properties = _.extend(
30758 {},
30759 default_page_properties,
30760 properties
30761 );
30762
30763 return this.track(event_name, event_properties);
30764 });
30765
30766 /**
30767 * Track clicks on a set of document elements. Selector must be a
30768 * valid query. Elements must exist on the page at the time track_links is called.
30769 *
30770 * ### Usage:
30771 *
30772 * // track click for link id #nav
30773 * mixpanel.track_links('#nav', 'Clicked Nav Link');
30774 *
30775 * ### Notes:
30776 *
30777 * This function will wait up to 300 ms for the Mixpanel
30778 * servers to respond. If they have not responded by that time
30779 * it will head to the link without ensuring that your event
30780 * has been tracked. To configure this timeout please see the
30781 * set_config() documentation below.
30782 *
30783 * If you pass a function in as the properties argument, the
30784 * function will receive the DOMElement that triggered the
30785 * event as an argument. You are expected to return an object
30786 * from the function; any properties defined on this object
30787 * will be sent to mixpanel as event properties.
30788 *
30789 * @type {Function}
30790 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
30791 * @param {String} event_name The name of the event to track
30792 * @param {Object|Function} [properties] A properties object or function that returns a dictionary of properties when passed a DOMElement
30793 */
30794 MixpanelLib.prototype.track_links = function() {
30795 return this._track_dom.call(this, LinkTracker, arguments);
30796 };
30797
30798 /**
30799 * Track form submissions. Selector must be a valid query.
30800 *
30801 * ### Usage:
30802 *
30803 * // track submission for form id 'register'
30804 * mixpanel.track_forms('#register', 'Created Account');
30805 *
30806 * ### Notes:
30807 *
30808 * This function will wait up to 300 ms for the mixpanel
30809 * servers to respond, if they have not responded by that time
30810 * it will head to the link without ensuring that your event
30811 * has been tracked. To configure this timeout please see the
30812 * set_config() documentation below.
30813 *
30814 * If you pass a function in as the properties argument, the
30815 * function will receive the DOMElement that triggered the
30816 * event as an argument. You are expected to return an object
30817 * from the function; any properties defined on this object
30818 * will be sent to mixpanel as event properties.
30819 *
30820 * @type {Function}
30821 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
30822 * @param {String} event_name The name of the event to track
30823 * @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
30824 */
30825 MixpanelLib.prototype.track_forms = function() {
30826 return this._track_dom.call(this, FormTracker, arguments);
30827 };
30828
30829 /**
30830 * Time an event by including the time between this call and a
30831 * later 'track' call for the same event in the properties sent
30832 * with the event.
30833 *
30834 * ### Usage:
30835 *
30836 * // time an event named 'Registered'
30837 * mixpanel.time_event('Registered');
30838 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
30839 *
30840 * When called for a particular event name, the next track call for that event
30841 * name will include the elapsed time between the 'time_event' and 'track'
30842 * calls. This value is stored as seconds in the '$duration' property.
30843 *
30844 * @param {String} event_name The name of the event.
30845 */
30846 MixpanelLib.prototype.time_event = function(event_name) {
30847 if (_.isUndefined(event_name)) {
30848 this.report_error('No event name provided to mixpanel.time_event');
30849 return;
30850 }
30851
30852 if (this._event_is_disabled(event_name)) {
30853 return;
30854 }
30855
30856 this['persistence'].set_event_timer(event_name, new Date().getTime());
30857 };
30858
30859 var REGISTER_DEFAULTS = {
30860 'persistent': true
30861 };
30862 /**
30863 * Helper to parse options param for register methods, maintaining
30864 * legacy support for plain "days" param instead of options object
30865 * @param {Number|Object} [days_or_options] 'days' option (Number), or Options object for register methods
30866 * @returns {Object} options object
30867 */
30868 var options_for_register = function(days_or_options) {
30869 var options;
30870 if (_.isObject(days_or_options)) {
30871 options = days_or_options;
30872 } else if (!_.isUndefined(days_or_options)) {
30873 options = {'days': days_or_options};
30874 } else {
30875 options = {};
30876 }
30877 return _.extend({}, REGISTER_DEFAULTS, options);
30878 };
30879
30880 /**
30881 * Register a set of super properties, which are included with all
30882 * events. This will overwrite previous super property values.
30883 *
30884 * ### Usage:
30885 *
30886 * // register 'Gender' as a super property
30887 * mixpanel.register({'Gender': 'Female'});
30888 *
30889 * // register several super properties when a user signs up
30890 * mixpanel.register({
30891 * 'Email': '[email protected]',
30892 * 'Account Type': 'Free'
30893 * });
30894 *
30895 * // register only for the current pageload
30896 * mixpanel.register({'Name': 'Pat'}, {persistent: false});
30897 *
30898 * @param {Object} properties An associative array of properties to store about the user
30899 * @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)
30900 * @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)
30901 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
30902 */
30903 MixpanelLib.prototype.register = function(props, days_or_options) {
30904 var options = options_for_register(days_or_options);
30905 if (options['persistent']) {
30906 this['persistence'].register(props, options['days']);
30907 } else {
30908 _.extend(this.unpersisted_superprops, props);
30909 }
30910 };
30911
30912 /**
30913 * Register a set of super properties only once. This will not
30914 * overwrite previous super property values, unlike register().
30915 *
30916 * ### Usage:
30917 *
30918 * // register a super property for the first time only
30919 * mixpanel.register_once({
30920 * 'First Login Date': new Date().toISOString()
30921 * });
30922 *
30923 * // register once, only for the current pageload
30924 * mixpanel.register_once({
30925 * 'First interaction time': new Date().toISOString()
30926 * }, 'None', {persistent: false});
30927 *
30928 * ### Notes:
30929 *
30930 * If default_value is specified, current super properties
30931 * with that value will be overwritten.
30932 *
30933 * @param {Object} properties An associative array of properties to store about the user
30934 * @param {*} [default_value] Value to override if already set in super properties (ex: 'False') Default: 'None'
30935 * @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)
30936 * @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)
30937 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
30938 */
30939 MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
30940 var options = options_for_register(days_or_options);
30941 if (options['persistent']) {
30942 this['persistence'].register_once(props, default_value, options['days']);
30943 } else {
30944 if (typeof(default_value) === 'undefined') {
30945 default_value = 'None';
30946 }
30947 _.each(props, function(val, prop) {
30948 if (!this.unpersisted_superprops.hasOwnProperty(prop) || this.unpersisted_superprops[prop] === default_value) {
30949 this.unpersisted_superprops[prop] = val;
30950 }
30951 }, this);
30952 }
30953 };
30954
30955 /**
30956 * Delete a super property stored with the current user.
30957 *
30958 * @param {String} property The name of the super property to remove
30959 * @param {Object} [options]
30960 * @param {boolean} [options.persistent=true] - whether to look in persistent storage (cookie/localStorage)
30961 */
30962 MixpanelLib.prototype.unregister = function(property, options) {
30963 options = options_for_register(options);
30964 if (options['persistent']) {
30965 this['persistence'].unregister(property);
30966 } else {
30967 delete this.unpersisted_superprops[property];
30968 }
30969 };
30970
30971 MixpanelLib.prototype._register_single = function(prop, value) {
30972 var props = {};
30973 props[prop] = value;
30974 this.register(props);
30975 };
30976
30977 /**
30978 * Identify a user with a unique ID to track user activity across
30979 * devices, tie a user to their events, and create a user profile.
30980 * If you never call this method, unique visitors are tracked using
30981 * a UUID generated the first time they visit the site.
30982 *
30983 * Call identify when you know the identity of the current user,
30984 * typically after login or signup. We recommend against using
30985 * identify for anonymous visitors to your site.
30986 *
30987 * ### Notes:
30988 * If your project has
30989 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
30990 * enabled, the identify method will connect pre- and
30991 * post-authentication events when appropriate.
30992 *
30993 * If your project does not have ID Merge enabled, identify will
30994 * change the user's local distinct_id to the unique ID you pass.
30995 * Events tracked prior to authentication will not be connected
30996 * to the same user identity. If ID Merge is disabled, alias can
30997 * be used to connect pre- and post-registration events.
30998 *
30999 * @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.
31000 */
31001 MixpanelLib.prototype.identify = function(
31002 new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
31003 ) {
31004 // Optional Parameters
31005 // _set_callback:function A callback to be run if and when the People set queue is flushed
31006 // _add_callback:function A callback to be run if and when the People add queue is flushed
31007 // _append_callback:function A callback to be run if and when the People append queue is flushed
31008 // _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
31009 // _union_callback:function A callback to be run if and when the People union queue is flushed
31010 // _unset_callback:function A callback to be run if and when the People unset queue is flushed
31011
31012 var previous_distinct_id = this.get_distinct_id();
31013 if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
31014 // we allow the following condition if previous distinct_id is same as new_distinct_id
31015 // so that you can force flush people updates for anonymous profiles.
31016 if (typeof new_distinct_id === 'string' && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
31017 this.report_error('distinct_id cannot have $device: prefix');
31018 return -1;
31019 }
31020 this.register({'$user_id': new_distinct_id});
31021 }
31022
31023 if (!this.get_property('$device_id')) {
31024 // The persisted distinct id might not actually be a device id at all
31025 // it might be a distinct id of the user from before
31026 var device_id = previous_distinct_id;
31027 this.register_once({
31028 '$had_persisted_distinct_id': true,
31029 '$device_id': device_id
31030 }, '');
31031 }
31032
31033 // identify only changes the distinct id if it doesn't match either the existing or the alias;
31034 // if it's new, blow away the alias as well.
31035 if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
31036 this.unregister(ALIAS_ID_KEY);
31037 this.register({'distinct_id': new_distinct_id});
31038 }
31039 this._flags.identify_called = true;
31040 // Flush any queued up people requests
31041 this['people']._flush(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback);
31042
31043 // send an $identify event any time the distinct_id is changing - logic on the server
31044 // will determine whether or not to do anything with it.
31045 if (new_distinct_id !== previous_distinct_id) {
31046 this.track('$identify', {
31047 'distinct_id': new_distinct_id,
31048 '$anon_distinct_id': previous_distinct_id
31049 }, {skip_hooks: true});
31050 }
31051
31052 // check feature flags again if distinct id has changed
31053 if (new_distinct_id !== previous_distinct_id) {
31054 this.flags.fetchFlags();
31055 }
31056 };
31057
31058 /**
31059 * Clears super properties and generates a new random distinct_id for this instance.
31060 * Useful for clearing data when a user logs out.
31061 */
31062 MixpanelLib.prototype.reset = function() {
31063 this.stop_session_recording();
31064 this['persistence'].clear();
31065 this._flags.identify_called = false;
31066 var uuid = _.UUID();
31067 this.register_once({
31068 'distinct_id': DEVICE_ID_PREFIX + uuid,
31069 '$device_id': uuid
31070 }, '');
31071 this._check_and_start_session_recording();
31072 };
31073
31074 /**
31075 * Returns the current distinct id of the user. This is either the id automatically
31076 * generated by the library or the id that has been passed by a call to identify().
31077 *
31078 * ### Notes:
31079 *
31080 * get_distinct_id() can only be called after the Mixpanel library has finished loading.
31081 * init() has a loaded function available to handle this automatically. For example:
31082 *
31083 * // set distinct_id after the mixpanel library has loaded
31084 * mixpanel.init('YOUR PROJECT TOKEN', {
31085 * loaded: function(mixpanel) {
31086 * distinct_id = mixpanel.get_distinct_id();
31087 * }
31088 * });
31089 */
31090 MixpanelLib.prototype.get_distinct_id = function() {
31091 return this.get_property('distinct_id');
31092 };
31093
31094 /**
31095 * The alias method creates an alias which Mixpanel will use to
31096 * remap one id to another. Multiple aliases can point to the
31097 * same identifier.
31098 *
31099 * The following is a valid use of alias:
31100 *
31101 * mixpanel.alias('new_id', 'existing_id');
31102 * // You can add multiple id aliases to the existing ID
31103 * mixpanel.alias('newer_id', 'existing_id');
31104 *
31105 * Aliases can also be chained - the following is a valid example:
31106 *
31107 * mixpanel.alias('new_id', 'existing_id');
31108 * // chain newer_id - new_id - existing_id
31109 * mixpanel.alias('newer_id', 'new_id');
31110 *
31111 * Aliases cannot point to multiple identifiers - the following
31112 * example will not work:
31113 *
31114 * mixpanel.alias('new_id', 'existing_id');
31115 * // this is invalid as 'new_id' already points to 'existing_id'
31116 * mixpanel.alias('new_id', 'newer_id');
31117 *
31118 * ### Notes:
31119 *
31120 * If your project does not have
31121 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31122 * enabled, the best practice is to call alias once when a unique
31123 * ID is first created for a user (e.g., when a user first registers
31124 * for an account). Do not use alias multiple times for a single
31125 * user without ID Merge enabled.
31126 *
31127 * @param {String} alias A unique identifier that you want to use for this user in the future.
31128 * @param {String} [original] The current identifier being used for this user.
31129 */
31130 MixpanelLib.prototype.alias = function(alias, original) {
31131 // If the $people_distinct_id key exists in persistence, there has been a previous
31132 // mixpanel.people.identify() call made for this user. It is VERY BAD to make an alias with
31133 // this ID, as it will duplicate users.
31134 if (alias === this.get_property(PEOPLE_DISTINCT_ID_KEY)) {
31135 this.report_error('Attempting to create alias for existing People user - aborting.');
31136 return -2;
31137 }
31138
31139 var _this = this;
31140 if (_.isUndefined(original)) {
31141 original = this.get_distinct_id();
31142 }
31143 if (alias !== original) {
31144 this._register_single(ALIAS_ID_KEY, alias);
31145 return this.track('$create_alias', {
31146 'alias': alias,
31147 'distinct_id': original
31148 }, {
31149 skip_hooks: true
31150 }, function() {
31151 // Flush the people queue
31152 _this.identify(alias);
31153 });
31154 } else {
31155 this.report_error('alias matches current distinct_id - skipping api call.');
31156 this.identify(alias);
31157 return -1;
31158 }
31159 };
31160
31161 /**
31162 * Provide a string to recognize the user by. The string passed to
31163 * this method will appear in the Mixpanel Streams product rather
31164 * than an automatically generated name. Name tags do not have to
31165 * be unique.
31166 *
31167 * This value will only be included in Streams data.
31168 *
31169 * @param {String} name_tag A human readable name for the user
31170 * @deprecated
31171 */
31172 MixpanelLib.prototype.name_tag = function(name_tag) {
31173 this._register_single('mp_name_tag', name_tag);
31174 };
31175
31176 /**
31177 * Update the configuration of a mixpanel library instance.
31178 *
31179 * The default config is:
31180 *
31181 * {
31182 * // host for requests (customizable for e.g. a local proxy)
31183 * api_host: 'https://api-js.mixpanel.com',
31184 *
31185 * // endpoints for different types of requests
31186 * api_routes: {
31187 * track: 'track/',
31188 * engage: 'engage/',
31189 * groups: 'groups/',
31190 * }
31191 *
31192 * // HTTP method for tracking requests
31193 * api_method: 'POST'
31194 *
31195 * // transport for sending requests ('XHR' or 'sendBeacon')
31196 * // NB: sendBeacon should only be used for scenarios such as
31197 * // page unload where a "best-effort" attempt to send is
31198 * // acceptable; the sendBeacon API does not support callbacks
31199 * // or any way to know the result of the request. Mixpanel
31200 * // tracking via sendBeacon will not support any event-
31201 * // batching or retry mechanisms.
31202 * api_transport: 'XHR'
31203 *
31204 * // request-batching/queueing/retry
31205 * batch_requests: true,
31206 *
31207 * // maximum number of events/updates to send in a single
31208 * // network request
31209 * batch_size: 50,
31210 *
31211 * // milliseconds to wait between sending batch requests
31212 * batch_flush_interval_ms: 5000,
31213 *
31214 * // milliseconds to wait for network responses to batch requests
31215 * // before they are considered timed-out and retried
31216 * batch_request_timeout_ms: 90000,
31217 *
31218 * // override value for cookie domain, only useful for ensuring
31219 * // correct cross-subdomain cookies on unusual domains like
31220 * // subdomain.mainsite.avocat.fr; NB this cannot be used to
31221 * // set cookies on a different domain than the current origin
31222 * cookie_domain: ''
31223 *
31224 * // super properties cookie expiration (in days)
31225 * cookie_expiration: 365
31226 *
31227 * // if true, cookie will be set with SameSite=None; Secure
31228 * // this is only useful in special situations, like embedded
31229 * // 3rd-party iframes that set up a Mixpanel instance
31230 * cross_site_cookie: false
31231 *
31232 * // super properties span subdomains
31233 * cross_subdomain_cookie: true
31234 *
31235 * // debug mode
31236 * debug: false
31237 *
31238 * // if this is true, the mixpanel cookie or localStorage entry
31239 * // will be deleted, and no user persistence will take place
31240 * disable_persistence: false
31241 *
31242 * // if this is true, Mixpanel will automatically determine
31243 * // City, Region and Country data using the IP address of
31244 * //the client
31245 * ip: true
31246 *
31247 * // opt users out of tracking by this Mixpanel instance by default
31248 * opt_out_tracking_by_default: false
31249 *
31250 * // opt users out of browser data storage by this Mixpanel instance by default
31251 * opt_out_persistence_by_default: false
31252 *
31253 * // persistence mechanism used by opt-in/opt-out methods - cookie
31254 * // or localStorage - falls back to cookie if localStorage is unavailable
31255 * opt_out_tracking_persistence_type: 'localStorage'
31256 *
31257 * // customize the name of cookie/localStorage set by opt-in/opt-out methods
31258 * opt_out_tracking_cookie_prefix: null
31259 *
31260 * // type of persistent store for super properties (cookie/
31261 * // localStorage) if set to 'localStorage', any existing
31262 * // mixpanel cookie value with the same persistence_name
31263 * // will be transferred to localStorage and deleted
31264 * persistence: 'cookie'
31265 *
31266 * // name for super properties persistent store
31267 * persistence_name: ''
31268 *
31269 * // names of properties/superproperties which should never
31270 * // be sent with track() calls
31271 * property_blacklist: []
31272 *
31273 * // if this is true, mixpanel cookies will be marked as
31274 * // secure, meaning they will only be transmitted over https
31275 * secure_cookie: false
31276 *
31277 * // disables enriching user profiles with first touch marketing data
31278 * skip_first_touch_marketing: false
31279 *
31280 * // the amount of time track_links will
31281 * // wait for Mixpanel's servers to respond
31282 * track_links_timeout: 300
31283 *
31284 * // adds any UTM parameters and click IDs present on the page to any events fired
31285 * track_marketing: true
31286 *
31287 * // enables automatic page view tracking using default page view events through
31288 * // the track_pageview() method
31289 * track_pageview: false
31290 *
31291 * // if you set upgrade to be true, the library will check for
31292 * // a cookie from our old js library and import super
31293 * // properties from it, then the old cookie is deleted
31294 * // The upgrade config option only works in the initialization,
31295 * // so make sure you set it when you create the library.
31296 * upgrade: false
31297 *
31298 * // extra HTTP request headers to set for each API request, in
31299 * // the format {'Header-Name': value}
31300 * xhr_headers: {}
31301 *
31302 * // whether to ignore or respect the web browser's Do Not Track setting
31303 * ignore_dnt: false
31304 * }
31305 *
31306 *
31307 * @param {Object} config A dictionary of new configuration values to update
31308 */
31309 MixpanelLib.prototype.set_config = function(config) {
31310 if (_.isObject(config)) {
31311 _.extend(this['config'], config);
31312
31313 var new_batch_size = config['batch_size'];
31314 if (new_batch_size) {
31315 _.each(this.request_batchers, function(batcher) {
31316 batcher.resetBatchSize();
31317 });
31318 }
31319
31320 if (!this.get_config('persistence_name')) {
31321 this['config']['persistence_name'] = this['config']['cookie_name'];
31322 }
31323 if (!this.get_config('disable_persistence')) {
31324 this['config']['disable_persistence'] = this['config']['disable_cookie'];
31325 }
31326
31327 if (this['persistence']) {
31328 this['persistence'].update_config(this['config']);
31329 }
31330 Config.DEBUG = Config.DEBUG || this.get_config('debug');
31331
31332 if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
31333 this.autocapture.init();
31334 }
31335 }
31336 };
31337
31338 /**
31339 * returns the current config object for the library.
31340 */
31341 MixpanelLib.prototype.get_config = function(prop_name) {
31342 return this['config'][prop_name];
31343 };
31344
31345 /**
31346 * Fetch a hook function from config, with safe default, and run it
31347 * against the given arguments
31348 * @param {string} hook_name which hook to retrieve
31349 * @returns {any|null} return value of user-provided hook, or null if nothing was returned
31350 */
31351 MixpanelLib.prototype._run_hook = function(hook_name) {
31352 var ret = (this['config']['hooks'][hook_name] || IDENTITY_FUNC).apply(this, slice.call(arguments, 1));
31353 if (typeof ret === 'undefined') {
31354 this.report_error(hook_name + ' hook did not return a value');
31355 ret = null;
31356 }
31357 return ret;
31358 };
31359
31360 /**
31361 * Returns the value of the super property named property_name. If no such
31362 * property is set, get_property() will return the undefined value.
31363 *
31364 * ### Notes:
31365 *
31366 * get_property() can only be called after the Mixpanel library has finished loading.
31367 * init() has a loaded function available to handle this automatically. For example:
31368 *
31369 * // grab value for 'user_id' after the mixpanel library has loaded
31370 * mixpanel.init('YOUR PROJECT TOKEN', {
31371 * loaded: function(mixpanel) {
31372 * user_id = mixpanel.get_property('user_id');
31373 * }
31374 * });
31375 *
31376 * @param {String} property_name The name of the super property you want to retrieve
31377 */
31378 MixpanelLib.prototype.get_property = function(property_name) {
31379 return this['persistence'].load_prop([property_name]);
31380 };
31381
31382 /**
31383 * Get the API host for a specific endpoint type, falling back to the default api_host if not specified
31384 *
31385 * @param {String} endpoint_type The type of endpoint (e.g., "events", "people", "groups")
31386 * @returns {String} The API host to use for this endpoint
31387 */
31388 MixpanelLib.prototype.get_api_host = function(endpoint_type) {
31389 return this.get_config('api_hosts')[endpoint_type] || this.get_config('api_host');
31390 };
31391
31392 MixpanelLib.prototype.toString = function() {
31393 var name = this.get_config('name');
31394 if (name !== PRIMARY_INSTANCE_NAME) {
31395 name = PRIMARY_INSTANCE_NAME + '.' + name;
31396 }
31397 return name;
31398 };
31399
31400 MixpanelLib.prototype._event_is_disabled = function(event_name) {
31401 return _.isBlockedUA(userAgent) ||
31402 this._flags.disable_all_events ||
31403 _.include(this.__disabled_events, event_name);
31404 };
31405
31406 // perform some housekeeping around GDPR opt-in/out state
31407 MixpanelLib.prototype._gdpr_init = function() {
31408 var is_localStorage_requested = this.get_config('opt_out_tracking_persistence_type') === 'localStorage';
31409
31410 // try to convert opt-in/out cookies to localStorage if possible
31411 if (is_localStorage_requested && _.localStorage.is_supported()) {
31412 if (!this.has_opted_in_tracking() && this.has_opted_in_tracking({'persistence_type': 'cookie'})) {
31413 this.opt_in_tracking({'enable_persistence': false});
31414 }
31415 if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({'persistence_type': 'cookie'})) {
31416 this.opt_out_tracking({'clear_persistence': false});
31417 }
31418 this.clear_opt_in_out_tracking({
31419 'persistence_type': 'cookie',
31420 'enable_persistence': false
31421 });
31422 }
31423
31424 // check whether the user has already opted out - if so, clear & disable persistence
31425 if (this.has_opted_out_tracking()) {
31426 this._gdpr_update_persistence({'clear_persistence': true});
31427
31428 // check whether we should opt out by default
31429 // note: we don't clear persistence here by default since opt-out default state is often
31430 // used as an initial state while GDPR information is being collected
31431 } else if (!this.has_opted_in_tracking() && (
31432 this.get_config('opt_out_tracking_by_default') || _.cookie.get('mp_optout')
31433 )) {
31434 _.cookie.remove('mp_optout');
31435 this.opt_out_tracking({
31436 'clear_persistence': this.get_config('opt_out_persistence_by_default')
31437 });
31438 }
31439 };
31440
31441 /**
31442 * Enable or disable persistence based on options
31443 * only enable/disable if persistence is not already in this state
31444 * @param {boolean} [options.clear_persistence] If true, will delete all data stored by the sdk in persistence and disable it
31445 * @param {boolean} [options.enable_persistence] If true, will re-enable sdk persistence
31446 */
31447 MixpanelLib.prototype._gdpr_update_persistence = function(options) {
31448 var disabled;
31449 if (options && options['clear_persistence']) {
31450 disabled = true;
31451 } else if (options && options['enable_persistence']) {
31452 disabled = false;
31453 } else {
31454 return;
31455 }
31456
31457 if (!this.get_config('disable_persistence') && this['persistence'].disabled !== disabled) {
31458 this['persistence'].set_disabled(disabled);
31459 }
31460
31461 if (disabled) {
31462 this.stop_batch_senders();
31463 this.stop_session_recording();
31464 } else {
31465 // only start batchers after opt-in if they have previously been started
31466 // in order to avoid unintentionally starting up batching for the first time
31467 if (this._batchers_were_started) {
31468 this.start_batch_senders();
31469 }
31470 }
31471 };
31472
31473 // call a base gdpr function after constructing the appropriate token and options args
31474 MixpanelLib.prototype._gdpr_call_func = function(func, options) {
31475 options = _.extend({
31476 'track': _.bind(this.track, this),
31477 'persistence_type': this.get_config('opt_out_tracking_persistence_type'),
31478 'cookie_prefix': this.get_config('opt_out_tracking_cookie_prefix'),
31479 'cookie_expiration': this.get_config('cookie_expiration'),
31480 'cross_site_cookie': this.get_config('cross_site_cookie'),
31481 'cross_subdomain_cookie': this.get_config('cross_subdomain_cookie'),
31482 'cookie_domain': this.get_config('cookie_domain'),
31483 'secure_cookie': this.get_config('secure_cookie'),
31484 'ignore_dnt': this.get_config('ignore_dnt')
31485 }, options);
31486
31487 // check if localStorage can be used for recording opt out status, fall back to cookie if not
31488 if (!_.localStorage.is_supported()) {
31489 options['persistence_type'] = 'cookie';
31490 }
31491
31492 return func(this.get_config('token'), {
31493 track: options['track'],
31494 trackEventName: options['track_event_name'],
31495 trackProperties: options['track_properties'],
31496 persistenceType: options['persistence_type'],
31497 persistencePrefix: options['cookie_prefix'],
31498 cookieDomain: options['cookie_domain'],
31499 cookieExpiration: options['cookie_expiration'],
31500 crossSiteCookie: options['cross_site_cookie'],
31501 crossSubdomainCookie: options['cross_subdomain_cookie'],
31502 secureCookie: options['secure_cookie'],
31503 ignoreDnt: options['ignore_dnt']
31504 });
31505 };
31506
31507 /**
31508 * Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
31509 *
31510 * ### Usage:
31511 *
31512 * // opt user in
31513 * mixpanel.opt_in_tracking();
31514 *
31515 * // opt user in with specific event name, properties, cookie configuration
31516 * mixpanel.opt_in_tracking({
31517 * track_event_name: 'User opted in',
31518 * track_event_properties: {
31519 * 'Email': '[email protected]'
31520 * },
31521 * cookie_expiration: 30,
31522 * secure_cookie: true
31523 * });
31524 *
31525 * @param {Object} [options] A dictionary of config options to override
31526 * @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)
31527 * @param {string} [options.track_event_name=$opt_in] Event name to be used for tracking the opt-in action
31528 * @param {Object} [options.track_properties] Set of properties to be tracked along with the opt-in action
31529 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
31530 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31531 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31532 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
31533 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
31534 * @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)
31535 * @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)
31536 * @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)
31537 */
31538 MixpanelLib.prototype.opt_in_tracking = function(options) {
31539 options = _.extend({
31540 'enable_persistence': true
31541 }, options);
31542
31543 this._gdpr_call_func(optIn, options);
31544 this._gdpr_update_persistence(options);
31545 };
31546
31547 /**
31548 * Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
31549 *
31550 * ### Usage:
31551 *
31552 * // opt user out
31553 * mixpanel.opt_out_tracking();
31554 *
31555 * // opt user out with different cookie configuration from Mixpanel instance
31556 * mixpanel.opt_out_tracking({
31557 * cookie_expiration: 30,
31558 * secure_cookie: true
31559 * });
31560 *
31561 * @param {Object} [options] A dictionary of config options to override
31562 * @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
31563 * @param {boolean} [options.clear_persistence=true] If true, will delete all data stored by the sdk in persistence
31564 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31565 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31566 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
31567 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
31568 * @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)
31569 * @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)
31570 * @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)
31571 */
31572 MixpanelLib.prototype.opt_out_tracking = function(options) {
31573 options = _.extend({
31574 'clear_persistence': true,
31575 'delete_user': true
31576 }, options);
31577
31578 // delete user and clear charges since these methods may be disabled by opt-out
31579 if (options['delete_user'] && this['people'] && this['people']._identify_called()) {
31580 this['people'].delete_user();
31581 this['people'].clear_charges();
31582 }
31583
31584 this._gdpr_call_func(optOut, options);
31585 this._gdpr_update_persistence(options);
31586 };
31587
31588 /**
31589 * Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
31590 *
31591 * ### Usage:
31592 *
31593 * var has_opted_in = mixpanel.has_opted_in_tracking();
31594 * // use has_opted_in value
31595 *
31596 * @param {Object} [options] A dictionary of config options to override
31597 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31598 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31599 * @returns {boolean} current opt-in status
31600 */
31601 MixpanelLib.prototype.has_opted_in_tracking = function(options) {
31602 return this._gdpr_call_func(hasOptedIn, options);
31603 };
31604
31605 /**
31606 * Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
31607 *
31608 * ### Usage:
31609 *
31610 * var has_opted_out = mixpanel.has_opted_out_tracking();
31611 * // use has_opted_out 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-out status
31617 */
31618 MixpanelLib.prototype.has_opted_out_tracking = function(options) {
31619 return this._gdpr_call_func(hasOptedOut, options);
31620 };
31621
31622 /**
31623 * Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
31624 *
31625 * ### Usage:
31626 *
31627 * // clear user's opt-in/out status
31628 * mixpanel.clear_opt_in_out_tracking();
31629 *
31630 * // clear user's opt-in/out status with specific cookie configuration - should match
31631 * // configuration used when opt_in_tracking/opt_out_tracking methods were called.
31632 * mixpanel.clear_opt_in_out_tracking({
31633 * cookie_expiration: 30,
31634 * secure_cookie: true
31635 * });
31636 *
31637 * @param {Object} [options] A dictionary of config options to override
31638 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
31639 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31640 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31641 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
31642 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
31643 * @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)
31644 * @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)
31645 * @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)
31646 */
31647 MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
31648 options = _.extend({
31649 'enable_persistence': true
31650 }, options);
31651
31652 this._gdpr_call_func(clearOptInOut, options);
31653 this._gdpr_update_persistence(options);
31654 };
31655
31656 MixpanelLib.prototype.report_error = function(msg, err) {
31657 console$1.error.apply(console$1.error, arguments);
31658 try {
31659 if (!err && !(msg instanceof Error)) {
31660 msg = new Error(msg);
31661 }
31662 this.get_config('error_reporter')(msg, err);
31663 } catch(err) {
31664 console$1.error(err);
31665 }
31666 };
31667
31668 // EXPORTS (for closure compiler)
31669
31670 // MixpanelLib Exports
31671 MixpanelLib.prototype['init'] = MixpanelLib.prototype.init;
31672 MixpanelLib.prototype['reset'] = MixpanelLib.prototype.reset;
31673 MixpanelLib.prototype['disable'] = MixpanelLib.prototype.disable;
31674 MixpanelLib.prototype['time_event'] = MixpanelLib.prototype.time_event;
31675 MixpanelLib.prototype['track'] = MixpanelLib.prototype.track;
31676 MixpanelLib.prototype['track_links'] = MixpanelLib.prototype.track_links;
31677 MixpanelLib.prototype['track_forms'] = MixpanelLib.prototype.track_forms;
31678 MixpanelLib.prototype['track_pageview'] = MixpanelLib.prototype.track_pageview;
31679 MixpanelLib.prototype['register'] = MixpanelLib.prototype.register;
31680 MixpanelLib.prototype['register_once'] = MixpanelLib.prototype.register_once;
31681 MixpanelLib.prototype['unregister'] = MixpanelLib.prototype.unregister;
31682 MixpanelLib.prototype['identify'] = MixpanelLib.prototype.identify;
31683 MixpanelLib.prototype['alias'] = MixpanelLib.prototype.alias;
31684 MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
31685 MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
31686 MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
31687 MixpanelLib.prototype['get_api_host'] = MixpanelLib.prototype.get_api_host;
31688 MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
31689 MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
31690 MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
31691 MixpanelLib.prototype['opt_out_tracking'] = MixpanelLib.prototype.opt_out_tracking;
31692 MixpanelLib.prototype['opt_in_tracking'] = MixpanelLib.prototype.opt_in_tracking;
31693 MixpanelLib.prototype['has_opted_out_tracking'] = MixpanelLib.prototype.has_opted_out_tracking;
31694 MixpanelLib.prototype['has_opted_in_tracking'] = MixpanelLib.prototype.has_opted_in_tracking;
31695 MixpanelLib.prototype['clear_opt_in_out_tracking'] = MixpanelLib.prototype.clear_opt_in_out_tracking;
31696 MixpanelLib.prototype['get_group'] = MixpanelLib.prototype.get_group;
31697 MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
31698 MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
31699 MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
31700 MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
31701 MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
31702 MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;
31703 MixpanelLib.prototype['start_session_recording'] = MixpanelLib.prototype.start_session_recording;
31704 MixpanelLib.prototype['stop_session_recording'] = MixpanelLib.prototype.stop_session_recording;
31705 MixpanelLib.prototype['pause_session_recording'] = MixpanelLib.prototype.pause_session_recording;
31706 MixpanelLib.prototype['resume_session_recording'] = MixpanelLib.prototype.resume_session_recording;
31707 MixpanelLib.prototype['get_session_recording_properties'] = MixpanelLib.prototype.get_session_recording_properties;
31708 MixpanelLib.prototype['get_session_replay_url'] = MixpanelLib.prototype.get_session_replay_url;
31709 MixpanelLib.prototype['get_tab_id'] = MixpanelLib.prototype.get_tab_id;
31710 MixpanelLib.prototype['DEFAULT_API_ROUTES'] = DEFAULT_API_ROUTES;
31711
31712 // Exports intended only for testing
31713 MixpanelLib.prototype['__get_recorder'] = MixpanelLib.prototype.__get_recorder;
31714
31715 // MixpanelPersistence Exports
31716 MixpanelPersistence.prototype['properties'] = MixpanelPersistence.prototype.properties;
31717 MixpanelPersistence.prototype['update_search_keyword'] = MixpanelPersistence.prototype.update_search_keyword;
31718 MixpanelPersistence.prototype['update_referrer_info'] = MixpanelPersistence.prototype.update_referrer_info;
31719 MixpanelPersistence.prototype['get_cross_subdomain'] = MixpanelPersistence.prototype.get_cross_subdomain;
31720 MixpanelPersistence.prototype['clear'] = MixpanelPersistence.prototype.clear;
31721
31722
31723 var instances = {};
31724 var extend_mp = function() {
31725 // add all the sub mixpanel instances
31726 _.each(instances, function(instance, name) {
31727 if (name !== PRIMARY_INSTANCE_NAME) { mixpanel_master[name] = instance; }
31728 });
31729
31730 // add private functions as _
31731 mixpanel_master['_'] = _;
31732 };
31733
31734 var override_mp_init_func = function() {
31735 // we override the snippets init function to handle the case where a
31736 // user initializes the mixpanel library after the script loads & runs
31737 mixpanel_master['init'] = function(token, config, name) {
31738 if (name) {
31739 // initialize a sub library
31740 if (!mixpanel_master[name]) {
31741 mixpanel_master[name] = instances[name] = create_mplib(token, config, name);
31742 mixpanel_master[name]._loaded();
31743 }
31744 return mixpanel_master[name];
31745 } else {
31746 var instance = mixpanel_master;
31747
31748 if (instances[PRIMARY_INSTANCE_NAME]) {
31749 // main mixpanel lib already initialized
31750 instance = instances[PRIMARY_INSTANCE_NAME];
31751 } else if (token) {
31752 // intialize the main mixpanel lib
31753 instance = create_mplib(token, config, PRIMARY_INSTANCE_NAME);
31754 instance._loaded();
31755 instances[PRIMARY_INSTANCE_NAME] = instance;
31756 }
31757
31758 mixpanel_master = instance;
31759 if (init_type === INIT_SNIPPET) {
31760 win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
31761 }
31762 extend_mp();
31763 }
31764 };
31765 };
31766
31767 var add_dom_loaded_handler = function() {
31768 // Cross browser DOM Loaded support
31769 function dom_loaded_handler() {
31770 // function flag since we only want to execute this once
31771 if (dom_loaded_handler.done) { return; }
31772 dom_loaded_handler.done = true;
31773
31774 DOM_LOADED = true;
31775 ENQUEUE_REQUESTS = false;
31776
31777 _.each(instances, function(inst) {
31778 inst._dom_loaded();
31779 });
31780 }
31781
31782 function do_scroll_check() {
31783 try {
31784 document$1.documentElement.doScroll('left');
31785 } catch(e) {
31786 setTimeout(do_scroll_check, 1);
31787 return;
31788 }
31789
31790 dom_loaded_handler();
31791 }
31792
31793 if (document$1.addEventListener) {
31794 if (document$1.readyState === 'complete') {
31795 // safari 4 can fire the DOMContentLoaded event before loading all
31796 // external JS (including this file). you will see some copypasta
31797 // on the internet that checks for 'complete' and 'loaded', but
31798 // 'loaded' is an IE thing
31799 dom_loaded_handler();
31800 } else {
31801 document$1.addEventListener('DOMContentLoaded', dom_loaded_handler, false);
31802 }
31803 } else if (document$1.attachEvent) {
31804 // IE
31805 document$1.attachEvent('onreadystatechange', dom_loaded_handler);
31806
31807 // check to make sure we arn't in a frame
31808 var toplevel = false;
31809 try {
31810 toplevel = win.frameElement === null;
31811 } catch(e) {
31812 // noop
31813 }
31814
31815 if (document$1.documentElement.doScroll && toplevel) {
31816 do_scroll_check();
31817 }
31818 }
31819
31820 // fallback handler, always will work
31821 _.register_event(win, 'load', dom_loaded_handler, true);
31822 };
31823
31824 function init_as_module(bundle_loader) {
31825 load_extra_bundle = bundle_loader;
31826 init_type = INIT_MODULE;
31827 mixpanel_master = new MixpanelLib();
31828
31829 override_mp_init_func();
31830 mixpanel_master['init']();
31831 add_dom_loaded_handler();
31832
31833 return mixpanel_master;
31834 }
31835
31836 // For loading separate bundles asynchronously via script tag
31837 // so that we don't load them until they are needed at runtime.
31838
31839 // For builds that have everything in one bundle, no extra work.
31840 function loadNoop (_src, onload) {
31841 onload();
31842 }
31843
31844 /* eslint camelcase: "off" */
31845
31846 var mixpanel = init_as_module(loadNoop);
31847
31848
31849
31850
31851 /***/ }),
31852
31853 /***/ "../node_modules/redux-thunk/es/index.js":
31854 /*!***********************************************!*\
31855 !*** ../node_modules/redux-thunk/es/index.js ***!
31856 \***********************************************/
31857 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
31858
31859 "use strict";
31860 __webpack_require__.r(__webpack_exports__);
31861 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
31862 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
31863 /* harmony export */ });
31864 /** A function that accepts a potential "extra argument" value to be injected later,
31865 * and returns an instance of the thunk middleware that uses that value
31866 */
31867 function createThunkMiddleware(extraArgument) {
31868 // Standard Redux middleware definition pattern:
31869 // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
31870 var middleware = function middleware(_ref) {
31871 var dispatch = _ref.dispatch,
31872 getState = _ref.getState;
31873 return function (next) {
31874 return function (action) {
31875 // The thunk middleware looks for any functions that were passed to `store.dispatch`.
31876 // If this "action" is really a function, call it and return the result.
31877 if (typeof action === 'function') {
31878 // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
31879 return action(dispatch, getState, extraArgument);
31880 } // Otherwise, pass the action down the middleware chain as usual
31881
31882
31883 return next(action);
31884 };
31885 };
31886 };
31887
31888 return middleware;
31889 }
31890
31891 var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
31892 // with whatever "extra arg" they want to inject into their thunks
31893
31894 thunk.withExtraArgument = createThunkMiddleware;
31895 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (thunk);
31896
31897 /***/ }),
31898
31899 /***/ "../node_modules/redux/es/redux.js":
31900 /*!*****************************************!*\
31901 !*** ../node_modules/redux/es/redux.js ***!
31902 \*****************************************/
31903 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
31904
31905 "use strict";
31906 __webpack_require__.r(__webpack_exports__);
31907 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
31908 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* binding */ ActionTypes),
31909 /* harmony export */ applyMiddleware: () => (/* binding */ applyMiddleware),
31910 /* harmony export */ bindActionCreators: () => (/* binding */ bindActionCreators),
31911 /* harmony export */ combineReducers: () => (/* binding */ combineReducers),
31912 /* harmony export */ compose: () => (/* binding */ compose),
31913 /* harmony export */ createStore: () => (/* binding */ createStore),
31914 /* harmony export */ legacy_createStore: () => (/* binding */ legacy_createStore)
31915 /* harmony export */ });
31916 /* 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");
31917
31918
31919 /**
31920 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
31921 *
31922 * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
31923 * during build.
31924 * @param {number} code
31925 */
31926 function formatProdErrorMessage(code) {
31927 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. ';
31928 }
31929
31930 // Inlined version of the `symbol-observable` polyfill
31931 var $$observable = (function () {
31932 return typeof Symbol === 'function' && Symbol.observable || '@@observable';
31933 })();
31934
31935 /**
31936 * These are private action types reserved by Redux.
31937 * For any unknown actions, you must return the current state.
31938 * If the current state is undefined, you must return the initial state.
31939 * Do not reference these action types directly in your code.
31940 */
31941 var randomString = function randomString() {
31942 return Math.random().toString(36).substring(7).split('').join('.');
31943 };
31944
31945 var ActionTypes = {
31946 INIT: "@@redux/INIT" + randomString(),
31947 REPLACE: "@@redux/REPLACE" + randomString(),
31948 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
31949 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
31950 }
31951 };
31952
31953 /**
31954 * @param {any} obj The object to inspect.
31955 * @returns {boolean} True if the argument appears to be a plain object.
31956 */
31957 function isPlainObject(obj) {
31958 if (typeof obj !== 'object' || obj === null) return false;
31959 var proto = obj;
31960
31961 while (Object.getPrototypeOf(proto) !== null) {
31962 proto = Object.getPrototypeOf(proto);
31963 }
31964
31965 return Object.getPrototypeOf(obj) === proto;
31966 }
31967
31968 // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
31969 function miniKindOf(val) {
31970 if (val === void 0) return 'undefined';
31971 if (val === null) return 'null';
31972 var type = typeof val;
31973
31974 switch (type) {
31975 case 'boolean':
31976 case 'string':
31977 case 'number':
31978 case 'symbol':
31979 case 'function':
31980 {
31981 return type;
31982 }
31983 }
31984
31985 if (Array.isArray(val)) return 'array';
31986 if (isDate(val)) return 'date';
31987 if (isError(val)) return 'error';
31988 var constructorName = ctorName(val);
31989
31990 switch (constructorName) {
31991 case 'Symbol':
31992 case 'Promise':
31993 case 'WeakMap':
31994 case 'WeakSet':
31995 case 'Map':
31996 case 'Set':
31997 return constructorName;
31998 } // other
31999
32000
32001 return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
32002 }
32003
32004 function ctorName(val) {
32005 return typeof val.constructor === 'function' ? val.constructor.name : null;
32006 }
32007
32008 function isError(val) {
32009 return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
32010 }
32011
32012 function isDate(val) {
32013 if (val instanceof Date) return true;
32014 return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
32015 }
32016
32017 function kindOf(val) {
32018 var typeOfVal = typeof val;
32019
32020 if (true) {
32021 typeOfVal = miniKindOf(val);
32022 }
32023
32024 return typeOfVal;
32025 }
32026
32027 /**
32028 * @deprecated
32029 *
32030 * **We recommend using the `configureStore` method
32031 * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
32032 *
32033 * Redux Toolkit is our recommended approach for writing Redux logic today,
32034 * including store setup, reducers, data fetching, and more.
32035 *
32036 * **For more details, please read this Redux docs page:**
32037 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32038 *
32039 * `configureStore` from Redux Toolkit is an improved version of `createStore` that
32040 * simplifies setup and helps avoid common bugs.
32041 *
32042 * You should not be using the `redux` core package by itself today, except for learning purposes.
32043 * The `createStore` method from the core `redux` package will not be removed, but we encourage
32044 * all users to migrate to using Redux Toolkit for all Redux code.
32045 *
32046 * If you want to use `createStore` without this visual deprecation warning, use
32047 * the `legacy_createStore` import instead:
32048 *
32049 * `import { legacy_createStore as createStore} from 'redux'`
32050 *
32051 */
32052
32053 function createStore(reducer, preloadedState, enhancer) {
32054 var _ref2;
32055
32056 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
32057 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.');
32058 }
32059
32060 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
32061 enhancer = preloadedState;
32062 preloadedState = undefined;
32063 }
32064
32065 if (typeof enhancer !== 'undefined') {
32066 if (typeof enhancer !== 'function') {
32067 throw new Error( false ? 0 : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
32068 }
32069
32070 return enhancer(createStore)(reducer, preloadedState);
32071 }
32072
32073 if (typeof reducer !== 'function') {
32074 throw new Error( false ? 0 : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
32075 }
32076
32077 var currentReducer = reducer;
32078 var currentState = preloadedState;
32079 var currentListeners = [];
32080 var nextListeners = currentListeners;
32081 var isDispatching = false;
32082 /**
32083 * This makes a shallow copy of currentListeners so we can use
32084 * nextListeners as a temporary list while dispatching.
32085 *
32086 * This prevents any bugs around consumers calling
32087 * subscribe/unsubscribe in the middle of a dispatch.
32088 */
32089
32090 function ensureCanMutateNextListeners() {
32091 if (nextListeners === currentListeners) {
32092 nextListeners = currentListeners.slice();
32093 }
32094 }
32095 /**
32096 * Reads the state tree managed by the store.
32097 *
32098 * @returns {any} The current state tree of your application.
32099 */
32100
32101
32102 function getState() {
32103 if (isDispatching) {
32104 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.');
32105 }
32106
32107 return currentState;
32108 }
32109 /**
32110 * Adds a change listener. It will be called any time an action is dispatched,
32111 * and some part of the state tree may potentially have changed. You may then
32112 * call `getState()` to read the current state tree inside the callback.
32113 *
32114 * You may call `dispatch()` from a change listener, with the following
32115 * caveats:
32116 *
32117 * 1. The subscriptions are snapshotted just before every `dispatch()` call.
32118 * If you subscribe or unsubscribe while the listeners are being invoked, this
32119 * will not have any effect on the `dispatch()` that is currently in progress.
32120 * However, the next `dispatch()` call, whether nested or not, will use a more
32121 * recent snapshot of the subscription list.
32122 *
32123 * 2. The listener should not expect to see all state changes, as the state
32124 * might have been updated multiple times during a nested `dispatch()` before
32125 * the listener is called. It is, however, guaranteed that all subscribers
32126 * registered before the `dispatch()` started will be called with the latest
32127 * state by the time it exits.
32128 *
32129 * @param {Function} listener A callback to be invoked on every dispatch.
32130 * @returns {Function} A function to remove this change listener.
32131 */
32132
32133
32134 function subscribe(listener) {
32135 if (typeof listener !== 'function') {
32136 throw new Error( false ? 0 : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
32137 }
32138
32139 if (isDispatching) {
32140 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.');
32141 }
32142
32143 var isSubscribed = true;
32144 ensureCanMutateNextListeners();
32145 nextListeners.push(listener);
32146 return function unsubscribe() {
32147 if (!isSubscribed) {
32148 return;
32149 }
32150
32151 if (isDispatching) {
32152 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.');
32153 }
32154
32155 isSubscribed = false;
32156 ensureCanMutateNextListeners();
32157 var index = nextListeners.indexOf(listener);
32158 nextListeners.splice(index, 1);
32159 currentListeners = null;
32160 };
32161 }
32162 /**
32163 * Dispatches an action. It is the only way to trigger a state change.
32164 *
32165 * The `reducer` function, used to create the store, will be called with the
32166 * current state tree and the given `action`. Its return value will
32167 * be considered the **next** state of the tree, and the change listeners
32168 * will be notified.
32169 *
32170 * The base implementation only supports plain object actions. If you want to
32171 * dispatch a Promise, an Observable, a thunk, or something else, you need to
32172 * wrap your store creating function into the corresponding middleware. For
32173 * example, see the documentation for the `redux-thunk` package. Even the
32174 * middleware will eventually dispatch plain object actions using this method.
32175 *
32176 * @param {Object} action A plain object representing “what changed”. It is
32177 * a good idea to keep actions serializable so you can record and replay user
32178 * sessions, or use the time travelling `redux-devtools`. An action must have
32179 * a `type` property which may not be `undefined`. It is a good idea to use
32180 * string constants for action types.
32181 *
32182 * @returns {Object} For convenience, the same action object you dispatched.
32183 *
32184 * Note that, if you use a custom middleware, it may wrap `dispatch()` to
32185 * return something else (for example, a Promise you can await).
32186 */
32187
32188
32189 function dispatch(action) {
32190 if (!isPlainObject(action)) {
32191 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.");
32192 }
32193
32194 if (typeof action.type === 'undefined') {
32195 throw new Error( false ? 0 : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
32196 }
32197
32198 if (isDispatching) {
32199 throw new Error( false ? 0 : 'Reducers may not dispatch actions.');
32200 }
32201
32202 try {
32203 isDispatching = true;
32204 currentState = currentReducer(currentState, action);
32205 } finally {
32206 isDispatching = false;
32207 }
32208
32209 var listeners = currentListeners = nextListeners;
32210
32211 for (var i = 0; i < listeners.length; i++) {
32212 var listener = listeners[i];
32213 listener();
32214 }
32215
32216 return action;
32217 }
32218 /**
32219 * Replaces the reducer currently used by the store to calculate the state.
32220 *
32221 * You might need this if your app implements code splitting and you want to
32222 * load some of the reducers dynamically. You might also need this if you
32223 * implement a hot reloading mechanism for Redux.
32224 *
32225 * @param {Function} nextReducer The reducer for the store to use instead.
32226 * @returns {void}
32227 */
32228
32229
32230 function replaceReducer(nextReducer) {
32231 if (typeof nextReducer !== 'function') {
32232 throw new Error( false ? 0 : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
32233 }
32234
32235 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
32236 // Any reducers that existed in both the new and old rootReducer
32237 // will receive the previous state. This effectively populates
32238 // the new state tree with any relevant data from the old one.
32239
32240 dispatch({
32241 type: ActionTypes.REPLACE
32242 });
32243 }
32244 /**
32245 * Interoperability point for observable/reactive libraries.
32246 * @returns {observable} A minimal observable of state changes.
32247 * For more information, see the observable proposal:
32248 * https://github.com/tc39/proposal-observable
32249 */
32250
32251
32252 function observable() {
32253 var _ref;
32254
32255 var outerSubscribe = subscribe;
32256 return _ref = {
32257 /**
32258 * The minimal observable subscription method.
32259 * @param {Object} observer Any object that can be used as an observer.
32260 * The observer object should have a `next` method.
32261 * @returns {subscription} An object with an `unsubscribe` method that can
32262 * be used to unsubscribe the observable from the store, and prevent further
32263 * emission of values from the observable.
32264 */
32265 subscribe: function subscribe(observer) {
32266 if (typeof observer !== 'object' || observer === null) {
32267 throw new Error( false ? 0 : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
32268 }
32269
32270 function observeState() {
32271 if (observer.next) {
32272 observer.next(getState());
32273 }
32274 }
32275
32276 observeState();
32277 var unsubscribe = outerSubscribe(observeState);
32278 return {
32279 unsubscribe: unsubscribe
32280 };
32281 }
32282 }, _ref[$$observable] = function () {
32283 return this;
32284 }, _ref;
32285 } // When a store is created, an "INIT" action is dispatched so that every
32286 // reducer returns their initial state. This effectively populates
32287 // the initial state tree.
32288
32289
32290 dispatch({
32291 type: ActionTypes.INIT
32292 });
32293 return _ref2 = {
32294 dispatch: dispatch,
32295 subscribe: subscribe,
32296 getState: getState,
32297 replaceReducer: replaceReducer
32298 }, _ref2[$$observable] = observable, _ref2;
32299 }
32300 /**
32301 * Creates a Redux store that holds the state tree.
32302 *
32303 * **We recommend using `configureStore` from the
32304 * `@reduxjs/toolkit` package**, which replaces `createStore`:
32305 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32306 *
32307 * The only way to change the data in the store is to call `dispatch()` on it.
32308 *
32309 * There should only be a single store in your app. To specify how different
32310 * parts of the state tree respond to actions, you may combine several reducers
32311 * into a single reducer function by using `combineReducers`.
32312 *
32313 * @param {Function} reducer A function that returns the next state tree, given
32314 * the current state tree and the action to handle.
32315 *
32316 * @param {any} [preloadedState] The initial state. You may optionally specify it
32317 * to hydrate the state from the server in universal apps, or to restore a
32318 * previously serialized user session.
32319 * If you use `combineReducers` to produce the root reducer function, this must be
32320 * an object with the same shape as `combineReducers` keys.
32321 *
32322 * @param {Function} [enhancer] The store enhancer. You may optionally specify it
32323 * to enhance the store with third-party capabilities such as middleware,
32324 * time travel, persistence, etc. The only store enhancer that ships with Redux
32325 * is `applyMiddleware()`.
32326 *
32327 * @returns {Store} A Redux store that lets you read the state, dispatch actions
32328 * and subscribe to changes.
32329 */
32330
32331 var legacy_createStore = createStore;
32332
32333 /**
32334 * Prints a warning in the console if it exists.
32335 *
32336 * @param {String} message The warning message.
32337 * @returns {void}
32338 */
32339 function warning(message) {
32340 /* eslint-disable no-console */
32341 if (typeof console !== 'undefined' && typeof console.error === 'function') {
32342 console.error(message);
32343 }
32344 /* eslint-enable no-console */
32345
32346
32347 try {
32348 // This error was thrown as a convenience so that if you enable
32349 // "break on all exceptions" in your console,
32350 // it would pause the execution at this line.
32351 throw new Error(message);
32352 } catch (e) {} // eslint-disable-line no-empty
32353
32354 }
32355
32356 function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
32357 var reducerKeys = Object.keys(reducers);
32358 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
32359
32360 if (reducerKeys.length === 0) {
32361 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
32362 }
32363
32364 if (!isPlainObject(inputState)) {
32365 return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
32366 }
32367
32368 var unexpectedKeys = Object.keys(inputState).filter(function (key) {
32369 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
32370 });
32371 unexpectedKeys.forEach(function (key) {
32372 unexpectedKeyCache[key] = true;
32373 });
32374 if (action && action.type === ActionTypes.REPLACE) return;
32375
32376 if (unexpectedKeys.length > 0) {
32377 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.");
32378 }
32379 }
32380
32381 function assertReducerShape(reducers) {
32382 Object.keys(reducers).forEach(function (key) {
32383 var reducer = reducers[key];
32384 var initialState = reducer(undefined, {
32385 type: ActionTypes.INIT
32386 });
32387
32388 if (typeof initialState === 'undefined') {
32389 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.");
32390 }
32391
32392 if (typeof reducer(undefined, {
32393 type: ActionTypes.PROBE_UNKNOWN_ACTION()
32394 }) === 'undefined') {
32395 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.");
32396 }
32397 });
32398 }
32399 /**
32400 * Turns an object whose values are different reducer functions, into a single
32401 * reducer function. It will call every child reducer, and gather their results
32402 * into a single state object, whose keys correspond to the keys of the passed
32403 * reducer functions.
32404 *
32405 * @param {Object} reducers An object whose values correspond to different
32406 * reducer functions that need to be combined into one. One handy way to obtain
32407 * it is to use ES6 `import * as reducers` syntax. The reducers may never return
32408 * undefined for any action. Instead, they should return their initial state
32409 * if the state passed to them was undefined, and the current state for any
32410 * unrecognized action.
32411 *
32412 * @returns {Function} A reducer function that invokes every reducer inside the
32413 * passed object, and builds a state object with the same shape.
32414 */
32415
32416
32417 function combineReducers(reducers) {
32418 var reducerKeys = Object.keys(reducers);
32419 var finalReducers = {};
32420
32421 for (var i = 0; i < reducerKeys.length; i++) {
32422 var key = reducerKeys[i];
32423
32424 if (true) {
32425 if (typeof reducers[key] === 'undefined') {
32426 warning("No reducer provided for key \"" + key + "\"");
32427 }
32428 }
32429
32430 if (typeof reducers[key] === 'function') {
32431 finalReducers[key] = reducers[key];
32432 }
32433 }
32434
32435 var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
32436 // keys multiple times.
32437
32438 var unexpectedKeyCache;
32439
32440 if (true) {
32441 unexpectedKeyCache = {};
32442 }
32443
32444 var shapeAssertionError;
32445
32446 try {
32447 assertReducerShape(finalReducers);
32448 } catch (e) {
32449 shapeAssertionError = e;
32450 }
32451
32452 return function combination(state, action) {
32453 if (state === void 0) {
32454 state = {};
32455 }
32456
32457 if (shapeAssertionError) {
32458 throw shapeAssertionError;
32459 }
32460
32461 if (true) {
32462 var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
32463
32464 if (warningMessage) {
32465 warning(warningMessage);
32466 }
32467 }
32468
32469 var hasChanged = false;
32470 var nextState = {};
32471
32472 for (var _i = 0; _i < finalReducerKeys.length; _i++) {
32473 var _key = finalReducerKeys[_i];
32474 var reducer = finalReducers[_key];
32475 var previousStateForKey = state[_key];
32476 var nextStateForKey = reducer(previousStateForKey, action);
32477
32478 if (typeof nextStateForKey === 'undefined') {
32479 var actionType = action && action.type;
32480 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.");
32481 }
32482
32483 nextState[_key] = nextStateForKey;
32484 hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
32485 }
32486
32487 hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
32488 return hasChanged ? nextState : state;
32489 };
32490 }
32491
32492 function bindActionCreator(actionCreator, dispatch) {
32493 return function () {
32494 return dispatch(actionCreator.apply(this, arguments));
32495 };
32496 }
32497 /**
32498 * Turns an object whose values are action creators, into an object with the
32499 * same keys, but with every function wrapped into a `dispatch` call so they
32500 * may be invoked directly. This is just a convenience method, as you can call
32501 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
32502 *
32503 * For convenience, you can also pass an action creator as the first argument,
32504 * and get a dispatch wrapped function in return.
32505 *
32506 * @param {Function|Object} actionCreators An object whose values are action
32507 * creator functions. One handy way to obtain it is to use ES6 `import * as`
32508 * syntax. You may also pass a single function.
32509 *
32510 * @param {Function} dispatch The `dispatch` function available on your Redux
32511 * store.
32512 *
32513 * @returns {Function|Object} The object mimicking the original object, but with
32514 * every action creator wrapped into the `dispatch` call. If you passed a
32515 * function as `actionCreators`, the return value will also be a single
32516 * function.
32517 */
32518
32519
32520 function bindActionCreators(actionCreators, dispatch) {
32521 if (typeof actionCreators === 'function') {
32522 return bindActionCreator(actionCreators, dispatch);
32523 }
32524
32525 if (typeof actionCreators !== 'object' || actionCreators === null) {
32526 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\"?");
32527 }
32528
32529 var boundActionCreators = {};
32530
32531 for (var key in actionCreators) {
32532 var actionCreator = actionCreators[key];
32533
32534 if (typeof actionCreator === 'function') {
32535 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
32536 }
32537 }
32538
32539 return boundActionCreators;
32540 }
32541
32542 /**
32543 * Composes single-argument functions from right to left. The rightmost
32544 * function can take multiple arguments as it provides the signature for
32545 * the resulting composite function.
32546 *
32547 * @param {...Function} funcs The functions to compose.
32548 * @returns {Function} A function obtained by composing the argument functions
32549 * from right to left. For example, compose(f, g, h) is identical to doing
32550 * (...args) => f(g(h(...args))).
32551 */
32552 function compose() {
32553 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
32554 funcs[_key] = arguments[_key];
32555 }
32556
32557 if (funcs.length === 0) {
32558 return function (arg) {
32559 return arg;
32560 };
32561 }
32562
32563 if (funcs.length === 1) {
32564 return funcs[0];
32565 }
32566
32567 return funcs.reduce(function (a, b) {
32568 return function () {
32569 return a(b.apply(void 0, arguments));
32570 };
32571 });
32572 }
32573
32574 /**
32575 * Creates a store enhancer that applies middleware to the dispatch method
32576 * of the Redux store. This is handy for a variety of tasks, such as expressing
32577 * asynchronous actions in a concise manner, or logging every action payload.
32578 *
32579 * See `redux-thunk` package as an example of the Redux middleware.
32580 *
32581 * Because middleware is potentially asynchronous, this should be the first
32582 * store enhancer in the composition chain.
32583 *
32584 * Note that each middleware will be given the `dispatch` and `getState` functions
32585 * as named arguments.
32586 *
32587 * @param {...Function} middlewares The middleware chain to be applied.
32588 * @returns {Function} A store enhancer applying the middleware.
32589 */
32590
32591 function applyMiddleware() {
32592 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
32593 middlewares[_key] = arguments[_key];
32594 }
32595
32596 return function (createStore) {
32597 return function () {
32598 var store = createStore.apply(void 0, arguments);
32599
32600 var _dispatch = function dispatch() {
32601 throw new Error( false ? 0 : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
32602 };
32603
32604 var middlewareAPI = {
32605 getState: store.getState,
32606 dispatch: function dispatch() {
32607 return _dispatch.apply(void 0, arguments);
32608 }
32609 };
32610 var chain = middlewares.map(function (middleware) {
32611 return middleware(middlewareAPI);
32612 });
32613 _dispatch = compose.apply(void 0, chain)(store.dispatch);
32614 return (0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])((0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])({}, store), {}, {
32615 dispatch: _dispatch
32616 });
32617 };
32618 };
32619 }
32620
32621
32622
32623
32624 /***/ }),
32625
32626 /***/ "../node_modules/reselect/es/defaultMemoize.js":
32627 /*!*****************************************************!*\
32628 !*** ../node_modules/reselect/es/defaultMemoize.js ***!
32629 \*****************************************************/
32630 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32631
32632 "use strict";
32633 __webpack_require__.r(__webpack_exports__);
32634 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32635 /* harmony export */ createCacheKeyComparator: () => (/* binding */ createCacheKeyComparator),
32636 /* harmony export */ defaultEqualityCheck: () => (/* binding */ defaultEqualityCheck),
32637 /* harmony export */ defaultMemoize: () => (/* binding */ defaultMemoize)
32638 /* harmony export */ });
32639 // Cache implementation based on Erik Rasmussen's `lru-memoize`:
32640 // https://github.com/erikras/lru-memoize
32641 var NOT_FOUND = 'NOT_FOUND';
32642
32643 function createSingletonCache(equals) {
32644 var entry;
32645 return {
32646 get: function get(key) {
32647 if (entry && equals(entry.key, key)) {
32648 return entry.value;
32649 }
32650
32651 return NOT_FOUND;
32652 },
32653 put: function put(key, value) {
32654 entry = {
32655 key: key,
32656 value: value
32657 };
32658 },
32659 getEntries: function getEntries() {
32660 return entry ? [entry] : [];
32661 },
32662 clear: function clear() {
32663 entry = undefined;
32664 }
32665 };
32666 }
32667
32668 function createLruCache(maxSize, equals) {
32669 var entries = [];
32670
32671 function get(key) {
32672 var cacheIndex = entries.findIndex(function (entry) {
32673 return equals(key, entry.key);
32674 }); // We found a cached entry
32675
32676 if (cacheIndex > -1) {
32677 var entry = entries[cacheIndex]; // Cached entry not at top of cache, move it to the top
32678
32679 if (cacheIndex > 0) {
32680 entries.splice(cacheIndex, 1);
32681 entries.unshift(entry);
32682 }
32683
32684 return entry.value;
32685 } // No entry found in cache, return sentinel
32686
32687
32688 return NOT_FOUND;
32689 }
32690
32691 function put(key, value) {
32692 if (get(key) === NOT_FOUND) {
32693 // TODO Is unshift slow?
32694 entries.unshift({
32695 key: key,
32696 value: value
32697 });
32698
32699 if (entries.length > maxSize) {
32700 entries.pop();
32701 }
32702 }
32703 }
32704
32705 function getEntries() {
32706 return entries;
32707 }
32708
32709 function clear() {
32710 entries = [];
32711 }
32712
32713 return {
32714 get: get,
32715 put: put,
32716 getEntries: getEntries,
32717 clear: clear
32718 };
32719 }
32720
32721 var defaultEqualityCheck = function defaultEqualityCheck(a, b) {
32722 return a === b;
32723 };
32724 function createCacheKeyComparator(equalityCheck) {
32725 return function areArgumentsShallowlyEqual(prev, next) {
32726 if (prev === null || next === null || prev.length !== next.length) {
32727 return false;
32728 } // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
32729
32730
32731 var length = prev.length;
32732
32733 for (var i = 0; i < length; i++) {
32734 if (!equalityCheck(prev[i], next[i])) {
32735 return false;
32736 }
32737 }
32738
32739 return true;
32740 };
32741 }
32742 // defaultMemoize now supports a configurable cache size with LRU behavior,
32743 // and optional comparison of the result value with existing values
32744 function defaultMemoize(func, equalityCheckOrOptions) {
32745 var providedOptions = typeof equalityCheckOrOptions === 'object' ? equalityCheckOrOptions : {
32746 equalityCheck: equalityCheckOrOptions
32747 };
32748 var _providedOptions$equa = providedOptions.equalityCheck,
32749 equalityCheck = _providedOptions$equa === void 0 ? defaultEqualityCheck : _providedOptions$equa,
32750 _providedOptions$maxS = providedOptions.maxSize,
32751 maxSize = _providedOptions$maxS === void 0 ? 1 : _providedOptions$maxS,
32752 resultEqualityCheck = providedOptions.resultEqualityCheck;
32753 var comparator = createCacheKeyComparator(equalityCheck);
32754 var cache = maxSize === 1 ? createSingletonCache(comparator) : createLruCache(maxSize, comparator); // we reference arguments instead of spreading them for performance reasons
32755
32756 function memoized() {
32757 var value = cache.get(arguments);
32758
32759 if (value === NOT_FOUND) {
32760 // @ts-ignore
32761 value = func.apply(null, arguments);
32762
32763 if (resultEqualityCheck) {
32764 var entries = cache.getEntries();
32765 var matchingEntry = entries.find(function (entry) {
32766 return resultEqualityCheck(entry.value, value);
32767 });
32768
32769 if (matchingEntry) {
32770 value = matchingEntry.value;
32771 }
32772 }
32773
32774 cache.put(arguments, value);
32775 }
32776
32777 return value;
32778 }
32779
32780 memoized.clearCache = function () {
32781 return cache.clear();
32782 };
32783
32784 return memoized;
32785 }
32786
32787 /***/ }),
32788
32789 /***/ "../node_modules/reselect/es/index.js":
32790 /*!********************************************!*\
32791 !*** ../node_modules/reselect/es/index.js ***!
32792 \********************************************/
32793 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32794
32795 "use strict";
32796 __webpack_require__.r(__webpack_exports__);
32797 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32798 /* harmony export */ createSelector: () => (/* binding */ createSelector),
32799 /* harmony export */ createSelectorCreator: () => (/* binding */ createSelectorCreator),
32800 /* harmony export */ createStructuredSelector: () => (/* binding */ createStructuredSelector),
32801 /* harmony export */ defaultEqualityCheck: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultEqualityCheck),
32802 /* harmony export */ defaultMemoize: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize)
32803 /* harmony export */ });
32804 /* harmony import */ var _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultMemoize */ "../node_modules/reselect/es/defaultMemoize.js");
32805
32806
32807
32808 function getDependencies(funcs) {
32809 var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
32810
32811 if (!dependencies.every(function (dep) {
32812 return typeof dep === 'function';
32813 })) {
32814 var dependencyTypes = dependencies.map(function (dep) {
32815 return typeof dep === 'function' ? "function " + (dep.name || 'unnamed') + "()" : typeof dep;
32816 }).join(', ');
32817 throw new Error("createSelector expects all input-selectors to be functions, but received the following types: [" + dependencyTypes + "]");
32818 }
32819
32820 return dependencies;
32821 }
32822
32823 function createSelectorCreator(memoize) {
32824 for (var _len = arguments.length, memoizeOptionsFromArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
32825 memoizeOptionsFromArgs[_key - 1] = arguments[_key];
32826 }
32827
32828 var createSelector = function createSelector() {
32829 for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
32830 funcs[_key2] = arguments[_key2];
32831 }
32832
32833 var _recomputations = 0;
32834
32835 var _lastResult; // Due to the intricacies of rest params, we can't do an optional arg after `...funcs`.
32836 // So, start by declaring the default value here.
32837 // (And yes, the words 'memoize' and 'options' appear too many times in this next sequence.)
32838
32839
32840 var directlyPassedOptions = {
32841 memoizeOptions: undefined
32842 }; // Normally, the result func or "output selector" is the last arg
32843
32844 var resultFunc = funcs.pop(); // If the result func is actually an _object_, assume it's our options object
32845
32846 if (typeof resultFunc === 'object') {
32847 directlyPassedOptions = resultFunc; // and pop the real result func off
32848
32849 resultFunc = funcs.pop();
32850 }
32851
32852 if (typeof resultFunc !== 'function') {
32853 throw new Error("createSelector expects an output function after the inputs, but received: [" + typeof resultFunc + "]");
32854 } // Determine which set of options we're using. Prefer options passed directly,
32855 // but fall back to options given to createSelectorCreator.
32856
32857
32858 var _directlyPassedOption = directlyPassedOptions,
32859 _directlyPassedOption2 = _directlyPassedOption.memoizeOptions,
32860 memoizeOptions = _directlyPassedOption2 === void 0 ? memoizeOptionsFromArgs : _directlyPassedOption2; // Simplifying assumption: it's unlikely that the first options arg of the provided memoizer
32861 // is an array. In most libs I've looked at, it's an equality function or options object.
32862 // Based on that, if `memoizeOptions` _is_ an array, we assume it's a full
32863 // user-provided array of options. Otherwise, it must be just the _first_ arg, and so
32864 // we wrap it in an array so we can apply it.
32865
32866 var finalMemoizeOptions = Array.isArray(memoizeOptions) ? memoizeOptions : [memoizeOptions];
32867 var dependencies = getDependencies(funcs);
32868 var memoizedResultFunc = memoize.apply(void 0, [function recomputationWrapper() {
32869 _recomputations++; // apply arguments instead of spreading for performance.
32870
32871 return resultFunc.apply(null, arguments);
32872 }].concat(finalMemoizeOptions)); // If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
32873
32874 var selector = memoize(function dependenciesChecker() {
32875 var params = [];
32876 var length = dependencies.length;
32877
32878 for (var i = 0; i < length; i++) {
32879 // apply arguments instead of spreading and mutate a local list of params for performance.
32880 // @ts-ignore
32881 params.push(dependencies[i].apply(null, arguments));
32882 } // apply arguments instead of spreading for performance.
32883
32884
32885 _lastResult = memoizedResultFunc.apply(null, params);
32886 return _lastResult;
32887 });
32888 Object.assign(selector, {
32889 resultFunc: resultFunc,
32890 memoizedResultFunc: memoizedResultFunc,
32891 dependencies: dependencies,
32892 lastResult: function lastResult() {
32893 return _lastResult;
32894 },
32895 recomputations: function recomputations() {
32896 return _recomputations;
32897 },
32898 resetRecomputations: function resetRecomputations() {
32899 return _recomputations = 0;
32900 }
32901 });
32902 return selector;
32903 }; // @ts-ignore
32904
32905
32906 return createSelector;
32907 }
32908 var createSelector = /* #__PURE__ */createSelectorCreator(_defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize);
32909 // Manual definition of state and output arguments
32910 var createStructuredSelector = function createStructuredSelector(selectors, selectorCreator) {
32911 if (selectorCreator === void 0) {
32912 selectorCreator = createSelector;
32913 }
32914
32915 if (typeof selectors !== 'object') {
32916 throw new Error('createStructuredSelector expects first argument to be an object ' + ("where each property is a selector, instead received a " + typeof selectors));
32917 }
32918
32919 var objectKeys = Object.keys(selectors);
32920 var resultSelector = selectorCreator( // @ts-ignore
32921 objectKeys.map(function (key) {
32922 return selectors[key];
32923 }), function () {
32924 for (var _len3 = arguments.length, values = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
32925 values[_key3] = arguments[_key3];
32926 }
32927
32928 return values.reduce(function (composition, value, index) {
32929 composition[objectKeys[index]] = value;
32930 return composition;
32931 }, {});
32932 });
32933 return resultSelector;
32934 };
32935
32936 /***/ }),
32937
32938 /***/ "@wordpress/i18n":
32939 /*!**************************!*\
32940 !*** external "wp.i18n" ***!
32941 \**************************/
32942 /***/ ((module) => {
32943
32944 "use strict";
32945 module.exports = wp.i18n;
32946
32947 /***/ })
32948
32949 /******/ });
32950 /************************************************************************/
32951 /******/ // The module cache
32952 /******/ var __webpack_module_cache__ = {};
32953 /******/
32954 /******/ // The require function
32955 /******/ function __webpack_require__(moduleId) {
32956 /******/ // Check if module is in cache
32957 /******/ var cachedModule = __webpack_module_cache__[moduleId];
32958 /******/ if (cachedModule !== undefined) {
32959 /******/ return cachedModule.exports;
32960 /******/ }
32961 /******/ // Create a new module (and put it into the cache)
32962 /******/ var module = __webpack_module_cache__[moduleId] = {
32963 /******/ // no module.id needed
32964 /******/ // no module.loaded needed
32965 /******/ exports: {}
32966 /******/ };
32967 /******/
32968 /******/ // Execute the module function
32969 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
32970 /******/
32971 /******/ // Return the exports of the module
32972 /******/ return module.exports;
32973 /******/ }
32974 /******/
32975 /************************************************************************/
32976 /******/ /* webpack/runtime/define property getters */
32977 /******/ (() => {
32978 /******/ // define getter functions for harmony exports
32979 /******/ __webpack_require__.d = (exports, definition) => {
32980 /******/ for(var key in definition) {
32981 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
32982 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
32983 /******/ }
32984 /******/ }
32985 /******/ };
32986 /******/ })();
32987 /******/
32988 /******/ /* webpack/runtime/global */
32989 /******/ (() => {
32990 /******/ __webpack_require__.g = (function() {
32991 /******/ if (typeof globalThis === 'object') return globalThis;
32992 /******/ try {
32993 /******/ return this || new Function('return this')();
32994 /******/ } catch (e) {
32995 /******/ if (typeof window === 'object') return window;
32996 /******/ }
32997 /******/ })();
32998 /******/ })();
32999 /******/
33000 /******/ /* webpack/runtime/hasOwnProperty shorthand */
33001 /******/ (() => {
33002 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
33003 /******/ })();
33004 /******/
33005 /******/ /* webpack/runtime/make namespace object */
33006 /******/ (() => {
33007 /******/ // define __esModule on exports
33008 /******/ __webpack_require__.r = (exports) => {
33009 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
33010 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
33011 /******/ }
33012 /******/ Object.defineProperty(exports, '__esModule', { value: true });
33013 /******/ };
33014 /******/ })();
33015 /******/
33016 /************************************************************************/
33017 var __webpack_exports__ = {};
33018 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
33019 (() => {
33020 "use strict";
33021 /*!******************************************!*\
33022 !*** ../core/common/assets/js/common.js ***!
33023 \******************************************/
33024
33025
33026 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
33027 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
33028 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
33029 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
33030 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
33031 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
33032 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
33033 var _helpers = _interopRequireDefault(__webpack_require__(/*! ./utils/helpers */ "../core/common/assets/js/utils/helpers.js"));
33034 var _storage = _interopRequireDefault(__webpack_require__(/*! ./utils/storage */ "../core/common/assets/js/utils/storage.js"));
33035 var _debug = _interopRequireDefault(__webpack_require__(/*! ./utils/debug */ "../core/common/assets/js/utils/debug.js"));
33036 var _ajax = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/ajax/assets/js/ajax */ "../core/common/modules/ajax/assets/js/ajax.js"));
33037 var _finder = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/finder/assets/js/finder */ "../core/common/modules/finder/assets/js/finder.js"));
33038 var _connect = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/connect/assets/js/connect */ "../core/common/modules/connect/assets/js/connect.js"));
33039 var _component = _interopRequireDefault(__webpack_require__(/*! ./components/wordpress/component */ "../core/common/assets/js/components/wordpress/component.js"));
33040 var _component2 = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/data/component */ "../core/common/modules/event-tracker/assets/js/data/component.js"));
33041 var _events = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/events */ "../core/common/modules/event-tracker/assets/js/events.js"));
33042 var _module = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/events-manager/assets/js/module */ "../core/common/modules/events-manager/assets/js/module.js"));
33043 var _notifications = _interopRequireDefault(__webpack_require__(/*! elementor-utils/notifications */ "../assets/dev/js/utils/notifications.js"));
33044 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)); }
33045 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
33046 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; }
33047 var ElementorCommonApp = /*#__PURE__*/function (_elementorModules$Vie) {
33048 function ElementorCommonApp() {
33049 (0, _classCallCheck2.default)(this, ElementorCommonApp);
33050 return _callSuper(this, ElementorCommonApp, arguments);
33051 }
33052 (0, _inherits2.default)(ElementorCommonApp, _elementorModules$Vie);
33053 return (0, _createClass2.default)(ElementorCommonApp, [{
33054 key: "setMarionetteTemplateCompiler",
33055 value: function setMarionetteTemplateCompiler() {
33056 Marionette.TemplateCache.prototype.compileTemplate = function (rawTemplate, options) {
33057 options = {
33058 evaluate: /<#([\s\S]+?)#>/g,
33059 interpolate: /{{{([\s\S]+?)}}}/g,
33060 escape: /{{([^}]+?)}}(?!})/g
33061 };
33062 return _.template(rawTemplate, options);
33063 };
33064 }
33065 }, {
33066 key: "getDefaultElements",
33067 value: function getDefaultElements() {
33068 return {
33069 $window: jQuery(window),
33070 $document: jQuery(document),
33071 $body: jQuery(document.body)
33072 };
33073 }
33074 }, {
33075 key: "initComponents",
33076 value: function initComponents() {
33077 this.events = new _events.default();
33078 this.eventsManager = new _module.default();
33079 this.debug = new _debug.default();
33080 this.helpers = new _helpers.default();
33081 this.storage = new _storage.default();
33082 this.dialogsManager = new DialogsManager.Instance();
33083 this.notifications = new _notifications.default();
33084 this.api = window.$e;
33085 $e.components.register(new _component2.default());
33086 elementorCommon.elements.$window.on('elementor:init-components', function () {
33087 $e.components.register(new _component.default());
33088 });
33089 this.initModules();
33090 }
33091 }, {
33092 key: "initModules",
33093 value: function initModules() {
33094 var _this = this;
33095 var activeModules = this.config.activeModules;
33096 var modules = {
33097 ajax: _ajax.default,
33098 finder: _finder.default,
33099 connect: _connect.default
33100 };
33101 activeModules.forEach(function (name) {
33102 if (modules[name]) {
33103 _this[name] = new modules[name](_this.config[name]);
33104 }
33105 });
33106 }
33107 }, {
33108 key: "compileArrayTemplateArgs",
33109 value: function compileArrayTemplateArgs(template, templateArgs) {
33110 return template.replace(/%(?:(\d+)\$)?s/g, function (match, number) {
33111 if (!number) {
33112 number = 1;
33113 }
33114 number--;
33115 return undefined !== templateArgs[number] ? templateArgs[number] : match;
33116 });
33117 }
33118 }, {
33119 key: "compileObjectTemplateArgs",
33120 value: function compileObjectTemplateArgs(template, templateArgs) {
33121 return template.replace(/{{(?:([ \w]+))}}/g, function (match, name) {
33122 return templateArgs[name] ? templateArgs[name] : match;
33123 });
33124 }
33125 }, {
33126 key: "compileTemplate",
33127 value: function compileTemplate(template, templateArgs) {
33128 return jQuery.isPlainObject(templateArgs) ? this.compileObjectTemplateArgs(template, templateArgs) : this.compileArrayTemplateArgs(template, templateArgs);
33129 }
33130 }, {
33131 key: "translate",
33132 value: function translate(stringKey, context, templateArgs, i18nStack) {
33133 if (context) {
33134 i18nStack = this.config[context].i18n;
33135 }
33136 if (!i18nStack) {
33137 i18nStack = this.config.i18n;
33138 }
33139 var string = i18nStack[stringKey];
33140 if (undefined === string) {
33141 string = stringKey;
33142 }
33143 if (templateArgs) {
33144 string = this.compileTemplate(string, templateArgs);
33145 }
33146 return string;
33147 }
33148 }, {
33149 key: "onInit",
33150 value: function onInit() {
33151 _superPropGet(ElementorCommonApp, "onInit", this, 3)([]);
33152 this.config = elementorCommonConfig;
33153 this.setMarionetteTemplateCompiler();
33154 }
33155 }]);
33156 }(elementorModules.ViewModule);
33157 window.elementorCommon = new ElementorCommonApp();
33158 elementorCommon.initComponents();
33159 })();
33160
33161 /******/ })()
33162 ;
33163 //# sourceMappingURL=common.js.map