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

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

33,176 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 this.config = _eventsConfig.default;
1996 if (!this.canSendEvents()) {
1997 return;
1998 }
1999 this.initializeMixpanel();
2000 this.enableTracking();
2001 }
2002 }, {
2003 key: "initializeMixpanel",
2004 value: function initializeMixpanel() {
2005 var _elementorCommon$conf;
2006 _mixpanelBrowser.default.init((_elementorCommon$conf = elementorCommon.config.editor_events) === null || _elementorCommon$conf === void 0 ? void 0 : _elementorCommon$conf.token, {
2007 persistence: 'localStorage',
2008 autocapture: false,
2009 record_sessions_percent: 0,
2010 record_idle_timeout_ms: 60000,
2011 record_max_ms: 300000,
2012 record_mask_text_selector: '',
2013 flags: true,
2014 api_hosts: {
2015 flags: 'https://api-eu.mixpanel.com'
2016 }
2017 });
2018 }
2019 }, {
2020 key: "enableTracking",
2021 value: function enableTracking() {
2022 var _elementorCommon$conf2;
2023 var userId = (_elementorCommon$conf2 = elementorCommon.config.library_connect) === null || _elementorCommon$conf2 === void 0 ? void 0 : _elementorCommon$conf2.user_id;
2024 if (userId) {
2025 var _elementorCommon$conf3;
2026 _mixpanelBrowser.default.identify(userId);
2027 _mixpanelBrowser.default.register({
2028 appType: 'Editor'
2029 });
2030 _mixpanelBrowser.default.people.set_once({
2031 $user_id: userId,
2032 $last_login: new Date().toISOString(),
2033 $plan_type: ((_elementorCommon$conf3 = elementorCommon.config.library_connect) === null || _elementorCommon$conf3 === void 0 ? void 0 : _elementorCommon$conf3.plan_type) || _tiers.TIERS.free
2034 });
2035 }
2036 this.trackingEnabled = true;
2037 }
2038 }, {
2039 key: "dispatchEvent",
2040 value: function dispatchEvent(name, data) {
2041 var _elementorCommon$conf4, _elementorCommon$conf5, _elementorCommon$conf6, _elementorCommon$conf7, _elementorCommon$conf8, _elementorCommon$conf9, _elementorCommon$conf0, _elementorCommon$conf1, _elementorCommon$conf10;
2042 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2043 if (!this.canSendEvents()) {
2044 return;
2045 }
2046 if (!this.trackingEnabled) {
2047 this.enableTracking();
2048 }
2049 var eventData = _objectSpread({
2050 user_id: ((_elementorCommon$conf4 = elementorCommon.config.library_connect) === null || _elementorCommon$conf4 === void 0 ? void 0 : _elementorCommon$conf4.user_id) || null,
2051 user_roles: ((_elementorCommon$conf5 = elementorCommon.config.library_connect) === null || _elementorCommon$conf5 === void 0 ? void 0 : _elementorCommon$conf5.user_roles) || [],
2052 subscription_id: ((_elementorCommon$conf6 = elementorCommon.config.editor_events) === null || _elementorCommon$conf6 === void 0 ? void 0 : _elementorCommon$conf6.subscription_id) || null,
2053 user_tier: ((_elementorCommon$conf7 = elementorCommon.config.library_connect) === null || _elementorCommon$conf7 === void 0 ? void 0 : _elementorCommon$conf7.current_access_tier) || null,
2054 url: (_elementorCommon$conf8 = elementorCommon.config.editor_events) === null || _elementorCommon$conf8 === void 0 ? void 0 : _elementorCommon$conf8.site_url,
2055 wp_version: (_elementorCommon$conf9 = elementorCommon.config.editor_events) === null || _elementorCommon$conf9 === void 0 ? void 0 : _elementorCommon$conf9.wp_version,
2056 client_id: (_elementorCommon$conf0 = elementorCommon.config.editor_events) === null || _elementorCommon$conf0 === void 0 ? void 0 : _elementorCommon$conf0.site_key,
2057 app_version: (_elementorCommon$conf1 = elementorCommon.config.editor_events) === null || _elementorCommon$conf1 === void 0 ? void 0 : _elementorCommon$conf1.elementor_version,
2058 site_language: (_elementorCommon$conf10 = elementorCommon.config.editor_events) === null || _elementorCommon$conf10 === void 0 ? void 0 : _elementorCommon$conf10.site_language
2059 }, data);
2060 _mixpanelBrowser.default.track(name, eventData, options);
2061 }
2062 }, {
2063 key: "startSessionRecording",
2064 value: function startSessionRecording() {
2065 if (!this.canSendEvents() || this.isSessionRecordingInProgress()) {
2066 return;
2067 }
2068 if (!this.trackingEnabled) {
2069 this.enableTracking();
2070 }
2071 _mixpanelBrowser.default.start_session_recording();
2072 this.setSessionRecordingInProgress(true);
2073 }
2074 }, {
2075 key: "stopSessionRecording",
2076 value: function stopSessionRecording() {
2077 if (!this.canSendEvents() || !this.isSessionRecordingInProgress()) {
2078 return;
2079 }
2080 _mixpanelBrowser.default.stop_session_recording();
2081 this.setSessionRecordingInProgress(false);
2082 }
2083 }, {
2084 key: "setSessionRecordingInProgress",
2085 value: function setSessionRecordingInProgress(value) {
2086 if ('boolean' !== typeof value) {
2087 return;
2088 }
2089 _classPrivateFieldSet(_sessionRecordingInProgress, this, value);
2090 }
2091 }, {
2092 key: "isSessionRecordingInProgress",
2093 value: function isSessionRecordingInProgress() {
2094 return _classPrivateFieldGet(_sessionRecordingInProgress, this);
2095 }
2096 }, {
2097 key: "featureFlagIsActive",
2098 value: function () {
2099 var _featureFlagIsActive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(flagName) {
2100 var _mixpanel$flags;
2101 var isEnabled;
2102 return _regenerator.default.wrap(function (_context) {
2103 while (1) switch (_context.prev = _context.next) {
2104 case 0:
2105 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))) {
2106 _context.next = 1;
2107 break;
2108 }
2109 return _context.abrupt("return", false);
2110 case 1:
2111 _context.next = 2;
2112 return _mixpanelBrowser.default.flags.is_enabled(flagName, false);
2113 case 2:
2114 isEnabled = _context.sent;
2115 return _context.abrupt("return", true === isEnabled);
2116 case 3:
2117 case "end":
2118 return _context.stop();
2119 }
2120 }, _callee);
2121 }));
2122 function featureFlagIsActive(_x) {
2123 return _featureFlagIsActive.apply(this, arguments);
2124 }
2125 return featureFlagIsActive;
2126 }()
2127 }, {
2128 key: "getExperimentVariant",
2129 value: function () {
2130 var _getExperimentVariant = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(experimentName) {
2131 var defaultValue,
2132 _elementorCommon$conf11,
2133 _elementorCommon$conf12,
2134 isAbTestingEnabled,
2135 variant,
2136 _args2 = arguments,
2137 _t;
2138 return _regenerator.default.wrap(function (_context2) {
2139 while (1) switch (_context2.prev = _context2.next) {
2140 case 0:
2141 defaultValue = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 'control';
2142 _context2.prev = 1;
2143 if (this.canSendEvents()) {
2144 _context2.next = 2;
2145 break;
2146 }
2147 return _context2.abrupt("return", defaultValue);
2148 case 2:
2149 isAbTestingEnabled = (_elementorCommon$conf11 = (_elementorCommon$conf12 = elementorCommon.config.editor_events) === null || _elementorCommon$conf12 === void 0 ? void 0 : _elementorCommon$conf12.flags_enabled) !== null && _elementorCommon$conf11 !== void 0 ? _elementorCommon$conf11 : false;
2150 if (isAbTestingEnabled) {
2151 _context2.next = 3;
2152 break;
2153 }
2154 return _context2.abrupt("return", defaultValue);
2155 case 3:
2156 if (_mixpanelBrowser.default) {
2157 _context2.next = 4;
2158 break;
2159 }
2160 return _context2.abrupt("return", defaultValue);
2161 case 4:
2162 if (!this.trackingEnabled) {
2163 this.enableTracking();
2164 }
2165 if (_mixpanelBrowser.default.flags) {
2166 _context2.next = 5;
2167 break;
2168 }
2169 return _context2.abrupt("return", defaultValue);
2170 case 5:
2171 if (!('function' !== typeof _mixpanelBrowser.default.flags.get_variant_value)) {
2172 _context2.next = 6;
2173 break;
2174 }
2175 return _context2.abrupt("return", defaultValue);
2176 case 6:
2177 _context2.next = 7;
2178 return _mixpanelBrowser.default.flags.get_variant_value(experimentName, defaultValue);
2179 case 7:
2180 variant = _context2.sent;
2181 if (!(undefined === variant || null === variant)) {
2182 _context2.next = 8;
2183 break;
2184 }
2185 return _context2.abrupt("return", defaultValue);
2186 case 8:
2187 return _context2.abrupt("return", variant);
2188 case 9:
2189 _context2.prev = 9;
2190 _t = _context2["catch"](1);
2191 return _context2.abrupt("return", defaultValue);
2192 case 10:
2193 case "end":
2194 return _context2.stop();
2195 }
2196 }, _callee2, this, [[1, 9]]);
2197 }));
2198 function getExperimentVariant(_x2) {
2199 return _getExperimentVariant.apply(this, arguments);
2200 }
2201 return getExperimentVariant;
2202 }()
2203 }, {
2204 key: "startExperiment",
2205 value: function startExperiment(experimentName, experimentVariant) {
2206 if (!this.trackingEnabled) {
2207 return;
2208 }
2209 _mixpanelBrowser.default.track('$experiment_started', {
2210 'Experiment name': experimentName,
2211 'Variant name': experimentVariant
2212 });
2213 }
2214 }, {
2215 key: "canSendEvents",
2216 value: function canSendEvents() {
2217 var _elementorCommon;
2218 return !!((_elementorCommon = elementorCommon) !== null && _elementorCommon !== void 0 && (_elementorCommon = _elementorCommon.config) !== null && _elementorCommon !== void 0 && (_elementorCommon = _elementorCommon.editor_events) !== null && _elementorCommon !== void 0 && _elementorCommon.can_send_events);
2219 }
2220 }]);
2221 }(elementorModules.Module);
2222
2223 /***/ }),
2224
2225 /***/ "../core/common/modules/finder/assets/js/commands/index.js":
2226 /*!*****************************************************************!*\
2227 !*** ../core/common/modules/finder/assets/js/commands/index.js ***!
2228 \*****************************************************************/
2229 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2230
2231 "use strict";
2232
2233
2234 Object.defineProperty(exports, "__esModule", ({
2235 value: true
2236 }));
2237 Object.defineProperty(exports, "NavigateDown", ({
2238 enumerable: true,
2239 get: function get() {
2240 return _navigateDown.NavigateDown;
2241 }
2242 }));
2243 Object.defineProperty(exports, "NavigateSelect", ({
2244 enumerable: true,
2245 get: function get() {
2246 return _navigateSelect.NavigateSelect;
2247 }
2248 }));
2249 Object.defineProperty(exports, "NavigateUp", ({
2250 enumerable: true,
2251 get: function get() {
2252 return _navigateUp.NavigateUp;
2253 }
2254 }));
2255 var _navigateDown = __webpack_require__(/*! ./navigate-down */ "../core/common/modules/finder/assets/js/commands/navigate-down.js");
2256 var _navigateSelect = __webpack_require__(/*! ./navigate-select */ "../core/common/modules/finder/assets/js/commands/navigate-select.js");
2257 var _navigateUp = __webpack_require__(/*! ./navigate-up */ "../core/common/modules/finder/assets/js/commands/navigate-up.js");
2258
2259 /***/ }),
2260
2261 /***/ "../core/common/modules/finder/assets/js/commands/navigate-down.js":
2262 /*!*************************************************************************!*\
2263 !*** ../core/common/modules/finder/assets/js/commands/navigate-down.js ***!
2264 \*************************************************************************/
2265 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2266
2267 "use strict";
2268
2269
2270 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2271 Object.defineProperty(exports, "__esModule", ({
2272 value: true
2273 }));
2274 exports["default"] = exports.NavigateDown = void 0;
2275 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2276 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2277 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2278 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2279 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2280 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2281 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)); }
2282 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2283 var NavigateDown = exports.NavigateDown = /*#__PURE__*/function (_CommandBase) {
2284 function NavigateDown() {
2285 (0, _classCallCheck2.default)(this, NavigateDown);
2286 return _callSuper(this, NavigateDown, arguments);
2287 }
2288 (0, _inherits2.default)(NavigateDown, _CommandBase);
2289 return (0, _createClass2.default)(NavigateDown, [{
2290 key: "apply",
2291 value: function apply() {
2292 this.component.getItemsView().activateNextItem();
2293 }
2294 }]);
2295 }(_commandBase.default);
2296 var _default = exports["default"] = NavigateDown;
2297
2298 /***/ }),
2299
2300 /***/ "../core/common/modules/finder/assets/js/commands/navigate-select.js":
2301 /*!***************************************************************************!*\
2302 !*** ../core/common/modules/finder/assets/js/commands/navigate-select.js ***!
2303 \***************************************************************************/
2304 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2305
2306 "use strict";
2307
2308
2309 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2310 Object.defineProperty(exports, "__esModule", ({
2311 value: true
2312 }));
2313 exports["default"] = exports.NavigateSelect = void 0;
2314 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2315 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2316 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2317 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2318 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2319 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2320 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)); }
2321 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2322 var NavigateSelect = exports.NavigateSelect = /*#__PURE__*/function (_CommandBase) {
2323 function NavigateSelect() {
2324 (0, _classCallCheck2.default)(this, NavigateSelect);
2325 return _callSuper(this, NavigateSelect, arguments);
2326 }
2327 (0, _inherits2.default)(NavigateSelect, _CommandBase);
2328 return (0, _createClass2.default)(NavigateSelect, [{
2329 key: "apply",
2330 value: function apply(args) {
2331 this.component.getItemsView().goToActiveItem(args);
2332 }
2333 }]);
2334 }(_commandBase.default);
2335 var _default = exports["default"] = NavigateSelect;
2336
2337 /***/ }),
2338
2339 /***/ "../core/common/modules/finder/assets/js/commands/navigate-up.js":
2340 /*!***********************************************************************!*\
2341 !*** ../core/common/modules/finder/assets/js/commands/navigate-up.js ***!
2342 \***********************************************************************/
2343 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2344
2345 "use strict";
2346
2347
2348 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2349 Object.defineProperty(exports, "__esModule", ({
2350 value: true
2351 }));
2352 exports["default"] = exports.NavigateUp = void 0;
2353 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2354 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2355 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2356 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2357 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2358 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2359 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)); }
2360 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2361 var NavigateUp = exports.NavigateUp = /*#__PURE__*/function (_CommandBase) {
2362 function NavigateUp() {
2363 (0, _classCallCheck2.default)(this, NavigateUp);
2364 return _callSuper(this, NavigateUp, arguments);
2365 }
2366 (0, _inherits2.default)(NavigateUp, _CommandBase);
2367 return (0, _createClass2.default)(NavigateUp, [{
2368 key: "apply",
2369 value: function apply() {
2370 this.component.getItemsView().activateNextItem(true);
2371 }
2372 }]);
2373 }(_commandBase.default);
2374 var _default = exports["default"] = NavigateUp;
2375
2376 /***/ }),
2377
2378 /***/ "../core/common/modules/finder/assets/js/component.js":
2379 /*!************************************************************!*\
2380 !*** ../core/common/modules/finder/assets/js/component.js ***!
2381 \************************************************************/
2382 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2383
2384 "use strict";
2385
2386
2387 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2388 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2389 Object.defineProperty(exports, "__esModule", ({
2390 value: true
2391 }));
2392 exports["default"] = void 0;
2393 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2394 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2395 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2396 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2397 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2398 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2399 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2400 var _componentModalBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-modal-base */ "../modules/web-cli/assets/js/modules/component-modal-base.js"));
2401 var _layout = _interopRequireDefault(__webpack_require__(/*! ./modal/views/layout */ "../core/common/modules/finder/assets/js/modal/views/layout.js"));
2402 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../core/common/modules/finder/assets/js/commands/index.js"));
2403 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); }
2404 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; }
2405 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; }
2406 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)); }
2407 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2408 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; }
2409 var Component = exports["default"] = /*#__PURE__*/function (_ComponentModalBase) {
2410 function Component() {
2411 (0, _classCallCheck2.default)(this, Component);
2412 return _callSuper(this, Component, arguments);
2413 }
2414 (0, _inherits2.default)(Component, _ComponentModalBase);
2415 return (0, _createClass2.default)(Component, [{
2416 key: "getNamespace",
2417 value: function getNamespace() {
2418 return 'finder';
2419 }
2420 }, {
2421 key: "defaultShortcuts",
2422 value: function defaultShortcuts() {
2423 var _this = this;
2424 return {
2425 '': {
2426 keys: 'ctrl+e'
2427 },
2428 'navigate-down': {
2429 keys: 'down',
2430 scopes: [this.getNamespace()],
2431 dependency: function dependency() {
2432 return _this.getItemsView();
2433 }
2434 },
2435 'navigate-up': {
2436 keys: 'up',
2437 scopes: [this.getNamespace()],
2438 dependency: function dependency() {
2439 return _this.getItemsView();
2440 }
2441 },
2442 'navigate-select': {
2443 keys: 'enter',
2444 scopes: [this.getNamespace()],
2445 dependency: function dependency() {
2446 return _this.getItemsView().$activeItem;
2447 }
2448 }
2449 };
2450 }
2451 }, {
2452 key: "defaultCommands",
2453 value: function defaultCommands() {
2454 var modalCommands = _superPropGet(Component, "defaultCommands", this, 3)([]);
2455 return _objectSpread(_objectSpread({
2456 'navigate/down': function navigate_down() {
2457 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/down' )", '3.0.0', "$e.run( 'finder/navigate-down' )");
2458 $e.run('finder/navigate-down');
2459 },
2460 'navigate/up': function navigate_up() {
2461 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/up' )", '3.0.0', "$e.run( 'finder/navigate-up' )");
2462 $e.run('finder/navigate-up');
2463 },
2464 'navigate/select': function navigate_select(event) {
2465 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/select', event )", '3.0.0', "$e.run( 'finder/navigate-select', event )");
2466
2467 // TODO: Fix $e.shortcuts use args. ( args.event ).
2468 $e.run('finder/navigate-select', event);
2469 }
2470 }, modalCommands), this.importCommands(commands));
2471 }
2472 }, {
2473 key: "getModalLayout",
2474 value: function getModalLayout() {
2475 return _layout.default;
2476 }
2477 }, {
2478 key: "getItemsView",
2479 value: function getItemsView() {
2480 return this.layout.modalContent.currentView.content.currentView;
2481 }
2482 }]);
2483 }(_componentModalBase.default);
2484
2485 /***/ }),
2486
2487 /***/ "../core/common/modules/finder/assets/js/finder.js":
2488 /*!*********************************************************!*\
2489 !*** ../core/common/modules/finder/assets/js/finder.js ***!
2490 \*********************************************************/
2491 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2492
2493 "use strict";
2494
2495
2496 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2497 Object.defineProperty(exports, "__esModule", ({
2498 value: true
2499 }));
2500 exports["default"] = void 0;
2501 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2502 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2503 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2504 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2505 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2506 var _component = _interopRequireDefault(__webpack_require__(/*! ./component */ "../core/common/modules/finder/assets/js/component.js"));
2507 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)); }
2508 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2509 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2510 function _default() {
2511 (0, _classCallCheck2.default)(this, _default);
2512 return _callSuper(this, _default, arguments);
2513 }
2514 (0, _inherits2.default)(_default, _elementorModules$Mod);
2515 return (0, _createClass2.default)(_default, [{
2516 key: "onInit",
2517 value: function onInit() {
2518 // TODO: Temp fix, do not load finder in theme-builder.
2519 // Better to pass into '$e' constructor the app owner. ( admin, editor, preview, iframe ).
2520 if (window.top !== window) {
2521 return;
2522 }
2523 this.channel = Backbone.Radio.channel('ELEMENTOR:finder');
2524 $e.components.register(new _component.default({
2525 manager: this
2526 }));
2527 }
2528 }]);
2529 }(elementorModules.Module);
2530
2531 /***/ }),
2532
2533 /***/ "../core/common/modules/finder/assets/js/modal/model/item.js":
2534 /*!*******************************************************************!*\
2535 !*** ../core/common/modules/finder/assets/js/modal/model/item.js ***!
2536 \*******************************************************************/
2537 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2538
2539 "use strict";
2540
2541
2542 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2543 Object.defineProperty(exports, "__esModule", ({
2544 value: true
2545 }));
2546 exports["default"] = void 0;
2547 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2548 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2549 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2550 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2551 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2552 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)); }
2553 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2554 var _default = exports["default"] = /*#__PURE__*/function (_Backbone$Model) {
2555 function _default() {
2556 (0, _classCallCheck2.default)(this, _default);
2557 return _callSuper(this, _default, arguments);
2558 }
2559 (0, _inherits2.default)(_default, _Backbone$Model);
2560 return (0, _createClass2.default)(_default, [{
2561 key: "defaults",
2562 value: function defaults() {
2563 return {
2564 description: '',
2565 icon: 'settings',
2566 url: '',
2567 keywords: [],
2568 actions: [],
2569 lock: null
2570 };
2571 }
2572 }]);
2573 }(Backbone.Model);
2574
2575 /***/ }),
2576
2577 /***/ "../core/common/modules/finder/assets/js/modal/views/categories.js":
2578 /*!*************************************************************************!*\
2579 !*** ../core/common/modules/finder/assets/js/modal/views/categories.js ***!
2580 \*************************************************************************/
2581 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2582
2583 "use strict";
2584
2585
2586 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2587 Object.defineProperty(exports, "__esModule", ({
2588 value: true
2589 }));
2590 exports["default"] = void 0;
2591 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2592 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2593 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2594 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2595 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2596 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
2597 var _dynamicCategory = _interopRequireDefault(__webpack_require__(/*! ./dynamic-category */ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js"));
2598 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)); }
2599 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2600 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
2601 function _default() {
2602 (0, _classCallCheck2.default)(this, _default);
2603 return _callSuper(this, _default, arguments);
2604 }
2605 (0, _inherits2.default)(_default, _Marionette$Composite);
2606 return (0, _createClass2.default)(_default, [{
2607 key: "id",
2608 value: function id() {
2609 return 'elementor-finder__results-container';
2610 }
2611 }, {
2612 key: "ui",
2613 value: function ui() {
2614 this.selectors = {
2615 noResults: '#elementor-finder__no-results',
2616 categoryItem: '.elementor-finder__results__item'
2617 };
2618 return this.selectors;
2619 }
2620 }, {
2621 key: "events",
2622 value: function events() {
2623 return {
2624 'mouseenter @ui.categoryItem': 'onCategoryItemMouseEnter'
2625 };
2626 }
2627 }, {
2628 key: "getTemplate",
2629 value: function getTemplate() {
2630 return '#tmpl-elementor-finder-results-container';
2631 }
2632 }, {
2633 key: "getChildView",
2634 value: function getChildView(childModel) {
2635 return childModel.get('dynamic') ? _dynamicCategory.default : _category.default;
2636 }
2637 }, {
2638 key: "initialize",
2639 value: function initialize() {
2640 this.$activeItem = null;
2641 this.childViewContainer = '#elementor-finder__results';
2642 this.collection = new Backbone.Collection(Object.values(elementorCommon.finder.getSettings('data')));
2643 }
2644 }, {
2645 key: "activateItem",
2646 value: function activateItem($item) {
2647 if (this.$activeItem) {
2648 this.$activeItem.removeClass('elementor-active');
2649 }
2650 $item.addClass('elementor-active');
2651 this.$activeItem = $item;
2652 }
2653 }, {
2654 key: "activateNextItem",
2655 value: function activateNextItem(reverse) {
2656 var $allItems = jQuery(this.selectors.categoryItem);
2657 var nextItemIndex = 0;
2658 if (this.$activeItem) {
2659 nextItemIndex = $allItems.index(this.$activeItem) + (reverse ? -1 : 1);
2660 if (nextItemIndex >= $allItems.length) {
2661 nextItemIndex = 0;
2662 } else if (nextItemIndex < 0) {
2663 nextItemIndex = $allItems.length - 1;
2664 }
2665 }
2666 var $nextItem = $allItems.eq(nextItemIndex);
2667 this.activateItem($nextItem);
2668 $nextItem[0].scrollIntoView({
2669 block: 'nearest'
2670 });
2671 }
2672 }, {
2673 key: "goToActiveItem",
2674 value: function goToActiveItem(event) {
2675 var $a = this.$activeItem.children('a'),
2676 isControlClicked = $e.shortcuts.isControlEvent(event);
2677 if (isControlClicked) {
2678 $a.attr('target', '_blank');
2679 }
2680 $a[0].click();
2681 if (isControlClicked) {
2682 $a.removeAttr('target');
2683 }
2684 }
2685 }, {
2686 key: "onCategoryItemMouseEnter",
2687 value: function onCategoryItemMouseEnter(event) {
2688 this.activateItem(jQuery(event.currentTarget));
2689 }
2690 }, {
2691 key: "onChildviewToggleVisibility",
2692 value: function onChildviewToggleVisibility() {
2693 var allCategoriesAreEmpty = this.children.every(function (child) {
2694 return !child.isVisible;
2695 });
2696 this.ui.noResults.toggle(allCategoriesAreEmpty);
2697 }
2698 }]);
2699 }(Marionette.CompositeView);
2700
2701 /***/ }),
2702
2703 /***/ "../core/common/modules/finder/assets/js/modal/views/category.js":
2704 /*!***********************************************************************!*\
2705 !*** ../core/common/modules/finder/assets/js/modal/views/category.js ***!
2706 \***********************************************************************/
2707 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2708
2709 "use strict";
2710
2711
2712 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2713 Object.defineProperty(exports, "__esModule", ({
2714 value: true
2715 }));
2716 exports["default"] = void 0;
2717 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2718 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2719 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2720 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2721 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2722 var _item = _interopRequireDefault(__webpack_require__(/*! ./item */ "../core/common/modules/finder/assets/js/modal/views/item.js"));
2723 var _item2 = _interopRequireDefault(__webpack_require__(/*! ../model/item */ "../core/common/modules/finder/assets/js/modal/model/item.js"));
2724 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)); }
2725 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2726 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
2727 function _default() {
2728 (0, _classCallCheck2.default)(this, _default);
2729 return _callSuper(this, _default, arguments);
2730 }
2731 (0, _inherits2.default)(_default, _Marionette$Composite);
2732 return (0, _createClass2.default)(_default, [{
2733 key: "className",
2734 value: function className() {
2735 return 'elementor-finder__results__category';
2736 }
2737 }, {
2738 key: "getTemplate",
2739 value: function getTemplate() {
2740 return '#tmpl-elementor-finder__results__category';
2741 }
2742 }, {
2743 key: "getChildView",
2744 value: function getChildView() {
2745 return _item.default;
2746 }
2747 }, {
2748 key: "initialize",
2749 value: function initialize() {
2750 this.childViewContainer = '.elementor-finder__results__category__items';
2751 this.isVisible = true;
2752 var items = this.model.get('items');
2753 if (items) {
2754 items = Object.values(items);
2755 }
2756 this.collection = new Backbone.Collection(items, {
2757 model: _item2.default
2758 });
2759 }
2760 }, {
2761 key: "filter",
2762 value: function filter(childModel) {
2763 var textFilter = this.getTextFilter();
2764 if (childModel.get('title').toLowerCase().indexOf(textFilter) >= 0) {
2765 return true;
2766 }
2767 return childModel.get('keywords').some(function (keyword) {
2768 return keyword.indexOf(textFilter) >= 0;
2769 });
2770 }
2771 }, {
2772 key: "getTextFilter",
2773 value: function getTextFilter() {
2774 return elementorCommon.finder.channel.request('filter:text').trim().toLowerCase();
2775 }
2776 }, {
2777 key: "toggleElement",
2778 value: function toggleElement() {
2779 var isCurrentlyVisible = !!this.children.length;
2780 if (isCurrentlyVisible !== this.isVisible) {
2781 this.isVisible = isCurrentlyVisible;
2782 this.$el.toggle(isCurrentlyVisible);
2783 this.triggerMethod('toggle:visibility');
2784 }
2785 }
2786 }, {
2787 key: "onRender",
2788 value: function onRender() {
2789 this.listenTo(elementorCommon.finder.channel, 'filter:change', this.onFilterChange.bind(this));
2790 }
2791 }, {
2792 key: "onFilterChange",
2793 value: function onFilterChange() {
2794 this._renderChildren();
2795 }
2796 }, {
2797 key: "onRenderCollection",
2798 value: function onRenderCollection() {
2799 this.toggleElement();
2800 }
2801 }]);
2802 }(Marionette.CompositeView);
2803
2804 /***/ }),
2805
2806 /***/ "../core/common/modules/finder/assets/js/modal/views/content.js":
2807 /*!**********************************************************************!*\
2808 !*** ../core/common/modules/finder/assets/js/modal/views/content.js ***!
2809 \**********************************************************************/
2810 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2811
2812 "use strict";
2813
2814
2815 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2816 Object.defineProperty(exports, "__esModule", ({
2817 value: true
2818 }));
2819 exports["default"] = void 0;
2820 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2821 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2822 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2823 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2824 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2825 var _categories = _interopRequireDefault(__webpack_require__(/*! ./categories */ "../core/common/modules/finder/assets/js/modal/views/categories.js"));
2826 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)); }
2827 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2828 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$LayoutVie) {
2829 function _default() {
2830 (0, _classCallCheck2.default)(this, _default);
2831 return _callSuper(this, _default, arguments);
2832 }
2833 (0, _inherits2.default)(_default, _Marionette$LayoutVie);
2834 return (0, _createClass2.default)(_default, [{
2835 key: "id",
2836 value: function id() {
2837 return 'elementor-finder';
2838 }
2839 }, {
2840 key: "getTemplate",
2841 value: function getTemplate() {
2842 return '#tmpl-elementor-finder';
2843 }
2844 }, {
2845 key: "ui",
2846 value: function ui() {
2847 return {
2848 searchInput: '#elementor-finder__search__input'
2849 };
2850 }
2851 }, {
2852 key: "events",
2853 value: function events() {
2854 return {
2855 'input @ui.searchInput': 'onSearchInputInput'
2856 };
2857 }
2858 }, {
2859 key: "regions",
2860 value: function regions() {
2861 return {
2862 content: '#elementor-finder__content'
2863 };
2864 }
2865 }, {
2866 key: "showCategoriesView",
2867 value: function showCategoriesView() {
2868 this.content.show(new _categories.default());
2869 }
2870 }, {
2871 key: "onSearchInputInput",
2872 value: function onSearchInputInput() {
2873 var value = this.ui.searchInput.val();
2874 if (value) {
2875 elementorCommon.finder.channel.reply('filter:text', value).trigger('filter:change');
2876 if (!(this.content.currentView instanceof _categories.default)) {
2877 this.showCategoriesView();
2878 }
2879 }
2880 this.content.currentView.$el.toggle(!!value);
2881 }
2882 }]);
2883 }(Marionette.LayoutView);
2884
2885 /***/ }),
2886
2887 /***/ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js":
2888 /*!*******************************************************************************!*\
2889 !*** ../core/common/modules/finder/assets/js/modal/views/dynamic-category.js ***!
2890 \*******************************************************************************/
2891 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2892
2893 "use strict";
2894
2895
2896 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2897 Object.defineProperty(exports, "__esModule", ({
2898 value: true
2899 }));
2900 exports["default"] = void 0;
2901 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2902 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2903 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2904 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2905 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2906 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2907 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
2908 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)); }
2909 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2910 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; }
2911 var _default = exports["default"] = /*#__PURE__*/function (_Category) {
2912 function _default() {
2913 (0, _classCallCheck2.default)(this, _default);
2914 return _callSuper(this, _default, arguments);
2915 }
2916 (0, _inherits2.default)(_default, _Category);
2917 return (0, _createClass2.default)(_default, [{
2918 key: "className",
2919 value: function className() {
2920 return _superPropGet(_default, "className", this, 3)([]) + ' elementor-finder__results__category--dynamic';
2921 }
2922 }, {
2923 key: "ui",
2924 value: function ui() {
2925 return {
2926 title: '.elementor-finder__results__category__title'
2927 };
2928 }
2929 }, {
2930 key: "fetchData",
2931 value: function fetchData() {
2932 var _this = this;
2933 this.ui.loadingIcon.show();
2934 elementorCommon.ajax.addRequest('finder_get_category_items', {
2935 data: {
2936 category: this.model.get('name'),
2937 filter: this.getTextFilter()
2938 },
2939 success: function success(data) {
2940 if (_this.isDestroyed) {
2941 return;
2942 }
2943 _this.collection.set(data);
2944 _this.toggleElement();
2945 _this.ui.loadingIcon.hide();
2946 }
2947 });
2948 }
2949 }, {
2950 key: "filter",
2951 value: function filter() {
2952 return true;
2953 }
2954 }, {
2955 key: "onFilterChange",
2956 value: function onFilterChange() {
2957 this.fetchData();
2958 }
2959 }, {
2960 key: "onRender",
2961 value: function onRender() {
2962 _superPropGet(_default, "onRender", this, 3)([]);
2963 this.ui.loadingIcon = jQuery('<i>', {
2964 class: 'eicon-loading eicon-animation-spin'
2965 });
2966 this.ui.title.after(this.ui.loadingIcon);
2967 this.fetchData();
2968 }
2969 }]);
2970 }(_category.default);
2971
2972 /***/ }),
2973
2974 /***/ "../core/common/modules/finder/assets/js/modal/views/item.js":
2975 /*!*******************************************************************!*\
2976 !*** ../core/common/modules/finder/assets/js/modal/views/item.js ***!
2977 \*******************************************************************/
2978 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2979
2980 "use strict";
2981 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
2982
2983
2984 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2985 Object.defineProperty(exports, "__esModule", ({
2986 value: true
2987 }));
2988 exports["default"] = void 0;
2989 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2990 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2991 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2992 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2993 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2994 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)); }
2995 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2996 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$ItemView) {
2997 function _default() {
2998 (0, _classCallCheck2.default)(this, _default);
2999 return _callSuper(this, _default, arguments);
3000 }
3001 (0, _inherits2.default)(_default, _Marionette$ItemView);
3002 return (0, _createClass2.default)(_default, [{
3003 key: "className",
3004 value: function className() {
3005 return 'elementor-finder__results__item';
3006 }
3007 }, {
3008 key: "getTemplate",
3009 value: function getTemplate() {
3010 return '#tmpl-elementor-finder__results__item';
3011 }
3012 }, {
3013 key: "events",
3014 value: function events() {
3015 this.$el[0].addEventListener('click', this.onClick.bind(this), true);
3016 }
3017 }, {
3018 key: "onClick",
3019 value: function onClick(e) {
3020 var _this = this;
3021 var lockOptions = this.model.get('lock');
3022 if (!(lockOptions !== null && lockOptions !== void 0 && lockOptions.is_locked)) {
3023 return;
3024 }
3025 e.preventDefault();
3026 e.stopImmediatePropagation();
3027 elementorCommon.dialogsManager.createWidget('confirm', {
3028 id: 'elementor-finder__lock-dialog',
3029 headerMessage: lockOptions.content.heading,
3030 message: lockOptions.content.description,
3031 position: {
3032 my: 'center center',
3033 at: 'center center'
3034 },
3035 strings: {
3036 confirm: lockOptions.button.text,
3037 cancel: __('Cancel', 'elementor')
3038 },
3039 onConfirm: function onConfirm() {
3040 var link = _this.replaceLockLinkPlaceholders(lockOptions.button.url);
3041 window.open(link, '_blank');
3042 }
3043 }).show();
3044 }
3045 }, {
3046 key: "replaceLockLinkPlaceholders",
3047 value: function replaceLockLinkPlaceholders(link) {
3048 return link.replace(/%%utm_source%%/g, 'finder').replace(/%%utm_medium%%/g, 'wp-dash');
3049 }
3050 }]);
3051 }(Marionette.ItemView);
3052
3053 /***/ }),
3054
3055 /***/ "../core/common/modules/finder/assets/js/modal/views/layout.js":
3056 /*!*********************************************************************!*\
3057 !*** ../core/common/modules/finder/assets/js/modal/views/layout.js ***!
3058 \*********************************************************************/
3059 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3060
3061 "use strict";
3062 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3063
3064
3065 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3066 Object.defineProperty(exports, "__esModule", ({
3067 value: true
3068 }));
3069 exports["default"] = void 0;
3070 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3071 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3072 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3073 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3074 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3075 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3076 var _content = _interopRequireDefault(__webpack_require__(/*! ./content */ "../core/common/modules/finder/assets/js/modal/views/content.js"));
3077 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)); }
3078 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3079 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; }
3080 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$com) {
3081 function _default() {
3082 (0, _classCallCheck2.default)(this, _default);
3083 return _callSuper(this, _default, arguments);
3084 }
3085 (0, _inherits2.default)(_default, _elementorModules$com);
3086 return (0, _createClass2.default)(_default, [{
3087 key: "getModalOptions",
3088 value: function getModalOptions() {
3089 return {
3090 id: 'elementor-finder__modal',
3091 draggable: true,
3092 effects: {
3093 show: 'show',
3094 hide: 'hide'
3095 },
3096 position: {
3097 enable: false
3098 }
3099 };
3100 }
3101 }, {
3102 key: "getLogoOptions",
3103 value: function getLogoOptions() {
3104 return {
3105 title: __('Finder', 'elementor')
3106 };
3107 }
3108 }, {
3109 key: "initialize",
3110 value: function initialize() {
3111 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3112 args[_key] = arguments[_key];
3113 }
3114 _superPropGet(_default, "initialize", this, 3)(args);
3115 this.showLogo();
3116 this.showContentView();
3117 }
3118 }, {
3119 key: "showContentView",
3120 value: function showContentView() {
3121 this.modalContent.show(new _content.default());
3122 }
3123 }, {
3124 key: "showModal",
3125 value: function showModal() {
3126 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3127 args[_key2] = arguments[_key2];
3128 }
3129 _superPropGet(_default, "showModal", this, 3)(args);
3130 this.modalContent.currentView.ui.searchInput.focus();
3131 }
3132 }]);
3133 }(elementorModules.common.views.modal.Layout);
3134
3135 /***/ }),
3136
3137 /***/ "../modules/web-cli/assets/js/core/data/errors/base-error.js":
3138 /*!*******************************************************************!*\
3139 !*** ../modules/web-cli/assets/js/core/data/errors/base-error.js ***!
3140 \*******************************************************************/
3141 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3142
3143 "use strict";
3144
3145
3146 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3147 Object.defineProperty(exports, "__esModule", ({
3148 value: true
3149 }));
3150 exports["default"] = void 0;
3151 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3152 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3153 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3154 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3155 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3156 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
3157 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3158 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3159 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../../../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
3160 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; }
3161 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; }
3162 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)); }
3163 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3164 var BaseError = exports["default"] = /*#__PURE__*/function (_Error) {
3165 /**
3166 * Error constructor.
3167 *
3168 * @param {string} message
3169 * @param {string} code
3170 * @param {*} data
3171 */
3172 function BaseError() {
3173 var _this;
3174 var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
3175 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3176 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3177 (0, _classCallCheck2.default)(this, BaseError);
3178 _this = _callSuper(this, BaseError, [message]);
3179 /**
3180 * The server error code.
3181 *
3182 * @type {string}
3183 */
3184 (0, _defineProperty2.default)(_this, "code", '');
3185 /**
3186 * Additional data about the current error.
3187 *
3188 * @type {*[]}
3189 */
3190 (0, _defineProperty2.default)(_this, "data", []);
3191 _this.code = code;
3192 _this.data = data;
3193 return _this;
3194 }
3195
3196 /**
3197 * Notify a message when the error occurs.
3198 */
3199 (0, _inherits2.default)(BaseError, _Error);
3200 return (0, _createClass2.default)(BaseError, [{
3201 key: "notify",
3202 value: function notify() {
3203 _console.default.error(_objectSpread({
3204 message: this.message
3205 }, this));
3206 }
3207 }], [{
3208 key: "create",
3209 value:
3210 /**
3211 * Static helper function to create the error.
3212 *
3213 * @param {string} message
3214 * @param {string} code
3215 * @param {*} data
3216 * @return {BaseError} error
3217 */
3218 function create(message) {
3219 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3220 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3221 return new this(message, code, data);
3222 }
3223
3224 /**
3225 * Returns the status code of the error.
3226 */
3227 }, {
3228 key: "getHTTPErrorCode",
3229 value: function getHTTPErrorCode() {
3230 (0, _forceMethodImplementation.default)();
3231 }
3232 }]);
3233 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
3234
3235 /***/ }),
3236
3237 /***/ "../modules/web-cli/assets/js/core/data/errors/default-error.js":
3238 /*!**********************************************************************!*\
3239 !*** ../modules/web-cli/assets/js/core/data/errors/default-error.js ***!
3240 \**********************************************************************/
3241 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3242
3243 "use strict";
3244
3245
3246 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3247 Object.defineProperty(exports, "__esModule", ({
3248 value: true
3249 }));
3250 exports["default"] = exports.DefaultError = void 0;
3251 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3252 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3253 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3254 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3255 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3256 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3257 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)); }
3258 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3259 var DefaultError = exports.DefaultError = /*#__PURE__*/function (_BaseError) {
3260 function DefaultError() {
3261 (0, _classCallCheck2.default)(this, DefaultError);
3262 return _callSuper(this, DefaultError, arguments);
3263 }
3264 (0, _inherits2.default)(DefaultError, _BaseError);
3265 return (0, _createClass2.default)(DefaultError, null, [{
3266 key: "getHTTPErrorCode",
3267 value: function getHTTPErrorCode() {
3268 return 501;
3269 }
3270 }]);
3271 }(_baseError.default);
3272 var _default = exports["default"] = DefaultError;
3273
3274 /***/ }),
3275
3276 /***/ "../modules/web-cli/assets/js/core/data/errors/error-404.js":
3277 /*!******************************************************************!*\
3278 !*** ../modules/web-cli/assets/js/core/data/errors/error-404.js ***!
3279 \******************************************************************/
3280 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3281
3282 "use strict";
3283
3284
3285 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3286 Object.defineProperty(exports, "__esModule", ({
3287 value: true
3288 }));
3289 exports["default"] = exports.Error404 = void 0;
3290 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3291 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3292 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3293 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3294 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3295 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3296 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3297 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)); }
3298 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3299 var Error404 = exports.Error404 = /*#__PURE__*/function (_BaseError) {
3300 function Error404() {
3301 (0, _classCallCheck2.default)(this, Error404);
3302 return _callSuper(this, Error404, arguments);
3303 }
3304 (0, _inherits2.default)(Error404, _BaseError);
3305 return (0, _createClass2.default)(Error404, [{
3306 key: "notify",
3307 value: function notify() {
3308 _console.default.warn(this.message);
3309 }
3310 }], [{
3311 key: "getHTTPErrorCode",
3312 value: function getHTTPErrorCode() {
3313 return 404;
3314 }
3315 }]);
3316 }(_baseError.default);
3317 var _default = exports["default"] = Error404;
3318
3319 /***/ }),
3320
3321 /***/ "../modules/web-cli/assets/js/core/data/errors/index.js":
3322 /*!**************************************************************!*\
3323 !*** ../modules/web-cli/assets/js/core/data/errors/index.js ***!
3324 \**************************************************************/
3325 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3326
3327 "use strict";
3328
3329
3330 Object.defineProperty(exports, "__esModule", ({
3331 value: true
3332 }));
3333 Object.defineProperty(exports, "DefaultError", ({
3334 enumerable: true,
3335 get: function get() {
3336 return _defaultError.DefaultError;
3337 }
3338 }));
3339 Object.defineProperty(exports, "Error404", ({
3340 enumerable: true,
3341 get: function get() {
3342 return _error.Error404;
3343 }
3344 }));
3345 var _defaultError = __webpack_require__(/*! ./default-error */ "../modules/web-cli/assets/js/core/data/errors/default-error.js");
3346 var _error = __webpack_require__(/*! ./error-404 */ "../modules/web-cli/assets/js/core/data/errors/error-404.js");
3347
3348 /***/ }),
3349
3350 /***/ "../modules/web-cli/assets/js/modules/command-base.js":
3351 /*!************************************************************!*\
3352 !*** ../modules/web-cli/assets/js/modules/command-base.js ***!
3353 \************************************************************/
3354 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3355
3356 "use strict";
3357
3358
3359 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3360 Object.defineProperty(exports, "__esModule", ({
3361 value: true
3362 }));
3363 exports["default"] = void 0;
3364 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3365 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3366 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3367 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3368 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3369 var _commandInfra = _interopRequireDefault(__webpack_require__(/*! ./command-infra */ "../modules/web-cli/assets/js/modules/command-infra.js"));
3370 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3371 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)); }
3372 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3373 /**
3374 * @name $e.modules.CommandBase
3375 */
3376 var CommandBase = exports["default"] = /*#__PURE__*/function (_CommandInfra) {
3377 function CommandBase() {
3378 (0, _classCallCheck2.default)(this, CommandBase);
3379 return _callSuper(this, CommandBase, arguments);
3380 }
3381 (0, _inherits2.default)(CommandBase, _CommandInfra);
3382 return (0, _createClass2.default)(CommandBase, [{
3383 key: "onBeforeRun",
3384 value: function onBeforeRun() {
3385 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3386 $e.hooks.runUIBefore(this.command, args);
3387 }
3388 }, {
3389 key: "onAfterRun",
3390 value: function onAfterRun() {
3391 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3392 var result = arguments.length > 1 ? arguments[1] : undefined;
3393 $e.hooks.runUIAfter(this.command, args, result);
3394 }
3395 }, {
3396 key: "onBeforeApply",
3397 value: function onBeforeApply() {
3398 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3399 $e.hooks.runDataDependency(this.command, args);
3400 }
3401 }, {
3402 key: "onAfterApply",
3403 value: function onAfterApply() {
3404 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3405 var result = arguments.length > 1 ? arguments[1] : undefined;
3406 return $e.hooks.runDataAfter(this.command, args, result);
3407 }
3408 }, {
3409 key: "onCatchApply",
3410 value: function onCatchApply(e) {
3411 this.runCatchHooks(e);
3412 }
3413
3414 /**
3415 * Run all the catch hooks.
3416 *
3417 * @param {Error} e
3418 */
3419 }, {
3420 key: "runCatchHooks",
3421 value: function runCatchHooks(e) {
3422 $e.hooks.runDataCatch(this.command, this.args, e);
3423 $e.hooks.runUICatch(this.command, this.args, e);
3424 }
3425
3426 /**
3427 * TODO - Remove - Backwards compatibility.
3428 *
3429 * Function requireContainer().
3430 *
3431 * Validate `arg.container` & `arg.containers`.
3432 *
3433 * @param {{}} args
3434 * @deprecated since 3.7.0, extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase` instead.
3435 *
3436 * @throws {Error}
3437 */
3438 }, {
3439 key: "requireContainer",
3440 value: function requireContainer() {
3441 var _this = this;
3442 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
3443 _deprecation.default.deprecated('requireContainer()', '3.7.0', 'Extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase`');
3444 if (!args.container && !args.containers) {
3445 throw Error('container or containers are required.');
3446 }
3447 if (args.container && args.containers) {
3448 throw Error('container and containers cannot go together please select one of them.');
3449 }
3450 var containers = args.containers || [args.container];
3451 containers.forEach(function (container) {
3452 _this.requireArgumentInstance('container', elementorModules.editor.Container, {
3453 container: container
3454 });
3455 });
3456 }
3457 }], [{
3458 key: "getInstanceType",
3459 value: function getInstanceType() {
3460 return 'CommandBase';
3461 }
3462 }]);
3463 }(_commandInfra.default);
3464
3465 /***/ }),
3466
3467 /***/ "../modules/web-cli/assets/js/modules/command-callback-base.js":
3468 /*!*********************************************************************!*\
3469 !*** ../modules/web-cli/assets/js/modules/command-callback-base.js ***!
3470 \*********************************************************************/
3471 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3472
3473 "use strict";
3474
3475
3476 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3477 Object.defineProperty(exports, "__esModule", ({
3478 value: true
3479 }));
3480 exports["default"] = void 0;
3481 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3482 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3483 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3484 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3485 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3486 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3487 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)); }
3488 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3489 /**
3490 * To support pure callbacks in the API(commands.js), to ensure they have registered with the proper context.
3491 */
3492 var CommandCallbackBase = exports["default"] = /*#__PURE__*/function (_CommandBase) {
3493 function CommandCallbackBase() {
3494 (0, _classCallCheck2.default)(this, CommandCallbackBase);
3495 return _callSuper(this, CommandCallbackBase, arguments);
3496 }
3497 (0, _inherits2.default)(CommandCallbackBase, _CommandBase);
3498 return (0, _createClass2.default)(CommandCallbackBase, [{
3499 key: "apply",
3500 value: function apply() {
3501 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3502 return this.constructor.getCallback()(args);
3503 }
3504 }], [{
3505 key: "getInstanceType",
3506 value: function getInstanceType() {
3507 return 'CommandCallbackBase';
3508 }
3509
3510 /**
3511 * Get original callback of the command.
3512 *
3513 * Support pure callbacks ( Non command-base ).
3514 *
3515 * @return {()=>{}} Command Results.
3516 */
3517 }, {
3518 key: "getCallback",
3519 value: function getCallback() {
3520 return this.registerConfig.callback;
3521 }
3522 }]);
3523 }(_commandBase.default);
3524
3525 /***/ }),
3526
3527 /***/ "../modules/web-cli/assets/js/modules/command-data.js":
3528 /*!************************************************************!*\
3529 !*** ../modules/web-cli/assets/js/modules/command-data.js ***!
3530 \************************************************************/
3531 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3532
3533 "use strict";
3534
3535
3536 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3537 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
3538 Object.defineProperty(exports, "__esModule", ({
3539 value: true
3540 }));
3541 exports["default"] = void 0;
3542 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3543 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3544 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3545 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3546 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3547 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3548 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3549 var errors = _interopRequireWildcard(__webpack_require__(/*! ../core/data/errors/ */ "../modules/web-cli/assets/js/core/data/errors/index.js"));
3550 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); }
3551 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)); }
3552 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3553 /**
3554 * @name $e.modules.CommandData
3555 */
3556 /**
3557 * @typedef {('create'|'delete'|'get'|'update'|'options')} DataTypes
3558 */
3559 /**
3560 * @typedef {{}} RequestData
3561 */
3562 /**
3563 * @typedef {import('../core/data/errors/base-error')} BaseError
3564 */
3565 var CommandData = exports["default"] = /*#__PURE__*/function (_CommandBase) {
3566 function CommandData(args) {
3567 var _this$args$options;
3568 var _this;
3569 var commandsAPI = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $e.data;
3570 (0, _classCallCheck2.default)(this, CommandData);
3571 _this = _callSuper(this, CommandData, [args, commandsAPI]);
3572 /**
3573 * Data returned from remote.
3574 *
3575 * @type {*}
3576 */
3577 (0, _defineProperty2.default)(_this, "data", void 0);
3578 /**
3579 * Fetch type.
3580 *
3581 * @type {DataTypes}
3582 */
3583 (0, _defineProperty2.default)(_this, "type", void 0);
3584 if ((_this$args$options = _this.args.options) !== null && _this$args$options !== void 0 && _this$args$options.type) {
3585 _this.type = _this.args.options.type;
3586 }
3587 return _this;
3588 }
3589
3590 /**
3591 * Function getEndpointFormat().
3592 *
3593 * @return {null|string} endpoint format
3594 */
3595 (0, _inherits2.default)(CommandData, _CommandBase);
3596 return (0, _createClass2.default)(CommandData, [{
3597 key: "getApplyMethods",
3598 value:
3599 /**
3600 * @param {DataTypes} type
3601 *
3602 * @return {boolean|{before: (function(*=): {}), after: (function({}, *=): {})}} apply methods
3603 */
3604 function getApplyMethods() {
3605 var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.type;
3606 var before, after;
3607 switch (type) {
3608 case 'create':
3609 before = this.applyBeforeCreate;
3610 after = this.applyAfterCreate;
3611 break;
3612 case 'delete':
3613 before = this.applyBeforeDelete;
3614 after = this.applyAfterDelete;
3615 break;
3616 case 'get':
3617 before = this.applyBeforeGet;
3618 after = this.applyAfterGet;
3619 break;
3620 case 'update':
3621 before = this.applyBeforeUpdate;
3622 after = this.applyAfterUpdate;
3623 break;
3624 case 'options':
3625 before = this.applyBeforeOptions;
3626 after = this.applyAfterOptions;
3627 break;
3628 default:
3629 return false;
3630 }
3631 return {
3632 before: before.bind(this),
3633 after: after.bind(this)
3634 };
3635 }
3636
3637 /**
3638 * Function getRequestData().
3639 *
3640 * @return {RequestData} request data
3641 */
3642 }, {
3643 key: "getRequestData",
3644 value: function getRequestData() {
3645 return {
3646 type: this.type,
3647 args: this.args,
3648 timestamp: new Date().getTime(),
3649 component: this.component,
3650 command: this.command,
3651 endpoint: $e.data.commandToEndpoint(this.command, JSON.parse(JSON.stringify(this.args)), this.constructor.getEndpointFormat())
3652 };
3653 }
3654 }, {
3655 key: "apply",
3656 value: function apply() {
3657 var _this2 = this;
3658 var applyMethods = this.getApplyMethods();
3659
3660 // Run 'before' method.
3661 this.args = applyMethods.before(this.args);
3662 var requestData = this.getRequestData();
3663 return $e.data.fetch(requestData).then(function (data) {
3664 _this2.data = data;
3665
3666 // Run 'after' method.
3667 _this2.data = applyMethods.after(data, _this2.args);
3668 _this2.data = {
3669 data: _this2.data
3670 };
3671
3672 // Append requestData.
3673 _this2.data = Object.assign({
3674 __requestData__: requestData
3675 }, _this2.data);
3676 return _this2.data;
3677 });
3678 }
3679
3680 /**
3681 * @param {*} [args={}]
3682 * @return {{}} filtered args
3683 */
3684 }, {
3685 key: "applyBeforeCreate",
3686 value: function applyBeforeCreate() {
3687 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3688 return args;
3689 }
3690
3691 /**
3692 * @param {{}} data
3693 * @param {*} [args={}]
3694 * @return {{}} filtered result
3695 */
3696 }, {
3697 key: "applyAfterCreate",
3698 value: function applyAfterCreate(data) {
3699 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3700 // eslint-disable-line no-unused-vars
3701 return data;
3702 }
3703
3704 /**
3705 * @param {*} [args={}]
3706 * @return {{}} filtered args
3707 */
3708 }, {
3709 key: "applyBeforeDelete",
3710 value: function applyBeforeDelete() {
3711 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3712 return args;
3713 }
3714
3715 /**
3716 * @param {{}} data
3717 * @param {*} [args={}]
3718 * @return {{}} filtered result
3719 */
3720 }, {
3721 key: "applyAfterDelete",
3722 value: function applyAfterDelete(data) {
3723 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3724 // eslint-disable-line no-unused-vars
3725 return data;
3726 }
3727
3728 /**
3729 * @param {*} [args={}]
3730 * @return {{}} filtered args
3731 */
3732 }, {
3733 key: "applyBeforeGet",
3734 value: function applyBeforeGet() {
3735 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3736 return args;
3737 }
3738
3739 /**
3740 * @param {{}} data
3741 * @param {*} [args={}]
3742 * @return {{}} filtered result
3743 */
3744 }, {
3745 key: "applyAfterGet",
3746 value: function applyAfterGet(data) {
3747 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3748 // eslint-disable-line no-unused-vars
3749 return data;
3750 }
3751
3752 /**
3753 * @param {*} [args={}]
3754 * @return {{}} filtered args
3755 */
3756 }, {
3757 key: "applyBeforeUpdate",
3758 value: function applyBeforeUpdate() {
3759 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3760 return args;
3761 }
3762
3763 /**
3764 * @param {{}} data
3765 * @param {*} [args={}]
3766 * @return {{}} filtered result
3767 */
3768 }, {
3769 key: "applyAfterUpdate",
3770 value: function applyAfterUpdate(data) {
3771 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3772 // eslint-disable-line no-unused-vars
3773 return data;
3774 }
3775
3776 /**
3777 * @param {*} [args={}]
3778 * @return {{}} filtered args
3779 */
3780 }, {
3781 key: "applyBeforeOptions",
3782 value: function applyBeforeOptions() {
3783 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3784 return args;
3785 }
3786
3787 /**
3788 * @param {{}} data
3789 * @param {*} [args={}]
3790 * @return {{}} filtered result
3791 */
3792 }, {
3793 key: "applyAfterOptions",
3794 value: function applyAfterOptions(data) {
3795 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3796 // eslint-disable-line no-unused-vars
3797 return data;
3798 }
3799
3800 /**
3801 * @param {BaseError} e
3802 */
3803 }, {
3804 key: "applyAfterCatch",
3805 value: function applyAfterCatch(e) {
3806 e.notify();
3807 }
3808 }, {
3809 key: "onCatchApply",
3810 value: function onCatchApply(e) {
3811 var _e;
3812 // TODO: If the errors that returns from the server is consistent remove the '?' from 'e'
3813 var httpErrorCode = ((_e = e) === null || _e === void 0 || (_e = _e.data) === null || _e === void 0 ? void 0 : _e.status) || 501;
3814 var dataError = Object.values(errors).find(function (error) {
3815 return error.getHTTPErrorCode() === httpErrorCode;
3816 });
3817 if (!dataError) {
3818 dataError = errors.DefaultError;
3819 }
3820 e = dataError.create(e.message, e.code, e.data || []);
3821 this.runCatchHooks(e);
3822 this.applyAfterCatch(e);
3823 }
3824 }], [{
3825 key: "getInstanceType",
3826 value: function getInstanceType() {
3827 return 'CommandData';
3828 }
3829 }, {
3830 key: "getEndpointFormat",
3831 value: function getEndpointFormat() {
3832 return null;
3833 }
3834 }]);
3835 }(_commandBase.default);
3836
3837 /***/ }),
3838
3839 /***/ "../modules/web-cli/assets/js/modules/command-infra.js":
3840 /*!*************************************************************!*\
3841 !*** ../modules/web-cli/assets/js/modules/command-infra.js ***!
3842 \*************************************************************/
3843 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3844
3845 "use strict";
3846
3847
3848 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3849 Object.defineProperty(exports, "__esModule", ({
3850 value: true
3851 }));
3852 exports["default"] = void 0;
3853 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3854 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3855 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3856 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3857 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3858 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3859 var _argsObject = _interopRequireDefault(__webpack_require__(/*! elementor-assets-js/modules/imports/args-object */ "../assets/dev/js/modules/imports/args-object.js"));
3860 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3861 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)); }
3862 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3863 /**
3864 * @typedef {import('../modules/component-base')} ComponentBase
3865 */
3866 var CommandInfra = exports["default"] = /*#__PURE__*/function (_ArgsObject) {
3867 /**
3868 * Function constructor().
3869 *
3870 * Create Commands Base.
3871 *
3872 * @param {{}} args
3873 */
3874 function CommandInfra() {
3875 var _this;
3876 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3877 (0, _classCallCheck2.default)(this, CommandInfra);
3878 _this = _callSuper(this, CommandInfra, [args]);
3879 if (!_this.constructor.registerConfig) {
3880 throw RangeError('Doing it wrong: Each command type should have `registerConfig`.');
3881 }
3882
3883 // Acknowledge self about which command it run.
3884 _this.command = _this.constructor.getCommand();
3885
3886 // Assign instance of current component.
3887 _this.component = _this.constructor.getComponent();
3888
3889 // Who ever need do something before without `super` the constructor can use `initialize` method.
3890 _this.initialize(args);
3891
3892 // Refresh args, maybe the changed via `initialize`.
3893 args = _this.args;
3894
3895 // Validate args before run.
3896 _this.validateArgs(args);
3897 return _this;
3898 }
3899
3900 /**
3901 * Function initialize().
3902 *
3903 * Initialize command, called after construction.
3904 *
3905 * @param {{}} args
3906 */
3907 (0, _inherits2.default)(CommandInfra, _ArgsObject);
3908 return (0, _createClass2.default)(CommandInfra, [{
3909 key: "currentCommand",
3910 get:
3911 /**
3912 * @deprecated since 3.7.0, use `this.command` instead.
3913 */
3914 function get() {
3915 _deprecation.default.deprecated('this.currentCommand', '3.7.0', 'this.command');
3916 return this.command;
3917 }
3918 }, {
3919 key: "initialize",
3920 value: function initialize() {
3921 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3922 } // eslint-disable-line no-unused-vars
3923
3924 /**
3925 * Function validateArgs().
3926 *
3927 * Validate command arguments.
3928 *
3929 * @param {{}} args
3930 */
3931 }, {
3932 key: "validateArgs",
3933 value: function validateArgs() {
3934 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3935 } // eslint-disable-line no-unused-vars
3936
3937 // eslint-disable-next-line jsdoc/require-returns-check
3938 /**
3939 * Function apply().
3940 *
3941 * Do the actual command.
3942 *
3943 * @param {{}} args
3944 *
3945 * @return {*} Command results.
3946 */
3947 }, {
3948 key: "apply",
3949 value: function apply() {
3950 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3951 // eslint-disable-line no-unused-vars
3952 elementorModules.ForceMethodImplementation();
3953 }
3954
3955 /**
3956 * Function run().
3957 *
3958 * Run command with history & hooks.
3959 *
3960 * @return {*} Command results.
3961 */
3962 }, {
3963 key: "run",
3964 value: function run() {
3965 return this.apply(this.args);
3966 }
3967
3968 /**
3969 * Function onBeforeRun.
3970 *
3971 * Called before run().
3972 *
3973 * @param {{}} args
3974 */
3975 }, {
3976 key: "onBeforeRun",
3977 value: function onBeforeRun() {
3978 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3979 } // eslint-disable-line no-unused-vars
3980
3981 /**
3982 * Function onAfterRun.
3983 *
3984 * Called after run().
3985 *
3986 * @param {{}} args
3987 * @param {*} result
3988 */
3989 }, {
3990 key: "onAfterRun",
3991 value: function onAfterRun() {
3992 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3993 var result = arguments.length > 1 ? arguments[1] : undefined;
3994 } // eslint-disable-line no-unused-vars
3995
3996 /**
3997 * Function onBeforeApply.
3998 *
3999 * Called before apply().
4000 *
4001 * @param {{}} args
4002 */
4003 }, {
4004 key: "onBeforeApply",
4005 value: function onBeforeApply() {
4006 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4007 } // eslint-disable-line no-unused-vars
4008
4009 /**
4010 * Function onAfterApply.
4011 *
4012 * Called after apply().
4013 *
4014 * @param {{}} args
4015 * @param {*} result
4016 */
4017 }, {
4018 key: "onAfterApply",
4019 value: function onAfterApply() {
4020 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4021 var result = arguments.length > 1 ? arguments[1] : undefined;
4022 } // eslint-disable-line no-unused-vars
4023
4024 /**
4025 * Function onCatchApply.
4026 *
4027 * Called after apply() failed.
4028 *
4029 * @param {Error} e
4030 */
4031 }, {
4032 key: "onCatchApply",
4033 value: function onCatchApply(e) {} // eslint-disable-line no-unused-vars
4034 }], [{
4035 key: "getInstanceType",
4036 value: function getInstanceType() {
4037 return 'CommandInfra';
4038 }
4039
4040 /**
4041 * Get info of command.
4042 *
4043 * @return {Object} Extra information about the command.
4044 */
4045 }, {
4046 key: "getInfo",
4047 value: function getInfo() {
4048 return {};
4049 }
4050
4051 /**
4052 * @return {string} Self command name.
4053 */
4054 }, {
4055 key: "getCommand",
4056 value: function getCommand() {
4057 return this.registerConfig.command;
4058 }
4059
4060 /**
4061 * @return {ComponentBase} Self component
4062 */
4063 }, {
4064 key: "getComponent",
4065 value: function getComponent() {
4066 return this.registerConfig.component;
4067 }
4068 }, {
4069 key: "setRegisterConfig",
4070 value: function setRegisterConfig(config) {
4071 this.registerConfig = Object.freeze(config);
4072 }
4073 }]);
4074 }(_argsObject.default);
4075 /**
4076 * @type {Object}
4077 */
4078 (0, _defineProperty2.default)(CommandInfra, "registerConfig", null);
4079
4080 /***/ }),
4081
4082 /***/ "../modules/web-cli/assets/js/modules/commands/close.js":
4083 /*!**************************************************************!*\
4084 !*** ../modules/web-cli/assets/js/modules/commands/close.js ***!
4085 \**************************************************************/
4086 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4087
4088 "use strict";
4089
4090
4091 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4092 Object.defineProperty(exports, "__esModule", ({
4093 value: true
4094 }));
4095 exports["default"] = exports.Close = void 0;
4096 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4097 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4098 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4099 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4100 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4101 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4102 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)); }
4103 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4104 var Close = exports.Close = /*#__PURE__*/function (_CommandBase) {
4105 function Close() {
4106 (0, _classCallCheck2.default)(this, Close);
4107 return _callSuper(this, Close, arguments);
4108 }
4109 (0, _inherits2.default)(Close, _CommandBase);
4110 return (0, _createClass2.default)(Close, [{
4111 key: "apply",
4112 value: function apply() {
4113 this.component.close();
4114 }
4115 }]);
4116 }(_commandBase.default);
4117 var _default = exports["default"] = Close;
4118
4119 /***/ }),
4120
4121 /***/ "../modules/web-cli/assets/js/modules/commands/index.js":
4122 /*!**************************************************************!*\
4123 !*** ../modules/web-cli/assets/js/modules/commands/index.js ***!
4124 \**************************************************************/
4125 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4126
4127 "use strict";
4128
4129
4130 Object.defineProperty(exports, "__esModule", ({
4131 value: true
4132 }));
4133 Object.defineProperty(exports, "Close", ({
4134 enumerable: true,
4135 get: function get() {
4136 return _close.Close;
4137 }
4138 }));
4139 Object.defineProperty(exports, "Open", ({
4140 enumerable: true,
4141 get: function get() {
4142 return _open.Open;
4143 }
4144 }));
4145 Object.defineProperty(exports, "Toggle", ({
4146 enumerable: true,
4147 get: function get() {
4148 return _toggle.Toggle;
4149 }
4150 }));
4151 var _close = __webpack_require__(/*! ./close */ "../modules/web-cli/assets/js/modules/commands/close.js");
4152 var _open = __webpack_require__(/*! ./open */ "../modules/web-cli/assets/js/modules/commands/open.js");
4153 var _toggle = __webpack_require__(/*! ./toggle */ "../modules/web-cli/assets/js/modules/commands/toggle.js");
4154
4155 /***/ }),
4156
4157 /***/ "../modules/web-cli/assets/js/modules/commands/open.js":
4158 /*!*************************************************************!*\
4159 !*** ../modules/web-cli/assets/js/modules/commands/open.js ***!
4160 \*************************************************************/
4161 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4162
4163 "use strict";
4164
4165
4166 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4167 Object.defineProperty(exports, "__esModule", ({
4168 value: true
4169 }));
4170 exports["default"] = exports.Open = void 0;
4171 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4172 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4173 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4174 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4175 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4176 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4177 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)); }
4178 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4179 var Open = exports.Open = /*#__PURE__*/function (_CommandBase) {
4180 function Open() {
4181 (0, _classCallCheck2.default)(this, Open);
4182 return _callSuper(this, Open, arguments);
4183 }
4184 (0, _inherits2.default)(Open, _CommandBase);
4185 return (0, _createClass2.default)(Open, [{
4186 key: "apply",
4187 value: function apply() {
4188 $e.route(this.component.getNamespace());
4189 }
4190 }]);
4191 }(_commandBase.default);
4192 var _default = exports["default"] = Open;
4193
4194 /***/ }),
4195
4196 /***/ "../modules/web-cli/assets/js/modules/commands/toggle.js":
4197 /*!***************************************************************!*\
4198 !*** ../modules/web-cli/assets/js/modules/commands/toggle.js ***!
4199 \***************************************************************/
4200 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4201
4202 "use strict";
4203
4204
4205 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4206 Object.defineProperty(exports, "__esModule", ({
4207 value: true
4208 }));
4209 exports["default"] = exports.Toggle = void 0;
4210 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4211 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4212 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4213 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4214 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4215 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4216 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)); }
4217 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4218 var Toggle = exports.Toggle = /*#__PURE__*/function (_CommandBase) {
4219 function Toggle() {
4220 (0, _classCallCheck2.default)(this, Toggle);
4221 return _callSuper(this, Toggle, arguments);
4222 }
4223 (0, _inherits2.default)(Toggle, _CommandBase);
4224 return (0, _createClass2.default)(Toggle, [{
4225 key: "apply",
4226 value: function apply() {
4227 if (this.component.isOpen) {
4228 this.component.close();
4229 } else {
4230 $e.route(this.component.getNamespace());
4231 }
4232 }
4233 }]);
4234 }(_commandBase.default);
4235 var _default = exports["default"] = Toggle;
4236
4237 /***/ }),
4238
4239 /***/ "../modules/web-cli/assets/js/modules/component-base.js":
4240 /*!**************************************************************!*\
4241 !*** ../modules/web-cli/assets/js/modules/component-base.js ***!
4242 \**************************************************************/
4243 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4244
4245 "use strict";
4246
4247
4248 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4249 Object.defineProperty(exports, "__esModule", ({
4250 value: true
4251 }));
4252 exports["default"] = void 0;
4253 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4254 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4255 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4256 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4257 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4258 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4259 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4260 var _commandCallbackBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-callback-base */ "../modules/web-cli/assets/js/modules/command-callback-base.js"));
4261 var _toolkit = __webpack_require__(/*! @reduxjs/toolkit */ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js");
4262 var _module = _interopRequireDefault(__webpack_require__(/*! elementor/assets/dev/js/modules/imports/module.js */ "../assets/dev/js/modules/imports/module.js"));
4263 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4264 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4265 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; }
4266 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; }
4267 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)); }
4268 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4269 /**
4270 * @typedef {import('./command-infra')} CommandInfra
4271 * @typedef {import('./hook-base')} HookBase
4272 * @typedef {import('../core/states/ui-state-base')} UiStateBase
4273 */
4274 var ComponentBase = exports["default"] = /*#__PURE__*/function (_Module) {
4275 function ComponentBase() {
4276 (0, _classCallCheck2.default)(this, ComponentBase);
4277 return _callSuper(this, ComponentBase, arguments);
4278 }
4279 (0, _inherits2.default)(ComponentBase, _Module);
4280 return (0, _createClass2.default)(ComponentBase, [{
4281 key: "__construct",
4282 value: function __construct() {
4283 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4284 if (args.manager) {
4285 this.manager = args.manager;
4286 }
4287 this.commands = this.defaultCommands();
4288 this.commandsInternal = this.defaultCommandsInternal();
4289 this.hooks = this.defaultHooks();
4290 this.routes = this.defaultRoutes();
4291 this.tabs = this.defaultTabs();
4292 this.shortcuts = this.defaultShortcuts();
4293 this.utils = this.defaultUtils();
4294 this.data = this.defaultData();
4295 this.uiStates = this.defaultUiStates();
4296 this.states = this.defaultStates();
4297 this.defaultRoute = '';
4298 this.currentTab = '';
4299 }
4300 }, {
4301 key: "registerAPI",
4302 value: function registerAPI() {
4303 var _this = this;
4304 Object.entries(this.getTabs()).forEach(function (tab) {
4305 return _this.registerTabRoute(tab[0]);
4306 });
4307 Object.entries(this.getRoutes()).forEach(function (_ref) {
4308 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
4309 route = _ref2[0],
4310 callback = _ref2[1];
4311 return _this.registerRoute(route, callback);
4312 });
4313 Object.entries(this.getCommands()).forEach(function (_ref3) {
4314 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
4315 command = _ref4[0],
4316 callback = _ref4[1];
4317 return _this.registerCommand(command, callback);
4318 });
4319 Object.entries(this.getCommandsInternal()).forEach(function (_ref5) {
4320 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
4321 command = _ref6[0],
4322 callback = _ref6[1];
4323 return _this.registerCommandInternal(command, callback);
4324 });
4325 Object.values(this.getHooks()).forEach(function (instance) {
4326 return _this.registerHook(instance);
4327 });
4328 Object.entries(this.getData()).forEach(function (_ref7) {
4329 var _ref8 = (0, _slicedToArray2.default)(_ref7, 2),
4330 command = _ref8[0],
4331 callback = _ref8[1];
4332 return _this.registerData(command, callback);
4333 });
4334 Object.values(this.getUiStates()).forEach(function (instance) {
4335 return _this.registerUiState(instance);
4336 });
4337 Object.entries(this.getStates()).forEach(function (_ref9) {
4338 var _ref0 = (0, _slicedToArray2.default)(_ref9, 2),
4339 id = _ref0[0],
4340 state = _ref0[1];
4341 return _this.registerState(id, state);
4342 });
4343 }
4344
4345 // eslint-disable-next-line jsdoc/require-returns-check
4346 /**
4347 * @return {string} namespace
4348 */
4349 }, {
4350 key: "getNamespace",
4351 value: function getNamespace() {
4352 (0, _forceMethodImplementation.default)();
4353 }
4354
4355 /**
4356 * @deprecated since 3.7.0, use `getServiceName()` instead.
4357 */
4358 }, {
4359 key: "getRootContainer",
4360 value: function getRootContainer() {
4361 _deprecation.default.deprecated('getRootContainer()', '3.7.0', 'getServiceName()');
4362 return this.getServiceName();
4363 }
4364 }, {
4365 key: "getServiceName",
4366 value: function getServiceName() {
4367 return this.getNamespace().split('/')[0];
4368 }
4369 }, {
4370 key: "store",
4371 get: function get() {
4372 return $e.store.get(this.getNamespace());
4373 }
4374 }, {
4375 key: "defaultTabs",
4376 value: function defaultTabs() {
4377 return {};
4378 }
4379 }, {
4380 key: "defaultRoutes",
4381 value: function defaultRoutes() {
4382 return {};
4383 }
4384 }, {
4385 key: "defaultCommands",
4386 value: function defaultCommands() {
4387 return {};
4388 }
4389 }, {
4390 key: "defaultCommandsInternal",
4391 value: function defaultCommandsInternal() {
4392 return {};
4393 }
4394 }, {
4395 key: "defaultHooks",
4396 value: function defaultHooks() {
4397 return {};
4398 }
4399
4400 /**
4401 * Get the component's default UI states.
4402 *
4403 * @return {Object} default UI states
4404 */
4405 }, {
4406 key: "defaultUiStates",
4407 value: function defaultUiStates() {
4408 return {};
4409 }
4410
4411 /**
4412 * Get the component's Redux slice settings.
4413 *
4414 * @return {Object} Redux slice settings
4415 */
4416 }, {
4417 key: "defaultStates",
4418 value: function defaultStates() {
4419 return {};
4420 }
4421 }, {
4422 key: "defaultShortcuts",
4423 value: function defaultShortcuts() {
4424 return {};
4425 }
4426 }, {
4427 key: "defaultUtils",
4428 value: function defaultUtils() {
4429 return {};
4430 }
4431 }, {
4432 key: "defaultData",
4433 value: function defaultData() {
4434 return {};
4435 }
4436 }, {
4437 key: "getCommands",
4438 value: function getCommands() {
4439 return this.commands;
4440 }
4441 }, {
4442 key: "getCommandsInternal",
4443 value: function getCommandsInternal() {
4444 return this.commandsInternal;
4445 }
4446 }, {
4447 key: "getHooks",
4448 value: function getHooks() {
4449 return this.hooks;
4450 }
4451
4452 /**
4453 * Retrieve the component's UI states.
4454 *
4455 * @return {Object} UI states
4456 */
4457 }, {
4458 key: "getUiStates",
4459 value: function getUiStates() {
4460 return this.uiStates;
4461 }
4462
4463 /**
4464 * Retrieve the component's Redux Slice.
4465 *
4466 * @return {Object} Redux Slice
4467 */
4468 }, {
4469 key: "getStates",
4470 value: function getStates() {
4471 return this.states;
4472 }
4473 }, {
4474 key: "getRoutes",
4475 value: function getRoutes() {
4476 return this.routes;
4477 }
4478 }, {
4479 key: "getTabs",
4480 value: function getTabs() {
4481 return this.tabs;
4482 }
4483 }, {
4484 key: "getShortcuts",
4485 value: function getShortcuts() {
4486 return this.shortcuts;
4487 }
4488 }, {
4489 key: "getData",
4490 value: function getData() {
4491 return this.data;
4492 }
4493
4494 /**
4495 * @param {string} command
4496 * @param {(()=>{}|CommandInfra)} context
4497 * @param {'default'|'internal'|'data'} commandsType
4498 */
4499 }, {
4500 key: "registerCommand",
4501 value: function registerCommand(command, context) {
4502 var commandsType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'default';
4503 var commandsManager;
4504 switch (commandsType) {
4505 case 'default':
4506 commandsManager = $e.commands;
4507 break;
4508 case 'internal':
4509 commandsManager = $e.commandsInternal;
4510 break;
4511 case 'data':
4512 commandsManager = $e.data;
4513 break;
4514 default:
4515 throw new Error("Invalid commands type: '".concat(command, "'"));
4516 }
4517 var fullCommand = this.getNamespace() + '/' + command,
4518 instanceType = context.getInstanceType ? context.getInstanceType() : false,
4519 registerConfig = {
4520 command: fullCommand,
4521 component: this
4522 };
4523
4524 // Support pure callback.
4525 if (!instanceType) {
4526 if ($e.devTools) {
4527 $e.devTools.log.warn("Attach command-callback-base, on command: '".concat(fullCommand, "', context is unknown type."));
4528 }
4529 registerConfig.callback = context;
4530
4531 // Unique class.
4532 context = /*#__PURE__*/function (_CommandCallbackBase) {
4533 function context() {
4534 (0, _classCallCheck2.default)(this, context);
4535 return _callSuper(this, context, arguments);
4536 }
4537 (0, _inherits2.default)(context, _CommandCallbackBase);
4538 return (0, _createClass2.default)(context);
4539 }(_commandCallbackBase.default);
4540 }
4541 context.setRegisterConfig(registerConfig);
4542 commandsManager.register(this, command, context);
4543 }
4544
4545 /**
4546 * @param {HookBase} instance
4547 */
4548 }, {
4549 key: "registerHook",
4550 value: function registerHook(instance) {
4551 return instance.register();
4552 }
4553 }, {
4554 key: "registerCommandInternal",
4555 value: function registerCommandInternal(command, context) {
4556 this.registerCommand(command, context, 'internal');
4557 }
4558
4559 /**
4560 * Register a UI state.
4561 *
4562 * @param {UiStateBase} instance - UI state instance.
4563 *
4564 * @return {void}
4565 */
4566 }, {
4567 key: "registerUiState",
4568 value: function registerUiState(instance) {
4569 $e.uiStates.register(instance);
4570 }
4571
4572 /**
4573 * Register a Redux Slice.
4574 *
4575 * @param {string} id - State id.
4576 * @param {Object} stateConfig - The state config.
4577 *
4578 * @return {void}
4579 */
4580 }, {
4581 key: "registerState",
4582 value: function registerState(id, stateConfig) {
4583 id = this.getNamespace() + (id ? "/".concat(id) : '');
4584 var slice = (0, _toolkit.createSlice)(_objectSpread(_objectSpread({}, stateConfig), {}, {
4585 name: id
4586 }));
4587 $e.store.register(id, slice);
4588 }
4589 }, {
4590 key: "registerRoute",
4591 value: function registerRoute(route, callback) {
4592 $e.routes.register(this, route, callback);
4593 }
4594 }, {
4595 key: "registerData",
4596 value: function registerData(command, context) {
4597 this.registerCommand(command, context, 'data');
4598 }
4599 }, {
4600 key: "unregisterRoute",
4601 value: function unregisterRoute(route) {
4602 $e.routes.unregister(this, route);
4603 }
4604 }, {
4605 key: "registerTabRoute",
4606 value: function registerTabRoute(tab) {
4607 var _this2 = this;
4608 this.registerRoute(tab, function (args) {
4609 return _this2.activateTab(tab, args);
4610 });
4611 }
4612 }, {
4613 key: "dependency",
4614 value: function dependency() {
4615 return true;
4616 }
4617 }, {
4618 key: "open",
4619 value: function open() {
4620 return true;
4621 }
4622 }, {
4623 key: "close",
4624 value: function close() {
4625 if (!this.isOpen) {
4626 return false;
4627 }
4628 this.isOpen = false;
4629 this.inactivate();
4630 $e.routes.clearCurrent(this.getNamespace());
4631 $e.routes.clearHistory(this.getServiceName());
4632 return true;
4633 }
4634 }, {
4635 key: "activate",
4636 value: function activate() {
4637 $e.components.activate(this.getNamespace());
4638 }
4639 }, {
4640 key: "inactivate",
4641 value: function inactivate() {
4642 $e.components.inactivate(this.getNamespace());
4643 }
4644 }, {
4645 key: "isActive",
4646 value: function isActive() {
4647 return $e.components.isActive(this.getNamespace());
4648 }
4649 }, {
4650 key: "onRoute",
4651 value: function onRoute(route) {
4652 this.toggleRouteClass(route, true);
4653 this.toggleHistoryClass();
4654 this.activate();
4655 this.trigger('route/open', route);
4656 }
4657 }, {
4658 key: "onCloseRoute",
4659 value: function onCloseRoute(route) {
4660 this.toggleRouteClass(route, false);
4661 this.inactivate();
4662 this.trigger('route/close', route);
4663 }
4664 }, {
4665 key: "setDefaultRoute",
4666 value: function setDefaultRoute(route) {
4667 this.defaultRoute = this.getNamespace() + '/' + route;
4668 }
4669 }, {
4670 key: "getDefaultRoute",
4671 value: function getDefaultRoute() {
4672 return this.defaultRoute;
4673 }
4674 }, {
4675 key: "removeTab",
4676 value: function removeTab(tab) {
4677 delete this.tabs[tab];
4678 this.unregisterRoute(tab);
4679 }
4680 }, {
4681 key: "hasTab",
4682 value: function hasTab(tab) {
4683 return !!this.tabs[tab];
4684 }
4685 }, {
4686 key: "addTab",
4687 value: function addTab(tab, args, position) {
4688 var _this3 = this;
4689 this.tabs[tab] = args;
4690 // It can be 0.
4691 if ('undefined' !== typeof position) {
4692 var newTabs = {};
4693 var ids = Object.keys(this.tabs);
4694 // Remove new tab
4695 ids.pop();
4696
4697 // Add it to position.
4698 ids.splice(position, 0, tab);
4699 ids.forEach(function (id) {
4700 newTabs[id] = _this3.tabs[id];
4701 });
4702 this.tabs = newTabs;
4703 }
4704 this.registerTabRoute(tab);
4705 }
4706 }, {
4707 key: "getTabsWrapperSelector",
4708 value: function getTabsWrapperSelector() {
4709 return '';
4710 }
4711 }, {
4712 key: "getTabRoute",
4713 value: function getTabRoute(tab) {
4714 return this.getNamespace() + '/' + tab;
4715 }
4716 }, {
4717 key: "renderTab",
4718 value: function renderTab(tab) {} // eslint-disable-line
4719 }, {
4720 key: "activateTab",
4721 value: function activateTab(tab, args) {
4722 var _this4 = this;
4723 this.renderTab(tab, args);
4724 jQuery(this.getTabsWrapperSelector() + ' .elementor-component-tab').off('click').on('click', function (event) {
4725 $e.route(_this4.getTabRoute(event.currentTarget.dataset.tab), args);
4726 }).removeClass('elementor-active').filter('[data-tab="' + tab + '"]').addClass('elementor-active');
4727 }
4728 }, {
4729 key: "getActiveTabConfig",
4730 value: function getActiveTabConfig() {
4731 return this.tabs[this.currentTab] || {};
4732 }
4733 }, {
4734 key: "getBodyClass",
4735 value: function getBodyClass(route) {
4736 return 'e-route-' + route.replace(/\//g, '-');
4737 }
4738
4739 /**
4740 * If command includes uppercase character convert it to lowercase and add `-`.
4741 * e.g: `CopyAll` is converted to `copy-all`.
4742 *
4743 * @param {string} commandName
4744 */
4745 }, {
4746 key: "normalizeCommandName",
4747 value: function normalizeCommandName(commandName) {
4748 return commandName.replace(/[A-Z]/g, function (match, offset) {
4749 return (offset > 0 ? '-' : '') + match.toLowerCase();
4750 });
4751 }
4752
4753 /**
4754 * @param {{}} commandsFromImport
4755 * @return {{}} imported commands
4756 */
4757 }, {
4758 key: "importCommands",
4759 value: function importCommands(commandsFromImport) {
4760 var _this5 = this;
4761 var commands = {};
4762
4763 // Convert `Commands` to `ComponentBase` workable format.
4764 Object.entries(commandsFromImport).forEach(function (_ref1) {
4765 var _ref10 = (0, _slicedToArray2.default)(_ref1, 2),
4766 className = _ref10[0],
4767 Class = _ref10[1];
4768 var command = _this5.normalizeCommandName(className);
4769 commands[command] = Class;
4770 });
4771 return commands;
4772 }
4773 }, {
4774 key: "importHooks",
4775 value: function importHooks(hooksFromImport) {
4776 var hooks = {};
4777 for (var key in hooksFromImport) {
4778 var hook = new hooksFromImport[key]();
4779 hooks[hook.getId()] = hook;
4780 }
4781 return hooks;
4782 }
4783
4784 /**
4785 * Import & initialize the component's UI states.
4786 * Should be used inside `defaultUiState()`.
4787 *
4788 * @param {Object} statesFromImport - UI states from import.
4789 *
4790 * @return {Object} UI States
4791 */
4792 }, {
4793 key: "importUiStates",
4794 value: function importUiStates(statesFromImport) {
4795 var _this6 = this;
4796 var uiStates = {};
4797 Object.values(statesFromImport).forEach(function (className) {
4798 var uiState = new className(_this6);
4799 uiStates[uiState.getId()] = uiState;
4800 });
4801 return uiStates;
4802 }
4803
4804 /**
4805 * Set a UI state value.
4806 * TODO: Should we provide such function? Maybe the developer should implicitly pass the full state ID?
4807 *
4808 * @param {string} state - Non-prefixed state ID.
4809 * @param {*} value - New state value.
4810 *
4811 * @return {void}
4812 */
4813 }, {
4814 key: "setUiState",
4815 value: function setUiState(state, value) {
4816 $e.uiStates.set("".concat(this.getNamespace(), "/").concat(state), value);
4817 }
4818 }, {
4819 key: "toggleRouteClass",
4820 value: function toggleRouteClass(route, state) {
4821 document.body.classList.toggle(this.getBodyClass(route), state);
4822 }
4823 }, {
4824 key: "toggleHistoryClass",
4825 value: function toggleHistoryClass() {
4826 document.body.classList.toggle('e-routes-has-history', !!$e.routes.getHistory(this.getServiceName()).length);
4827 }
4828 }]);
4829 }(_module.default);
4830
4831 /***/ }),
4832
4833 /***/ "../modules/web-cli/assets/js/modules/component-modal-base.js":
4834 /*!********************************************************************!*\
4835 !*** ../modules/web-cli/assets/js/modules/component-modal-base.js ***!
4836 \********************************************************************/
4837 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4838
4839 "use strict";
4840
4841
4842 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4843 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
4844 Object.defineProperty(exports, "__esModule", ({
4845 value: true
4846 }));
4847 exports["default"] = void 0;
4848 var _readOnlyError2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/readOnlyError */ "../node_modules/@babel/runtime/helpers/readOnlyError.js"));
4849 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4850 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4851 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4852 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4853 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
4854 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4855 var _componentBase = _interopRequireDefault(__webpack_require__(/*! ./component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
4856 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../modules/web-cli/assets/js/modules/commands/index.js"));
4857 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4858 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); }
4859 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)); }
4860 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4861 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; }
4862 var ComponentModalBase = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
4863 function ComponentModalBase() {
4864 (0, _classCallCheck2.default)(this, ComponentModalBase);
4865 return _callSuper(this, ComponentModalBase, arguments);
4866 }
4867 (0, _inherits2.default)(ComponentModalBase, _ComponentBase);
4868 return (0, _createClass2.default)(ComponentModalBase, [{
4869 key: "registerAPI",
4870 value: function registerAPI() {
4871 var _this = this;
4872 _superPropGet(ComponentModalBase, "registerAPI", this, 3)([]);
4873 $e.shortcuts.register('esc', {
4874 scopes: [this.getNamespace()],
4875 callback: function callback() {
4876 return _this.close();
4877 }
4878 });
4879 }
4880 }, {
4881 key: "defaultCommands",
4882 value: function defaultCommands() {
4883 return this.importCommands(commands);
4884 }
4885 }, {
4886 key: "defaultRoutes",
4887 value: function defaultRoutes() {
4888 return {
4889 '': function _() {/* Nothing to do, it's already rendered. */}
4890 };
4891 }
4892 }, {
4893 key: "open",
4894 value: function open() {
4895 var _this2 = this;
4896 if (!this.layout) {
4897 var layout = this.getModalLayout();
4898 this.layout = new layout({
4899 component: this
4900 });
4901 this.layout.getModal().on('hide', function () {
4902 return _this2.close();
4903 });
4904 }
4905 this.layout.showModal();
4906 return true;
4907 }
4908 }, {
4909 key: "close",
4910 value: function close() {
4911 if (!_superPropGet(ComponentModalBase, "close", this, 3)([])) {
4912 return false;
4913 }
4914 var close = elementor.hooks.applyFilters('component/modal/close', this.layout.getModal().hide.bind(this.layout.getModal()), this);
4915 close();
4916 return true;
4917 }
4918 }, {
4919 key: "getModalLayout",
4920 value: function getModalLayout() {
4921 (0, _forceMethodImplementation.default)();
4922 }
4923 }]);
4924 }(_componentBase.default);
4925
4926 /***/ }),
4927
4928 /***/ "../modules/web-cli/assets/js/utils/console.js":
4929 /*!*****************************************************!*\
4930 !*** ../modules/web-cli/assets/js/utils/console.js ***!
4931 \*****************************************************/
4932 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4933
4934 "use strict";
4935
4936
4937 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4938 Object.defineProperty(exports, "__esModule", ({
4939 value: true
4940 }));
4941 exports["default"] = void 0;
4942 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4943 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4944 var Console = exports["default"] = /*#__PURE__*/function () {
4945 function Console() {
4946 (0, _classCallCheck2.default)(this, Console);
4947 }
4948 return (0, _createClass2.default)(Console, null, [{
4949 key: "error",
4950 value: function error(message) {
4951 // Show an error if devTools is available.
4952 if ($e.devTools) {
4953 $e.devTools.log.error(message);
4954 }
4955
4956 // If not a 'Hook-Break' then show error.
4957 if (!(message instanceof $e.modules.HookBreak)) {
4958 // eslint-disable-next-line no-console
4959 console.error(message);
4960 }
4961 }
4962 }, {
4963 key: "warn",
4964 value: function warn() {
4965 var _console;
4966 var style = "font-size: 12px; background-image: url(\"".concat(elementorWebCliConfig.urls.assets, "images/logo-icon.png\"); background-repeat: no-repeat; background-size: contain;");
4967 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4968 args[_key] = arguments[_key];
4969 }
4970 args.unshift('%c %c', style, '');
4971 (_console = console).warn.apply(_console, args); // eslint-disable-line no-console
4972 }
4973 }]);
4974 }();
4975
4976 /***/ }),
4977
4978 /***/ "../modules/web-cli/assets/js/utils/deprecation.js":
4979 /*!*********************************************************!*\
4980 !*** ../modules/web-cli/assets/js/utils/deprecation.js ***!
4981 \*********************************************************/
4982 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4983
4984 "use strict";
4985
4986
4987 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4988 Object.defineProperty(exports, "__esModule", ({
4989 value: true
4990 }));
4991 exports["default"] = void 0;
4992 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4993 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4994 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4995 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
4996 // Copied from `modules/dev-tools/assets/js/deprecation.js`
4997 /**
4998 * @typedef {Object} Version
4999 * @property {number} major1 The first number
5000 * @property {number} major2 The second number
5001 * @property {number} minor The third number
5002 * @property {string} build The fourth number
5003 */
5004
5005 var softDeprecated = function softDeprecated(name, version, replacement) {
5006 if (elementorWebCliConfig.isDebug) {
5007 deprecatedMessage('soft', name, version, replacement);
5008 }
5009 };
5010 var hardDeprecated = function hardDeprecated(name, version, replacement) {
5011 deprecatedMessage('hard', name, version, replacement);
5012 };
5013 var deprecatedMessage = function deprecatedMessage(type, name, version, replacement) {
5014 var message = "`".concat(name, "` is ").concat(type, " deprecated since ").concat(version);
5015 if (replacement) {
5016 message += " - Use `".concat(replacement, "` instead");
5017 }
5018 _console.default.warn(message);
5019 };
5020 var Deprecation = exports["default"] = /*#__PURE__*/function () {
5021 function Deprecation() {
5022 (0, _classCallCheck2.default)(this, Deprecation);
5023 }
5024 return (0, _createClass2.default)(Deprecation, null, [{
5025 key: "deprecated",
5026 value: function deprecated(name, version, replacement) {
5027 if (this.isHardDeprecated(version)) {
5028 hardDeprecated(name, version, replacement);
5029 } else {
5030 softDeprecated(name, version, replacement);
5031 }
5032 }
5033
5034 /**
5035 * @param {string} version
5036 *
5037 * @return {Version}
5038 */
5039 }, {
5040 key: "parseVersion",
5041 value: function parseVersion(version) {
5042 var versionParts = version.split('.');
5043 if (versionParts.length < 3 || versionParts.length > 4) {
5044 throw new RangeError('Invalid Semantic Version string provided');
5045 }
5046 var _versionParts = (0, _slicedToArray2.default)(versionParts, 4),
5047 major1 = _versionParts[0],
5048 major2 = _versionParts[1],
5049 minor = _versionParts[2],
5050 _versionParts$ = _versionParts[3],
5051 build = _versionParts$ === void 0 ? '' : _versionParts$;
5052 return {
5053 major1: parseInt(major1),
5054 major2: parseInt(major2),
5055 minor: parseInt(minor),
5056 build: build
5057 };
5058 }
5059
5060 /**
5061 * Get total of major.
5062 *
5063 * 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,
5064 * versions with major2 more then 9 will be added to total.
5065 *
5066 * @param {Version} versionObj
5067 *
5068 * @return {number}
5069 */
5070 }, {
5071 key: "getTotalMajor",
5072 value: function getTotalMajor(versionObj) {
5073 var total = parseInt("".concat(versionObj.major1).concat(versionObj.major2, "0"));
5074 total = Number((total / 10).toFixed(0));
5075 if (versionObj.major2 > 9) {
5076 total = versionObj.major2 - 9;
5077 }
5078 return total;
5079 }
5080
5081 /**
5082 * @param {string} version1
5083 * @param {string} version2
5084 *
5085 * @return {number}
5086 */
5087 }, {
5088 key: "compareVersion",
5089 value: function compareVersion(version1, version2) {
5090 var _this = this;
5091 return [this.parseVersion(version1), this.parseVersion(version2)].map(function (versionObj) {
5092 return _this.getTotalMajor(versionObj);
5093 }).reduce(function (acc, major) {
5094 return acc - major;
5095 });
5096 }
5097
5098 /**
5099 * @param {string} version
5100 *
5101 * @return {boolean}
5102 */
5103 }, {
5104 key: "isSoftDeprecated",
5105 value: function isSoftDeprecated(version) {
5106 var total = this.compareVersion(version, elementorWebCliConfig.version);
5107 return total <= 4;
5108 }
5109
5110 /**
5111 * @param {string} version
5112 * @return {boolean}
5113 */
5114 }, {
5115 key: "isHardDeprecated",
5116 value: function isHardDeprecated(version) {
5117 var total = this.compareVersion(version, elementorWebCliConfig.version);
5118 return total < 0 || total >= 8;
5119 }
5120 }]);
5121 }();
5122
5123 /***/ }),
5124
5125 /***/ "../modules/web-cli/assets/js/utils/force-method-implementation.js":
5126 /*!*************************************************************************!*\
5127 !*** ../modules/web-cli/assets/js/utils/force-method-implementation.js ***!
5128 \*************************************************************************/
5129 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5130
5131 "use strict";
5132
5133
5134 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5135 Object.defineProperty(exports, "__esModule", ({
5136 value: true
5137 }));
5138 exports["default"] = exports.ForceMethodImplementation = void 0;
5139 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5140 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5141 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5142 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5143 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5144 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
5145 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)); }
5146 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5147 // TODO: Copied from `assets/dev/js/modules/imports/force-method-implementation.js`;
5148 var ForceMethodImplementation = exports.ForceMethodImplementation = /*#__PURE__*/function (_Error) {
5149 function ForceMethodImplementation() {
5150 var _this;
5151 var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5152 (0, _classCallCheck2.default)(this, ForceMethodImplementation);
5153 _this = _callSuper(this, ForceMethodImplementation, ["".concat(info.isStatic ? 'static ' : '').concat(info.fullName, "() should be implemented, please provide '").concat(info.functionName || info.fullName, "' functionality.")]);
5154 Error.captureStackTrace(_this, ForceMethodImplementation);
5155 return _this;
5156 }
5157 (0, _inherits2.default)(ForceMethodImplementation, _Error);
5158 return (0, _createClass2.default)(ForceMethodImplementation);
5159 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
5160 var _default = exports["default"] = function _default() {
5161 var stack = Error().stack,
5162 caller = stack.split('\n')[2].trim(),
5163 callerName = caller.startsWith('at new') ? 'constructor' : caller.split(' ')[1],
5164 info = {};
5165 info.functionName = callerName;
5166 info.fullName = callerName;
5167 if (info.functionName.includes('.')) {
5168 var parts = info.functionName.split('.');
5169 info.className = parts[0];
5170 info.functionName = parts[1];
5171 } else {
5172 info.isStatic = true;
5173 }
5174 throw new ForceMethodImplementation(info);
5175 };
5176
5177 /***/ }),
5178
5179 /***/ "../node_modules/@babel/runtime/helpers/OverloadYield.js":
5180 /*!***************************************************************!*\
5181 !*** ../node_modules/@babel/runtime/helpers/OverloadYield.js ***!
5182 \***************************************************************/
5183 /***/ ((module) => {
5184
5185 function _OverloadYield(e, d) {
5186 this.v = e, this.k = d;
5187 }
5188 module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
5189
5190 /***/ }),
5191
5192 /***/ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
5193 /*!******************************************************************!*\
5194 !*** ../node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
5195 \******************************************************************/
5196 /***/ ((module) => {
5197
5198 function _arrayLikeToArray(r, a) {
5199 (null == a || a > r.length) && (a = r.length);
5200 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
5201 return n;
5202 }
5203 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
5204
5205 /***/ }),
5206
5207 /***/ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js":
5208 /*!****************************************************************!*\
5209 !*** ../node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
5210 \****************************************************************/
5211 /***/ ((module) => {
5212
5213 function _arrayWithHoles(r) {
5214 if (Array.isArray(r)) return r;
5215 }
5216 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
5217
5218 /***/ }),
5219
5220 /***/ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js":
5221 /*!***********************************************************************!*\
5222 !*** ../node_modules/@babel/runtime/helpers/assertThisInitialized.js ***!
5223 \***********************************************************************/
5224 /***/ ((module) => {
5225
5226 function _assertThisInitialized(e) {
5227 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5228 return e;
5229 }
5230 module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
5231
5232 /***/ }),
5233
5234 /***/ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js":
5235 /*!******************************************************************!*\
5236 !*** ../node_modules/@babel/runtime/helpers/asyncToGenerator.js ***!
5237 \******************************************************************/
5238 /***/ ((module) => {
5239
5240 function asyncGeneratorStep(n, t, e, r, o, a, c) {
5241 try {
5242 var i = n[a](c),
5243 u = i.value;
5244 } catch (n) {
5245 return void e(n);
5246 }
5247 i.done ? t(u) : Promise.resolve(u).then(r, o);
5248 }
5249 function _asyncToGenerator(n) {
5250 return function () {
5251 var t = this,
5252 e = arguments;
5253 return new Promise(function (r, o) {
5254 var a = n.apply(t, e);
5255 function _next(n) {
5256 asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
5257 }
5258 function _throw(n) {
5259 asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
5260 }
5261 _next(void 0);
5262 });
5263 };
5264 }
5265 module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5266
5267 /***/ }),
5268
5269 /***/ "../node_modules/@babel/runtime/helpers/classCallCheck.js":
5270 /*!****************************************************************!*\
5271 !*** ../node_modules/@babel/runtime/helpers/classCallCheck.js ***!
5272 \****************************************************************/
5273 /***/ ((module) => {
5274
5275 function _classCallCheck(a, n) {
5276 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
5277 }
5278 module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
5279
5280 /***/ }),
5281
5282 /***/ "../node_modules/@babel/runtime/helpers/construct.js":
5283 /*!***********************************************************!*\
5284 !*** ../node_modules/@babel/runtime/helpers/construct.js ***!
5285 \***********************************************************/
5286 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5287
5288 var isNativeReflectConstruct = __webpack_require__(/*! ./isNativeReflectConstruct.js */ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js");
5289 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5290 function _construct(t, e, r) {
5291 if (isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
5292 var o = [null];
5293 o.push.apply(o, e);
5294 var p = new (t.bind.apply(t, o))();
5295 return r && setPrototypeOf(p, r.prototype), p;
5296 }
5297 module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5298
5299 /***/ }),
5300
5301 /***/ "../node_modules/@babel/runtime/helpers/createClass.js":
5302 /*!*************************************************************!*\
5303 !*** ../node_modules/@babel/runtime/helpers/createClass.js ***!
5304 \*************************************************************/
5305 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5306
5307 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5308 function _defineProperties(e, r) {
5309 for (var t = 0; t < r.length; t++) {
5310 var o = r[t];
5311 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
5312 }
5313 }
5314 function _createClass(e, r, t) {
5315 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
5316 writable: !1
5317 }), e;
5318 }
5319 module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
5320
5321 /***/ }),
5322
5323 /***/ "../node_modules/@babel/runtime/helpers/defineProperty.js":
5324 /*!****************************************************************!*\
5325 !*** ../node_modules/@babel/runtime/helpers/defineProperty.js ***!
5326 \****************************************************************/
5327 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5328
5329 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5330 function _defineProperty(e, r, t) {
5331 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5332 value: t,
5333 enumerable: !0,
5334 configurable: !0,
5335 writable: !0
5336 }) : e[r] = t, e;
5337 }
5338 module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
5339
5340 /***/ }),
5341
5342 /***/ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js":
5343 /*!********************************************************************!*\
5344 !*** ../node_modules/@babel/runtime/helpers/esm/defineProperty.js ***!
5345 \********************************************************************/
5346 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5347
5348 "use strict";
5349 __webpack_require__.r(__webpack_exports__);
5350 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5351 /* harmony export */ "default": () => (/* binding */ _defineProperty)
5352 /* harmony export */ });
5353 /* harmony import */ var _toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js");
5354
5355 function _defineProperty(e, r, t) {
5356 return (r = (0,_toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r)) in e ? Object.defineProperty(e, r, {
5357 value: t,
5358 enumerable: !0,
5359 configurable: !0,
5360 writable: !0
5361 }) : e[r] = t, e;
5362 }
5363
5364
5365 /***/ }),
5366
5367 /***/ "../node_modules/@babel/runtime/helpers/esm/objectSpread2.js":
5368 /*!*******************************************************************!*\
5369 !*** ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js ***!
5370 \*******************************************************************/
5371 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5372
5373 "use strict";
5374 __webpack_require__.r(__webpack_exports__);
5375 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5376 /* harmony export */ "default": () => (/* binding */ _objectSpread2)
5377 /* harmony export */ });
5378 /* harmony import */ var _defineProperty_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defineProperty.js */ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js");
5379
5380 function ownKeys(e, r) {
5381 var t = Object.keys(e);
5382 if (Object.getOwnPropertySymbols) {
5383 var o = Object.getOwnPropertySymbols(e);
5384 r && (o = o.filter(function (r) {
5385 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5386 })), t.push.apply(t, o);
5387 }
5388 return t;
5389 }
5390 function _objectSpread2(e) {
5391 for (var r = 1; r < arguments.length; r++) {
5392 var t = null != arguments[r] ? arguments[r] : {};
5393 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
5394 (0,_defineProperty_js__WEBPACK_IMPORTED_MODULE_0__["default"])(e, r, t[r]);
5395 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
5396 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5397 });
5398 }
5399 return e;
5400 }
5401
5402
5403 /***/ }),
5404
5405 /***/ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js":
5406 /*!*****************************************************************!*\
5407 !*** ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js ***!
5408 \*****************************************************************/
5409 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5410
5411 "use strict";
5412 __webpack_require__.r(__webpack_exports__);
5413 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5414 /* harmony export */ "default": () => (/* binding */ toPrimitive)
5415 /* harmony export */ });
5416 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5417
5418 function toPrimitive(t, r) {
5419 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(t) || !t) return t;
5420 var e = t[Symbol.toPrimitive];
5421 if (void 0 !== e) {
5422 var i = e.call(t, r || "default");
5423 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i)) return i;
5424 throw new TypeError("@@toPrimitive must return a primitive value.");
5425 }
5426 return ("string" === r ? String : Number)(t);
5427 }
5428
5429
5430 /***/ }),
5431
5432 /***/ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js":
5433 /*!*******************************************************************!*\
5434 !*** ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js ***!
5435 \*******************************************************************/
5436 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5437
5438 "use strict";
5439 __webpack_require__.r(__webpack_exports__);
5440 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5441 /* harmony export */ "default": () => (/* binding */ toPropertyKey)
5442 /* harmony export */ });
5443 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5444 /* harmony import */ var _toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js");
5445
5446
5447 function toPropertyKey(t) {
5448 var i = (0,_toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__["default"])(t, "string");
5449 return "symbol" == (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i) ? i : i + "";
5450 }
5451
5452
5453 /***/ }),
5454
5455 /***/ "../node_modules/@babel/runtime/helpers/esm/typeof.js":
5456 /*!************************************************************!*\
5457 !*** ../node_modules/@babel/runtime/helpers/esm/typeof.js ***!
5458 \************************************************************/
5459 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5460
5461 "use strict";
5462 __webpack_require__.r(__webpack_exports__);
5463 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5464 /* harmony export */ "default": () => (/* binding */ _typeof)
5465 /* harmony export */ });
5466 function _typeof(o) {
5467 "@babel/helpers - typeof";
5468
5469 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
5470 return typeof o;
5471 } : function (o) {
5472 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
5473 }, _typeof(o);
5474 }
5475
5476
5477 /***/ }),
5478
5479 /***/ "../node_modules/@babel/runtime/helpers/get.js":
5480 /*!*****************************************************!*\
5481 !*** ../node_modules/@babel/runtime/helpers/get.js ***!
5482 \*****************************************************/
5483 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5484
5485 var superPropBase = __webpack_require__(/*! ./superPropBase.js */ "../node_modules/@babel/runtime/helpers/superPropBase.js");
5486 function _get() {
5487 return module.exports = _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
5488 var p = superPropBase(e, t);
5489 if (p) {
5490 var n = Object.getOwnPropertyDescriptor(p, t);
5491 return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
5492 }
5493 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _get.apply(null, arguments);
5494 }
5495 module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
5496
5497 /***/ }),
5498
5499 /***/ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js":
5500 /*!****************************************************************!*\
5501 !*** ../node_modules/@babel/runtime/helpers/getPrototypeOf.js ***!
5502 \****************************************************************/
5503 /***/ ((module) => {
5504
5505 function _getPrototypeOf(t) {
5506 return module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
5507 return t.__proto__ || Object.getPrototypeOf(t);
5508 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _getPrototypeOf(t);
5509 }
5510 module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
5511
5512 /***/ }),
5513
5514 /***/ "../node_modules/@babel/runtime/helpers/inherits.js":
5515 /*!**********************************************************!*\
5516 !*** ../node_modules/@babel/runtime/helpers/inherits.js ***!
5517 \**********************************************************/
5518 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5519
5520 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5521 function _inherits(t, e) {
5522 if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
5523 t.prototype = Object.create(e && e.prototype, {
5524 constructor: {
5525 value: t,
5526 writable: !0,
5527 configurable: !0
5528 }
5529 }), Object.defineProperty(t, "prototype", {
5530 writable: !1
5531 }), e && setPrototypeOf(t, e);
5532 }
5533 module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
5534
5535 /***/ }),
5536
5537 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
5538 /*!***********************************************************************!*\
5539 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
5540 \***********************************************************************/
5541 /***/ ((module) => {
5542
5543 function _interopRequireDefault(e) {
5544 return e && e.__esModule ? e : {
5545 "default": e
5546 };
5547 }
5548 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
5549
5550 /***/ }),
5551
5552 /***/ "../node_modules/@babel/runtime/helpers/isNativeFunction.js":
5553 /*!******************************************************************!*\
5554 !*** ../node_modules/@babel/runtime/helpers/isNativeFunction.js ***!
5555 \******************************************************************/
5556 /***/ ((module) => {
5557
5558 function _isNativeFunction(t) {
5559 try {
5560 return -1 !== Function.toString.call(t).indexOf("[native code]");
5561 } catch (n) {
5562 return "function" == typeof t;
5563 }
5564 }
5565 module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
5566
5567 /***/ }),
5568
5569 /***/ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js":
5570 /*!**************************************************************************!*\
5571 !*** ../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js ***!
5572 \**************************************************************************/
5573 /***/ ((module) => {
5574
5575 function _isNativeReflectConstruct() {
5576 try {
5577 var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
5578 } catch (t) {}
5579 return (module.exports = _isNativeReflectConstruct = function _isNativeReflectConstruct() {
5580 return !!t;
5581 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5582 }
5583 module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5584
5585 /***/ }),
5586
5587 /***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
5588 /*!**********************************************************************!*\
5589 !*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
5590 \**********************************************************************/
5591 /***/ ((module) => {
5592
5593 function _iterableToArrayLimit(r, l) {
5594 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
5595 if (null != t) {
5596 var e,
5597 n,
5598 i,
5599 u,
5600 a = [],
5601 f = !0,
5602 o = !1;
5603 try {
5604 if (i = (t = t.call(r)).next, 0 === l) {
5605 if (Object(t) !== t) return;
5606 f = !1;
5607 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
5608 } catch (r) {
5609 o = !0, n = r;
5610 } finally {
5611 try {
5612 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
5613 } finally {
5614 if (o) throw n;
5615 }
5616 }
5617 return a;
5618 }
5619 }
5620 module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
5621
5622 /***/ }),
5623
5624 /***/ "../node_modules/@babel/runtime/helpers/nonIterableRest.js":
5625 /*!*****************************************************************!*\
5626 !*** ../node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
5627 \*****************************************************************/
5628 /***/ ((module) => {
5629
5630 function _nonIterableRest() {
5631 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5632 }
5633 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
5634
5635 /***/ }),
5636
5637 /***/ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js":
5638 /*!***************************************************************************!*\
5639 !*** ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js ***!
5640 \***************************************************************************/
5641 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5642
5643 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5644 var assertThisInitialized = __webpack_require__(/*! ./assertThisInitialized.js */ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js");
5645 function _possibleConstructorReturn(t, e) {
5646 if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
5647 if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
5648 return assertThisInitialized(t);
5649 }
5650 module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
5651
5652 /***/ }),
5653
5654 /***/ "../node_modules/@babel/runtime/helpers/readOnlyError.js":
5655 /*!***************************************************************!*\
5656 !*** ../node_modules/@babel/runtime/helpers/readOnlyError.js ***!
5657 \***************************************************************/
5658 /***/ ((module) => {
5659
5660 function _readOnlyError(r) {
5661 throw new TypeError('"' + r + '" is read-only');
5662 }
5663 module.exports = _readOnlyError, module.exports.__esModule = true, module.exports["default"] = module.exports;
5664
5665 /***/ }),
5666
5667 /***/ "../node_modules/@babel/runtime/helpers/regenerator.js":
5668 /*!*************************************************************!*\
5669 !*** ../node_modules/@babel/runtime/helpers/regenerator.js ***!
5670 \*************************************************************/
5671 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5672
5673 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
5674 function _regenerator() {
5675 /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
5676 var e,
5677 t,
5678 r = "function" == typeof Symbol ? Symbol : {},
5679 n = r.iterator || "@@iterator",
5680 o = r.toStringTag || "@@toStringTag";
5681 function i(r, n, o, i) {
5682 var c = n && n.prototype instanceof Generator ? n : Generator,
5683 u = Object.create(c.prototype);
5684 return regeneratorDefine(u, "_invoke", function (r, n, o) {
5685 var i,
5686 c,
5687 u,
5688 f = 0,
5689 p = o || [],
5690 y = !1,
5691 G = {
5692 p: 0,
5693 n: 0,
5694 v: e,
5695 a: d,
5696 f: d.bind(e, 4),
5697 d: function d(t, r) {
5698 return i = t, c = 0, u = e, G.n = r, a;
5699 }
5700 };
5701 function d(r, n) {
5702 for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
5703 var o,
5704 i = p[t],
5705 d = G.p,
5706 l = i[2];
5707 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));
5708 }
5709 if (o || r > 1) return a;
5710 throw y = !0, n;
5711 }
5712 return function (o, p, l) {
5713 if (f > 1) throw TypeError("Generator is already running");
5714 for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
5715 i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
5716 try {
5717 if (f = 2, i) {
5718 if (c || (o = "next"), t = i[o]) {
5719 if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
5720 if (!t.done) return t;
5721 u = t.value, c < 2 && (c = 0);
5722 } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
5723 i = e;
5724 } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
5725 } catch (t) {
5726 i = e, c = 1, u = t;
5727 } finally {
5728 f = 1;
5729 }
5730 }
5731 return {
5732 value: t,
5733 done: y
5734 };
5735 };
5736 }(r, o, i), !0), u;
5737 }
5738 var a = {};
5739 function Generator() {}
5740 function GeneratorFunction() {}
5741 function GeneratorFunctionPrototype() {}
5742 t = Object.getPrototypeOf;
5743 var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
5744 return this;
5745 }), t),
5746 u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
5747 function f(e) {
5748 return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
5749 }
5750 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 () {
5751 return this;
5752 }), regeneratorDefine(u, "toString", function () {
5753 return "[object Generator]";
5754 }), (module.exports = _regenerator = function _regenerator() {
5755 return {
5756 w: i,
5757 m: f
5758 };
5759 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5760 }
5761 module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5762
5763 /***/ }),
5764
5765 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js":
5766 /*!******************************************************************!*\
5767 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsync.js ***!
5768 \******************************************************************/
5769 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5770
5771 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
5772 function _regeneratorAsync(n, e, r, t, o) {
5773 var a = regeneratorAsyncGen(n, e, r, t, o);
5774 return a.next().then(function (n) {
5775 return n.done ? n.value : a.next();
5776 });
5777 }
5778 module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
5779
5780 /***/ }),
5781
5782 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js":
5783 /*!*********************************************************************!*\
5784 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js ***!
5785 \*********************************************************************/
5786 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5787
5788 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
5789 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
5790 function _regeneratorAsyncGen(r, e, t, o, n) {
5791 return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
5792 }
5793 module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
5794
5795 /***/ }),
5796
5797 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js":
5798 /*!**************************************************************************!*\
5799 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js ***!
5800 \**************************************************************************/
5801 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5802
5803 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
5804 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
5805 function AsyncIterator(t, e) {
5806 function n(r, o, i, f) {
5807 try {
5808 var c = t[r](o),
5809 u = c.value;
5810 return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
5811 n("next", t, i, f);
5812 }, function (t) {
5813 n("throw", t, i, f);
5814 }) : e.resolve(u).then(function (t) {
5815 c.value = t, i(c);
5816 }, function (t) {
5817 return n("throw", t, i, f);
5818 });
5819 } catch (t) {
5820 f(t);
5821 }
5822 }
5823 var r;
5824 this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
5825 return this;
5826 })), regeneratorDefine(this, "_invoke", function (t, o, i) {
5827 function f() {
5828 return new e(function (e, r) {
5829 n(t, i, e, r);
5830 });
5831 }
5832 return r = r ? r.then(f, f) : f();
5833 }, !0);
5834 }
5835 module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5836
5837 /***/ }),
5838
5839 /***/ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js":
5840 /*!*******************************************************************!*\
5841 !*** ../node_modules/@babel/runtime/helpers/regeneratorDefine.js ***!
5842 \*******************************************************************/
5843 /***/ ((module) => {
5844
5845 function _regeneratorDefine(e, r, n, t) {
5846 var i = Object.defineProperty;
5847 try {
5848 i({}, "", {});
5849 } catch (e) {
5850 i = 0;
5851 }
5852 module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
5853 function o(r, n) {
5854 _regeneratorDefine(e, r, function (e) {
5855 return this._invoke(r, n, e);
5856 });
5857 }
5858 r ? i ? i(e, r, {
5859 value: n,
5860 enumerable: !t,
5861 configurable: !t,
5862 writable: !t
5863 }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
5864 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
5865 }
5866 module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
5867
5868 /***/ }),
5869
5870 /***/ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js":
5871 /*!*****************************************************************!*\
5872 !*** ../node_modules/@babel/runtime/helpers/regeneratorKeys.js ***!
5873 \*****************************************************************/
5874 /***/ ((module) => {
5875
5876 function _regeneratorKeys(e) {
5877 var n = Object(e),
5878 r = [];
5879 for (var t in n) r.unshift(t);
5880 return function e() {
5881 for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
5882 return e.done = !0, e;
5883 };
5884 }
5885 module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
5886
5887 /***/ }),
5888
5889 /***/ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js":
5890 /*!********************************************************************!*\
5891 !*** ../node_modules/@babel/runtime/helpers/regeneratorRuntime.js ***!
5892 \********************************************************************/
5893 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5894
5895 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
5896 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
5897 var regeneratorAsync = __webpack_require__(/*! ./regeneratorAsync.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js");
5898 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
5899 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
5900 var regeneratorKeys = __webpack_require__(/*! ./regeneratorKeys.js */ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js");
5901 var regeneratorValues = __webpack_require__(/*! ./regeneratorValues.js */ "../node_modules/@babel/runtime/helpers/regeneratorValues.js");
5902 function _regeneratorRuntime() {
5903 "use strict";
5904
5905 var r = regenerator(),
5906 e = r.m(_regeneratorRuntime),
5907 t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
5908 function n(r) {
5909 var e = "function" == typeof r && r.constructor;
5910 return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
5911 }
5912 var o = {
5913 "throw": 1,
5914 "return": 2,
5915 "break": 3,
5916 "continue": 3
5917 };
5918 function a(r) {
5919 var e, t;
5920 return function (n) {
5921 e || (e = {
5922 stop: function stop() {
5923 return t(n.a, 2);
5924 },
5925 "catch": function _catch() {
5926 return n.v;
5927 },
5928 abrupt: function abrupt(r, e) {
5929 return t(n.a, o[r], e);
5930 },
5931 delegateYield: function delegateYield(r, o, a) {
5932 return e.resultName = o, t(n.d, regeneratorValues(r), a);
5933 },
5934 finish: function finish(r) {
5935 return t(n.f, r);
5936 }
5937 }, t = function t(r, _t, o) {
5938 n.p = e.prev, n.n = e.next;
5939 try {
5940 return r(_t, o);
5941 } finally {
5942 e.next = n.n;
5943 }
5944 }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
5945 try {
5946 return r.call(this, e);
5947 } finally {
5948 n.p = e.prev, n.n = e.next;
5949 }
5950 };
5951 }
5952 return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
5953 return {
5954 wrap: function wrap(e, t, n, o) {
5955 return r.w(a(e), t, n, o && o.reverse());
5956 },
5957 isGeneratorFunction: n,
5958 mark: r.m,
5959 awrap: function awrap(r, e) {
5960 return new OverloadYield(r, e);
5961 },
5962 AsyncIterator: regeneratorAsyncIterator,
5963 async: function async(r, e, t, o, u) {
5964 return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
5965 },
5966 keys: regeneratorKeys,
5967 values: regeneratorValues
5968 };
5969 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5970 }
5971 module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
5972
5973 /***/ }),
5974
5975 /***/ "../node_modules/@babel/runtime/helpers/regeneratorValues.js":
5976 /*!*******************************************************************!*\
5977 !*** ../node_modules/@babel/runtime/helpers/regeneratorValues.js ***!
5978 \*******************************************************************/
5979 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5980
5981 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5982 function _regeneratorValues(e) {
5983 if (null != e) {
5984 var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
5985 r = 0;
5986 if (t) return t.call(e);
5987 if ("function" == typeof e.next) return e;
5988 if (!isNaN(e.length)) return {
5989 next: function next() {
5990 return e && r >= e.length && (e = void 0), {
5991 value: e && e[r++],
5992 done: !e
5993 };
5994 }
5995 };
5996 }
5997 throw new TypeError(_typeof(e) + " is not iterable");
5998 }
5999 module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
6000
6001 /***/ }),
6002
6003 /***/ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js":
6004 /*!****************************************************************!*\
6005 !*** ../node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
6006 \****************************************************************/
6007 /***/ ((module) => {
6008
6009 function _setPrototypeOf(t, e) {
6010 return module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
6011 return t.__proto__ = e, t;
6012 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _setPrototypeOf(t, e);
6013 }
6014 module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6015
6016 /***/ }),
6017
6018 /***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js":
6019 /*!***************************************************************!*\
6020 !*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***!
6021 \***************************************************************/
6022 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6023
6024 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js");
6025 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
6026 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
6027 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "../node_modules/@babel/runtime/helpers/nonIterableRest.js");
6028 function _slicedToArray(r, e) {
6029 return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();
6030 }
6031 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6032
6033 /***/ }),
6034
6035 /***/ "../node_modules/@babel/runtime/helpers/superPropBase.js":
6036 /*!***************************************************************!*\
6037 !*** ../node_modules/@babel/runtime/helpers/superPropBase.js ***!
6038 \***************************************************************/
6039 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6040
6041 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6042 function _superPropBase(t, o) {
6043 for (; !{}.hasOwnProperty.call(t, o) && null !== (t = getPrototypeOf(t)););
6044 return t;
6045 }
6046 module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
6047
6048 /***/ }),
6049
6050 /***/ "../node_modules/@babel/runtime/helpers/toPrimitive.js":
6051 /*!*************************************************************!*\
6052 !*** ../node_modules/@babel/runtime/helpers/toPrimitive.js ***!
6053 \*************************************************************/
6054 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6055
6056 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6057 function toPrimitive(t, r) {
6058 if ("object" != _typeof(t) || !t) return t;
6059 var e = t[Symbol.toPrimitive];
6060 if (void 0 !== e) {
6061 var i = e.call(t, r || "default");
6062 if ("object" != _typeof(i)) return i;
6063 throw new TypeError("@@toPrimitive must return a primitive value.");
6064 }
6065 return ("string" === r ? String : Number)(t);
6066 }
6067 module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
6068
6069 /***/ }),
6070
6071 /***/ "../node_modules/@babel/runtime/helpers/toPropertyKey.js":
6072 /*!***************************************************************!*\
6073 !*** ../node_modules/@babel/runtime/helpers/toPropertyKey.js ***!
6074 \***************************************************************/
6075 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6076
6077 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6078 var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/toPrimitive.js");
6079 function toPropertyKey(t) {
6080 var i = toPrimitive(t, "string");
6081 return "symbol" == _typeof(i) ? i : i + "";
6082 }
6083 module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
6084
6085 /***/ }),
6086
6087 /***/ "../node_modules/@babel/runtime/helpers/typeof.js":
6088 /*!********************************************************!*\
6089 !*** ../node_modules/@babel/runtime/helpers/typeof.js ***!
6090 \********************************************************/
6091 /***/ ((module) => {
6092
6093 function _typeof(o) {
6094 "@babel/helpers - typeof";
6095
6096 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
6097 return typeof o;
6098 } : function (o) {
6099 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
6100 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
6101 }
6102 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
6103
6104 /***/ }),
6105
6106 /***/ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
6107 /*!****************************************************************************!*\
6108 !*** ../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
6109 \****************************************************************************/
6110 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6111
6112 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
6113 function _unsupportedIterableToArray(r, a) {
6114 if (r) {
6115 if ("string" == typeof r) return arrayLikeToArray(r, a);
6116 var t = {}.toString.call(r).slice(8, -1);
6117 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;
6118 }
6119 }
6120 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6121
6122 /***/ }),
6123
6124 /***/ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js":
6125 /*!*****************************************************************!*\
6126 !*** ../node_modules/@babel/runtime/helpers/wrapNativeSuper.js ***!
6127 \*****************************************************************/
6128 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6129
6130 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6131 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6132 var isNativeFunction = __webpack_require__(/*! ./isNativeFunction.js */ "../node_modules/@babel/runtime/helpers/isNativeFunction.js");
6133 var construct = __webpack_require__(/*! ./construct.js */ "../node_modules/@babel/runtime/helpers/construct.js");
6134 function _wrapNativeSuper(t) {
6135 var r = "function" == typeof Map ? new Map() : void 0;
6136 return module.exports = _wrapNativeSuper = function _wrapNativeSuper(t) {
6137 if (null === t || !isNativeFunction(t)) return t;
6138 if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
6139 if (void 0 !== r) {
6140 if (r.has(t)) return r.get(t);
6141 r.set(t, Wrapper);
6142 }
6143 function Wrapper() {
6144 return construct(t, arguments, getPrototypeOf(this).constructor);
6145 }
6146 return Wrapper.prototype = Object.create(t.prototype, {
6147 constructor: {
6148 value: Wrapper,
6149 enumerable: !1,
6150 writable: !0,
6151 configurable: !0
6152 }
6153 }), setPrototypeOf(Wrapper, t);
6154 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _wrapNativeSuper(t);
6155 }
6156 module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
6157
6158 /***/ }),
6159
6160 /***/ "../node_modules/@babel/runtime/regenerator/index.js":
6161 /*!***********************************************************!*\
6162 !*** ../node_modules/@babel/runtime/regenerator/index.js ***!
6163 \***********************************************************/
6164 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6165
6166 // TODO(Babel 8): Remove this file.
6167
6168 var runtime = __webpack_require__(/*! ../helpers/regeneratorRuntime */ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js")();
6169 module.exports = runtime;
6170
6171 // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
6172 try {
6173 regeneratorRuntime = runtime;
6174 } catch (accidentalStrictMode) {
6175 if (typeof globalThis === "object") {
6176 globalThis.regeneratorRuntime = runtime;
6177 } else {
6178 Function("r", "regeneratorRuntime = r")(runtime);
6179 }
6180 }
6181
6182
6183 /***/ }),
6184
6185 /***/ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js":
6186 /*!******************************************************************!*\
6187 !*** ../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js ***!
6188 \******************************************************************/
6189 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6190
6191 "use strict";
6192 __webpack_require__.r(__webpack_exports__);
6193 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6194 /* harmony export */ EnhancerArray: () => (/* binding */ EnhancerArray),
6195 /* harmony export */ MiddlewareArray: () => (/* binding */ MiddlewareArray),
6196 /* harmony export */ SHOULD_AUTOBATCH: () => (/* binding */ SHOULD_AUTOBATCH),
6197 /* harmony export */ TaskAbortError: () => (/* binding */ TaskAbortError),
6198 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.__DO_NOT_USE__ActionTypes),
6199 /* harmony export */ addListener: () => (/* binding */ addListener),
6200 /* harmony export */ applyMiddleware: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware),
6201 /* harmony export */ autoBatchEnhancer: () => (/* binding */ autoBatchEnhancer),
6202 /* harmony export */ bindActionCreators: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.bindActionCreators),
6203 /* harmony export */ clearAllListeners: () => (/* binding */ clearAllListeners),
6204 /* harmony export */ combineReducers: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers),
6205 /* harmony export */ compose: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.compose),
6206 /* harmony export */ configureStore: () => (/* binding */ configureStore),
6207 /* harmony export */ createAction: () => (/* binding */ createAction),
6208 /* harmony export */ createActionCreatorInvariantMiddleware: () => (/* binding */ createActionCreatorInvariantMiddleware),
6209 /* harmony export */ createAsyncThunk: () => (/* binding */ createAsyncThunk),
6210 /* harmony export */ createDraftSafeSelector: () => (/* binding */ createDraftSafeSelector),
6211 /* harmony export */ createEntityAdapter: () => (/* binding */ createEntityAdapter),
6212 /* harmony export */ createImmutableStateInvariantMiddleware: () => (/* binding */ createImmutableStateInvariantMiddleware),
6213 /* harmony export */ createListenerMiddleware: () => (/* binding */ createListenerMiddleware),
6214 /* harmony export */ createNextState: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__["default"]),
6215 /* harmony export */ createReducer: () => (/* binding */ createReducer),
6216 /* harmony export */ createSelector: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector),
6217 /* harmony export */ createSerializableStateInvariantMiddleware: () => (/* binding */ createSerializableStateInvariantMiddleware),
6218 /* harmony export */ createSlice: () => (/* binding */ createSlice),
6219 /* harmony export */ createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.createStore),
6220 /* harmony export */ current: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.current),
6221 /* harmony export */ findNonSerializableValue: () => (/* binding */ findNonSerializableValue),
6222 /* harmony export */ freeze: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.freeze),
6223 /* harmony export */ getDefaultMiddleware: () => (/* binding */ getDefaultMiddleware),
6224 /* harmony export */ getType: () => (/* binding */ getType),
6225 /* harmony export */ isAction: () => (/* binding */ isAction),
6226 /* harmony export */ isActionCreator: () => (/* binding */ isActionCreator),
6227 /* harmony export */ isAllOf: () => (/* binding */ isAllOf),
6228 /* harmony export */ isAnyOf: () => (/* binding */ isAnyOf),
6229 /* harmony export */ isAsyncThunkAction: () => (/* binding */ isAsyncThunkAction),
6230 /* harmony export */ isDraft: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.isDraft),
6231 /* harmony export */ isFluxStandardAction: () => (/* binding */ isFSA),
6232 /* harmony export */ isFulfilled: () => (/* binding */ isFulfilled),
6233 /* harmony export */ isImmutableDefault: () => (/* binding */ isImmutableDefault),
6234 /* harmony export */ isPending: () => (/* binding */ isPending),
6235 /* harmony export */ isPlain: () => (/* binding */ isPlain),
6236 /* harmony export */ isPlainObject: () => (/* binding */ isPlainObject),
6237 /* harmony export */ isRejected: () => (/* binding */ isRejected),
6238 /* harmony export */ isRejectedWithValue: () => (/* binding */ isRejectedWithValue),
6239 /* harmony export */ legacy_createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.legacy_createStore),
6240 /* harmony export */ miniSerializeError: () => (/* binding */ miniSerializeError),
6241 /* harmony export */ nanoid: () => (/* binding */ nanoid),
6242 /* harmony export */ original: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.original),
6243 /* harmony export */ prepareAutoBatched: () => (/* binding */ prepareAutoBatched),
6244 /* harmony export */ removeListener: () => (/* binding */ removeListener),
6245 /* harmony export */ unwrapResult: () => (/* binding */ unwrapResult)
6246 /* harmony export */ });
6247 /* harmony import */ var immer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! immer */ "../node_modules/immer/dist/immer.esm.mjs");
6248 /* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! redux */ "../node_modules/redux/es/redux.js");
6249 /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! reselect */ "../node_modules/reselect/es/index.js");
6250 /* harmony import */ var redux_thunk__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! redux-thunk */ "../node_modules/redux-thunk/es/index.js");
6251 var __extends = (undefined && undefined.__extends) || (function () {
6252 var extendStatics = function (d, b) {
6253 extendStatics = Object.setPrototypeOf ||
6254 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6255 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6256 return extendStatics(d, b);
6257 };
6258 return function (d, b) {
6259 if (typeof b !== "function" && b !== null)
6260 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
6261 extendStatics(d, b);
6262 function __() { this.constructor = d; }
6263 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6264 };
6265 })();
6266 var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
6267 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6268 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6269 function verb(n) { return function (v) { return step([n, v]); }; }
6270 function step(op) {
6271 if (f) throw new TypeError("Generator is already executing.");
6272 while (_) try {
6273 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;
6274 if (y = 0, t) op = [op[0] & 2, t.value];
6275 switch (op[0]) {
6276 case 0: case 1: t = op; break;
6277 case 4: _.label++; return { value: op[1], done: false };
6278 case 5: _.label++; y = op[1]; op = [0]; continue;
6279 case 7: op = _.ops.pop(); _.trys.pop(); continue;
6280 default:
6281 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6282 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6283 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6284 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6285 if (t[2]) _.ops.pop();
6286 _.trys.pop(); continue;
6287 }
6288 op = body.call(thisArg, _);
6289 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6290 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6291 }
6292 };
6293 var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
6294 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
6295 to[j] = from[i];
6296 return to;
6297 };
6298 var __defProp = Object.defineProperty;
6299 var __defProps = Object.defineProperties;
6300 var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6301 var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6302 var __hasOwnProp = Object.prototype.hasOwnProperty;
6303 var __propIsEnum = Object.prototype.propertyIsEnumerable;
6304 var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
6305 var __spreadValues = function (a, b) {
6306 for (var prop in b || (b = {}))
6307 if (__hasOwnProp.call(b, prop))
6308 __defNormalProp(a, prop, b[prop]);
6309 if (__getOwnPropSymbols)
6310 for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
6311 var prop = _c[_i];
6312 if (__propIsEnum.call(b, prop))
6313 __defNormalProp(a, prop, b[prop]);
6314 }
6315 return a;
6316 };
6317 var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
6318 var __async = function (__this, __arguments, generator) {
6319 return new Promise(function (resolve, reject) {
6320 var fulfilled = function (value) {
6321 try {
6322 step(generator.next(value));
6323 }
6324 catch (e) {
6325 reject(e);
6326 }
6327 };
6328 var rejected = function (value) {
6329 try {
6330 step(generator.throw(value));
6331 }
6332 catch (e) {
6333 reject(e);
6334 }
6335 };
6336 var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
6337 step((generator = generator.apply(__this, __arguments)).next());
6338 });
6339 };
6340 // src/index.ts
6341
6342
6343
6344
6345 // src/createDraftSafeSelector.ts
6346
6347
6348 var createDraftSafeSelector = function () {
6349 var args = [];
6350 for (var _i = 0; _i < arguments.length; _i++) {
6351 args[_i] = arguments[_i];
6352 }
6353 var selector = reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector.apply(void 0, args);
6354 var wrappedSelector = function (value) {
6355 var rest = [];
6356 for (var _i = 1; _i < arguments.length; _i++) {
6357 rest[_i - 1] = arguments[_i];
6358 }
6359 return selector.apply(void 0, __spreadArray([(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(value) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__.current)(value) : value], rest));
6360 };
6361 return wrappedSelector;
6362 };
6363 // src/configureStore.ts
6364
6365 // src/devtoolsExtension.ts
6366
6367 var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
6368 if (arguments.length === 0)
6369 return void 0;
6370 if (typeof arguments[0] === "object")
6371 return redux__WEBPACK_IMPORTED_MODULE_1__.compose;
6372 return redux__WEBPACK_IMPORTED_MODULE_1__.compose.apply(null, arguments);
6373 };
6374 var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function () {
6375 return function (noop2) {
6376 return noop2;
6377 };
6378 };
6379 // src/isPlainObject.ts
6380 function isPlainObject(value) {
6381 if (typeof value !== "object" || value === null)
6382 return false;
6383 var proto = Object.getPrototypeOf(value);
6384 if (proto === null)
6385 return true;
6386 var baseProto = proto;
6387 while (Object.getPrototypeOf(baseProto) !== null) {
6388 baseProto = Object.getPrototypeOf(baseProto);
6389 }
6390 return proto === baseProto;
6391 }
6392 // src/getDefaultMiddleware.ts
6393
6394 // src/tsHelpers.ts
6395 var hasMatchFunction = function (v) {
6396 return v && typeof v.match === "function";
6397 };
6398 // src/createAction.ts
6399 function createAction(type, prepareAction) {
6400 function actionCreator() {
6401 var args = [];
6402 for (var _i = 0; _i < arguments.length; _i++) {
6403 args[_i] = arguments[_i];
6404 }
6405 if (prepareAction) {
6406 var prepared = prepareAction.apply(void 0, args);
6407 if (!prepared) {
6408 throw new Error("prepareAction did not return an object");
6409 }
6410 return __spreadValues(__spreadValues({
6411 type: type,
6412 payload: prepared.payload
6413 }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
6414 }
6415 return { type: type, payload: args[0] };
6416 }
6417 actionCreator.toString = function () { return "" + type; };
6418 actionCreator.type = type;
6419 actionCreator.match = function (action) { return action.type === type; };
6420 return actionCreator;
6421 }
6422 function isAction(action) {
6423 return isPlainObject(action) && "type" in action;
6424 }
6425 function isActionCreator(action) {
6426 return typeof action === "function" && "type" in action && hasMatchFunction(action);
6427 }
6428 function isFSA(action) {
6429 return isAction(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
6430 }
6431 function isValidKey(key) {
6432 return ["type", "payload", "error", "meta"].indexOf(key) > -1;
6433 }
6434 function getType(actionCreator) {
6435 return "" + actionCreator;
6436 }
6437 // src/actionCreatorInvariantMiddleware.ts
6438 function getMessage(type) {
6439 var splitType = type ? ("" + type).split("/") : [];
6440 var actionName = splitType[splitType.length - 1] || "actionCreator";
6441 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.";
6442 }
6443 function createActionCreatorInvariantMiddleware(options) {
6444 if (options === void 0) { options = {}; }
6445 if (false) // removed by dead control flow
6446 {}
6447 var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
6448 return function () { return function (next) { return function (action) {
6449 if (isActionCreator2(action)) {
6450 console.warn(getMessage(action.type));
6451 }
6452 return next(action);
6453 }; }; };
6454 }
6455 // src/utils.ts
6456
6457 function getTimeMeasureUtils(maxDelay, fnName) {
6458 var elapsed = 0;
6459 return {
6460 measureTime: function (fn) {
6461 var started = Date.now();
6462 try {
6463 return fn();
6464 }
6465 finally {
6466 var finished = Date.now();
6467 elapsed += finished - started;
6468 }
6469 },
6470 warnIfExceeded: function () {
6471 if (elapsed > maxDelay) {
6472 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.");
6473 }
6474 }
6475 };
6476 }
6477 var MiddlewareArray = /** @class */ (function (_super) {
6478 __extends(MiddlewareArray, _super);
6479 function MiddlewareArray() {
6480 var args = [];
6481 for (var _i = 0; _i < arguments.length; _i++) {
6482 args[_i] = arguments[_i];
6483 }
6484 var _this = _super.apply(this, args) || this;
6485 Object.setPrototypeOf(_this, MiddlewareArray.prototype);
6486 return _this;
6487 }
6488 Object.defineProperty(MiddlewareArray, Symbol.species, {
6489 get: function () {
6490 return MiddlewareArray;
6491 },
6492 enumerable: false,
6493 configurable: true
6494 });
6495 MiddlewareArray.prototype.concat = function () {
6496 var arr = [];
6497 for (var _i = 0; _i < arguments.length; _i++) {
6498 arr[_i] = arguments[_i];
6499 }
6500 return _super.prototype.concat.apply(this, arr);
6501 };
6502 MiddlewareArray.prototype.prepend = function () {
6503 var arr = [];
6504 for (var _i = 0; _i < arguments.length; _i++) {
6505 arr[_i] = arguments[_i];
6506 }
6507 if (arr.length === 1 && Array.isArray(arr[0])) {
6508 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
6509 }
6510 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
6511 };
6512 return MiddlewareArray;
6513 }(Array));
6514 var EnhancerArray = /** @class */ (function (_super) {
6515 __extends(EnhancerArray, _super);
6516 function EnhancerArray() {
6517 var args = [];
6518 for (var _i = 0; _i < arguments.length; _i++) {
6519 args[_i] = arguments[_i];
6520 }
6521 var _this = _super.apply(this, args) || this;
6522 Object.setPrototypeOf(_this, EnhancerArray.prototype);
6523 return _this;
6524 }
6525 Object.defineProperty(EnhancerArray, Symbol.species, {
6526 get: function () {
6527 return EnhancerArray;
6528 },
6529 enumerable: false,
6530 configurable: true
6531 });
6532 EnhancerArray.prototype.concat = function () {
6533 var arr = [];
6534 for (var _i = 0; _i < arguments.length; _i++) {
6535 arr[_i] = arguments[_i];
6536 }
6537 return _super.prototype.concat.apply(this, arr);
6538 };
6539 EnhancerArray.prototype.prepend = function () {
6540 var arr = [];
6541 for (var _i = 0; _i < arguments.length; _i++) {
6542 arr[_i] = arguments[_i];
6543 }
6544 if (arr.length === 1 && Array.isArray(arr[0])) {
6545 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
6546 }
6547 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
6548 };
6549 return EnhancerArray;
6550 }(Array));
6551 function freezeDraftable(val) {
6552 return (0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(val) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(val, function () {
6553 }) : val;
6554 }
6555 // src/immutableStateInvariantMiddleware.ts
6556 var isProduction = "development" === "production";
6557 var prefix = "Invariant failed";
6558 function invariant(condition, message) {
6559 if (condition) {
6560 return;
6561 }
6562 if (isProduction) {
6563 throw new Error(prefix);
6564 }
6565 throw new Error(prefix + ": " + (message || ""));
6566 }
6567 function stringify(obj, serializer, indent, decycler) {
6568 return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
6569 }
6570 function getSerialize(serializer, decycler) {
6571 var stack = [], keys = [];
6572 if (!decycler)
6573 decycler = function (_, value) {
6574 if (stack[0] === value)
6575 return "[Circular ~]";
6576 return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
6577 };
6578 return function (key, value) {
6579 if (stack.length > 0) {
6580 var thisPos = stack.indexOf(this);
6581 ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
6582 ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
6583 if (~stack.indexOf(value))
6584 value = decycler.call(this, key, value);
6585 }
6586 else
6587 stack.push(value);
6588 return serializer == null ? value : serializer.call(this, key, value);
6589 };
6590 }
6591 function isImmutableDefault(value) {
6592 return typeof value !== "object" || value == null || Object.isFrozen(value);
6593 }
6594 function trackForMutations(isImmutable, ignorePaths, obj) {
6595 var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
6596 return {
6597 detectMutations: function () {
6598 return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
6599 }
6600 };
6601 }
6602 function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
6603 if (ignorePaths === void 0) { ignorePaths = []; }
6604 if (path === void 0) { path = ""; }
6605 if (checkedObjects === void 0) { checkedObjects = new Set(); }
6606 var tracked = { value: obj };
6607 if (!isImmutable(obj) && !checkedObjects.has(obj)) {
6608 checkedObjects.add(obj);
6609 tracked.children = {};
6610 for (var key in obj) {
6611 var childPath = path ? path + "." + key : key;
6612 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
6613 continue;
6614 }
6615 tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
6616 }
6617 }
6618 return tracked;
6619 }
6620 function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
6621 if (ignoredPaths === void 0) { ignoredPaths = []; }
6622 if (sameParentRef === void 0) { sameParentRef = false; }
6623 if (path === void 0) { path = ""; }
6624 var prevObj = trackedProperty ? trackedProperty.value : void 0;
6625 var sameRef = prevObj === obj;
6626 if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
6627 return { wasMutated: true, path: path };
6628 }
6629 if (isImmutable(prevObj) || isImmutable(obj)) {
6630 return { wasMutated: false };
6631 }
6632 var keysToDetect = {};
6633 for (var key in trackedProperty.children) {
6634 keysToDetect[key] = true;
6635 }
6636 for (var key in obj) {
6637 keysToDetect[key] = true;
6638 }
6639 var hasIgnoredPaths = ignoredPaths.length > 0;
6640 var _loop_1 = function (key) {
6641 var nestedPath = path ? path + "." + key : key;
6642 if (hasIgnoredPaths) {
6643 var hasMatches = ignoredPaths.some(function (ignored) {
6644 if (ignored instanceof RegExp) {
6645 return ignored.test(nestedPath);
6646 }
6647 return nestedPath === ignored;
6648 });
6649 if (hasMatches) {
6650 return "continue";
6651 }
6652 }
6653 var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
6654 if (result.wasMutated) {
6655 return { value: result };
6656 }
6657 };
6658 for (var key in keysToDetect) {
6659 var state_1 = _loop_1(key);
6660 if (typeof state_1 === "object")
6661 return state_1.value;
6662 }
6663 return { wasMutated: false };
6664 }
6665 function createImmutableStateInvariantMiddleware(options) {
6666 if (options === void 0) { options = {}; }
6667 if (false) // removed by dead control flow
6668 {}
6669 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;
6670 ignoredPaths = ignoredPaths || ignore;
6671 var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
6672 return function (_c) {
6673 var getState = _c.getState;
6674 var state = getState();
6675 var tracker = track(state);
6676 var result;
6677 return function (next) { return function (action) {
6678 var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
6679 measureUtils.measureTime(function () {
6680 state = getState();
6681 result = tracker.detectMutations();
6682 tracker = track(state);
6683 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)");
6684 });
6685 var dispatchedAction = next(action);
6686 measureUtils.measureTime(function () {
6687 state = getState();
6688 result = tracker.detectMutations();
6689 tracker = track(state);
6690 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)");
6691 });
6692 measureUtils.warnIfExceeded();
6693 return dispatchedAction;
6694 }; };
6695 };
6696 }
6697 // src/serializableStateInvariantMiddleware.ts
6698 function isPlain(val) {
6699 var type = typeof val;
6700 return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
6701 }
6702 function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
6703 if (path === void 0) { path = ""; }
6704 if (isSerializable === void 0) { isSerializable = isPlain; }
6705 if (ignoredPaths === void 0) { ignoredPaths = []; }
6706 var foundNestedSerializable;
6707 if (!isSerializable(value)) {
6708 return {
6709 keyPath: path || "<root>",
6710 value: value
6711 };
6712 }
6713 if (typeof value !== "object" || value === null) {
6714 return false;
6715 }
6716 if (cache == null ? void 0 : cache.has(value))
6717 return false;
6718 var entries = getEntries != null ? getEntries(value) : Object.entries(value);
6719 var hasIgnoredPaths = ignoredPaths.length > 0;
6720 var _loop_2 = function (key, nestedValue) {
6721 var nestedPath = path ? path + "." + key : key;
6722 if (hasIgnoredPaths) {
6723 var hasMatches = ignoredPaths.some(function (ignored) {
6724 if (ignored instanceof RegExp) {
6725 return ignored.test(nestedPath);
6726 }
6727 return nestedPath === ignored;
6728 });
6729 if (hasMatches) {
6730 return "continue";
6731 }
6732 }
6733 if (!isSerializable(nestedValue)) {
6734 return { value: {
6735 keyPath: nestedPath,
6736 value: nestedValue
6737 } };
6738 }
6739 if (typeof nestedValue === "object") {
6740 foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
6741 if (foundNestedSerializable) {
6742 return { value: foundNestedSerializable };
6743 }
6744 }
6745 };
6746 for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
6747 var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
6748 var state_2 = _loop_2(key, nestedValue);
6749 if (typeof state_2 === "object")
6750 return state_2.value;
6751 }
6752 if (cache && isNestedFrozen(value))
6753 cache.add(value);
6754 return false;
6755 }
6756 function isNestedFrozen(value) {
6757 if (!Object.isFrozen(value))
6758 return false;
6759 for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
6760 var nestedValue = _c[_i];
6761 if (typeof nestedValue !== "object" || nestedValue === null)
6762 continue;
6763 if (!isNestedFrozen(nestedValue))
6764 return false;
6765 }
6766 return true;
6767 }
6768 function createSerializableStateInvariantMiddleware(options) {
6769 if (options === void 0) { options = {}; }
6770 if (false) // removed by dead control flow
6771 {}
6772 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;
6773 var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
6774 return function (storeAPI) { return function (next) { return function (action) {
6775 var result = next(action);
6776 var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
6777 if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
6778 measureUtils.measureTime(function () {
6779 var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
6780 if (foundActionNonSerializableValue) {
6781 var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
6782 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)");
6783 }
6784 });
6785 }
6786 if (!ignoreState) {
6787 measureUtils.measureTime(function () {
6788 var state = storeAPI.getState();
6789 var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
6790 if (foundStateNonSerializableValue) {
6791 var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
6792 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)");
6793 }
6794 });
6795 measureUtils.warnIfExceeded();
6796 }
6797 return result;
6798 }; }; };
6799 }
6800 // src/getDefaultMiddleware.ts
6801 function isBoolean(x) {
6802 return typeof x === "boolean";
6803 }
6804 function curryGetDefaultMiddleware() {
6805 return function curriedGetDefaultMiddleware(options) {
6806 return getDefaultMiddleware(options);
6807 };
6808 }
6809 function getDefaultMiddleware(options) {
6810 if (options === void 0) { options = {}; }
6811 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;
6812 var middlewareArray = new MiddlewareArray();
6813 if (thunk) {
6814 if (isBoolean(thunk)) {
6815 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"]);
6816 }
6817 else {
6818 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"].withExtraArgument(thunk.extraArgument));
6819 }
6820 }
6821 if (true) {
6822 if (immutableCheck) {
6823 var immutableOptions = {};
6824 if (!isBoolean(immutableCheck)) {
6825 immutableOptions = immutableCheck;
6826 }
6827 middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
6828 }
6829 if (serializableCheck) {
6830 var serializableOptions = {};
6831 if (!isBoolean(serializableCheck)) {
6832 serializableOptions = serializableCheck;
6833 }
6834 middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
6835 }
6836 if (actionCreatorCheck) {
6837 var actionCreatorOptions = {};
6838 if (!isBoolean(actionCreatorCheck)) {
6839 actionCreatorOptions = actionCreatorCheck;
6840 }
6841 middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
6842 }
6843 }
6844 return middlewareArray;
6845 }
6846 // src/configureStore.ts
6847 var IS_PRODUCTION = "development" === "production";
6848 function configureStore(options) {
6849 var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
6850 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;
6851 var rootReducer;
6852 if (typeof reducer === "function") {
6853 rootReducer = reducer;
6854 }
6855 else if (isPlainObject(reducer)) {
6856 rootReducer = (0,redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers)(reducer);
6857 }
6858 else {
6859 throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
6860 }
6861 var finalMiddleware = middleware;
6862 if (typeof finalMiddleware === "function") {
6863 finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
6864 if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
6865 throw new Error("when using a middleware builder function, an array of middleware must be returned");
6866 }
6867 }
6868 if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
6869 throw new Error("each middleware provided to configureStore must be a function");
6870 }
6871 var middlewareEnhancer = redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware.apply(void 0, finalMiddleware);
6872 var finalCompose = redux__WEBPACK_IMPORTED_MODULE_1__.compose;
6873 if (devTools) {
6874 finalCompose = composeWithDevTools(__spreadValues({
6875 trace: !IS_PRODUCTION
6876 }, typeof devTools === "object" && devTools));
6877 }
6878 var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
6879 var storeEnhancers = defaultEnhancers;
6880 if (Array.isArray(enhancers)) {
6881 storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
6882 }
6883 else if (typeof enhancers === "function") {
6884 storeEnhancers = enhancers(defaultEnhancers);
6885 }
6886 var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
6887 return (0,redux__WEBPACK_IMPORTED_MODULE_1__.createStore)(rootReducer, preloadedState, composedEnhancer);
6888 }
6889 // src/createReducer.ts
6890
6891 // src/mapBuilders.ts
6892 function executeReducerBuilderCallback(builderCallback) {
6893 var actionsMap = {};
6894 var actionMatchers = [];
6895 var defaultCaseReducer;
6896 var builder = {
6897 addCase: function (typeOrActionCreator, reducer) {
6898 if (true) {
6899 if (actionMatchers.length > 0) {
6900 throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
6901 }
6902 if (defaultCaseReducer) {
6903 throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
6904 }
6905 }
6906 var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
6907 if (!type) {
6908 throw new Error("`builder.addCase` cannot be called with an empty action type");
6909 }
6910 if (type in actionsMap) {
6911 throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");
6912 }
6913 actionsMap[type] = reducer;
6914 return builder;
6915 },
6916 addMatcher: function (matcher, reducer) {
6917 if (true) {
6918 if (defaultCaseReducer) {
6919 throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
6920 }
6921 }
6922 actionMatchers.push({ matcher: matcher, reducer: reducer });
6923 return builder;
6924 },
6925 addDefaultCase: function (reducer) {
6926 if (true) {
6927 if (defaultCaseReducer) {
6928 throw new Error("`builder.addDefaultCase` can only be called once");
6929 }
6930 }
6931 defaultCaseReducer = reducer;
6932 return builder;
6933 }
6934 };
6935 builderCallback(builder);
6936 return [actionsMap, actionMatchers, defaultCaseReducer];
6937 }
6938 // src/createReducer.ts
6939 function isStateFunction(x) {
6940 return typeof x === "function";
6941 }
6942 var hasWarnedAboutObjectNotation = false;
6943 function createReducer(initialState, mapOrBuilderCallback, actionMatchers, defaultCaseReducer) {
6944 if (actionMatchers === void 0) { actionMatchers = []; }
6945 if (true) {
6946 if (typeof mapOrBuilderCallback === "object") {
6947 if (!hasWarnedAboutObjectNotation) {
6948 hasWarnedAboutObjectNotation = true;
6949 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");
6950 }
6951 }
6952 }
6953 var _c = typeof mapOrBuilderCallback === "function" ? executeReducerBuilderCallback(mapOrBuilderCallback) : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer], actionsMap = _c[0], finalActionMatchers = _c[1], finalDefaultCaseReducer = _c[2];
6954 var getInitialState;
6955 if (isStateFunction(initialState)) {
6956 getInitialState = function () { return freezeDraftable(initialState()); };
6957 }
6958 else {
6959 var frozenInitialState_1 = freezeDraftable(initialState);
6960 getInitialState = function () { return frozenInitialState_1; };
6961 }
6962 function reducer(state, action) {
6963 if (state === void 0) { state = getInitialState(); }
6964 var caseReducers = __spreadArray([
6965 actionsMap[action.type]
6966 ], finalActionMatchers.filter(function (_c) {
6967 var matcher = _c.matcher;
6968 return matcher(action);
6969 }).map(function (_c) {
6970 var reducer2 = _c.reducer;
6971 return reducer2;
6972 }));
6973 if (caseReducers.filter(function (cr) { return !!cr; }).length === 0) {
6974 caseReducers = [finalDefaultCaseReducer];
6975 }
6976 return caseReducers.reduce(function (previousState, caseReducer) {
6977 if (caseReducer) {
6978 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(previousState)) {
6979 var draft = previousState;
6980 var result = caseReducer(draft, action);
6981 if (result === void 0) {
6982 return previousState;
6983 }
6984 return result;
6985 }
6986 else if (!(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(previousState)) {
6987 var result = caseReducer(previousState, action);
6988 if (result === void 0) {
6989 if (previousState === null) {
6990 return previousState;
6991 }
6992 throw Error("A case reducer on a non-draftable value must not return undefined");
6993 }
6994 return result;
6995 }
6996 else {
6997 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(previousState, function (draft) {
6998 return caseReducer(draft, action);
6999 });
7000 }
7001 }
7002 return previousState;
7003 }, state);
7004 }
7005 reducer.getInitialState = getInitialState;
7006 return reducer;
7007 }
7008 // src/createSlice.ts
7009 var hasWarnedAboutObjectNotation2 = false;
7010 function getType2(slice, actionKey) {
7011 return slice + "/" + actionKey;
7012 }
7013 function createSlice(options) {
7014 var name = options.name;
7015 if (!name) {
7016 throw new Error("`name` is a required option for createSlice");
7017 }
7018 if (typeof process !== "undefined" && "development" === "development") {
7019 if (options.initialState === void 0) {
7020 console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
7021 }
7022 }
7023 var initialState = typeof options.initialState == "function" ? options.initialState : freezeDraftable(options.initialState);
7024 var reducers = options.reducers || {};
7025 var reducerNames = Object.keys(reducers);
7026 var sliceCaseReducersByName = {};
7027 var sliceCaseReducersByType = {};
7028 var actionCreators = {};
7029 reducerNames.forEach(function (reducerName) {
7030 var maybeReducerWithPrepare = reducers[reducerName];
7031 var type = getType2(name, reducerName);
7032 var caseReducer;
7033 var prepareCallback;
7034 if ("reducer" in maybeReducerWithPrepare) {
7035 caseReducer = maybeReducerWithPrepare.reducer;
7036 prepareCallback = maybeReducerWithPrepare.prepare;
7037 }
7038 else {
7039 caseReducer = maybeReducerWithPrepare;
7040 }
7041 sliceCaseReducersByName[reducerName] = caseReducer;
7042 sliceCaseReducersByType[type] = caseReducer;
7043 actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type);
7044 });
7045 function buildReducer() {
7046 if (true) {
7047 if (typeof options.extraReducers === "object") {
7048 if (!hasWarnedAboutObjectNotation2) {
7049 hasWarnedAboutObjectNotation2 = true;
7050 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");
7051 }
7052 }
7053 }
7054 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;
7055 var finalCaseReducers = __spreadValues(__spreadValues({}, extraReducers), sliceCaseReducersByType);
7056 return createReducer(initialState, function (builder) {
7057 for (var key in finalCaseReducers) {
7058 builder.addCase(key, finalCaseReducers[key]);
7059 }
7060 for (var _i = 0, actionMatchers_1 = actionMatchers; _i < actionMatchers_1.length; _i++) {
7061 var m = actionMatchers_1[_i];
7062 builder.addMatcher(m.matcher, m.reducer);
7063 }
7064 if (defaultCaseReducer) {
7065 builder.addDefaultCase(defaultCaseReducer);
7066 }
7067 });
7068 }
7069 var _reducer;
7070 return {
7071 name: name,
7072 reducer: function (state, action) {
7073 if (!_reducer)
7074 _reducer = buildReducer();
7075 return _reducer(state, action);
7076 },
7077 actions: actionCreators,
7078 caseReducers: sliceCaseReducersByName,
7079 getInitialState: function () {
7080 if (!_reducer)
7081 _reducer = buildReducer();
7082 return _reducer.getInitialState();
7083 }
7084 };
7085 }
7086 // src/entities/entity_state.ts
7087 function getInitialEntityState() {
7088 return {
7089 ids: [],
7090 entities: {}
7091 };
7092 }
7093 function createInitialStateFactory() {
7094 function getInitialState(additionalState) {
7095 if (additionalState === void 0) { additionalState = {}; }
7096 return Object.assign(getInitialEntityState(), additionalState);
7097 }
7098 return { getInitialState: getInitialState };
7099 }
7100 // src/entities/state_selectors.ts
7101 function createSelectorsFactory() {
7102 function getSelectors(selectState) {
7103 var selectIds = function (state) { return state.ids; };
7104 var selectEntities = function (state) { return state.entities; };
7105 var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) { return ids.map(function (id) { return entities[id]; }); });
7106 var selectId = function (_, id) { return id; };
7107 var selectById = function (entities, id) { return entities[id]; };
7108 var selectTotal = createDraftSafeSelector(selectIds, function (ids) { return ids.length; });
7109 if (!selectState) {
7110 return {
7111 selectIds: selectIds,
7112 selectEntities: selectEntities,
7113 selectAll: selectAll,
7114 selectTotal: selectTotal,
7115 selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
7116 };
7117 }
7118 var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
7119 return {
7120 selectIds: createDraftSafeSelector(selectState, selectIds),
7121 selectEntities: selectGlobalizedEntities,
7122 selectAll: createDraftSafeSelector(selectState, selectAll),
7123 selectTotal: createDraftSafeSelector(selectState, selectTotal),
7124 selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
7125 };
7126 }
7127 return { getSelectors: getSelectors };
7128 }
7129 // src/entities/state_adapter.ts
7130
7131 function createSingleArgumentStateOperator(mutator) {
7132 var operator = createStateOperator(function (_, state) { return mutator(state); });
7133 return function operation(state) {
7134 return operator(state, void 0);
7135 };
7136 }
7137 function createStateOperator(mutator) {
7138 return function operation(state, arg) {
7139 function isPayloadActionArgument(arg2) {
7140 return isFSA(arg2);
7141 }
7142 var runMutator = function (draft) {
7143 if (isPayloadActionArgument(arg)) {
7144 mutator(arg.payload, draft);
7145 }
7146 else {
7147 mutator(arg, draft);
7148 }
7149 };
7150 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(state)) {
7151 runMutator(state);
7152 return state;
7153 }
7154 else {
7155 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(state, runMutator);
7156 }
7157 };
7158 }
7159 // src/entities/utils.ts
7160 function selectIdValue(entity, selectId) {
7161 var key = selectId(entity);
7162 if ( true && key === void 0) {
7163 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());
7164 }
7165 return key;
7166 }
7167 function ensureEntitiesArray(entities) {
7168 if (!Array.isArray(entities)) {
7169 entities = Object.values(entities);
7170 }
7171 return entities;
7172 }
7173 function splitAddedUpdatedEntities(newEntities, selectId, state) {
7174 newEntities = ensureEntitiesArray(newEntities);
7175 var added = [];
7176 var updated = [];
7177 for (var _i = 0, newEntities_1 = newEntities; _i < newEntities_1.length; _i++) {
7178 var entity = newEntities_1[_i];
7179 var id = selectIdValue(entity, selectId);
7180 if (id in state.entities) {
7181 updated.push({ id: id, changes: entity });
7182 }
7183 else {
7184 added.push(entity);
7185 }
7186 }
7187 return [added, updated];
7188 }
7189 // src/entities/unsorted_state_adapter.ts
7190 function createUnsortedStateAdapter(selectId) {
7191 function addOneMutably(entity, state) {
7192 var key = selectIdValue(entity, selectId);
7193 if (key in state.entities) {
7194 return;
7195 }
7196 state.ids.push(key);
7197 state.entities[key] = entity;
7198 }
7199 function addManyMutably(newEntities, state) {
7200 newEntities = ensureEntitiesArray(newEntities);
7201 for (var _i = 0, newEntities_2 = newEntities; _i < newEntities_2.length; _i++) {
7202 var entity = newEntities_2[_i];
7203 addOneMutably(entity, state);
7204 }
7205 }
7206 function setOneMutably(entity, state) {
7207 var key = selectIdValue(entity, selectId);
7208 if (!(key in state.entities)) {
7209 state.ids.push(key);
7210 }
7211 state.entities[key] = entity;
7212 }
7213 function setManyMutably(newEntities, state) {
7214 newEntities = ensureEntitiesArray(newEntities);
7215 for (var _i = 0, newEntities_3 = newEntities; _i < newEntities_3.length; _i++) {
7216 var entity = newEntities_3[_i];
7217 setOneMutably(entity, state);
7218 }
7219 }
7220 function setAllMutably(newEntities, state) {
7221 newEntities = ensureEntitiesArray(newEntities);
7222 state.ids = [];
7223 state.entities = {};
7224 addManyMutably(newEntities, state);
7225 }
7226 function removeOneMutably(key, state) {
7227 return removeManyMutably([key], state);
7228 }
7229 function removeManyMutably(keys, state) {
7230 var didMutate = false;
7231 keys.forEach(function (key) {
7232 if (key in state.entities) {
7233 delete state.entities[key];
7234 didMutate = true;
7235 }
7236 });
7237 if (didMutate) {
7238 state.ids = state.ids.filter(function (id) { return id in state.entities; });
7239 }
7240 }
7241 function removeAllMutably(state) {
7242 Object.assign(state, {
7243 ids: [],
7244 entities: {}
7245 });
7246 }
7247 function takeNewKey(keys, update, state) {
7248 var original2 = state.entities[update.id];
7249 var updated = Object.assign({}, original2, update.changes);
7250 var newKey = selectIdValue(updated, selectId);
7251 var hasNewKey = newKey !== update.id;
7252 if (hasNewKey) {
7253 keys[update.id] = newKey;
7254 delete state.entities[update.id];
7255 }
7256 state.entities[newKey] = updated;
7257 return hasNewKey;
7258 }
7259 function updateOneMutably(update, state) {
7260 return updateManyMutably([update], state);
7261 }
7262 function updateManyMutably(updates, state) {
7263 var newKeys = {};
7264 var updatesPerEntity = {};
7265 updates.forEach(function (update) {
7266 if (update.id in state.entities) {
7267 updatesPerEntity[update.id] = {
7268 id: update.id,
7269 changes: __spreadValues(__spreadValues({}, updatesPerEntity[update.id] ? updatesPerEntity[update.id].changes : null), update.changes)
7270 };
7271 }
7272 });
7273 updates = Object.values(updatesPerEntity);
7274 var didMutateEntities = updates.length > 0;
7275 if (didMutateEntities) {
7276 var didMutateIds = updates.filter(function (update) { return takeNewKey(newKeys, update, state); }).length > 0;
7277 if (didMutateIds) {
7278 state.ids = Object.keys(state.entities);
7279 }
7280 }
7281 }
7282 function upsertOneMutably(entity, state) {
7283 return upsertManyMutably([entity], state);
7284 }
7285 function upsertManyMutably(newEntities, state) {
7286 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7287 updateManyMutably(updated, state);
7288 addManyMutably(added, state);
7289 }
7290 return {
7291 removeAll: createSingleArgumentStateOperator(removeAllMutably),
7292 addOne: createStateOperator(addOneMutably),
7293 addMany: createStateOperator(addManyMutably),
7294 setOne: createStateOperator(setOneMutably),
7295 setMany: createStateOperator(setManyMutably),
7296 setAll: createStateOperator(setAllMutably),
7297 updateOne: createStateOperator(updateOneMutably),
7298 updateMany: createStateOperator(updateManyMutably),
7299 upsertOne: createStateOperator(upsertOneMutably),
7300 upsertMany: createStateOperator(upsertManyMutably),
7301 removeOne: createStateOperator(removeOneMutably),
7302 removeMany: createStateOperator(removeManyMutably)
7303 };
7304 }
7305 // src/entities/sorted_state_adapter.ts
7306 function createSortedStateAdapter(selectId, sort) {
7307 var _c = createUnsortedStateAdapter(selectId), removeOne = _c.removeOne, removeMany = _c.removeMany, removeAll = _c.removeAll;
7308 function addOneMutably(entity, state) {
7309 return addManyMutably([entity], state);
7310 }
7311 function addManyMutably(newEntities, state) {
7312 newEntities = ensureEntitiesArray(newEntities);
7313 var models = newEntities.filter(function (model) { return !(selectIdValue(model, selectId) in state.entities); });
7314 if (models.length !== 0) {
7315 merge(models, state);
7316 }
7317 }
7318 function setOneMutably(entity, state) {
7319 return setManyMutably([entity], state);
7320 }
7321 function setManyMutably(newEntities, state) {
7322 newEntities = ensureEntitiesArray(newEntities);
7323 if (newEntities.length !== 0) {
7324 merge(newEntities, state);
7325 }
7326 }
7327 function setAllMutably(newEntities, state) {
7328 newEntities = ensureEntitiesArray(newEntities);
7329 state.entities = {};
7330 state.ids = [];
7331 addManyMutably(newEntities, state);
7332 }
7333 function updateOneMutably(update, state) {
7334 return updateManyMutably([update], state);
7335 }
7336 function updateManyMutably(updates, state) {
7337 var appliedUpdates = false;
7338 for (var _i = 0, updates_1 = updates; _i < updates_1.length; _i++) {
7339 var update = updates_1[_i];
7340 var entity = state.entities[update.id];
7341 if (!entity) {
7342 continue;
7343 }
7344 appliedUpdates = true;
7345 Object.assign(entity, update.changes);
7346 var newId = selectId(entity);
7347 if (update.id !== newId) {
7348 delete state.entities[update.id];
7349 state.entities[newId] = entity;
7350 }
7351 }
7352 if (appliedUpdates) {
7353 resortEntities(state);
7354 }
7355 }
7356 function upsertOneMutably(entity, state) {
7357 return upsertManyMutably([entity], state);
7358 }
7359 function upsertManyMutably(newEntities, state) {
7360 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7361 updateManyMutably(updated, state);
7362 addManyMutably(added, state);
7363 }
7364 function areArraysEqual(a, b) {
7365 if (a.length !== b.length) {
7366 return false;
7367 }
7368 for (var i = 0; i < a.length && i < b.length; i++) {
7369 if (a[i] === b[i]) {
7370 continue;
7371 }
7372 return false;
7373 }
7374 return true;
7375 }
7376 function merge(models, state) {
7377 models.forEach(function (model) {
7378 state.entities[selectId(model)] = model;
7379 });
7380 resortEntities(state);
7381 }
7382 function resortEntities(state) {
7383 var allEntities = Object.values(state.entities);
7384 allEntities.sort(sort);
7385 var newSortedIds = allEntities.map(selectId);
7386 var ids = state.ids;
7387 if (!areArraysEqual(ids, newSortedIds)) {
7388 state.ids = newSortedIds;
7389 }
7390 }
7391 return {
7392 removeOne: removeOne,
7393 removeMany: removeMany,
7394 removeAll: removeAll,
7395 addOne: createStateOperator(addOneMutably),
7396 updateOne: createStateOperator(updateOneMutably),
7397 upsertOne: createStateOperator(upsertOneMutably),
7398 setOne: createStateOperator(setOneMutably),
7399 setMany: createStateOperator(setManyMutably),
7400 setAll: createStateOperator(setAllMutably),
7401 addMany: createStateOperator(addManyMutably),
7402 updateMany: createStateOperator(updateManyMutably),
7403 upsertMany: createStateOperator(upsertManyMutably)
7404 };
7405 }
7406 // src/entities/create_adapter.ts
7407 function createEntityAdapter(options) {
7408 if (options === void 0) { options = {}; }
7409 var _c = __spreadValues({
7410 sortComparer: false,
7411 selectId: function (instance) { return instance.id; }
7412 }, options), selectId = _c.selectId, sortComparer = _c.sortComparer;
7413 var stateFactory = createInitialStateFactory();
7414 var selectorsFactory = createSelectorsFactory();
7415 var stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
7416 return __spreadValues(__spreadValues(__spreadValues({
7417 selectId: selectId,
7418 sortComparer: sortComparer
7419 }, stateFactory), selectorsFactory), stateAdapter);
7420 }
7421 // src/nanoid.ts
7422 var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
7423 var nanoid = function (size) {
7424 if (size === void 0) { size = 21; }
7425 var id = "";
7426 var i = size;
7427 while (i--) {
7428 id += urlAlphabet[Math.random() * 64 | 0];
7429 }
7430 return id;
7431 };
7432 // src/createAsyncThunk.ts
7433 var commonProperties = [
7434 "name",
7435 "message",
7436 "stack",
7437 "code"
7438 ];
7439 var RejectWithValue = /** @class */ (function () {
7440 function RejectWithValue(payload, meta) {
7441 this.payload = payload;
7442 this.meta = meta;
7443 }
7444 return RejectWithValue;
7445 }());
7446 var FulfillWithMeta = /** @class */ (function () {
7447 function FulfillWithMeta(payload, meta) {
7448 this.payload = payload;
7449 this.meta = meta;
7450 }
7451 return FulfillWithMeta;
7452 }());
7453 var miniSerializeError = function (value) {
7454 if (typeof value === "object" && value !== null) {
7455 var simpleError = {};
7456 for (var _i = 0, commonProperties_1 = commonProperties; _i < commonProperties_1.length; _i++) {
7457 var property = commonProperties_1[_i];
7458 if (typeof value[property] === "string") {
7459 simpleError[property] = value[property];
7460 }
7461 }
7462 return simpleError;
7463 }
7464 return { message: String(value) };
7465 };
7466 var createAsyncThunk = (function () {
7467 function createAsyncThunk2(typePrefix, payloadCreator, options) {
7468 var fulfilled = createAction(typePrefix + "/fulfilled", function (payload, requestId, arg, meta) { return ({
7469 payload: payload,
7470 meta: __spreadProps(__spreadValues({}, meta || {}), {
7471 arg: arg,
7472 requestId: requestId,
7473 requestStatus: "fulfilled"
7474 })
7475 }); });
7476 var pending = createAction(typePrefix + "/pending", function (requestId, arg, meta) { return ({
7477 payload: void 0,
7478 meta: __spreadProps(__spreadValues({}, meta || {}), {
7479 arg: arg,
7480 requestId: requestId,
7481 requestStatus: "pending"
7482 })
7483 }); });
7484 var rejected = createAction(typePrefix + "/rejected", function (error, requestId, arg, payload, meta) { return ({
7485 payload: payload,
7486 error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
7487 meta: __spreadProps(__spreadValues({}, meta || {}), {
7488 arg: arg,
7489 requestId: requestId,
7490 rejectedWithValue: !!payload,
7491 requestStatus: "rejected",
7492 aborted: (error == null ? void 0 : error.name) === "AbortError",
7493 condition: (error == null ? void 0 : error.name) === "ConditionError"
7494 })
7495 }); });
7496 var displayedWarning = false;
7497 var AC = typeof AbortController !== "undefined" ? AbortController : /** @class */ (function () {
7498 function class_1() {
7499 this.signal = {
7500 aborted: false,
7501 addEventListener: function () {
7502 },
7503 dispatchEvent: function () {
7504 return false;
7505 },
7506 onabort: function () {
7507 },
7508 removeEventListener: function () {
7509 },
7510 reason: void 0,
7511 throwIfAborted: function () {
7512 }
7513 };
7514 }
7515 class_1.prototype.abort = function () {
7516 if (true) {
7517 if (!displayedWarning) {
7518 displayedWarning = true;
7519 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'.");
7520 }
7521 }
7522 };
7523 return class_1;
7524 }());
7525 function actionCreator(arg) {
7526 return function (dispatch, getState, extra) {
7527 var requestId = (options == null ? void 0 : options.idGenerator) ? options.idGenerator(arg) : nanoid();
7528 var abortController = new AC();
7529 var abortReason;
7530 var started = false;
7531 function abort(reason) {
7532 abortReason = reason;
7533 abortController.abort();
7534 }
7535 var promise2 = function () {
7536 return __async(this, null, function () {
7537 var _a, _b, finalAction, conditionResult, abortedPromise, err_1, skipDispatch;
7538 return __generator(this, function (_c) {
7539 switch (_c.label) {
7540 case 0:
7541 _c.trys.push([0, 4, , 5]);
7542 conditionResult = (_a = options == null ? void 0 : options.condition) == null ? void 0 : _a.call(options, arg, { getState: getState, extra: extra });
7543 if (!isThenable(conditionResult)) return [3 /*break*/, 2];
7544 return [4 /*yield*/, conditionResult];
7545 case 1:
7546 conditionResult = _c.sent();
7547 _c.label = 2;
7548 case 2:
7549 if (conditionResult === false || abortController.signal.aborted) {
7550 throw {
7551 name: "ConditionError",
7552 message: "Aborted due to condition callback returning false."
7553 };
7554 }
7555 started = true;
7556 abortedPromise = new Promise(function (_, reject) { return abortController.signal.addEventListener("abort", function () { return reject({
7557 name: "AbortError",
7558 message: abortReason || "Aborted"
7559 }); }); });
7560 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 })));
7561 return [4 /*yield*/, Promise.race([
7562 abortedPromise,
7563 Promise.resolve(payloadCreator(arg, {
7564 dispatch: dispatch,
7565 getState: getState,
7566 extra: extra,
7567 requestId: requestId,
7568 signal: abortController.signal,
7569 abort: abort,
7570 rejectWithValue: function (value, meta) {
7571 return new RejectWithValue(value, meta);
7572 },
7573 fulfillWithValue: function (value, meta) {
7574 return new FulfillWithMeta(value, meta);
7575 }
7576 })).then(function (result) {
7577 if (result instanceof RejectWithValue) {
7578 throw result;
7579 }
7580 if (result instanceof FulfillWithMeta) {
7581 return fulfilled(result.payload, requestId, arg, result.meta);
7582 }
7583 return fulfilled(result, requestId, arg);
7584 })
7585 ])];
7586 case 3:
7587 finalAction = _c.sent();
7588 return [3 /*break*/, 5];
7589 case 4:
7590 err_1 = _c.sent();
7591 finalAction = err_1 instanceof RejectWithValue ? rejected(null, requestId, arg, err_1.payload, err_1.meta) : rejected(err_1, requestId, arg);
7592 return [3 /*break*/, 5];
7593 case 5:
7594 skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
7595 if (!skipDispatch) {
7596 dispatch(finalAction);
7597 }
7598 return [2 /*return*/, finalAction];
7599 }
7600 });
7601 });
7602 }();
7603 return Object.assign(promise2, {
7604 abort: abort,
7605 requestId: requestId,
7606 arg: arg,
7607 unwrap: function () {
7608 return promise2.then(unwrapResult);
7609 }
7610 });
7611 };
7612 }
7613 return Object.assign(actionCreator, {
7614 pending: pending,
7615 rejected: rejected,
7616 fulfilled: fulfilled,
7617 typePrefix: typePrefix
7618 });
7619 }
7620 createAsyncThunk2.withTypes = function () { return createAsyncThunk2; };
7621 return createAsyncThunk2;
7622 })();
7623 function unwrapResult(action) {
7624 if (action.meta && action.meta.rejectedWithValue) {
7625 throw action.payload;
7626 }
7627 if (action.error) {
7628 throw action.error;
7629 }
7630 return action.payload;
7631 }
7632 function isThenable(value) {
7633 return value !== null && typeof value === "object" && typeof value.then === "function";
7634 }
7635 // src/matchers.ts
7636 var matches = function (matcher, action) {
7637 if (hasMatchFunction(matcher)) {
7638 return matcher.match(action);
7639 }
7640 else {
7641 return matcher(action);
7642 }
7643 };
7644 function isAnyOf() {
7645 var matchers = [];
7646 for (var _i = 0; _i < arguments.length; _i++) {
7647 matchers[_i] = arguments[_i];
7648 }
7649 return function (action) {
7650 return matchers.some(function (matcher) { return matches(matcher, action); });
7651 };
7652 }
7653 function isAllOf() {
7654 var matchers = [];
7655 for (var _i = 0; _i < arguments.length; _i++) {
7656 matchers[_i] = arguments[_i];
7657 }
7658 return function (action) {
7659 return matchers.every(function (matcher) { return matches(matcher, action); });
7660 };
7661 }
7662 function hasExpectedRequestMetadata(action, validStatus) {
7663 if (!action || !action.meta)
7664 return false;
7665 var hasValidRequestId = typeof action.meta.requestId === "string";
7666 var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
7667 return hasValidRequestId && hasValidRequestStatus;
7668 }
7669 function isAsyncThunkArray(a) {
7670 return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
7671 }
7672 function isPending() {
7673 var asyncThunks = [];
7674 for (var _i = 0; _i < arguments.length; _i++) {
7675 asyncThunks[_i] = arguments[_i];
7676 }
7677 if (asyncThunks.length === 0) {
7678 return function (action) { return hasExpectedRequestMetadata(action, ["pending"]); };
7679 }
7680 if (!isAsyncThunkArray(asyncThunks)) {
7681 return isPending()(asyncThunks[0]);
7682 }
7683 return function (action) {
7684 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.pending; });
7685 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7686 return combinedMatcher(action);
7687 };
7688 }
7689 function isRejected() {
7690 var asyncThunks = [];
7691 for (var _i = 0; _i < arguments.length; _i++) {
7692 asyncThunks[_i] = arguments[_i];
7693 }
7694 if (asyncThunks.length === 0) {
7695 return function (action) { return hasExpectedRequestMetadata(action, ["rejected"]); };
7696 }
7697 if (!isAsyncThunkArray(asyncThunks)) {
7698 return isRejected()(asyncThunks[0]);
7699 }
7700 return function (action) {
7701 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.rejected; });
7702 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7703 return combinedMatcher(action);
7704 };
7705 }
7706 function isRejectedWithValue() {
7707 var asyncThunks = [];
7708 for (var _i = 0; _i < arguments.length; _i++) {
7709 asyncThunks[_i] = arguments[_i];
7710 }
7711 var hasFlag = function (action) {
7712 return action && action.meta && action.meta.rejectedWithValue;
7713 };
7714 if (asyncThunks.length === 0) {
7715 return function (action) {
7716 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
7717 return combinedMatcher(action);
7718 };
7719 }
7720 if (!isAsyncThunkArray(asyncThunks)) {
7721 return isRejectedWithValue()(asyncThunks[0]);
7722 }
7723 return function (action) {
7724 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
7725 return combinedMatcher(action);
7726 };
7727 }
7728 function isFulfilled() {
7729 var asyncThunks = [];
7730 for (var _i = 0; _i < arguments.length; _i++) {
7731 asyncThunks[_i] = arguments[_i];
7732 }
7733 if (asyncThunks.length === 0) {
7734 return function (action) { return hasExpectedRequestMetadata(action, ["fulfilled"]); };
7735 }
7736 if (!isAsyncThunkArray(asyncThunks)) {
7737 return isFulfilled()(asyncThunks[0]);
7738 }
7739 return function (action) {
7740 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.fulfilled; });
7741 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7742 return combinedMatcher(action);
7743 };
7744 }
7745 function isAsyncThunkAction() {
7746 var asyncThunks = [];
7747 for (var _i = 0; _i < arguments.length; _i++) {
7748 asyncThunks[_i] = arguments[_i];
7749 }
7750 if (asyncThunks.length === 0) {
7751 return function (action) { return hasExpectedRequestMetadata(action, ["pending", "fulfilled", "rejected"]); };
7752 }
7753 if (!isAsyncThunkArray(asyncThunks)) {
7754 return isAsyncThunkAction()(asyncThunks[0]);
7755 }
7756 return function (action) {
7757 var matchers = [];
7758 for (var _i = 0, asyncThunks_1 = asyncThunks; _i < asyncThunks_1.length; _i++) {
7759 var asyncThunk = asyncThunks_1[_i];
7760 matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
7761 }
7762 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7763 return combinedMatcher(action);
7764 };
7765 }
7766 // src/listenerMiddleware/utils.ts
7767 var assertFunction = function (func, expected) {
7768 if (typeof func !== "function") {
7769 throw new TypeError(expected + " is not a function");
7770 }
7771 };
7772 var noop = function () {
7773 };
7774 var catchRejection = function (promise2, onError) {
7775 if (onError === void 0) { onError = noop; }
7776 promise2.catch(onError);
7777 return promise2;
7778 };
7779 var addAbortSignalListener = function (abortSignal, callback) {
7780 abortSignal.addEventListener("abort", callback, { once: true });
7781 return function () { return abortSignal.removeEventListener("abort", callback); };
7782 };
7783 var abortControllerWithReason = function (abortController, reason) {
7784 var signal = abortController.signal;
7785 if (signal.aborted) {
7786 return;
7787 }
7788 if (!("reason" in signal)) {
7789 Object.defineProperty(signal, "reason", {
7790 enumerable: true,
7791 value: reason,
7792 configurable: true,
7793 writable: true
7794 });
7795 }
7796 ;
7797 abortController.abort(reason);
7798 };
7799 // src/listenerMiddleware/exceptions.ts
7800 var task = "task";
7801 var listener = "listener";
7802 var completed = "completed";
7803 var cancelled = "cancelled";
7804 var taskCancelled = "task-" + cancelled;
7805 var taskCompleted = "task-" + completed;
7806 var listenerCancelled = listener + "-" + cancelled;
7807 var listenerCompleted = listener + "-" + completed;
7808 var TaskAbortError = /** @class */ (function () {
7809 function TaskAbortError(code) {
7810 this.code = code;
7811 this.name = "TaskAbortError";
7812 this.message = task + " " + cancelled + " (reason: " + code + ")";
7813 }
7814 return TaskAbortError;
7815 }());
7816 // src/listenerMiddleware/task.ts
7817 var validateActive = function (signal) {
7818 if (signal.aborted) {
7819 throw new TaskAbortError(signal.reason);
7820 }
7821 };
7822 function raceWithSignal(signal, promise2) {
7823 var cleanup = noop;
7824 return new Promise(function (resolve, reject) {
7825 var notifyRejection = function () { return reject(new TaskAbortError(signal.reason)); };
7826 if (signal.aborted) {
7827 notifyRejection();
7828 return;
7829 }
7830 cleanup = addAbortSignalListener(signal, notifyRejection);
7831 promise2.finally(function () { return cleanup(); }).then(resolve, reject);
7832 }).finally(function () {
7833 cleanup = noop;
7834 });
7835 }
7836 var runTask = function (task2, cleanUp) { return __async(void 0, null, function () {
7837 var value, error_1;
7838 return __generator(this, function (_c) {
7839 switch (_c.label) {
7840 case 0:
7841 _c.trys.push([0, 3, 4, 5]);
7842 return [4 /*yield*/, Promise.resolve()];
7843 case 1:
7844 _c.sent();
7845 return [4 /*yield*/, task2()];
7846 case 2:
7847 value = _c.sent();
7848 return [2 /*return*/, {
7849 status: "ok",
7850 value: value
7851 }];
7852 case 3:
7853 error_1 = _c.sent();
7854 return [2 /*return*/, {
7855 status: error_1 instanceof TaskAbortError ? "cancelled" : "rejected",
7856 error: error_1
7857 }];
7858 case 4:
7859 cleanUp == null ? void 0 : cleanUp();
7860 return [7 /*endfinally*/];
7861 case 5: return [2 /*return*/];
7862 }
7863 });
7864 }); };
7865 var createPause = function (signal) {
7866 return function (promise2) {
7867 return catchRejection(raceWithSignal(signal, promise2).then(function (output) {
7868 validateActive(signal);
7869 return output;
7870 }));
7871 };
7872 };
7873 var createDelay = function (signal) {
7874 var pause = createPause(signal);
7875 return function (timeoutMs) {
7876 return pause(new Promise(function (resolve) { return setTimeout(resolve, timeoutMs); }));
7877 };
7878 };
7879 // src/listenerMiddleware/index.ts
7880 var assign = Object.assign;
7881 var INTERNAL_NIL_TOKEN = {};
7882 var alm = "listenerMiddleware";
7883 var createFork = function (parentAbortSignal, parentBlockingPromises) {
7884 var linkControllers = function (controller) { return addAbortSignalListener(parentAbortSignal, function () { return abortControllerWithReason(controller, parentAbortSignal.reason); }); };
7885 return function (taskExecutor, opts) {
7886 assertFunction(taskExecutor, "taskExecutor");
7887 var childAbortController = new AbortController();
7888 linkControllers(childAbortController);
7889 var result = runTask(function () { return __async(void 0, null, function () {
7890 var result2;
7891 return __generator(this, function (_c) {
7892 switch (_c.label) {
7893 case 0:
7894 validateActive(parentAbortSignal);
7895 validateActive(childAbortController.signal);
7896 return [4 /*yield*/, taskExecutor({
7897 pause: createPause(childAbortController.signal),
7898 delay: createDelay(childAbortController.signal),
7899 signal: childAbortController.signal
7900 })];
7901 case 1:
7902 result2 = _c.sent();
7903 validateActive(childAbortController.signal);
7904 return [2 /*return*/, result2];
7905 }
7906 });
7907 }); }, function () { return abortControllerWithReason(childAbortController, taskCompleted); });
7908 if (opts == null ? void 0 : opts.autoJoin) {
7909 parentBlockingPromises.push(result);
7910 }
7911 return {
7912 result: createPause(parentAbortSignal)(result),
7913 cancel: function () {
7914 abortControllerWithReason(childAbortController, taskCancelled);
7915 }
7916 };
7917 };
7918 };
7919 var createTakePattern = function (startListening, signal) {
7920 var take = function (predicate, timeout) { return __async(void 0, null, function () {
7921 var unsubscribe, tuplePromise, promises, output;
7922 return __generator(this, function (_c) {
7923 switch (_c.label) {
7924 case 0:
7925 validateActive(signal);
7926 unsubscribe = function () {
7927 };
7928 tuplePromise = new Promise(function (resolve, reject) {
7929 var stopListening = startListening({
7930 predicate: predicate,
7931 effect: function (action, listenerApi) {
7932 listenerApi.unsubscribe();
7933 resolve([
7934 action,
7935 listenerApi.getState(),
7936 listenerApi.getOriginalState()
7937 ]);
7938 }
7939 });
7940 unsubscribe = function () {
7941 stopListening();
7942 reject();
7943 };
7944 });
7945 promises = [
7946 tuplePromise
7947 ];
7948 if (timeout != null) {
7949 promises.push(new Promise(function (resolve) { return setTimeout(resolve, timeout, null); }));
7950 }
7951 _c.label = 1;
7952 case 1:
7953 _c.trys.push([1, , 3, 4]);
7954 return [4 /*yield*/, raceWithSignal(signal, Promise.race(promises))];
7955 case 2:
7956 output = _c.sent();
7957 validateActive(signal);
7958 return [2 /*return*/, output];
7959 case 3:
7960 unsubscribe();
7961 return [7 /*endfinally*/];
7962 case 4: return [2 /*return*/];
7963 }
7964 });
7965 }); };
7966 return function (predicate, timeout) { return catchRejection(take(predicate, timeout)); };
7967 };
7968 var getListenerEntryPropsFrom = function (options) {
7969 var type = options.type, actionCreator = options.actionCreator, matcher = options.matcher, predicate = options.predicate, effect = options.effect;
7970 if (type) {
7971 predicate = createAction(type).match;
7972 }
7973 else if (actionCreator) {
7974 type = actionCreator.type;
7975 predicate = actionCreator.match;
7976 }
7977 else if (matcher) {
7978 predicate = matcher;
7979 }
7980 else if (predicate) {
7981 }
7982 else {
7983 throw new Error("Creating or removing a listener requires one of the known fields for matching an action");
7984 }
7985 assertFunction(effect, "options.listener");
7986 return { predicate: predicate, type: type, effect: effect };
7987 };
7988 var createListenerEntry = function (options) {
7989 var _c = getListenerEntryPropsFrom(options), type = _c.type, predicate = _c.predicate, effect = _c.effect;
7990 var id = nanoid();
7991 var entry = {
7992 id: id,
7993 effect: effect,
7994 type: type,
7995 predicate: predicate,
7996 pending: new Set(),
7997 unsubscribe: function () {
7998 throw new Error("Unsubscribe not initialized");
7999 }
8000 };
8001 return entry;
8002 };
8003 var cancelActiveListeners = function (entry) {
8004 entry.pending.forEach(function (controller) {
8005 abortControllerWithReason(controller, listenerCancelled);
8006 });
8007 };
8008 var createClearListenerMiddleware = function (listenerMap) {
8009 return function () {
8010 listenerMap.forEach(cancelActiveListeners);
8011 listenerMap.clear();
8012 };
8013 };
8014 var safelyNotifyError = function (errorHandler, errorToNotify, errorInfo) {
8015 try {
8016 errorHandler(errorToNotify, errorInfo);
8017 }
8018 catch (errorHandlerError) {
8019 setTimeout(function () {
8020 throw errorHandlerError;
8021 }, 0);
8022 }
8023 };
8024 var addListener = createAction(alm + "/add");
8025 var clearAllListeners = createAction(alm + "/removeAll");
8026 var removeListener = createAction(alm + "/remove");
8027 var defaultErrorHandler = function () {
8028 var args = [];
8029 for (var _i = 0; _i < arguments.length; _i++) {
8030 args[_i] = arguments[_i];
8031 }
8032 console.error.apply(console, __spreadArray([alm + "/error"], args));
8033 };
8034 function createListenerMiddleware(middlewareOptions) {
8035 var _this = this;
8036 if (middlewareOptions === void 0) { middlewareOptions = {}; }
8037 var listenerMap = new Map();
8038 var extra = middlewareOptions.extra, _c = middlewareOptions.onError, onError = _c === void 0 ? defaultErrorHandler : _c;
8039 assertFunction(onError, "onError");
8040 var insertEntry = function (entry) {
8041 entry.unsubscribe = function () { return listenerMap.delete(entry.id); };
8042 listenerMap.set(entry.id, entry);
8043 return function (cancelOptions) {
8044 entry.unsubscribe();
8045 if (cancelOptions == null ? void 0 : cancelOptions.cancelActive) {
8046 cancelActiveListeners(entry);
8047 }
8048 };
8049 };
8050 var findListenerEntry = function (comparator) {
8051 for (var _i = 0, _c = Array.from(listenerMap.values()); _i < _c.length; _i++) {
8052 var entry = _c[_i];
8053 if (comparator(entry)) {
8054 return entry;
8055 }
8056 }
8057 return void 0;
8058 };
8059 var startListening = function (options) {
8060 var entry = findListenerEntry(function (existingEntry) { return existingEntry.effect === options.effect; });
8061 if (!entry) {
8062 entry = createListenerEntry(options);
8063 }
8064 return insertEntry(entry);
8065 };
8066 var stopListening = function (options) {
8067 var _c = getListenerEntryPropsFrom(options), type = _c.type, effect = _c.effect, predicate = _c.predicate;
8068 var entry = findListenerEntry(function (entry2) {
8069 var matchPredicateOrType = typeof type === "string" ? entry2.type === type : entry2.predicate === predicate;
8070 return matchPredicateOrType && entry2.effect === effect;
8071 });
8072 if (entry) {
8073 entry.unsubscribe();
8074 if (options.cancelActive) {
8075 cancelActiveListeners(entry);
8076 }
8077 }
8078 return !!entry;
8079 };
8080 var notifyListener = function (entry, action, api, getOriginalState) { return __async(_this, null, function () {
8081 var internalTaskController, take, autoJoinPromises, listenerError_1;
8082 return __generator(this, function (_c) {
8083 switch (_c.label) {
8084 case 0:
8085 internalTaskController = new AbortController();
8086 take = createTakePattern(startListening, internalTaskController.signal);
8087 autoJoinPromises = [];
8088 _c.label = 1;
8089 case 1:
8090 _c.trys.push([1, 3, 4, 6]);
8091 entry.pending.add(internalTaskController);
8092 return [4 /*yield*/, Promise.resolve(entry.effect(action, assign({}, api, {
8093 getOriginalState: getOriginalState,
8094 condition: function (predicate, timeout) { return take(predicate, timeout).then(Boolean); },
8095 take: take,
8096 delay: createDelay(internalTaskController.signal),
8097 pause: createPause(internalTaskController.signal),
8098 extra: extra,
8099 signal: internalTaskController.signal,
8100 fork: createFork(internalTaskController.signal, autoJoinPromises),
8101 unsubscribe: entry.unsubscribe,
8102 subscribe: function () {
8103 listenerMap.set(entry.id, entry);
8104 },
8105 cancelActiveListeners: function () {
8106 entry.pending.forEach(function (controller, _, set) {
8107 if (controller !== internalTaskController) {
8108 abortControllerWithReason(controller, listenerCancelled);
8109 set.delete(controller);
8110 }
8111 });
8112 }
8113 })))];
8114 case 2:
8115 _c.sent();
8116 return [3 /*break*/, 6];
8117 case 3:
8118 listenerError_1 = _c.sent();
8119 if (!(listenerError_1 instanceof TaskAbortError)) {
8120 safelyNotifyError(onError, listenerError_1, {
8121 raisedBy: "effect"
8122 });
8123 }
8124 return [3 /*break*/, 6];
8125 case 4: return [4 /*yield*/, Promise.allSettled(autoJoinPromises)];
8126 case 5:
8127 _c.sent();
8128 abortControllerWithReason(internalTaskController, listenerCompleted);
8129 entry.pending.delete(internalTaskController);
8130 return [7 /*endfinally*/];
8131 case 6: return [2 /*return*/];
8132 }
8133 });
8134 }); };
8135 var clearListenerMiddleware = createClearListenerMiddleware(listenerMap);
8136 var middleware = function (api) { return function (next) { return function (action) {
8137 if (!isAction(action)) {
8138 return next(action);
8139 }
8140 if (addListener.match(action)) {
8141 return startListening(action.payload);
8142 }
8143 if (clearAllListeners.match(action)) {
8144 clearListenerMiddleware();
8145 return;
8146 }
8147 if (removeListener.match(action)) {
8148 return stopListening(action.payload);
8149 }
8150 var originalState = api.getState();
8151 var getOriginalState = function () {
8152 if (originalState === INTERNAL_NIL_TOKEN) {
8153 throw new Error(alm + ": getOriginalState can only be called synchronously");
8154 }
8155 return originalState;
8156 };
8157 var result;
8158 try {
8159 result = next(action);
8160 if (listenerMap.size > 0) {
8161 var currentState = api.getState();
8162 var listenerEntries = Array.from(listenerMap.values());
8163 for (var _i = 0, listenerEntries_1 = listenerEntries; _i < listenerEntries_1.length; _i++) {
8164 var entry = listenerEntries_1[_i];
8165 var runListener = false;
8166 try {
8167 runListener = entry.predicate(action, currentState, originalState);
8168 }
8169 catch (predicateError) {
8170 runListener = false;
8171 safelyNotifyError(onError, predicateError, {
8172 raisedBy: "predicate"
8173 });
8174 }
8175 if (!runListener) {
8176 continue;
8177 }
8178 notifyListener(entry, action, api, getOriginalState);
8179 }
8180 }
8181 }
8182 finally {
8183 originalState = INTERNAL_NIL_TOKEN;
8184 }
8185 return result;
8186 }; }; };
8187 return {
8188 middleware: middleware,
8189 startListening: startListening,
8190 stopListening: stopListening,
8191 clearListeners: clearListenerMiddleware
8192 };
8193 }
8194 // src/autoBatchEnhancer.ts
8195 var SHOULD_AUTOBATCH = "RTK_autoBatch";
8196 var prepareAutoBatched = function () { return function (payload) {
8197 var _c;
8198 return ({
8199 payload: payload,
8200 meta: (_c = {}, _c[SHOULD_AUTOBATCH] = true, _c)
8201 });
8202 }; };
8203 var promise;
8204 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 () {
8205 throw err;
8206 }, 0); }); };
8207 var createQueueWithTimer = function (timeout) {
8208 return function (notify) {
8209 setTimeout(notify, timeout);
8210 };
8211 };
8212 var rAF = typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10);
8213 var autoBatchEnhancer = function (options) {
8214 if (options === void 0) { options = { type: "raf" }; }
8215 return function (next) { return function () {
8216 var args = [];
8217 for (var _i = 0; _i < arguments.length; _i++) {
8218 args[_i] = arguments[_i];
8219 }
8220 var store = next.apply(void 0, args);
8221 var notifying = true;
8222 var shouldNotifyAtEndOfTick = false;
8223 var notificationQueued = false;
8224 var listeners = new Set();
8225 var queueCallback = options.type === "tick" ? queueMicrotaskShim : options.type === "raf" ? rAF : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
8226 var notifyListeners = function () {
8227 notificationQueued = false;
8228 if (shouldNotifyAtEndOfTick) {
8229 shouldNotifyAtEndOfTick = false;
8230 listeners.forEach(function (l) { return l(); });
8231 }
8232 };
8233 return Object.assign({}, store, {
8234 subscribe: function (listener2) {
8235 var wrappedListener = function () { return notifying && listener2(); };
8236 var unsubscribe = store.subscribe(wrappedListener);
8237 listeners.add(listener2);
8238 return function () {
8239 unsubscribe();
8240 listeners.delete(listener2);
8241 };
8242 },
8243 dispatch: function (action) {
8244 var _a;
8245 try {
8246 notifying = !((_a = action == null ? void 0 : action.meta) == null ? void 0 : _a[SHOULD_AUTOBATCH]);
8247 shouldNotifyAtEndOfTick = !notifying;
8248 if (shouldNotifyAtEndOfTick) {
8249 if (!notificationQueued) {
8250 notificationQueued = true;
8251 queueCallback(notifyListeners);
8252 }
8253 }
8254 return store.dispatch(action);
8255 }
8256 finally {
8257 notifying = true;
8258 }
8259 }
8260 });
8261 }; };
8262 };
8263 // src/index.ts
8264 (0,immer__WEBPACK_IMPORTED_MODULE_0__.enableES5)();
8265
8266 //# sourceMappingURL=redux-toolkit.esm.js.map
8267
8268 /***/ }),
8269
8270 /***/ "../node_modules/immer/dist/immer.esm.mjs":
8271 /*!************************************************!*\
8272 !*** ../node_modules/immer/dist/immer.esm.mjs ***!
8273 \************************************************/
8274 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8275
8276 "use strict";
8277 __webpack_require__.r(__webpack_exports__);
8278 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8279 /* harmony export */ Immer: () => (/* binding */ un),
8280 /* harmony export */ applyPatches: () => (/* binding */ pn),
8281 /* harmony export */ castDraft: () => (/* binding */ K),
8282 /* harmony export */ castImmutable: () => (/* binding */ $),
8283 /* harmony export */ createDraft: () => (/* binding */ ln),
8284 /* harmony export */ current: () => (/* binding */ R),
8285 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
8286 /* harmony export */ enableAllPlugins: () => (/* binding */ J),
8287 /* harmony export */ enableES5: () => (/* binding */ F),
8288 /* harmony export */ enableMapSet: () => (/* binding */ C),
8289 /* harmony export */ enablePatches: () => (/* binding */ T),
8290 /* harmony export */ finishDraft: () => (/* binding */ dn),
8291 /* harmony export */ freeze: () => (/* binding */ d),
8292 /* harmony export */ immerable: () => (/* binding */ L),
8293 /* harmony export */ isDraft: () => (/* binding */ r),
8294 /* harmony export */ isDraftable: () => (/* binding */ t),
8295 /* harmony export */ nothing: () => (/* binding */ H),
8296 /* harmony export */ original: () => (/* binding */ e),
8297 /* harmony export */ produce: () => (/* binding */ fn),
8298 /* harmony export */ produceWithPatches: () => (/* binding */ cn),
8299 /* harmony export */ setAutoFreeze: () => (/* binding */ sn),
8300 /* harmony export */ setUseProxies: () => (/* binding */ vn)
8301 /* harmony export */ });
8302 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
8303 }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);
8304 //# sourceMappingURL=immer.esm.js.map
8305
8306
8307 /***/ }),
8308
8309 /***/ "../node_modules/mixpanel-browser/dist/mixpanel.module.js":
8310 /*!****************************************************************!*\
8311 !*** ../node_modules/mixpanel-browser/dist/mixpanel.module.js ***!
8312 \****************************************************************/
8313 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8314
8315 "use strict";
8316 __webpack_require__.r(__webpack_exports__);
8317 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8318 /* harmony export */ "default": () => (/* binding */ mixpanel)
8319 /* harmony export */ });
8320 // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
8321 var win;
8322 if (typeof(window) === 'undefined') {
8323 var loc = {
8324 hostname: ''
8325 };
8326 win = {
8327 crypto: {randomUUID: function() {throw Error('unsupported');}},
8328 navigator: { userAgent: '', onLine: true },
8329 document: {
8330 createElement: function() { return {}; },
8331 location: loc,
8332 referrer: ''
8333 },
8334 screen: { width: 0, height: 0 },
8335 location: loc,
8336 addEventListener: function() {},
8337 removeEventListener: function() {}
8338 };
8339 } else {
8340 win = window;
8341 }
8342
8343 function _array_like_to_array(arr, len) {
8344 if (len == null || len > arr.length) len = arr.length;
8345 for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8346 return arr2;
8347 }
8348 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8349 try {
8350 var info = gen[key](arg);
8351 var value = info.value;
8352 } catch (error) {
8353 reject(error);
8354 return;
8355 }
8356 if (info.done) {
8357 resolve(value);
8358 } else {
8359 Promise.resolve(value).then(_next, _throw);
8360 }
8361 }
8362 function _async_to_generator(fn) {
8363 return function() {
8364 var self = this, args = arguments;
8365 return new Promise(function(resolve, reject) {
8366 var gen = fn.apply(self, args);
8367 function _next(value) {
8368 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8369 }
8370 function _throw(err) {
8371 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8372 }
8373 _next(undefined);
8374 });
8375 };
8376 }
8377 function _construct(Parent, args, Class) {
8378 if (_is_native_reflect_construct()) {
8379 _construct = Reflect.construct;
8380 } else {
8381 _construct = function construct(Parent, args, Class) {
8382 var a = [
8383 null
8384 ];
8385 a.push.apply(a, args);
8386 var Constructor = Function.bind.apply(Parent, a);
8387 var instance = new Constructor();
8388 if (Class) _set_prototype_of(instance, Class.prototype);
8389 return instance;
8390 };
8391 }
8392 return _construct.apply(null, arguments);
8393 }
8394 function _defineProperties(target, props) {
8395 for(var i = 0; i < props.length; i++){
8396 var descriptor = props[i];
8397 descriptor.enumerable = descriptor.enumerable || false;
8398 descriptor.configurable = true;
8399 if ("value" in descriptor) descriptor.writable = true;
8400 Object.defineProperty(target, descriptor.key, descriptor);
8401 }
8402 }
8403 function _create_class(Constructor, protoProps, staticProps) {
8404 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
8405 return Constructor;
8406 }
8407 function _extends() {
8408 _extends = Object.assign || function(target) {
8409 for(var i = 1; i < arguments.length; i++){
8410 var source = arguments[i];
8411 for(var key in source){
8412 if (Object.prototype.hasOwnProperty.call(source, key)) {
8413 target[key] = source[key];
8414 }
8415 }
8416 }
8417 return target;
8418 };
8419 return _extends.apply(this, arguments);
8420 }
8421 function _get_prototype_of(o) {
8422 _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
8423 return o.__proto__ || Object.getPrototypeOf(o);
8424 };
8425 return _get_prototype_of(o);
8426 }
8427 function _inherits(subClass, superClass) {
8428 if (typeof superClass !== "function" && superClass !== null) {
8429 throw new TypeError("Super expression must either be null or a function");
8430 }
8431 subClass.prototype = Object.create(superClass && superClass.prototype, {
8432 constructor: {
8433 value: subClass,
8434 writable: true,
8435 configurable: true
8436 }
8437 });
8438 if (superClass) _set_prototype_of(subClass, superClass);
8439 }
8440 function _instanceof(left, right) {
8441 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
8442 return !!right[Symbol.hasInstance](left);
8443 } else {
8444 return left instanceof right;
8445 }
8446 }
8447 function _is_native_function(fn) {
8448 return Function.toString.call(fn).indexOf("[native code]") !== -1;
8449 }
8450 function _object_without_properties_loose(source, excluded) {
8451 if (source == null) return {};
8452 var target = {};
8453 var sourceKeys = Object.keys(source);
8454 var key, i;
8455 for(i = 0; i < sourceKeys.length; i++){
8456 key = sourceKeys[i];
8457 if (excluded.indexOf(key) >= 0) continue;
8458 target[key] = source[key];
8459 }
8460 return target;
8461 }
8462 function _set_prototype_of(o, p) {
8463 _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
8464 o.__proto__ = p;
8465 return o;
8466 };
8467 return _set_prototype_of(o, p);
8468 }
8469 function _type_of(obj) {
8470 "@swc/helpers - typeof";
8471 return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
8472 }
8473 function _unsupported_iterable_to_array(o, minLen) {
8474 if (!o) return;
8475 if (typeof o === "string") return _array_like_to_array(o, minLen);
8476 var n = Object.prototype.toString.call(o).slice(8, -1);
8477 if (n === "Object" && o.constructor) n = o.constructor.name;
8478 if (n === "Map" || n === "Set") return Array.from(n);
8479 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
8480 }
8481 function _wrap_native_super(Class) {
8482 var _cache = typeof Map === "function" ? new Map() : undefined;
8483 _wrap_native_super = function wrapNativeSuper(Class) {
8484 if (Class === null || !_is_native_function(Class)) return Class;
8485 if (typeof Class !== "function") {
8486 throw new TypeError("Super expression must either be null or a function");
8487 }
8488 if (typeof _cache !== "undefined") {
8489 if (_cache.has(Class)) return _cache.get(Class);
8490 _cache.set(Class, Wrapper);
8491 }
8492 function Wrapper() {
8493 return _construct(Class, arguments, _get_prototype_of(this).constructor);
8494 }
8495 Wrapper.prototype = Object.create(Class.prototype, {
8496 constructor: {
8497 value: Wrapper,
8498 enumerable: false,
8499 writable: true,
8500 configurable: true
8501 }
8502 });
8503 return _set_prototype_of(Wrapper, Class);
8504 };
8505 return _wrap_native_super(Class);
8506 }
8507 function _is_native_reflect_construct() {
8508 try {
8509 var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
8510 } catch (_) {}
8511 return (_is_native_reflect_construct = function() {
8512 return !!result;
8513 })();
8514 }
8515 function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
8516 var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
8517 if (it) return (it = it.call(o)).next.bind(it);
8518 if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike) {
8519 if (it) o = it;
8520 var i = 0;
8521 return function() {
8522 if (i >= o.length) {
8523 return {
8524 done: true
8525 };
8526 }
8527 return {
8528 done: false,
8529 value: o[i++]
8530 };
8531 };
8532 }
8533 throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8534 }
8535 function _ts_generator(thisArg, body) {
8536 var f, y, t, g, _ = {
8537 label: 0,
8538 sent: function() {
8539 if (t[0] & 1) throw t[1];
8540 return t[1];
8541 },
8542 trys: [],
8543 ops: []
8544 };
8545 return g = {
8546 next: verb(0),
8547 "throw": verb(1),
8548 "return": verb(2)
8549 }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
8550 return this;
8551 }), g;
8552 function verb(n) {
8553 return function(v) {
8554 return step([
8555 n,
8556 v
8557 ]);
8558 };
8559 }
8560 function step(op) {
8561 if (f) throw new TypeError("Generator is already executing.");
8562 while(_)try {
8563 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;
8564 if (y = 0, t) op = [
8565 op[0] & 2,
8566 t.value
8567 ];
8568 switch(op[0]){
8569 case 0:
8570 case 1:
8571 t = op;
8572 break;
8573 case 4:
8574 _.label++;
8575 return {
8576 value: op[1],
8577 done: false
8578 };
8579 case 5:
8580 _.label++;
8581 y = op[1];
8582 op = [
8583 0
8584 ];
8585 continue;
8586 case 7:
8587 op = _.ops.pop();
8588 _.trys.pop();
8589 continue;
8590 default:
8591 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
8592 _ = 0;
8593 continue;
8594 }
8595 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
8596 _.label = op[1];
8597 break;
8598 }
8599 if (op[0] === 6 && _.label < t[1]) {
8600 _.label = t[1];
8601 t = op;
8602 break;
8603 }
8604 if (t && _.label < t[2]) {
8605 _.label = t[2];
8606 _.ops.push(op);
8607 break;
8608 }
8609 if (t[2]) _.ops.pop();
8610 _.trys.pop();
8611 continue;
8612 }
8613 op = body.call(thisArg, _);
8614 } catch (e) {
8615 op = [
8616 6,
8617 e
8618 ];
8619 y = 0;
8620 } finally{
8621 f = t = 0;
8622 }
8623 if (op[0] & 5) throw op[1];
8624 return {
8625 value: op[0] ? op[1] : void 0,
8626 done: true
8627 };
8628 }
8629 }
8630 function _ts_values(o) {
8631 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
8632 if (m) return m.call(o);
8633 if (o && typeof o.length === "number") return {
8634 next: function() {
8635 if (o && i >= o.length) o = void 0;
8636 return {
8637 value: o && o[i++],
8638 done: !o
8639 };
8640 }
8641 };
8642 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
8643 }
8644 var __defProp = Object.defineProperty;
8645 var __defNormalProp = function(obj, key, value) {
8646 return key in obj ? __defProp(obj, key, {
8647 enumerable: true,
8648 configurable: true,
8649 writable: true,
8650 value: value
8651 }) : obj[key] = value;
8652 };
8653 var __publicField = function(obj, key, value) {
8654 return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
8655 };
8656 var _a;
8657 var __defProp$1 = Object.defineProperty;
8658 var __defNormalProp$1 = function(obj, key, value) {
8659 return key in obj ? __defProp$1(obj, key, {
8660 enumerable: true,
8661 configurable: true,
8662 writable: true,
8663 value: value
8664 }) : obj[key] = value;
8665 };
8666 var __publicField$1 = function(obj, key, value) {
8667 return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
8668 };
8669 var NodeType$3 = /* @__PURE__ */ function(NodeType2) {
8670 NodeType2[NodeType2["Document"] = 0] = "Document";
8671 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
8672 NodeType2[NodeType2["Element"] = 2] = "Element";
8673 NodeType2[NodeType2["Text"] = 3] = "Text";
8674 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
8675 NodeType2[NodeType2["Comment"] = 5] = "Comment";
8676 return NodeType2;
8677 }(NodeType$3 || {});
8678 var testableAccessors$1 = {
8679 Node: [
8680 "childNodes",
8681 "parentNode",
8682 "parentElement",
8683 "textContent"
8684 ],
8685 ShadowRoot: [
8686 "host",
8687 "styleSheets"
8688 ],
8689 Element: [
8690 "shadowRoot",
8691 "querySelector",
8692 "querySelectorAll"
8693 ],
8694 MutationObserver: []
8695 };
8696 var testableMethods$1 = {
8697 Node: [
8698 "contains",
8699 "getRootNode"
8700 ],
8701 ShadowRoot: [
8702 "getSelection"
8703 ],
8704 Element: [],
8705 MutationObserver: [
8706 "constructor"
8707 ]
8708 };
8709 var untaintedBasePrototype$1 = {};
8710 var isAngularZonePresent$1 = function() {
8711 return !!globalThis.Zone;
8712 };
8713 function getUntaintedPrototype$1(key) {
8714 if (untaintedBasePrototype$1[key]) return untaintedBasePrototype$1[key];
8715 var defaultObj = globalThis[key];
8716 var defaultPrototype = defaultObj.prototype;
8717 var accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
8718 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
8719 accessorNames.every(function(accessor) {
8720 var _a2, _b;
8721 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
8722 }));
8723 var methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
8724 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
8725 function(method) {
8726 var _a2;
8727 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
8728 }));
8729 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent$1()) {
8730 untaintedBasePrototype$1[key] = defaultObj.prototype;
8731 return defaultObj.prototype;
8732 }
8733 try {
8734 var iframeEl = document.createElement("iframe");
8735 document.body.appendChild(iframeEl);
8736 var win = iframeEl.contentWindow;
8737 if (!win) return defaultObj.prototype;
8738 var untaintedObject = win[key].prototype;
8739 document.body.removeChild(iframeEl);
8740 if (!untaintedObject) return defaultPrototype;
8741 return untaintedBasePrototype$1[key] = untaintedObject;
8742 } catch (e) {
8743 return defaultPrototype;
8744 }
8745 }
8746 var untaintedAccessorCache$1 = {};
8747 function getUntaintedAccessor$1(key, instance, accessor) {
8748 var _a2;
8749 var cacheKey = key + "." + String(accessor);
8750 if (untaintedAccessorCache$1[cacheKey]) return untaintedAccessorCache$1[cacheKey].call(instance);
8751 var untaintedPrototype = getUntaintedPrototype$1(key);
8752 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
8753 if (!untaintedAccessor) return instance[accessor];
8754 untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
8755 return untaintedAccessor.call(instance);
8756 }
8757 var untaintedMethodCache$1 = {};
8758 function getUntaintedMethod$1(key, instance, method) {
8759 var cacheKey = key + "." + String(method);
8760 if (untaintedMethodCache$1[cacheKey]) return untaintedMethodCache$1[cacheKey].bind(instance);
8761 var untaintedPrototype = getUntaintedPrototype$1(key);
8762 var untaintedMethod = untaintedPrototype[method];
8763 if (typeof untaintedMethod !== "function") return instance[method];
8764 untaintedMethodCache$1[cacheKey] = untaintedMethod;
8765 return untaintedMethod.bind(instance);
8766 }
8767 function childNodes$1(n2) {
8768 return getUntaintedAccessor$1("Node", n2, "childNodes");
8769 }
8770 function parentNode$1(n2) {
8771 return getUntaintedAccessor$1("Node", n2, "parentNode");
8772 }
8773 function parentElement$1(n2) {
8774 return getUntaintedAccessor$1("Node", n2, "parentElement");
8775 }
8776 function textContent$1(n2) {
8777 return getUntaintedAccessor$1("Node", n2, "textContent");
8778 }
8779 function contains$1(n2, other) {
8780 return getUntaintedMethod$1("Node", n2, "contains")(other);
8781 }
8782 function getRootNode$1(n2) {
8783 return getUntaintedMethod$1("Node", n2, "getRootNode")();
8784 }
8785 function host$1(n2) {
8786 if (!n2 || !("host" in n2)) return null;
8787 return getUntaintedAccessor$1("ShadowRoot", n2, "host");
8788 }
8789 function styleSheets$1(n2) {
8790 return n2.styleSheets;
8791 }
8792 function shadowRoot$1(n2) {
8793 if (!n2 || !("shadowRoot" in n2)) return null;
8794 return getUntaintedAccessor$1("Element", n2, "shadowRoot");
8795 }
8796 function querySelector$1(n2, selectors) {
8797 return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
8798 }
8799 function querySelectorAll$1(n2, selectors) {
8800 return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
8801 }
8802 function mutationObserverCtor$1() {
8803 return getUntaintedPrototype$1("MutationObserver").constructor;
8804 }
8805 function patch$1(source, name, replacement) {
8806 try {
8807 if (!(name in source)) {
8808 return function() {};
8809 }
8810 var original = source[name];
8811 var wrapped = replacement(original);
8812 if (typeof wrapped === "function") {
8813 wrapped.prototype = wrapped.prototype || {};
8814 Object.defineProperties(wrapped, {
8815 __rrweb_original__: {
8816 enumerable: false,
8817 value: original
8818 }
8819 });
8820 }
8821 source[name] = wrapped;
8822 return function() {
8823 source[name] = original;
8824 };
8825 } catch (e) {
8826 return function() {};
8827 }
8828 }
8829 var index$1 = {
8830 childNodes: childNodes$1,
8831 parentNode: parentNode$1,
8832 parentElement: parentElement$1,
8833 textContent: textContent$1,
8834 contains: contains$1,
8835 getRootNode: getRootNode$1,
8836 host: host$1,
8837 styleSheets: styleSheets$1,
8838 shadowRoot: shadowRoot$1,
8839 querySelector: querySelector$1,
8840 querySelectorAll: querySelectorAll$1,
8841 mutationObserver: mutationObserverCtor$1,
8842 patch: patch$1
8843 };
8844 function isElement(n2) {
8845 return n2.nodeType === n2.ELEMENT_NODE;
8846 }
8847 function isShadowRoot(n2) {
8848 var hostEl = // anchor and textarea elements also have a `host` property
8849 // but only shadow roots have a `mode` property
8850 n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null;
8851 return Boolean(hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2);
8852 }
8853 function isNativeShadowDom(shadowRoot2) {
8854 return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
8855 }
8856 function fixBrowserCompatibilityIssuesInCSS(cssText) {
8857 if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
8858 cssText = cssText.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;");
8859 }
8860 return cssText;
8861 }
8862 function escapeImportStatement(rule2) {
8863 var cssText = rule2.cssText;
8864 if (cssText.split('"').length < 3) return cssText;
8865 var statement = [
8866 "@import",
8867 "url(" + JSON.stringify(rule2.href) + ")"
8868 ];
8869 if (rule2.layerName === "") {
8870 statement.push("layer");
8871 } else if (rule2.layerName) {
8872 statement.push("layer(" + rule2.layerName + ")");
8873 }
8874 if (rule2.supportsText) {
8875 statement.push("supports(" + rule2.supportsText + ")");
8876 }
8877 if (rule2.media.length) {
8878 statement.push(rule2.media.mediaText);
8879 }
8880 return statement.join(" ") + ";";
8881 }
8882 function stringifyStylesheet(s2) {
8883 try {
8884 var rules2 = s2.rules || s2.cssRules;
8885 if (!rules2) {
8886 return null;
8887 }
8888 var sheetHref = s2.href;
8889 if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
8890 sheetHref = s2.ownerNode.ownerDocument.location.href;
8891 }
8892 var stringifiedRules = Array.from(rules2, function(rule2) {
8893 return stringifyRule(rule2, sheetHref);
8894 }).join("");
8895 return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
8896 } catch (error) {
8897 return null;
8898 }
8899 }
8900 function stringifyRule(rule2, sheetHref) {
8901 if (isCSSImportRule(rule2)) {
8902 var importStringified;
8903 try {
8904 importStringified = // we can access the imported stylesheet rules directly
8905 stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
8906 escapeImportStatement(rule2);
8907 } catch (error) {
8908 importStringified = rule2.cssText;
8909 }
8910 if (rule2.styleSheet.href) {
8911 return absolutifyURLs(importStringified, rule2.styleSheet.href);
8912 }
8913 return importStringified;
8914 } else {
8915 var ruleStringified = rule2.cssText;
8916 if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
8917 ruleStringified = fixSafariColons(ruleStringified);
8918 }
8919 if (sheetHref) {
8920 return absolutifyURLs(ruleStringified, sheetHref);
8921 }
8922 return ruleStringified;
8923 }
8924 }
8925 function fixSafariColons(cssStringified) {
8926 var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
8927 return cssStringified.replace(regex, "$1\\$2");
8928 }
8929 function isCSSImportRule(rule2) {
8930 return "styleSheet" in rule2;
8931 }
8932 function isCSSStyleRule(rule2) {
8933 return "selectorText" in rule2;
8934 }
8935 var Mirror = /*#__PURE__*/ function() {
8936 function Mirror() {
8937 __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
8938 __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
8939 }
8940 var _proto = Mirror.prototype;
8941 _proto.getId = function getId(n2) {
8942 var _a2;
8943 if (!n2) return -1;
8944 var id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id;
8945 return id != null ? id : -1;
8946 };
8947 _proto.getNode = function getNode(id) {
8948 return this.idNodeMap.get(id) || null;
8949 };
8950 _proto.getIds = function getIds() {
8951 return Array.from(this.idNodeMap.keys());
8952 };
8953 _proto.getMeta = function getMeta(n2) {
8954 return this.nodeMetaMap.get(n2) || null;
8955 };
8956 // removes the node from idNodeMap
8957 // doesn't remove the node from nodeMetaMap
8958 _proto.removeNodeFromMap = function removeNodeFromMap(n2) {
8959 var _this = this;
8960 var id = this.getId(n2);
8961 this.idNodeMap.delete(id);
8962 if (n2.childNodes) {
8963 n2.childNodes.forEach(function(childNode) {
8964 return _this.removeNodeFromMap(childNode);
8965 });
8966 }
8967 };
8968 _proto.has = function has(id) {
8969 return this.idNodeMap.has(id);
8970 };
8971 _proto.hasNode = function hasNode(node2) {
8972 return this.nodeMetaMap.has(node2);
8973 };
8974 _proto.add = function add(n2, meta) {
8975 var id = meta.id;
8976 this.idNodeMap.set(id, n2);
8977 this.nodeMetaMap.set(n2, meta);
8978 };
8979 _proto.replace = function replace(id, n2) {
8980 var oldNode = this.getNode(id);
8981 if (oldNode) {
8982 var meta = this.nodeMetaMap.get(oldNode);
8983 if (meta) this.nodeMetaMap.set(n2, meta);
8984 }
8985 this.idNodeMap.set(id, n2);
8986 };
8987 _proto.reset = function reset() {
8988 this.idNodeMap = /* @__PURE__ */ new Map();
8989 this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
8990 };
8991 return Mirror;
8992 }();
8993 function createMirror$2() {
8994 return new Mirror();
8995 }
8996 function maskInputValue(param) {
8997 var element = param.element, maskInputOptions = param.maskInputOptions, tagName = param.tagName, type = param.type, value = param.value, maskInputFn = param.maskInputFn;
8998 var text = value || "";
8999 var actualType = type && toLowerCase(type);
9000 if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
9001 if (maskInputFn) {
9002 text = maskInputFn(text, element);
9003 } else {
9004 text = "*".repeat(text.length);
9005 }
9006 }
9007 return text;
9008 }
9009 function toLowerCase(str) {
9010 return str.toLowerCase();
9011 }
9012 var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
9013 function is2DCanvasBlank(canvas) {
9014 var ctx = canvas.getContext("2d");
9015 if (!ctx) return true;
9016 var chunkSize = 50;
9017 for(var x2 = 0; x2 < canvas.width; x2 += chunkSize){
9018 for(var y = 0; y < canvas.height; y += chunkSize){
9019 var getImageData = ctx.getImageData;
9020 var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
9021 var pixelBuffer = new Uint32Array(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
9022 originalGetImageData.call(ctx, x2, y, Math.min(chunkSize, canvas.width - x2), Math.min(chunkSize, canvas.height - y)).data.buffer);
9023 if (pixelBuffer.some(function(pixel) {
9024 return pixel !== 0;
9025 })) return false;
9026 }
9027 }
9028 return true;
9029 }
9030 function getInputType(element) {
9031 var type = element.type;
9032 return element.hasAttribute("data-rr-is-password") ? "password" : type ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
9033 toLowerCase(type) : null;
9034 }
9035 function extractFileExtension(path, baseURL) {
9036 var url;
9037 try {
9038 url = new URL(path, baseURL != null ? baseURL : window.location.href);
9039 } catch (err) {
9040 return null;
9041 }
9042 var regex = /\.([0-9a-z]+)(?:$)/i;
9043 var match = url.pathname.match(regex);
9044 var _ref;
9045 return (_ref = match == null ? void 0 : match[1]) != null ? _ref : null;
9046 }
9047 function extractOrigin(url) {
9048 var origin = "";
9049 if (url.indexOf("//") > -1) {
9050 origin = url.split("/").slice(0, 3).join("/");
9051 } else {
9052 origin = url.split("/")[0];
9053 }
9054 origin = origin.split("?")[0];
9055 return origin;
9056 }
9057 var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
9058 var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
9059 var URL_WWW_MATCH = /^www\..*/i;
9060 var DATA_URI = /^(data:)([^,]*),(.*)/i;
9061 function absolutifyURLs(cssText, href) {
9062 return (cssText || "").replace(URL_IN_CSS_REF, function(origin, quote1, path1, quote2, path2, path3) {
9063 var filePath = path1 || path2 || path3;
9064 var maybeQuote = quote1 || quote2 || "";
9065 if (!filePath) {
9066 return origin;
9067 }
9068 if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
9069 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9070 }
9071 if (DATA_URI.test(filePath)) {
9072 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9073 }
9074 if (filePath[0] === "/") {
9075 return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
9076 }
9077 var stack = href.split("/");
9078 var parts = filePath.split("/");
9079 stack.pop();
9080 for(var _iterator = _create_for_of_iterator_helper_loose(parts), _step; !(_step = _iterator()).done;){
9081 var part = _step.value;
9082 if (part === ".") {
9083 continue;
9084 } else if (part === "..") {
9085 stack.pop();
9086 } else {
9087 stack.push(part);
9088 }
9089 }
9090 return "url(" + maybeQuote + stack.join("/") + maybeQuote + ")";
9091 });
9092 }
9093 function normalizeCssString(cssText, _testNoPxNorm) {
9094 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9095 if (_testNoPxNorm) {
9096 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
9097 } else {
9098 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
9099 }
9100 }
9101 function splitCssText(cssText, style, _testNoPxNorm) {
9102 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9103 var childNodes2 = Array.from(style.childNodes);
9104 var splits = [];
9105 var iterCount = 0;
9106 if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
9107 var cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
9108 var normFactor = cssTextNorm.length / cssText.length;
9109 for(var i2 = 1; i2 < childNodes2.length; i2++){
9110 if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
9111 var textContentNorm = normalizeCssString(childNodes2[i2].textContent, _testNoPxNorm);
9112 var jLimit = 100;
9113 var j = 3;
9114 for(; j < textContentNorm.length; j++){
9115 if (// keep consuming css identifiers (to get a decent chunk more quickly)
9116 textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
9117 textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1) {
9118 continue;
9119 }
9120 break;
9121 }
9122 for(; j < textContentNorm.length; j++){
9123 var startSubstring = textContentNorm.substring(0, j);
9124 var cssNormSplits = cssTextNorm.split(startSubstring);
9125 var splitNorm = -1;
9126 if (cssNormSplits.length === 2) {
9127 splitNorm = cssNormSplits[0].length;
9128 } else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
9129 splitNorm = cssTextNorm.indexOf(startSubstring, 1);
9130 } else if (cssNormSplits.length === 1) {
9131 startSubstring = startSubstring.substring(0, startSubstring.length - 1);
9132 cssNormSplits = cssTextNorm.split(startSubstring);
9133 if (cssNormSplits.length <= 1) {
9134 splits.push(cssText);
9135 return splits;
9136 }
9137 j = jLimit + 1;
9138 } else if (j === textContentNorm.length - 1) {
9139 splitNorm = cssTextNorm.indexOf(startSubstring);
9140 }
9141 if (cssNormSplits.length >= 2 && j > jLimit) {
9142 var prevTextContent = childNodes2[i2 - 1].textContent;
9143 if (prevTextContent && typeof prevTextContent === "string") {
9144 var prevMinLength = normalizeCssString(prevTextContent).length;
9145 splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
9146 }
9147 if (splitNorm === -1) {
9148 splitNorm = cssNormSplits[0].length;
9149 }
9150 }
9151 if (splitNorm !== -1) {
9152 var k = Math.floor(splitNorm / normFactor);
9153 for(; k > 0 && k < cssText.length;){
9154 iterCount += 1;
9155 if (iterCount > 50 * childNodes2.length) {
9156 splits.push(cssText);
9157 return splits;
9158 }
9159 var normPart = normalizeCssString(cssText.substring(0, k), _testNoPxNorm);
9160 if (normPart.length === splitNorm) {
9161 splits.push(cssText.substring(0, k));
9162 cssText = cssText.substring(k);
9163 cssTextNorm = cssTextNorm.substring(splitNorm);
9164 break;
9165 } else if (normPart.length < splitNorm) {
9166 k += Math.max(1, Math.floor((splitNorm - normPart.length) / normFactor));
9167 } else {
9168 k -= Math.max(1, Math.floor((normPart.length - splitNorm) * normFactor));
9169 }
9170 }
9171 break;
9172 }
9173 }
9174 }
9175 }
9176 }
9177 splits.push(cssText);
9178 return splits;
9179 }
9180 function markCssSplits(cssText, style) {
9181 return splitCssText(cssText, style).join("/* rr_split */");
9182 }
9183 var _id = 1;
9184 var tagNameRegex = new RegExp("[^a-z0-9-_:]");
9185 var IGNORED_NODE = -2;
9186 function genId() {
9187 return _id++;
9188 }
9189 function getValidTagName$1(element) {
9190 if (_instanceof(element, HTMLFormElement)) {
9191 return "form";
9192 }
9193 var processedTagName = toLowerCase(element.tagName);
9194 if (tagNameRegex.test(processedTagName)) {
9195 return "div";
9196 }
9197 return processedTagName;
9198 }
9199 var canvasService;
9200 var canvasCtx;
9201 var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
9202 var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
9203 function getAbsoluteSrcsetString(doc, attributeValue) {
9204 if (attributeValue.trim() === "") {
9205 return attributeValue;
9206 }
9207 var pos = 0;
9208 function collectCharacters(regEx) {
9209 var chars2;
9210 var match = regEx.exec(attributeValue.substring(pos));
9211 if (match) {
9212 chars2 = match[0];
9213 pos += chars2.length;
9214 return chars2;
9215 }
9216 return "";
9217 }
9218 var output = [];
9219 while(true){
9220 collectCharacters(SRCSET_COMMAS_OR_SPACES);
9221 if (pos >= attributeValue.length) {
9222 break;
9223 }
9224 var url = collectCharacters(SRCSET_NOT_SPACES);
9225 if (url.slice(-1) === ",") {
9226 url = absoluteToDoc(doc, url.substring(0, url.length - 1));
9227 output.push(url);
9228 } else {
9229 var descriptorsStr = "";
9230 url = absoluteToDoc(doc, url);
9231 var inParens = false;
9232 while(true){
9233 var c2 = attributeValue.charAt(pos);
9234 if (c2 === "") {
9235 output.push((url + descriptorsStr).trim());
9236 break;
9237 } else if (!inParens) {
9238 if (c2 === ",") {
9239 pos += 1;
9240 output.push((url + descriptorsStr).trim());
9241 break;
9242 } else if (c2 === "(") {
9243 inParens = true;
9244 }
9245 } else {
9246 if (c2 === ")") {
9247 inParens = false;
9248 }
9249 }
9250 descriptorsStr += c2;
9251 pos += 1;
9252 }
9253 }
9254 }
9255 return output.join(", ");
9256 }
9257 var cachedDocument = /* @__PURE__ */ new WeakMap();
9258 function absoluteToDoc(doc, attributeValue) {
9259 if (!attributeValue || attributeValue.trim() === "") {
9260 return attributeValue;
9261 }
9262 return getHref(doc, attributeValue);
9263 }
9264 function isSVGElement(el) {
9265 return Boolean(el.tagName === "svg" || el.ownerSVGElement);
9266 }
9267 function getHref(doc, customHref) {
9268 var a2 = cachedDocument.get(doc);
9269 if (!a2) {
9270 a2 = doc.createElement("a");
9271 cachedDocument.set(doc, a2);
9272 }
9273 if (!customHref) {
9274 customHref = "";
9275 } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
9276 return customHref;
9277 }
9278 a2.setAttribute("href", customHref);
9279 return a2.href;
9280 }
9281 function transformAttribute(doc, tagName, name, value) {
9282 if (!value) {
9283 return value;
9284 }
9285 if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
9286 return absoluteToDoc(doc, value);
9287 } else if (name === "xlink:href" && value[0] !== "#") {
9288 return absoluteToDoc(doc, value);
9289 } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
9290 return absoluteToDoc(doc, value);
9291 } else if (name === "srcset") {
9292 return getAbsoluteSrcsetString(doc, value);
9293 } else if (name === "style") {
9294 return absolutifyURLs(value, getHref(doc));
9295 } else if (tagName === "object" && name === "data") {
9296 return absoluteToDoc(doc, value);
9297 }
9298 return value;
9299 }
9300 function ignoreAttribute(tagName, name, _value) {
9301 return (tagName === "video" || tagName === "audio") && name === "autoplay";
9302 }
9303 function _isBlockedElement(element, blockClass, blockSelector) {
9304 try {
9305 if (typeof blockClass === "string") {
9306 if (element.classList.contains(blockClass)) {
9307 return true;
9308 }
9309 } else {
9310 for(var eIndex = element.classList.length; eIndex--;){
9311 var className = element.classList[eIndex];
9312 if (blockClass.test(className)) {
9313 return true;
9314 }
9315 }
9316 }
9317 if (blockSelector) {
9318 return element.matches(blockSelector);
9319 }
9320 } catch (e2) {}
9321 return false;
9322 }
9323 function classMatchesRegex(node2, regex, checkAncestors) {
9324 if (!node2) return false;
9325 if (node2.nodeType !== node2.ELEMENT_NODE) {
9326 if (!checkAncestors) return false;
9327 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9328 }
9329 for(var eIndex = node2.classList.length; eIndex--;){
9330 var className = node2.classList[eIndex];
9331 if (regex.test(className)) {
9332 return true;
9333 }
9334 }
9335 if (!checkAncestors) return false;
9336 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9337 }
9338 function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
9339 var el;
9340 if (isElement(node2)) {
9341 el = node2;
9342 if (!index$1.childNodes(el).length) {
9343 return false;
9344 }
9345 } else if (index$1.parentElement(node2) === null) {
9346 return false;
9347 } else {
9348 el = index$1.parentElement(node2);
9349 }
9350 try {
9351 if (typeof maskTextClass === "string") {
9352 if (checkAncestors) {
9353 if (el.closest("." + maskTextClass)) return true;
9354 } else {
9355 if (el.classList.contains(maskTextClass)) return true;
9356 }
9357 } else {
9358 if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
9359 }
9360 if (maskTextSelector) {
9361 if (checkAncestors) {
9362 if (el.closest(maskTextSelector)) return true;
9363 } else {
9364 if (el.matches(maskTextSelector)) return true;
9365 }
9366 }
9367 } catch (e2) {}
9368 return false;
9369 }
9370 function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
9371 var win = iframeEl.contentWindow;
9372 if (!win) {
9373 return;
9374 }
9375 var fired = false;
9376 var readyState;
9377 try {
9378 readyState = win.document.readyState;
9379 } catch (error) {
9380 return;
9381 }
9382 if (readyState !== "complete") {
9383 var timer = setTimeout(function() {
9384 if (!fired) {
9385 listener();
9386 fired = true;
9387 }
9388 }, iframeLoadTimeout);
9389 iframeEl.addEventListener("load", function() {
9390 clearTimeout(timer);
9391 fired = true;
9392 listener();
9393 });
9394 return;
9395 }
9396 var blankUrl = "about:blank";
9397 if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
9398 setTimeout(listener, 0);
9399 return iframeEl.addEventListener("load", listener);
9400 }
9401 iframeEl.addEventListener("load", listener);
9402 }
9403 function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
9404 var fired = false;
9405 var styleSheetLoaded;
9406 try {
9407 styleSheetLoaded = link.sheet;
9408 } catch (error) {
9409 return;
9410 }
9411 if (styleSheetLoaded) return;
9412 var timer = setTimeout(function() {
9413 if (!fired) {
9414 listener();
9415 fired = true;
9416 }
9417 }, styleSheetLoadTimeout);
9418 link.addEventListener("load", function() {
9419 clearTimeout(timer);
9420 fired = true;
9421 listener();
9422 });
9423 }
9424 function serializeNode(n2, options) {
9425 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;
9426 var rootId = getRootId(doc, mirror2);
9427 switch(n2.nodeType){
9428 case n2.DOCUMENT_NODE:
9429 if (n2.compatMode !== "CSS1Compat") {
9430 return {
9431 type: NodeType$3.Document,
9432 childNodes: [],
9433 compatMode: n2.compatMode
9434 };
9435 } else {
9436 return {
9437 type: NodeType$3.Document,
9438 childNodes: []
9439 };
9440 }
9441 case n2.DOCUMENT_TYPE_NODE:
9442 return {
9443 type: NodeType$3.DocumentType,
9444 name: n2.name,
9445 publicId: n2.publicId,
9446 systemId: n2.systemId,
9447 rootId: rootId
9448 };
9449 case n2.ELEMENT_NODE:
9450 return serializeElementNode(n2, {
9451 doc: doc,
9452 blockClass: blockClass,
9453 blockSelector: blockSelector,
9454 inlineStylesheet: inlineStylesheet,
9455 maskInputOptions: maskInputOptions,
9456 maskInputFn: maskInputFn,
9457 dataURLOptions: dataURLOptions,
9458 inlineImages: inlineImages,
9459 recordCanvas: recordCanvas,
9460 keepIframeSrcFn: keepIframeSrcFn,
9461 newlyAddedElement: newlyAddedElement,
9462 rootId: rootId
9463 });
9464 case n2.TEXT_NODE:
9465 return serializeTextNode(n2, {
9466 doc: doc,
9467 needsMask: needsMask,
9468 maskTextFn: maskTextFn,
9469 rootId: rootId,
9470 cssCaptured: cssCaptured
9471 });
9472 case n2.CDATA_SECTION_NODE:
9473 return {
9474 type: NodeType$3.CDATA,
9475 textContent: "",
9476 rootId: rootId
9477 };
9478 case n2.COMMENT_NODE:
9479 return {
9480 type: NodeType$3.Comment,
9481 textContent: index$1.textContent(n2) || "",
9482 rootId: rootId
9483 };
9484 default:
9485 return false;
9486 }
9487 }
9488 function getRootId(doc, mirror2) {
9489 if (!mirror2.hasNode(doc)) return void 0;
9490 var docId = mirror2.getId(doc);
9491 return docId === 1 ? void 0 : docId;
9492 }
9493 function serializeTextNode(n2, options) {
9494 var needsMask = options.needsMask, maskTextFn = options.maskTextFn, rootId = options.rootId, cssCaptured = options.cssCaptured;
9495 var parent = index$1.parentNode(n2);
9496 var parentTagName = parent && parent.tagName;
9497 var textContent2 = "";
9498 var isStyle = parentTagName === "STYLE" ? true : void 0;
9499 var isScript = parentTagName === "SCRIPT" ? true : void 0;
9500 if (isScript) {
9501 textContent2 = "SCRIPT_PLACEHOLDER";
9502 } else if (!cssCaptured) {
9503 textContent2 = index$1.textContent(n2);
9504 if (isStyle && textContent2) {
9505 textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
9506 }
9507 }
9508 if (!isStyle && !isScript && textContent2 && needsMask) {
9509 textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
9510 }
9511 return {
9512 type: NodeType$3.Text,
9513 textContent: textContent2 || "",
9514 rootId: rootId
9515 };
9516 }
9517 function serializeElementNode(n2, options) {
9518 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;
9519 var needBlock = _isBlockedElement(n2, blockClass, blockSelector);
9520 var tagName = getValidTagName$1(n2);
9521 var attributes = {};
9522 var len = n2.attributes.length;
9523 for(var i2 = 0; i2 < len; i2++){
9524 var attr = n2.attributes[i2];
9525 if (!ignoreAttribute(tagName, attr.name, attr.value)) {
9526 attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
9527 }
9528 }
9529 if (tagName === "link" && inlineStylesheet) {
9530 var stylesheet = Array.from(doc.styleSheets).find(function(s2) {
9531 return s2.href === n2.href;
9532 });
9533 var cssText = null;
9534 if (stylesheet) {
9535 cssText = stringifyStylesheet(stylesheet);
9536 }
9537 if (cssText) {
9538 delete attributes.rel;
9539 delete attributes.href;
9540 attributes._cssText = cssText;
9541 }
9542 }
9543 if (tagName === "style" && n2.sheet) {
9544 var cssText1 = stringifyStylesheet(n2.sheet);
9545 if (cssText1) {
9546 if (n2.childNodes.length > 1) {
9547 cssText1 = markCssSplits(cssText1, n2);
9548 }
9549 attributes._cssText = cssText1;
9550 }
9551 }
9552 if (tagName === "input" || tagName === "textarea" || tagName === "select") {
9553 var value = n2.value;
9554 var checked = n2.checked;
9555 if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
9556 attributes.value = maskInputValue({
9557 element: n2,
9558 type: getInputType(n2),
9559 tagName: tagName,
9560 value: value,
9561 maskInputOptions: maskInputOptions,
9562 maskInputFn: maskInputFn
9563 });
9564 } else if (checked) {
9565 attributes.checked = checked;
9566 }
9567 }
9568 if (tagName === "option") {
9569 if (n2.selected && !maskInputOptions["select"]) {
9570 attributes.selected = true;
9571 } else {
9572 delete attributes.selected;
9573 }
9574 }
9575 if (tagName === "dialog" && n2.open) {
9576 attributes.rr_open_mode = n2.matches("dialog:modal") ? "modal" : "non-modal";
9577 }
9578 if (tagName === "canvas" && recordCanvas) {
9579 if (n2.__context === "2d") {
9580 if (!is2DCanvasBlank(n2)) {
9581 attributes.rr_dataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9582 }
9583 } else if (!("__context" in n2)) {
9584 var canvasDataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9585 var blankCanvas = doc.createElement("canvas");
9586 blankCanvas.width = n2.width;
9587 blankCanvas.height = n2.height;
9588 var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9589 if (canvasDataURL !== blankCanvasDataURL) {
9590 attributes.rr_dataURL = canvasDataURL;
9591 }
9592 }
9593 }
9594 if (tagName === "img" && inlineImages) {
9595 if (!canvasService) {
9596 canvasService = doc.createElement("canvas");
9597 canvasCtx = canvasService.getContext("2d");
9598 }
9599 var image = n2;
9600 var imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
9601 var priorCrossOrigin = image.crossOrigin;
9602 var recordInlineImage = function() {
9603 image.removeEventListener("load", recordInlineImage);
9604 try {
9605 canvasService.width = image.naturalWidth;
9606 canvasService.height = image.naturalHeight;
9607 canvasCtx.drawImage(image, 0, 0);
9608 attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9609 } catch (err) {
9610 if (image.crossOrigin !== "anonymous") {
9611 image.crossOrigin = "anonymous";
9612 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
9613 else image.addEventListener("load", recordInlineImage);
9614 return;
9615 } else {
9616 console.warn("Cannot inline img src=" + imageSrc + "! Error: " + err);
9617 }
9618 }
9619 if (image.crossOrigin === "anonymous") {
9620 priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
9621 }
9622 };
9623 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
9624 else image.addEventListener("load", recordInlineImage);
9625 }
9626 if (tagName === "audio" || tagName === "video") {
9627 var mediaAttributes = attributes;
9628 mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
9629 mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
9630 mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
9631 mediaAttributes.rr_mediaMuted = n2.muted;
9632 mediaAttributes.rr_mediaLoop = n2.loop;
9633 mediaAttributes.rr_mediaVolume = n2.volume;
9634 }
9635 if (!newlyAddedElement) {
9636 if (n2.scrollLeft) {
9637 attributes.rr_scrollLeft = n2.scrollLeft;
9638 }
9639 if (n2.scrollTop) {
9640 attributes.rr_scrollTop = n2.scrollTop;
9641 }
9642 }
9643 if (needBlock) {
9644 var _n2_getBoundingClientRect = n2.getBoundingClientRect(), width = _n2_getBoundingClientRect.width, height = _n2_getBoundingClientRect.height;
9645 attributes = {
9646 class: attributes.class,
9647 rr_width: "" + width + "px",
9648 rr_height: "" + height + "px"
9649 };
9650 }
9651 if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
9652 if (!n2.contentDocument) {
9653 attributes.rr_src = attributes.src;
9654 }
9655 delete attributes.src;
9656 }
9657 var isCustomElement;
9658 try {
9659 if (customElements.get(tagName)) isCustomElement = true;
9660 } catch (e2) {}
9661 return {
9662 type: NodeType$3.Element,
9663 tagName: tagName,
9664 attributes: attributes,
9665 childNodes: [],
9666 isSVG: isSVGElement(n2) || void 0,
9667 needBlock: needBlock,
9668 rootId: rootId,
9669 isCustom: isCustomElement
9670 };
9671 }
9672 function lowerIfExists(maybeAttr) {
9673 if (maybeAttr === void 0 || maybeAttr === null) {
9674 return "";
9675 } else {
9676 return maybeAttr.toLowerCase();
9677 }
9678 }
9679 function slimDOMExcluded(sn, slimDOMOptions) {
9680 if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
9681 return true;
9682 } else if (sn.type === NodeType$3.Element) {
9683 if (slimDOMOptions.script && // script tag
9684 (sn.tagName === "script" || // (module)preload link
9685 sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
9686 sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
9687 return true;
9688 } 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"))) {
9689 return true;
9690 } else if (sn.tagName === "meta") {
9691 if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
9692 return true;
9693 } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
9694 lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
9695 return true;
9696 } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
9697 return true;
9698 } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
9699 return true;
9700 } 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:/))) {
9701 return true;
9702 } 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")) {
9703 return true;
9704 }
9705 }
9706 }
9707 return false;
9708 }
9709 function serializeNodeWithId(n2, options) {
9710 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() {
9711 return false;
9712 } : _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;
9713 var needsMask = options.needsMask;
9714 var _options_preserveWhiteSpace = options.preserveWhiteSpace, preserveWhiteSpace = _options_preserveWhiteSpace === void 0 ? true : _options_preserveWhiteSpace;
9715 if (!needsMask) {
9716 var checkAncestors = needsMask === void 0;
9717 needsMask = needMaskingText(n2, maskTextClass, maskTextSelector, checkAncestors);
9718 }
9719 var _serializedNode = serializeNode(n2, {
9720 doc: doc,
9721 mirror: mirror2,
9722 blockClass: blockClass,
9723 blockSelector: blockSelector,
9724 needsMask: needsMask,
9725 inlineStylesheet: inlineStylesheet,
9726 maskInputOptions: maskInputOptions,
9727 maskTextFn: maskTextFn,
9728 maskInputFn: maskInputFn,
9729 dataURLOptions: dataURLOptions,
9730 inlineImages: inlineImages,
9731 recordCanvas: recordCanvas,
9732 keepIframeSrcFn: keepIframeSrcFn,
9733 newlyAddedElement: newlyAddedElement,
9734 cssCaptured: cssCaptured
9735 });
9736 if (!_serializedNode) {
9737 console.warn(n2, "not serialized");
9738 return null;
9739 }
9740 var id;
9741 if (mirror2.hasNode(n2)) {
9742 id = mirror2.getId(n2);
9743 } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
9744 id = IGNORED_NODE;
9745 } else {
9746 id = genId();
9747 }
9748 var serializedNode = Object.assign(_serializedNode, {
9749 id: id
9750 });
9751 mirror2.add(n2, serializedNode);
9752 if (id === IGNORED_NODE) {
9753 return null;
9754 }
9755 if (onSerialize) {
9756 onSerialize(n2);
9757 }
9758 var recordChild = !skipChild;
9759 if (serializedNode.type === NodeType$3.Element) {
9760 recordChild = recordChild && !serializedNode.needBlock;
9761 delete serializedNode.needBlock;
9762 var shadowRootEl = index$1.shadowRoot(n2);
9763 if (shadowRootEl && isNativeShadowDom(shadowRootEl)) serializedNode.isShadowHost = true;
9764 }
9765 if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
9766 if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
9767 preserveWhiteSpace = false;
9768 }
9769 var bypassOptions = {
9770 doc: doc,
9771 mirror: mirror2,
9772 blockClass: blockClass,
9773 blockSelector: blockSelector,
9774 needsMask: needsMask,
9775 maskTextClass: maskTextClass,
9776 maskTextSelector: maskTextSelector,
9777 skipChild: skipChild,
9778 inlineStylesheet: inlineStylesheet,
9779 maskInputOptions: maskInputOptions,
9780 maskTextFn: maskTextFn,
9781 maskInputFn: maskInputFn,
9782 slimDOMOptions: slimDOMOptions,
9783 dataURLOptions: dataURLOptions,
9784 inlineImages: inlineImages,
9785 recordCanvas: recordCanvas,
9786 preserveWhiteSpace: preserveWhiteSpace,
9787 onSerialize: onSerialize,
9788 onIframeLoad: onIframeLoad,
9789 iframeLoadTimeout: iframeLoadTimeout,
9790 onStylesheetLoad: onStylesheetLoad,
9791 stylesheetLoadTimeout: stylesheetLoadTimeout,
9792 keepIframeSrcFn: keepIframeSrcFn,
9793 cssCaptured: false
9794 };
9795 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
9796 else {
9797 if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
9798 bypassOptions.cssCaptured = true;
9799 }
9800 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(n2))), _step; !(_step = _iterator()).done;){
9801 var childN = _step.value;
9802 var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
9803 if (serializedChildNode) {
9804 serializedNode.childNodes.push(serializedChildNode);
9805 }
9806 }
9807 }
9808 var shadowRootEl1 = null;
9809 if (isElement(n2) && (shadowRootEl1 = index$1.shadowRoot(n2))) {
9810 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(shadowRootEl1))), _step1; !(_step1 = _iterator1()).done;){
9811 var childN1 = _step1.value;
9812 var serializedChildNode1 = serializeNodeWithId(childN1, bypassOptions);
9813 if (serializedChildNode1) {
9814 isNativeShadowDom(shadowRootEl1) && (serializedChildNode1.isShadow = true);
9815 serializedNode.childNodes.push(serializedChildNode1);
9816 }
9817 }
9818 }
9819 }
9820 var parent = index$1.parentNode(n2);
9821 if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
9822 serializedNode.isShadow = true;
9823 }
9824 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
9825 onceIframeLoaded(n2, function() {
9826 var iframeDoc = n2.contentDocument;
9827 if (iframeDoc && onIframeLoad) {
9828 var serializedIframeNode = serializeNodeWithId(iframeDoc, {
9829 doc: iframeDoc,
9830 mirror: mirror2,
9831 blockClass: blockClass,
9832 blockSelector: blockSelector,
9833 needsMask: needsMask,
9834 maskTextClass: maskTextClass,
9835 maskTextSelector: maskTextSelector,
9836 skipChild: false,
9837 inlineStylesheet: inlineStylesheet,
9838 maskInputOptions: maskInputOptions,
9839 maskTextFn: maskTextFn,
9840 maskInputFn: maskInputFn,
9841 slimDOMOptions: slimDOMOptions,
9842 dataURLOptions: dataURLOptions,
9843 inlineImages: inlineImages,
9844 recordCanvas: recordCanvas,
9845 preserveWhiteSpace: preserveWhiteSpace,
9846 onSerialize: onSerialize,
9847 onIframeLoad: onIframeLoad,
9848 iframeLoadTimeout: iframeLoadTimeout,
9849 onStylesheetLoad: onStylesheetLoad,
9850 stylesheetLoadTimeout: stylesheetLoadTimeout,
9851 keepIframeSrcFn: keepIframeSrcFn
9852 });
9853 if (serializedIframeNode) {
9854 onIframeLoad(n2, serializedIframeNode);
9855 }
9856 }
9857 }, iframeLoadTimeout);
9858 }
9859 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")) {
9860 onceStylesheetLoaded(n2, function() {
9861 if (onStylesheetLoad) {
9862 var serializedLinkNode = serializeNodeWithId(n2, {
9863 doc: doc,
9864 mirror: mirror2,
9865 blockClass: blockClass,
9866 blockSelector: blockSelector,
9867 needsMask: needsMask,
9868 maskTextClass: maskTextClass,
9869 maskTextSelector: maskTextSelector,
9870 skipChild: false,
9871 inlineStylesheet: inlineStylesheet,
9872 maskInputOptions: maskInputOptions,
9873 maskTextFn: maskTextFn,
9874 maskInputFn: maskInputFn,
9875 slimDOMOptions: slimDOMOptions,
9876 dataURLOptions: dataURLOptions,
9877 inlineImages: inlineImages,
9878 recordCanvas: recordCanvas,
9879 preserveWhiteSpace: preserveWhiteSpace,
9880 onSerialize: onSerialize,
9881 onIframeLoad: onIframeLoad,
9882 iframeLoadTimeout: iframeLoadTimeout,
9883 onStylesheetLoad: onStylesheetLoad,
9884 stylesheetLoadTimeout: stylesheetLoadTimeout,
9885 keepIframeSrcFn: keepIframeSrcFn
9886 });
9887 if (serializedLinkNode) {
9888 onStylesheetLoad(n2, serializedLinkNode);
9889 }
9890 }
9891 }, stylesheetLoadTimeout);
9892 }
9893 return serializedNode;
9894 }
9895 function snapshot(n2, options) {
9896 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() {
9897 return false;
9898 } : _ref_keepIframeSrcFn;
9899 var maskInputOptions = maskAllInputs === true ? {
9900 color: true,
9901 date: true,
9902 "datetime-local": true,
9903 email: true,
9904 month: true,
9905 number: true,
9906 range: true,
9907 search: true,
9908 tel: true,
9909 text: true,
9910 time: true,
9911 url: true,
9912 week: true,
9913 textarea: true,
9914 select: true,
9915 password: true,
9916 hidden: true
9917 } : maskAllInputs === false ? {
9918 password: true
9919 } : maskAllInputs;
9920 var slimDOMOptions = slimDOM === true || slimDOM === "all" ? // if true: set of sensible options that should not throw away any information
9921 {
9922 script: true,
9923 comment: true,
9924 headFavicon: true,
9925 headWhitespace: true,
9926 headMetaDescKeywords: slimDOM === "all",
9927 // destructive
9928 headMetaSocial: true,
9929 headMetaRobots: true,
9930 headMetaHttpEquiv: true,
9931 headMetaAuthorship: true,
9932 headMetaVerification: true
9933 } : slimDOM === false ? {} : slimDOM;
9934 return serializeNodeWithId(n2, {
9935 doc: n2,
9936 mirror: mirror2,
9937 blockClass: blockClass,
9938 blockSelector: blockSelector,
9939 maskTextClass: maskTextClass,
9940 maskTextSelector: maskTextSelector,
9941 skipChild: false,
9942 inlineStylesheet: inlineStylesheet,
9943 maskInputOptions: maskInputOptions,
9944 maskTextFn: maskTextFn,
9945 maskInputFn: maskInputFn,
9946 slimDOMOptions: slimDOMOptions,
9947 dataURLOptions: dataURLOptions,
9948 inlineImages: inlineImages,
9949 recordCanvas: recordCanvas,
9950 preserveWhiteSpace: preserveWhiteSpace,
9951 onSerialize: onSerialize,
9952 onIframeLoad: onIframeLoad,
9953 iframeLoadTimeout: iframeLoadTimeout,
9954 onStylesheetLoad: onStylesheetLoad,
9955 stylesheetLoadTimeout: stylesheetLoadTimeout,
9956 keepIframeSrcFn: keepIframeSrcFn,
9957 newlyAddedElement: false
9958 });
9959 }
9960 function getDefaultExportFromCjs$1(x2) {
9961 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
9962 }
9963 function getAugmentedNamespace$1(n2) {
9964 if (n2.__esModule) return n2;
9965 var f2 = n2.default;
9966 if (typeof f2 == "function") {
9967 var a2 = function a22() {
9968 if (_instanceof(this, a22)) {
9969 return Reflect.construct(f2, arguments, this.constructor);
9970 }
9971 return f2.apply(this, arguments);
9972 };
9973 a2.prototype = f2.prototype;
9974 } else a2 = {};
9975 Object.defineProperty(a2, "__esModule", {
9976 value: true
9977 });
9978 Object.keys(n2).forEach(function(k) {
9979 var d = Object.getOwnPropertyDescriptor(n2, k);
9980 Object.defineProperty(a2, k, d.get ? d : {
9981 enumerable: true,
9982 get: function get() {
9983 return n2[k];
9984 }
9985 });
9986 });
9987 return a2;
9988 }
9989 var picocolors_browser$1 = {
9990 exports: {}
9991 };
9992 var x$1 = String;
9993 var create$1 = function create$1() {
9994 return {
9995 isColorSupported: false,
9996 reset: x$1,
9997 bold: x$1,
9998 dim: x$1,
9999 italic: x$1,
10000 underline: x$1,
10001 inverse: x$1,
10002 hidden: x$1,
10003 strikethrough: x$1,
10004 black: x$1,
10005 red: x$1,
10006 green: x$1,
10007 yellow: x$1,
10008 blue: x$1,
10009 magenta: x$1,
10010 cyan: x$1,
10011 white: x$1,
10012 gray: x$1,
10013 bgBlack: x$1,
10014 bgRed: x$1,
10015 bgGreen: x$1,
10016 bgYellow: x$1,
10017 bgBlue: x$1,
10018 bgMagenta: x$1,
10019 bgCyan: x$1,
10020 bgWhite: x$1
10021 };
10022 };
10023 picocolors_browser$1.exports = create$1();
10024 picocolors_browser$1.exports.createColors = create$1;
10025 var picocolors_browserExports$1 = picocolors_browser$1.exports;
10026 var __viteBrowserExternal$2 = {};
10027 var __viteBrowserExternal$1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10028 __proto__: null,
10029 default: __viteBrowserExternal$2
10030 }, Symbol.toStringTag, {
10031 value: "Module"
10032 }));
10033 var require$$2$1 = /* @__PURE__ */ getAugmentedNamespace$1(__viteBrowserExternal$1$1);
10034 var pico$1 = picocolors_browserExports$1;
10035 var terminalHighlight$1$1 = require$$2$1;
10036 var CssSyntaxError$3$1 = /*#__PURE__*/ function(Error1) {
10037 _inherits(CssSyntaxError, Error1);
10038 function CssSyntaxError(message, line, column, source, file, plugin22) {
10039 var _this;
10040 _this = Error1.call(this, message) || this;
10041 _this.name = "CssSyntaxError";
10042 _this.reason = message;
10043 if (file) {
10044 _this.file = file;
10045 }
10046 if (source) {
10047 _this.source = source;
10048 }
10049 if (plugin22) {
10050 _this.plugin = plugin22;
10051 }
10052 if (typeof line !== "undefined" && typeof column !== "undefined") {
10053 if (typeof line === "number") {
10054 _this.line = line;
10055 _this.column = column;
10056 } else {
10057 _this.line = line.line;
10058 _this.column = line.column;
10059 _this.endLine = column.line;
10060 _this.endColumn = column.column;
10061 }
10062 }
10063 _this.setMessage();
10064 if (Error.captureStackTrace) {
10065 Error.captureStackTrace(_this, CssSyntaxError);
10066 }
10067 return _this;
10068 }
10069 var _proto = CssSyntaxError.prototype;
10070 _proto.setMessage = function setMessage() {
10071 this.message = this.plugin ? this.plugin + ": " : "";
10072 this.message += this.file ? this.file : "<css input>";
10073 if (typeof this.line !== "undefined") {
10074 this.message += ":" + this.line + ":" + this.column;
10075 }
10076 this.message += ": " + this.reason;
10077 };
10078 _proto.showSourceCode = function showSourceCode(color) {
10079 var _this = this;
10080 if (!this.source) return "";
10081 var css = this.source;
10082 if (color == null) color = pico$1.isColorSupported;
10083 if (terminalHighlight$1$1) {
10084 if (color) css = terminalHighlight$1$1(css);
10085 }
10086 var lines = css.split(/\r?\n/);
10087 var start = Math.max(this.line - 3, 0);
10088 var end = Math.min(this.line + 2, lines.length);
10089 var maxWidth = String(end).length;
10090 var mark, aside;
10091 if (color) {
10092 var _pico$1_createColors = pico$1.createColors(true), bold = _pico$1_createColors.bold, gray = _pico$1_createColors.gray, red = _pico$1_createColors.red;
10093 mark = function(text) {
10094 return bold(red(text));
10095 };
10096 aside = function(text) {
10097 return gray(text);
10098 };
10099 } else {
10100 mark = aside = function(str) {
10101 return str;
10102 };
10103 }
10104 return lines.slice(start, end).map(function(line, index2) {
10105 var number = start + 1 + index2;
10106 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
10107 if (number === _this.line) {
10108 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
10109 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
10110 }
10111 return " " + aside(gutter) + line;
10112 }).join("\n");
10113 };
10114 _proto.toString = function toString() {
10115 var code = this.showSourceCode();
10116 if (code) {
10117 code = "\n\n" + code + "\n";
10118 }
10119 return this.name + ": " + this.message + code;
10120 };
10121 return CssSyntaxError;
10122 }(_wrap_native_super(Error));
10123 var cssSyntaxError$1 = CssSyntaxError$3$1;
10124 CssSyntaxError$3$1.default = CssSyntaxError$3$1;
10125 var symbols$1 = {};
10126 symbols$1.isClean = Symbol("isClean");
10127 symbols$1.my = Symbol("my");
10128 var DEFAULT_RAW$1 = {
10129 after: "\n",
10130 beforeClose: "\n",
10131 beforeComment: "\n",
10132 beforeDecl: "\n",
10133 beforeOpen: " ",
10134 beforeRule: "\n",
10135 colon: ": ",
10136 commentLeft: " ",
10137 commentRight: " ",
10138 emptyBody: "",
10139 indent: " ",
10140 semicolon: false
10141 };
10142 function capitalize$1(str) {
10143 return str[0].toUpperCase() + str.slice(1);
10144 }
10145 var Stringifier$2$1 = /*#__PURE__*/ function() {
10146 function Stringifier(builder) {
10147 this.builder = builder;
10148 }
10149 var _proto = Stringifier.prototype;
10150 _proto.atrule = function atrule(node2, semicolon) {
10151 var name = "@" + node2.name;
10152 var params = node2.params ? this.rawValue(node2, "params") : "";
10153 if (typeof node2.raws.afterName !== "undefined") {
10154 name += node2.raws.afterName;
10155 } else if (params) {
10156 name += " ";
10157 }
10158 if (node2.nodes) {
10159 this.block(node2, name + params);
10160 } else {
10161 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
10162 this.builder(name + params + end, node2);
10163 }
10164 };
10165 _proto.beforeAfter = function beforeAfter(node2, detect) {
10166 var value;
10167 if (node2.type === "decl") {
10168 value = this.raw(node2, null, "beforeDecl");
10169 } else if (node2.type === "comment") {
10170 value = this.raw(node2, null, "beforeComment");
10171 } else if (detect === "before") {
10172 value = this.raw(node2, null, "beforeRule");
10173 } else {
10174 value = this.raw(node2, null, "beforeClose");
10175 }
10176 var buf = node2.parent;
10177 var depth = 0;
10178 while(buf && buf.type !== "root"){
10179 depth += 1;
10180 buf = buf.parent;
10181 }
10182 if (value.includes("\n")) {
10183 var indent = this.raw(node2, null, "indent");
10184 if (indent.length) {
10185 for(var step = 0; step < depth; step++)value += indent;
10186 }
10187 }
10188 return value;
10189 };
10190 _proto.block = function block(node2, start) {
10191 var between = this.raw(node2, "between", "beforeOpen");
10192 this.builder(start + between + "{", node2, "start");
10193 var after;
10194 if (node2.nodes && node2.nodes.length) {
10195 this.body(node2);
10196 after = this.raw(node2, "after");
10197 } else {
10198 after = this.raw(node2, "after", "emptyBody");
10199 }
10200 if (after) this.builder(after);
10201 this.builder("}", node2, "end");
10202 };
10203 _proto.body = function body(node2) {
10204 var last = node2.nodes.length - 1;
10205 while(last > 0){
10206 if (node2.nodes[last].type !== "comment") break;
10207 last -= 1;
10208 }
10209 var semicolon = this.raw(node2, "semicolon");
10210 for(var i2 = 0; i2 < node2.nodes.length; i2++){
10211 var child = node2.nodes[i2];
10212 var before = this.raw(child, "before");
10213 if (before) this.builder(before);
10214 this.stringify(child, last !== i2 || semicolon);
10215 }
10216 };
10217 _proto.comment = function comment(node2) {
10218 var left = this.raw(node2, "left", "commentLeft");
10219 var right = this.raw(node2, "right", "commentRight");
10220 this.builder("/*" + left + node2.text + right + "*/", node2);
10221 };
10222 _proto.decl = function decl(node2, semicolon) {
10223 var between = this.raw(node2, "between", "colon");
10224 var string = node2.prop + between + this.rawValue(node2, "value");
10225 if (node2.important) {
10226 string += node2.raws.important || " !important";
10227 }
10228 if (semicolon) string += ";";
10229 this.builder(string, node2);
10230 };
10231 _proto.document = function document1(node2) {
10232 this.body(node2);
10233 };
10234 _proto.raw = function raw(node2, own, detect) {
10235 var value;
10236 if (!detect) detect = own;
10237 if (own) {
10238 value = node2.raws[own];
10239 if (typeof value !== "undefined") return value;
10240 }
10241 var parent = node2.parent;
10242 if (detect === "before") {
10243 if (!parent || parent.type === "root" && parent.first === node2) {
10244 return "";
10245 }
10246 if (parent && parent.type === "document") {
10247 return "";
10248 }
10249 }
10250 if (!parent) return DEFAULT_RAW$1[detect];
10251 var root2 = node2.root();
10252 if (!root2.rawCache) root2.rawCache = {};
10253 if (typeof root2.rawCache[detect] !== "undefined") {
10254 return root2.rawCache[detect];
10255 }
10256 if (detect === "before" || detect === "after") {
10257 return this.beforeAfter(node2, detect);
10258 } else {
10259 var method = "raw" + capitalize$1(detect);
10260 if (this[method]) {
10261 value = this[method](root2, node2);
10262 } else {
10263 root2.walk(function(i2) {
10264 value = i2.raws[own];
10265 if (typeof value !== "undefined") return false;
10266 });
10267 }
10268 }
10269 if (typeof value === "undefined") value = DEFAULT_RAW$1[detect];
10270 root2.rawCache[detect] = value;
10271 return value;
10272 };
10273 _proto.rawBeforeClose = function rawBeforeClose(root2) {
10274 var value;
10275 root2.walk(function(i2) {
10276 if (i2.nodes && i2.nodes.length > 0) {
10277 if (typeof i2.raws.after !== "undefined") {
10278 value = i2.raws.after;
10279 if (value.includes("\n")) {
10280 value = value.replace(/[^\n]+$/, "");
10281 }
10282 return false;
10283 }
10284 }
10285 });
10286 if (value) value = value.replace(/\S/g, "");
10287 return value;
10288 };
10289 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
10290 var value;
10291 root2.walkComments(function(i2) {
10292 if (typeof i2.raws.before !== "undefined") {
10293 value = i2.raws.before;
10294 if (value.includes("\n")) {
10295 value = value.replace(/[^\n]+$/, "");
10296 }
10297 return false;
10298 }
10299 });
10300 if (typeof value === "undefined") {
10301 value = this.raw(node2, null, "beforeDecl");
10302 } else if (value) {
10303 value = value.replace(/\S/g, "");
10304 }
10305 return value;
10306 };
10307 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
10308 var value;
10309 root2.walkDecls(function(i2) {
10310 if (typeof i2.raws.before !== "undefined") {
10311 value = i2.raws.before;
10312 if (value.includes("\n")) {
10313 value = value.replace(/[^\n]+$/, "");
10314 }
10315 return false;
10316 }
10317 });
10318 if (typeof value === "undefined") {
10319 value = this.raw(node2, null, "beforeRule");
10320 } else if (value) {
10321 value = value.replace(/\S/g, "");
10322 }
10323 return value;
10324 };
10325 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
10326 var value;
10327 root2.walk(function(i2) {
10328 if (i2.type !== "decl") {
10329 value = i2.raws.between;
10330 if (typeof value !== "undefined") return false;
10331 }
10332 });
10333 return value;
10334 };
10335 _proto.rawBeforeRule = function rawBeforeRule(root2) {
10336 var value;
10337 root2.walk(function(i2) {
10338 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
10339 if (typeof i2.raws.before !== "undefined") {
10340 value = i2.raws.before;
10341 if (value.includes("\n")) {
10342 value = value.replace(/[^\n]+$/, "");
10343 }
10344 return false;
10345 }
10346 }
10347 });
10348 if (value) value = value.replace(/\S/g, "");
10349 return value;
10350 };
10351 _proto.rawColon = function rawColon(root2) {
10352 var value;
10353 root2.walkDecls(function(i2) {
10354 if (typeof i2.raws.between !== "undefined") {
10355 value = i2.raws.between.replace(/[^\s:]/g, "");
10356 return false;
10357 }
10358 });
10359 return value;
10360 };
10361 _proto.rawEmptyBody = function rawEmptyBody(root2) {
10362 var value;
10363 root2.walk(function(i2) {
10364 if (i2.nodes && i2.nodes.length === 0) {
10365 value = i2.raws.after;
10366 if (typeof value !== "undefined") return false;
10367 }
10368 });
10369 return value;
10370 };
10371 _proto.rawIndent = function rawIndent(root2) {
10372 if (root2.raws.indent) return root2.raws.indent;
10373 var value;
10374 root2.walk(function(i2) {
10375 var p = i2.parent;
10376 if (p && p !== root2 && p.parent && p.parent === root2) {
10377 if (typeof i2.raws.before !== "undefined") {
10378 var parts = i2.raws.before.split("\n");
10379 value = parts[parts.length - 1];
10380 value = value.replace(/\S/g, "");
10381 return false;
10382 }
10383 }
10384 });
10385 return value;
10386 };
10387 _proto.rawSemicolon = function rawSemicolon(root2) {
10388 var value;
10389 root2.walk(function(i2) {
10390 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
10391 value = i2.raws.semicolon;
10392 if (typeof value !== "undefined") return false;
10393 }
10394 });
10395 return value;
10396 };
10397 _proto.rawValue = function rawValue(node2, prop) {
10398 var value = node2[prop];
10399 var raw = node2.raws[prop];
10400 if (raw && raw.value === value) {
10401 return raw.raw;
10402 }
10403 return value;
10404 };
10405 _proto.root = function root(node2) {
10406 this.body(node2);
10407 if (node2.raws.after) this.builder(node2.raws.after);
10408 };
10409 _proto.rule = function rule(node2) {
10410 this.block(node2, this.rawValue(node2, "selector"));
10411 if (node2.raws.ownSemicolon) {
10412 this.builder(node2.raws.ownSemicolon, node2, "end");
10413 }
10414 };
10415 _proto.stringify = function stringify(node2, semicolon) {
10416 if (!this[node2.type]) {
10417 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
10418 }
10419 this[node2.type](node2, semicolon);
10420 };
10421 return Stringifier;
10422 }();
10423 var stringifier$1 = Stringifier$2$1;
10424 Stringifier$2$1.default = Stringifier$2$1;
10425 var Stringifier$1$1 = stringifier$1;
10426 function stringify$4$1(node2, builder) {
10427 var str = new Stringifier$1$1(builder);
10428 str.stringify(node2);
10429 }
10430 var stringify_1$1 = stringify$4$1;
10431 stringify$4$1.default = stringify$4$1;
10432 var isClean$2$1 = symbols$1.isClean, my$2$1 = symbols$1.my;
10433 var CssSyntaxError$2$1 = cssSyntaxError$1;
10434 var Stringifier2$1 = stringifier$1;
10435 var stringify$3$1 = stringify_1$1;
10436 function cloneNode$1(obj, parent) {
10437 var cloned = new obj.constructor();
10438 for(var i2 in obj){
10439 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
10440 continue;
10441 }
10442 if (i2 === "proxyCache") continue;
10443 var value = obj[i2];
10444 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
10445 if (i2 === "parent" && type === "object") {
10446 if (parent) cloned[i2] = parent;
10447 } else if (i2 === "source") {
10448 cloned[i2] = value;
10449 } else if (Array.isArray(value)) {
10450 cloned[i2] = value.map(function(j) {
10451 return cloneNode$1(j, cloned);
10452 });
10453 } else {
10454 if (type === "object" && value !== null) value = cloneNode$1(value);
10455 cloned[i2] = value;
10456 }
10457 }
10458 return cloned;
10459 }
10460 var Node$4$1 = /*#__PURE__*/ function() {
10461 function Node2(defaults) {
10462 if (defaults === void 0) defaults = {};
10463 this.raws = {};
10464 this[isClean$2$1] = false;
10465 this[my$2$1] = true;
10466 for(var name in defaults){
10467 if (name === "nodes") {
10468 this.nodes = [];
10469 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
10470 var node2 = _step.value;
10471 if (typeof node2.clone === "function") {
10472 this.append(node2.clone());
10473 } else {
10474 this.append(node2);
10475 }
10476 }
10477 } else {
10478 this[name] = defaults[name];
10479 }
10480 }
10481 }
10482 var _proto = Node2.prototype;
10483 _proto.addToError = function addToError(error) {
10484 error.postcssNode = this;
10485 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
10486 var s2 = this.source;
10487 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
10488 }
10489 return error;
10490 };
10491 _proto.after = function after(add) {
10492 this.parent.insertAfter(this, add);
10493 return this;
10494 };
10495 _proto.assign = function assign(overrides) {
10496 if (overrides === void 0) overrides = {};
10497 for(var name in overrides){
10498 this[name] = overrides[name];
10499 }
10500 return this;
10501 };
10502 _proto.before = function before(add) {
10503 this.parent.insertBefore(this, add);
10504 return this;
10505 };
10506 _proto.cleanRaws = function cleanRaws(keepBetween) {
10507 delete this.raws.before;
10508 delete this.raws.after;
10509 if (!keepBetween) delete this.raws.between;
10510 };
10511 _proto.clone = function clone(overrides) {
10512 if (overrides === void 0) overrides = {};
10513 var cloned = cloneNode$1(this);
10514 for(var name in overrides){
10515 cloned[name] = overrides[name];
10516 }
10517 return cloned;
10518 };
10519 _proto.cloneAfter = function cloneAfter(overrides) {
10520 if (overrides === void 0) overrides = {};
10521 var cloned = this.clone(overrides);
10522 this.parent.insertAfter(this, cloned);
10523 return cloned;
10524 };
10525 _proto.cloneBefore = function cloneBefore(overrides) {
10526 if (overrides === void 0) overrides = {};
10527 var cloned = this.clone(overrides);
10528 this.parent.insertBefore(this, cloned);
10529 return cloned;
10530 };
10531 _proto.error = function error(message, opts) {
10532 if (opts === void 0) opts = {};
10533 if (this.source) {
10534 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
10535 return this.source.input.error(message, {
10536 column: start.column,
10537 line: start.line
10538 }, {
10539 column: end.column,
10540 line: end.line
10541 }, opts);
10542 }
10543 return new CssSyntaxError$2$1(message);
10544 };
10545 _proto.getProxyProcessor = function getProxyProcessor() {
10546 return {
10547 get: function get(node2, prop) {
10548 if (prop === "proxyOf") {
10549 return node2;
10550 } else if (prop === "root") {
10551 return function() {
10552 return node2.root().toProxy();
10553 };
10554 } else {
10555 return node2[prop];
10556 }
10557 },
10558 set: function set(node2, prop, value) {
10559 if (node2[prop] === value) return true;
10560 node2[prop] = value;
10561 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
10562 node2.markDirty();
10563 }
10564 return true;
10565 }
10566 };
10567 };
10568 _proto.markDirty = function markDirty() {
10569 if (this[isClean$2$1]) {
10570 this[isClean$2$1] = false;
10571 var next = this;
10572 while(next = next.parent){
10573 next[isClean$2$1] = false;
10574 }
10575 }
10576 };
10577 _proto.next = function next() {
10578 if (!this.parent) return void 0;
10579 var index2 = this.parent.index(this);
10580 return this.parent.nodes[index2 + 1];
10581 };
10582 _proto.positionBy = function positionBy(opts, stringRepresentation) {
10583 var pos = this.source.start;
10584 if (opts.index) {
10585 pos = this.positionInside(opts.index, stringRepresentation);
10586 } else if (opts.word) {
10587 stringRepresentation = this.toString();
10588 var index2 = stringRepresentation.indexOf(opts.word);
10589 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
10590 }
10591 return pos;
10592 };
10593 _proto.positionInside = function positionInside(index2, stringRepresentation) {
10594 var string = stringRepresentation || this.toString();
10595 var column = this.source.start.column;
10596 var line = this.source.start.line;
10597 for(var i2 = 0; i2 < index2; i2++){
10598 if (string[i2] === "\n") {
10599 column = 1;
10600 line += 1;
10601 } else {
10602 column += 1;
10603 }
10604 }
10605 return {
10606 column: column,
10607 line: line
10608 };
10609 };
10610 _proto.prev = function prev() {
10611 if (!this.parent) return void 0;
10612 var index2 = this.parent.index(this);
10613 return this.parent.nodes[index2 - 1];
10614 };
10615 _proto.rangeBy = function rangeBy(opts) {
10616 var start = {
10617 column: this.source.start.column,
10618 line: this.source.start.line
10619 };
10620 var end = this.source.end ? {
10621 column: this.source.end.column + 1,
10622 line: this.source.end.line
10623 } : {
10624 column: start.column + 1,
10625 line: start.line
10626 };
10627 if (opts.word) {
10628 var stringRepresentation = this.toString();
10629 var index2 = stringRepresentation.indexOf(opts.word);
10630 if (index2 !== -1) {
10631 start = this.positionInside(index2, stringRepresentation);
10632 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
10633 }
10634 } else {
10635 if (opts.start) {
10636 start = {
10637 column: opts.start.column,
10638 line: opts.start.line
10639 };
10640 } else if (opts.index) {
10641 start = this.positionInside(opts.index);
10642 }
10643 if (opts.end) {
10644 end = {
10645 column: opts.end.column,
10646 line: opts.end.line
10647 };
10648 } else if (typeof opts.endIndex === "number") {
10649 end = this.positionInside(opts.endIndex);
10650 } else if (opts.index) {
10651 end = this.positionInside(opts.index + 1);
10652 }
10653 }
10654 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
10655 end = {
10656 column: start.column + 1,
10657 line: start.line
10658 };
10659 }
10660 return {
10661 end: end,
10662 start: start
10663 };
10664 };
10665 _proto.raw = function raw(prop, defaultType) {
10666 var str = new Stringifier2$1();
10667 return str.raw(this, prop, defaultType);
10668 };
10669 _proto.remove = function remove() {
10670 if (this.parent) {
10671 this.parent.removeChild(this);
10672 }
10673 this.parent = void 0;
10674 return this;
10675 };
10676 _proto.replaceWith = function replaceWith() {
10677 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
10678 nodes[_key] = arguments[_key];
10679 }
10680 if (this.parent) {
10681 var bookmark = this;
10682 var foundSelf = false;
10683 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
10684 var node2 = _step.value;
10685 if (node2 === this) {
10686 foundSelf = true;
10687 } else if (foundSelf) {
10688 this.parent.insertAfter(bookmark, node2);
10689 bookmark = node2;
10690 } else {
10691 this.parent.insertBefore(bookmark, node2);
10692 }
10693 }
10694 if (!foundSelf) {
10695 this.remove();
10696 }
10697 }
10698 return this;
10699 };
10700 _proto.root = function root() {
10701 var result2 = this;
10702 while(result2.parent && result2.parent.type !== "document"){
10703 result2 = result2.parent;
10704 }
10705 return result2;
10706 };
10707 _proto.toJSON = function toJSON(_, inputs) {
10708 var fixed = {};
10709 var emitInputs = inputs == null;
10710 inputs = inputs || /* @__PURE__ */ new Map();
10711 var inputsNextIndex = 0;
10712 for(var name in this){
10713 if (!Object.prototype.hasOwnProperty.call(this, name)) {
10714 continue;
10715 }
10716 if (name === "parent" || name === "proxyCache") continue;
10717 var value = this[name];
10718 if (Array.isArray(value)) {
10719 fixed[name] = value.map(function(i2) {
10720 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
10721 return i2.toJSON(null, inputs);
10722 } else {
10723 return i2;
10724 }
10725 });
10726 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
10727 fixed[name] = value.toJSON(null, inputs);
10728 } else if (name === "source") {
10729 var inputId = inputs.get(value.input);
10730 if (inputId == null) {
10731 inputId = inputsNextIndex;
10732 inputs.set(value.input, inputsNextIndex);
10733 inputsNextIndex++;
10734 }
10735 fixed[name] = {
10736 end: value.end,
10737 inputId: inputId,
10738 start: value.start
10739 };
10740 } else {
10741 fixed[name] = value;
10742 }
10743 }
10744 if (emitInputs) {
10745 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
10746 return input2.toJSON();
10747 });
10748 }
10749 return fixed;
10750 };
10751 _proto.toProxy = function toProxy() {
10752 if (!this.proxyCache) {
10753 this.proxyCache = new Proxy(this, this.getProxyProcessor());
10754 }
10755 return this.proxyCache;
10756 };
10757 _proto.toString = function toString(stringifier2) {
10758 if (stringifier2 === void 0) stringifier2 = stringify$3$1;
10759 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
10760 var result2 = "";
10761 stringifier2(this, function(i2) {
10762 result2 += i2;
10763 });
10764 return result2;
10765 };
10766 _proto.warn = function warn(result2, text, opts) {
10767 var data = {
10768 node: this
10769 };
10770 for(var i2 in opts)data[i2] = opts[i2];
10771 return result2.warn(text, data);
10772 };
10773 _create_class(Node2, [
10774 {
10775 key: "proxyOf",
10776 get: function get() {
10777 return this;
10778 }
10779 }
10780 ]);
10781 return Node2;
10782 }();
10783 var node$1 = Node$4$1;
10784 Node$4$1.default = Node$4$1;
10785 var Node$3$1 = node$1;
10786 var Declaration$4$1 = /*#__PURE__*/ function(Node$3$1) {
10787 _inherits(Declaration, Node$3$1);
10788 function Declaration(defaults) {
10789 var _this;
10790 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
10791 defaults = _extends({}, defaults, {
10792 value: String(defaults.value)
10793 });
10794 }
10795 _this = Node$3$1.call(this, defaults) || this;
10796 _this.type = "decl";
10797 return _this;
10798 }
10799 _create_class(Declaration, [
10800 {
10801 key: "variable",
10802 get: function get() {
10803 return this.prop.startsWith("--") || this.prop[0] === "$";
10804 }
10805 }
10806 ]);
10807 return Declaration;
10808 }(Node$3$1);
10809 var declaration$1 = Declaration$4$1;
10810 Declaration$4$1.default = Declaration$4$1;
10811 var urlAlphabet$1 = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
10812 var nanoid$1$1 = function(size) {
10813 if (size === void 0) size = 21;
10814 var id = "";
10815 var i2 = size;
10816 while(i2--){
10817 id += urlAlphabet$1[Math.random() * 64 | 0];
10818 }
10819 return id;
10820 };
10821 var nonSecure$1 = {
10822 nanoid: nanoid$1$1};
10823 var SourceMapConsumer$2$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$2$1 = require$$2$1.SourceMapGenerator;
10824 var existsSync$1 = require$$2$1.existsSync, readFileSync$1 = require$$2$1.readFileSync;
10825 var dirname$1$1 = require$$2$1.dirname, join$1 = require$$2$1.join;
10826 function fromBase64$1(str) {
10827 if (Buffer) {
10828 return Buffer.from(str, "base64").toString();
10829 } else {
10830 return window.atob(str);
10831 }
10832 }
10833 var PreviousMap$2$1 = /*#__PURE__*/ function() {
10834 function PreviousMap(css, opts) {
10835 if (opts.map === false) return;
10836 this.loadAnnotation(css);
10837 this.inline = this.startWith(this.annotation, "data:");
10838 var prev = opts.map ? opts.map.prev : void 0;
10839 var text = this.loadMap(opts.from, prev);
10840 if (!this.mapFile && opts.from) {
10841 this.mapFile = opts.from;
10842 }
10843 if (this.mapFile) this.root = dirname$1$1(this.mapFile);
10844 if (text) this.text = text;
10845 }
10846 var _proto = PreviousMap.prototype;
10847 _proto.consumer = function consumer() {
10848 if (!this.consumerCache) {
10849 this.consumerCache = new SourceMapConsumer$2$1(this.text);
10850 }
10851 return this.consumerCache;
10852 };
10853 _proto.decodeInline = function decodeInline(text) {
10854 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
10855 var baseUri = /^data:application\/json;base64,/;
10856 var charsetUri = /^data:application\/json;charset=utf-?8,/;
10857 var uri = /^data:application\/json,/;
10858 if (charsetUri.test(text) || uri.test(text)) {
10859 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
10860 }
10861 if (baseCharsetUri.test(text) || baseUri.test(text)) {
10862 return fromBase64$1(text.substr(RegExp.lastMatch.length));
10863 }
10864 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
10865 throw new Error("Unsupported source map encoding " + encoding);
10866 };
10867 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
10868 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
10869 };
10870 _proto.isMap = function isMap(map) {
10871 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
10872 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
10873 };
10874 _proto.loadAnnotation = function loadAnnotation(css) {
10875 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
10876 if (!comments) return;
10877 var start = css.lastIndexOf(comments.pop());
10878 var end = css.indexOf("*/", start);
10879 if (start > -1 && end > -1) {
10880 this.annotation = this.getAnnotationURL(css.substring(start, end));
10881 }
10882 };
10883 _proto.loadFile = function loadFile(path) {
10884 this.root = dirname$1$1(path);
10885 if (existsSync$1(path)) {
10886 this.mapFile = path;
10887 return readFileSync$1(path, "utf-8").toString().trim();
10888 }
10889 };
10890 _proto.loadMap = function loadMap(file, prev) {
10891 if (prev === false) return false;
10892 if (prev) {
10893 if (typeof prev === "string") {
10894 return prev;
10895 } else if (typeof prev === "function") {
10896 var prevPath = prev(file);
10897 if (prevPath) {
10898 var map = this.loadFile(prevPath);
10899 if (!map) {
10900 throw new Error("Unable to load previous source map: " + prevPath.toString());
10901 }
10902 return map;
10903 }
10904 } else if (_instanceof(prev, SourceMapConsumer$2$1)) {
10905 return SourceMapGenerator$2$1.fromSourceMap(prev).toString();
10906 } else if (_instanceof(prev, SourceMapGenerator$2$1)) {
10907 return prev.toString();
10908 } else if (this.isMap(prev)) {
10909 return JSON.stringify(prev);
10910 } else {
10911 throw new Error("Unsupported previous source map format: " + prev.toString());
10912 }
10913 } else if (this.inline) {
10914 return this.decodeInline(this.annotation);
10915 } else if (this.annotation) {
10916 var map1 = this.annotation;
10917 if (file) map1 = join$1(dirname$1$1(file), map1);
10918 return this.loadFile(map1);
10919 }
10920 };
10921 _proto.startWith = function startWith(string, start) {
10922 if (!string) return false;
10923 return string.substr(0, start.length) === start;
10924 };
10925 _proto.withContent = function withContent() {
10926 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
10927 };
10928 return PreviousMap;
10929 }();
10930 var previousMap$1 = PreviousMap$2$1;
10931 PreviousMap$2$1.default = PreviousMap$2$1;
10932 var SourceMapConsumer$1$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$1$1 = require$$2$1.SourceMapGenerator;
10933 var fileURLToPath$1 = require$$2$1.fileURLToPath, pathToFileURL$1$1 = require$$2$1.pathToFileURL;
10934 var isAbsolute$1 = require$$2$1.isAbsolute, resolve$1$1 = require$$2$1.resolve;
10935 var nanoid$2 = nonSecure$1.nanoid;
10936 var terminalHighlight$2 = require$$2$1;
10937 var CssSyntaxError$1$1 = cssSyntaxError$1;
10938 var PreviousMap$1$1 = previousMap$1;
10939 var fromOffsetCache$1 = Symbol("fromOffsetCache");
10940 var sourceMapAvailable$1$1 = Boolean(SourceMapConsumer$1$1 && SourceMapGenerator$1$1);
10941 var pathAvailable$1$1 = Boolean(resolve$1$1 && isAbsolute$1);
10942 var Input$4$1 = /*#__PURE__*/ function() {
10943 function Input(css, opts) {
10944 if (opts === void 0) opts = {};
10945 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
10946 throw new Error("PostCSS received " + css + " instead of CSS string");
10947 }
10948 this.css = css.toString();
10949 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
10950 this.hasBOM = true;
10951 this.css = this.css.slice(1);
10952 } else {
10953 this.hasBOM = false;
10954 }
10955 if (opts.from) {
10956 if (!pathAvailable$1$1 || /^\w+:\/\//.test(opts.from) || isAbsolute$1(opts.from)) {
10957 this.file = opts.from;
10958 } else {
10959 this.file = resolve$1$1(opts.from);
10960 }
10961 }
10962 if (pathAvailable$1$1 && sourceMapAvailable$1$1) {
10963 var map = new PreviousMap$1$1(this.css, opts);
10964 if (map.text) {
10965 this.map = map;
10966 var file = map.consumer().file;
10967 if (!this.file && file) this.file = this.mapResolve(file);
10968 }
10969 }
10970 if (!this.file) {
10971 this.id = "<input css " + nanoid$2(6) + ">";
10972 }
10973 if (this.map) this.map.file = this.from;
10974 }
10975 var _proto = Input.prototype;
10976 _proto.error = function error(message, line, column, opts) {
10977 if (opts === void 0) opts = {};
10978 var result2, endLine, endColumn;
10979 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
10980 var start = line;
10981 var end = column;
10982 if (typeof start.offset === "number") {
10983 var pos = this.fromOffset(start.offset);
10984 line = pos.line;
10985 column = pos.col;
10986 } else {
10987 line = start.line;
10988 column = start.column;
10989 }
10990 if (typeof end.offset === "number") {
10991 var pos1 = this.fromOffset(end.offset);
10992 endLine = pos1.line;
10993 endColumn = pos1.col;
10994 } else {
10995 endLine = end.line;
10996 endColumn = end.column;
10997 }
10998 } else if (!column) {
10999 var pos2 = this.fromOffset(line);
11000 line = pos2.line;
11001 column = pos2.col;
11002 }
11003 var origin = this.origin(line, column, endLine, endColumn);
11004 if (origin) {
11005 result2 = new CssSyntaxError$1$1(message, origin.endLine === void 0 ? origin.line : {
11006 column: origin.column,
11007 line: origin.line
11008 }, origin.endLine === void 0 ? origin.column : {
11009 column: origin.endColumn,
11010 line: origin.endLine
11011 }, origin.source, origin.file, opts.plugin);
11012 } else {
11013 result2 = new CssSyntaxError$1$1(message, endLine === void 0 ? line : {
11014 column: column,
11015 line: line
11016 }, endLine === void 0 ? column : {
11017 column: endColumn,
11018 line: endLine
11019 }, this.css, this.file, opts.plugin);
11020 }
11021 result2.input = {
11022 column: column,
11023 endColumn: endColumn,
11024 endLine: endLine,
11025 line: line,
11026 source: this.css
11027 };
11028 if (this.file) {
11029 if (pathToFileURL$1$1) {
11030 result2.input.url = pathToFileURL$1$1(this.file).toString();
11031 }
11032 result2.input.file = this.file;
11033 }
11034 return result2;
11035 };
11036 _proto.fromOffset = function fromOffset(offset) {
11037 var lastLine, lineToIndex;
11038 if (!this[fromOffsetCache$1]) {
11039 var lines = this.css.split("\n");
11040 lineToIndex = new Array(lines.length);
11041 var prevIndex = 0;
11042 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
11043 lineToIndex[i2] = prevIndex;
11044 prevIndex += lines[i2].length + 1;
11045 }
11046 this[fromOffsetCache$1] = lineToIndex;
11047 } else {
11048 lineToIndex = this[fromOffsetCache$1];
11049 }
11050 lastLine = lineToIndex[lineToIndex.length - 1];
11051 var min = 0;
11052 if (offset >= lastLine) {
11053 min = lineToIndex.length - 1;
11054 } else {
11055 var max = lineToIndex.length - 2;
11056 var mid;
11057 while(min < max){
11058 mid = min + (max - min >> 1);
11059 if (offset < lineToIndex[mid]) {
11060 max = mid - 1;
11061 } else if (offset >= lineToIndex[mid + 1]) {
11062 min = mid + 1;
11063 } else {
11064 min = mid;
11065 break;
11066 }
11067 }
11068 }
11069 return {
11070 col: offset - lineToIndex[min] + 1,
11071 line: min + 1
11072 };
11073 };
11074 _proto.mapResolve = function mapResolve(file) {
11075 if (/^\w+:\/\//.test(file)) {
11076 return file;
11077 }
11078 return resolve$1$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
11079 };
11080 _proto.origin = function origin(line, column, endLine, endColumn) {
11081 if (!this.map) return false;
11082 var consumer = this.map.consumer();
11083 var from = consumer.originalPositionFor({
11084 column: column,
11085 line: line
11086 });
11087 if (!from.source) return false;
11088 var to;
11089 if (typeof endLine === "number") {
11090 to = consumer.originalPositionFor({
11091 column: endColumn,
11092 line: endLine
11093 });
11094 }
11095 var fromUrl;
11096 if (isAbsolute$1(from.source)) {
11097 fromUrl = pathToFileURL$1$1(from.source);
11098 } else {
11099 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1$1(this.map.mapFile));
11100 }
11101 var result2 = {
11102 column: from.column,
11103 endColumn: to && to.column,
11104 endLine: to && to.line,
11105 line: from.line,
11106 url: fromUrl.toString()
11107 };
11108 if (fromUrl.protocol === "file:") {
11109 if (fileURLToPath$1) {
11110 result2.file = fileURLToPath$1(fromUrl);
11111 } else {
11112 throw new Error("file: protocol is not available in this PostCSS build");
11113 }
11114 }
11115 var source = consumer.sourceContentFor(from.source);
11116 if (source) result2.source = source;
11117 return result2;
11118 };
11119 _proto.toJSON = function toJSON() {
11120 var json = {};
11121 for(var _i = 0, _iter = [
11122 "hasBOM",
11123 "css",
11124 "file",
11125 "id"
11126 ]; _i < _iter.length; _i++){
11127 var name = _iter[_i];
11128 if (this[name] != null) {
11129 json[name] = this[name];
11130 }
11131 }
11132 if (this.map) {
11133 json.map = _extends({}, this.map);
11134 if (json.map.consumerCache) {
11135 json.map.consumerCache = void 0;
11136 }
11137 }
11138 return json;
11139 };
11140 _create_class(Input, [
11141 {
11142 key: "from",
11143 get: function get() {
11144 return this.file || this.id;
11145 }
11146 }
11147 ]);
11148 return Input;
11149 }();
11150 var input$1 = Input$4$1;
11151 Input$4$1.default = Input$4$1;
11152 if (terminalHighlight$2 && terminalHighlight$2.registerInput) {
11153 terminalHighlight$2.registerInput(Input$4$1);
11154 }
11155 var SourceMapConsumer$3 = require$$2$1.SourceMapConsumer, SourceMapGenerator$3 = require$$2$1.SourceMapGenerator;
11156 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;
11157 var pathToFileURL$2 = require$$2$1.pathToFileURL;
11158 var Input$3$1 = input$1;
11159 var sourceMapAvailable$2 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$3);
11160 var pathAvailable$2 = Boolean(dirname$2 && resolve$2 && relative$1 && sep$1);
11161 var MapGenerator$2$1 = /*#__PURE__*/ function() {
11162 function MapGenerator(stringify2, root2, opts, cssString) {
11163 this.stringify = stringify2;
11164 this.mapOpts = opts.map || {};
11165 this.root = root2;
11166 this.opts = opts;
11167 this.css = cssString;
11168 this.originalCSS = cssString;
11169 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
11170 this.memoizedFileURLs = /* @__PURE__ */ new Map();
11171 this.memoizedPaths = /* @__PURE__ */ new Map();
11172 this.memoizedURLs = /* @__PURE__ */ new Map();
11173 }
11174 var _proto = MapGenerator.prototype;
11175 _proto.addAnnotation = function addAnnotation() {
11176 var content;
11177 if (this.isInline()) {
11178 content = "data:application/json;base64," + this.toBase64(this.map.toString());
11179 } else if (typeof this.mapOpts.annotation === "string") {
11180 content = this.mapOpts.annotation;
11181 } else if (typeof this.mapOpts.annotation === "function") {
11182 content = this.mapOpts.annotation(this.opts.to, this.root);
11183 } else {
11184 content = this.outputFile() + ".map";
11185 }
11186 var eol = "\n";
11187 if (this.css.includes("\r\n")) eol = "\r\n";
11188 this.css += eol + "/*# sourceMappingURL=" + content + " */";
11189 };
11190 _proto.applyPrevMaps = function applyPrevMaps() {
11191 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
11192 var prev = _step.value;
11193 var from = this.toUrl(this.path(prev.file));
11194 var root2 = prev.root || dirname$2(prev.file);
11195 var map = void 0;
11196 if (this.mapOpts.sourcesContent === false) {
11197 map = new SourceMapConsumer$3(prev.text);
11198 if (map.sourcesContent) {
11199 map.sourcesContent = null;
11200 }
11201 } else {
11202 map = prev.consumer();
11203 }
11204 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
11205 }
11206 };
11207 _proto.clearAnnotation = function clearAnnotation() {
11208 if (this.mapOpts.annotation === false) return;
11209 if (this.root) {
11210 var node2;
11211 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
11212 node2 = this.root.nodes[i2];
11213 if (node2.type !== "comment") continue;
11214 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
11215 this.root.removeChild(i2);
11216 }
11217 }
11218 } else if (this.css) {
11219 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
11220 }
11221 };
11222 _proto.generate = function generate() {
11223 this.clearAnnotation();
11224 if (pathAvailable$2 && sourceMapAvailable$2 && this.isMap()) {
11225 return this.generateMap();
11226 } else {
11227 var result2 = "";
11228 this.stringify(this.root, function(i2) {
11229 result2 += i2;
11230 });
11231 return [
11232 result2
11233 ];
11234 }
11235 };
11236 _proto.generateMap = function generateMap() {
11237 if (this.root) {
11238 this.generateString();
11239 } else if (this.previous().length === 1) {
11240 var prev = this.previous()[0].consumer();
11241 prev.file = this.outputFile();
11242 this.map = SourceMapGenerator$3.fromSourceMap(prev, {
11243 ignoreInvalidMapping: true
11244 });
11245 } else {
11246 this.map = new SourceMapGenerator$3({
11247 file: this.outputFile(),
11248 ignoreInvalidMapping: true
11249 });
11250 this.map.addMapping({
11251 generated: {
11252 column: 0,
11253 line: 1
11254 },
11255 original: {
11256 column: 0,
11257 line: 1
11258 },
11259 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
11260 });
11261 }
11262 if (this.isSourcesContent()) this.setSourcesContent();
11263 if (this.root && this.previous().length > 0) this.applyPrevMaps();
11264 if (this.isAnnotation()) this.addAnnotation();
11265 if (this.isInline()) {
11266 return [
11267 this.css
11268 ];
11269 } else {
11270 return [
11271 this.css,
11272 this.map
11273 ];
11274 }
11275 };
11276 _proto.generateString = function generateString() {
11277 var _this = this;
11278 this.css = "";
11279 this.map = new SourceMapGenerator$3({
11280 file: this.outputFile(),
11281 ignoreInvalidMapping: true
11282 });
11283 var line = 1;
11284 var column = 1;
11285 var noSource = "<no source>";
11286 var mapping = {
11287 generated: {
11288 column: 0,
11289 line: 0
11290 },
11291 original: {
11292 column: 0,
11293 line: 0
11294 },
11295 source: ""
11296 };
11297 var lines, last;
11298 this.stringify(this.root, function(str, node2, type) {
11299 _this.css += str;
11300 if (node2 && type !== "end") {
11301 mapping.generated.line = line;
11302 mapping.generated.column = column - 1;
11303 if (node2.source && node2.source.start) {
11304 mapping.source = _this.sourcePath(node2);
11305 mapping.original.line = node2.source.start.line;
11306 mapping.original.column = node2.source.start.column - 1;
11307 _this.map.addMapping(mapping);
11308 } else {
11309 mapping.source = noSource;
11310 mapping.original.line = 1;
11311 mapping.original.column = 0;
11312 _this.map.addMapping(mapping);
11313 }
11314 }
11315 lines = str.match(/\n/g);
11316 if (lines) {
11317 line += lines.length;
11318 last = str.lastIndexOf("\n");
11319 column = str.length - last;
11320 } else {
11321 column += str.length;
11322 }
11323 if (node2 && type !== "start") {
11324 var p = node2.parent || {
11325 raws: {}
11326 };
11327 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
11328 if (!childless || node2 !== p.last || p.raws.semicolon) {
11329 if (node2.source && node2.source.end) {
11330 mapping.source = _this.sourcePath(node2);
11331 mapping.original.line = node2.source.end.line;
11332 mapping.original.column = node2.source.end.column - 1;
11333 mapping.generated.line = line;
11334 mapping.generated.column = column - 2;
11335 _this.map.addMapping(mapping);
11336 } else {
11337 mapping.source = noSource;
11338 mapping.original.line = 1;
11339 mapping.original.column = 0;
11340 mapping.generated.line = line;
11341 mapping.generated.column = column - 1;
11342 _this.map.addMapping(mapping);
11343 }
11344 }
11345 }
11346 });
11347 };
11348 _proto.isAnnotation = function isAnnotation() {
11349 if (this.isInline()) {
11350 return true;
11351 }
11352 if (typeof this.mapOpts.annotation !== "undefined") {
11353 return this.mapOpts.annotation;
11354 }
11355 if (this.previous().length) {
11356 return this.previous().some(function(i2) {
11357 return i2.annotation;
11358 });
11359 }
11360 return true;
11361 };
11362 _proto.isInline = function isInline() {
11363 if (typeof this.mapOpts.inline !== "undefined") {
11364 return this.mapOpts.inline;
11365 }
11366 var annotation = this.mapOpts.annotation;
11367 if (typeof annotation !== "undefined" && annotation !== true) {
11368 return false;
11369 }
11370 if (this.previous().length) {
11371 return this.previous().some(function(i2) {
11372 return i2.inline;
11373 });
11374 }
11375 return true;
11376 };
11377 _proto.isMap = function isMap() {
11378 if (typeof this.opts.map !== "undefined") {
11379 return !!this.opts.map;
11380 }
11381 return this.previous().length > 0;
11382 };
11383 _proto.isSourcesContent = function isSourcesContent() {
11384 if (typeof this.mapOpts.sourcesContent !== "undefined") {
11385 return this.mapOpts.sourcesContent;
11386 }
11387 if (this.previous().length) {
11388 return this.previous().some(function(i2) {
11389 return i2.withContent();
11390 });
11391 }
11392 return true;
11393 };
11394 _proto.outputFile = function outputFile() {
11395 if (this.opts.to) {
11396 return this.path(this.opts.to);
11397 } else if (this.opts.from) {
11398 return this.path(this.opts.from);
11399 } else {
11400 return "to.css";
11401 }
11402 };
11403 _proto.path = function path(file) {
11404 if (this.mapOpts.absolute) return file;
11405 if (file.charCodeAt(0) === 60) return file;
11406 if (/^\w+:\/\//.test(file)) return file;
11407 var cached = this.memoizedPaths.get(file);
11408 if (cached) return cached;
11409 var from = this.opts.to ? dirname$2(this.opts.to) : ".";
11410 if (typeof this.mapOpts.annotation === "string") {
11411 from = dirname$2(resolve$2(from, this.mapOpts.annotation));
11412 }
11413 var path = relative$1(from, file);
11414 this.memoizedPaths.set(file, path);
11415 return path;
11416 };
11417 _proto.previous = function previous() {
11418 var _this = this;
11419 if (!this.previousMaps) {
11420 this.previousMaps = [];
11421 if (this.root) {
11422 this.root.walk(function(node2) {
11423 if (node2.source && node2.source.input.map) {
11424 var map = node2.source.input.map;
11425 if (!_this.previousMaps.includes(map)) {
11426 _this.previousMaps.push(map);
11427 }
11428 }
11429 });
11430 } else {
11431 var input2 = new Input$3$1(this.originalCSS, this.opts);
11432 if (input2.map) this.previousMaps.push(input2.map);
11433 }
11434 }
11435 return this.previousMaps;
11436 };
11437 _proto.setSourcesContent = function setSourcesContent() {
11438 var _this = this;
11439 var already = {};
11440 if (this.root) {
11441 this.root.walk(function(node2) {
11442 if (node2.source) {
11443 var from = node2.source.input.from;
11444 if (from && !already[from]) {
11445 already[from] = true;
11446 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
11447 _this.map.setSourceContent(fromUrl, node2.source.input.css);
11448 }
11449 }
11450 });
11451 } else if (this.css) {
11452 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
11453 this.map.setSourceContent(from, this.css);
11454 }
11455 };
11456 _proto.sourcePath = function sourcePath(node2) {
11457 if (this.mapOpts.from) {
11458 return this.toUrl(this.mapOpts.from);
11459 } else if (this.usesFileUrls) {
11460 return this.toFileUrl(node2.source.input.from);
11461 } else {
11462 return this.toUrl(this.path(node2.source.input.from));
11463 }
11464 };
11465 _proto.toBase64 = function toBase64(str) {
11466 if (Buffer) {
11467 return Buffer.from(str).toString("base64");
11468 } else {
11469 return window.btoa(unescape(encodeURIComponent(str)));
11470 }
11471 };
11472 _proto.toFileUrl = function toFileUrl(path) {
11473 var cached = this.memoizedFileURLs.get(path);
11474 if (cached) return cached;
11475 if (pathToFileURL$2) {
11476 var fileURL = pathToFileURL$2(path).toString();
11477 this.memoizedFileURLs.set(path, fileURL);
11478 return fileURL;
11479 } else {
11480 throw new Error("`map.absolute` option is not available in this PostCSS build");
11481 }
11482 };
11483 _proto.toUrl = function toUrl(path) {
11484 var cached = this.memoizedURLs.get(path);
11485 if (cached) return cached;
11486 if (sep$1 === "\\") {
11487 path = path.replace(/\\/g, "/");
11488 }
11489 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
11490 this.memoizedURLs.set(path, url);
11491 return url;
11492 };
11493 return MapGenerator;
11494 }();
11495 var mapGenerator$1 = MapGenerator$2$1;
11496 var Node$2$1 = node$1;
11497 var Comment$4$1 = /*#__PURE__*/ function(Node$2$1) {
11498 _inherits(Comment, Node$2$1);
11499 function Comment(defaults) {
11500 var _this;
11501 _this = Node$2$1.call(this, defaults) || this;
11502 _this.type = "comment";
11503 return _this;
11504 }
11505 return Comment;
11506 }(Node$2$1);
11507 var comment$1 = Comment$4$1;
11508 Comment$4$1.default = Comment$4$1;
11509 var isClean$1$1 = symbols$1.isClean, my$1$1 = symbols$1.my;
11510 var Declaration$3$1 = declaration$1;
11511 var Comment$3$1 = comment$1;
11512 var Node$1$1 = node$1;
11513 var parse$4$1, Rule$4$1, AtRule$4$1, Root$6$1;
11514 function cleanSource$1(nodes) {
11515 return nodes.map(function(i2) {
11516 if (i2.nodes) i2.nodes = cleanSource$1(i2.nodes);
11517 delete i2.source;
11518 return i2;
11519 });
11520 }
11521 function markDirtyUp$1(node2) {
11522 node2[isClean$1$1] = false;
11523 if (node2.proxyOf.nodes) {
11524 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
11525 var i2 = _step.value;
11526 markDirtyUp$1(i2);
11527 }
11528 }
11529 }
11530 var Container$7$1 = /*#__PURE__*/ function(Node$1$1) {
11531 _inherits(Container, Node$1$1);
11532 function Container() {
11533 return Node$1$1.apply(this, arguments) || this;
11534 }
11535 var _proto = Container.prototype;
11536 _proto.append = function append() {
11537 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
11538 children[_key] = arguments[_key];
11539 }
11540 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
11541 var child = _step.value;
11542 var nodes = this.normalize(child, this.last);
11543 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11544 var node2 = _step1.value;
11545 this.proxyOf.nodes.push(node2);
11546 }
11547 }
11548 this.markDirty();
11549 return this;
11550 };
11551 _proto.cleanRaws = function cleanRaws(keepBetween) {
11552 Node$1$1.prototype.cleanRaws.call(this, keepBetween);
11553 if (this.nodes) {
11554 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
11555 var node2 = _step.value;
11556 node2.cleanRaws(keepBetween);
11557 }
11558 }
11559 };
11560 _proto.each = function each(callback) {
11561 if (!this.proxyOf.nodes) return void 0;
11562 var iterator = this.getIterator();
11563 var index2, result2;
11564 while(this.indexes[iterator] < this.proxyOf.nodes.length){
11565 index2 = this.indexes[iterator];
11566 result2 = callback(this.proxyOf.nodes[index2], index2);
11567 if (result2 === false) break;
11568 this.indexes[iterator] += 1;
11569 }
11570 delete this.indexes[iterator];
11571 return result2;
11572 };
11573 _proto.every = function every(condition) {
11574 return this.nodes.every(condition);
11575 };
11576 _proto.getIterator = function getIterator() {
11577 if (!this.lastEach) this.lastEach = 0;
11578 if (!this.indexes) this.indexes = {};
11579 this.lastEach += 1;
11580 var iterator = this.lastEach;
11581 this.indexes[iterator] = 0;
11582 return iterator;
11583 };
11584 _proto.getProxyProcessor = function getProxyProcessor() {
11585 return {
11586 get: function get(node2, prop) {
11587 if (prop === "proxyOf") {
11588 return node2;
11589 } else if (!node2[prop]) {
11590 return node2[prop];
11591 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
11592 return function() {
11593 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
11594 args[_key] = arguments[_key];
11595 }
11596 var _node2;
11597 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
11598 if (typeof i2 === "function") {
11599 return function(child, index2) {
11600 return i2(child.toProxy(), index2);
11601 };
11602 } else {
11603 return i2;
11604 }
11605 })));
11606 };
11607 } else if (prop === "every" || prop === "some") {
11608 return function(cb) {
11609 return node2[prop](function(child) {
11610 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
11611 other[_key - 1] = arguments[_key];
11612 }
11613 return cb.apply(void 0, [].concat([
11614 child.toProxy()
11615 ], other));
11616 });
11617 };
11618 } else if (prop === "root") {
11619 return function() {
11620 return node2.root().toProxy();
11621 };
11622 } else if (prop === "nodes") {
11623 return node2.nodes.map(function(i2) {
11624 return i2.toProxy();
11625 });
11626 } else if (prop === "first" || prop === "last") {
11627 return node2[prop].toProxy();
11628 } else {
11629 return node2[prop];
11630 }
11631 },
11632 set: function set(node2, prop, value) {
11633 if (node2[prop] === value) return true;
11634 node2[prop] = value;
11635 if (prop === "name" || prop === "params" || prop === "selector") {
11636 node2.markDirty();
11637 }
11638 return true;
11639 }
11640 };
11641 };
11642 _proto.index = function index(child) {
11643 if (typeof child === "number") return child;
11644 if (child.proxyOf) child = child.proxyOf;
11645 return this.proxyOf.nodes.indexOf(child);
11646 };
11647 _proto.insertAfter = function insertAfter(exist, add) {
11648 var existIndex = this.index(exist);
11649 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
11650 existIndex = this.index(exist);
11651 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11652 var node2 = _step.value;
11653 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
11654 }
11655 var index2;
11656 for(var id in this.indexes){
11657 index2 = this.indexes[id];
11658 if (existIndex < index2) {
11659 this.indexes[id] = index2 + nodes.length;
11660 }
11661 }
11662 this.markDirty();
11663 return this;
11664 };
11665 _proto.insertBefore = function insertBefore(exist, add) {
11666 var existIndex = this.index(exist);
11667 var type = existIndex === 0 ? "prepend" : false;
11668 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
11669 existIndex = this.index(exist);
11670 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11671 var node2 = _step.value;
11672 this.proxyOf.nodes.splice(existIndex, 0, node2);
11673 }
11674 var index2;
11675 for(var id in this.indexes){
11676 index2 = this.indexes[id];
11677 if (existIndex <= index2) {
11678 this.indexes[id] = index2 + nodes.length;
11679 }
11680 }
11681 this.markDirty();
11682 return this;
11683 };
11684 _proto.normalize = function normalize(nodes, sample) {
11685 var _this = this;
11686 if (typeof nodes === "string") {
11687 nodes = cleanSource$1(parse$4$1(nodes).nodes);
11688 } else if (typeof nodes === "undefined") {
11689 nodes = [];
11690 } else if (Array.isArray(nodes)) {
11691 nodes = nodes.slice(0);
11692 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11693 var i2 = _step.value;
11694 if (i2.parent) i2.parent.removeChild(i2, "ignore");
11695 }
11696 } else if (nodes.type === "root" && this.type !== "document") {
11697 nodes = nodes.nodes.slice(0);
11698 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11699 var i21 = _step1.value;
11700 if (i21.parent) i21.parent.removeChild(i21, "ignore");
11701 }
11702 } else if (nodes.type) {
11703 nodes = [
11704 nodes
11705 ];
11706 } else if (nodes.prop) {
11707 if (typeof nodes.value === "undefined") {
11708 throw new Error("Value field is missed in node creation");
11709 } else if (typeof nodes.value !== "string") {
11710 nodes.value = String(nodes.value);
11711 }
11712 nodes = [
11713 new Declaration$3$1(nodes)
11714 ];
11715 } else if (nodes.selector) {
11716 nodes = [
11717 new Rule$4$1(nodes)
11718 ];
11719 } else if (nodes.name) {
11720 nodes = [
11721 new AtRule$4$1(nodes)
11722 ];
11723 } else if (nodes.text) {
11724 nodes = [
11725 new Comment$3$1(nodes)
11726 ];
11727 } else {
11728 throw new Error("Unknown node type in node creation");
11729 }
11730 var processed = nodes.map(function(i2) {
11731 if (!i2[my$1$1]) Container.rebuild(i2);
11732 i2 = i2.proxyOf;
11733 if (i2.parent) i2.parent.removeChild(i2);
11734 if (i2[isClean$1$1]) markDirtyUp$1(i2);
11735 if (typeof i2.raws.before === "undefined") {
11736 if (sample && typeof sample.raws.before !== "undefined") {
11737 i2.raws.before = sample.raws.before.replace(/\S/g, "");
11738 }
11739 }
11740 i2.parent = _this.proxyOf;
11741 return i2;
11742 });
11743 return processed;
11744 };
11745 _proto.prepend = function prepend() {
11746 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
11747 children[_key] = arguments[_key];
11748 }
11749 children = children.reverse();
11750 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
11751 var child = _step.value;
11752 var nodes = this.normalize(child, this.first, "prepend").reverse();
11753 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11754 var node2 = _step1.value;
11755 this.proxyOf.nodes.unshift(node2);
11756 }
11757 for(var id in this.indexes){
11758 this.indexes[id] = this.indexes[id] + nodes.length;
11759 }
11760 }
11761 this.markDirty();
11762 return this;
11763 };
11764 _proto.push = function push(child) {
11765 child.parent = this;
11766 this.proxyOf.nodes.push(child);
11767 return this;
11768 };
11769 _proto.removeAll = function removeAll() {
11770 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
11771 var node2 = _step.value;
11772 node2.parent = void 0;
11773 }
11774 this.proxyOf.nodes = [];
11775 this.markDirty();
11776 return this;
11777 };
11778 _proto.removeChild = function removeChild(child) {
11779 child = this.index(child);
11780 this.proxyOf.nodes[child].parent = void 0;
11781 this.proxyOf.nodes.splice(child, 1);
11782 var index2;
11783 for(var id in this.indexes){
11784 index2 = this.indexes[id];
11785 if (index2 >= child) {
11786 this.indexes[id] = index2 - 1;
11787 }
11788 }
11789 this.markDirty();
11790 return this;
11791 };
11792 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
11793 if (!callback) {
11794 callback = opts;
11795 opts = {};
11796 }
11797 this.walkDecls(function(decl) {
11798 if (opts.props && !opts.props.includes(decl.prop)) return;
11799 if (opts.fast && !decl.value.includes(opts.fast)) return;
11800 decl.value = decl.value.replace(pattern, callback);
11801 });
11802 this.markDirty();
11803 return this;
11804 };
11805 _proto.some = function some(condition) {
11806 return this.nodes.some(condition);
11807 };
11808 _proto.walk = function walk(callback) {
11809 return this.each(function(child, i2) {
11810 var result2;
11811 try {
11812 result2 = callback(child, i2);
11813 } catch (e2) {
11814 throw child.addToError(e2);
11815 }
11816 if (result2 !== false && child.walk) {
11817 result2 = child.walk(callback);
11818 }
11819 return result2;
11820 });
11821 };
11822 _proto.walkAtRules = function walkAtRules(name, callback) {
11823 if (!callback) {
11824 callback = name;
11825 return this.walk(function(child, i2) {
11826 if (child.type === "atrule") {
11827 return callback(child, i2);
11828 }
11829 });
11830 }
11831 if (_instanceof(name, RegExp)) {
11832 return this.walk(function(child, i2) {
11833 if (child.type === "atrule" && name.test(child.name)) {
11834 return callback(child, i2);
11835 }
11836 });
11837 }
11838 return this.walk(function(child, i2) {
11839 if (child.type === "atrule" && child.name === name) {
11840 return callback(child, i2);
11841 }
11842 });
11843 };
11844 _proto.walkComments = function walkComments(callback) {
11845 return this.walk(function(child, i2) {
11846 if (child.type === "comment") {
11847 return callback(child, i2);
11848 }
11849 });
11850 };
11851 _proto.walkDecls = function walkDecls(prop, callback) {
11852 if (!callback) {
11853 callback = prop;
11854 return this.walk(function(child, i2) {
11855 if (child.type === "decl") {
11856 return callback(child, i2);
11857 }
11858 });
11859 }
11860 if (_instanceof(prop, RegExp)) {
11861 return this.walk(function(child, i2) {
11862 if (child.type === "decl" && prop.test(child.prop)) {
11863 return callback(child, i2);
11864 }
11865 });
11866 }
11867 return this.walk(function(child, i2) {
11868 if (child.type === "decl" && child.prop === prop) {
11869 return callback(child, i2);
11870 }
11871 });
11872 };
11873 _proto.walkRules = function walkRules(selector, callback) {
11874 if (!callback) {
11875 callback = selector;
11876 return this.walk(function(child, i2) {
11877 if (child.type === "rule") {
11878 return callback(child, i2);
11879 }
11880 });
11881 }
11882 if (_instanceof(selector, RegExp)) {
11883 return this.walk(function(child, i2) {
11884 if (child.type === "rule" && selector.test(child.selector)) {
11885 return callback(child, i2);
11886 }
11887 });
11888 }
11889 return this.walk(function(child, i2) {
11890 if (child.type === "rule" && child.selector === selector) {
11891 return callback(child, i2);
11892 }
11893 });
11894 };
11895 _create_class(Container, [
11896 {
11897 key: "first",
11898 get: function get() {
11899 if (!this.proxyOf.nodes) return void 0;
11900 return this.proxyOf.nodes[0];
11901 }
11902 },
11903 {
11904 key: "last",
11905 get: function get() {
11906 if (!this.proxyOf.nodes) return void 0;
11907 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
11908 }
11909 }
11910 ]);
11911 return Container;
11912 }(Node$1$1);
11913 Container$7$1.registerParse = function(dependant) {
11914 parse$4$1 = dependant;
11915 };
11916 Container$7$1.registerRule = function(dependant) {
11917 Rule$4$1 = dependant;
11918 };
11919 Container$7$1.registerAtRule = function(dependant) {
11920 AtRule$4$1 = dependant;
11921 };
11922 Container$7$1.registerRoot = function(dependant) {
11923 Root$6$1 = dependant;
11924 };
11925 var container$1 = Container$7$1;
11926 Container$7$1.default = Container$7$1;
11927 Container$7$1.rebuild = function(node2) {
11928 if (node2.type === "atrule") {
11929 Object.setPrototypeOf(node2, AtRule$4$1.prototype);
11930 } else if (node2.type === "rule") {
11931 Object.setPrototypeOf(node2, Rule$4$1.prototype);
11932 } else if (node2.type === "decl") {
11933 Object.setPrototypeOf(node2, Declaration$3$1.prototype);
11934 } else if (node2.type === "comment") {
11935 Object.setPrototypeOf(node2, Comment$3$1.prototype);
11936 } else if (node2.type === "root") {
11937 Object.setPrototypeOf(node2, Root$6$1.prototype);
11938 }
11939 node2[my$1$1] = true;
11940 if (node2.nodes) {
11941 node2.nodes.forEach(function(child) {
11942 Container$7$1.rebuild(child);
11943 });
11944 }
11945 };
11946 var Container$6$1 = container$1;
11947 var LazyResult$4$1, Processor$3$1;
11948 var Document$3$1 = /*#__PURE__*/ function(Container$6$1) {
11949 _inherits(Document2, Container$6$1);
11950 function Document2(defaults) {
11951 var _this;
11952 _this = Container$6$1.call(this, _extends({
11953 type: "document"
11954 }, defaults)) || this;
11955 if (!_this.nodes) {
11956 _this.nodes = [];
11957 }
11958 return _this;
11959 }
11960 var _proto = Document2.prototype;
11961 _proto.toResult = function toResult(opts) {
11962 if (opts === void 0) opts = {};
11963 var lazy = new LazyResult$4$1(new Processor$3$1(), this, opts);
11964 return lazy.stringify();
11965 };
11966 return Document2;
11967 }(Container$6$1);
11968 Document$3$1.registerLazyResult = function(dependant) {
11969 LazyResult$4$1 = dependant;
11970 };
11971 Document$3$1.registerProcessor = function(dependant) {
11972 Processor$3$1 = dependant;
11973 };
11974 var document$1$1 = Document$3$1;
11975 Document$3$1.default = Document$3$1;
11976 var printed$1 = {};
11977 var warnOnce$2$1 = function warnOnce(message) {
11978 if (printed$1[message]) return;
11979 printed$1[message] = true;
11980 if (typeof console !== "undefined" && console.warn) {
11981 console.warn(message);
11982 }
11983 };
11984 var Warning$2$1 = /*#__PURE__*/ function() {
11985 function Warning(text, opts) {
11986 if (opts === void 0) opts = {};
11987 this.type = "warning";
11988 this.text = text;
11989 if (opts.node && opts.node.source) {
11990 var range = opts.node.rangeBy(opts);
11991 this.line = range.start.line;
11992 this.column = range.start.column;
11993 this.endLine = range.end.line;
11994 this.endColumn = range.end.column;
11995 }
11996 for(var opt in opts)this[opt] = opts[opt];
11997 }
11998 var _proto = Warning.prototype;
11999 _proto.toString = function toString() {
12000 if (this.node) {
12001 return this.node.error(this.text, {
12002 index: this.index,
12003 plugin: this.plugin,
12004 word: this.word
12005 }).message;
12006 }
12007 if (this.plugin) {
12008 return this.plugin + ": " + this.text;
12009 }
12010 return this.text;
12011 };
12012 return Warning;
12013 }();
12014 var warning$1 = Warning$2$1;
12015 Warning$2$1.default = Warning$2$1;
12016 var Warning$1$1 = warning$1;
12017 var Result$3$1 = /*#__PURE__*/ function() {
12018 function Result(processor2, root2, opts) {
12019 this.processor = processor2;
12020 this.messages = [];
12021 this.root = root2;
12022 this.opts = opts;
12023 this.css = void 0;
12024 this.map = void 0;
12025 }
12026 var _proto = Result.prototype;
12027 _proto.toString = function toString() {
12028 return this.css;
12029 };
12030 _proto.warn = function warn(text, opts) {
12031 if (opts === void 0) opts = {};
12032 if (!opts.plugin) {
12033 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
12034 opts.plugin = this.lastPlugin.postcssPlugin;
12035 }
12036 }
12037 var warning2 = new Warning$1$1(text, opts);
12038 this.messages.push(warning2);
12039 return warning2;
12040 };
12041 _proto.warnings = function warnings() {
12042 return this.messages.filter(function(i2) {
12043 return i2.type === "warning";
12044 });
12045 };
12046 _create_class(Result, [
12047 {
12048 key: "content",
12049 get: function get() {
12050 return this.css;
12051 }
12052 }
12053 ]);
12054 return Result;
12055 }();
12056 var result$1 = Result$3$1;
12057 Result$3$1.default = Result$3$1;
12058 var SINGLE_QUOTE$1 = "'".charCodeAt(0);
12059 var DOUBLE_QUOTE$1 = '"'.charCodeAt(0);
12060 var BACKSLASH$1 = "\\".charCodeAt(0);
12061 var SLASH$1 = "/".charCodeAt(0);
12062 var NEWLINE$1 = "\n".charCodeAt(0);
12063 var SPACE$1 = " ".charCodeAt(0);
12064 var FEED$1 = "\f".charCodeAt(0);
12065 var TAB$1 = " ".charCodeAt(0);
12066 var CR$1 = "\r".charCodeAt(0);
12067 var OPEN_SQUARE$1 = "[".charCodeAt(0);
12068 var CLOSE_SQUARE$1 = "]".charCodeAt(0);
12069 var OPEN_PARENTHESES$1 = "(".charCodeAt(0);
12070 var CLOSE_PARENTHESES$1 = ")".charCodeAt(0);
12071 var OPEN_CURLY$1 = "{".charCodeAt(0);
12072 var CLOSE_CURLY$1 = "}".charCodeAt(0);
12073 var SEMICOLON$1 = ";".charCodeAt(0);
12074 var ASTERISK$1 = "*".charCodeAt(0);
12075 var COLON$1 = ":".charCodeAt(0);
12076 var AT$1 = "@".charCodeAt(0);
12077 var RE_AT_END$1 = /[\t\n\f\r "#'()/;[\\\]{}]/g;
12078 var RE_WORD_END$1 = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
12079 var RE_BAD_BRACKET$1 = /.[\r\n"'(/\\]/;
12080 var RE_HEX_ESCAPE$1 = /[\da-f]/i;
12081 var tokenize$1 = function tokenizer(input2, options) {
12082 if (options === void 0) options = {};
12083 var css = input2.css.valueOf();
12084 var ignore = options.ignoreErrors;
12085 var code, next, quote, content, escape;
12086 var escaped, escapePos, prev, n2, currentToken;
12087 var length = css.length;
12088 var pos = 0;
12089 var buffer = [];
12090 var returned = [];
12091 function position() {
12092 return pos;
12093 }
12094 function unclosed(what) {
12095 throw input2.error("Unclosed " + what, pos);
12096 }
12097 function endOfFile() {
12098 return returned.length === 0 && pos >= length;
12099 }
12100 function nextToken(opts) {
12101 if (returned.length) return returned.pop();
12102 if (pos >= length) return;
12103 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
12104 code = css.charCodeAt(pos);
12105 switch(code){
12106 case NEWLINE$1:
12107 case SPACE$1:
12108 case TAB$1:
12109 case CR$1:
12110 case FEED$1:
12111 {
12112 next = pos;
12113 do {
12114 next += 1;
12115 code = css.charCodeAt(next);
12116 }while (code === SPACE$1 || code === NEWLINE$1 || code === TAB$1 || code === CR$1 || code === FEED$1);
12117 currentToken = [
12118 "space",
12119 css.slice(pos, next)
12120 ];
12121 pos = next - 1;
12122 break;
12123 }
12124 case OPEN_SQUARE$1:
12125 case CLOSE_SQUARE$1:
12126 case OPEN_CURLY$1:
12127 case CLOSE_CURLY$1:
12128 case COLON$1:
12129 case SEMICOLON$1:
12130 case CLOSE_PARENTHESES$1:
12131 {
12132 var controlChar = String.fromCharCode(code);
12133 currentToken = [
12134 controlChar,
12135 controlChar,
12136 pos
12137 ];
12138 break;
12139 }
12140 case OPEN_PARENTHESES$1:
12141 {
12142 prev = buffer.length ? buffer.pop()[1] : "";
12143 n2 = css.charCodeAt(pos + 1);
12144 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) {
12145 next = pos;
12146 do {
12147 escaped = false;
12148 next = css.indexOf(")", next + 1);
12149 if (next === -1) {
12150 if (ignore || ignoreUnclosed) {
12151 next = pos;
12152 break;
12153 } else {
12154 unclosed("bracket");
12155 }
12156 }
12157 escapePos = next;
12158 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12159 escapePos -= 1;
12160 escaped = !escaped;
12161 }
12162 }while (escaped);
12163 currentToken = [
12164 "brackets",
12165 css.slice(pos, next + 1),
12166 pos,
12167 next
12168 ];
12169 pos = next;
12170 } else {
12171 next = css.indexOf(")", pos + 1);
12172 content = css.slice(pos, next + 1);
12173 if (next === -1 || RE_BAD_BRACKET$1.test(content)) {
12174 currentToken = [
12175 "(",
12176 "(",
12177 pos
12178 ];
12179 } else {
12180 currentToken = [
12181 "brackets",
12182 content,
12183 pos,
12184 next
12185 ];
12186 pos = next;
12187 }
12188 }
12189 break;
12190 }
12191 case SINGLE_QUOTE$1:
12192 case DOUBLE_QUOTE$1:
12193 {
12194 quote = code === SINGLE_QUOTE$1 ? "'" : '"';
12195 next = pos;
12196 do {
12197 escaped = false;
12198 next = css.indexOf(quote, next + 1);
12199 if (next === -1) {
12200 if (ignore || ignoreUnclosed) {
12201 next = pos + 1;
12202 break;
12203 } else {
12204 unclosed("string");
12205 }
12206 }
12207 escapePos = next;
12208 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12209 escapePos -= 1;
12210 escaped = !escaped;
12211 }
12212 }while (escaped);
12213 currentToken = [
12214 "string",
12215 css.slice(pos, next + 1),
12216 pos,
12217 next
12218 ];
12219 pos = next;
12220 break;
12221 }
12222 case AT$1:
12223 {
12224 RE_AT_END$1.lastIndex = pos + 1;
12225 RE_AT_END$1.test(css);
12226 if (RE_AT_END$1.lastIndex === 0) {
12227 next = css.length - 1;
12228 } else {
12229 next = RE_AT_END$1.lastIndex - 2;
12230 }
12231 currentToken = [
12232 "at-word",
12233 css.slice(pos, next + 1),
12234 pos,
12235 next
12236 ];
12237 pos = next;
12238 break;
12239 }
12240 case BACKSLASH$1:
12241 {
12242 next = pos;
12243 escape = true;
12244 while(css.charCodeAt(next + 1) === BACKSLASH$1){
12245 next += 1;
12246 escape = !escape;
12247 }
12248 code = css.charCodeAt(next + 1);
12249 if (escape && code !== SLASH$1 && code !== SPACE$1 && code !== NEWLINE$1 && code !== TAB$1 && code !== CR$1 && code !== FEED$1) {
12250 next += 1;
12251 if (RE_HEX_ESCAPE$1.test(css.charAt(next))) {
12252 while(RE_HEX_ESCAPE$1.test(css.charAt(next + 1))){
12253 next += 1;
12254 }
12255 if (css.charCodeAt(next + 1) === SPACE$1) {
12256 next += 1;
12257 }
12258 }
12259 }
12260 currentToken = [
12261 "word",
12262 css.slice(pos, next + 1),
12263 pos,
12264 next
12265 ];
12266 pos = next;
12267 break;
12268 }
12269 default:
12270 {
12271 if (code === SLASH$1 && css.charCodeAt(pos + 1) === ASTERISK$1) {
12272 next = css.indexOf("*/", pos + 2) + 1;
12273 if (next === 0) {
12274 if (ignore || ignoreUnclosed) {
12275 next = css.length;
12276 } else {
12277 unclosed("comment");
12278 }
12279 }
12280 currentToken = [
12281 "comment",
12282 css.slice(pos, next + 1),
12283 pos,
12284 next
12285 ];
12286 pos = next;
12287 } else {
12288 RE_WORD_END$1.lastIndex = pos + 1;
12289 RE_WORD_END$1.test(css);
12290 if (RE_WORD_END$1.lastIndex === 0) {
12291 next = css.length - 1;
12292 } else {
12293 next = RE_WORD_END$1.lastIndex - 2;
12294 }
12295 currentToken = [
12296 "word",
12297 css.slice(pos, next + 1),
12298 pos,
12299 next
12300 ];
12301 buffer.push(currentToken);
12302 pos = next;
12303 }
12304 break;
12305 }
12306 }
12307 pos++;
12308 return currentToken;
12309 }
12310 function back(token) {
12311 returned.push(token);
12312 }
12313 return {
12314 back: back,
12315 endOfFile: endOfFile,
12316 nextToken: nextToken,
12317 position: position
12318 };
12319 };
12320 var Container$5$1 = container$1;
12321 var AtRule$3$1 = /*#__PURE__*/ function(Container$5$1) {
12322 _inherits(AtRule, Container$5$1);
12323 function AtRule(defaults) {
12324 var _this;
12325 _this = Container$5$1.call(this, defaults) || this;
12326 _this.type = "atrule";
12327 return _this;
12328 }
12329 var _proto = AtRule.prototype;
12330 _proto.append = function append() {
12331 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12332 children[_key] = arguments[_key];
12333 }
12334 var _Container$5$1_prototype_append;
12335 if (!this.proxyOf.nodes) this.nodes = [];
12336 return (_Container$5$1_prototype_append = Container$5$1.prototype.append).call.apply(_Container$5$1_prototype_append, [].concat([
12337 this
12338 ], children));
12339 };
12340 _proto.prepend = function prepend() {
12341 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12342 children[_key] = arguments[_key];
12343 }
12344 var _Container$5$1_prototype_prepend;
12345 if (!this.proxyOf.nodes) this.nodes = [];
12346 return (_Container$5$1_prototype_prepend = Container$5$1.prototype.prepend).call.apply(_Container$5$1_prototype_prepend, [].concat([
12347 this
12348 ], children));
12349 };
12350 return AtRule;
12351 }(Container$5$1);
12352 var atRule$1 = AtRule$3$1;
12353 AtRule$3$1.default = AtRule$3$1;
12354 Container$5$1.registerAtRule(AtRule$3$1);
12355 var Container$4$1 = container$1;
12356 var LazyResult$3$1, Processor$2$1;
12357 var Root$5$1 = /*#__PURE__*/ function(Container$4$1) {
12358 _inherits(Root, Container$4$1);
12359 function Root(defaults) {
12360 var _this;
12361 _this = Container$4$1.call(this, defaults) || this;
12362 _this.type = "root";
12363 if (!_this.nodes) _this.nodes = [];
12364 return _this;
12365 }
12366 var _proto = Root.prototype;
12367 _proto.normalize = function normalize(child, sample, type) {
12368 var nodes = Container$4$1.prototype.normalize.call(this, child);
12369 if (sample) {
12370 if (type === "prepend") {
12371 if (this.nodes.length > 1) {
12372 sample.raws.before = this.nodes[1].raws.before;
12373 } else {
12374 delete sample.raws.before;
12375 }
12376 } else if (this.first !== sample) {
12377 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12378 var node2 = _step.value;
12379 node2.raws.before = sample.raws.before;
12380 }
12381 }
12382 }
12383 return nodes;
12384 };
12385 _proto.removeChild = function removeChild(child, ignore) {
12386 var index2 = this.index(child);
12387 if (!ignore && index2 === 0 && this.nodes.length > 1) {
12388 this.nodes[1].raws.before = this.nodes[index2].raws.before;
12389 }
12390 return Container$4$1.prototype.removeChild.call(this, child);
12391 };
12392 _proto.toResult = function toResult(opts) {
12393 if (opts === void 0) opts = {};
12394 var lazy = new LazyResult$3$1(new Processor$2$1(), this, opts);
12395 return lazy.stringify();
12396 };
12397 return Root;
12398 }(Container$4$1);
12399 Root$5$1.registerLazyResult = function(dependant) {
12400 LazyResult$3$1 = dependant;
12401 };
12402 Root$5$1.registerProcessor = function(dependant) {
12403 Processor$2$1 = dependant;
12404 };
12405 var root$1 = Root$5$1;
12406 Root$5$1.default = Root$5$1;
12407 Container$4$1.registerRoot(Root$5$1);
12408 var list$2$1 = {
12409 comma: function comma(string) {
12410 return list$2$1.split(string, [
12411 ","
12412 ], true);
12413 },
12414 space: function space(string) {
12415 var spaces = [
12416 " ",
12417 "\n",
12418 " "
12419 ];
12420 return list$2$1.split(string, spaces);
12421 },
12422 split: function split(string, separators, last) {
12423 var array = [];
12424 var current = "";
12425 var split = false;
12426 var func = 0;
12427 var inQuote = false;
12428 var prevQuote = "";
12429 var escape = false;
12430 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
12431 var letter = _step.value;
12432 if (escape) {
12433 escape = false;
12434 } else if (letter === "\\") {
12435 escape = true;
12436 } else if (inQuote) {
12437 if (letter === prevQuote) {
12438 inQuote = false;
12439 }
12440 } else if (letter === '"' || letter === "'") {
12441 inQuote = true;
12442 prevQuote = letter;
12443 } else if (letter === "(") {
12444 func += 1;
12445 } else if (letter === ")") {
12446 if (func > 0) func -= 1;
12447 } else if (func === 0) {
12448 if (separators.includes(letter)) split = true;
12449 }
12450 if (split) {
12451 if (current !== "") array.push(current.trim());
12452 current = "";
12453 split = false;
12454 } else {
12455 current += letter;
12456 }
12457 }
12458 if (last || current !== "") array.push(current.trim());
12459 return array;
12460 }
12461 };
12462 var list_1$1 = list$2$1;
12463 list$2$1.default = list$2$1;
12464 var Container$3$1 = container$1;
12465 var list$1$1 = list_1$1;
12466 var Rule$3$1 = /*#__PURE__*/ function(Container$3$1) {
12467 _inherits(Rule, Container$3$1);
12468 function Rule(defaults) {
12469 var _this;
12470 _this = Container$3$1.call(this, defaults) || this;
12471 _this.type = "rule";
12472 if (!_this.nodes) _this.nodes = [];
12473 return _this;
12474 }
12475 _create_class(Rule, [
12476 {
12477 key: "selectors",
12478 get: function get() {
12479 return list$1$1.comma(this.selector);
12480 },
12481 set: function set(values) {
12482 var match = this.selector ? this.selector.match(/,\s*/) : null;
12483 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
12484 this.selector = values.join(sep2);
12485 }
12486 }
12487 ]);
12488 return Rule;
12489 }(Container$3$1);
12490 var rule$1 = Rule$3$1;
12491 Rule$3$1.default = Rule$3$1;
12492 Container$3$1.registerRule(Rule$3$1);
12493 var Declaration$2$1 = declaration$1;
12494 var tokenizer2$1 = tokenize$1;
12495 var Comment$2$1 = comment$1;
12496 var AtRule$2$1 = atRule$1;
12497 var Root$4$1 = root$1;
12498 var Rule$2$1 = rule$1;
12499 var SAFE_COMMENT_NEIGHBOR$1 = {
12500 empty: true,
12501 space: true
12502 };
12503 function findLastWithPosition$1(tokens) {
12504 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
12505 var token = tokens[i2];
12506 var pos = token[3] || token[2];
12507 if (pos) return pos;
12508 }
12509 }
12510 var Parser$1$1 = /*#__PURE__*/ function() {
12511 function Parser(input2) {
12512 this.input = input2;
12513 this.root = new Root$4$1();
12514 this.current = this.root;
12515 this.spaces = "";
12516 this.semicolon = false;
12517 this.createTokenizer();
12518 this.root.source = {
12519 input: input2,
12520 start: {
12521 column: 1,
12522 line: 1,
12523 offset: 0
12524 }
12525 };
12526 }
12527 var _proto = Parser.prototype;
12528 _proto.atrule = function atrule(token) {
12529 var node2 = new AtRule$2$1();
12530 node2.name = token[1].slice(1);
12531 if (node2.name === "") {
12532 this.unnamedAtrule(node2, token);
12533 }
12534 this.init(node2, token[2]);
12535 var type;
12536 var prev;
12537 var shift;
12538 var last = false;
12539 var open = false;
12540 var params = [];
12541 var brackets = [];
12542 while(!this.tokenizer.endOfFile()){
12543 token = this.tokenizer.nextToken();
12544 type = token[0];
12545 if (type === "(" || type === "[") {
12546 brackets.push(type === "(" ? ")" : "]");
12547 } else if (type === "{" && brackets.length > 0) {
12548 brackets.push("}");
12549 } else if (type === brackets[brackets.length - 1]) {
12550 brackets.pop();
12551 }
12552 if (brackets.length === 0) {
12553 if (type === ";") {
12554 node2.source.end = this.getPosition(token[2]);
12555 node2.source.end.offset++;
12556 this.semicolon = true;
12557 break;
12558 } else if (type === "{") {
12559 open = true;
12560 break;
12561 } else if (type === "}") {
12562 if (params.length > 0) {
12563 shift = params.length - 1;
12564 prev = params[shift];
12565 while(prev && prev[0] === "space"){
12566 prev = params[--shift];
12567 }
12568 if (prev) {
12569 node2.source.end = this.getPosition(prev[3] || prev[2]);
12570 node2.source.end.offset++;
12571 }
12572 }
12573 this.end(token);
12574 break;
12575 } else {
12576 params.push(token);
12577 }
12578 } else {
12579 params.push(token);
12580 }
12581 if (this.tokenizer.endOfFile()) {
12582 last = true;
12583 break;
12584 }
12585 }
12586 node2.raws.between = this.spacesAndCommentsFromEnd(params);
12587 if (params.length) {
12588 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
12589 this.raw(node2, "params", params);
12590 if (last) {
12591 token = params[params.length - 1];
12592 node2.source.end = this.getPosition(token[3] || token[2]);
12593 node2.source.end.offset++;
12594 this.spaces = node2.raws.between;
12595 node2.raws.between = "";
12596 }
12597 } else {
12598 node2.raws.afterName = "";
12599 node2.params = "";
12600 }
12601 if (open) {
12602 node2.nodes = [];
12603 this.current = node2;
12604 }
12605 };
12606 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
12607 var colon = this.colon(tokens);
12608 if (colon === false) return;
12609 var founded = 0;
12610 var token;
12611 for(var j = colon - 1; j >= 0; j--){
12612 token = tokens[j];
12613 if (token[0] !== "space") {
12614 founded += 1;
12615 if (founded === 2) break;
12616 }
12617 }
12618 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
12619 };
12620 _proto.colon = function colon(tokens) {
12621 var brackets = 0;
12622 var token, type, prev;
12623 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
12624 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
12625 token = element;
12626 type = token[0];
12627 if (type === "(") {
12628 brackets += 1;
12629 }
12630 if (type === ")") {
12631 brackets -= 1;
12632 }
12633 if (brackets === 0 && type === ":") {
12634 if (!prev) {
12635 this.doubleColon(token);
12636 } else if (prev[0] === "word" && prev[1] === "progid") {
12637 continue;
12638 } else {
12639 return i2;
12640 }
12641 }
12642 prev = token;
12643 }
12644 return false;
12645 };
12646 _proto.comment = function comment(token) {
12647 var node2 = new Comment$2$1();
12648 this.init(node2, token[2]);
12649 node2.source.end = this.getPosition(token[3] || token[2]);
12650 node2.source.end.offset++;
12651 var text = token[1].slice(2, -2);
12652 if (/^\s*$/.test(text)) {
12653 node2.text = "";
12654 node2.raws.left = text;
12655 node2.raws.right = "";
12656 } else {
12657 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
12658 node2.text = match[2];
12659 node2.raws.left = match[1];
12660 node2.raws.right = match[3];
12661 }
12662 };
12663 _proto.createTokenizer = function createTokenizer() {
12664 this.tokenizer = tokenizer2$1(this.input);
12665 };
12666 _proto.decl = function decl(tokens, customProperty) {
12667 var node2 = new Declaration$2$1();
12668 this.init(node2, tokens[0][2]);
12669 var last = tokens[tokens.length - 1];
12670 if (last[0] === ";") {
12671 this.semicolon = true;
12672 tokens.pop();
12673 }
12674 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition$1(tokens));
12675 node2.source.end.offset++;
12676 while(tokens[0][0] !== "word"){
12677 if (tokens.length === 1) this.unknownWord(tokens);
12678 node2.raws.before += tokens.shift()[1];
12679 }
12680 node2.source.start = this.getPosition(tokens[0][2]);
12681 node2.prop = "";
12682 while(tokens.length){
12683 var type = tokens[0][0];
12684 if (type === ":" || type === "space" || type === "comment") {
12685 break;
12686 }
12687 node2.prop += tokens.shift()[1];
12688 }
12689 node2.raws.between = "";
12690 var token;
12691 while(tokens.length){
12692 token = tokens.shift();
12693 if (token[0] === ":") {
12694 node2.raws.between += token[1];
12695 break;
12696 } else {
12697 if (token[0] === "word" && /\w/.test(token[1])) {
12698 this.unknownWord([
12699 token
12700 ]);
12701 }
12702 node2.raws.between += token[1];
12703 }
12704 }
12705 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
12706 node2.raws.before += node2.prop[0];
12707 node2.prop = node2.prop.slice(1);
12708 }
12709 var firstSpaces = [];
12710 var next;
12711 while(tokens.length){
12712 next = tokens[0][0];
12713 if (next !== "space" && next !== "comment") break;
12714 firstSpaces.push(tokens.shift());
12715 }
12716 this.precheckMissedSemicolon(tokens);
12717 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
12718 token = tokens[i2];
12719 if (token[1].toLowerCase() === "!important") {
12720 node2.important = true;
12721 var string = this.stringFrom(tokens, i2);
12722 string = this.spacesFromEnd(tokens) + string;
12723 if (string !== " !important") node2.raws.important = string;
12724 break;
12725 } else if (token[1].toLowerCase() === "important") {
12726 var cache = tokens.slice(0);
12727 var str = "";
12728 for(var j = i2; j > 0; j--){
12729 var type1 = cache[j][0];
12730 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
12731 break;
12732 }
12733 str = cache.pop()[1] + str;
12734 }
12735 if (str.trim().indexOf("!") === 0) {
12736 node2.important = true;
12737 node2.raws.important = str;
12738 tokens = cache;
12739 }
12740 }
12741 if (token[0] !== "space" && token[0] !== "comment") {
12742 break;
12743 }
12744 }
12745 var hasWord = tokens.some(function(i2) {
12746 return i2[0] !== "space" && i2[0] !== "comment";
12747 });
12748 if (hasWord) {
12749 node2.raws.between += firstSpaces.map(function(i2) {
12750 return i2[1];
12751 }).join("");
12752 firstSpaces = [];
12753 }
12754 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
12755 if (node2.value.includes(":") && !customProperty) {
12756 this.checkMissedSemicolon(tokens);
12757 }
12758 };
12759 _proto.doubleColon = function doubleColon(token) {
12760 throw this.input.error("Double colon", {
12761 offset: token[2]
12762 }, {
12763 offset: token[2] + token[1].length
12764 });
12765 };
12766 _proto.emptyRule = function emptyRule(token) {
12767 var node2 = new Rule$2$1();
12768 this.init(node2, token[2]);
12769 node2.selector = "";
12770 node2.raws.between = "";
12771 this.current = node2;
12772 };
12773 _proto.end = function end(token) {
12774 if (this.current.nodes && this.current.nodes.length) {
12775 this.current.raws.semicolon = this.semicolon;
12776 }
12777 this.semicolon = false;
12778 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
12779 this.spaces = "";
12780 if (this.current.parent) {
12781 this.current.source.end = this.getPosition(token[2]);
12782 this.current.source.end.offset++;
12783 this.current = this.current.parent;
12784 } else {
12785 this.unexpectedClose(token);
12786 }
12787 };
12788 _proto.endFile = function endFile() {
12789 if (this.current.parent) this.unclosedBlock();
12790 if (this.current.nodes && this.current.nodes.length) {
12791 this.current.raws.semicolon = this.semicolon;
12792 }
12793 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
12794 this.root.source.end = this.getPosition(this.tokenizer.position());
12795 };
12796 _proto.freeSemicolon = function freeSemicolon(token) {
12797 this.spaces += token[1];
12798 if (this.current.nodes) {
12799 var prev = this.current.nodes[this.current.nodes.length - 1];
12800 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
12801 prev.raws.ownSemicolon = this.spaces;
12802 this.spaces = "";
12803 }
12804 }
12805 };
12806 // Helpers
12807 _proto.getPosition = function getPosition(offset) {
12808 var pos = this.input.fromOffset(offset);
12809 return {
12810 column: pos.col,
12811 line: pos.line,
12812 offset: offset
12813 };
12814 };
12815 _proto.init = function init(node2, offset) {
12816 this.current.push(node2);
12817 node2.source = {
12818 input: this.input,
12819 start: this.getPosition(offset)
12820 };
12821 node2.raws.before = this.spaces;
12822 this.spaces = "";
12823 if (node2.type !== "comment") this.semicolon = false;
12824 };
12825 _proto.other = function other(start) {
12826 var end = false;
12827 var type = null;
12828 var colon = false;
12829 var bracket = null;
12830 var brackets = [];
12831 var customProperty = start[1].startsWith("--");
12832 var tokens = [];
12833 var token = start;
12834 while(token){
12835 type = token[0];
12836 tokens.push(token);
12837 if (type === "(" || type === "[") {
12838 if (!bracket) bracket = token;
12839 brackets.push(type === "(" ? ")" : "]");
12840 } else if (customProperty && colon && type === "{") {
12841 if (!bracket) bracket = token;
12842 brackets.push("}");
12843 } else if (brackets.length === 0) {
12844 if (type === ";") {
12845 if (colon) {
12846 this.decl(tokens, customProperty);
12847 return;
12848 } else {
12849 break;
12850 }
12851 } else if (type === "{") {
12852 this.rule(tokens);
12853 return;
12854 } else if (type === "}") {
12855 this.tokenizer.back(tokens.pop());
12856 end = true;
12857 break;
12858 } else if (type === ":") {
12859 colon = true;
12860 }
12861 } else if (type === brackets[brackets.length - 1]) {
12862 brackets.pop();
12863 if (brackets.length === 0) bracket = null;
12864 }
12865 token = this.tokenizer.nextToken();
12866 }
12867 if (this.tokenizer.endOfFile()) end = true;
12868 if (brackets.length > 0) this.unclosedBracket(bracket);
12869 if (end && colon) {
12870 if (!customProperty) {
12871 while(tokens.length){
12872 token = tokens[tokens.length - 1][0];
12873 if (token !== "space" && token !== "comment") break;
12874 this.tokenizer.back(tokens.pop());
12875 }
12876 }
12877 this.decl(tokens, customProperty);
12878 } else {
12879 this.unknownWord(tokens);
12880 }
12881 };
12882 _proto.parse = function parse() {
12883 var token;
12884 while(!this.tokenizer.endOfFile()){
12885 token = this.tokenizer.nextToken();
12886 switch(token[0]){
12887 case "space":
12888 this.spaces += token[1];
12889 break;
12890 case ";":
12891 this.freeSemicolon(token);
12892 break;
12893 case "}":
12894 this.end(token);
12895 break;
12896 case "comment":
12897 this.comment(token);
12898 break;
12899 case "at-word":
12900 this.atrule(token);
12901 break;
12902 case "{":
12903 this.emptyRule(token);
12904 break;
12905 default:
12906 this.other(token);
12907 break;
12908 }
12909 }
12910 this.endFile();
12911 };
12912 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
12913 _proto.raw = function raw(node2, prop, tokens, customProperty) {
12914 var token, type;
12915 var length = tokens.length;
12916 var value = "";
12917 var clean = true;
12918 var next, prev;
12919 for(var i2 = 0; i2 < length; i2 += 1){
12920 token = tokens[i2];
12921 type = token[0];
12922 if (type === "space" && i2 === length - 1 && !customProperty) {
12923 clean = false;
12924 } else if (type === "comment") {
12925 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
12926 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
12927 if (!SAFE_COMMENT_NEIGHBOR$1[prev] && !SAFE_COMMENT_NEIGHBOR$1[next]) {
12928 if (value.slice(-1) === ",") {
12929 clean = false;
12930 } else {
12931 value += token[1];
12932 }
12933 } else {
12934 clean = false;
12935 }
12936 } else {
12937 value += token[1];
12938 }
12939 }
12940 if (!clean) {
12941 var raw = tokens.reduce(function(all, i2) {
12942 return all + i2[1];
12943 }, "");
12944 node2.raws[prop] = {
12945 raw: raw,
12946 value: value
12947 };
12948 }
12949 node2[prop] = value;
12950 };
12951 _proto.rule = function rule(tokens) {
12952 tokens.pop();
12953 var node2 = new Rule$2$1();
12954 this.init(node2, tokens[0][2]);
12955 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
12956 this.raw(node2, "selector", tokens);
12957 this.current = node2;
12958 };
12959 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
12960 var lastTokenType;
12961 var spaces = "";
12962 while(tokens.length){
12963 lastTokenType = tokens[tokens.length - 1][0];
12964 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
12965 spaces = tokens.pop()[1] + spaces;
12966 }
12967 return spaces;
12968 };
12969 // Errors
12970 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
12971 var next;
12972 var spaces = "";
12973 while(tokens.length){
12974 next = tokens[0][0];
12975 if (next !== "space" && next !== "comment") break;
12976 spaces += tokens.shift()[1];
12977 }
12978 return spaces;
12979 };
12980 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
12981 var lastTokenType;
12982 var spaces = "";
12983 while(tokens.length){
12984 lastTokenType = tokens[tokens.length - 1][0];
12985 if (lastTokenType !== "space") break;
12986 spaces = tokens.pop()[1] + spaces;
12987 }
12988 return spaces;
12989 };
12990 _proto.stringFrom = function stringFrom(tokens, from) {
12991 var result2 = "";
12992 for(var i2 = from; i2 < tokens.length; i2++){
12993 result2 += tokens[i2][1];
12994 }
12995 tokens.splice(from, tokens.length - from);
12996 return result2;
12997 };
12998 _proto.unclosedBlock = function unclosedBlock() {
12999 var pos = this.current.source.start;
13000 throw this.input.error("Unclosed block", pos.line, pos.column);
13001 };
13002 _proto.unclosedBracket = function unclosedBracket(bracket) {
13003 throw this.input.error("Unclosed bracket", {
13004 offset: bracket[2]
13005 }, {
13006 offset: bracket[2] + 1
13007 });
13008 };
13009 _proto.unexpectedClose = function unexpectedClose(token) {
13010 throw this.input.error("Unexpected }", {
13011 offset: token[2]
13012 }, {
13013 offset: token[2] + 1
13014 });
13015 };
13016 _proto.unknownWord = function unknownWord(tokens) {
13017 throw this.input.error("Unknown word", {
13018 offset: tokens[0][2]
13019 }, {
13020 offset: tokens[0][2] + tokens[0][1].length
13021 });
13022 };
13023 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
13024 throw this.input.error("At-rule without name", {
13025 offset: token[2]
13026 }, {
13027 offset: token[2] + token[1].length
13028 });
13029 };
13030 return Parser;
13031 }();
13032 var parser$1 = Parser$1$1;
13033 var Container$2$1 = container$1;
13034 var Parser2$1 = parser$1;
13035 var Input$2$1 = input$1;
13036 function parse$3$1(css, opts) {
13037 var input2 = new Input$2$1(css, opts);
13038 var parser2 = new Parser2$1(input2);
13039 try {
13040 parser2.parse();
13041 } catch (e2) {
13042 if (true) {
13043 if (e2.name === "CssSyntaxError" && opts && opts.from) {
13044 if (/\.scss$/i.test(opts.from)) {
13045 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
13046 } else if (/\.sass/i.test(opts.from)) {
13047 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
13048 } else if (/\.less$/i.test(opts.from)) {
13049 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
13050 }
13051 }
13052 }
13053 throw e2;
13054 }
13055 return parser2.root;
13056 }
13057 var parse_1$1 = parse$3$1;
13058 parse$3$1.default = parse$3$1;
13059 Container$2$1.registerParse(parse$3$1);
13060 var isClean$3 = symbols$1.isClean, my$3 = symbols$1.my;
13061 var MapGenerator$1$1 = mapGenerator$1;
13062 var stringify$2$1 = stringify_1$1;
13063 var Container$1$1 = container$1;
13064 var Document$2$1 = document$1$1;
13065 var warnOnce$1$1 = warnOnce$2$1;
13066 var Result$2$1 = result$1;
13067 var parse$2$1 = parse_1$1;
13068 var Root$3$1 = root$1;
13069 var TYPE_TO_CLASS_NAME$1 = {
13070 atrule: "AtRule",
13071 comment: "Comment",
13072 decl: "Declaration",
13073 document: "Document",
13074 root: "Root",
13075 rule: "Rule"
13076 };
13077 var PLUGIN_PROPS$1 = {
13078 AtRule: true,
13079 AtRuleExit: true,
13080 Comment: true,
13081 CommentExit: true,
13082 Declaration: true,
13083 DeclarationExit: true,
13084 Document: true,
13085 DocumentExit: true,
13086 Once: true,
13087 OnceExit: true,
13088 postcssPlugin: true,
13089 prepare: true,
13090 Root: true,
13091 RootExit: true,
13092 Rule: true,
13093 RuleExit: true
13094 };
13095 var NOT_VISITORS$1 = {
13096 Once: true,
13097 postcssPlugin: true,
13098 prepare: true
13099 };
13100 var CHILDREN$1 = 0;
13101 function isPromise$1(obj) {
13102 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
13103 }
13104 function getEvents$1(node2) {
13105 var key = false;
13106 var type = TYPE_TO_CLASS_NAME$1[node2.type];
13107 if (node2.type === "decl") {
13108 key = node2.prop.toLowerCase();
13109 } else if (node2.type === "atrule") {
13110 key = node2.name.toLowerCase();
13111 }
13112 if (key && node2.append) {
13113 return [
13114 type,
13115 type + "-" + key,
13116 CHILDREN$1,
13117 type + "Exit",
13118 type + "Exit-" + key
13119 ];
13120 } else if (key) {
13121 return [
13122 type,
13123 type + "-" + key,
13124 type + "Exit",
13125 type + "Exit-" + key
13126 ];
13127 } else if (node2.append) {
13128 return [
13129 type,
13130 CHILDREN$1,
13131 type + "Exit"
13132 ];
13133 } else {
13134 return [
13135 type,
13136 type + "Exit"
13137 ];
13138 }
13139 }
13140 function toStack$1(node2) {
13141 var events;
13142 if (node2.type === "document") {
13143 events = [
13144 "Document",
13145 CHILDREN$1,
13146 "DocumentExit"
13147 ];
13148 } else if (node2.type === "root") {
13149 events = [
13150 "Root",
13151 CHILDREN$1,
13152 "RootExit"
13153 ];
13154 } else {
13155 events = getEvents$1(node2);
13156 }
13157 return {
13158 eventIndex: 0,
13159 events: events,
13160 iterator: 0,
13161 node: node2,
13162 visitorIndex: 0,
13163 visitors: []
13164 };
13165 }
13166 function cleanMarks$1(node2) {
13167 node2[isClean$3] = false;
13168 if (node2.nodes) node2.nodes.forEach(function(i2) {
13169 return cleanMarks$1(i2);
13170 });
13171 return node2;
13172 }
13173 var postcss$2$1 = {};
13174 var LazyResult$2$1 = /*#__PURE__*/ function() {
13175 function LazyResult(processor2, css, opts) {
13176 var _this = this;
13177 this.stringified = false;
13178 this.processed = false;
13179 var root2;
13180 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
13181 root2 = cleanMarks$1(css);
13182 } else if (_instanceof(css, LazyResult) || _instanceof(css, Result$2$1)) {
13183 root2 = cleanMarks$1(css.root);
13184 if (css.map) {
13185 if (typeof opts.map === "undefined") opts.map = {};
13186 if (!opts.map.inline) opts.map.inline = false;
13187 opts.map.prev = css.map;
13188 }
13189 } else {
13190 var parser2 = parse$2$1;
13191 if (opts.syntax) parser2 = opts.syntax.parse;
13192 if (opts.parser) parser2 = opts.parser;
13193 if (parser2.parse) parser2 = parser2.parse;
13194 try {
13195 root2 = parser2(css, opts);
13196 } catch (error) {
13197 this.processed = true;
13198 this.error = error;
13199 }
13200 if (root2 && !root2[my$3]) {
13201 Container$1$1.rebuild(root2);
13202 }
13203 }
13204 this.result = new Result$2$1(processor2, root2, opts);
13205 this.helpers = _extends({}, postcss$2$1, {
13206 postcss: postcss$2$1,
13207 result: this.result
13208 });
13209 this.plugins = this.processor.plugins.map(function(plugin22) {
13210 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
13211 return _extends({}, plugin22, plugin22.prepare(_this.result));
13212 } else {
13213 return plugin22;
13214 }
13215 });
13216 }
13217 var _proto = LazyResult.prototype;
13218 _proto.async = function async() {
13219 if (this.error) return Promise.reject(this.error);
13220 if (this.processed) return Promise.resolve(this.result);
13221 if (!this.processing) {
13222 this.processing = this.runAsync();
13223 }
13224 return this.processing;
13225 };
13226 _proto.catch = function _catch(onRejected) {
13227 return this.async().catch(onRejected);
13228 };
13229 _proto.finally = function _finally(onFinally) {
13230 return this.async().then(onFinally, onFinally);
13231 };
13232 _proto.getAsyncError = function getAsyncError() {
13233 throw new Error("Use process(css).then(cb) to work with async plugins");
13234 };
13235 _proto.handleError = function handleError(error, node2) {
13236 var plugin22 = this.result.lastPlugin;
13237 try {
13238 if (node2) node2.addToError(error);
13239 this.error = error;
13240 if (error.name === "CssSyntaxError" && !error.plugin) {
13241 error.plugin = plugin22.postcssPlugin;
13242 error.setMessage();
13243 } else if (plugin22.postcssVersion) {
13244 if (true) {
13245 var pluginName = plugin22.postcssPlugin;
13246 var pluginVer = plugin22.postcssVersion;
13247 var runtimeVer = this.result.processor.version;
13248 var a2 = pluginVer.split(".");
13249 var b = runtimeVer.split(".");
13250 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
13251 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.");
13252 }
13253 }
13254 }
13255 } catch (err) {
13256 if (console && console.error) console.error(err);
13257 }
13258 return error;
13259 };
13260 _proto.prepareVisitors = function prepareVisitors() {
13261 var _this = this;
13262 this.listeners = {};
13263 var add = function(plugin22, type, cb) {
13264 if (!_this.listeners[type]) _this.listeners[type] = [];
13265 _this.listeners[type].push([
13266 plugin22,
13267 cb
13268 ]);
13269 };
13270 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13271 var plugin22 = _step.value;
13272 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
13273 for(var event in plugin22){
13274 if (!PLUGIN_PROPS$1[event] && /^[A-Z]/.test(event)) {
13275 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
13276 }
13277 if (!NOT_VISITORS$1[event]) {
13278 if (_type_of(plugin22[event]) === "object") {
13279 for(var filter in plugin22[event]){
13280 if (filter === "*") {
13281 add(plugin22, event, plugin22[event][filter]);
13282 } else {
13283 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
13284 }
13285 }
13286 } else if (typeof plugin22[event] === "function") {
13287 add(plugin22, event, plugin22[event]);
13288 }
13289 }
13290 }
13291 }
13292 }
13293 this.hasListener = Object.keys(this.listeners).length > 0;
13294 };
13295 _proto.runAsync = function runAsync() {
13296 var _this = this;
13297 return _async_to_generator(function() {
13298 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
13299 return _ts_generator(this, function(_state) {
13300 switch(_state.label){
13301 case 0:
13302 _this.plugin = 0;
13303 i2 = 0;
13304 _state.label = 1;
13305 case 1:
13306 if (!(i2 < _this.plugins.length)) return [
13307 3,
13308 6
13309 ];
13310 plugin22 = _this.plugins[i2];
13311 promise = _this.runOnRoot(plugin22);
13312 if (!isPromise$1(promise)) return [
13313 3,
13314 5
13315 ];
13316 _state.label = 2;
13317 case 2:
13318 _state.trys.push([
13319 2,
13320 4,
13321 ,
13322 5
13323 ]);
13324 return [
13325 4,
13326 promise
13327 ];
13328 case 3:
13329 _state.sent();
13330 return [
13331 3,
13332 5
13333 ];
13334 case 4:
13335 error = _state.sent();
13336 throw _this.handleError(error);
13337 case 5:
13338 i2++;
13339 return [
13340 3,
13341 1
13342 ];
13343 case 6:
13344 _this.prepareVisitors();
13345 if (!_this.hasListener) return [
13346 3,
13347 18
13348 ];
13349 root2 = _this.result.root;
13350 _state.label = 7;
13351 case 7:
13352 if (!!root2[isClean$3]) return [
13353 3,
13354 14
13355 ];
13356 root2[isClean$3] = true;
13357 stack = [
13358 toStack$1(root2)
13359 ];
13360 _state.label = 8;
13361 case 8:
13362 if (!(stack.length > 0)) return [
13363 3,
13364 13
13365 ];
13366 promise1 = _this.visitTick(stack);
13367 if (!isPromise$1(promise1)) return [
13368 3,
13369 12
13370 ];
13371 _state.label = 9;
13372 case 9:
13373 _state.trys.push([
13374 9,
13375 11,
13376 ,
13377 12
13378 ]);
13379 return [
13380 4,
13381 promise1
13382 ];
13383 case 10:
13384 _state.sent();
13385 return [
13386 3,
13387 12
13388 ];
13389 case 11:
13390 e2 = _state.sent();
13391 node2 = stack[stack.length - 1].node;
13392 throw _this.handleError(e2, node2);
13393 case 12:
13394 return [
13395 3,
13396 8
13397 ];
13398 case 13:
13399 return [
13400 3,
13401 7
13402 ];
13403 case 14:
13404 if (!_this.listeners.OnceExit) return [
13405 3,
13406 18
13407 ];
13408 _loop = function() {
13409 var _step_value, plugin22, visitor, roots, e2;
13410 return _ts_generator(this, function(_state) {
13411 switch(_state.label){
13412 case 0:
13413 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13414 _this.result.lastPlugin = plugin22;
13415 _state.label = 1;
13416 case 1:
13417 _state.trys.push([
13418 1,
13419 6,
13420 ,
13421 7
13422 ]);
13423 if (!(root2.type === "document")) return [
13424 3,
13425 3
13426 ];
13427 roots = root2.nodes.map(function(subRoot) {
13428 return visitor(subRoot, _this.helpers);
13429 });
13430 return [
13431 4,
13432 Promise.all(roots)
13433 ];
13434 case 2:
13435 _state.sent();
13436 return [
13437 3,
13438 5
13439 ];
13440 case 3:
13441 return [
13442 4,
13443 visitor(root2, _this.helpers)
13444 ];
13445 case 4:
13446 _state.sent();
13447 _state.label = 5;
13448 case 5:
13449 return [
13450 3,
13451 7
13452 ];
13453 case 6:
13454 e2 = _state.sent();
13455 throw _this.handleError(e2);
13456 case 7:
13457 return [
13458 2
13459 ];
13460 }
13461 });
13462 };
13463 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
13464 _state.label = 15;
13465 case 15:
13466 if (!!(_step = _iterator()).done) return [
13467 3,
13468 18
13469 ];
13470 return [
13471 5,
13472 _ts_values(_loop())
13473 ];
13474 case 16:
13475 _state.sent();
13476 _state.label = 17;
13477 case 17:
13478 return [
13479 3,
13480 15
13481 ];
13482 case 18:
13483 _this.processed = true;
13484 return [
13485 2,
13486 _this.stringify()
13487 ];
13488 }
13489 });
13490 })();
13491 };
13492 _proto.runOnRoot = function runOnRoot(plugin22) {
13493 var _this = this;
13494 this.result.lastPlugin = plugin22;
13495 try {
13496 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
13497 if (this.result.root.type === "document") {
13498 var roots = this.result.root.nodes.map(function(root2) {
13499 return plugin22.Once(root2, _this.helpers);
13500 });
13501 if (isPromise$1(roots[0])) {
13502 return Promise.all(roots);
13503 }
13504 return roots;
13505 }
13506 return plugin22.Once(this.result.root, this.helpers);
13507 } else if (typeof plugin22 === "function") {
13508 return plugin22(this.result.root, this.result);
13509 }
13510 } catch (error) {
13511 throw this.handleError(error);
13512 }
13513 };
13514 _proto.stringify = function stringify() {
13515 if (this.error) throw this.error;
13516 if (this.stringified) return this.result;
13517 this.stringified = true;
13518 this.sync();
13519 var opts = this.result.opts;
13520 var str = stringify$2$1;
13521 if (opts.syntax) str = opts.syntax.stringify;
13522 if (opts.stringifier) str = opts.stringifier;
13523 if (str.stringify) str = str.stringify;
13524 var map = new MapGenerator$1$1(str, this.result.root, this.result.opts);
13525 var data = map.generate();
13526 this.result.css = data[0];
13527 this.result.map = data[1];
13528 return this.result;
13529 };
13530 _proto.sync = function sync() {
13531 if (this.error) throw this.error;
13532 if (this.processed) return this.result;
13533 this.processed = true;
13534 if (this.processing) {
13535 throw this.getAsyncError();
13536 }
13537 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13538 var plugin22 = _step.value;
13539 var promise = this.runOnRoot(plugin22);
13540 if (isPromise$1(promise)) {
13541 throw this.getAsyncError();
13542 }
13543 }
13544 this.prepareVisitors();
13545 if (this.hasListener) {
13546 var root2 = this.result.root;
13547 while(!root2[isClean$3]){
13548 root2[isClean$3] = true;
13549 this.walkSync(root2);
13550 }
13551 if (this.listeners.OnceExit) {
13552 if (root2.type === "document") {
13553 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
13554 var subRoot = _step1.value;
13555 this.visitSync(this.listeners.OnceExit, subRoot);
13556 }
13557 } else {
13558 this.visitSync(this.listeners.OnceExit, root2);
13559 }
13560 }
13561 }
13562 return this.result;
13563 };
13564 _proto.then = function then(onFulfilled, onRejected) {
13565 if (true) {
13566 if (!("from" in this.opts)) {
13567 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.");
13568 }
13569 }
13570 return this.async().then(onFulfilled, onRejected);
13571 };
13572 _proto.toString = function toString() {
13573 return this.css;
13574 };
13575 _proto.visitSync = function visitSync(visitors, node2) {
13576 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
13577 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13578 this.result.lastPlugin = plugin22;
13579 var promise = void 0;
13580 try {
13581 promise = visitor(node2, this.helpers);
13582 } catch (e2) {
13583 throw this.handleError(e2, node2.proxyOf);
13584 }
13585 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
13586 return true;
13587 }
13588 if (isPromise$1(promise)) {
13589 throw this.getAsyncError();
13590 }
13591 }
13592 };
13593 _proto.visitTick = function visitTick(stack) {
13594 var visit2 = stack[stack.length - 1];
13595 var node2 = visit2.node, visitors = visit2.visitors;
13596 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
13597 stack.pop();
13598 return;
13599 }
13600 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
13601 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
13602 visit2.visitorIndex += 1;
13603 if (visit2.visitorIndex === visitors.length) {
13604 visit2.visitors = [];
13605 visit2.visitorIndex = 0;
13606 }
13607 this.result.lastPlugin = plugin22;
13608 try {
13609 return visitor(node2.toProxy(), this.helpers);
13610 } catch (e2) {
13611 throw this.handleError(e2, node2);
13612 }
13613 }
13614 if (visit2.iterator !== 0) {
13615 var iterator = visit2.iterator;
13616 var child;
13617 while(child = node2.nodes[node2.indexes[iterator]]){
13618 node2.indexes[iterator] += 1;
13619 if (!child[isClean$3]) {
13620 child[isClean$3] = true;
13621 stack.push(toStack$1(child));
13622 return;
13623 }
13624 }
13625 visit2.iterator = 0;
13626 delete node2.indexes[iterator];
13627 }
13628 var events = visit2.events;
13629 while(visit2.eventIndex < events.length){
13630 var event = events[visit2.eventIndex];
13631 visit2.eventIndex += 1;
13632 if (event === CHILDREN$1) {
13633 if (node2.nodes && node2.nodes.length) {
13634 node2[isClean$3] = true;
13635 visit2.iterator = node2.getIterator();
13636 }
13637 return;
13638 } else if (this.listeners[event]) {
13639 visit2.visitors = this.listeners[event];
13640 return;
13641 }
13642 }
13643 stack.pop();
13644 };
13645 _proto.walkSync = function walkSync(node2) {
13646 var _this = this;
13647 node2[isClean$3] = true;
13648 var events = getEvents$1(node2);
13649 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
13650 var event = _step.value;
13651 if (event === CHILDREN$1) {
13652 if (node2.nodes) {
13653 node2.each(function(child) {
13654 if (!child[isClean$3]) _this.walkSync(child);
13655 });
13656 }
13657 } else {
13658 var visitors = this.listeners[event];
13659 if (visitors) {
13660 if (this.visitSync(visitors, node2.toProxy())) return;
13661 }
13662 }
13663 }
13664 };
13665 _proto.warnings = function warnings() {
13666 return this.sync().warnings();
13667 };
13668 _create_class(LazyResult, [
13669 {
13670 key: "content",
13671 get: function get() {
13672 return this.stringify().content;
13673 }
13674 },
13675 {
13676 key: "css",
13677 get: function get() {
13678 return this.stringify().css;
13679 }
13680 },
13681 {
13682 key: "map",
13683 get: function get() {
13684 return this.stringify().map;
13685 }
13686 },
13687 {
13688 key: "messages",
13689 get: function get() {
13690 return this.sync().messages;
13691 }
13692 },
13693 {
13694 key: "opts",
13695 get: function get() {
13696 return this.result.opts;
13697 }
13698 },
13699 {
13700 key: "processor",
13701 get: function get() {
13702 return this.result.processor;
13703 }
13704 },
13705 {
13706 key: "root",
13707 get: function get() {
13708 return this.sync().root;
13709 }
13710 },
13711 {
13712 key: Symbol.toStringTag,
13713 get: function get() {
13714 return "LazyResult";
13715 }
13716 }
13717 ]);
13718 return LazyResult;
13719 }();
13720 LazyResult$2$1.registerPostcss = function(dependant) {
13721 postcss$2$1 = dependant;
13722 };
13723 var lazyResult$1 = LazyResult$2$1;
13724 LazyResult$2$1.default = LazyResult$2$1;
13725 Root$3$1.registerLazyResult(LazyResult$2$1);
13726 Document$2$1.registerLazyResult(LazyResult$2$1);
13727 var MapGenerator2$1 = mapGenerator$1;
13728 var stringify$1$1 = stringify_1$1;
13729 var warnOnce2$1 = warnOnce$2$1;
13730 var parse$1$1 = parse_1$1;
13731 var Result$1$1 = result$1;
13732 var NoWorkResult$1$1 = /*#__PURE__*/ function() {
13733 function NoWorkResult(processor2, css, opts) {
13734 css = css.toString();
13735 this.stringified = false;
13736 this._processor = processor2;
13737 this._css = css;
13738 this._opts = opts;
13739 this._map = void 0;
13740 var root2;
13741 var str = stringify$1$1;
13742 this.result = new Result$1$1(this._processor, root2, this._opts);
13743 this.result.css = css;
13744 var self = this;
13745 Object.defineProperty(this.result, "root", {
13746 get: function get() {
13747 return self.root;
13748 }
13749 });
13750 var map = new MapGenerator2$1(str, root2, this._opts, css);
13751 if (map.isMap()) {
13752 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
13753 if (generatedCSS) {
13754 this.result.css = generatedCSS;
13755 }
13756 if (generatedMap) {
13757 this.result.map = generatedMap;
13758 }
13759 } else {
13760 map.clearAnnotation();
13761 this.result.css = map.css;
13762 }
13763 }
13764 var _proto = NoWorkResult.prototype;
13765 _proto.async = function async() {
13766 if (this.error) return Promise.reject(this.error);
13767 return Promise.resolve(this.result);
13768 };
13769 _proto.catch = function _catch(onRejected) {
13770 return this.async().catch(onRejected);
13771 };
13772 _proto.finally = function _finally(onFinally) {
13773 return this.async().then(onFinally, onFinally);
13774 };
13775 _proto.sync = function sync() {
13776 if (this.error) throw this.error;
13777 return this.result;
13778 };
13779 _proto.then = function then(onFulfilled, onRejected) {
13780 if (true) {
13781 if (!("from" in this._opts)) {
13782 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.");
13783 }
13784 }
13785 return this.async().then(onFulfilled, onRejected);
13786 };
13787 _proto.toString = function toString() {
13788 return this._css;
13789 };
13790 _proto.warnings = function warnings() {
13791 return [];
13792 };
13793 _create_class(NoWorkResult, [
13794 {
13795 key: "content",
13796 get: function get() {
13797 return this.result.css;
13798 }
13799 },
13800 {
13801 key: "css",
13802 get: function get() {
13803 return this.result.css;
13804 }
13805 },
13806 {
13807 key: "map",
13808 get: function get() {
13809 return this.result.map;
13810 }
13811 },
13812 {
13813 key: "messages",
13814 get: function get() {
13815 return [];
13816 }
13817 },
13818 {
13819 key: "opts",
13820 get: function get() {
13821 return this.result.opts;
13822 }
13823 },
13824 {
13825 key: "processor",
13826 get: function get() {
13827 return this.result.processor;
13828 }
13829 },
13830 {
13831 key: "root",
13832 get: function get() {
13833 if (this._root) {
13834 return this._root;
13835 }
13836 var root2;
13837 var parser2 = parse$1$1;
13838 try {
13839 root2 = parser2(this._css, this._opts);
13840 } catch (error) {
13841 this.error = error;
13842 }
13843 if (this.error) {
13844 throw this.error;
13845 } else {
13846 this._root = root2;
13847 return root2;
13848 }
13849 }
13850 },
13851 {
13852 key: Symbol.toStringTag,
13853 get: function get() {
13854 return "NoWorkResult";
13855 }
13856 }
13857 ]);
13858 return NoWorkResult;
13859 }();
13860 var noWorkResult$1 = NoWorkResult$1$1;
13861 NoWorkResult$1$1.default = NoWorkResult$1$1;
13862 var NoWorkResult2$1 = noWorkResult$1;
13863 var LazyResult$1$1 = lazyResult$1;
13864 var Document$1$1 = document$1$1;
13865 var Root$2$1 = root$1;
13866 var Processor$1$1 = /*#__PURE__*/ function() {
13867 function Processor(plugins) {
13868 if (plugins === void 0) plugins = [];
13869 this.version = "8.4.38";
13870 this.plugins = this.normalize(plugins);
13871 }
13872 var _proto = Processor.prototype;
13873 _proto.normalize = function normalize(plugins) {
13874 var normalized = [];
13875 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
13876 var i2 = _step.value;
13877 if (i2.postcss === true) {
13878 i2 = i2();
13879 } else if (i2.postcss) {
13880 i2 = i2.postcss;
13881 }
13882 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
13883 normalized = normalized.concat(i2.plugins);
13884 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
13885 normalized.push(i2);
13886 } else if (typeof i2 === "function") {
13887 normalized.push(i2);
13888 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
13889 if (true) {
13890 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.");
13891 }
13892 } else {
13893 throw new Error(i2 + " is not a PostCSS plugin");
13894 }
13895 }
13896 return normalized;
13897 };
13898 _proto.process = function process1(css, opts) {
13899 if (opts === void 0) opts = {};
13900 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
13901 return new NoWorkResult2$1(this, css, opts);
13902 } else {
13903 return new LazyResult$1$1(this, css, opts);
13904 }
13905 };
13906 _proto.use = function use(plugin22) {
13907 this.plugins = this.plugins.concat(this.normalize([
13908 plugin22
13909 ]));
13910 return this;
13911 };
13912 return Processor;
13913 }();
13914 var processor$1 = Processor$1$1;
13915 Processor$1$1.default = Processor$1$1;
13916 Root$2$1.registerProcessor(Processor$1$1);
13917 Document$1$1.registerProcessor(Processor$1$1);
13918 var Declaration$1$1 = declaration$1;
13919 var PreviousMap2$1 = previousMap$1;
13920 var Comment$1$1 = comment$1;
13921 var AtRule$1$1 = atRule$1;
13922 var Input$1$1 = input$1;
13923 var Root$1$1 = root$1;
13924 var Rule$1$1 = rule$1;
13925 function fromJSON$1$1(json, inputs) {
13926 if (Array.isArray(json)) return json.map(function(n2) {
13927 return fromJSON$1$1(n2);
13928 });
13929 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
13930 "inputs"
13931 ]);
13932 if (ownInputs) {
13933 inputs = [];
13934 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
13935 var input2 = _step.value;
13936 var inputHydrated = _extends({}, input2, {
13937 __proto__: Input$1$1.prototype
13938 });
13939 if (inputHydrated.map) {
13940 inputHydrated.map = _extends({}, inputHydrated.map, {
13941 __proto__: PreviousMap2$1.prototype
13942 });
13943 }
13944 inputs.push(inputHydrated);
13945 }
13946 }
13947 if (defaults.nodes) {
13948 defaults.nodes = json.nodes.map(function(n2) {
13949 return fromJSON$1$1(n2, inputs);
13950 });
13951 }
13952 if (defaults.source) {
13953 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
13954 "inputId"
13955 ]);
13956 defaults.source = source;
13957 if (inputId != null) {
13958 defaults.source.input = inputs[inputId];
13959 }
13960 }
13961 if (defaults.type === "root") {
13962 return new Root$1$1(defaults);
13963 } else if (defaults.type === "decl") {
13964 return new Declaration$1$1(defaults);
13965 } else if (defaults.type === "rule") {
13966 return new Rule$1$1(defaults);
13967 } else if (defaults.type === "comment") {
13968 return new Comment$1$1(defaults);
13969 } else if (defaults.type === "atrule") {
13970 return new AtRule$1$1(defaults);
13971 } else {
13972 throw new Error("Unknown node type: " + json.type);
13973 }
13974 }
13975 var fromJSON_1$1 = fromJSON$1$1;
13976 fromJSON$1$1.default = fromJSON$1$1;
13977 var CssSyntaxError2$1 = cssSyntaxError$1;
13978 var Declaration2$1 = declaration$1;
13979 var LazyResult2$1 = lazyResult$1;
13980 var Container2$1 = container$1;
13981 var Processor2$1 = processor$1;
13982 var stringify$5 = stringify_1$1;
13983 var fromJSON$2 = fromJSON_1$1;
13984 var Document22 = document$1$1;
13985 var Warning2$1 = warning$1;
13986 var Comment2$1 = comment$1;
13987 var AtRule2$1 = atRule$1;
13988 var Result2$1 = result$1;
13989 var Input2$1 = input$1;
13990 var parse$5 = parse_1$1;
13991 var list$3 = list_1$1;
13992 var Rule2$1 = rule$1;
13993 var Root2$1 = root$1;
13994 var Node2$1 = node$1;
13995 function postcss$3() {
13996 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
13997 plugins[_key] = arguments[_key];
13998 }
13999 if (plugins.length === 1 && Array.isArray(plugins[0])) {
14000 plugins = plugins[0];
14001 }
14002 return new Processor2$1(plugins);
14003 }
14004 postcss$3.plugin = function plugin(name, initializer) {
14005 var warningPrinted = false;
14006 function creator() {
14007 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
14008 args[_key] = arguments[_key];
14009 }
14010 if (console && console.warn && !warningPrinted) {
14011 warningPrinted = true;
14012 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
14013 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
14014 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
14015 }
14016 }
14017 var transformer = initializer.apply(void 0, [].concat(args));
14018 transformer.postcssPlugin = name;
14019 transformer.postcssVersion = new Processor2$1().version;
14020 return transformer;
14021 }
14022 var cache;
14023 Object.defineProperty(creator, "postcss", {
14024 get: function get() {
14025 if (!cache) cache = creator();
14026 return cache;
14027 }
14028 });
14029 creator.process = function(css, processOpts, pluginOpts) {
14030 return postcss$3([
14031 creator(pluginOpts)
14032 ]).process(css, processOpts);
14033 };
14034 return creator;
14035 };
14036 postcss$3.stringify = stringify$5;
14037 postcss$3.parse = parse$5;
14038 postcss$3.fromJSON = fromJSON$2;
14039 postcss$3.list = list$3;
14040 postcss$3.comment = function(defaults) {
14041 return new Comment2$1(defaults);
14042 };
14043 postcss$3.atRule = function(defaults) {
14044 return new AtRule2$1(defaults);
14045 };
14046 postcss$3.decl = function(defaults) {
14047 return new Declaration2$1(defaults);
14048 };
14049 postcss$3.rule = function(defaults) {
14050 return new Rule2$1(defaults);
14051 };
14052 postcss$3.root = function(defaults) {
14053 return new Root2$1(defaults);
14054 };
14055 postcss$3.document = function(defaults) {
14056 return new Document22(defaults);
14057 };
14058 postcss$3.CssSyntaxError = CssSyntaxError2$1;
14059 postcss$3.Declaration = Declaration2$1;
14060 postcss$3.Container = Container2$1;
14061 postcss$3.Processor = Processor2$1;
14062 postcss$3.Document = Document22;
14063 postcss$3.Comment = Comment2$1;
14064 postcss$3.Warning = Warning2$1;
14065 postcss$3.AtRule = AtRule2$1;
14066 postcss$3.Result = Result2$1;
14067 postcss$3.Input = Input2$1;
14068 postcss$3.Rule = Rule2$1;
14069 postcss$3.Root = Root2$1;
14070 postcss$3.Node = Node2$1;
14071 LazyResult2$1.registerPostcss(postcss$3);
14072 var postcss_1$1 = postcss$3;
14073 postcss$3.default = postcss$3;
14074 var postcss$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(postcss_1$1);
14075 postcss$1$1.stringify;
14076 postcss$1$1.fromJSON;
14077 postcss$1$1.plugin;
14078 postcss$1$1.parse;
14079 postcss$1$1.list;
14080 postcss$1$1.document;
14081 postcss$1$1.comment;
14082 postcss$1$1.atRule;
14083 postcss$1$1.rule;
14084 postcss$1$1.decl;
14085 postcss$1$1.root;
14086 postcss$1$1.CssSyntaxError;
14087 postcss$1$1.Declaration;
14088 postcss$1$1.Container;
14089 postcss$1$1.Processor;
14090 postcss$1$1.Document;
14091 postcss$1$1.Comment;
14092 postcss$1$1.Warning;
14093 postcss$1$1.AtRule;
14094 postcss$1$1.Result;
14095 postcss$1$1.Input;
14096 postcss$1$1.Rule;
14097 postcss$1$1.Root;
14098 postcss$1$1.Node;
14099 var __defProp2 = Object.defineProperty;
14100 var __defNormalProp2 = function(obj, key, value) {
14101 return key in obj ? __defProp2(obj, key, {
14102 enumerable: true,
14103 configurable: true,
14104 writable: true,
14105 value: value
14106 }) : obj[key] = value;
14107 };
14108 var __publicField2 = function(obj, key, value) {
14109 return __defNormalProp2(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
14110 };
14111 function getDefaultExportFromCjs(x2) {
14112 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
14113 }
14114 function getAugmentedNamespace(n2) {
14115 if (n2.__esModule) return n2;
14116 var f2 = n2.default;
14117 if (typeof f2 == "function") {
14118 var a2 = function a22() {
14119 if (_instanceof(this, a22)) {
14120 return Reflect.construct(f2, arguments, this.constructor);
14121 }
14122 return f2.apply(this, arguments);
14123 };
14124 a2.prototype = f2.prototype;
14125 } else a2 = {};
14126 Object.defineProperty(a2, "__esModule", {
14127 value: true
14128 });
14129 Object.keys(n2).forEach(function(k) {
14130 var d = Object.getOwnPropertyDescriptor(n2, k);
14131 Object.defineProperty(a2, k, d.get ? d : {
14132 enumerable: true,
14133 get: function get() {
14134 return n2[k];
14135 }
14136 });
14137 });
14138 return a2;
14139 }
14140 var picocolors_browser = {
14141 exports: {}
14142 };
14143 var x = String;
14144 var create = function create() {
14145 return {
14146 isColorSupported: false,
14147 reset: x,
14148 bold: x,
14149 dim: x,
14150 italic: x,
14151 underline: x,
14152 inverse: x,
14153 hidden: x,
14154 strikethrough: x,
14155 black: x,
14156 red: x,
14157 green: x,
14158 yellow: x,
14159 blue: x,
14160 magenta: x,
14161 cyan: x,
14162 white: x,
14163 gray: x,
14164 bgBlack: x,
14165 bgRed: x,
14166 bgGreen: x,
14167 bgYellow: x,
14168 bgBlue: x,
14169 bgMagenta: x,
14170 bgCyan: x,
14171 bgWhite: x
14172 };
14173 };
14174 picocolors_browser.exports = create();
14175 picocolors_browser.exports.createColors = create;
14176 var picocolors_browserExports = picocolors_browser.exports;
14177 var __viteBrowserExternal = {};
14178 var __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
14179 __proto__: null,
14180 default: __viteBrowserExternal
14181 }, Symbol.toStringTag, {
14182 value: "Module"
14183 }));
14184 var require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
14185 var pico = picocolors_browserExports;
14186 var terminalHighlight$1 = require$$2;
14187 var CssSyntaxError$3 = /*#__PURE__*/ function(Error1) {
14188 _inherits(CssSyntaxError2, Error1);
14189 function CssSyntaxError2(message, line, column, source, file, plugin22) {
14190 var _this;
14191 _this = Error1.call(this, message) || this;
14192 _this.name = "CssSyntaxError";
14193 _this.reason = message;
14194 if (file) {
14195 _this.file = file;
14196 }
14197 if (source) {
14198 _this.source = source;
14199 }
14200 if (plugin22) {
14201 _this.plugin = plugin22;
14202 }
14203 if (typeof line !== "undefined" && typeof column !== "undefined") {
14204 if (typeof line === "number") {
14205 _this.line = line;
14206 _this.column = column;
14207 } else {
14208 _this.line = line.line;
14209 _this.column = line.column;
14210 _this.endLine = column.line;
14211 _this.endColumn = column.column;
14212 }
14213 }
14214 _this.setMessage();
14215 if (Error.captureStackTrace) {
14216 Error.captureStackTrace(_this, CssSyntaxError2);
14217 }
14218 return _this;
14219 }
14220 var _proto = CssSyntaxError2.prototype;
14221 _proto.setMessage = function setMessage() {
14222 this.message = this.plugin ? this.plugin + ": " : "";
14223 this.message += this.file ? this.file : "<css input>";
14224 if (typeof this.line !== "undefined") {
14225 this.message += ":" + this.line + ":" + this.column;
14226 }
14227 this.message += ": " + this.reason;
14228 };
14229 _proto.showSourceCode = function showSourceCode(color) {
14230 var _this = this;
14231 if (!this.source) return "";
14232 var css = this.source;
14233 if (color == null) color = pico.isColorSupported;
14234 if (terminalHighlight$1) {
14235 if (color) css = terminalHighlight$1(css);
14236 }
14237 var lines = css.split(/\r?\n/);
14238 var start = Math.max(this.line - 3, 0);
14239 var end = Math.min(this.line + 2, lines.length);
14240 var maxWidth = String(end).length;
14241 var mark, aside;
14242 if (color) {
14243 var _pico_createColors = pico.createColors(true), bold = _pico_createColors.bold, gray = _pico_createColors.gray, red = _pico_createColors.red;
14244 mark = function(text) {
14245 return bold(red(text));
14246 };
14247 aside = function(text) {
14248 return gray(text);
14249 };
14250 } else {
14251 mark = aside = function(str) {
14252 return str;
14253 };
14254 }
14255 return lines.slice(start, end).map(function(line, index2) {
14256 var number = start + 1 + index2;
14257 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
14258 if (number === _this.line) {
14259 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
14260 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
14261 }
14262 return " " + aside(gutter) + line;
14263 }).join("\n");
14264 };
14265 _proto.toString = function toString() {
14266 var code = this.showSourceCode();
14267 if (code) {
14268 code = "\n\n" + code + "\n";
14269 }
14270 return this.name + ": " + this.message + code;
14271 };
14272 return CssSyntaxError2;
14273 }(_wrap_native_super(Error));
14274 var cssSyntaxError = CssSyntaxError$3;
14275 CssSyntaxError$3.default = CssSyntaxError$3;
14276 var symbols = {};
14277 symbols.isClean = Symbol("isClean");
14278 symbols.my = Symbol("my");
14279 var DEFAULT_RAW = {
14280 after: "\n",
14281 beforeClose: "\n",
14282 beforeComment: "\n",
14283 beforeDecl: "\n",
14284 beforeOpen: " ",
14285 beforeRule: "\n",
14286 colon: ": ",
14287 commentLeft: " ",
14288 commentRight: " ",
14289 emptyBody: "",
14290 indent: " ",
14291 semicolon: false
14292 };
14293 function capitalize(str) {
14294 return str[0].toUpperCase() + str.slice(1);
14295 }
14296 var Stringifier$2 = /*#__PURE__*/ function() {
14297 function Stringifier2(builder) {
14298 this.builder = builder;
14299 }
14300 var _proto = Stringifier2.prototype;
14301 _proto.atrule = function atrule(node2, semicolon) {
14302 var name = "@" + node2.name;
14303 var params = node2.params ? this.rawValue(node2, "params") : "";
14304 if (typeof node2.raws.afterName !== "undefined") {
14305 name += node2.raws.afterName;
14306 } else if (params) {
14307 name += " ";
14308 }
14309 if (node2.nodes) {
14310 this.block(node2, name + params);
14311 } else {
14312 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
14313 this.builder(name + params + end, node2);
14314 }
14315 };
14316 _proto.beforeAfter = function beforeAfter(node2, detect) {
14317 var value;
14318 if (node2.type === "decl") {
14319 value = this.raw(node2, null, "beforeDecl");
14320 } else if (node2.type === "comment") {
14321 value = this.raw(node2, null, "beforeComment");
14322 } else if (detect === "before") {
14323 value = this.raw(node2, null, "beforeRule");
14324 } else {
14325 value = this.raw(node2, null, "beforeClose");
14326 }
14327 var buf = node2.parent;
14328 var depth = 0;
14329 while(buf && buf.type !== "root"){
14330 depth += 1;
14331 buf = buf.parent;
14332 }
14333 if (value.includes("\n")) {
14334 var indent = this.raw(node2, null, "indent");
14335 if (indent.length) {
14336 for(var step = 0; step < depth; step++)value += indent;
14337 }
14338 }
14339 return value;
14340 };
14341 _proto.block = function block(node2, start) {
14342 var between = this.raw(node2, "between", "beforeOpen");
14343 this.builder(start + between + "{", node2, "start");
14344 var after;
14345 if (node2.nodes && node2.nodes.length) {
14346 this.body(node2);
14347 after = this.raw(node2, "after");
14348 } else {
14349 after = this.raw(node2, "after", "emptyBody");
14350 }
14351 if (after) this.builder(after);
14352 this.builder("}", node2, "end");
14353 };
14354 _proto.body = function body(node2) {
14355 var last = node2.nodes.length - 1;
14356 while(last > 0){
14357 if (node2.nodes[last].type !== "comment") break;
14358 last -= 1;
14359 }
14360 var semicolon = this.raw(node2, "semicolon");
14361 for(var i2 = 0; i2 < node2.nodes.length; i2++){
14362 var child = node2.nodes[i2];
14363 var before = this.raw(child, "before");
14364 if (before) this.builder(before);
14365 this.stringify(child, last !== i2 || semicolon);
14366 }
14367 };
14368 _proto.comment = function comment(node2) {
14369 var left = this.raw(node2, "left", "commentLeft");
14370 var right = this.raw(node2, "right", "commentRight");
14371 this.builder("/*" + left + node2.text + right + "*/", node2);
14372 };
14373 _proto.decl = function decl(node2, semicolon) {
14374 var between = this.raw(node2, "between", "colon");
14375 var string = node2.prop + between + this.rawValue(node2, "value");
14376 if (node2.important) {
14377 string += node2.raws.important || " !important";
14378 }
14379 if (semicolon) string += ";";
14380 this.builder(string, node2);
14381 };
14382 _proto.document = function document1(node2) {
14383 this.body(node2);
14384 };
14385 _proto.raw = function raw(node2, own, detect) {
14386 var value;
14387 if (!detect) detect = own;
14388 if (own) {
14389 value = node2.raws[own];
14390 if (typeof value !== "undefined") return value;
14391 }
14392 var parent = node2.parent;
14393 if (detect === "before") {
14394 if (!parent || parent.type === "root" && parent.first === node2) {
14395 return "";
14396 }
14397 if (parent && parent.type === "document") {
14398 return "";
14399 }
14400 }
14401 if (!parent) return DEFAULT_RAW[detect];
14402 var root2 = node2.root();
14403 if (!root2.rawCache) root2.rawCache = {};
14404 if (typeof root2.rawCache[detect] !== "undefined") {
14405 return root2.rawCache[detect];
14406 }
14407 if (detect === "before" || detect === "after") {
14408 return this.beforeAfter(node2, detect);
14409 } else {
14410 var method = "raw" + capitalize(detect);
14411 if (this[method]) {
14412 value = this[method](root2, node2);
14413 } else {
14414 root2.walk(function(i2) {
14415 value = i2.raws[own];
14416 if (typeof value !== "undefined") return false;
14417 });
14418 }
14419 }
14420 if (typeof value === "undefined") value = DEFAULT_RAW[detect];
14421 root2.rawCache[detect] = value;
14422 return value;
14423 };
14424 _proto.rawBeforeClose = function rawBeforeClose(root2) {
14425 var value;
14426 root2.walk(function(i2) {
14427 if (i2.nodes && i2.nodes.length > 0) {
14428 if (typeof i2.raws.after !== "undefined") {
14429 value = i2.raws.after;
14430 if (value.includes("\n")) {
14431 value = value.replace(/[^\n]+$/, "");
14432 }
14433 return false;
14434 }
14435 }
14436 });
14437 if (value) value = value.replace(/\S/g, "");
14438 return value;
14439 };
14440 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
14441 var value;
14442 root2.walkComments(function(i2) {
14443 if (typeof i2.raws.before !== "undefined") {
14444 value = i2.raws.before;
14445 if (value.includes("\n")) {
14446 value = value.replace(/[^\n]+$/, "");
14447 }
14448 return false;
14449 }
14450 });
14451 if (typeof value === "undefined") {
14452 value = this.raw(node2, null, "beforeDecl");
14453 } else if (value) {
14454 value = value.replace(/\S/g, "");
14455 }
14456 return value;
14457 };
14458 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
14459 var value;
14460 root2.walkDecls(function(i2) {
14461 if (typeof i2.raws.before !== "undefined") {
14462 value = i2.raws.before;
14463 if (value.includes("\n")) {
14464 value = value.replace(/[^\n]+$/, "");
14465 }
14466 return false;
14467 }
14468 });
14469 if (typeof value === "undefined") {
14470 value = this.raw(node2, null, "beforeRule");
14471 } else if (value) {
14472 value = value.replace(/\S/g, "");
14473 }
14474 return value;
14475 };
14476 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
14477 var value;
14478 root2.walk(function(i2) {
14479 if (i2.type !== "decl") {
14480 value = i2.raws.between;
14481 if (typeof value !== "undefined") return false;
14482 }
14483 });
14484 return value;
14485 };
14486 _proto.rawBeforeRule = function rawBeforeRule(root2) {
14487 var value;
14488 root2.walk(function(i2) {
14489 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
14490 if (typeof i2.raws.before !== "undefined") {
14491 value = i2.raws.before;
14492 if (value.includes("\n")) {
14493 value = value.replace(/[^\n]+$/, "");
14494 }
14495 return false;
14496 }
14497 }
14498 });
14499 if (value) value = value.replace(/\S/g, "");
14500 return value;
14501 };
14502 _proto.rawColon = function rawColon(root2) {
14503 var value;
14504 root2.walkDecls(function(i2) {
14505 if (typeof i2.raws.between !== "undefined") {
14506 value = i2.raws.between.replace(/[^\s:]/g, "");
14507 return false;
14508 }
14509 });
14510 return value;
14511 };
14512 _proto.rawEmptyBody = function rawEmptyBody(root2) {
14513 var value;
14514 root2.walk(function(i2) {
14515 if (i2.nodes && i2.nodes.length === 0) {
14516 value = i2.raws.after;
14517 if (typeof value !== "undefined") return false;
14518 }
14519 });
14520 return value;
14521 };
14522 _proto.rawIndent = function rawIndent(root2) {
14523 if (root2.raws.indent) return root2.raws.indent;
14524 var value;
14525 root2.walk(function(i2) {
14526 var p = i2.parent;
14527 if (p && p !== root2 && p.parent && p.parent === root2) {
14528 if (typeof i2.raws.before !== "undefined") {
14529 var parts = i2.raws.before.split("\n");
14530 value = parts[parts.length - 1];
14531 value = value.replace(/\S/g, "");
14532 return false;
14533 }
14534 }
14535 });
14536 return value;
14537 };
14538 _proto.rawSemicolon = function rawSemicolon(root2) {
14539 var value;
14540 root2.walk(function(i2) {
14541 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
14542 value = i2.raws.semicolon;
14543 if (typeof value !== "undefined") return false;
14544 }
14545 });
14546 return value;
14547 };
14548 _proto.rawValue = function rawValue(node2, prop) {
14549 var value = node2[prop];
14550 var raw = node2.raws[prop];
14551 if (raw && raw.value === value) {
14552 return raw.raw;
14553 }
14554 return value;
14555 };
14556 _proto.root = function root(node2) {
14557 this.body(node2);
14558 if (node2.raws.after) this.builder(node2.raws.after);
14559 };
14560 _proto.rule = function rule(node2) {
14561 this.block(node2, this.rawValue(node2, "selector"));
14562 if (node2.raws.ownSemicolon) {
14563 this.builder(node2.raws.ownSemicolon, node2, "end");
14564 }
14565 };
14566 _proto.stringify = function stringify(node2, semicolon) {
14567 if (!this[node2.type]) {
14568 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
14569 }
14570 this[node2.type](node2, semicolon);
14571 };
14572 return Stringifier2;
14573 }();
14574 var stringifier = Stringifier$2;
14575 Stringifier$2.default = Stringifier$2;
14576 var Stringifier$1 = stringifier;
14577 function stringify$4(node2, builder) {
14578 var str = new Stringifier$1(builder);
14579 str.stringify(node2);
14580 }
14581 var stringify_1 = stringify$4;
14582 stringify$4.default = stringify$4;
14583 var isClean$2 = symbols.isClean, my$2 = symbols.my;
14584 var CssSyntaxError$2 = cssSyntaxError;
14585 var Stringifier22 = stringifier;
14586 var stringify$3 = stringify_1;
14587 function cloneNode(obj, parent) {
14588 var cloned = new obj.constructor();
14589 for(var i2 in obj){
14590 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
14591 continue;
14592 }
14593 if (i2 === "proxyCache") continue;
14594 var value = obj[i2];
14595 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
14596 if (i2 === "parent" && type === "object") {
14597 if (parent) cloned[i2] = parent;
14598 } else if (i2 === "source") {
14599 cloned[i2] = value;
14600 } else if (Array.isArray(value)) {
14601 cloned[i2] = value.map(function(j) {
14602 return cloneNode(j, cloned);
14603 });
14604 } else {
14605 if (type === "object" && value !== null) value = cloneNode(value);
14606 cloned[i2] = value;
14607 }
14608 }
14609 return cloned;
14610 }
14611 var Node$4 = /*#__PURE__*/ function() {
14612 function Node3(defaults) {
14613 if (defaults === void 0) defaults = {};
14614 this.raws = {};
14615 this[isClean$2] = false;
14616 this[my$2] = true;
14617 for(var name in defaults){
14618 if (name === "nodes") {
14619 this.nodes = [];
14620 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
14621 var node2 = _step.value;
14622 if (typeof node2.clone === "function") {
14623 this.append(node2.clone());
14624 } else {
14625 this.append(node2);
14626 }
14627 }
14628 } else {
14629 this[name] = defaults[name];
14630 }
14631 }
14632 }
14633 var _proto = Node3.prototype;
14634 _proto.addToError = function addToError(error) {
14635 error.postcssNode = this;
14636 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
14637 var s2 = this.source;
14638 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
14639 }
14640 return error;
14641 };
14642 _proto.after = function after(add) {
14643 this.parent.insertAfter(this, add);
14644 return this;
14645 };
14646 _proto.assign = function assign(overrides) {
14647 if (overrides === void 0) overrides = {};
14648 for(var name in overrides){
14649 this[name] = overrides[name];
14650 }
14651 return this;
14652 };
14653 _proto.before = function before(add) {
14654 this.parent.insertBefore(this, add);
14655 return this;
14656 };
14657 _proto.cleanRaws = function cleanRaws(keepBetween) {
14658 delete this.raws.before;
14659 delete this.raws.after;
14660 if (!keepBetween) delete this.raws.between;
14661 };
14662 _proto.clone = function clone(overrides) {
14663 if (overrides === void 0) overrides = {};
14664 var cloned = cloneNode(this);
14665 for(var name in overrides){
14666 cloned[name] = overrides[name];
14667 }
14668 return cloned;
14669 };
14670 _proto.cloneAfter = function cloneAfter(overrides) {
14671 if (overrides === void 0) overrides = {};
14672 var cloned = this.clone(overrides);
14673 this.parent.insertAfter(this, cloned);
14674 return cloned;
14675 };
14676 _proto.cloneBefore = function cloneBefore(overrides) {
14677 if (overrides === void 0) overrides = {};
14678 var cloned = this.clone(overrides);
14679 this.parent.insertBefore(this, cloned);
14680 return cloned;
14681 };
14682 _proto.error = function error(message, opts) {
14683 if (opts === void 0) opts = {};
14684 if (this.source) {
14685 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
14686 return this.source.input.error(message, {
14687 column: start.column,
14688 line: start.line
14689 }, {
14690 column: end.column,
14691 line: end.line
14692 }, opts);
14693 }
14694 return new CssSyntaxError$2(message);
14695 };
14696 _proto.getProxyProcessor = function getProxyProcessor() {
14697 return {
14698 get: function get(node2, prop) {
14699 if (prop === "proxyOf") {
14700 return node2;
14701 } else if (prop === "root") {
14702 return function() {
14703 return node2.root().toProxy();
14704 };
14705 } else {
14706 return node2[prop];
14707 }
14708 },
14709 set: function set(node2, prop, value) {
14710 if (node2[prop] === value) return true;
14711 node2[prop] = value;
14712 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
14713 node2.markDirty();
14714 }
14715 return true;
14716 }
14717 };
14718 };
14719 _proto.markDirty = function markDirty() {
14720 if (this[isClean$2]) {
14721 this[isClean$2] = false;
14722 var next = this;
14723 while(next = next.parent){
14724 next[isClean$2] = false;
14725 }
14726 }
14727 };
14728 _proto.next = function next() {
14729 if (!this.parent) return void 0;
14730 var index2 = this.parent.index(this);
14731 return this.parent.nodes[index2 + 1];
14732 };
14733 _proto.positionBy = function positionBy(opts, stringRepresentation) {
14734 var pos = this.source.start;
14735 if (opts.index) {
14736 pos = this.positionInside(opts.index, stringRepresentation);
14737 } else if (opts.word) {
14738 stringRepresentation = this.toString();
14739 var index2 = stringRepresentation.indexOf(opts.word);
14740 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
14741 }
14742 return pos;
14743 };
14744 _proto.positionInside = function positionInside(index2, stringRepresentation) {
14745 var string = stringRepresentation || this.toString();
14746 var column = this.source.start.column;
14747 var line = this.source.start.line;
14748 for(var i2 = 0; i2 < index2; i2++){
14749 if (string[i2] === "\n") {
14750 column = 1;
14751 line += 1;
14752 } else {
14753 column += 1;
14754 }
14755 }
14756 return {
14757 column: column,
14758 line: line
14759 };
14760 };
14761 _proto.prev = function prev() {
14762 if (!this.parent) return void 0;
14763 var index2 = this.parent.index(this);
14764 return this.parent.nodes[index2 - 1];
14765 };
14766 _proto.rangeBy = function rangeBy(opts) {
14767 var start = {
14768 column: this.source.start.column,
14769 line: this.source.start.line
14770 };
14771 var end = this.source.end ? {
14772 column: this.source.end.column + 1,
14773 line: this.source.end.line
14774 } : {
14775 column: start.column + 1,
14776 line: start.line
14777 };
14778 if (opts.word) {
14779 var stringRepresentation = this.toString();
14780 var index2 = stringRepresentation.indexOf(opts.word);
14781 if (index2 !== -1) {
14782 start = this.positionInside(index2, stringRepresentation);
14783 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
14784 }
14785 } else {
14786 if (opts.start) {
14787 start = {
14788 column: opts.start.column,
14789 line: opts.start.line
14790 };
14791 } else if (opts.index) {
14792 start = this.positionInside(opts.index);
14793 }
14794 if (opts.end) {
14795 end = {
14796 column: opts.end.column,
14797 line: opts.end.line
14798 };
14799 } else if (typeof opts.endIndex === "number") {
14800 end = this.positionInside(opts.endIndex);
14801 } else if (opts.index) {
14802 end = this.positionInside(opts.index + 1);
14803 }
14804 }
14805 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
14806 end = {
14807 column: start.column + 1,
14808 line: start.line
14809 };
14810 }
14811 return {
14812 end: end,
14813 start: start
14814 };
14815 };
14816 _proto.raw = function raw(prop, defaultType) {
14817 var str = new Stringifier22();
14818 return str.raw(this, prop, defaultType);
14819 };
14820 _proto.remove = function remove() {
14821 if (this.parent) {
14822 this.parent.removeChild(this);
14823 }
14824 this.parent = void 0;
14825 return this;
14826 };
14827 _proto.replaceWith = function replaceWith() {
14828 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
14829 nodes[_key] = arguments[_key];
14830 }
14831 if (this.parent) {
14832 var bookmark = this;
14833 var foundSelf = false;
14834 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
14835 var node2 = _step.value;
14836 if (node2 === this) {
14837 foundSelf = true;
14838 } else if (foundSelf) {
14839 this.parent.insertAfter(bookmark, node2);
14840 bookmark = node2;
14841 } else {
14842 this.parent.insertBefore(bookmark, node2);
14843 }
14844 }
14845 if (!foundSelf) {
14846 this.remove();
14847 }
14848 }
14849 return this;
14850 };
14851 _proto.root = function root() {
14852 var result2 = this;
14853 while(result2.parent && result2.parent.type !== "document"){
14854 result2 = result2.parent;
14855 }
14856 return result2;
14857 };
14858 _proto.toJSON = function toJSON(_, inputs) {
14859 var fixed = {};
14860 var emitInputs = inputs == null;
14861 inputs = inputs || /* @__PURE__ */ new Map();
14862 var inputsNextIndex = 0;
14863 for(var name in this){
14864 if (!Object.prototype.hasOwnProperty.call(this, name)) {
14865 continue;
14866 }
14867 if (name === "parent" || name === "proxyCache") continue;
14868 var value = this[name];
14869 if (Array.isArray(value)) {
14870 fixed[name] = value.map(function(i2) {
14871 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
14872 return i2.toJSON(null, inputs);
14873 } else {
14874 return i2;
14875 }
14876 });
14877 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
14878 fixed[name] = value.toJSON(null, inputs);
14879 } else if (name === "source") {
14880 var inputId = inputs.get(value.input);
14881 if (inputId == null) {
14882 inputId = inputsNextIndex;
14883 inputs.set(value.input, inputsNextIndex);
14884 inputsNextIndex++;
14885 }
14886 fixed[name] = {
14887 end: value.end,
14888 inputId: inputId,
14889 start: value.start
14890 };
14891 } else {
14892 fixed[name] = value;
14893 }
14894 }
14895 if (emitInputs) {
14896 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
14897 return input2.toJSON();
14898 });
14899 }
14900 return fixed;
14901 };
14902 _proto.toProxy = function toProxy() {
14903 if (!this.proxyCache) {
14904 this.proxyCache = new Proxy(this, this.getProxyProcessor());
14905 }
14906 return this.proxyCache;
14907 };
14908 _proto.toString = function toString(stringifier2) {
14909 if (stringifier2 === void 0) stringifier2 = stringify$3;
14910 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
14911 var result2 = "";
14912 stringifier2(this, function(i2) {
14913 result2 += i2;
14914 });
14915 return result2;
14916 };
14917 _proto.warn = function warn(result2, text, opts) {
14918 var data = {
14919 node: this
14920 };
14921 for(var i2 in opts)data[i2] = opts[i2];
14922 return result2.warn(text, data);
14923 };
14924 _create_class(Node3, [
14925 {
14926 key: "proxyOf",
14927 get: function get() {
14928 return this;
14929 }
14930 }
14931 ]);
14932 return Node3;
14933 }();
14934 var node = Node$4;
14935 Node$4.default = Node$4;
14936 var Node$3 = node;
14937 var Declaration$4 = /*#__PURE__*/ function(Node$3) {
14938 _inherits(Declaration2, Node$3);
14939 function Declaration2(defaults) {
14940 var _this;
14941 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
14942 defaults = _extends({}, defaults, {
14943 value: String(defaults.value)
14944 });
14945 }
14946 _this = Node$3.call(this, defaults) || this;
14947 _this.type = "decl";
14948 return _this;
14949 }
14950 _create_class(Declaration2, [
14951 {
14952 key: "variable",
14953 get: function get() {
14954 return this.prop.startsWith("--") || this.prop[0] === "$";
14955 }
14956 }
14957 ]);
14958 return Declaration2;
14959 }(Node$3);
14960 var declaration = Declaration$4;
14961 Declaration$4.default = Declaration$4;
14962 var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
14963 var nanoid$1 = function(size) {
14964 if (size === void 0) size = 21;
14965 var id = "";
14966 var i2 = size;
14967 while(i2--){
14968 id += urlAlphabet[Math.random() * 64 | 0];
14969 }
14970 return id;
14971 };
14972 var nonSecure = {
14973 nanoid: nanoid$1};
14974 var SourceMapConsumer$2 = require$$2.SourceMapConsumer, SourceMapGenerator$2 = require$$2.SourceMapGenerator;
14975 var existsSync = require$$2.existsSync, readFileSync = require$$2.readFileSync;
14976 var dirname$1 = require$$2.dirname, join = require$$2.join;
14977 function fromBase64(str) {
14978 if (Buffer) {
14979 return Buffer.from(str, "base64").toString();
14980 } else {
14981 return window.atob(str);
14982 }
14983 }
14984 var PreviousMap$2 = /*#__PURE__*/ function() {
14985 function PreviousMap2(css, opts) {
14986 if (opts.map === false) return;
14987 this.loadAnnotation(css);
14988 this.inline = this.startWith(this.annotation, "data:");
14989 var prev = opts.map ? opts.map.prev : void 0;
14990 var text = this.loadMap(opts.from, prev);
14991 if (!this.mapFile && opts.from) {
14992 this.mapFile = opts.from;
14993 }
14994 if (this.mapFile) this.root = dirname$1(this.mapFile);
14995 if (text) this.text = text;
14996 }
14997 var _proto = PreviousMap2.prototype;
14998 _proto.consumer = function consumer() {
14999 if (!this.consumerCache) {
15000 this.consumerCache = new SourceMapConsumer$2(this.text);
15001 }
15002 return this.consumerCache;
15003 };
15004 _proto.decodeInline = function decodeInline(text) {
15005 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
15006 var baseUri = /^data:application\/json;base64,/;
15007 var charsetUri = /^data:application\/json;charset=utf-?8,/;
15008 var uri = /^data:application\/json,/;
15009 if (charsetUri.test(text) || uri.test(text)) {
15010 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
15011 }
15012 if (baseCharsetUri.test(text) || baseUri.test(text)) {
15013 return fromBase64(text.substr(RegExp.lastMatch.length));
15014 }
15015 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
15016 throw new Error("Unsupported source map encoding " + encoding);
15017 };
15018 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
15019 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
15020 };
15021 _proto.isMap = function isMap(map) {
15022 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
15023 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
15024 };
15025 _proto.loadAnnotation = function loadAnnotation(css) {
15026 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
15027 if (!comments) return;
15028 var start = css.lastIndexOf(comments.pop());
15029 var end = css.indexOf("*/", start);
15030 if (start > -1 && end > -1) {
15031 this.annotation = this.getAnnotationURL(css.substring(start, end));
15032 }
15033 };
15034 _proto.loadFile = function loadFile(path) {
15035 this.root = dirname$1(path);
15036 if (existsSync(path)) {
15037 this.mapFile = path;
15038 return readFileSync(path, "utf-8").toString().trim();
15039 }
15040 };
15041 _proto.loadMap = function loadMap(file, prev) {
15042 if (prev === false) return false;
15043 if (prev) {
15044 if (typeof prev === "string") {
15045 return prev;
15046 } else if (typeof prev === "function") {
15047 var prevPath = prev(file);
15048 if (prevPath) {
15049 var map = this.loadFile(prevPath);
15050 if (!map) {
15051 throw new Error("Unable to load previous source map: " + prevPath.toString());
15052 }
15053 return map;
15054 }
15055 } else if (_instanceof(prev, SourceMapConsumer$2)) {
15056 return SourceMapGenerator$2.fromSourceMap(prev).toString();
15057 } else if (_instanceof(prev, SourceMapGenerator$2)) {
15058 return prev.toString();
15059 } else if (this.isMap(prev)) {
15060 return JSON.stringify(prev);
15061 } else {
15062 throw new Error("Unsupported previous source map format: " + prev.toString());
15063 }
15064 } else if (this.inline) {
15065 return this.decodeInline(this.annotation);
15066 } else if (this.annotation) {
15067 var map1 = this.annotation;
15068 if (file) map1 = join(dirname$1(file), map1);
15069 return this.loadFile(map1);
15070 }
15071 };
15072 _proto.startWith = function startWith(string, start) {
15073 if (!string) return false;
15074 return string.substr(0, start.length) === start;
15075 };
15076 _proto.withContent = function withContent() {
15077 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
15078 };
15079 return PreviousMap2;
15080 }();
15081 var previousMap = PreviousMap$2;
15082 PreviousMap$2.default = PreviousMap$2;
15083 var SourceMapConsumer$1 = require$$2.SourceMapConsumer, SourceMapGenerator$1 = require$$2.SourceMapGenerator;
15084 var fileURLToPath = require$$2.fileURLToPath, pathToFileURL$1 = require$$2.pathToFileURL;
15085 var isAbsolute = require$$2.isAbsolute, resolve$1 = require$$2.resolve;
15086 var nanoid = nonSecure.nanoid;
15087 var terminalHighlight = require$$2;
15088 var CssSyntaxError$1 = cssSyntaxError;
15089 var PreviousMap$1 = previousMap;
15090 var fromOffsetCache = Symbol("fromOffsetCache");
15091 var sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
15092 var pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
15093 var Input$4 = /*#__PURE__*/ function() {
15094 function Input2(css, opts) {
15095 if (opts === void 0) opts = {};
15096 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
15097 throw new Error("PostCSS received " + css + " instead of CSS string");
15098 }
15099 this.css = css.toString();
15100 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
15101 this.hasBOM = true;
15102 this.css = this.css.slice(1);
15103 } else {
15104 this.hasBOM = false;
15105 }
15106 if (opts.from) {
15107 if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
15108 this.file = opts.from;
15109 } else {
15110 this.file = resolve$1(opts.from);
15111 }
15112 }
15113 if (pathAvailable$1 && sourceMapAvailable$1) {
15114 var map = new PreviousMap$1(this.css, opts);
15115 if (map.text) {
15116 this.map = map;
15117 var file = map.consumer().file;
15118 if (!this.file && file) this.file = this.mapResolve(file);
15119 }
15120 }
15121 if (!this.file) {
15122 this.id = "<input css " + nanoid(6) + ">";
15123 }
15124 if (this.map) this.map.file = this.from;
15125 }
15126 var _proto = Input2.prototype;
15127 _proto.error = function error(message, line, column, opts) {
15128 if (opts === void 0) opts = {};
15129 var result2, endLine, endColumn;
15130 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
15131 var start = line;
15132 var end = column;
15133 if (typeof start.offset === "number") {
15134 var pos = this.fromOffset(start.offset);
15135 line = pos.line;
15136 column = pos.col;
15137 } else {
15138 line = start.line;
15139 column = start.column;
15140 }
15141 if (typeof end.offset === "number") {
15142 var pos1 = this.fromOffset(end.offset);
15143 endLine = pos1.line;
15144 endColumn = pos1.col;
15145 } else {
15146 endLine = end.line;
15147 endColumn = end.column;
15148 }
15149 } else if (!column) {
15150 var pos2 = this.fromOffset(line);
15151 line = pos2.line;
15152 column = pos2.col;
15153 }
15154 var origin = this.origin(line, column, endLine, endColumn);
15155 if (origin) {
15156 result2 = new CssSyntaxError$1(message, origin.endLine === void 0 ? origin.line : {
15157 column: origin.column,
15158 line: origin.line
15159 }, origin.endLine === void 0 ? origin.column : {
15160 column: origin.endColumn,
15161 line: origin.endLine
15162 }, origin.source, origin.file, opts.plugin);
15163 } else {
15164 result2 = new CssSyntaxError$1(message, endLine === void 0 ? line : {
15165 column: column,
15166 line: line
15167 }, endLine === void 0 ? column : {
15168 column: endColumn,
15169 line: endLine
15170 }, this.css, this.file, opts.plugin);
15171 }
15172 result2.input = {
15173 column: column,
15174 endColumn: endColumn,
15175 endLine: endLine,
15176 line: line,
15177 source: this.css
15178 };
15179 if (this.file) {
15180 if (pathToFileURL$1) {
15181 result2.input.url = pathToFileURL$1(this.file).toString();
15182 }
15183 result2.input.file = this.file;
15184 }
15185 return result2;
15186 };
15187 _proto.fromOffset = function fromOffset(offset) {
15188 var lastLine, lineToIndex;
15189 if (!this[fromOffsetCache]) {
15190 var lines = this.css.split("\n");
15191 lineToIndex = new Array(lines.length);
15192 var prevIndex = 0;
15193 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
15194 lineToIndex[i2] = prevIndex;
15195 prevIndex += lines[i2].length + 1;
15196 }
15197 this[fromOffsetCache] = lineToIndex;
15198 } else {
15199 lineToIndex = this[fromOffsetCache];
15200 }
15201 lastLine = lineToIndex[lineToIndex.length - 1];
15202 var min = 0;
15203 if (offset >= lastLine) {
15204 min = lineToIndex.length - 1;
15205 } else {
15206 var max = lineToIndex.length - 2;
15207 var mid;
15208 while(min < max){
15209 mid = min + (max - min >> 1);
15210 if (offset < lineToIndex[mid]) {
15211 max = mid - 1;
15212 } else if (offset >= lineToIndex[mid + 1]) {
15213 min = mid + 1;
15214 } else {
15215 min = mid;
15216 break;
15217 }
15218 }
15219 }
15220 return {
15221 col: offset - lineToIndex[min] + 1,
15222 line: min + 1
15223 };
15224 };
15225 _proto.mapResolve = function mapResolve(file) {
15226 if (/^\w+:\/\//.test(file)) {
15227 return file;
15228 }
15229 return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
15230 };
15231 _proto.origin = function origin(line, column, endLine, endColumn) {
15232 if (!this.map) return false;
15233 var consumer = this.map.consumer();
15234 var from = consumer.originalPositionFor({
15235 column: column,
15236 line: line
15237 });
15238 if (!from.source) return false;
15239 var to;
15240 if (typeof endLine === "number") {
15241 to = consumer.originalPositionFor({
15242 column: endColumn,
15243 line: endLine
15244 });
15245 }
15246 var fromUrl;
15247 if (isAbsolute(from.source)) {
15248 fromUrl = pathToFileURL$1(from.source);
15249 } else {
15250 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile));
15251 }
15252 var result2 = {
15253 column: from.column,
15254 endColumn: to && to.column,
15255 endLine: to && to.line,
15256 line: from.line,
15257 url: fromUrl.toString()
15258 };
15259 if (fromUrl.protocol === "file:") {
15260 if (fileURLToPath) {
15261 result2.file = fileURLToPath(fromUrl);
15262 } else {
15263 throw new Error("file: protocol is not available in this PostCSS build");
15264 }
15265 }
15266 var source = consumer.sourceContentFor(from.source);
15267 if (source) result2.source = source;
15268 return result2;
15269 };
15270 _proto.toJSON = function toJSON() {
15271 var json = {};
15272 for(var _i = 0, _iter = [
15273 "hasBOM",
15274 "css",
15275 "file",
15276 "id"
15277 ]; _i < _iter.length; _i++){
15278 var name = _iter[_i];
15279 if (this[name] != null) {
15280 json[name] = this[name];
15281 }
15282 }
15283 if (this.map) {
15284 json.map = _extends({}, this.map);
15285 if (json.map.consumerCache) {
15286 json.map.consumerCache = void 0;
15287 }
15288 }
15289 return json;
15290 };
15291 _create_class(Input2, [
15292 {
15293 key: "from",
15294 get: function get() {
15295 return this.file || this.id;
15296 }
15297 }
15298 ]);
15299 return Input2;
15300 }();
15301 var input = Input$4;
15302 Input$4.default = Input$4;
15303 if (terminalHighlight && terminalHighlight.registerInput) {
15304 terminalHighlight.registerInput(Input$4);
15305 }
15306 var SourceMapConsumer = require$$2.SourceMapConsumer, SourceMapGenerator = require$$2.SourceMapGenerator;
15307 var dirname = require$$2.dirname, relative = require$$2.relative, resolve$3 = require$$2.resolve, sep = require$$2.sep;
15308 var pathToFileURL = require$$2.pathToFileURL;
15309 var Input$3 = input;
15310 var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
15311 var pathAvailable = Boolean(dirname && resolve$3 && relative && sep);
15312 var MapGenerator$2 = /*#__PURE__*/ function() {
15313 function MapGenerator2(stringify2, root2, opts, cssString) {
15314 this.stringify = stringify2;
15315 this.mapOpts = opts.map || {};
15316 this.root = root2;
15317 this.opts = opts;
15318 this.css = cssString;
15319 this.originalCSS = cssString;
15320 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
15321 this.memoizedFileURLs = /* @__PURE__ */ new Map();
15322 this.memoizedPaths = /* @__PURE__ */ new Map();
15323 this.memoizedURLs = /* @__PURE__ */ new Map();
15324 }
15325 var _proto = MapGenerator2.prototype;
15326 _proto.addAnnotation = function addAnnotation() {
15327 var content;
15328 if (this.isInline()) {
15329 content = "data:application/json;base64," + this.toBase64(this.map.toString());
15330 } else if (typeof this.mapOpts.annotation === "string") {
15331 content = this.mapOpts.annotation;
15332 } else if (typeof this.mapOpts.annotation === "function") {
15333 content = this.mapOpts.annotation(this.opts.to, this.root);
15334 } else {
15335 content = this.outputFile() + ".map";
15336 }
15337 var eol = "\n";
15338 if (this.css.includes("\r\n")) eol = "\r\n";
15339 this.css += eol + "/*# sourceMappingURL=" + content + " */";
15340 };
15341 _proto.applyPrevMaps = function applyPrevMaps() {
15342 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
15343 var prev = _step.value;
15344 var from = this.toUrl(this.path(prev.file));
15345 var root2 = prev.root || dirname(prev.file);
15346 var map = void 0;
15347 if (this.mapOpts.sourcesContent === false) {
15348 map = new SourceMapConsumer(prev.text);
15349 if (map.sourcesContent) {
15350 map.sourcesContent = null;
15351 }
15352 } else {
15353 map = prev.consumer();
15354 }
15355 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
15356 }
15357 };
15358 _proto.clearAnnotation = function clearAnnotation() {
15359 if (this.mapOpts.annotation === false) return;
15360 if (this.root) {
15361 var node2;
15362 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
15363 node2 = this.root.nodes[i2];
15364 if (node2.type !== "comment") continue;
15365 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
15366 this.root.removeChild(i2);
15367 }
15368 }
15369 } else if (this.css) {
15370 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
15371 }
15372 };
15373 _proto.generate = function generate() {
15374 this.clearAnnotation();
15375 if (pathAvailable && sourceMapAvailable && this.isMap()) {
15376 return this.generateMap();
15377 } else {
15378 var result2 = "";
15379 this.stringify(this.root, function(i2) {
15380 result2 += i2;
15381 });
15382 return [
15383 result2
15384 ];
15385 }
15386 };
15387 _proto.generateMap = function generateMap() {
15388 if (this.root) {
15389 this.generateString();
15390 } else if (this.previous().length === 1) {
15391 var prev = this.previous()[0].consumer();
15392 prev.file = this.outputFile();
15393 this.map = SourceMapGenerator.fromSourceMap(prev, {
15394 ignoreInvalidMapping: true
15395 });
15396 } else {
15397 this.map = new SourceMapGenerator({
15398 file: this.outputFile(),
15399 ignoreInvalidMapping: true
15400 });
15401 this.map.addMapping({
15402 generated: {
15403 column: 0,
15404 line: 1
15405 },
15406 original: {
15407 column: 0,
15408 line: 1
15409 },
15410 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
15411 });
15412 }
15413 if (this.isSourcesContent()) this.setSourcesContent();
15414 if (this.root && this.previous().length > 0) this.applyPrevMaps();
15415 if (this.isAnnotation()) this.addAnnotation();
15416 if (this.isInline()) {
15417 return [
15418 this.css
15419 ];
15420 } else {
15421 return [
15422 this.css,
15423 this.map
15424 ];
15425 }
15426 };
15427 _proto.generateString = function generateString() {
15428 var _this = this;
15429 this.css = "";
15430 this.map = new SourceMapGenerator({
15431 file: this.outputFile(),
15432 ignoreInvalidMapping: true
15433 });
15434 var line = 1;
15435 var column = 1;
15436 var noSource = "<no source>";
15437 var mapping = {
15438 generated: {
15439 column: 0,
15440 line: 0
15441 },
15442 original: {
15443 column: 0,
15444 line: 0
15445 },
15446 source: ""
15447 };
15448 var lines, last;
15449 this.stringify(this.root, function(str, node2, type) {
15450 _this.css += str;
15451 if (node2 && type !== "end") {
15452 mapping.generated.line = line;
15453 mapping.generated.column = column - 1;
15454 if (node2.source && node2.source.start) {
15455 mapping.source = _this.sourcePath(node2);
15456 mapping.original.line = node2.source.start.line;
15457 mapping.original.column = node2.source.start.column - 1;
15458 _this.map.addMapping(mapping);
15459 } else {
15460 mapping.source = noSource;
15461 mapping.original.line = 1;
15462 mapping.original.column = 0;
15463 _this.map.addMapping(mapping);
15464 }
15465 }
15466 lines = str.match(/\n/g);
15467 if (lines) {
15468 line += lines.length;
15469 last = str.lastIndexOf("\n");
15470 column = str.length - last;
15471 } else {
15472 column += str.length;
15473 }
15474 if (node2 && type !== "start") {
15475 var p = node2.parent || {
15476 raws: {}
15477 };
15478 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
15479 if (!childless || node2 !== p.last || p.raws.semicolon) {
15480 if (node2.source && node2.source.end) {
15481 mapping.source = _this.sourcePath(node2);
15482 mapping.original.line = node2.source.end.line;
15483 mapping.original.column = node2.source.end.column - 1;
15484 mapping.generated.line = line;
15485 mapping.generated.column = column - 2;
15486 _this.map.addMapping(mapping);
15487 } else {
15488 mapping.source = noSource;
15489 mapping.original.line = 1;
15490 mapping.original.column = 0;
15491 mapping.generated.line = line;
15492 mapping.generated.column = column - 1;
15493 _this.map.addMapping(mapping);
15494 }
15495 }
15496 }
15497 });
15498 };
15499 _proto.isAnnotation = function isAnnotation() {
15500 if (this.isInline()) {
15501 return true;
15502 }
15503 if (typeof this.mapOpts.annotation !== "undefined") {
15504 return this.mapOpts.annotation;
15505 }
15506 if (this.previous().length) {
15507 return this.previous().some(function(i2) {
15508 return i2.annotation;
15509 });
15510 }
15511 return true;
15512 };
15513 _proto.isInline = function isInline() {
15514 if (typeof this.mapOpts.inline !== "undefined") {
15515 return this.mapOpts.inline;
15516 }
15517 var annotation = this.mapOpts.annotation;
15518 if (typeof annotation !== "undefined" && annotation !== true) {
15519 return false;
15520 }
15521 if (this.previous().length) {
15522 return this.previous().some(function(i2) {
15523 return i2.inline;
15524 });
15525 }
15526 return true;
15527 };
15528 _proto.isMap = function isMap() {
15529 if (typeof this.opts.map !== "undefined") {
15530 return !!this.opts.map;
15531 }
15532 return this.previous().length > 0;
15533 };
15534 _proto.isSourcesContent = function isSourcesContent() {
15535 if (typeof this.mapOpts.sourcesContent !== "undefined") {
15536 return this.mapOpts.sourcesContent;
15537 }
15538 if (this.previous().length) {
15539 return this.previous().some(function(i2) {
15540 return i2.withContent();
15541 });
15542 }
15543 return true;
15544 };
15545 _proto.outputFile = function outputFile() {
15546 if (this.opts.to) {
15547 return this.path(this.opts.to);
15548 } else if (this.opts.from) {
15549 return this.path(this.opts.from);
15550 } else {
15551 return "to.css";
15552 }
15553 };
15554 _proto.path = function path(file) {
15555 if (this.mapOpts.absolute) return file;
15556 if (file.charCodeAt(0) === 60) return file;
15557 if (/^\w+:\/\//.test(file)) return file;
15558 var cached = this.memoizedPaths.get(file);
15559 if (cached) return cached;
15560 var from = this.opts.to ? dirname(this.opts.to) : ".";
15561 if (typeof this.mapOpts.annotation === "string") {
15562 from = dirname(resolve$3(from, this.mapOpts.annotation));
15563 }
15564 var path = relative(from, file);
15565 this.memoizedPaths.set(file, path);
15566 return path;
15567 };
15568 _proto.previous = function previous() {
15569 var _this = this;
15570 if (!this.previousMaps) {
15571 this.previousMaps = [];
15572 if (this.root) {
15573 this.root.walk(function(node2) {
15574 if (node2.source && node2.source.input.map) {
15575 var map = node2.source.input.map;
15576 if (!_this.previousMaps.includes(map)) {
15577 _this.previousMaps.push(map);
15578 }
15579 }
15580 });
15581 } else {
15582 var input2 = new Input$3(this.originalCSS, this.opts);
15583 if (input2.map) this.previousMaps.push(input2.map);
15584 }
15585 }
15586 return this.previousMaps;
15587 };
15588 _proto.setSourcesContent = function setSourcesContent() {
15589 var _this = this;
15590 var already = {};
15591 if (this.root) {
15592 this.root.walk(function(node2) {
15593 if (node2.source) {
15594 var from = node2.source.input.from;
15595 if (from && !already[from]) {
15596 already[from] = true;
15597 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
15598 _this.map.setSourceContent(fromUrl, node2.source.input.css);
15599 }
15600 }
15601 });
15602 } else if (this.css) {
15603 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
15604 this.map.setSourceContent(from, this.css);
15605 }
15606 };
15607 _proto.sourcePath = function sourcePath(node2) {
15608 if (this.mapOpts.from) {
15609 return this.toUrl(this.mapOpts.from);
15610 } else if (this.usesFileUrls) {
15611 return this.toFileUrl(node2.source.input.from);
15612 } else {
15613 return this.toUrl(this.path(node2.source.input.from));
15614 }
15615 };
15616 _proto.toBase64 = function toBase64(str) {
15617 if (Buffer) {
15618 return Buffer.from(str).toString("base64");
15619 } else {
15620 return window.btoa(unescape(encodeURIComponent(str)));
15621 }
15622 };
15623 _proto.toFileUrl = function toFileUrl(path) {
15624 var cached = this.memoizedFileURLs.get(path);
15625 if (cached) return cached;
15626 if (pathToFileURL) {
15627 var fileURL = pathToFileURL(path).toString();
15628 this.memoizedFileURLs.set(path, fileURL);
15629 return fileURL;
15630 } else {
15631 throw new Error("`map.absolute` option is not available in this PostCSS build");
15632 }
15633 };
15634 _proto.toUrl = function toUrl(path) {
15635 var cached = this.memoizedURLs.get(path);
15636 if (cached) return cached;
15637 if (sep === "\\") {
15638 path = path.replace(/\\/g, "/");
15639 }
15640 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
15641 this.memoizedURLs.set(path, url);
15642 return url;
15643 };
15644 return MapGenerator2;
15645 }();
15646 var mapGenerator = MapGenerator$2;
15647 var Node$2 = node;
15648 var Comment$4 = /*#__PURE__*/ function(Node$2) {
15649 _inherits(Comment2, Node$2);
15650 function Comment2(defaults) {
15651 var _this;
15652 _this = Node$2.call(this, defaults) || this;
15653 _this.type = "comment";
15654 return _this;
15655 }
15656 return Comment2;
15657 }(Node$2);
15658 var comment = Comment$4;
15659 Comment$4.default = Comment$4;
15660 var isClean$1 = symbols.isClean, my$1 = symbols.my;
15661 var Declaration$3 = declaration;
15662 var Comment$3 = comment;
15663 var Node$1 = node;
15664 var parse$4, Rule$4, AtRule$4, Root$6;
15665 function cleanSource(nodes) {
15666 return nodes.map(function(i2) {
15667 if (i2.nodes) i2.nodes = cleanSource(i2.nodes);
15668 delete i2.source;
15669 return i2;
15670 });
15671 }
15672 function markDirtyUp(node2) {
15673 node2[isClean$1] = false;
15674 if (node2.proxyOf.nodes) {
15675 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
15676 var i2 = _step.value;
15677 markDirtyUp(i2);
15678 }
15679 }
15680 }
15681 var Container$7 = /*#__PURE__*/ function(Node$1) {
15682 _inherits(Container2, Node$1);
15683 function Container2() {
15684 return Node$1.apply(this, arguments) || this;
15685 }
15686 var _proto = Container2.prototype;
15687 _proto.append = function append() {
15688 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
15689 children[_key] = arguments[_key];
15690 }
15691 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
15692 var child = _step.value;
15693 var nodes = this.normalize(child, this.last);
15694 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15695 var node2 = _step1.value;
15696 this.proxyOf.nodes.push(node2);
15697 }
15698 }
15699 this.markDirty();
15700 return this;
15701 };
15702 _proto.cleanRaws = function cleanRaws(keepBetween) {
15703 Node$1.prototype.cleanRaws.call(this, keepBetween);
15704 if (this.nodes) {
15705 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
15706 var node2 = _step.value;
15707 node2.cleanRaws(keepBetween);
15708 }
15709 }
15710 };
15711 _proto.each = function each(callback) {
15712 if (!this.proxyOf.nodes) return void 0;
15713 var iterator = this.getIterator();
15714 var index2, result2;
15715 while(this.indexes[iterator] < this.proxyOf.nodes.length){
15716 index2 = this.indexes[iterator];
15717 result2 = callback(this.proxyOf.nodes[index2], index2);
15718 if (result2 === false) break;
15719 this.indexes[iterator] += 1;
15720 }
15721 delete this.indexes[iterator];
15722 return result2;
15723 };
15724 _proto.every = function every(condition) {
15725 return this.nodes.every(condition);
15726 };
15727 _proto.getIterator = function getIterator() {
15728 if (!this.lastEach) this.lastEach = 0;
15729 if (!this.indexes) this.indexes = {};
15730 this.lastEach += 1;
15731 var iterator = this.lastEach;
15732 this.indexes[iterator] = 0;
15733 return iterator;
15734 };
15735 _proto.getProxyProcessor = function getProxyProcessor() {
15736 return {
15737 get: function get(node2, prop) {
15738 if (prop === "proxyOf") {
15739 return node2;
15740 } else if (!node2[prop]) {
15741 return node2[prop];
15742 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
15743 return function() {
15744 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
15745 args[_key] = arguments[_key];
15746 }
15747 var _node2;
15748 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
15749 if (typeof i2 === "function") {
15750 return function(child, index2) {
15751 return i2(child.toProxy(), index2);
15752 };
15753 } else {
15754 return i2;
15755 }
15756 })));
15757 };
15758 } else if (prop === "every" || prop === "some") {
15759 return function(cb) {
15760 return node2[prop](function(child) {
15761 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
15762 other[_key - 1] = arguments[_key];
15763 }
15764 return cb.apply(void 0, [].concat([
15765 child.toProxy()
15766 ], other));
15767 });
15768 };
15769 } else if (prop === "root") {
15770 return function() {
15771 return node2.root().toProxy();
15772 };
15773 } else if (prop === "nodes") {
15774 return node2.nodes.map(function(i2) {
15775 return i2.toProxy();
15776 });
15777 } else if (prop === "first" || prop === "last") {
15778 return node2[prop].toProxy();
15779 } else {
15780 return node2[prop];
15781 }
15782 },
15783 set: function set(node2, prop, value) {
15784 if (node2[prop] === value) return true;
15785 node2[prop] = value;
15786 if (prop === "name" || prop === "params" || prop === "selector") {
15787 node2.markDirty();
15788 }
15789 return true;
15790 }
15791 };
15792 };
15793 _proto.index = function index(child) {
15794 if (typeof child === "number") return child;
15795 if (child.proxyOf) child = child.proxyOf;
15796 return this.proxyOf.nodes.indexOf(child);
15797 };
15798 _proto.insertAfter = function insertAfter(exist, add) {
15799 var existIndex = this.index(exist);
15800 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
15801 existIndex = this.index(exist);
15802 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15803 var node2 = _step.value;
15804 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
15805 }
15806 var index2;
15807 for(var id in this.indexes){
15808 index2 = this.indexes[id];
15809 if (existIndex < index2) {
15810 this.indexes[id] = index2 + nodes.length;
15811 }
15812 }
15813 this.markDirty();
15814 return this;
15815 };
15816 _proto.insertBefore = function insertBefore(exist, add) {
15817 var existIndex = this.index(exist);
15818 var type = existIndex === 0 ? "prepend" : false;
15819 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
15820 existIndex = this.index(exist);
15821 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15822 var node2 = _step.value;
15823 this.proxyOf.nodes.splice(existIndex, 0, node2);
15824 }
15825 var index2;
15826 for(var id in this.indexes){
15827 index2 = this.indexes[id];
15828 if (existIndex <= index2) {
15829 this.indexes[id] = index2 + nodes.length;
15830 }
15831 }
15832 this.markDirty();
15833 return this;
15834 };
15835 _proto.normalize = function normalize(nodes, sample) {
15836 var _this = this;
15837 if (typeof nodes === "string") {
15838 nodes = cleanSource(parse$4(nodes).nodes);
15839 } else if (typeof nodes === "undefined") {
15840 nodes = [];
15841 } else if (Array.isArray(nodes)) {
15842 nodes = nodes.slice(0);
15843 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15844 var i2 = _step.value;
15845 if (i2.parent) i2.parent.removeChild(i2, "ignore");
15846 }
15847 } else if (nodes.type === "root" && this.type !== "document") {
15848 nodes = nodes.nodes.slice(0);
15849 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15850 var i21 = _step1.value;
15851 if (i21.parent) i21.parent.removeChild(i21, "ignore");
15852 }
15853 } else if (nodes.type) {
15854 nodes = [
15855 nodes
15856 ];
15857 } else if (nodes.prop) {
15858 if (typeof nodes.value === "undefined") {
15859 throw new Error("Value field is missed in node creation");
15860 } else if (typeof nodes.value !== "string") {
15861 nodes.value = String(nodes.value);
15862 }
15863 nodes = [
15864 new Declaration$3(nodes)
15865 ];
15866 } else if (nodes.selector) {
15867 nodes = [
15868 new Rule$4(nodes)
15869 ];
15870 } else if (nodes.name) {
15871 nodes = [
15872 new AtRule$4(nodes)
15873 ];
15874 } else if (nodes.text) {
15875 nodes = [
15876 new Comment$3(nodes)
15877 ];
15878 } else {
15879 throw new Error("Unknown node type in node creation");
15880 }
15881 var processed = nodes.map(function(i2) {
15882 if (!i2[my$1]) Container2.rebuild(i2);
15883 i2 = i2.proxyOf;
15884 if (i2.parent) i2.parent.removeChild(i2);
15885 if (i2[isClean$1]) markDirtyUp(i2);
15886 if (typeof i2.raws.before === "undefined") {
15887 if (sample && typeof sample.raws.before !== "undefined") {
15888 i2.raws.before = sample.raws.before.replace(/\S/g, "");
15889 }
15890 }
15891 i2.parent = _this.proxyOf;
15892 return i2;
15893 });
15894 return processed;
15895 };
15896 _proto.prepend = function prepend() {
15897 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
15898 children[_key] = arguments[_key];
15899 }
15900 children = children.reverse();
15901 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
15902 var child = _step.value;
15903 var nodes = this.normalize(child, this.first, "prepend").reverse();
15904 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15905 var node2 = _step1.value;
15906 this.proxyOf.nodes.unshift(node2);
15907 }
15908 for(var id in this.indexes){
15909 this.indexes[id] = this.indexes[id] + nodes.length;
15910 }
15911 }
15912 this.markDirty();
15913 return this;
15914 };
15915 _proto.push = function push(child) {
15916 child.parent = this;
15917 this.proxyOf.nodes.push(child);
15918 return this;
15919 };
15920 _proto.removeAll = function removeAll() {
15921 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
15922 var node2 = _step.value;
15923 node2.parent = void 0;
15924 }
15925 this.proxyOf.nodes = [];
15926 this.markDirty();
15927 return this;
15928 };
15929 _proto.removeChild = function removeChild(child) {
15930 child = this.index(child);
15931 this.proxyOf.nodes[child].parent = void 0;
15932 this.proxyOf.nodes.splice(child, 1);
15933 var index2;
15934 for(var id in this.indexes){
15935 index2 = this.indexes[id];
15936 if (index2 >= child) {
15937 this.indexes[id] = index2 - 1;
15938 }
15939 }
15940 this.markDirty();
15941 return this;
15942 };
15943 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
15944 if (!callback) {
15945 callback = opts;
15946 opts = {};
15947 }
15948 this.walkDecls(function(decl) {
15949 if (opts.props && !opts.props.includes(decl.prop)) return;
15950 if (opts.fast && !decl.value.includes(opts.fast)) return;
15951 decl.value = decl.value.replace(pattern, callback);
15952 });
15953 this.markDirty();
15954 return this;
15955 };
15956 _proto.some = function some(condition) {
15957 return this.nodes.some(condition);
15958 };
15959 _proto.walk = function walk(callback) {
15960 return this.each(function(child, i2) {
15961 var result2;
15962 try {
15963 result2 = callback(child, i2);
15964 } catch (e2) {
15965 throw child.addToError(e2);
15966 }
15967 if (result2 !== false && child.walk) {
15968 result2 = child.walk(callback);
15969 }
15970 return result2;
15971 });
15972 };
15973 _proto.walkAtRules = function walkAtRules(name, callback) {
15974 if (!callback) {
15975 callback = name;
15976 return this.walk(function(child, i2) {
15977 if (child.type === "atrule") {
15978 return callback(child, i2);
15979 }
15980 });
15981 }
15982 if (_instanceof(name, RegExp)) {
15983 return this.walk(function(child, i2) {
15984 if (child.type === "atrule" && name.test(child.name)) {
15985 return callback(child, i2);
15986 }
15987 });
15988 }
15989 return this.walk(function(child, i2) {
15990 if (child.type === "atrule" && child.name === name) {
15991 return callback(child, i2);
15992 }
15993 });
15994 };
15995 _proto.walkComments = function walkComments(callback) {
15996 return this.walk(function(child, i2) {
15997 if (child.type === "comment") {
15998 return callback(child, i2);
15999 }
16000 });
16001 };
16002 _proto.walkDecls = function walkDecls(prop, callback) {
16003 if (!callback) {
16004 callback = prop;
16005 return this.walk(function(child, i2) {
16006 if (child.type === "decl") {
16007 return callback(child, i2);
16008 }
16009 });
16010 }
16011 if (_instanceof(prop, RegExp)) {
16012 return this.walk(function(child, i2) {
16013 if (child.type === "decl" && prop.test(child.prop)) {
16014 return callback(child, i2);
16015 }
16016 });
16017 }
16018 return this.walk(function(child, i2) {
16019 if (child.type === "decl" && child.prop === prop) {
16020 return callback(child, i2);
16021 }
16022 });
16023 };
16024 _proto.walkRules = function walkRules(selector, callback) {
16025 if (!callback) {
16026 callback = selector;
16027 return this.walk(function(child, i2) {
16028 if (child.type === "rule") {
16029 return callback(child, i2);
16030 }
16031 });
16032 }
16033 if (_instanceof(selector, RegExp)) {
16034 return this.walk(function(child, i2) {
16035 if (child.type === "rule" && selector.test(child.selector)) {
16036 return callback(child, i2);
16037 }
16038 });
16039 }
16040 return this.walk(function(child, i2) {
16041 if (child.type === "rule" && child.selector === selector) {
16042 return callback(child, i2);
16043 }
16044 });
16045 };
16046 _create_class(Container2, [
16047 {
16048 key: "first",
16049 get: function get() {
16050 if (!this.proxyOf.nodes) return void 0;
16051 return this.proxyOf.nodes[0];
16052 }
16053 },
16054 {
16055 key: "last",
16056 get: function get() {
16057 if (!this.proxyOf.nodes) return void 0;
16058 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
16059 }
16060 }
16061 ]);
16062 return Container2;
16063 }(Node$1);
16064 Container$7.registerParse = function(dependant) {
16065 parse$4 = dependant;
16066 };
16067 Container$7.registerRule = function(dependant) {
16068 Rule$4 = dependant;
16069 };
16070 Container$7.registerAtRule = function(dependant) {
16071 AtRule$4 = dependant;
16072 };
16073 Container$7.registerRoot = function(dependant) {
16074 Root$6 = dependant;
16075 };
16076 var container = Container$7;
16077 Container$7.default = Container$7;
16078 Container$7.rebuild = function(node2) {
16079 if (node2.type === "atrule") {
16080 Object.setPrototypeOf(node2, AtRule$4.prototype);
16081 } else if (node2.type === "rule") {
16082 Object.setPrototypeOf(node2, Rule$4.prototype);
16083 } else if (node2.type === "decl") {
16084 Object.setPrototypeOf(node2, Declaration$3.prototype);
16085 } else if (node2.type === "comment") {
16086 Object.setPrototypeOf(node2, Comment$3.prototype);
16087 } else if (node2.type === "root") {
16088 Object.setPrototypeOf(node2, Root$6.prototype);
16089 }
16090 node2[my$1] = true;
16091 if (node2.nodes) {
16092 node2.nodes.forEach(function(child) {
16093 Container$7.rebuild(child);
16094 });
16095 }
16096 };
16097 var Container$6 = container;
16098 var LazyResult$4, Processor$3;
16099 var Document$3 = /*#__PURE__*/ function(Container$6) {
16100 _inherits(Document23, Container$6);
16101 function Document23(defaults) {
16102 var _this;
16103 _this = Container$6.call(this, _extends({
16104 type: "document"
16105 }, defaults)) || this;
16106 if (!_this.nodes) {
16107 _this.nodes = [];
16108 }
16109 return _this;
16110 }
16111 var _proto = Document23.prototype;
16112 _proto.toResult = function toResult(opts) {
16113 if (opts === void 0) opts = {};
16114 var lazy = new LazyResult$4(new Processor$3(), this, opts);
16115 return lazy.stringify();
16116 };
16117 return Document23;
16118 }(Container$6);
16119 Document$3.registerLazyResult = function(dependant) {
16120 LazyResult$4 = dependant;
16121 };
16122 Document$3.registerProcessor = function(dependant) {
16123 Processor$3 = dependant;
16124 };
16125 var document$1$2 = Document$3;
16126 Document$3.default = Document$3;
16127 var printed = {};
16128 var warnOnce$2 = function warnOnce2(message) {
16129 if (printed[message]) return;
16130 printed[message] = true;
16131 if (typeof console !== "undefined" && console.warn) {
16132 console.warn(message);
16133 }
16134 };
16135 var Warning$2 = /*#__PURE__*/ function() {
16136 function Warning2(text, opts) {
16137 if (opts === void 0) opts = {};
16138 this.type = "warning";
16139 this.text = text;
16140 if (opts.node && opts.node.source) {
16141 var range = opts.node.rangeBy(opts);
16142 this.line = range.start.line;
16143 this.column = range.start.column;
16144 this.endLine = range.end.line;
16145 this.endColumn = range.end.column;
16146 }
16147 for(var opt in opts)this[opt] = opts[opt];
16148 }
16149 var _proto = Warning2.prototype;
16150 _proto.toString = function toString() {
16151 if (this.node) {
16152 return this.node.error(this.text, {
16153 index: this.index,
16154 plugin: this.plugin,
16155 word: this.word
16156 }).message;
16157 }
16158 if (this.plugin) {
16159 return this.plugin + ": " + this.text;
16160 }
16161 return this.text;
16162 };
16163 return Warning2;
16164 }();
16165 var warning = Warning$2;
16166 Warning$2.default = Warning$2;
16167 var Warning$1 = warning;
16168 var Result$3 = /*#__PURE__*/ function() {
16169 function Result2(processor2, root2, opts) {
16170 this.processor = processor2;
16171 this.messages = [];
16172 this.root = root2;
16173 this.opts = opts;
16174 this.css = void 0;
16175 this.map = void 0;
16176 }
16177 var _proto = Result2.prototype;
16178 _proto.toString = function toString() {
16179 return this.css;
16180 };
16181 _proto.warn = function warn(text, opts) {
16182 if (opts === void 0) opts = {};
16183 if (!opts.plugin) {
16184 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
16185 opts.plugin = this.lastPlugin.postcssPlugin;
16186 }
16187 }
16188 var warning2 = new Warning$1(text, opts);
16189 this.messages.push(warning2);
16190 return warning2;
16191 };
16192 _proto.warnings = function warnings() {
16193 return this.messages.filter(function(i2) {
16194 return i2.type === "warning";
16195 });
16196 };
16197 _create_class(Result2, [
16198 {
16199 key: "content",
16200 get: function get() {
16201 return this.css;
16202 }
16203 }
16204 ]);
16205 return Result2;
16206 }();
16207 var result = Result$3;
16208 Result$3.default = Result$3;
16209 var SINGLE_QUOTE = "'".charCodeAt(0);
16210 var DOUBLE_QUOTE = '"'.charCodeAt(0);
16211 var BACKSLASH = "\\".charCodeAt(0);
16212 var SLASH = "/".charCodeAt(0);
16213 var NEWLINE = "\n".charCodeAt(0);
16214 var SPACE = " ".charCodeAt(0);
16215 var FEED = "\f".charCodeAt(0);
16216 var TAB = " ".charCodeAt(0);
16217 var CR = "\r".charCodeAt(0);
16218 var OPEN_SQUARE = "[".charCodeAt(0);
16219 var CLOSE_SQUARE = "]".charCodeAt(0);
16220 var OPEN_PARENTHESES = "(".charCodeAt(0);
16221 var CLOSE_PARENTHESES = ")".charCodeAt(0);
16222 var OPEN_CURLY = "{".charCodeAt(0);
16223 var CLOSE_CURLY = "}".charCodeAt(0);
16224 var SEMICOLON = ";".charCodeAt(0);
16225 var ASTERISK = "*".charCodeAt(0);
16226 var COLON = ":".charCodeAt(0);
16227 var AT = "@".charCodeAt(0);
16228 var RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
16229 var RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
16230 var RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
16231 var RE_HEX_ESCAPE = /[\da-f]/i;
16232 var tokenize = function tokenizer2(input2, options) {
16233 if (options === void 0) options = {};
16234 var css = input2.css.valueOf();
16235 var ignore = options.ignoreErrors;
16236 var code, next, quote, content, escape;
16237 var escaped, escapePos, prev, n2, currentToken;
16238 var length = css.length;
16239 var pos = 0;
16240 var buffer = [];
16241 var returned = [];
16242 function position() {
16243 return pos;
16244 }
16245 function unclosed(what) {
16246 throw input2.error("Unclosed " + what, pos);
16247 }
16248 function endOfFile() {
16249 return returned.length === 0 && pos >= length;
16250 }
16251 function nextToken(opts) {
16252 if (returned.length) return returned.pop();
16253 if (pos >= length) return;
16254 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
16255 code = css.charCodeAt(pos);
16256 switch(code){
16257 case NEWLINE:
16258 case SPACE:
16259 case TAB:
16260 case CR:
16261 case FEED:
16262 {
16263 next = pos;
16264 do {
16265 next += 1;
16266 code = css.charCodeAt(next);
16267 }while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED);
16268 currentToken = [
16269 "space",
16270 css.slice(pos, next)
16271 ];
16272 pos = next - 1;
16273 break;
16274 }
16275 case OPEN_SQUARE:
16276 case CLOSE_SQUARE:
16277 case OPEN_CURLY:
16278 case CLOSE_CURLY:
16279 case COLON:
16280 case SEMICOLON:
16281 case CLOSE_PARENTHESES:
16282 {
16283 var controlChar = String.fromCharCode(code);
16284 currentToken = [
16285 controlChar,
16286 controlChar,
16287 pos
16288 ];
16289 break;
16290 }
16291 case OPEN_PARENTHESES:
16292 {
16293 prev = buffer.length ? buffer.pop()[1] : "";
16294 n2 = css.charCodeAt(pos + 1);
16295 if (prev === "url" && n2 !== SINGLE_QUOTE && n2 !== DOUBLE_QUOTE && n2 !== SPACE && n2 !== NEWLINE && n2 !== TAB && n2 !== FEED && n2 !== CR) {
16296 next = pos;
16297 do {
16298 escaped = false;
16299 next = css.indexOf(")", next + 1);
16300 if (next === -1) {
16301 if (ignore || ignoreUnclosed) {
16302 next = pos;
16303 break;
16304 } else {
16305 unclosed("bracket");
16306 }
16307 }
16308 escapePos = next;
16309 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16310 escapePos -= 1;
16311 escaped = !escaped;
16312 }
16313 }while (escaped);
16314 currentToken = [
16315 "brackets",
16316 css.slice(pos, next + 1),
16317 pos,
16318 next
16319 ];
16320 pos = next;
16321 } else {
16322 next = css.indexOf(")", pos + 1);
16323 content = css.slice(pos, next + 1);
16324 if (next === -1 || RE_BAD_BRACKET.test(content)) {
16325 currentToken = [
16326 "(",
16327 "(",
16328 pos
16329 ];
16330 } else {
16331 currentToken = [
16332 "brackets",
16333 content,
16334 pos,
16335 next
16336 ];
16337 pos = next;
16338 }
16339 }
16340 break;
16341 }
16342 case SINGLE_QUOTE:
16343 case DOUBLE_QUOTE:
16344 {
16345 quote = code === SINGLE_QUOTE ? "'" : '"';
16346 next = pos;
16347 do {
16348 escaped = false;
16349 next = css.indexOf(quote, next + 1);
16350 if (next === -1) {
16351 if (ignore || ignoreUnclosed) {
16352 next = pos + 1;
16353 break;
16354 } else {
16355 unclosed("string");
16356 }
16357 }
16358 escapePos = next;
16359 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16360 escapePos -= 1;
16361 escaped = !escaped;
16362 }
16363 }while (escaped);
16364 currentToken = [
16365 "string",
16366 css.slice(pos, next + 1),
16367 pos,
16368 next
16369 ];
16370 pos = next;
16371 break;
16372 }
16373 case AT:
16374 {
16375 RE_AT_END.lastIndex = pos + 1;
16376 RE_AT_END.test(css);
16377 if (RE_AT_END.lastIndex === 0) {
16378 next = css.length - 1;
16379 } else {
16380 next = RE_AT_END.lastIndex - 2;
16381 }
16382 currentToken = [
16383 "at-word",
16384 css.slice(pos, next + 1),
16385 pos,
16386 next
16387 ];
16388 pos = next;
16389 break;
16390 }
16391 case BACKSLASH:
16392 {
16393 next = pos;
16394 escape = true;
16395 while(css.charCodeAt(next + 1) === BACKSLASH){
16396 next += 1;
16397 escape = !escape;
16398 }
16399 code = css.charCodeAt(next + 1);
16400 if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
16401 next += 1;
16402 if (RE_HEX_ESCAPE.test(css.charAt(next))) {
16403 while(RE_HEX_ESCAPE.test(css.charAt(next + 1))){
16404 next += 1;
16405 }
16406 if (css.charCodeAt(next + 1) === SPACE) {
16407 next += 1;
16408 }
16409 }
16410 }
16411 currentToken = [
16412 "word",
16413 css.slice(pos, next + 1),
16414 pos,
16415 next
16416 ];
16417 pos = next;
16418 break;
16419 }
16420 default:
16421 {
16422 if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
16423 next = css.indexOf("*/", pos + 2) + 1;
16424 if (next === 0) {
16425 if (ignore || ignoreUnclosed) {
16426 next = css.length;
16427 } else {
16428 unclosed("comment");
16429 }
16430 }
16431 currentToken = [
16432 "comment",
16433 css.slice(pos, next + 1),
16434 pos,
16435 next
16436 ];
16437 pos = next;
16438 } else {
16439 RE_WORD_END.lastIndex = pos + 1;
16440 RE_WORD_END.test(css);
16441 if (RE_WORD_END.lastIndex === 0) {
16442 next = css.length - 1;
16443 } else {
16444 next = RE_WORD_END.lastIndex - 2;
16445 }
16446 currentToken = [
16447 "word",
16448 css.slice(pos, next + 1),
16449 pos,
16450 next
16451 ];
16452 buffer.push(currentToken);
16453 pos = next;
16454 }
16455 break;
16456 }
16457 }
16458 pos++;
16459 return currentToken;
16460 }
16461 function back(token) {
16462 returned.push(token);
16463 }
16464 return {
16465 back: back,
16466 endOfFile: endOfFile,
16467 nextToken: nextToken,
16468 position: position
16469 };
16470 };
16471 var Container$5 = container;
16472 var AtRule$3 = /*#__PURE__*/ function(Container$5) {
16473 _inherits(AtRule2, Container$5);
16474 function AtRule2(defaults) {
16475 var _this;
16476 _this = Container$5.call(this, defaults) || this;
16477 _this.type = "atrule";
16478 return _this;
16479 }
16480 var _proto = AtRule2.prototype;
16481 _proto.append = function append() {
16482 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16483 children[_key] = arguments[_key];
16484 }
16485 var _Container$5_prototype_append;
16486 if (!this.proxyOf.nodes) this.nodes = [];
16487 return (_Container$5_prototype_append = Container$5.prototype.append).call.apply(_Container$5_prototype_append, [].concat([
16488 this
16489 ], children));
16490 };
16491 _proto.prepend = function prepend() {
16492 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16493 children[_key] = arguments[_key];
16494 }
16495 var _Container$5_prototype_prepend;
16496 if (!this.proxyOf.nodes) this.nodes = [];
16497 return (_Container$5_prototype_prepend = Container$5.prototype.prepend).call.apply(_Container$5_prototype_prepend, [].concat([
16498 this
16499 ], children));
16500 };
16501 return AtRule2;
16502 }(Container$5);
16503 var atRule = AtRule$3;
16504 AtRule$3.default = AtRule$3;
16505 Container$5.registerAtRule(AtRule$3);
16506 var Container$4 = container;
16507 var LazyResult$3, Processor$2;
16508 var Root$5 = /*#__PURE__*/ function(Container$4) {
16509 _inherits(Root2, Container$4);
16510 function Root2(defaults) {
16511 var _this;
16512 _this = Container$4.call(this, defaults) || this;
16513 _this.type = "root";
16514 if (!_this.nodes) _this.nodes = [];
16515 return _this;
16516 }
16517 var _proto = Root2.prototype;
16518 _proto.normalize = function normalize(child, sample, type) {
16519 var nodes = Container$4.prototype.normalize.call(this, child);
16520 if (sample) {
16521 if (type === "prepend") {
16522 if (this.nodes.length > 1) {
16523 sample.raws.before = this.nodes[1].raws.before;
16524 } else {
16525 delete sample.raws.before;
16526 }
16527 } else if (this.first !== sample) {
16528 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16529 var node2 = _step.value;
16530 node2.raws.before = sample.raws.before;
16531 }
16532 }
16533 }
16534 return nodes;
16535 };
16536 _proto.removeChild = function removeChild(child, ignore) {
16537 var index2 = this.index(child);
16538 if (!ignore && index2 === 0 && this.nodes.length > 1) {
16539 this.nodes[1].raws.before = this.nodes[index2].raws.before;
16540 }
16541 return Container$4.prototype.removeChild.call(this, child);
16542 };
16543 _proto.toResult = function toResult(opts) {
16544 if (opts === void 0) opts = {};
16545 var lazy = new LazyResult$3(new Processor$2(), this, opts);
16546 return lazy.stringify();
16547 };
16548 return Root2;
16549 }(Container$4);
16550 Root$5.registerLazyResult = function(dependant) {
16551 LazyResult$3 = dependant;
16552 };
16553 Root$5.registerProcessor = function(dependant) {
16554 Processor$2 = dependant;
16555 };
16556 var root = Root$5;
16557 Root$5.default = Root$5;
16558 Container$4.registerRoot(Root$5);
16559 var list$2 = {
16560 comma: function comma(string) {
16561 return list$2.split(string, [
16562 ","
16563 ], true);
16564 },
16565 space: function space(string) {
16566 var spaces = [
16567 " ",
16568 "\n",
16569 " "
16570 ];
16571 return list$2.split(string, spaces);
16572 },
16573 split: function split(string, separators, last) {
16574 var array = [];
16575 var current = "";
16576 var split = false;
16577 var func = 0;
16578 var inQuote = false;
16579 var prevQuote = "";
16580 var escape = false;
16581 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
16582 var letter = _step.value;
16583 if (escape) {
16584 escape = false;
16585 } else if (letter === "\\") {
16586 escape = true;
16587 } else if (inQuote) {
16588 if (letter === prevQuote) {
16589 inQuote = false;
16590 }
16591 } else if (letter === '"' || letter === "'") {
16592 inQuote = true;
16593 prevQuote = letter;
16594 } else if (letter === "(") {
16595 func += 1;
16596 } else if (letter === ")") {
16597 if (func > 0) func -= 1;
16598 } else if (func === 0) {
16599 if (separators.includes(letter)) split = true;
16600 }
16601 if (split) {
16602 if (current !== "") array.push(current.trim());
16603 current = "";
16604 split = false;
16605 } else {
16606 current += letter;
16607 }
16608 }
16609 if (last || current !== "") array.push(current.trim());
16610 return array;
16611 }
16612 };
16613 var list_1 = list$2;
16614 list$2.default = list$2;
16615 var Container$3 = container;
16616 var list$1 = list_1;
16617 var Rule$3 = /*#__PURE__*/ function(Container$3) {
16618 _inherits(Rule2, Container$3);
16619 function Rule2(defaults) {
16620 var _this;
16621 _this = Container$3.call(this, defaults) || this;
16622 _this.type = "rule";
16623 if (!_this.nodes) _this.nodes = [];
16624 return _this;
16625 }
16626 _create_class(Rule2, [
16627 {
16628 key: "selectors",
16629 get: function get() {
16630 return list$1.comma(this.selector);
16631 },
16632 set: function set(values) {
16633 var match = this.selector ? this.selector.match(/,\s*/) : null;
16634 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
16635 this.selector = values.join(sep2);
16636 }
16637 }
16638 ]);
16639 return Rule2;
16640 }(Container$3);
16641 var rule = Rule$3;
16642 Rule$3.default = Rule$3;
16643 Container$3.registerRule(Rule$3);
16644 var Declaration$2 = declaration;
16645 var tokenizer22 = tokenize;
16646 var Comment$2 = comment;
16647 var AtRule$2 = atRule;
16648 var Root$4 = root;
16649 var Rule$2 = rule;
16650 var SAFE_COMMENT_NEIGHBOR = {
16651 empty: true,
16652 space: true
16653 };
16654 function findLastWithPosition(tokens) {
16655 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
16656 var token = tokens[i2];
16657 var pos = token[3] || token[2];
16658 if (pos) return pos;
16659 }
16660 }
16661 var Parser$1 = /*#__PURE__*/ function() {
16662 function Parser2(input2) {
16663 this.input = input2;
16664 this.root = new Root$4();
16665 this.current = this.root;
16666 this.spaces = "";
16667 this.semicolon = false;
16668 this.createTokenizer();
16669 this.root.source = {
16670 input: input2,
16671 start: {
16672 column: 1,
16673 line: 1,
16674 offset: 0
16675 }
16676 };
16677 }
16678 var _proto = Parser2.prototype;
16679 _proto.atrule = function atrule(token) {
16680 var node2 = new AtRule$2();
16681 node2.name = token[1].slice(1);
16682 if (node2.name === "") {
16683 this.unnamedAtrule(node2, token);
16684 }
16685 this.init(node2, token[2]);
16686 var type;
16687 var prev;
16688 var shift;
16689 var last = false;
16690 var open = false;
16691 var params = [];
16692 var brackets = [];
16693 while(!this.tokenizer.endOfFile()){
16694 token = this.tokenizer.nextToken();
16695 type = token[0];
16696 if (type === "(" || type === "[") {
16697 brackets.push(type === "(" ? ")" : "]");
16698 } else if (type === "{" && brackets.length > 0) {
16699 brackets.push("}");
16700 } else if (type === brackets[brackets.length - 1]) {
16701 brackets.pop();
16702 }
16703 if (brackets.length === 0) {
16704 if (type === ";") {
16705 node2.source.end = this.getPosition(token[2]);
16706 node2.source.end.offset++;
16707 this.semicolon = true;
16708 break;
16709 } else if (type === "{") {
16710 open = true;
16711 break;
16712 } else if (type === "}") {
16713 if (params.length > 0) {
16714 shift = params.length - 1;
16715 prev = params[shift];
16716 while(prev && prev[0] === "space"){
16717 prev = params[--shift];
16718 }
16719 if (prev) {
16720 node2.source.end = this.getPosition(prev[3] || prev[2]);
16721 node2.source.end.offset++;
16722 }
16723 }
16724 this.end(token);
16725 break;
16726 } else {
16727 params.push(token);
16728 }
16729 } else {
16730 params.push(token);
16731 }
16732 if (this.tokenizer.endOfFile()) {
16733 last = true;
16734 break;
16735 }
16736 }
16737 node2.raws.between = this.spacesAndCommentsFromEnd(params);
16738 if (params.length) {
16739 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
16740 this.raw(node2, "params", params);
16741 if (last) {
16742 token = params[params.length - 1];
16743 node2.source.end = this.getPosition(token[3] || token[2]);
16744 node2.source.end.offset++;
16745 this.spaces = node2.raws.between;
16746 node2.raws.between = "";
16747 }
16748 } else {
16749 node2.raws.afterName = "";
16750 node2.params = "";
16751 }
16752 if (open) {
16753 node2.nodes = [];
16754 this.current = node2;
16755 }
16756 };
16757 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
16758 var colon = this.colon(tokens);
16759 if (colon === false) return;
16760 var founded = 0;
16761 var token;
16762 for(var j = colon - 1; j >= 0; j--){
16763 token = tokens[j];
16764 if (token[0] !== "space") {
16765 founded += 1;
16766 if (founded === 2) break;
16767 }
16768 }
16769 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
16770 };
16771 _proto.colon = function colon(tokens) {
16772 var brackets = 0;
16773 var token, type, prev;
16774 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
16775 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
16776 token = element;
16777 type = token[0];
16778 if (type === "(") {
16779 brackets += 1;
16780 }
16781 if (type === ")") {
16782 brackets -= 1;
16783 }
16784 if (brackets === 0 && type === ":") {
16785 if (!prev) {
16786 this.doubleColon(token);
16787 } else if (prev[0] === "word" && prev[1] === "progid") {
16788 continue;
16789 } else {
16790 return i2;
16791 }
16792 }
16793 prev = token;
16794 }
16795 return false;
16796 };
16797 _proto.comment = function comment(token) {
16798 var node2 = new Comment$2();
16799 this.init(node2, token[2]);
16800 node2.source.end = this.getPosition(token[3] || token[2]);
16801 node2.source.end.offset++;
16802 var text = token[1].slice(2, -2);
16803 if (/^\s*$/.test(text)) {
16804 node2.text = "";
16805 node2.raws.left = text;
16806 node2.raws.right = "";
16807 } else {
16808 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
16809 node2.text = match[2];
16810 node2.raws.left = match[1];
16811 node2.raws.right = match[3];
16812 }
16813 };
16814 _proto.createTokenizer = function createTokenizer() {
16815 this.tokenizer = tokenizer22(this.input);
16816 };
16817 _proto.decl = function decl(tokens, customProperty) {
16818 var node2 = new Declaration$2();
16819 this.init(node2, tokens[0][2]);
16820 var last = tokens[tokens.length - 1];
16821 if (last[0] === ";") {
16822 this.semicolon = true;
16823 tokens.pop();
16824 }
16825 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition(tokens));
16826 node2.source.end.offset++;
16827 while(tokens[0][0] !== "word"){
16828 if (tokens.length === 1) this.unknownWord(tokens);
16829 node2.raws.before += tokens.shift()[1];
16830 }
16831 node2.source.start = this.getPosition(tokens[0][2]);
16832 node2.prop = "";
16833 while(tokens.length){
16834 var type = tokens[0][0];
16835 if (type === ":" || type === "space" || type === "comment") {
16836 break;
16837 }
16838 node2.prop += tokens.shift()[1];
16839 }
16840 node2.raws.between = "";
16841 var token;
16842 while(tokens.length){
16843 token = tokens.shift();
16844 if (token[0] === ":") {
16845 node2.raws.between += token[1];
16846 break;
16847 } else {
16848 if (token[0] === "word" && /\w/.test(token[1])) {
16849 this.unknownWord([
16850 token
16851 ]);
16852 }
16853 node2.raws.between += token[1];
16854 }
16855 }
16856 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
16857 node2.raws.before += node2.prop[0];
16858 node2.prop = node2.prop.slice(1);
16859 }
16860 var firstSpaces = [];
16861 var next;
16862 while(tokens.length){
16863 next = tokens[0][0];
16864 if (next !== "space" && next !== "comment") break;
16865 firstSpaces.push(tokens.shift());
16866 }
16867 this.precheckMissedSemicolon(tokens);
16868 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
16869 token = tokens[i2];
16870 if (token[1].toLowerCase() === "!important") {
16871 node2.important = true;
16872 var string = this.stringFrom(tokens, i2);
16873 string = this.spacesFromEnd(tokens) + string;
16874 if (string !== " !important") node2.raws.important = string;
16875 break;
16876 } else if (token[1].toLowerCase() === "important") {
16877 var cache = tokens.slice(0);
16878 var str = "";
16879 for(var j = i2; j > 0; j--){
16880 var type1 = cache[j][0];
16881 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
16882 break;
16883 }
16884 str = cache.pop()[1] + str;
16885 }
16886 if (str.trim().indexOf("!") === 0) {
16887 node2.important = true;
16888 node2.raws.important = str;
16889 tokens = cache;
16890 }
16891 }
16892 if (token[0] !== "space" && token[0] !== "comment") {
16893 break;
16894 }
16895 }
16896 var hasWord = tokens.some(function(i2) {
16897 return i2[0] !== "space" && i2[0] !== "comment";
16898 });
16899 if (hasWord) {
16900 node2.raws.between += firstSpaces.map(function(i2) {
16901 return i2[1];
16902 }).join("");
16903 firstSpaces = [];
16904 }
16905 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
16906 if (node2.value.includes(":") && !customProperty) {
16907 this.checkMissedSemicolon(tokens);
16908 }
16909 };
16910 _proto.doubleColon = function doubleColon(token) {
16911 throw this.input.error("Double colon", {
16912 offset: token[2]
16913 }, {
16914 offset: token[2] + token[1].length
16915 });
16916 };
16917 _proto.emptyRule = function emptyRule(token) {
16918 var node2 = new Rule$2();
16919 this.init(node2, token[2]);
16920 node2.selector = "";
16921 node2.raws.between = "";
16922 this.current = node2;
16923 };
16924 _proto.end = function end(token) {
16925 if (this.current.nodes && this.current.nodes.length) {
16926 this.current.raws.semicolon = this.semicolon;
16927 }
16928 this.semicolon = false;
16929 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
16930 this.spaces = "";
16931 if (this.current.parent) {
16932 this.current.source.end = this.getPosition(token[2]);
16933 this.current.source.end.offset++;
16934 this.current = this.current.parent;
16935 } else {
16936 this.unexpectedClose(token);
16937 }
16938 };
16939 _proto.endFile = function endFile() {
16940 if (this.current.parent) this.unclosedBlock();
16941 if (this.current.nodes && this.current.nodes.length) {
16942 this.current.raws.semicolon = this.semicolon;
16943 }
16944 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
16945 this.root.source.end = this.getPosition(this.tokenizer.position());
16946 };
16947 _proto.freeSemicolon = function freeSemicolon(token) {
16948 this.spaces += token[1];
16949 if (this.current.nodes) {
16950 var prev = this.current.nodes[this.current.nodes.length - 1];
16951 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
16952 prev.raws.ownSemicolon = this.spaces;
16953 this.spaces = "";
16954 }
16955 }
16956 };
16957 // Helpers
16958 _proto.getPosition = function getPosition(offset) {
16959 var pos = this.input.fromOffset(offset);
16960 return {
16961 column: pos.col,
16962 line: pos.line,
16963 offset: offset
16964 };
16965 };
16966 _proto.init = function init(node2, offset) {
16967 this.current.push(node2);
16968 node2.source = {
16969 input: this.input,
16970 start: this.getPosition(offset)
16971 };
16972 node2.raws.before = this.spaces;
16973 this.spaces = "";
16974 if (node2.type !== "comment") this.semicolon = false;
16975 };
16976 _proto.other = function other(start) {
16977 var end = false;
16978 var type = null;
16979 var colon = false;
16980 var bracket = null;
16981 var brackets = [];
16982 var customProperty = start[1].startsWith("--");
16983 var tokens = [];
16984 var token = start;
16985 while(token){
16986 type = token[0];
16987 tokens.push(token);
16988 if (type === "(" || type === "[") {
16989 if (!bracket) bracket = token;
16990 brackets.push(type === "(" ? ")" : "]");
16991 } else if (customProperty && colon && type === "{") {
16992 if (!bracket) bracket = token;
16993 brackets.push("}");
16994 } else if (brackets.length === 0) {
16995 if (type === ";") {
16996 if (colon) {
16997 this.decl(tokens, customProperty);
16998 return;
16999 } else {
17000 break;
17001 }
17002 } else if (type === "{") {
17003 this.rule(tokens);
17004 return;
17005 } else if (type === "}") {
17006 this.tokenizer.back(tokens.pop());
17007 end = true;
17008 break;
17009 } else if (type === ":") {
17010 colon = true;
17011 }
17012 } else if (type === brackets[brackets.length - 1]) {
17013 brackets.pop();
17014 if (brackets.length === 0) bracket = null;
17015 }
17016 token = this.tokenizer.nextToken();
17017 }
17018 if (this.tokenizer.endOfFile()) end = true;
17019 if (brackets.length > 0) this.unclosedBracket(bracket);
17020 if (end && colon) {
17021 if (!customProperty) {
17022 while(tokens.length){
17023 token = tokens[tokens.length - 1][0];
17024 if (token !== "space" && token !== "comment") break;
17025 this.tokenizer.back(tokens.pop());
17026 }
17027 }
17028 this.decl(tokens, customProperty);
17029 } else {
17030 this.unknownWord(tokens);
17031 }
17032 };
17033 _proto.parse = function parse() {
17034 var token;
17035 while(!this.tokenizer.endOfFile()){
17036 token = this.tokenizer.nextToken();
17037 switch(token[0]){
17038 case "space":
17039 this.spaces += token[1];
17040 break;
17041 case ";":
17042 this.freeSemicolon(token);
17043 break;
17044 case "}":
17045 this.end(token);
17046 break;
17047 case "comment":
17048 this.comment(token);
17049 break;
17050 case "at-word":
17051 this.atrule(token);
17052 break;
17053 case "{":
17054 this.emptyRule(token);
17055 break;
17056 default:
17057 this.other(token);
17058 break;
17059 }
17060 }
17061 this.endFile();
17062 };
17063 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
17064 _proto.raw = function raw(node2, prop, tokens, customProperty) {
17065 var token, type;
17066 var length = tokens.length;
17067 var value = "";
17068 var clean = true;
17069 var next, prev;
17070 for(var i2 = 0; i2 < length; i2 += 1){
17071 token = tokens[i2];
17072 type = token[0];
17073 if (type === "space" && i2 === length - 1 && !customProperty) {
17074 clean = false;
17075 } else if (type === "comment") {
17076 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
17077 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
17078 if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
17079 if (value.slice(-1) === ",") {
17080 clean = false;
17081 } else {
17082 value += token[1];
17083 }
17084 } else {
17085 clean = false;
17086 }
17087 } else {
17088 value += token[1];
17089 }
17090 }
17091 if (!clean) {
17092 var raw = tokens.reduce(function(all, i2) {
17093 return all + i2[1];
17094 }, "");
17095 node2.raws[prop] = {
17096 raw: raw,
17097 value: value
17098 };
17099 }
17100 node2[prop] = value;
17101 };
17102 _proto.rule = function rule(tokens) {
17103 tokens.pop();
17104 var node2 = new Rule$2();
17105 this.init(node2, tokens[0][2]);
17106 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
17107 this.raw(node2, "selector", tokens);
17108 this.current = node2;
17109 };
17110 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
17111 var lastTokenType;
17112 var spaces = "";
17113 while(tokens.length){
17114 lastTokenType = tokens[tokens.length - 1][0];
17115 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
17116 spaces = tokens.pop()[1] + spaces;
17117 }
17118 return spaces;
17119 };
17120 // Errors
17121 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
17122 var next;
17123 var spaces = "";
17124 while(tokens.length){
17125 next = tokens[0][0];
17126 if (next !== "space" && next !== "comment") break;
17127 spaces += tokens.shift()[1];
17128 }
17129 return spaces;
17130 };
17131 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
17132 var lastTokenType;
17133 var spaces = "";
17134 while(tokens.length){
17135 lastTokenType = tokens[tokens.length - 1][0];
17136 if (lastTokenType !== "space") break;
17137 spaces = tokens.pop()[1] + spaces;
17138 }
17139 return spaces;
17140 };
17141 _proto.stringFrom = function stringFrom(tokens, from) {
17142 var result2 = "";
17143 for(var i2 = from; i2 < tokens.length; i2++){
17144 result2 += tokens[i2][1];
17145 }
17146 tokens.splice(from, tokens.length - from);
17147 return result2;
17148 };
17149 _proto.unclosedBlock = function unclosedBlock() {
17150 var pos = this.current.source.start;
17151 throw this.input.error("Unclosed block", pos.line, pos.column);
17152 };
17153 _proto.unclosedBracket = function unclosedBracket(bracket) {
17154 throw this.input.error("Unclosed bracket", {
17155 offset: bracket[2]
17156 }, {
17157 offset: bracket[2] + 1
17158 });
17159 };
17160 _proto.unexpectedClose = function unexpectedClose(token) {
17161 throw this.input.error("Unexpected }", {
17162 offset: token[2]
17163 }, {
17164 offset: token[2] + 1
17165 });
17166 };
17167 _proto.unknownWord = function unknownWord(tokens) {
17168 throw this.input.error("Unknown word", {
17169 offset: tokens[0][2]
17170 }, {
17171 offset: tokens[0][2] + tokens[0][1].length
17172 });
17173 };
17174 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
17175 throw this.input.error("At-rule without name", {
17176 offset: token[2]
17177 }, {
17178 offset: token[2] + token[1].length
17179 });
17180 };
17181 return Parser2;
17182 }();
17183 var parser = Parser$1;
17184 var Container$2 = container;
17185 var Parser22 = parser;
17186 var Input$2 = input;
17187 function parse$3(css, opts) {
17188 var input2 = new Input$2(css, opts);
17189 var parser2 = new Parser22(input2);
17190 try {
17191 parser2.parse();
17192 } catch (e2) {
17193 if (true) {
17194 if (e2.name === "CssSyntaxError" && opts && opts.from) {
17195 if (/\.scss$/i.test(opts.from)) {
17196 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
17197 } else if (/\.sass/i.test(opts.from)) {
17198 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
17199 } else if (/\.less$/i.test(opts.from)) {
17200 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
17201 }
17202 }
17203 }
17204 throw e2;
17205 }
17206 return parser2.root;
17207 }
17208 var parse_1 = parse$3;
17209 parse$3.default = parse$3;
17210 Container$2.registerParse(parse$3);
17211 var isClean = symbols.isClean, my = symbols.my;
17212 var MapGenerator$1 = mapGenerator;
17213 var stringify$2 = stringify_1;
17214 var Container$1 = container;
17215 var Document$2 = document$1$2;
17216 var warnOnce$1 = warnOnce$2;
17217 var Result$2 = result;
17218 var parse$2 = parse_1;
17219 var Root$3 = root;
17220 var TYPE_TO_CLASS_NAME = {
17221 atrule: "AtRule",
17222 comment: "Comment",
17223 decl: "Declaration",
17224 document: "Document",
17225 root: "Root",
17226 rule: "Rule"
17227 };
17228 var PLUGIN_PROPS = {
17229 AtRule: true,
17230 AtRuleExit: true,
17231 Comment: true,
17232 CommentExit: true,
17233 Declaration: true,
17234 DeclarationExit: true,
17235 Document: true,
17236 DocumentExit: true,
17237 Once: true,
17238 OnceExit: true,
17239 postcssPlugin: true,
17240 prepare: true,
17241 Root: true,
17242 RootExit: true,
17243 Rule: true,
17244 RuleExit: true
17245 };
17246 var NOT_VISITORS = {
17247 Once: true,
17248 postcssPlugin: true,
17249 prepare: true
17250 };
17251 var CHILDREN = 0;
17252 function isPromise(obj) {
17253 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
17254 }
17255 function getEvents(node2) {
17256 var key = false;
17257 var type = TYPE_TO_CLASS_NAME[node2.type];
17258 if (node2.type === "decl") {
17259 key = node2.prop.toLowerCase();
17260 } else if (node2.type === "atrule") {
17261 key = node2.name.toLowerCase();
17262 }
17263 if (key && node2.append) {
17264 return [
17265 type,
17266 type + "-" + key,
17267 CHILDREN,
17268 type + "Exit",
17269 type + "Exit-" + key
17270 ];
17271 } else if (key) {
17272 return [
17273 type,
17274 type + "-" + key,
17275 type + "Exit",
17276 type + "Exit-" + key
17277 ];
17278 } else if (node2.append) {
17279 return [
17280 type,
17281 CHILDREN,
17282 type + "Exit"
17283 ];
17284 } else {
17285 return [
17286 type,
17287 type + "Exit"
17288 ];
17289 }
17290 }
17291 function toStack(node2) {
17292 var events;
17293 if (node2.type === "document") {
17294 events = [
17295 "Document",
17296 CHILDREN,
17297 "DocumentExit"
17298 ];
17299 } else if (node2.type === "root") {
17300 events = [
17301 "Root",
17302 CHILDREN,
17303 "RootExit"
17304 ];
17305 } else {
17306 events = getEvents(node2);
17307 }
17308 return {
17309 eventIndex: 0,
17310 events: events,
17311 iterator: 0,
17312 node: node2,
17313 visitorIndex: 0,
17314 visitors: []
17315 };
17316 }
17317 function cleanMarks(node2) {
17318 node2[isClean] = false;
17319 if (node2.nodes) node2.nodes.forEach(function(i2) {
17320 return cleanMarks(i2);
17321 });
17322 return node2;
17323 }
17324 var postcss$2 = {};
17325 var LazyResult$2 = /*#__PURE__*/ function() {
17326 function LazyResult2(processor2, css, opts) {
17327 var _this = this;
17328 this.stringified = false;
17329 this.processed = false;
17330 var root2;
17331 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
17332 root2 = cleanMarks(css);
17333 } else if (_instanceof(css, LazyResult2) || _instanceof(css, Result$2)) {
17334 root2 = cleanMarks(css.root);
17335 if (css.map) {
17336 if (typeof opts.map === "undefined") opts.map = {};
17337 if (!opts.map.inline) opts.map.inline = false;
17338 opts.map.prev = css.map;
17339 }
17340 } else {
17341 var parser2 = parse$2;
17342 if (opts.syntax) parser2 = opts.syntax.parse;
17343 if (opts.parser) parser2 = opts.parser;
17344 if (parser2.parse) parser2 = parser2.parse;
17345 try {
17346 root2 = parser2(css, opts);
17347 } catch (error) {
17348 this.processed = true;
17349 this.error = error;
17350 }
17351 if (root2 && !root2[my]) {
17352 Container$1.rebuild(root2);
17353 }
17354 }
17355 this.result = new Result$2(processor2, root2, opts);
17356 this.helpers = _extends({}, postcss$2, {
17357 postcss: postcss$2,
17358 result: this.result
17359 });
17360 this.plugins = this.processor.plugins.map(function(plugin22) {
17361 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
17362 return _extends({}, plugin22, plugin22.prepare(_this.result));
17363 } else {
17364 return plugin22;
17365 }
17366 });
17367 }
17368 var _proto = LazyResult2.prototype;
17369 _proto.async = function async() {
17370 if (this.error) return Promise.reject(this.error);
17371 if (this.processed) return Promise.resolve(this.result);
17372 if (!this.processing) {
17373 this.processing = this.runAsync();
17374 }
17375 return this.processing;
17376 };
17377 _proto.catch = function _catch(onRejected) {
17378 return this.async().catch(onRejected);
17379 };
17380 _proto.finally = function _finally(onFinally) {
17381 return this.async().then(onFinally, onFinally);
17382 };
17383 _proto.getAsyncError = function getAsyncError() {
17384 throw new Error("Use process(css).then(cb) to work with async plugins");
17385 };
17386 _proto.handleError = function handleError(error, node2) {
17387 var plugin22 = this.result.lastPlugin;
17388 try {
17389 if (node2) node2.addToError(error);
17390 this.error = error;
17391 if (error.name === "CssSyntaxError" && !error.plugin) {
17392 error.plugin = plugin22.postcssPlugin;
17393 error.setMessage();
17394 } else if (plugin22.postcssVersion) {
17395 if (true) {
17396 var pluginName = plugin22.postcssPlugin;
17397 var pluginVer = plugin22.postcssVersion;
17398 var runtimeVer = this.result.processor.version;
17399 var a2 = pluginVer.split(".");
17400 var b = runtimeVer.split(".");
17401 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
17402 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.");
17403 }
17404 }
17405 }
17406 } catch (err) {
17407 if (console && console.error) console.error(err);
17408 }
17409 return error;
17410 };
17411 _proto.prepareVisitors = function prepareVisitors() {
17412 var _this = this;
17413 this.listeners = {};
17414 var add = function(plugin22, type, cb) {
17415 if (!_this.listeners[type]) _this.listeners[type] = [];
17416 _this.listeners[type].push([
17417 plugin22,
17418 cb
17419 ]);
17420 };
17421 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17422 var plugin22 = _step.value;
17423 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
17424 for(var event in plugin22){
17425 if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
17426 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
17427 }
17428 if (!NOT_VISITORS[event]) {
17429 if (_type_of(plugin22[event]) === "object") {
17430 for(var filter in plugin22[event]){
17431 if (filter === "*") {
17432 add(plugin22, event, plugin22[event][filter]);
17433 } else {
17434 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
17435 }
17436 }
17437 } else if (typeof plugin22[event] === "function") {
17438 add(plugin22, event, plugin22[event]);
17439 }
17440 }
17441 }
17442 }
17443 }
17444 this.hasListener = Object.keys(this.listeners).length > 0;
17445 };
17446 _proto.runAsync = function runAsync() {
17447 var _this = this;
17448 return _async_to_generator(function() {
17449 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
17450 return _ts_generator(this, function(_state) {
17451 switch(_state.label){
17452 case 0:
17453 _this.plugin = 0;
17454 i2 = 0;
17455 _state.label = 1;
17456 case 1:
17457 if (!(i2 < _this.plugins.length)) return [
17458 3,
17459 6
17460 ];
17461 plugin22 = _this.plugins[i2];
17462 promise = _this.runOnRoot(plugin22);
17463 if (!isPromise(promise)) return [
17464 3,
17465 5
17466 ];
17467 _state.label = 2;
17468 case 2:
17469 _state.trys.push([
17470 2,
17471 4,
17472 ,
17473 5
17474 ]);
17475 return [
17476 4,
17477 promise
17478 ];
17479 case 3:
17480 _state.sent();
17481 return [
17482 3,
17483 5
17484 ];
17485 case 4:
17486 error = _state.sent();
17487 throw _this.handleError(error);
17488 case 5:
17489 i2++;
17490 return [
17491 3,
17492 1
17493 ];
17494 case 6:
17495 _this.prepareVisitors();
17496 if (!_this.hasListener) return [
17497 3,
17498 18
17499 ];
17500 root2 = _this.result.root;
17501 _state.label = 7;
17502 case 7:
17503 if (!!root2[isClean]) return [
17504 3,
17505 14
17506 ];
17507 root2[isClean] = true;
17508 stack = [
17509 toStack(root2)
17510 ];
17511 _state.label = 8;
17512 case 8:
17513 if (!(stack.length > 0)) return [
17514 3,
17515 13
17516 ];
17517 promise1 = _this.visitTick(stack);
17518 if (!isPromise(promise1)) return [
17519 3,
17520 12
17521 ];
17522 _state.label = 9;
17523 case 9:
17524 _state.trys.push([
17525 9,
17526 11,
17527 ,
17528 12
17529 ]);
17530 return [
17531 4,
17532 promise1
17533 ];
17534 case 10:
17535 _state.sent();
17536 return [
17537 3,
17538 12
17539 ];
17540 case 11:
17541 e2 = _state.sent();
17542 node2 = stack[stack.length - 1].node;
17543 throw _this.handleError(e2, node2);
17544 case 12:
17545 return [
17546 3,
17547 8
17548 ];
17549 case 13:
17550 return [
17551 3,
17552 7
17553 ];
17554 case 14:
17555 if (!_this.listeners.OnceExit) return [
17556 3,
17557 18
17558 ];
17559 _loop = function() {
17560 var _step_value, plugin22, visitor, roots, e2;
17561 return _ts_generator(this, function(_state) {
17562 switch(_state.label){
17563 case 0:
17564 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
17565 _this.result.lastPlugin = plugin22;
17566 _state.label = 1;
17567 case 1:
17568 _state.trys.push([
17569 1,
17570 6,
17571 ,
17572 7
17573 ]);
17574 if (!(root2.type === "document")) return [
17575 3,
17576 3
17577 ];
17578 roots = root2.nodes.map(function(subRoot) {
17579 return visitor(subRoot, _this.helpers);
17580 });
17581 return [
17582 4,
17583 Promise.all(roots)
17584 ];
17585 case 2:
17586 _state.sent();
17587 return [
17588 3,
17589 5
17590 ];
17591 case 3:
17592 return [
17593 4,
17594 visitor(root2, _this.helpers)
17595 ];
17596 case 4:
17597 _state.sent();
17598 _state.label = 5;
17599 case 5:
17600 return [
17601 3,
17602 7
17603 ];
17604 case 6:
17605 e2 = _state.sent();
17606 throw _this.handleError(e2);
17607 case 7:
17608 return [
17609 2
17610 ];
17611 }
17612 });
17613 };
17614 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
17615 _state.label = 15;
17616 case 15:
17617 if (!!(_step = _iterator()).done) return [
17618 3,
17619 18
17620 ];
17621 return [
17622 5,
17623 _ts_values(_loop())
17624 ];
17625 case 16:
17626 _state.sent();
17627 _state.label = 17;
17628 case 17:
17629 return [
17630 3,
17631 15
17632 ];
17633 case 18:
17634 _this.processed = true;
17635 return [
17636 2,
17637 _this.stringify()
17638 ];
17639 }
17640 });
17641 })();
17642 };
17643 _proto.runOnRoot = function runOnRoot(plugin22) {
17644 var _this = this;
17645 this.result.lastPlugin = plugin22;
17646 try {
17647 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
17648 if (this.result.root.type === "document") {
17649 var roots = this.result.root.nodes.map(function(root2) {
17650 return plugin22.Once(root2, _this.helpers);
17651 });
17652 if (isPromise(roots[0])) {
17653 return Promise.all(roots);
17654 }
17655 return roots;
17656 }
17657 return plugin22.Once(this.result.root, this.helpers);
17658 } else if (typeof plugin22 === "function") {
17659 return plugin22(this.result.root, this.result);
17660 }
17661 } catch (error) {
17662 throw this.handleError(error);
17663 }
17664 };
17665 _proto.stringify = function stringify() {
17666 if (this.error) throw this.error;
17667 if (this.stringified) return this.result;
17668 this.stringified = true;
17669 this.sync();
17670 var opts = this.result.opts;
17671 var str = stringify$2;
17672 if (opts.syntax) str = opts.syntax.stringify;
17673 if (opts.stringifier) str = opts.stringifier;
17674 if (str.stringify) str = str.stringify;
17675 var map = new MapGenerator$1(str, this.result.root, this.result.opts);
17676 var data = map.generate();
17677 this.result.css = data[0];
17678 this.result.map = data[1];
17679 return this.result;
17680 };
17681 _proto.sync = function sync() {
17682 if (this.error) throw this.error;
17683 if (this.processed) return this.result;
17684 this.processed = true;
17685 if (this.processing) {
17686 throw this.getAsyncError();
17687 }
17688 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17689 var plugin22 = _step.value;
17690 var promise = this.runOnRoot(plugin22);
17691 if (isPromise(promise)) {
17692 throw this.getAsyncError();
17693 }
17694 }
17695 this.prepareVisitors();
17696 if (this.hasListener) {
17697 var root2 = this.result.root;
17698 while(!root2[isClean]){
17699 root2[isClean] = true;
17700 this.walkSync(root2);
17701 }
17702 if (this.listeners.OnceExit) {
17703 if (root2.type === "document") {
17704 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
17705 var subRoot = _step1.value;
17706 this.visitSync(this.listeners.OnceExit, subRoot);
17707 }
17708 } else {
17709 this.visitSync(this.listeners.OnceExit, root2);
17710 }
17711 }
17712 }
17713 return this.result;
17714 };
17715 _proto.then = function then(onFulfilled, onRejected) {
17716 if (true) {
17717 if (!("from" in this.opts)) {
17718 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.");
17719 }
17720 }
17721 return this.async().then(onFulfilled, onRejected);
17722 };
17723 _proto.toString = function toString() {
17724 return this.css;
17725 };
17726 _proto.visitSync = function visitSync(visitors, node2) {
17727 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
17728 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
17729 this.result.lastPlugin = plugin22;
17730 var promise = void 0;
17731 try {
17732 promise = visitor(node2, this.helpers);
17733 } catch (e2) {
17734 throw this.handleError(e2, node2.proxyOf);
17735 }
17736 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
17737 return true;
17738 }
17739 if (isPromise(promise)) {
17740 throw this.getAsyncError();
17741 }
17742 }
17743 };
17744 _proto.visitTick = function visitTick(stack) {
17745 var visit2 = stack[stack.length - 1];
17746 var node2 = visit2.node, visitors = visit2.visitors;
17747 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
17748 stack.pop();
17749 return;
17750 }
17751 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
17752 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
17753 visit2.visitorIndex += 1;
17754 if (visit2.visitorIndex === visitors.length) {
17755 visit2.visitors = [];
17756 visit2.visitorIndex = 0;
17757 }
17758 this.result.lastPlugin = plugin22;
17759 try {
17760 return visitor(node2.toProxy(), this.helpers);
17761 } catch (e2) {
17762 throw this.handleError(e2, node2);
17763 }
17764 }
17765 if (visit2.iterator !== 0) {
17766 var iterator = visit2.iterator;
17767 var child;
17768 while(child = node2.nodes[node2.indexes[iterator]]){
17769 node2.indexes[iterator] += 1;
17770 if (!child[isClean]) {
17771 child[isClean] = true;
17772 stack.push(toStack(child));
17773 return;
17774 }
17775 }
17776 visit2.iterator = 0;
17777 delete node2.indexes[iterator];
17778 }
17779 var events = visit2.events;
17780 while(visit2.eventIndex < events.length){
17781 var event = events[visit2.eventIndex];
17782 visit2.eventIndex += 1;
17783 if (event === CHILDREN) {
17784 if (node2.nodes && node2.nodes.length) {
17785 node2[isClean] = true;
17786 visit2.iterator = node2.getIterator();
17787 }
17788 return;
17789 } else if (this.listeners[event]) {
17790 visit2.visitors = this.listeners[event];
17791 return;
17792 }
17793 }
17794 stack.pop();
17795 };
17796 _proto.walkSync = function walkSync(node2) {
17797 var _this = this;
17798 node2[isClean] = true;
17799 var events = getEvents(node2);
17800 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
17801 var event = _step.value;
17802 if (event === CHILDREN) {
17803 if (node2.nodes) {
17804 node2.each(function(child) {
17805 if (!child[isClean]) _this.walkSync(child);
17806 });
17807 }
17808 } else {
17809 var visitors = this.listeners[event];
17810 if (visitors) {
17811 if (this.visitSync(visitors, node2.toProxy())) return;
17812 }
17813 }
17814 }
17815 };
17816 _proto.warnings = function warnings() {
17817 return this.sync().warnings();
17818 };
17819 _create_class(LazyResult2, [
17820 {
17821 key: "content",
17822 get: function get() {
17823 return this.stringify().content;
17824 }
17825 },
17826 {
17827 key: "css",
17828 get: function get() {
17829 return this.stringify().css;
17830 }
17831 },
17832 {
17833 key: "map",
17834 get: function get() {
17835 return this.stringify().map;
17836 }
17837 },
17838 {
17839 key: "messages",
17840 get: function get() {
17841 return this.sync().messages;
17842 }
17843 },
17844 {
17845 key: "opts",
17846 get: function get() {
17847 return this.result.opts;
17848 }
17849 },
17850 {
17851 key: "processor",
17852 get: function get() {
17853 return this.result.processor;
17854 }
17855 },
17856 {
17857 key: "root",
17858 get: function get() {
17859 return this.sync().root;
17860 }
17861 },
17862 {
17863 key: Symbol.toStringTag,
17864 get: function get() {
17865 return "LazyResult";
17866 }
17867 }
17868 ]);
17869 return LazyResult2;
17870 }();
17871 LazyResult$2.registerPostcss = function(dependant) {
17872 postcss$2 = dependant;
17873 };
17874 var lazyResult = LazyResult$2;
17875 LazyResult$2.default = LazyResult$2;
17876 Root$3.registerLazyResult(LazyResult$2);
17877 Document$2.registerLazyResult(LazyResult$2);
17878 var MapGenerator22 = mapGenerator;
17879 var stringify$1 = stringify_1;
17880 var warnOnce22 = warnOnce$2;
17881 var parse$1 = parse_1;
17882 var Result$1 = result;
17883 var NoWorkResult$1 = /*#__PURE__*/ function() {
17884 function NoWorkResult2(processor2, css, opts) {
17885 css = css.toString();
17886 this.stringified = false;
17887 this._processor = processor2;
17888 this._css = css;
17889 this._opts = opts;
17890 this._map = void 0;
17891 var root2;
17892 var str = stringify$1;
17893 this.result = new Result$1(this._processor, root2, this._opts);
17894 this.result.css = css;
17895 var self = this;
17896 Object.defineProperty(this.result, "root", {
17897 get: function get() {
17898 return self.root;
17899 }
17900 });
17901 var map = new MapGenerator22(str, root2, this._opts, css);
17902 if (map.isMap()) {
17903 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
17904 if (generatedCSS) {
17905 this.result.css = generatedCSS;
17906 }
17907 if (generatedMap) {
17908 this.result.map = generatedMap;
17909 }
17910 } else {
17911 map.clearAnnotation();
17912 this.result.css = map.css;
17913 }
17914 }
17915 var _proto = NoWorkResult2.prototype;
17916 _proto.async = function async() {
17917 if (this.error) return Promise.reject(this.error);
17918 return Promise.resolve(this.result);
17919 };
17920 _proto.catch = function _catch(onRejected) {
17921 return this.async().catch(onRejected);
17922 };
17923 _proto.finally = function _finally(onFinally) {
17924 return this.async().then(onFinally, onFinally);
17925 };
17926 _proto.sync = function sync() {
17927 if (this.error) throw this.error;
17928 return this.result;
17929 };
17930 _proto.then = function then(onFulfilled, onRejected) {
17931 if (true) {
17932 if (!("from" in this._opts)) {
17933 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.");
17934 }
17935 }
17936 return this.async().then(onFulfilled, onRejected);
17937 };
17938 _proto.toString = function toString() {
17939 return this._css;
17940 };
17941 _proto.warnings = function warnings() {
17942 return [];
17943 };
17944 _create_class(NoWorkResult2, [
17945 {
17946 key: "content",
17947 get: function get() {
17948 return this.result.css;
17949 }
17950 },
17951 {
17952 key: "css",
17953 get: function get() {
17954 return this.result.css;
17955 }
17956 },
17957 {
17958 key: "map",
17959 get: function get() {
17960 return this.result.map;
17961 }
17962 },
17963 {
17964 key: "messages",
17965 get: function get() {
17966 return [];
17967 }
17968 },
17969 {
17970 key: "opts",
17971 get: function get() {
17972 return this.result.opts;
17973 }
17974 },
17975 {
17976 key: "processor",
17977 get: function get() {
17978 return this.result.processor;
17979 }
17980 },
17981 {
17982 key: "root",
17983 get: function get() {
17984 if (this._root) {
17985 return this._root;
17986 }
17987 var root2;
17988 var parser2 = parse$1;
17989 try {
17990 root2 = parser2(this._css, this._opts);
17991 } catch (error) {
17992 this.error = error;
17993 }
17994 if (this.error) {
17995 throw this.error;
17996 } else {
17997 this._root = root2;
17998 return root2;
17999 }
18000 }
18001 },
18002 {
18003 key: Symbol.toStringTag,
18004 get: function get() {
18005 return "NoWorkResult";
18006 }
18007 }
18008 ]);
18009 return NoWorkResult2;
18010 }();
18011 var noWorkResult = NoWorkResult$1;
18012 NoWorkResult$1.default = NoWorkResult$1;
18013 var NoWorkResult22 = noWorkResult;
18014 var LazyResult$1 = lazyResult;
18015 var Document$1 = document$1$2;
18016 var Root$2 = root;
18017 var Processor$1 = /*#__PURE__*/ function() {
18018 function Processor2(plugins) {
18019 if (plugins === void 0) plugins = [];
18020 this.version = "8.4.38";
18021 this.plugins = this.normalize(plugins);
18022 }
18023 var _proto = Processor2.prototype;
18024 _proto.normalize = function normalize(plugins) {
18025 var normalized = [];
18026 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
18027 var i2 = _step.value;
18028 if (i2.postcss === true) {
18029 i2 = i2();
18030 } else if (i2.postcss) {
18031 i2 = i2.postcss;
18032 }
18033 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
18034 normalized = normalized.concat(i2.plugins);
18035 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
18036 normalized.push(i2);
18037 } else if (typeof i2 === "function") {
18038 normalized.push(i2);
18039 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
18040 if (true) {
18041 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.");
18042 }
18043 } else {
18044 throw new Error(i2 + " is not a PostCSS plugin");
18045 }
18046 }
18047 return normalized;
18048 };
18049 _proto.process = function process1(css, opts) {
18050 if (opts === void 0) opts = {};
18051 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
18052 return new NoWorkResult22(this, css, opts);
18053 } else {
18054 return new LazyResult$1(this, css, opts);
18055 }
18056 };
18057 _proto.use = function use(plugin22) {
18058 this.plugins = this.plugins.concat(this.normalize([
18059 plugin22
18060 ]));
18061 return this;
18062 };
18063 return Processor2;
18064 }();
18065 var processor = Processor$1;
18066 Processor$1.default = Processor$1;
18067 Root$2.registerProcessor(Processor$1);
18068 Document$1.registerProcessor(Processor$1);
18069 var Declaration$1 = declaration;
18070 var PreviousMap22 = previousMap;
18071 var Comment$1 = comment;
18072 var AtRule$1 = atRule;
18073 var Input$1 = input;
18074 var Root$1 = root;
18075 var Rule$1 = rule;
18076 function fromJSON$1(json, inputs) {
18077 if (Array.isArray(json)) return json.map(function(n2) {
18078 return fromJSON$1(n2);
18079 });
18080 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
18081 "inputs"
18082 ]);
18083 if (ownInputs) {
18084 inputs = [];
18085 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
18086 var input2 = _step.value;
18087 var inputHydrated = _extends({}, input2, {
18088 __proto__: Input$1.prototype
18089 });
18090 if (inputHydrated.map) {
18091 inputHydrated.map = _extends({}, inputHydrated.map, {
18092 __proto__: PreviousMap22.prototype
18093 });
18094 }
18095 inputs.push(inputHydrated);
18096 }
18097 }
18098 if (defaults.nodes) {
18099 defaults.nodes = json.nodes.map(function(n2) {
18100 return fromJSON$1(n2, inputs);
18101 });
18102 }
18103 if (defaults.source) {
18104 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
18105 "inputId"
18106 ]);
18107 defaults.source = source;
18108 if (inputId != null) {
18109 defaults.source.input = inputs[inputId];
18110 }
18111 }
18112 if (defaults.type === "root") {
18113 return new Root$1(defaults);
18114 } else if (defaults.type === "decl") {
18115 return new Declaration$1(defaults);
18116 } else if (defaults.type === "rule") {
18117 return new Rule$1(defaults);
18118 } else if (defaults.type === "comment") {
18119 return new Comment$1(defaults);
18120 } else if (defaults.type === "atrule") {
18121 return new AtRule$1(defaults);
18122 } else {
18123 throw new Error("Unknown node type: " + json.type);
18124 }
18125 }
18126 var fromJSON_1 = fromJSON$1;
18127 fromJSON$1.default = fromJSON$1;
18128 var CssSyntaxError22 = cssSyntaxError;
18129 var Declaration22 = declaration;
18130 var LazyResult22 = lazyResult;
18131 var Container22 = container;
18132 var Processor22 = processor;
18133 var stringify = stringify_1;
18134 var fromJSON = fromJSON_1;
18135 var Document222 = document$1$2;
18136 var Warning22 = warning;
18137 var Comment22 = comment;
18138 var AtRule22 = atRule;
18139 var Result22 = result;
18140 var Input22 = input;
18141 var parse = parse_1;
18142 var list = list_1;
18143 var Rule22 = rule;
18144 var Root22 = root;
18145 var Node22 = node;
18146 function postcss() {
18147 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
18148 plugins[_key] = arguments[_key];
18149 }
18150 if (plugins.length === 1 && Array.isArray(plugins[0])) {
18151 plugins = plugins[0];
18152 }
18153 return new Processor22(plugins);
18154 }
18155 postcss.plugin = function plugin2(name, initializer) {
18156 var warningPrinted = false;
18157 function creator() {
18158 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18159 args[_key] = arguments[_key];
18160 }
18161 if (console && console.warn && !warningPrinted) {
18162 warningPrinted = true;
18163 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
18164 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
18165 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
18166 }
18167 }
18168 var transformer = initializer.apply(void 0, [].concat(args));
18169 transformer.postcssPlugin = name;
18170 transformer.postcssVersion = new Processor22().version;
18171 return transformer;
18172 }
18173 var cache;
18174 Object.defineProperty(creator, "postcss", {
18175 get: function get() {
18176 if (!cache) cache = creator();
18177 return cache;
18178 }
18179 });
18180 creator.process = function(css, processOpts, pluginOpts) {
18181 return postcss([
18182 creator(pluginOpts)
18183 ]).process(css, processOpts);
18184 };
18185 return creator;
18186 };
18187 postcss.stringify = stringify;
18188 postcss.parse = parse;
18189 postcss.fromJSON = fromJSON;
18190 postcss.list = list;
18191 postcss.comment = function(defaults) {
18192 return new Comment22(defaults);
18193 };
18194 postcss.atRule = function(defaults) {
18195 return new AtRule22(defaults);
18196 };
18197 postcss.decl = function(defaults) {
18198 return new Declaration22(defaults);
18199 };
18200 postcss.rule = function(defaults) {
18201 return new Rule22(defaults);
18202 };
18203 postcss.root = function(defaults) {
18204 return new Root22(defaults);
18205 };
18206 postcss.document = function(defaults) {
18207 return new Document222(defaults);
18208 };
18209 postcss.CssSyntaxError = CssSyntaxError22;
18210 postcss.Declaration = Declaration22;
18211 postcss.Container = Container22;
18212 postcss.Processor = Processor22;
18213 postcss.Document = Document222;
18214 postcss.Comment = Comment22;
18215 postcss.Warning = Warning22;
18216 postcss.AtRule = AtRule22;
18217 postcss.Result = Result22;
18218 postcss.Input = Input22;
18219 postcss.Rule = Rule22;
18220 postcss.Root = Root22;
18221 postcss.Node = Node22;
18222 LazyResult22.registerPostcss(postcss);
18223 var postcss_1 = postcss;
18224 postcss.default = postcss;
18225 var postcss$1 = /* @__PURE__ */ getDefaultExportFromCjs(postcss_1);
18226 postcss$1.stringify;
18227 postcss$1.fromJSON;
18228 postcss$1.plugin;
18229 postcss$1.parse;
18230 postcss$1.list;
18231 postcss$1.document;
18232 postcss$1.comment;
18233 postcss$1.atRule;
18234 postcss$1.rule;
18235 postcss$1.decl;
18236 postcss$1.root;
18237 postcss$1.CssSyntaxError;
18238 postcss$1.Declaration;
18239 postcss$1.Container;
18240 postcss$1.Processor;
18241 postcss$1.Document;
18242 postcss$1.Comment;
18243 postcss$1.Warning;
18244 postcss$1.AtRule;
18245 postcss$1.Result;
18246 postcss$1.Input;
18247 postcss$1.Rule;
18248 postcss$1.Root;
18249 postcss$1.Node;
18250 var BaseRRNode = /*#__PURE__*/ function() {
18251 function BaseRRNode() {
18252 for(var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++){
18253 _args[_key] = arguments[_key];
18254 }
18255 __publicField2(this, "parentElement", null);
18256 __publicField2(this, "parentNode", null);
18257 __publicField2(this, "ownerDocument");
18258 __publicField2(this, "firstChild", null);
18259 __publicField2(this, "lastChild", null);
18260 __publicField2(this, "previousSibling", null);
18261 __publicField2(this, "nextSibling", null);
18262 __publicField2(this, "ELEMENT_NODE", 1);
18263 __publicField2(this, "TEXT_NODE", 3);
18264 __publicField2(this, "nodeType");
18265 __publicField2(this, "nodeName");
18266 __publicField2(this, "RRNodeType");
18267 }
18268 var _proto = BaseRRNode.prototype;
18269 _proto.contains = function contains(node2) {
18270 if (!_instanceof(node2, BaseRRNode)) return false;
18271 else if (node2.ownerDocument !== this.ownerDocument) return false;
18272 else if (node2 === this) return true;
18273 while(node2.parentNode){
18274 if (node2.parentNode === this) return true;
18275 node2 = node2.parentNode;
18276 }
18277 return false;
18278 };
18279 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18280 _proto.appendChild = function appendChild(_newChild) {
18281 throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.");
18282 };
18283 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18284 _proto.insertBefore = function insertBefore(_newChild, _refChild) {
18285 throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.");
18286 };
18287 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18288 _proto.removeChild = function removeChild(_node) {
18289 throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.");
18290 };
18291 _proto.toString = function toString() {
18292 return "RRNode";
18293 };
18294 _create_class(BaseRRNode, [
18295 {
18296 key: "childNodes",
18297 get: function get() {
18298 var childNodes2 = [];
18299 var childIterator = this.firstChild;
18300 while(childIterator){
18301 childNodes2.push(childIterator);
18302 childIterator = childIterator.nextSibling;
18303 }
18304 return childNodes2;
18305 }
18306 }
18307 ]);
18308 return BaseRRNode;
18309 }();
18310 var testableAccessors = {
18311 Node: [
18312 "childNodes",
18313 "parentNode",
18314 "parentElement",
18315 "textContent"
18316 ],
18317 ShadowRoot: [
18318 "host",
18319 "styleSheets"
18320 ],
18321 Element: [
18322 "shadowRoot",
18323 "querySelector",
18324 "querySelectorAll"
18325 ],
18326 MutationObserver: []
18327 };
18328 var testableMethods = {
18329 Node: [
18330 "contains",
18331 "getRootNode"
18332 ],
18333 ShadowRoot: [
18334 "getSelection"
18335 ],
18336 Element: [],
18337 MutationObserver: [
18338 "constructor"
18339 ]
18340 };
18341 var untaintedBasePrototype = {};
18342 var isAngularZonePresent = function() {
18343 return !!globalThis.Zone;
18344 };
18345 function getUntaintedPrototype(key) {
18346 if (untaintedBasePrototype[key]) return untaintedBasePrototype[key];
18347 var defaultObj = globalThis[key];
18348 var defaultPrototype = defaultObj.prototype;
18349 var accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
18350 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
18351 accessorNames.every(function(accessor) {
18352 var _a2, _b;
18353 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
18354 }));
18355 var methodNames = key in testableMethods ? testableMethods[key] : void 0;
18356 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
18357 function(method) {
18358 var _a2;
18359 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
18360 }));
18361 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {
18362 untaintedBasePrototype[key] = defaultObj.prototype;
18363 return defaultObj.prototype;
18364 }
18365 try {
18366 var iframeEl = document.createElement("iframe");
18367 document.body.appendChild(iframeEl);
18368 var win = iframeEl.contentWindow;
18369 if (!win) return defaultObj.prototype;
18370 var untaintedObject = win[key].prototype;
18371 document.body.removeChild(iframeEl);
18372 if (!untaintedObject) return defaultPrototype;
18373 return untaintedBasePrototype[key] = untaintedObject;
18374 } catch (e) {
18375 return defaultPrototype;
18376 }
18377 }
18378 var untaintedAccessorCache = {};
18379 function getUntaintedAccessor(key, instance, accessor) {
18380 var _a2;
18381 var cacheKey = key + "." + String(accessor);
18382 if (untaintedAccessorCache[cacheKey]) return untaintedAccessorCache[cacheKey].call(instance);
18383 var untaintedPrototype = getUntaintedPrototype(key);
18384 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
18385 if (!untaintedAccessor) return instance[accessor];
18386 untaintedAccessorCache[cacheKey] = untaintedAccessor;
18387 return untaintedAccessor.call(instance);
18388 }
18389 var untaintedMethodCache = {};
18390 function getUntaintedMethod(key, instance, method) {
18391 var cacheKey = key + "." + String(method);
18392 if (untaintedMethodCache[cacheKey]) return untaintedMethodCache[cacheKey].bind(instance);
18393 var untaintedPrototype = getUntaintedPrototype(key);
18394 var untaintedMethod = untaintedPrototype[method];
18395 if (typeof untaintedMethod !== "function") return instance[method];
18396 untaintedMethodCache[cacheKey] = untaintedMethod;
18397 return untaintedMethod.bind(instance);
18398 }
18399 function childNodes(n2) {
18400 return getUntaintedAccessor("Node", n2, "childNodes");
18401 }
18402 function parentNode(n2) {
18403 return getUntaintedAccessor("Node", n2, "parentNode");
18404 }
18405 function parentElement(n2) {
18406 return getUntaintedAccessor("Node", n2, "parentElement");
18407 }
18408 function textContent(n2) {
18409 return getUntaintedAccessor("Node", n2, "textContent");
18410 }
18411 function contains(n2, other) {
18412 return getUntaintedMethod("Node", n2, "contains")(other);
18413 }
18414 function getRootNode(n2) {
18415 return getUntaintedMethod("Node", n2, "getRootNode")();
18416 }
18417 function host(n2) {
18418 if (!n2 || !("host" in n2)) return null;
18419 return getUntaintedAccessor("ShadowRoot", n2, "host");
18420 }
18421 function styleSheets(n2) {
18422 return n2.styleSheets;
18423 }
18424 function shadowRoot(n2) {
18425 if (!n2 || !("shadowRoot" in n2)) return null;
18426 return getUntaintedAccessor("Element", n2, "shadowRoot");
18427 }
18428 function querySelector(n2, selectors) {
18429 return getUntaintedAccessor("Element", n2, "querySelector")(selectors);
18430 }
18431 function querySelectorAll(n2, selectors) {
18432 return getUntaintedAccessor("Element", n2, "querySelectorAll")(selectors);
18433 }
18434 function mutationObserverCtor() {
18435 return getUntaintedPrototype("MutationObserver").constructor;
18436 }
18437 function patch(source, name, replacement) {
18438 try {
18439 if (!(name in source)) {
18440 return function() {};
18441 }
18442 var original = source[name];
18443 var wrapped = replacement(original);
18444 if (typeof wrapped === "function") {
18445 wrapped.prototype = wrapped.prototype || {};
18446 Object.defineProperties(wrapped, {
18447 __rrweb_original__: {
18448 enumerable: false,
18449 value: original
18450 }
18451 });
18452 }
18453 source[name] = wrapped;
18454 return function() {
18455 source[name] = original;
18456 };
18457 } catch (e) {
18458 return function() {};
18459 }
18460 }
18461 var index = {
18462 childNodes: childNodes,
18463 parentNode: parentNode,
18464 parentElement: parentElement,
18465 textContent: textContent,
18466 contains: contains,
18467 getRootNode: getRootNode,
18468 host: host,
18469 styleSheets: styleSheets,
18470 shadowRoot: shadowRoot,
18471 querySelector: querySelector,
18472 querySelectorAll: querySelectorAll,
18473 mutationObserver: mutationObserverCtor,
18474 patch: patch
18475 };
18476 function on(type, fn, target) {
18477 if (target === void 0) target = document;
18478 var options = {
18479 capture: true,
18480 passive: true
18481 };
18482 target.addEventListener(type, fn, options);
18483 return function() {
18484 return target.removeEventListener(type, fn, options);
18485 };
18486 }
18487 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.";
18488 var _mirror = {
18489 map: {},
18490 getId: function getId() {
18491 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18492 return -1;
18493 },
18494 getNode: function getNode() {
18495 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18496 return null;
18497 },
18498 removeNodeFromMap: function removeNodeFromMap() {
18499 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18500 },
18501 has: function has() {
18502 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18503 return false;
18504 },
18505 reset: function reset() {
18506 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18507 }
18508 };
18509 if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
18510 _mirror = new Proxy(_mirror, {
18511 get: function get(target, prop, receiver) {
18512 if (prop === "map") {
18513 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18514 }
18515 return Reflect.get(target, prop, receiver);
18516 }
18517 });
18518 }
18519 function throttle(func, wait, options) {
18520 if (options === void 0) options = {};
18521 var timeout = null;
18522 var previous = 0;
18523 return function() {
18524 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18525 args[_key] = arguments[_key];
18526 }
18527 var now = Date.now();
18528 if (!previous && options.leading === false) {
18529 previous = now;
18530 }
18531 var remaining = wait - (now - previous);
18532 var context = this;
18533 if (remaining <= 0 || remaining > wait) {
18534 if (timeout) {
18535 clearTimeout(timeout);
18536 timeout = null;
18537 }
18538 previous = now;
18539 func.apply(context, args);
18540 } else if (!timeout && options.trailing !== false) {
18541 timeout = setTimeout(function() {
18542 previous = options.leading === false ? 0 : Date.now();
18543 timeout = null;
18544 func.apply(context, args);
18545 }, remaining);
18546 }
18547 };
18548 }
18549 function hookSetter(target, key, d, isRevoked, win) {
18550 if (win === void 0) win = window;
18551 var original = win.Object.getOwnPropertyDescriptor(target, key);
18552 win.Object.defineProperty(target, key, isRevoked ? d : {
18553 set: function set(value) {
18554 var _this = this;
18555 setTimeout(function() {
18556 d.set.call(_this, value);
18557 }, 0);
18558 if (original && original.set) {
18559 original.set.call(this, value);
18560 }
18561 }
18562 });
18563 return function() {
18564 return hookSetter(target, key, original || {}, true);
18565 };
18566 }
18567 var nowTimestamp = Date.now;
18568 if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
18569 nowTimestamp = function() {
18570 return /* @__PURE__ */ new Date().getTime();
18571 };
18572 }
18573 function getWindowScroll(win) {
18574 var _a2, _b, _c, _d;
18575 var doc = win.document;
18576 return {
18577 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,
18578 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
18579 };
18580 }
18581 function getWindowHeight() {
18582 return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
18583 }
18584 function getWindowWidth() {
18585 return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
18586 }
18587 function closestElementOfNode(node2) {
18588 if (!node2) {
18589 return null;
18590 }
18591 var el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index.parentElement(node2);
18592 return el;
18593 }
18594 function isBlocked(node2, blockClass, blockSelector, checkAncestors) {
18595 if (!node2) {
18596 return false;
18597 }
18598 var el = closestElementOfNode(node2);
18599 if (!el) {
18600 return false;
18601 }
18602 try {
18603 if (typeof blockClass === "string") {
18604 if (el.classList.contains(blockClass)) return true;
18605 if (checkAncestors && el.closest("." + blockClass) !== null) return true;
18606 } else {
18607 if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
18608 }
18609 } catch (e2) {}
18610 if (blockSelector) {
18611 if (el.matches(blockSelector)) return true;
18612 if (checkAncestors && el.closest(blockSelector) !== null) return true;
18613 }
18614 return false;
18615 }
18616 function isSerialized(n2, mirror2) {
18617 return mirror2.getId(n2) !== -1;
18618 }
18619 function isIgnored(n2, mirror2, slimDOMOptions) {
18620 if (n2.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
18621 return true;
18622 }
18623 return mirror2.getId(n2) === IGNORED_NODE;
18624 }
18625 function isAncestorRemoved(target, mirror2) {
18626 if (isShadowRoot(target)) {
18627 return false;
18628 }
18629 var id = mirror2.getId(target);
18630 if (!mirror2.has(id)) {
18631 return true;
18632 }
18633 var parent = index.parentNode(target);
18634 if (parent && parent.nodeType === target.DOCUMENT_NODE) {
18635 return false;
18636 }
18637 if (!parent) {
18638 return true;
18639 }
18640 return isAncestorRemoved(parent, mirror2);
18641 }
18642 function legacy_isTouchEvent(event) {
18643 return Boolean(event.changedTouches);
18644 }
18645 function polyfill$1(win) {
18646 if (win === void 0) win = window;
18647 if ("NodeList" in win && !win.NodeList.prototype.forEach) {
18648 win.NodeList.prototype.forEach = Array.prototype.forEach;
18649 }
18650 if ("DOMTokenList" in win && !win.DOMTokenList.prototype.forEach) {
18651 win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
18652 }
18653 }
18654 function isSerializedIframe(n2, mirror2) {
18655 return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
18656 }
18657 function isSerializedStylesheet(n2, mirror2) {
18658 return Boolean(n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2));
18659 }
18660 function hasShadowRoot(n2) {
18661 if (!n2) return false;
18662 if (_instanceof(n2, BaseRRNode) && "shadowRoot" in n2) {
18663 return Boolean(n2.shadowRoot);
18664 }
18665 return Boolean(index.shadowRoot(n2));
18666 }
18667 var StyleSheetMirror = /*#__PURE__*/ function() {
18668 function StyleSheetMirror() {
18669 __publicField(this, "id", 1);
18670 __publicField(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
18671 __publicField(this, "idStyleMap", /* @__PURE__ */ new Map());
18672 }
18673 var _proto = StyleSheetMirror.prototype;
18674 _proto.getId = function getId(stylesheet) {
18675 var _this_styleIDMap_get;
18676 return (_this_styleIDMap_get = this.styleIDMap.get(stylesheet)) != null ? _this_styleIDMap_get : -1;
18677 };
18678 _proto.has = function has(stylesheet) {
18679 return this.styleIDMap.has(stylesheet);
18680 };
18681 /**
18682 * @returns If the stylesheet is in the mirror, returns the id of the stylesheet. If not, return the new assigned id.
18683 */ _proto.add = function add(stylesheet, id) {
18684 if (this.has(stylesheet)) return this.getId(stylesheet);
18685 var newId;
18686 if (id === void 0) {
18687 newId = this.id++;
18688 } else newId = id;
18689 this.styleIDMap.set(stylesheet, newId);
18690 this.idStyleMap.set(newId, stylesheet);
18691 return newId;
18692 };
18693 _proto.getStyle = function getStyle(id) {
18694 return this.idStyleMap.get(id) || null;
18695 };
18696 _proto.reset = function reset() {
18697 this.styleIDMap = /* @__PURE__ */ new WeakMap();
18698 this.idStyleMap = /* @__PURE__ */ new Map();
18699 this.id = 1;
18700 };
18701 _proto.generateId = function generateId() {
18702 return this.id++;
18703 };
18704 return StyleSheetMirror;
18705 }();
18706 function getShadowHost(n2) {
18707 var _a2;
18708 var shadowHost = null;
18709 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));
18710 return shadowHost;
18711 }
18712 function getRootShadowHost(n2) {
18713 var rootShadowHost = n2;
18714 var shadowHost;
18715 while(shadowHost = getShadowHost(rootShadowHost))rootShadowHost = shadowHost;
18716 return rootShadowHost;
18717 }
18718 function shadowHostInDom(n2) {
18719 var doc = n2.ownerDocument;
18720 if (!doc) return false;
18721 var shadowHost = getRootShadowHost(n2);
18722 return index.contains(doc, shadowHost);
18723 }
18724 function inDom(n2) {
18725 var doc = n2.ownerDocument;
18726 if (!doc) return false;
18727 return index.contains(doc, n2) || shadowHostInDom(n2);
18728 }
18729 var EventType = /* @__PURE__ */ function(EventType2) {
18730 EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
18731 EventType2[EventType2["Load"] = 1] = "Load";
18732 EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
18733 EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
18734 EventType2[EventType2["Meta"] = 4] = "Meta";
18735 EventType2[EventType2["Custom"] = 5] = "Custom";
18736 EventType2[EventType2["Plugin"] = 6] = "Plugin";
18737 return EventType2;
18738 }(EventType || {});
18739 var IncrementalSource = /* @__PURE__ */ function(IncrementalSource2) {
18740 IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
18741 IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
18742 IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
18743 IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
18744 IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
18745 IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
18746 IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
18747 IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
18748 IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
18749 IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
18750 IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
18751 IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
18752 IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
18753 IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
18754 IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
18755 IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
18756 IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
18757 return IncrementalSource2;
18758 }(IncrementalSource || {});
18759 var MouseInteractions = /* @__PURE__ */ function(MouseInteractions2) {
18760 MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
18761 MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
18762 MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
18763 MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
18764 MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
18765 MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
18766 MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
18767 MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
18768 MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
18769 MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
18770 MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
18771 return MouseInteractions2;
18772 }(MouseInteractions || {});
18773 var PointerTypes = /* @__PURE__ */ function(PointerTypes2) {
18774 PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
18775 PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
18776 PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
18777 return PointerTypes2;
18778 }(PointerTypes || {});
18779 var CanvasContext = /* @__PURE__ */ function(CanvasContext2) {
18780 CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
18781 CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
18782 CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
18783 return CanvasContext2;
18784 }(CanvasContext || {});
18785 var MediaInteractions = /* @__PURE__ */ function(MediaInteractions2) {
18786 MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
18787 MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
18788 MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
18789 MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
18790 MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
18791 return MediaInteractions2;
18792 }(MediaInteractions || {});
18793 var NodeType = /* @__PURE__ */ function(NodeType2) {
18794 NodeType2[NodeType2["Document"] = 0] = "Document";
18795 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
18796 NodeType2[NodeType2["Element"] = 2] = "Element";
18797 NodeType2[NodeType2["Text"] = 3] = "Text";
18798 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
18799 NodeType2[NodeType2["Comment"] = 5] = "Comment";
18800 return NodeType2;
18801 }(NodeType || {});
18802 function isNodeInLinkedList(n2) {
18803 return "__ln" in n2;
18804 }
18805 var DoubleLinkedList = /*#__PURE__*/ function() {
18806 function DoubleLinkedList() {
18807 __publicField(this, "length", 0);
18808 __publicField(this, "head", null);
18809 __publicField(this, "tail", null);
18810 }
18811 var _proto = DoubleLinkedList.prototype;
18812 _proto.get = function get(position) {
18813 if (position >= this.length) {
18814 throw new Error("Position outside of list range");
18815 }
18816 var current = this.head;
18817 for(var index2 = 0; index2 < position; index2++){
18818 current = (current == null ? void 0 : current.next) || null;
18819 }
18820 return current;
18821 };
18822 _proto.addNode = function addNode(n2) {
18823 var node2 = {
18824 value: n2,
18825 previous: null,
18826 next: null
18827 };
18828 n2.__ln = node2;
18829 if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
18830 var current = n2.previousSibling.__ln.next;
18831 node2.next = current;
18832 node2.previous = n2.previousSibling.__ln;
18833 n2.previousSibling.__ln.next = node2;
18834 if (current) {
18835 current.previous = node2;
18836 }
18837 } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
18838 var current1 = n2.nextSibling.__ln.previous;
18839 node2.previous = current1;
18840 node2.next = n2.nextSibling.__ln;
18841 n2.nextSibling.__ln.previous = node2;
18842 if (current1) {
18843 current1.next = node2;
18844 }
18845 } else {
18846 if (this.head) {
18847 this.head.previous = node2;
18848 }
18849 node2.next = this.head;
18850 this.head = node2;
18851 }
18852 if (node2.next === null) {
18853 this.tail = node2;
18854 }
18855 this.length++;
18856 };
18857 _proto.removeNode = function removeNode(n2) {
18858 var current = n2.__ln;
18859 if (!this.head) {
18860 return;
18861 }
18862 if (!current.previous) {
18863 this.head = current.next;
18864 if (this.head) {
18865 this.head.previous = null;
18866 } else {
18867 this.tail = null;
18868 }
18869 } else {
18870 current.previous.next = current.next;
18871 if (current.next) {
18872 current.next.previous = current.previous;
18873 } else {
18874 this.tail = current.previous;
18875 }
18876 }
18877 if (n2.__ln) {
18878 delete n2.__ln;
18879 }
18880 this.length--;
18881 };
18882 return DoubleLinkedList;
18883 }();
18884 var moveKey = function(id, parentId) {
18885 return id + "@" + parentId;
18886 };
18887 var MutationBuffer = /*#__PURE__*/ function() {
18888 function MutationBuffer() {
18889 var _this = this;
18890 __publicField(this, "frozen", false);
18891 __publicField(this, "locked", false);
18892 __publicField(this, "texts", []);
18893 __publicField(this, "attributes", []);
18894 __publicField(this, "attributeMap", /* @__PURE__ */ new WeakMap());
18895 __publicField(this, "removes", []);
18896 __publicField(this, "mapRemoves", []);
18897 __publicField(this, "movedMap", {});
18898 /**
18899 * the browser MutationObserver emits multiple mutations after
18900 * a delay for performance reasons, making tracing added nodes hard
18901 * in our `processMutations` callback function.
18902 * For example, if we append an element el_1 into body, and then append
18903 * another element el_2 into el_1, these two mutations may be passed to the
18904 * callback function together when the two operations were done.
18905 * Generally we need to trace child nodes of newly added nodes, but in this
18906 * case if we count el_2 as el_1's child node in the first mutation record,
18907 * then we will count el_2 again in the second mutation record which was
18908 * duplicated.
18909 * To avoid of duplicate counting added nodes, we use a Set to store
18910 * added nodes and its child nodes during iterate mutation records. Then
18911 * collect added nodes from the Set which have no duplicate copy. But
18912 * this also causes newly added nodes will not be serialized with id ASAP,
18913 * which means all the id related calculation should be lazy too.
18914 */ __publicField(this, "addedSet", /* @__PURE__ */ new Set());
18915 __publicField(this, "movedSet", /* @__PURE__ */ new Set());
18916 __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
18917 __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
18918 __publicField(this, "mutationCb");
18919 __publicField(this, "blockClass");
18920 __publicField(this, "blockSelector");
18921 __publicField(this, "maskTextClass");
18922 __publicField(this, "maskTextSelector");
18923 __publicField(this, "inlineStylesheet");
18924 __publicField(this, "maskInputOptions");
18925 __publicField(this, "maskTextFn");
18926 __publicField(this, "maskInputFn");
18927 __publicField(this, "keepIframeSrcFn");
18928 __publicField(this, "recordCanvas");
18929 __publicField(this, "inlineImages");
18930 __publicField(this, "slimDOMOptions");
18931 __publicField(this, "dataURLOptions");
18932 __publicField(this, "doc");
18933 __publicField(this, "mirror");
18934 __publicField(this, "iframeManager");
18935 __publicField(this, "stylesheetManager");
18936 __publicField(this, "shadowDomManager");
18937 __publicField(this, "canvasManager");
18938 __publicField(this, "processedNodeManager");
18939 __publicField(this, "unattachedDoc");
18940 __publicField(this, "processMutations", function(mutations) {
18941 mutations.forEach(_this.processMutation);
18942 _this.emit();
18943 });
18944 __publicField(this, "emit", function() {
18945 if (_this.frozen || _this.locked) {
18946 return;
18947 }
18948 var adds = [];
18949 var addedIds = /* @__PURE__ */ new Set();
18950 var addList = new DoubleLinkedList();
18951 var getNextId = function(n2) {
18952 var ns = n2;
18953 var nextId = IGNORED_NODE;
18954 while(nextId === IGNORED_NODE){
18955 ns = ns && ns.nextSibling;
18956 nextId = ns && _this.mirror.getId(ns);
18957 }
18958 return nextId;
18959 };
18960 var pushAdd = function(n2) {
18961 var parent = index.parentNode(n2);
18962 if (!parent || !inDom(n2)) {
18963 return;
18964 }
18965 var cssCaptured = false;
18966 if (n2.nodeType === Node.TEXT_NODE) {
18967 var parentTag = parent.tagName;
18968 if (parentTag === "TEXTAREA") {
18969 return;
18970 } else if (parentTag === "STYLE" && _this.addedSet.has(parent)) {
18971 cssCaptured = true;
18972 }
18973 }
18974 var parentId = isShadowRoot(parent) ? _this.mirror.getId(getShadowHost(n2)) : _this.mirror.getId(parent);
18975 var nextId = getNextId(n2);
18976 if (parentId === -1 || nextId === -1) {
18977 return addList.addNode(n2);
18978 }
18979 var sn = serializeNodeWithId(n2, {
18980 doc: _this.doc,
18981 mirror: _this.mirror,
18982 blockClass: _this.blockClass,
18983 blockSelector: _this.blockSelector,
18984 maskTextClass: _this.maskTextClass,
18985 maskTextSelector: _this.maskTextSelector,
18986 skipChild: true,
18987 newlyAddedElement: true,
18988 inlineStylesheet: _this.inlineStylesheet,
18989 maskInputOptions: _this.maskInputOptions,
18990 maskTextFn: _this.maskTextFn,
18991 maskInputFn: _this.maskInputFn,
18992 slimDOMOptions: _this.slimDOMOptions,
18993 dataURLOptions: _this.dataURLOptions,
18994 recordCanvas: _this.recordCanvas,
18995 inlineImages: _this.inlineImages,
18996 onSerialize: function(currentN) {
18997 if (isSerializedIframe(currentN, _this.mirror)) {
18998 _this.iframeManager.addIframe(currentN);
18999 }
19000 if (isSerializedStylesheet(currentN, _this.mirror)) {
19001 _this.stylesheetManager.trackLinkElement(currentN);
19002 }
19003 if (hasShadowRoot(n2)) {
19004 _this.shadowDomManager.addShadowRoot(index.shadowRoot(n2), _this.doc);
19005 }
19006 },
19007 onIframeLoad: function(iframe, childSn) {
19008 _this.iframeManager.attachIframe(iframe, childSn);
19009 _this.shadowDomManager.observeAttachShadow(iframe);
19010 },
19011 onStylesheetLoad: function(link, childSn) {
19012 _this.stylesheetManager.attachLinkElement(link, childSn);
19013 },
19014 cssCaptured: cssCaptured
19015 });
19016 if (sn) {
19017 adds.push({
19018 parentId: parentId,
19019 nextId: nextId,
19020 node: sn
19021 });
19022 addedIds.add(sn.id);
19023 }
19024 };
19025 while(_this.mapRemoves.length){
19026 _this.mirror.removeNodeFromMap(_this.mapRemoves.shift());
19027 }
19028 for(var _iterator = _create_for_of_iterator_helper_loose(_this.movedSet), _step; !(_step = _iterator()).done;){
19029 var n2 = _step.value;
19030 if (isParentRemoved(_this.removesSubTreeCache, n2, _this.mirror) && !_this.movedSet.has(index.parentNode(n2))) {
19031 continue;
19032 }
19033 pushAdd(n2);
19034 }
19035 for(var _iterator1 = _create_for_of_iterator_helper_loose(_this.addedSet), _step1; !(_step1 = _iterator1()).done;){
19036 var n21 = _step1.value;
19037 if (!isAncestorInSet(_this.droppedSet, n21) && !isParentRemoved(_this.removesSubTreeCache, n21, _this.mirror)) {
19038 pushAdd(n21);
19039 } else if (isAncestorInSet(_this.movedSet, n21)) {
19040 pushAdd(n21);
19041 } else {
19042 _this.droppedSet.add(n21);
19043 }
19044 }
19045 var candidate = null;
19046 while(addList.length){
19047 var node2 = null;
19048 if (candidate) {
19049 var parentId = _this.mirror.getId(index.parentNode(candidate.value));
19050 var nextId = getNextId(candidate.value);
19051 if (parentId !== -1 && nextId !== -1) {
19052 node2 = candidate;
19053 }
19054 }
19055 if (!node2) {
19056 var tailNode = addList.tail;
19057 while(tailNode){
19058 var _node = tailNode;
19059 tailNode = tailNode.previous;
19060 if (_node) {
19061 var parentId1 = _this.mirror.getId(index.parentNode(_node.value));
19062 var nextId1 = getNextId(_node.value);
19063 if (nextId1 === -1) continue;
19064 else if (parentId1 !== -1) {
19065 node2 = _node;
19066 break;
19067 } else {
19068 var unhandledNode = _node.value;
19069 var parent = index.parentNode(unhandledNode);
19070 if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
19071 var shadowHost = index.host(parent);
19072 var parentId2 = _this.mirror.getId(shadowHost);
19073 if (parentId2 !== -1) {
19074 node2 = _node;
19075 break;
19076 }
19077 }
19078 }
19079 }
19080 }
19081 }
19082 if (!node2) {
19083 while(addList.head){
19084 addList.removeNode(addList.head.value);
19085 }
19086 break;
19087 }
19088 candidate = node2.previous;
19089 addList.removeNode(node2.value);
19090 pushAdd(node2.value);
19091 }
19092 var payload = {
19093 texts: _this.texts.map(function(text) {
19094 var n2 = text.node;
19095 var parent = index.parentNode(n2);
19096 if (parent && parent.tagName === "TEXTAREA") {
19097 _this.genTextAreaValueMutation(parent);
19098 }
19099 return {
19100 id: _this.mirror.getId(n2),
19101 value: text.value
19102 };
19103 }).filter(function(text) {
19104 return !addedIds.has(text.id);
19105 }).filter(function(text) {
19106 return _this.mirror.has(text.id);
19107 }),
19108 attributes: _this.attributes.map(function(attribute) {
19109 var attributes = attribute.attributes;
19110 if (typeof attributes.style === "string") {
19111 var diffAsStr = JSON.stringify(attribute.styleDiff);
19112 var unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
19113 if (diffAsStr.length < attributes.style.length) {
19114 if ((diffAsStr + unchangedAsStr).split("var(").length === attributes.style.split("var(").length) {
19115 attributes.style = attribute.styleDiff;
19116 }
19117 }
19118 }
19119 return {
19120 id: _this.mirror.getId(attribute.node),
19121 attributes: attributes
19122 };
19123 }).filter(function(attribute) {
19124 return !addedIds.has(attribute.id);
19125 }).filter(function(attribute) {
19126 return _this.mirror.has(attribute.id);
19127 }),
19128 removes: _this.removes,
19129 adds: adds
19130 };
19131 if (!payload.texts.length && !payload.attributes.length && !payload.removes.length && !payload.adds.length) {
19132 return;
19133 }
19134 _this.texts = [];
19135 _this.attributes = [];
19136 _this.attributeMap = /* @__PURE__ */ new WeakMap();
19137 _this.removes = [];
19138 _this.addedSet = /* @__PURE__ */ new Set();
19139 _this.movedSet = /* @__PURE__ */ new Set();
19140 _this.droppedSet = /* @__PURE__ */ new Set();
19141 _this.removesSubTreeCache = /* @__PURE__ */ new Set();
19142 _this.movedMap = {};
19143 _this.mutationCb(payload);
19144 });
19145 __publicField(this, "genTextAreaValueMutation", function(textarea) {
19146 var item = _this.attributeMap.get(textarea);
19147 if (!item) {
19148 item = {
19149 node: textarea,
19150 attributes: {},
19151 styleDiff: {},
19152 _unchangedStyles: {}
19153 };
19154 _this.attributes.push(item);
19155 _this.attributeMap.set(textarea, item);
19156 }
19157 var value = Array.from(index.childNodes(textarea), function(cn) {
19158 return index.textContent(cn) || "";
19159 }).join("");
19160 item.attributes.value = maskInputValue({
19161 element: textarea,
19162 maskInputOptions: _this.maskInputOptions,
19163 tagName: textarea.tagName,
19164 type: getInputType(textarea),
19165 value: value,
19166 maskInputFn: _this.maskInputFn
19167 });
19168 });
19169 __publicField(this, "processMutation", function(m) {
19170 if (isIgnored(m.target, _this.mirror, _this.slimDOMOptions)) {
19171 return;
19172 }
19173 switch(m.type){
19174 case "characterData":
19175 {
19176 var value = index.textContent(m.target);
19177 if (!isBlocked(m.target, _this.blockClass, _this.blockSelector, false) && value !== m.oldValue) {
19178 _this.texts.push({
19179 value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, true) && value ? _this.maskTextFn ? _this.maskTextFn(value, closestElementOfNode(m.target)) : value.replace(/[\S]/g, "*") : value,
19180 node: m.target
19181 });
19182 }
19183 break;
19184 }
19185 case "attributes":
19186 {
19187 var target = m.target;
19188 var attributeName = m.attributeName;
19189 var value1 = m.target.getAttribute(attributeName);
19190 if (attributeName === "value") {
19191 var type = getInputType(target);
19192 value1 = maskInputValue({
19193 element: target,
19194 maskInputOptions: _this.maskInputOptions,
19195 tagName: target.tagName,
19196 type: type,
19197 value: value1,
19198 maskInputFn: _this.maskInputFn
19199 });
19200 }
19201 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || value1 === m.oldValue) {
19202 return;
19203 }
19204 var item = _this.attributeMap.get(m.target);
19205 if (target.tagName === "IFRAME" && attributeName === "src" && !_this.keepIframeSrcFn(value1)) {
19206 if (!target.contentDocument) {
19207 attributeName = "rr_src";
19208 } else {
19209 return;
19210 }
19211 }
19212 if (!item) {
19213 item = {
19214 node: m.target,
19215 attributes: {},
19216 styleDiff: {},
19217 _unchangedStyles: {}
19218 };
19219 _this.attributes.push(item);
19220 _this.attributeMap.set(m.target, item);
19221 }
19222 if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
19223 target.setAttribute("data-rr-is-password", "true");
19224 }
19225 if (!ignoreAttribute(target.tagName, attributeName)) {
19226 item.attributes[attributeName] = transformAttribute(_this.doc, toLowerCase(target.tagName), toLowerCase(attributeName), value1);
19227 if (attributeName === "style") {
19228 if (!_this.unattachedDoc) {
19229 try {
19230 _this.unattachedDoc = document.implementation.createHTMLDocument();
19231 } catch (e2) {
19232 _this.unattachedDoc = _this.doc;
19233 }
19234 }
19235 var old = _this.unattachedDoc.createElement("span");
19236 if (m.oldValue) {
19237 old.setAttribute("style", m.oldValue);
19238 }
19239 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(target.style)), _step; !(_step = _iterator()).done;){
19240 var pname = _step.value;
19241 var newValue = target.style.getPropertyValue(pname);
19242 var newPriority = target.style.getPropertyPriority(pname);
19243 if (newValue !== old.style.getPropertyValue(pname) || newPriority !== old.style.getPropertyPriority(pname)) {
19244 if (newPriority === "") {
19245 item.styleDiff[pname] = newValue;
19246 } else {
19247 item.styleDiff[pname] = [
19248 newValue,
19249 newPriority
19250 ];
19251 }
19252 } else {
19253 item._unchangedStyles[pname] = [
19254 newValue,
19255 newPriority
19256 ];
19257 }
19258 }
19259 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(old.style)), _step1; !(_step1 = _iterator1()).done;){
19260 var pname1 = _step1.value;
19261 if (target.style.getPropertyValue(pname1) === "") {
19262 item.styleDiff[pname1] = false;
19263 }
19264 }
19265 } else if (attributeName === "open" && target.tagName === "DIALOG") {
19266 if (target.matches("dialog:modal")) {
19267 item.attributes["rr_open_mode"] = "modal";
19268 } else {
19269 item.attributes["rr_open_mode"] = "non-modal";
19270 }
19271 }
19272 }
19273 break;
19274 }
19275 case "childList":
19276 {
19277 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, true)) return;
19278 if (m.target.tagName === "TEXTAREA") {
19279 _this.genTextAreaValueMutation(m.target);
19280 return;
19281 }
19282 m.addedNodes.forEach(function(n2) {
19283 return _this.genAdds(n2, m.target);
19284 });
19285 m.removedNodes.forEach(function(n2) {
19286 var nodeId = _this.mirror.getId(n2);
19287 var parentId = isShadowRoot(m.target) ? _this.mirror.getId(index.host(m.target)) : _this.mirror.getId(m.target);
19288 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || isIgnored(n2, _this.mirror, _this.slimDOMOptions) || !isSerialized(n2, _this.mirror)) {
19289 return;
19290 }
19291 if (_this.addedSet.has(n2)) {
19292 deepDelete(_this.addedSet, n2);
19293 _this.droppedSet.add(n2);
19294 } else if (_this.addedSet.has(m.target) && nodeId === -1) ;
19295 else if (isAncestorRemoved(m.target, _this.mirror)) ;
19296 else if (_this.movedSet.has(n2) && _this.movedMap[moveKey(nodeId, parentId)]) {
19297 deepDelete(_this.movedSet, n2);
19298 } else {
19299 _this.removes.push({
19300 parentId: parentId,
19301 id: nodeId,
19302 isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
19303 });
19304 processRemoves(n2, _this.removesSubTreeCache);
19305 }
19306 _this.mapRemoves.push(n2);
19307 });
19308 break;
19309 }
19310 }
19311 });
19312 /**
19313 * Make sure you check if `n`'s parent is blocked before calling this function
19314 * */ __publicField(this, "genAdds", function(n2, target) {
19315 if (_this.processedNodeManager.inOtherBuffer(n2, _this)) return;
19316 if (_this.addedSet.has(n2) || _this.movedSet.has(n2)) return;
19317 if (_this.mirror.hasNode(n2)) {
19318 if (isIgnored(n2, _this.mirror, _this.slimDOMOptions)) {
19319 return;
19320 }
19321 _this.movedSet.add(n2);
19322 var targetId = null;
19323 if (target && _this.mirror.hasNode(target)) {
19324 targetId = _this.mirror.getId(target);
19325 }
19326 if (targetId && targetId !== -1) {
19327 _this.movedMap[moveKey(_this.mirror.getId(n2), targetId)] = true;
19328 }
19329 } else {
19330 _this.addedSet.add(n2);
19331 _this.droppedSet.delete(n2);
19332 }
19333 if (!isBlocked(n2, _this.blockClass, _this.blockSelector, false)) {
19334 index.childNodes(n2).forEach(function(childN) {
19335 return _this.genAdds(childN);
19336 });
19337 if (hasShadowRoot(n2)) {
19338 index.childNodes(index.shadowRoot(n2)).forEach(function(childN) {
19339 _this.processedNodeManager.add(childN, _this);
19340 _this.genAdds(childN, n2);
19341 });
19342 }
19343 }
19344 });
19345 }
19346 var _proto = MutationBuffer.prototype;
19347 _proto.init = function init(options) {
19348 var _this = this;
19349 [
19350 "mutationCb",
19351 "blockClass",
19352 "blockSelector",
19353 "maskTextClass",
19354 "maskTextSelector",
19355 "inlineStylesheet",
19356 "maskInputOptions",
19357 "maskTextFn",
19358 "maskInputFn",
19359 "keepIframeSrcFn",
19360 "recordCanvas",
19361 "inlineImages",
19362 "slimDOMOptions",
19363 "dataURLOptions",
19364 "doc",
19365 "mirror",
19366 "iframeManager",
19367 "stylesheetManager",
19368 "shadowDomManager",
19369 "canvasManager",
19370 "processedNodeManager"
19371 ].forEach(function(key) {
19372 _this[key] = options[key];
19373 });
19374 };
19375 _proto.freeze = function freeze() {
19376 this.frozen = true;
19377 this.canvasManager.freeze();
19378 };
19379 _proto.unfreeze = function unfreeze() {
19380 this.frozen = false;
19381 this.canvasManager.unfreeze();
19382 this.emit();
19383 };
19384 _proto.isFrozen = function isFrozen() {
19385 return this.frozen;
19386 };
19387 _proto.lock = function lock() {
19388 this.locked = true;
19389 this.canvasManager.lock();
19390 };
19391 _proto.unlock = function unlock() {
19392 this.locked = false;
19393 this.canvasManager.unlock();
19394 this.emit();
19395 };
19396 _proto.reset = function reset() {
19397 this.shadowDomManager.reset();
19398 this.canvasManager.reset();
19399 };
19400 return MutationBuffer;
19401 }();
19402 function deepDelete(addsSet, n2) {
19403 addsSet.delete(n2);
19404 index.childNodes(n2).forEach(function(childN) {
19405 return deepDelete(addsSet, childN);
19406 });
19407 }
19408 function processRemoves(n2, cache) {
19409 var queue = [
19410 n2
19411 ];
19412 while(queue.length){
19413 var next = queue.pop();
19414 if (cache.has(next)) continue;
19415 cache.add(next);
19416 index.childNodes(next).forEach(function(n22) {
19417 return queue.push(n22);
19418 });
19419 }
19420 return;
19421 }
19422 function isParentRemoved(removes, n2, mirror2) {
19423 if (removes.size === 0) return false;
19424 return _isParentRemoved(removes, n2);
19425 }
19426 function _isParentRemoved(removes, n2, _mirror2) {
19427 var node2 = index.parentNode(n2);
19428 if (!node2) return false;
19429 return removes.has(node2);
19430 }
19431 function isAncestorInSet(set, n2) {
19432 if (set.size === 0) return false;
19433 return _isAncestorInSet(set, n2);
19434 }
19435 function _isAncestorInSet(set, n2) {
19436 var parent = index.parentNode(n2);
19437 if (!parent) {
19438 return false;
19439 }
19440 if (set.has(parent)) {
19441 return true;
19442 }
19443 return _isAncestorInSet(set, parent);
19444 }
19445 var errorHandler;
19446 function registerErrorHandler(handler) {
19447 errorHandler = handler;
19448 }
19449 function unregisterErrorHandler() {
19450 errorHandler = void 0;
19451 }
19452 var callbackWrapper = function(cb) {
19453 if (!errorHandler) {
19454 return cb;
19455 }
19456 var rrwebWrapped = function() {
19457 for(var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++){
19458 rest[_key] = arguments[_key];
19459 }
19460 try {
19461 return cb.apply(void 0, [].concat(rest));
19462 } catch (error) {
19463 if (errorHandler && errorHandler(error) === true) {
19464 return;
19465 }
19466 throw error;
19467 }
19468 };
19469 return rrwebWrapped;
19470 };
19471 var mutationBuffers = [];
19472 function getEventTarget(event) {
19473 try {
19474 if ("composedPath" in event) {
19475 var path = event.composedPath();
19476 if (path.length) {
19477 return path[0];
19478 }
19479 } else if ("path" in event && event.path.length) {
19480 return event.path[0];
19481 }
19482 } catch (e) {}
19483 return event && event.target;
19484 }
19485 function initMutationObserver(options, rootEl) {
19486 var mutationBuffer = new MutationBuffer();
19487 mutationBuffers.push(mutationBuffer);
19488 mutationBuffer.init(options);
19489 var observer = new (mutationObserverCtor())(callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer)));
19490 observer.observe(rootEl, {
19491 attributes: true,
19492 attributeOldValue: true,
19493 characterData: true,
19494 characterDataOldValue: true,
19495 childList: true,
19496 subtree: true
19497 });
19498 return observer;
19499 }
19500 function initMoveObserver(param) {
19501 var mousemoveCb = param.mousemoveCb, sampling = param.sampling, doc = param.doc, mirror2 = param.mirror;
19502 if (sampling.mousemove === false) {
19503 return function() {};
19504 }
19505 var threshold = typeof sampling.mousemove === "number" ? sampling.mousemove : 50;
19506 var callbackThreshold = typeof sampling.mousemoveCallback === "number" ? sampling.mousemoveCallback : 500;
19507 var positions = [];
19508 var timeBaseline;
19509 var wrappedCb = throttle(callbackWrapper(function(source) {
19510 var totalOffset = Date.now() - timeBaseline;
19511 mousemoveCb(positions.map(function(p) {
19512 p.timeOffset -= totalOffset;
19513 return p;
19514 }), source);
19515 positions = [];
19516 timeBaseline = null;
19517 }), callbackThreshold);
19518 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
19519 var target = getEventTarget(evt);
19520 var _ref = legacy_isTouchEvent(evt) ? evt.changedTouches[0] : evt, clientX = _ref.clientX, clientY = _ref.clientY;
19521 if (!timeBaseline) {
19522 timeBaseline = nowTimestamp();
19523 }
19524 positions.push({
19525 x: clientX,
19526 y: clientY,
19527 id: mirror2.getId(target),
19528 timeOffset: nowTimestamp() - timeBaseline
19529 });
19530 wrappedCb(typeof DragEvent !== "undefined" && _instanceof(evt, DragEvent) ? IncrementalSource.Drag : _instanceof(evt, MouseEvent) ? IncrementalSource.MouseMove : IncrementalSource.TouchMove);
19531 }), threshold, {
19532 trailing: false
19533 }));
19534 var handlers = [
19535 on("mousemove", updatePosition, doc),
19536 on("touchmove", updatePosition, doc),
19537 on("drag", updatePosition, doc)
19538 ];
19539 return callbackWrapper(function() {
19540 handlers.forEach(function(h) {
19541 return h();
19542 });
19543 });
19544 }
19545 function initMouseInteractionObserver(param) {
19546 var mouseInteractionCb = param.mouseInteractionCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
19547 if (sampling.mouseInteraction === false) {
19548 return function() {};
19549 }
19550 var disableMap = sampling.mouseInteraction === true || sampling.mouseInteraction === void 0 ? {} : sampling.mouseInteraction;
19551 var handlers = [];
19552 var currentPointerType = null;
19553 var getHandler = function(eventKey) {
19554 return function(event) {
19555 var target = getEventTarget(event);
19556 if (isBlocked(target, blockClass, blockSelector, true)) {
19557 return;
19558 }
19559 var pointerType = null;
19560 var thisEventKey = eventKey;
19561 if ("pointerType" in event) {
19562 switch(event.pointerType){
19563 case "mouse":
19564 pointerType = PointerTypes.Mouse;
19565 break;
19566 case "touch":
19567 pointerType = PointerTypes.Touch;
19568 break;
19569 case "pen":
19570 pointerType = PointerTypes.Pen;
19571 break;
19572 }
19573 if (pointerType === PointerTypes.Touch) {
19574 if (MouseInteractions[eventKey] === MouseInteractions.MouseDown) {
19575 thisEventKey = "TouchStart";
19576 } else if (MouseInteractions[eventKey] === MouseInteractions.MouseUp) {
19577 thisEventKey = "TouchEnd";
19578 }
19579 } else if (pointerType === PointerTypes.Pen) ;
19580 } else if (legacy_isTouchEvent(event)) {
19581 pointerType = PointerTypes.Touch;
19582 }
19583 if (pointerType !== null) {
19584 currentPointerType = pointerType;
19585 if (thisEventKey.startsWith("Touch") && pointerType === PointerTypes.Touch || thisEventKey.startsWith("Mouse") && pointerType === PointerTypes.Mouse) {
19586 pointerType = null;
19587 }
19588 } else if (MouseInteractions[eventKey] === MouseInteractions.Click) {
19589 pointerType = currentPointerType;
19590 currentPointerType = null;
19591 }
19592 var e2 = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
19593 if (!e2) {
19594 return;
19595 }
19596 var id = mirror2.getId(target);
19597 var clientX = e2.clientX, clientY = e2.clientY;
19598 callbackWrapper(mouseInteractionCb)(_extends({
19599 type: MouseInteractions[thisEventKey],
19600 id: id,
19601 x: clientX,
19602 y: clientY
19603 }, pointerType !== null && {
19604 pointerType: pointerType
19605 }));
19606 };
19607 };
19608 Object.keys(MouseInteractions).filter(function(key) {
19609 return Number.isNaN(Number(key)) && !key.endsWith("_Departed") && disableMap[key] !== false;
19610 }).forEach(function(eventKey) {
19611 var eventName = toLowerCase(eventKey);
19612 var handler = getHandler(eventKey);
19613 if (window.PointerEvent) {
19614 switch(MouseInteractions[eventKey]){
19615 case MouseInteractions.MouseDown:
19616 case MouseInteractions.MouseUp:
19617 eventName = eventName.replace("mouse", "pointer");
19618 break;
19619 case MouseInteractions.TouchStart:
19620 case MouseInteractions.TouchEnd:
19621 return;
19622 }
19623 }
19624 handlers.push(on(eventName, handler, doc));
19625 });
19626 return callbackWrapper(function() {
19627 handlers.forEach(function(h) {
19628 return h();
19629 });
19630 });
19631 }
19632 function initScrollObserver(param) {
19633 var scrollCb = param.scrollCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
19634 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
19635 var target = getEventTarget(evt);
19636 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
19637 return;
19638 }
19639 var id = mirror2.getId(target);
19640 if (target === doc && doc.defaultView) {
19641 var scrollLeftTop = getWindowScroll(doc.defaultView);
19642 scrollCb({
19643 id: id,
19644 x: scrollLeftTop.left,
19645 y: scrollLeftTop.top
19646 });
19647 } else {
19648 scrollCb({
19649 id: id,
19650 x: target.scrollLeft,
19651 y: target.scrollTop
19652 });
19653 }
19654 }), sampling.scroll || 100));
19655 return on("scroll", updatePosition, doc);
19656 }
19657 function initViewportResizeObserver(param, param1) {
19658 var viewportResizeCb = param.viewportResizeCb;
19659 var win = param1.win;
19660 var lastH = -1;
19661 var lastW = -1;
19662 var updateDimension = callbackWrapper(throttle(callbackWrapper(function() {
19663 var height = getWindowHeight();
19664 var width = getWindowWidth();
19665 if (lastH !== height || lastW !== width) {
19666 viewportResizeCb({
19667 width: Number(width),
19668 height: Number(height)
19669 });
19670 lastH = height;
19671 lastW = width;
19672 }
19673 }), 200));
19674 return on("resize", updateDimension, win);
19675 }
19676 var INPUT_TAGS = [
19677 "INPUT",
19678 "TEXTAREA",
19679 "SELECT"
19680 ];
19681 var lastInputValueMap = /* @__PURE__ */ new WeakMap();
19682 function initInputObserver(param) {
19683 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;
19684 function eventHandler(event) {
19685 var target = getEventTarget(event);
19686 var userTriggered = event.isTrusted;
19687 var tagName = target && target.tagName;
19688 if (target && tagName === "OPTION") {
19689 target = index.parentElement(target);
19690 }
19691 if (!target || !tagName || INPUT_TAGS.indexOf(tagName) < 0 || isBlocked(target, blockClass, blockSelector, true)) {
19692 return;
19693 }
19694 if (target.classList.contains(ignoreClass) || ignoreSelector && target.matches(ignoreSelector)) {
19695 return;
19696 }
19697 var text = target.value;
19698 var isChecked = false;
19699 var type = getInputType(target) || "";
19700 if (type === "radio" || type === "checkbox") {
19701 isChecked = target.checked;
19702 } else if (maskInputOptions[tagName.toLowerCase()] || maskInputOptions[type]) {
19703 text = maskInputValue({
19704 element: target,
19705 maskInputOptions: maskInputOptions,
19706 tagName: tagName,
19707 type: type,
19708 value: text,
19709 maskInputFn: maskInputFn
19710 });
19711 }
19712 cbWithDedup(target, userTriggeredOnInput ? {
19713 text: text,
19714 isChecked: isChecked,
19715 userTriggered: userTriggered
19716 } : {
19717 text: text,
19718 isChecked: isChecked
19719 });
19720 var name = target.name;
19721 if (type === "radio" && name && isChecked) {
19722 doc.querySelectorAll('input[type="radio"][name="' + name + '"]').forEach(function(el) {
19723 if (el !== target) {
19724 var text2 = el.value;
19725 cbWithDedup(el, userTriggeredOnInput ? {
19726 text: text2,
19727 isChecked: !isChecked,
19728 userTriggered: false
19729 } : {
19730 text: text2,
19731 isChecked: !isChecked
19732 });
19733 }
19734 });
19735 }
19736 }
19737 function cbWithDedup(target, v2) {
19738 var lastInputValue = lastInputValueMap.get(target);
19739 if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
19740 lastInputValueMap.set(target, v2);
19741 var id = mirror2.getId(target);
19742 callbackWrapper(inputCb)(_extends({}, v2, {
19743 id: id
19744 }));
19745 }
19746 }
19747 var events = sampling.input === "last" ? [
19748 "change"
19749 ] : [
19750 "input",
19751 "change"
19752 ];
19753 var handlers = events.map(function(eventName) {
19754 return on(eventName, callbackWrapper(eventHandler), doc);
19755 });
19756 var currentWindow = doc.defaultView;
19757 if (!currentWindow) {
19758 return function() {
19759 handlers.forEach(function(h) {
19760 return h();
19761 });
19762 };
19763 }
19764 var propertyDescriptor = currentWindow.Object.getOwnPropertyDescriptor(currentWindow.HTMLInputElement.prototype, "value");
19765 var hookProperties = [
19766 [
19767 currentWindow.HTMLInputElement.prototype,
19768 "value"
19769 ],
19770 [
19771 currentWindow.HTMLInputElement.prototype,
19772 "checked"
19773 ],
19774 [
19775 currentWindow.HTMLSelectElement.prototype,
19776 "value"
19777 ],
19778 [
19779 currentWindow.HTMLTextAreaElement.prototype,
19780 "value"
19781 ],
19782 // Some UI library use selectedIndex to set select value
19783 [
19784 currentWindow.HTMLSelectElement.prototype,
19785 "selectedIndex"
19786 ],
19787 [
19788 currentWindow.HTMLOptionElement.prototype,
19789 "selected"
19790 ]
19791 ];
19792 if (propertyDescriptor && propertyDescriptor.set) {
19793 var _handlers;
19794 (_handlers = handlers).push.apply(_handlers, [].concat(hookProperties.map(function(p) {
19795 return hookSetter(p[0], p[1], {
19796 set: function set() {
19797 callbackWrapper(eventHandler)({
19798 target: this,
19799 isTrusted: false
19800 });
19801 }
19802 }, false, currentWindow);
19803 })));
19804 }
19805 return callbackWrapper(function() {
19806 handlers.forEach(function(h) {
19807 return h();
19808 });
19809 });
19810 }
19811 function getNestedCSSRulePositions(rule2) {
19812 var positions = [];
19813 function recurse(childRule, pos) {
19814 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)) {
19815 var rules2 = Array.from(childRule.parentRule.cssRules);
19816 var index2 = rules2.indexOf(childRule);
19817 pos.unshift(index2);
19818 } else if (childRule.parentStyleSheet) {
19819 var rules21 = Array.from(childRule.parentStyleSheet.cssRules);
19820 var index21 = rules21.indexOf(childRule);
19821 pos.unshift(index21);
19822 }
19823 return pos;
19824 }
19825 return recurse(rule2, positions);
19826 }
19827 function getIdAndStyleId(sheet, mirror2, styleMirror) {
19828 var id, styleId;
19829 if (!sheet) return {};
19830 if (sheet.ownerNode) id = mirror2.getId(sheet.ownerNode);
19831 else styleId = styleMirror.getId(sheet);
19832 return {
19833 styleId: styleId,
19834 id: id
19835 };
19836 }
19837 function initStyleSheetObserver(param, param1) {
19838 var styleSheetRuleCb = param.styleSheetRuleCb, mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
19839 var win = param1.win;
19840 if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
19841 return function() {};
19842 }
19843 var insertRule = win.CSSStyleSheet.prototype.insertRule;
19844 win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
19845 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19846 var rule2 = argumentsList[0], index2 = argumentsList[1];
19847 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19848 if (id && id !== -1 || styleId && styleId !== -1) {
19849 styleSheetRuleCb({
19850 id: id,
19851 styleId: styleId,
19852 adds: [
19853 {
19854 rule: rule2,
19855 index: index2
19856 }
19857 ]
19858 });
19859 }
19860 return target.apply(thisArg, argumentsList);
19861 })
19862 });
19863 win.CSSStyleSheet.prototype.addRule = function(selector, styleBlock, index2) {
19864 if (index2 === void 0) index2 = this.cssRules.length;
19865 var rule2 = selector + " { " + styleBlock + " }";
19866 return win.CSSStyleSheet.prototype.insertRule.apply(this, [
19867 rule2,
19868 index2
19869 ]);
19870 };
19871 var deleteRule = win.CSSStyleSheet.prototype.deleteRule;
19872 win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
19873 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19874 var index2 = argumentsList[0];
19875 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19876 if (id && id !== -1 || styleId && styleId !== -1) {
19877 styleSheetRuleCb({
19878 id: id,
19879 styleId: styleId,
19880 removes: [
19881 {
19882 index: index2
19883 }
19884 ]
19885 });
19886 }
19887 return target.apply(thisArg, argumentsList);
19888 })
19889 });
19890 win.CSSStyleSheet.prototype.removeRule = function(index2) {
19891 return win.CSSStyleSheet.prototype.deleteRule.apply(this, [
19892 index2
19893 ]);
19894 };
19895 var replace;
19896 if (win.CSSStyleSheet.prototype.replace) {
19897 replace = win.CSSStyleSheet.prototype.replace;
19898 win.CSSStyleSheet.prototype.replace = new Proxy(replace, {
19899 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19900 var text = argumentsList[0];
19901 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19902 if (id && id !== -1 || styleId && styleId !== -1) {
19903 styleSheetRuleCb({
19904 id: id,
19905 styleId: styleId,
19906 replace: text
19907 });
19908 }
19909 return target.apply(thisArg, argumentsList);
19910 })
19911 });
19912 }
19913 var replaceSync;
19914 if (win.CSSStyleSheet.prototype.replaceSync) {
19915 replaceSync = win.CSSStyleSheet.prototype.replaceSync;
19916 win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {
19917 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19918 var text = argumentsList[0];
19919 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19920 if (id && id !== -1 || styleId && styleId !== -1) {
19921 styleSheetRuleCb({
19922 id: id,
19923 styleId: styleId,
19924 replaceSync: text
19925 });
19926 }
19927 return target.apply(thisArg, argumentsList);
19928 })
19929 });
19930 }
19931 var supportedNestedCSSRuleTypes = {};
19932 if (canMonkeyPatchNestedCSSRule("CSSGroupingRule")) {
19933 supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
19934 } else {
19935 if (canMonkeyPatchNestedCSSRule("CSSMediaRule")) {
19936 supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
19937 }
19938 if (canMonkeyPatchNestedCSSRule("CSSConditionRule")) {
19939 supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
19940 }
19941 if (canMonkeyPatchNestedCSSRule("CSSSupportsRule")) {
19942 supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
19943 }
19944 }
19945 var unmodifiedFunctions = {};
19946 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
19947 var typeKey = param[0], type = param[1];
19948 unmodifiedFunctions[typeKey] = {
19949 // eslint-disable-next-line @typescript-eslint/unbound-method
19950 insertRule: type.prototype.insertRule,
19951 // eslint-disable-next-line @typescript-eslint/unbound-method
19952 deleteRule: type.prototype.deleteRule
19953 };
19954 type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
19955 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19956 var rule2 = argumentsList[0], index2 = argumentsList[1];
19957 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19958 if (id && id !== -1 || styleId && styleId !== -1) {
19959 styleSheetRuleCb({
19960 id: id,
19961 styleId: styleId,
19962 adds: [
19963 {
19964 rule: rule2,
19965 index: [].concat(getNestedCSSRulePositions(thisArg), [
19966 index2 || 0
19967 ])
19968 }
19969 ]
19970 });
19971 }
19972 return target.apply(thisArg, argumentsList);
19973 })
19974 });
19975 type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
19976 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19977 var index2 = argumentsList[0];
19978 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19979 if (id && id !== -1 || styleId && styleId !== -1) {
19980 styleSheetRuleCb({
19981 id: id,
19982 styleId: styleId,
19983 removes: [
19984 {
19985 index: [].concat(getNestedCSSRulePositions(thisArg), [
19986 index2
19987 ])
19988 }
19989 ]
19990 });
19991 }
19992 return target.apply(thisArg, argumentsList);
19993 })
19994 });
19995 });
19996 return callbackWrapper(function() {
19997 win.CSSStyleSheet.prototype.insertRule = insertRule;
19998 win.CSSStyleSheet.prototype.deleteRule = deleteRule;
19999 replace && (win.CSSStyleSheet.prototype.replace = replace);
20000 replaceSync && (win.CSSStyleSheet.prototype.replaceSync = replaceSync);
20001 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
20002 var typeKey = param[0], type = param[1];
20003 type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
20004 type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
20005 });
20006 });
20007 }
20008 function initAdoptedStyleSheetObserver(param, host2) {
20009 var mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
20010 var _a2, _b, _c;
20011 var hostId = null;
20012 if (host2.nodeName === "#document") hostId = mirror2.getId(host2);
20013 else hostId = mirror2.getId(index.host(host2));
20014 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;
20015 var originalPropertyDescriptor = (patchTarget == null ? void 0 : patchTarget.prototype) ? Object.getOwnPropertyDescriptor(patchTarget == null ? void 0 : patchTarget.prototype, "adoptedStyleSheets") : void 0;
20016 if (hostId === null || hostId === -1 || !patchTarget || !originalPropertyDescriptor) return function() {};
20017 Object.defineProperty(host2, "adoptedStyleSheets", {
20018 configurable: originalPropertyDescriptor.configurable,
20019 enumerable: originalPropertyDescriptor.enumerable,
20020 get: function get() {
20021 var _a3;
20022 return (_a3 = originalPropertyDescriptor.get) == null ? void 0 : _a3.call(this);
20023 },
20024 set: function set(sheets) {
20025 var _a3;
20026 var result2 = (_a3 = originalPropertyDescriptor.set) == null ? void 0 : _a3.call(this, sheets);
20027 if (hostId !== null && hostId !== -1) {
20028 try {
20029 stylesheetManager.adoptStyleSheets(sheets, hostId);
20030 } catch (e2) {}
20031 }
20032 return result2;
20033 }
20034 });
20035 return callbackWrapper(function() {
20036 Object.defineProperty(host2, "adoptedStyleSheets", {
20037 configurable: originalPropertyDescriptor.configurable,
20038 enumerable: originalPropertyDescriptor.enumerable,
20039 // eslint-disable-next-line @typescript-eslint/unbound-method
20040 get: originalPropertyDescriptor.get,
20041 // eslint-disable-next-line @typescript-eslint/unbound-method
20042 set: originalPropertyDescriptor.set
20043 });
20044 });
20045 }
20046 function initStyleDeclarationObserver(param, param1) {
20047 var styleDeclarationCb = param.styleDeclarationCb, mirror2 = param.mirror, ignoreCSSAttributes = param.ignoreCSSAttributes, stylesheetManager = param.stylesheetManager;
20048 var win = param1.win;
20049 var setProperty = win.CSSStyleDeclaration.prototype.setProperty;
20050 win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
20051 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20052 var _a2;
20053 var property = argumentsList[0], value = argumentsList[1], priority = argumentsList[2];
20054 if (ignoreCSSAttributes.has(property)) {
20055 return setProperty.apply(thisArg, [
20056 property,
20057 value,
20058 priority
20059 ]);
20060 }
20061 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20062 if (id && id !== -1 || styleId && styleId !== -1) {
20063 styleDeclarationCb({
20064 id: id,
20065 styleId: styleId,
20066 set: {
20067 property: property,
20068 value: value,
20069 priority: priority
20070 },
20071 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20072 index: getNestedCSSRulePositions(thisArg.parentRule)
20073 });
20074 }
20075 return target.apply(thisArg, argumentsList);
20076 })
20077 });
20078 var removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
20079 win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
20080 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20081 var _a2;
20082 var property = argumentsList[0];
20083 if (ignoreCSSAttributes.has(property)) {
20084 return removeProperty.apply(thisArg, [
20085 property
20086 ]);
20087 }
20088 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20089 if (id && id !== -1 || styleId && styleId !== -1) {
20090 styleDeclarationCb({
20091 id: id,
20092 styleId: styleId,
20093 remove: {
20094 property: property
20095 },
20096 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20097 index: getNestedCSSRulePositions(thisArg.parentRule)
20098 });
20099 }
20100 return target.apply(thisArg, argumentsList);
20101 })
20102 });
20103 return callbackWrapper(function() {
20104 win.CSSStyleDeclaration.prototype.setProperty = setProperty;
20105 win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
20106 });
20107 }
20108 function initMediaInteractionObserver(param) {
20109 var mediaInteractionCb = param.mediaInteractionCb, blockClass = param.blockClass, blockSelector = param.blockSelector, mirror2 = param.mirror, sampling = param.sampling, doc = param.doc;
20110 var handler = callbackWrapper(function(type) {
20111 return throttle(callbackWrapper(function(event) {
20112 var target = getEventTarget(event);
20113 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20114 return;
20115 }
20116 var currentTime = target.currentTime, volume = target.volume, muted = target.muted, playbackRate = target.playbackRate, loop = target.loop;
20117 mediaInteractionCb({
20118 type: type,
20119 id: mirror2.getId(target),
20120 currentTime: currentTime,
20121 volume: volume,
20122 muted: muted,
20123 playbackRate: playbackRate,
20124 loop: loop
20125 });
20126 }), sampling.media || 500);
20127 });
20128 var handlers = [
20129 on("play", handler(MediaInteractions.Play), doc),
20130 on("pause", handler(MediaInteractions.Pause), doc),
20131 on("seeked", handler(MediaInteractions.Seeked), doc),
20132 on("volumechange", handler(MediaInteractions.VolumeChange), doc),
20133 on("ratechange", handler(MediaInteractions.RateChange), doc)
20134 ];
20135 return callbackWrapper(function() {
20136 handlers.forEach(function(h) {
20137 return h();
20138 });
20139 });
20140 }
20141 function initFontObserver(param) {
20142 var fontCb = param.fontCb, doc = param.doc;
20143 var win = doc.defaultView;
20144 if (!win) {
20145 return function() {};
20146 }
20147 var handlers = [];
20148 var fontMap = /* @__PURE__ */ new WeakMap();
20149 var originalFontFace = win.FontFace;
20150 win.FontFace = function FontFace2(family, source, descriptors) {
20151 var fontFace = new originalFontFace(family, source, descriptors);
20152 fontMap.set(fontFace, {
20153 family: family,
20154 buffer: typeof source !== "string",
20155 descriptors: descriptors,
20156 fontSource: typeof source === "string" ? source : JSON.stringify(Array.from(new Uint8Array(source)))
20157 });
20158 return fontFace;
20159 };
20160 var restoreHandler = patch(doc.fonts, "add", function(original) {
20161 return function(fontFace) {
20162 setTimeout(callbackWrapper(function() {
20163 var p = fontMap.get(fontFace);
20164 if (p) {
20165 fontCb(p);
20166 fontMap.delete(fontFace);
20167 }
20168 }), 0);
20169 return original.apply(this, [
20170 fontFace
20171 ]);
20172 };
20173 });
20174 handlers.push(function() {
20175 win.FontFace = originalFontFace;
20176 });
20177 handlers.push(restoreHandler);
20178 return callbackWrapper(function() {
20179 handlers.forEach(function(h) {
20180 return h();
20181 });
20182 });
20183 }
20184 function initSelectionObserver(param) {
20185 var doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, selectionCb = param.selectionCb;
20186 var collapsed = true;
20187 var updateSelection = callbackWrapper(function() {
20188 var selection = doc.getSelection();
20189 if (!selection || collapsed && (selection == null ? void 0 : selection.isCollapsed)) return;
20190 collapsed = selection.isCollapsed || false;
20191 var ranges = [];
20192 var count = selection.rangeCount || 0;
20193 for(var i2 = 0; i2 < count; i2++){
20194 var range = selection.getRangeAt(i2);
20195 var startContainer = range.startContainer, startOffset = range.startOffset, endContainer = range.endContainer, endOffset = range.endOffset;
20196 var blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
20197 if (blocked) continue;
20198 ranges.push({
20199 start: mirror2.getId(startContainer),
20200 startOffset: startOffset,
20201 end: mirror2.getId(endContainer),
20202 endOffset: endOffset
20203 });
20204 }
20205 selectionCb({
20206 ranges: ranges
20207 });
20208 });
20209 updateSelection();
20210 return on("selectionchange", updateSelection);
20211 }
20212 function initCustomElementObserver(param) {
20213 var doc = param.doc, customElementCb = param.customElementCb;
20214 var win = doc.defaultView;
20215 if (!win || !win.customElements) return function() {};
20216 var restoreHandler = patch(win.customElements, "define", function(original) {
20217 return function(name, constructor, options) {
20218 try {
20219 customElementCb({
20220 define: {
20221 name: name
20222 }
20223 });
20224 } catch (e2) {
20225 console.warn("Custom element callback failed for " + name);
20226 }
20227 return original.apply(this, [
20228 name,
20229 constructor,
20230 options
20231 ]);
20232 };
20233 });
20234 return restoreHandler;
20235 }
20236 function mergeHooks(o2, hooks) {
20237 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;
20238 o2.mutationCb = function() {
20239 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20240 p[_key] = arguments[_key];
20241 }
20242 if (hooks.mutation) {
20243 var _hooks;
20244 (_hooks = hooks).mutation.apply(_hooks, [].concat(p));
20245 }
20246 mutationCb.apply(void 0, [].concat(p));
20247 };
20248 o2.mousemoveCb = function() {
20249 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20250 p[_key] = arguments[_key];
20251 }
20252 if (hooks.mousemove) {
20253 var _hooks;
20254 (_hooks = hooks).mousemove.apply(_hooks, [].concat(p));
20255 }
20256 mousemoveCb.apply(void 0, [].concat(p));
20257 };
20258 o2.mouseInteractionCb = function() {
20259 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20260 p[_key] = arguments[_key];
20261 }
20262 if (hooks.mouseInteraction) {
20263 var _hooks;
20264 (_hooks = hooks).mouseInteraction.apply(_hooks, [].concat(p));
20265 }
20266 mouseInteractionCb.apply(void 0, [].concat(p));
20267 };
20268 o2.scrollCb = function() {
20269 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20270 p[_key] = arguments[_key];
20271 }
20272 if (hooks.scroll) {
20273 var _hooks;
20274 (_hooks = hooks).scroll.apply(_hooks, [].concat(p));
20275 }
20276 scrollCb.apply(void 0, [].concat(p));
20277 };
20278 o2.viewportResizeCb = function() {
20279 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20280 p[_key] = arguments[_key];
20281 }
20282 if (hooks.viewportResize) {
20283 var _hooks;
20284 (_hooks = hooks).viewportResize.apply(_hooks, [].concat(p));
20285 }
20286 viewportResizeCb.apply(void 0, [].concat(p));
20287 };
20288 o2.inputCb = function() {
20289 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20290 p[_key] = arguments[_key];
20291 }
20292 if (hooks.input) {
20293 var _hooks;
20294 (_hooks = hooks).input.apply(_hooks, [].concat(p));
20295 }
20296 inputCb.apply(void 0, [].concat(p));
20297 };
20298 o2.mediaInteractionCb = function() {
20299 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20300 p[_key] = arguments[_key];
20301 }
20302 if (hooks.mediaInteaction) {
20303 var _hooks;
20304 (_hooks = hooks).mediaInteaction.apply(_hooks, [].concat(p));
20305 }
20306 mediaInteractionCb.apply(void 0, [].concat(p));
20307 };
20308 o2.styleSheetRuleCb = function() {
20309 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20310 p[_key] = arguments[_key];
20311 }
20312 if (hooks.styleSheetRule) {
20313 var _hooks;
20314 (_hooks = hooks).styleSheetRule.apply(_hooks, [].concat(p));
20315 }
20316 styleSheetRuleCb.apply(void 0, [].concat(p));
20317 };
20318 o2.styleDeclarationCb = function() {
20319 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20320 p[_key] = arguments[_key];
20321 }
20322 if (hooks.styleDeclaration) {
20323 var _hooks;
20324 (_hooks = hooks).styleDeclaration.apply(_hooks, [].concat(p));
20325 }
20326 styleDeclarationCb.apply(void 0, [].concat(p));
20327 };
20328 o2.canvasMutationCb = function() {
20329 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20330 p[_key] = arguments[_key];
20331 }
20332 if (hooks.canvasMutation) {
20333 var _hooks;
20334 (_hooks = hooks).canvasMutation.apply(_hooks, [].concat(p));
20335 }
20336 canvasMutationCb.apply(void 0, [].concat(p));
20337 };
20338 o2.fontCb = function() {
20339 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20340 p[_key] = arguments[_key];
20341 }
20342 if (hooks.font) {
20343 var _hooks;
20344 (_hooks = hooks).font.apply(_hooks, [].concat(p));
20345 }
20346 fontCb.apply(void 0, [].concat(p));
20347 };
20348 o2.selectionCb = function() {
20349 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20350 p[_key] = arguments[_key];
20351 }
20352 if (hooks.selection) {
20353 var _hooks;
20354 (_hooks = hooks).selection.apply(_hooks, [].concat(p));
20355 }
20356 selectionCb.apply(void 0, [].concat(p));
20357 };
20358 o2.customElementCb = function() {
20359 for(var _len = arguments.length, c2 = new Array(_len), _key = 0; _key < _len; _key++){
20360 c2[_key] = arguments[_key];
20361 }
20362 if (hooks.customElement) {
20363 var _hooks;
20364 (_hooks = hooks).customElement.apply(_hooks, [].concat(c2));
20365 }
20366 customElementCb.apply(void 0, [].concat(c2));
20367 };
20368 }
20369 function initObservers(o2, hooks) {
20370 if (hooks === void 0) hooks = {};
20371 var currentWindow = o2.doc.defaultView;
20372 if (!currentWindow) {
20373 return function() {};
20374 }
20375 mergeHooks(o2, hooks);
20376 var mutationObserver;
20377 if (o2.recordDOM) {
20378 mutationObserver = initMutationObserver(o2, o2.doc);
20379 }
20380 var mousemoveHandler = initMoveObserver(o2);
20381 var mouseInteractionHandler = initMouseInteractionObserver(o2);
20382 var scrollHandler = initScrollObserver(o2);
20383 var viewportResizeHandler = initViewportResizeObserver(o2, {
20384 win: currentWindow
20385 });
20386 var inputHandler = initInputObserver(o2);
20387 var mediaInteractionHandler = initMediaInteractionObserver(o2);
20388 var styleSheetObserver = function() {};
20389 var adoptedStyleSheetObserver = function() {};
20390 var styleDeclarationObserver = function() {};
20391 var fontObserver = function() {};
20392 if (o2.recordDOM) {
20393 styleSheetObserver = initStyleSheetObserver(o2, {
20394 win: currentWindow
20395 });
20396 adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o2, o2.doc);
20397 styleDeclarationObserver = initStyleDeclarationObserver(o2, {
20398 win: currentWindow
20399 });
20400 if (o2.collectFonts) {
20401 fontObserver = initFontObserver(o2);
20402 }
20403 }
20404 var selectionObserver = initSelectionObserver(o2);
20405 var customElementObserver = initCustomElementObserver(o2);
20406 var pluginHandlers = [];
20407 for(var _iterator = _create_for_of_iterator_helper_loose(o2.plugins), _step; !(_step = _iterator()).done;){
20408 var plugin3 = _step.value;
20409 pluginHandlers.push(plugin3.observer(plugin3.callback, currentWindow, plugin3.options));
20410 }
20411 return callbackWrapper(function() {
20412 mutationBuffers.forEach(function(b) {
20413 return b.reset();
20414 });
20415 mutationObserver == null ? void 0 : mutationObserver.disconnect();
20416 mousemoveHandler();
20417 mouseInteractionHandler();
20418 scrollHandler();
20419 viewportResizeHandler();
20420 inputHandler();
20421 mediaInteractionHandler();
20422 styleSheetObserver();
20423 adoptedStyleSheetObserver();
20424 styleDeclarationObserver();
20425 fontObserver();
20426 selectionObserver();
20427 customElementObserver();
20428 pluginHandlers.forEach(function(h) {
20429 return h();
20430 });
20431 });
20432 }
20433 function hasNestedCSSRule(prop) {
20434 return typeof window[prop] !== "undefined";
20435 }
20436 function canMonkeyPatchNestedCSSRule(prop) {
20437 return Boolean(typeof window[prop] !== "undefined" && // Note: Generally, this check _shouldn't_ be necessary
20438 // However, in some scenarios (e.g. jsdom) this can sometimes fail, so we check for it here
20439 window[prop].prototype && "insertRule" in window[prop].prototype && "deleteRule" in window[prop].prototype);
20440 }
20441 var CrossOriginIframeMirror = /*#__PURE__*/ function() {
20442 function CrossOriginIframeMirror(generateIdFn) {
20443 __publicField(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
20444 __publicField(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
20445 this.generateIdFn = generateIdFn;
20446 }
20447 var _proto = CrossOriginIframeMirror.prototype;
20448 _proto.getId = function getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) {
20449 var idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe);
20450 var remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe);
20451 var id = idToRemoteIdMap.get(remoteId);
20452 if (!id) {
20453 id = this.generateIdFn();
20454 idToRemoteIdMap.set(remoteId, id);
20455 remoteIdToIdMap.set(id, remoteId);
20456 }
20457 return id;
20458 };
20459 _proto.getIds = function getIds(iframe, remoteId) {
20460 var _this = this;
20461 var idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);
20462 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20463 return remoteId.map(function(id) {
20464 return _this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap);
20465 });
20466 };
20467 _proto.getRemoteId = function getRemoteId(iframe, id, map) {
20468 var remoteIdToIdMap = map || this.getRemoteIdToIdMap(iframe);
20469 if (typeof id !== "number") return id;
20470 var remoteId = remoteIdToIdMap.get(id);
20471 if (!remoteId) return -1;
20472 return remoteId;
20473 };
20474 _proto.getRemoteIds = function getRemoteIds(iframe, ids) {
20475 var _this = this;
20476 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20477 return ids.map(function(id) {
20478 return _this.getRemoteId(iframe, id, remoteIdToIdMap);
20479 });
20480 };
20481 _proto.reset = function reset(iframe) {
20482 if (!iframe) {
20483 this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap();
20484 this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
20485 return;
20486 }
20487 this.iframeIdToRemoteIdMap.delete(iframe);
20488 this.iframeRemoteIdToIdMap.delete(iframe);
20489 };
20490 _proto.getIdToRemoteIdMap = function getIdToRemoteIdMap(iframe) {
20491 var idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe);
20492 if (!idToRemoteIdMap) {
20493 idToRemoteIdMap = /* @__PURE__ */ new Map();
20494 this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap);
20495 }
20496 return idToRemoteIdMap;
20497 };
20498 _proto.getRemoteIdToIdMap = function getRemoteIdToIdMap(iframe) {
20499 var remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe);
20500 if (!remoteIdToIdMap) {
20501 remoteIdToIdMap = /* @__PURE__ */ new Map();
20502 this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap);
20503 }
20504 return remoteIdToIdMap;
20505 };
20506 return CrossOriginIframeMirror;
20507 }();
20508 var IframeManager = /*#__PURE__*/ function() {
20509 function IframeManager(options) {
20510 __publicField(this, "iframes", /* @__PURE__ */ new WeakMap());
20511 __publicField(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
20512 __publicField(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
20513 __publicField(this, "crossOriginIframeStyleMirror");
20514 __publicField(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
20515 __publicField(this, "mirror");
20516 __publicField(this, "mutationCb");
20517 __publicField(this, "wrappedEmit");
20518 __publicField(this, "loadListener");
20519 __publicField(this, "stylesheetManager");
20520 __publicField(this, "recordCrossOriginIframes");
20521 this.mutationCb = options.mutationCb;
20522 this.wrappedEmit = options.wrappedEmit;
20523 this.stylesheetManager = options.stylesheetManager;
20524 this.recordCrossOriginIframes = options.recordCrossOriginIframes;
20525 this.crossOriginIframeStyleMirror = new CrossOriginIframeMirror(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror));
20526 this.mirror = options.mirror;
20527 if (this.recordCrossOriginIframes) {
20528 window.addEventListener("message", this.handleMessage.bind(this));
20529 }
20530 }
20531 var _proto = IframeManager.prototype;
20532 _proto.addIframe = function addIframe(iframeEl) {
20533 this.iframes.set(iframeEl, true);
20534 if (iframeEl.contentWindow) this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
20535 };
20536 _proto.addLoadListener = function addLoadListener(cb) {
20537 this.loadListener = cb;
20538 };
20539 _proto.attachIframe = function attachIframe(iframeEl, childSn) {
20540 var _a2, _b;
20541 this.mutationCb({
20542 adds: [
20543 {
20544 parentId: this.mirror.getId(iframeEl),
20545 nextId: null,
20546 node: childSn
20547 }
20548 ],
20549 removes: [],
20550 texts: [],
20551 attributes: [],
20552 isAttachIframe: true
20553 });
20554 if (this.recordCrossOriginIframes) (_a2 = iframeEl.contentWindow) == null ? void 0 : _a2.addEventListener("message", this.handleMessage.bind(this));
20555 (_b = this.loadListener) == null ? void 0 : _b.call(this, iframeEl);
20556 if (iframeEl.contentDocument && iframeEl.contentDocument.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0) this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
20557 };
20558 _proto.handleMessage = function handleMessage(message) {
20559 var crossOriginMessageEvent = message;
20560 if (crossOriginMessageEvent.data.type !== "rrweb" || // To filter out the rrweb messages which are forwarded by some sites.
20561 crossOriginMessageEvent.origin !== crossOriginMessageEvent.data.origin) return;
20562 var iframeSourceWindow = message.source;
20563 if (!iframeSourceWindow) return;
20564 var iframeEl = this.crossOriginIframeMap.get(message.source);
20565 if (!iframeEl) return;
20566 var transformedEvent = this.transformCrossOriginEvent(iframeEl, crossOriginMessageEvent.data.event);
20567 if (transformedEvent) this.wrappedEmit(transformedEvent, crossOriginMessageEvent.data.isCheckout);
20568 };
20569 _proto.transformCrossOriginEvent = function transformCrossOriginEvent(iframeEl, e2) {
20570 var _this = this;
20571 var _a2;
20572 switch(e2.type){
20573 case EventType.FullSnapshot:
20574 {
20575 this.crossOriginIframeMirror.reset(iframeEl);
20576 this.crossOriginIframeStyleMirror.reset(iframeEl);
20577 this.replaceIdOnNode(e2.data.node, iframeEl);
20578 var rootId = e2.data.node.id;
20579 this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
20580 this.patchRootIdOnNode(e2.data.node, rootId);
20581 return {
20582 timestamp: e2.timestamp,
20583 type: EventType.IncrementalSnapshot,
20584 data: {
20585 source: IncrementalSource.Mutation,
20586 adds: [
20587 {
20588 parentId: this.mirror.getId(iframeEl),
20589 nextId: null,
20590 node: e2.data.node
20591 }
20592 ],
20593 removes: [],
20594 texts: [],
20595 attributes: [],
20596 isAttachIframe: true
20597 }
20598 };
20599 }
20600 case EventType.Meta:
20601 case EventType.Load:
20602 case EventType.DomContentLoaded:
20603 {
20604 return false;
20605 }
20606 case EventType.Plugin:
20607 {
20608 return e2;
20609 }
20610 case EventType.Custom:
20611 {
20612 this.replaceIds(e2.data.payload, iframeEl, [
20613 "id",
20614 "parentId",
20615 "previousId",
20616 "nextId"
20617 ]);
20618 return e2;
20619 }
20620 case EventType.IncrementalSnapshot:
20621 {
20622 switch(e2.data.source){
20623 case IncrementalSource.Mutation:
20624 {
20625 e2.data.adds.forEach(function(n2) {
20626 _this.replaceIds(n2, iframeEl, [
20627 "parentId",
20628 "nextId",
20629 "previousId"
20630 ]);
20631 _this.replaceIdOnNode(n2.node, iframeEl);
20632 var rootId = _this.crossOriginIframeRootIdMap.get(iframeEl);
20633 rootId && _this.patchRootIdOnNode(n2.node, rootId);
20634 });
20635 e2.data.removes.forEach(function(n2) {
20636 _this.replaceIds(n2, iframeEl, [
20637 "parentId",
20638 "id"
20639 ]);
20640 });
20641 e2.data.attributes.forEach(function(n2) {
20642 _this.replaceIds(n2, iframeEl, [
20643 "id"
20644 ]);
20645 });
20646 e2.data.texts.forEach(function(n2) {
20647 _this.replaceIds(n2, iframeEl, [
20648 "id"
20649 ]);
20650 });
20651 return e2;
20652 }
20653 case IncrementalSource.Drag:
20654 case IncrementalSource.TouchMove:
20655 case IncrementalSource.MouseMove:
20656 {
20657 e2.data.positions.forEach(function(p) {
20658 _this.replaceIds(p, iframeEl, [
20659 "id"
20660 ]);
20661 });
20662 return e2;
20663 }
20664 case IncrementalSource.ViewportResize:
20665 {
20666 return false;
20667 }
20668 case IncrementalSource.MediaInteraction:
20669 case IncrementalSource.MouseInteraction:
20670 case IncrementalSource.Scroll:
20671 case IncrementalSource.CanvasMutation:
20672 case IncrementalSource.Input:
20673 {
20674 this.replaceIds(e2.data, iframeEl, [
20675 "id"
20676 ]);
20677 return e2;
20678 }
20679 case IncrementalSource.StyleSheetRule:
20680 case IncrementalSource.StyleDeclaration:
20681 {
20682 this.replaceIds(e2.data, iframeEl, [
20683 "id"
20684 ]);
20685 this.replaceStyleIds(e2.data, iframeEl, [
20686 "styleId"
20687 ]);
20688 return e2;
20689 }
20690 case IncrementalSource.Font:
20691 {
20692 return e2;
20693 }
20694 case IncrementalSource.Selection:
20695 {
20696 e2.data.ranges.forEach(function(range) {
20697 _this.replaceIds(range, iframeEl, [
20698 "start",
20699 "end"
20700 ]);
20701 });
20702 return e2;
20703 }
20704 case IncrementalSource.AdoptedStyleSheet:
20705 {
20706 this.replaceIds(e2.data, iframeEl, [
20707 "id"
20708 ]);
20709 this.replaceStyleIds(e2.data, iframeEl, [
20710 "styleIds"
20711 ]);
20712 (_a2 = e2.data.styles) == null ? void 0 : _a2.forEach(function(style) {
20713 _this.replaceStyleIds(style, iframeEl, [
20714 "styleId"
20715 ]);
20716 });
20717 return e2;
20718 }
20719 }
20720 }
20721 }
20722 return false;
20723 };
20724 _proto.replace = function replace(iframeMirror, obj, iframeEl, keys) {
20725 for(var _iterator = _create_for_of_iterator_helper_loose(keys), _step; !(_step = _iterator()).done;){
20726 var key = _step.value;
20727 if (!Array.isArray(obj[key]) && typeof obj[key] !== "number") continue;
20728 if (Array.isArray(obj[key])) {
20729 obj[key] = iframeMirror.getIds(iframeEl, obj[key]);
20730 } else {
20731 obj[key] = iframeMirror.getId(iframeEl, obj[key]);
20732 }
20733 }
20734 return obj;
20735 };
20736 _proto.replaceIds = function replaceIds(obj, iframeEl, keys) {
20737 return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);
20738 };
20739 _proto.replaceStyleIds = function replaceStyleIds(obj, iframeEl, keys) {
20740 return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
20741 };
20742 _proto.replaceIdOnNode = function replaceIdOnNode(node2, iframeEl) {
20743 var _this = this;
20744 this.replaceIds(node2, iframeEl, [
20745 "id",
20746 "rootId"
20747 ]);
20748 if ("childNodes" in node2) {
20749 node2.childNodes.forEach(function(child) {
20750 _this.replaceIdOnNode(child, iframeEl);
20751 });
20752 }
20753 };
20754 _proto.patchRootIdOnNode = function patchRootIdOnNode(node2, rootId) {
20755 var _this = this;
20756 if (node2.type !== NodeType.Document && !node2.rootId) node2.rootId = rootId;
20757 if ("childNodes" in node2) {
20758 node2.childNodes.forEach(function(child) {
20759 _this.patchRootIdOnNode(child, rootId);
20760 });
20761 }
20762 };
20763 return IframeManager;
20764 }();
20765 var ShadowDomManager = /*#__PURE__*/ function() {
20766 function ShadowDomManager(options) {
20767 __publicField(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
20768 __publicField(this, "mutationCb");
20769 __publicField(this, "scrollCb");
20770 __publicField(this, "bypassOptions");
20771 __publicField(this, "mirror");
20772 __publicField(this, "restoreHandlers", []);
20773 this.mutationCb = options.mutationCb;
20774 this.scrollCb = options.scrollCb;
20775 this.bypassOptions = options.bypassOptions;
20776 this.mirror = options.mirror;
20777 this.init();
20778 }
20779 var _proto = ShadowDomManager.prototype;
20780 _proto.init = function init() {
20781 this.reset();
20782 this.patchAttachShadow(Element, document);
20783 };
20784 _proto.addShadowRoot = function addShadowRoot(shadowRoot2, doc) {
20785 var _this = this;
20786 if (!isNativeShadowDom(shadowRoot2)) return;
20787 if (this.shadowDoms.has(shadowRoot2)) return;
20788 this.shadowDoms.add(shadowRoot2);
20789 var observer = initMutationObserver(_extends({}, this.bypassOptions, {
20790 doc: doc,
20791 mutationCb: this.mutationCb,
20792 mirror: this.mirror,
20793 shadowDomManager: this
20794 }), shadowRoot2);
20795 this.restoreHandlers.push(function() {
20796 return observer.disconnect();
20797 });
20798 this.restoreHandlers.push(initScrollObserver(_extends({}, this.bypassOptions, {
20799 scrollCb: this.scrollCb,
20800 // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813
20801 // scroll is not allowed to pass the boundary, so we need to listen the shadow document
20802 doc: shadowRoot2,
20803 mirror: this.mirror
20804 })));
20805 setTimeout(function() {
20806 if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0) _this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot2.adoptedStyleSheets, _this.mirror.getId(index.host(shadowRoot2)));
20807 _this.restoreHandlers.push(initAdoptedStyleSheetObserver({
20808 mirror: _this.mirror,
20809 stylesheetManager: _this.bypassOptions.stylesheetManager
20810 }, shadowRoot2));
20811 }, 0);
20812 };
20813 /**
20814 * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
20815 */ _proto.observeAttachShadow = function observeAttachShadow(iframeElement) {
20816 if (!iframeElement.contentWindow || !iframeElement.contentDocument) return;
20817 this.patchAttachShadow(iframeElement.contentWindow.Element, iframeElement.contentDocument);
20818 };
20819 /**
20820 * Patch 'attachShadow' to observe newly added shadow doms.
20821 */ _proto.patchAttachShadow = function patchAttachShadow(element, doc) {
20822 var manager = this;
20823 this.restoreHandlers.push(patch(element.prototype, "attachShadow", function(original) {
20824 return function(option) {
20825 var sRoot = original.call(this, option);
20826 var shadowRootEl = index.shadowRoot(this);
20827 if (shadowRootEl && inDom(this)) manager.addShadowRoot(shadowRootEl, doc);
20828 return sRoot;
20829 };
20830 }));
20831 };
20832 _proto.reset = function reset() {
20833 this.restoreHandlers.forEach(function(handler) {
20834 try {
20835 handler();
20836 } catch (e2) {}
20837 });
20838 this.restoreHandlers = [];
20839 this.shadowDoms = /* @__PURE__ */ new WeakSet();
20840 };
20841 return ShadowDomManager;
20842 }();
20843 var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
20844 var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
20845 for(var i$1 = 0; i$1 < chars.length; i$1++){
20846 lookup[chars.charCodeAt(i$1)] = i$1;
20847 }
20848 var encode = function encode(arraybuffer) {
20849 var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
20850 for(i2 = 0; i2 < len; i2 += 3){
20851 base64 += chars[bytes[i2] >> 2];
20852 base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
20853 base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
20854 base64 += chars[bytes[i2 + 2] & 63];
20855 }
20856 if (len % 3 === 2) {
20857 base64 = base64.substring(0, base64.length - 1) + "=";
20858 } else if (len % 3 === 1) {
20859 base64 = base64.substring(0, base64.length - 2) + "==";
20860 }
20861 return base64;
20862 };
20863 var canvasVarMap = /* @__PURE__ */ new Map();
20864 function variableListFor$1(ctx, ctor) {
20865 var contextMap = canvasVarMap.get(ctx);
20866 if (!contextMap) {
20867 contextMap = /* @__PURE__ */ new Map();
20868 canvasVarMap.set(ctx, contextMap);
20869 }
20870 if (!contextMap.has(ctor)) {
20871 contextMap.set(ctor, []);
20872 }
20873 return contextMap.get(ctor);
20874 }
20875 var saveWebGLVar = function(value, win, ctx) {
20876 if (!value || !(isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object")) return;
20877 var name = value.constructor.name;
20878 var list2 = variableListFor$1(ctx, name);
20879 var index2 = list2.indexOf(value);
20880 if (index2 === -1) {
20881 index2 = list2.length;
20882 list2.push(value);
20883 }
20884 return index2;
20885 };
20886 function serializeArg(value, win, ctx) {
20887 if (_instanceof(value, Array)) {
20888 return value.map(function(arg) {
20889 return serializeArg(arg, win, ctx);
20890 });
20891 } else if (value === null) {
20892 return value;
20893 } 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)) {
20894 var name = value.constructor.name;
20895 return {
20896 rr_type: name,
20897 args: [
20898 Object.values(value)
20899 ]
20900 };
20901 } else if (// SharedArrayBuffer disabled on most browsers due to spectre.
20902 // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer
20903 // value instanceof SharedArrayBuffer ||
20904 _instanceof(value, ArrayBuffer)) {
20905 var name1 = value.constructor.name;
20906 var base64 = encode(value);
20907 return {
20908 rr_type: name1,
20909 base64: base64
20910 };
20911 } else if (_instanceof(value, DataView)) {
20912 var name2 = value.constructor.name;
20913 return {
20914 rr_type: name2,
20915 args: [
20916 serializeArg(value.buffer, win, ctx),
20917 value.byteOffset,
20918 value.byteLength
20919 ]
20920 };
20921 } else if (_instanceof(value, HTMLImageElement)) {
20922 var name3 = value.constructor.name;
20923 var src = value.src;
20924 return {
20925 rr_type: name3,
20926 src: src
20927 };
20928 } else if (_instanceof(value, HTMLCanvasElement)) {
20929 var name4 = "HTMLImageElement";
20930 var src1 = value.toDataURL();
20931 return {
20932 rr_type: name4,
20933 src: src1
20934 };
20935 } else if (_instanceof(value, ImageData)) {
20936 var name5 = value.constructor.name;
20937 return {
20938 rr_type: name5,
20939 args: [
20940 serializeArg(value.data, win, ctx),
20941 value.width,
20942 value.height
20943 ]
20944 };
20945 } else if (isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
20946 var name6 = value.constructor.name;
20947 var index2 = saveWebGLVar(value, win, ctx);
20948 return {
20949 rr_type: name6,
20950 index: index2
20951 };
20952 }
20953 return value;
20954 }
20955 var serializeArgs = function(args, win, ctx) {
20956 return args.map(function(arg) {
20957 return serializeArg(arg, win, ctx);
20958 });
20959 };
20960 var isInstanceOfWebGLObject = function(value, win) {
20961 var webGLConstructorNames = [
20962 "WebGLActiveInfo",
20963 "WebGLBuffer",
20964 "WebGLFramebuffer",
20965 "WebGLProgram",
20966 "WebGLRenderbuffer",
20967 "WebGLShader",
20968 "WebGLShaderPrecisionFormat",
20969 "WebGLTexture",
20970 "WebGLUniformLocation",
20971 "WebGLVertexArrayObject",
20972 // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.
20973 "WebGLVertexArrayObjectOES"
20974 ];
20975 var supportedWebGLConstructorNames = webGLConstructorNames.filter(function(name) {
20976 return typeof win[name] === "function";
20977 });
20978 return Boolean(supportedWebGLConstructorNames.find(function(name) {
20979 return _instanceof(value, win[name]);
20980 }));
20981 };
20982 function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
20983 var _loop = function() {
20984 var prop = _step.value;
20985 try {
20986 if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
20987 return "continue";
20988 }
20989 var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
20990 return function() {
20991 var _this = this;
20992 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
20993 args[_key] = arguments[_key];
20994 }
20995 if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
20996 setTimeout(function() {
20997 var recordArgs = serializeArgs(args, win, _this);
20998 cb(_this.canvas, {
20999 type: CanvasContext["2D"],
21000 property: prop,
21001 args: recordArgs
21002 });
21003 }, 0);
21004 }
21005 return original.apply(this, args);
21006 };
21007 });
21008 handlers.push(restoreHandler);
21009 } catch (e) {
21010 var hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
21011 set: function set(v2) {
21012 cb(this.canvas, {
21013 type: CanvasContext["2D"],
21014 property: prop,
21015 args: [
21016 v2
21017 ],
21018 setter: true
21019 });
21020 }
21021 });
21022 handlers.push(hookHandler);
21023 }
21024 };
21025 var handlers = [];
21026 var props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
21027 for(var _iterator = _create_for_of_iterator_helper_loose(props2D), _step; !(_step = _iterator()).done;)_loop();
21028 return function() {
21029 handlers.forEach(function(h) {
21030 return h();
21031 });
21032 };
21033 }
21034 function getNormalizedContextName(contextType) {
21035 return contextType === "experimental-webgl" ? "webgl" : contextType;
21036 }
21037 function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
21038 var handlers = [];
21039 try {
21040 var restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
21041 return function(contextType) {
21042 for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
21043 args[_key - 1] = arguments[_key];
21044 }
21045 if (!isBlocked(this, blockClass, blockSelector, true)) {
21046 var ctxName = getNormalizedContextName(contextType);
21047 if (!("__context" in this)) this.__context = ctxName;
21048 if (setPreserveDrawingBufferToTrue && [
21049 "webgl",
21050 "webgl2"
21051 ].includes(ctxName)) {
21052 if (args[0] && _type_of(args[0]) === "object") {
21053 var contextAttributes = args[0];
21054 if (!contextAttributes.preserveDrawingBuffer) {
21055 contextAttributes.preserveDrawingBuffer = true;
21056 }
21057 } else {
21058 args.splice(0, 1, {
21059 preserveDrawingBuffer: true
21060 });
21061 }
21062 }
21063 }
21064 return original.apply(this, [].concat([
21065 contextType
21066 ], args));
21067 };
21068 });
21069 handlers.push(restoreHandler);
21070 } catch (e) {
21071 console.error("failed to patch HTMLCanvasElement.prototype.getContext");
21072 }
21073 return function() {
21074 handlers.forEach(function(h) {
21075 return h();
21076 });
21077 };
21078 }
21079 function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
21080 var _loop = function() {
21081 var prop = _step.value;
21082 if (//prop.startsWith('get') || // e.g. getProgramParameter, but too risky
21083 [
21084 "isContextLost",
21085 "canvas",
21086 "drawingBufferWidth",
21087 "drawingBufferHeight"
21088 ].includes(prop)) {
21089 return "continue";
21090 }
21091 try {
21092 if (typeof prototype[prop] !== "function") {
21093 return "continue";
21094 }
21095 var restoreHandler = patch(prototype, prop, function(original) {
21096 return function() {
21097 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21098 args[_key] = arguments[_key];
21099 }
21100 var result2 = original.apply(this, args);
21101 saveWebGLVar(result2, win, this);
21102 if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
21103 var recordArgs = serializeArgs(args, win, this);
21104 var mutation = {
21105 type: type,
21106 property: prop,
21107 args: recordArgs
21108 };
21109 cb(this.canvas, mutation);
21110 }
21111 return result2;
21112 };
21113 });
21114 handlers.push(restoreHandler);
21115 } catch (e) {
21116 var hookHandler = hookSetter(prototype, prop, {
21117 set: function set(v2) {
21118 cb(this.canvas, {
21119 type: type,
21120 property: prop,
21121 args: [
21122 v2
21123 ],
21124 setter: true
21125 });
21126 }
21127 });
21128 handlers.push(hookHandler);
21129 }
21130 };
21131 var handlers = [];
21132 var props = Object.getOwnPropertyNames(prototype);
21133 for(var _iterator = _create_for_of_iterator_helper_loose(props), _step; !(_step = _iterator()).done;)_loop();
21134 return handlers;
21135 }
21136 function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
21137 var _handlers;
21138 var handlers = [];
21139 (_handlers = handlers).push.apply(_handlers, [].concat(patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, blockSelector, win)));
21140 if (typeof win.WebGL2RenderingContext !== "undefined") {
21141 var _handlers1;
21142 (_handlers1 = handlers).push.apply(_handlers1, [].concat(patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, blockSelector, win)));
21143 }
21144 return function() {
21145 handlers.forEach(function(h) {
21146 return h();
21147 });
21148 };
21149 }
21150 var encodedJs = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=";
21151 var decodeBase64 = function(base64) {
21152 return Uint8Array.from(atob(base64), function(c2) {
21153 return c2.charCodeAt(0);
21154 });
21155 };
21156 var blob = typeof window !== "undefined" && window.Blob && new Blob([
21157 decodeBase64(encodedJs)
21158 ], {
21159 type: "text/javascript;charset=utf-8"
21160 });
21161 function WorkerWrapper(options) {
21162 var objURL;
21163 try {
21164 objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
21165 if (!objURL) throw "";
21166 var worker = new Worker(objURL, {
21167 name: options == null ? void 0 : options.name
21168 });
21169 worker.addEventListener("error", function() {
21170 (window.URL || window.webkitURL).revokeObjectURL(objURL);
21171 });
21172 return worker;
21173 } catch (e2) {
21174 return new Worker("data:text/javascript;base64," + encodedJs, {
21175 name: options == null ? void 0 : options.name
21176 });
21177 } finally{
21178 objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
21179 }
21180 }
21181 var CanvasManager = /*#__PURE__*/ function() {
21182 function CanvasManager(options) {
21183 var _this = this;
21184 __publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
21185 __publicField(this, "rafStamps", {
21186 latestId: 0,
21187 invokeId: null
21188 });
21189 __publicField(this, "mirror");
21190 __publicField(this, "mutationCb");
21191 __publicField(this, "resetObservers");
21192 __publicField(this, "frozen", false);
21193 __publicField(this, "locked", false);
21194 __publicField(this, "processMutation", function(target, mutation) {
21195 var newFrame = _this.rafStamps.invokeId && _this.rafStamps.latestId !== _this.rafStamps.invokeId;
21196 if (newFrame || !_this.rafStamps.invokeId) _this.rafStamps.invokeId = _this.rafStamps.latestId;
21197 if (!_this.pendingCanvasMutations.has(target)) {
21198 _this.pendingCanvasMutations.set(target, []);
21199 }
21200 _this.pendingCanvasMutations.get(target).push(mutation);
21201 });
21202 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;
21203 this.mutationCb = options.mutationCb;
21204 this.mirror = options.mirror;
21205 if (recordCanvas && sampling === "all") this.initCanvasMutationObserver(win, blockClass, blockSelector);
21206 if (recordCanvas && typeof sampling === "number") this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
21207 dataURLOptions: dataURLOptions
21208 });
21209 }
21210 var _proto = CanvasManager.prototype;
21211 _proto.reset = function reset() {
21212 this.pendingCanvasMutations.clear();
21213 this.resetObservers && this.resetObservers();
21214 };
21215 _proto.freeze = function freeze() {
21216 this.frozen = true;
21217 };
21218 _proto.unfreeze = function unfreeze() {
21219 this.frozen = false;
21220 };
21221 _proto.lock = function lock() {
21222 this.locked = true;
21223 };
21224 _proto.unlock = function unlock() {
21225 this.locked = false;
21226 };
21227 _proto.initCanvasFPSObserver = function initCanvasFPSObserver(fps, win, blockClass, blockSelector, options) {
21228 var _this = this;
21229 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, true);
21230 var snapshotInProgressMap = /* @__PURE__ */ new Map();
21231 var worker = new WorkerWrapper();
21232 worker.onmessage = function(e2) {
21233 var id = e2.data.id;
21234 snapshotInProgressMap.set(id, false);
21235 if (!("base64" in e2.data)) return;
21236 var _e2_data = e2.data, base64 = _e2_data.base64, type = _e2_data.type, width = _e2_data.width, height = _e2_data.height;
21237 _this.mutationCb({
21238 id: id,
21239 type: CanvasContext["2D"],
21240 commands: [
21241 {
21242 property: "clearRect",
21243 // wipe canvas
21244 args: [
21245 0,
21246 0,
21247 width,
21248 height
21249 ]
21250 },
21251 {
21252 property: "drawImage",
21253 // draws (semi-transparent) image
21254 args: [
21255 {
21256 rr_type: "ImageBitmap",
21257 args: [
21258 {
21259 rr_type: "Blob",
21260 data: [
21261 {
21262 rr_type: "ArrayBuffer",
21263 base64: base64
21264 }
21265 ],
21266 type: type
21267 }
21268 ]
21269 },
21270 0,
21271 0
21272 ]
21273 }
21274 ]
21275 });
21276 };
21277 var timeBetweenSnapshots = 1e3 / fps;
21278 var lastSnapshotTime = 0;
21279 var rafId;
21280 var getCanvas = function() {
21281 var matchedCanvas = [];
21282 win.document.querySelectorAll("canvas").forEach(function(canvas) {
21283 if (!isBlocked(canvas, blockClass, blockSelector, true)) {
21284 matchedCanvas.push(canvas);
21285 }
21286 });
21287 return matchedCanvas;
21288 };
21289 var takeCanvasSnapshots = function(timestamp) {
21290 if (lastSnapshotTime && timestamp - lastSnapshotTime < timeBetweenSnapshots) {
21291 rafId = requestAnimationFrame(takeCanvasSnapshots);
21292 return;
21293 }
21294 lastSnapshotTime = timestamp;
21295 var _this1 = _this;
21296 getCanvas().forEach(/*#__PURE__*/ _async_to_generator(function(canvas) {
21297 var _a2, id, context, bitmap;
21298 return _ts_generator(this, function(_state) {
21299 switch(_state.label){
21300 case 0:
21301 id = _this1.mirror.getId(canvas);
21302 if (snapshotInProgressMap.get(id)) return [
21303 2
21304 ];
21305 if (canvas.width === 0 || canvas.height === 0) return [
21306 2
21307 ];
21308 snapshotInProgressMap.set(id, true);
21309 if ([
21310 "webgl",
21311 "webgl2"
21312 ].includes(canvas.__context)) {
21313 context = canvas.getContext(canvas.__context);
21314 if (((_a2 = context == null ? void 0 : context.getContextAttributes()) == null ? void 0 : _a2.preserveDrawingBuffer) === false) {
21315 context.clear(context.COLOR_BUFFER_BIT);
21316 }
21317 }
21318 return [
21319 4,
21320 createImageBitmap(canvas)
21321 ];
21322 case 1:
21323 bitmap = _state.sent();
21324 worker.postMessage({
21325 id: id,
21326 bitmap: bitmap,
21327 width: canvas.width,
21328 height: canvas.height,
21329 dataURLOptions: options.dataURLOptions
21330 }, [
21331 bitmap
21332 ]);
21333 return [
21334 2
21335 ];
21336 }
21337 });
21338 }));
21339 rafId = requestAnimationFrame(takeCanvasSnapshots);
21340 };
21341 rafId = requestAnimationFrame(takeCanvasSnapshots);
21342 this.resetObservers = function() {
21343 canvasContextReset();
21344 cancelAnimationFrame(rafId);
21345 };
21346 };
21347 _proto.initCanvasMutationObserver = function initCanvasMutationObserver(win, blockClass, blockSelector) {
21348 this.startRAFTimestamping();
21349 this.startPendingCanvasMutationFlusher();
21350 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, false);
21351 var canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21352 var canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21353 this.resetObservers = function() {
21354 canvasContextReset();
21355 canvas2DReset();
21356 canvasWebGL1and2Reset();
21357 };
21358 };
21359 _proto.startPendingCanvasMutationFlusher = function startPendingCanvasMutationFlusher() {
21360 var _this = this;
21361 requestAnimationFrame(function() {
21362 return _this.flushPendingCanvasMutations();
21363 });
21364 };
21365 _proto.startRAFTimestamping = function startRAFTimestamping() {
21366 var _this = this;
21367 var setLatestRAFTimestamp = function(timestamp) {
21368 _this.rafStamps.latestId = timestamp;
21369 requestAnimationFrame(setLatestRAFTimestamp);
21370 };
21371 requestAnimationFrame(setLatestRAFTimestamp);
21372 };
21373 _proto.flushPendingCanvasMutations = function flushPendingCanvasMutations() {
21374 var _this = this;
21375 this.pendingCanvasMutations.forEach(function(_values, canvas) {
21376 var id = _this.mirror.getId(canvas);
21377 _this.flushPendingCanvasMutationFor(canvas, id);
21378 });
21379 requestAnimationFrame(function() {
21380 return _this.flushPendingCanvasMutations();
21381 });
21382 };
21383 _proto.flushPendingCanvasMutationFor = function flushPendingCanvasMutationFor(canvas, id) {
21384 if (this.frozen || this.locked) {
21385 return;
21386 }
21387 var valuesWithType = this.pendingCanvasMutations.get(canvas);
21388 if (!valuesWithType || id === -1) return;
21389 var values = valuesWithType.map(function(value) {
21390 value.type; var rest = _object_without_properties_loose(value, [
21391 "type"
21392 ]);
21393 return rest;
21394 });
21395 var type = valuesWithType[0].type;
21396 this.mutationCb({
21397 id: id,
21398 type: type,
21399 commands: values
21400 });
21401 this.pendingCanvasMutations.delete(canvas);
21402 };
21403 return CanvasManager;
21404 }();
21405 var StylesheetManager = /*#__PURE__*/ function() {
21406 function StylesheetManager(options) {
21407 __publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
21408 __publicField(this, "mutationCb");
21409 __publicField(this, "adoptedStyleSheetCb");
21410 __publicField(this, "styleMirror", new StyleSheetMirror());
21411 this.mutationCb = options.mutationCb;
21412 this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
21413 }
21414 var _proto = StylesheetManager.prototype;
21415 _proto.attachLinkElement = function attachLinkElement(linkEl, childSn) {
21416 if ("_cssText" in childSn.attributes) this.mutationCb({
21417 adds: [],
21418 removes: [],
21419 texts: [],
21420 attributes: [
21421 {
21422 id: childSn.id,
21423 attributes: childSn.attributes
21424 }
21425 ]
21426 });
21427 this.trackLinkElement(linkEl);
21428 };
21429 _proto.trackLinkElement = function trackLinkElement(linkEl) {
21430 if (this.trackedLinkElements.has(linkEl)) return;
21431 this.trackedLinkElements.add(linkEl);
21432 this.trackStylesheetInLinkElement(linkEl);
21433 };
21434 _proto.adoptStyleSheets = function adoptStyleSheets(sheets, hostId) {
21435 var _this, _loop = function() {
21436 var sheet = _step.value;
21437 var styleId = void 0;
21438 if (!_this.styleMirror.has(sheet)) {
21439 styleId = _this.styleMirror.add(sheet);
21440 styles.push({
21441 styleId: styleId,
21442 rules: Array.from(sheet.rules || CSSRule, function(r2, index2) {
21443 return {
21444 rule: stringifyRule(r2, sheet.href),
21445 index: index2
21446 };
21447 })
21448 });
21449 } else styleId = _this.styleMirror.getId(sheet);
21450 adoptedStyleSheetData.styleIds.push(styleId);
21451 };
21452 if (sheets.length === 0) return;
21453 var adoptedStyleSheetData = {
21454 id: hostId,
21455 styleIds: []
21456 };
21457 var styles = [];
21458 for(var _iterator = _create_for_of_iterator_helper_loose(sheets), _step; !(_step = _iterator()).done;)_this = this, _loop();
21459 if (styles.length > 0) adoptedStyleSheetData.styles = styles;
21460 this.adoptedStyleSheetCb(adoptedStyleSheetData);
21461 };
21462 _proto.reset = function reset() {
21463 this.styleMirror.reset();
21464 this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
21465 };
21466 // TODO: take snapshot on stylesheet reload by applying event listener
21467 _proto.trackStylesheetInLinkElement = function trackStylesheetInLinkElement(_linkEl) {};
21468 return StylesheetManager;
21469 }();
21470 var ProcessedNodeManager = /*#__PURE__*/ function() {
21471 function ProcessedNodeManager() {
21472 __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap());
21473 __publicField(this, "active", false);
21474 }
21475 var _proto = ProcessedNodeManager.prototype;
21476 _proto.inOtherBuffer = function inOtherBuffer(node2, thisBuffer) {
21477 var buffers = this.nodeMap.get(node2);
21478 return buffers && Array.from(buffers).some(function(buffer) {
21479 return buffer !== thisBuffer;
21480 });
21481 };
21482 _proto.add = function add(node2, buffer) {
21483 var _this = this;
21484 if (!this.active) {
21485 this.active = true;
21486 requestAnimationFrame(function() {
21487 _this.nodeMap = /* @__PURE__ */ new WeakMap();
21488 _this.active = false;
21489 });
21490 }
21491 this.nodeMap.set(node2, (this.nodeMap.get(node2) || /* @__PURE__ */ new Set()).add(buffer));
21492 };
21493 _proto.destroy = function destroy() {};
21494 return ProcessedNodeManager;
21495 }();
21496 var wrappedEmit;
21497 var takeFullSnapshot$1;
21498 var canvasManager;
21499 var recording = false;
21500 try {
21501 if (Array.from([
21502 1
21503 ], function(x2) {
21504 return x2 * 2;
21505 })[0] !== 2) {
21506 var cleanFrame = document.createElement("iframe");
21507 document.body.appendChild(cleanFrame);
21508 Array.from = ((_a = cleanFrame.contentWindow) == null ? void 0 : _a.Array.from) || Array.from;
21509 document.body.removeChild(cleanFrame);
21510 }
21511 } catch (err) {
21512 console.debug("Unable to override Array.from", err);
21513 }
21514 var mirror = createMirror$2();
21515 function record(options) {
21516 if (options === void 0) options = {};
21517 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() {
21518 return false;
21519 } : _options_keepIframeSrcFn, _options_ignoreCSSAttributes = options.ignoreCSSAttributes, ignoreCSSAttributes = _options_ignoreCSSAttributes === void 0 ? /* @__PURE__ */ new Set([]) : _options_ignoreCSSAttributes, errorHandler2 = options.errorHandler;
21520 registerErrorHandler(errorHandler2);
21521 var inEmittingFrame = recordCrossOriginIframes ? window.parent === window : true;
21522 var passEmitsToParent = false;
21523 if (!inEmittingFrame) {
21524 try {
21525 if (window.parent.document) {
21526 passEmitsToParent = false;
21527 }
21528 } catch (e2) {
21529 passEmitsToParent = true;
21530 }
21531 }
21532 if (inEmittingFrame && !emit) {
21533 throw new Error("emit function is required");
21534 }
21535 if (!inEmittingFrame && !passEmitsToParent) {
21536 return function() {};
21537 }
21538 if (mousemoveWait !== void 0 && sampling.mousemove === void 0) {
21539 sampling.mousemove = mousemoveWait;
21540 }
21541 mirror.reset();
21542 var maskInputOptions = maskAllInputs === true ? {
21543 color: true,
21544 date: true,
21545 "datetime-local": true,
21546 email: true,
21547 month: true,
21548 number: true,
21549 range: true,
21550 search: true,
21551 tel: true,
21552 text: true,
21553 time: true,
21554 url: true,
21555 week: true,
21556 textarea: true,
21557 select: true,
21558 password: true,
21559 hidden: true
21560 } : _maskInputOptions !== void 0 ? _maskInputOptions : {
21561 password: true
21562 };
21563 var slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
21564 script: true,
21565 comment: true,
21566 headFavicon: true,
21567 headWhitespace: true,
21568 headMetaSocial: true,
21569 headMetaRobots: true,
21570 headMetaHttpEquiv: true,
21571 headMetaVerification: true,
21572 // the following are off for slimDOMOptions === true,
21573 // as they destroy some (hidden) info:
21574 headMetaAuthorship: _slimDOMOptions === "all",
21575 headMetaDescKeywords: _slimDOMOptions === "all",
21576 headTitleMutations: _slimDOMOptions === "all"
21577 } : _slimDOMOptions ? _slimDOMOptions : {};
21578 polyfill$1();
21579 var lastFullSnapshotEvent;
21580 var incrementalSnapshotCount = 0;
21581 var eventProcessor = function(e2) {
21582 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
21583 var plugin3 = _step.value;
21584 if (plugin3.eventProcessor) {
21585 e2 = plugin3.eventProcessor(e2);
21586 }
21587 }
21588 if (packFn && // Disable packing events which will be emitted to parent frames.
21589 !passEmitsToParent) {
21590 e2 = packFn(e2);
21591 }
21592 return e2;
21593 };
21594 wrappedEmit = function(r2, isCheckout) {
21595 var _a2;
21596 var e2 = r2;
21597 e2.timestamp = nowTimestamp();
21598 if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
21599 mutationBuffers.forEach(function(buf) {
21600 return buf.unfreeze();
21601 });
21602 }
21603 if (inEmittingFrame) {
21604 emit == null ? void 0 : emit(eventProcessor(e2), isCheckout);
21605 } else if (passEmitsToParent) {
21606 var message = {
21607 type: "rrweb",
21608 event: eventProcessor(e2),
21609 origin: window.location.origin,
21610 isCheckout: isCheckout
21611 };
21612 window.parent.postMessage(message, "*");
21613 }
21614 if (e2.type === EventType.FullSnapshot) {
21615 lastFullSnapshotEvent = e2;
21616 incrementalSnapshotCount = 0;
21617 } else if (e2.type === EventType.IncrementalSnapshot) {
21618 if (e2.data.source === IncrementalSource.Mutation && e2.data.isAttachIframe) {
21619 return;
21620 }
21621 incrementalSnapshotCount++;
21622 var exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
21623 var exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
21624 if (exceedCount || exceedTime) {
21625 takeFullSnapshot$1(true);
21626 }
21627 }
21628 };
21629 var wrappedMutationEmit = function(m) {
21630 wrappedEmit({
21631 type: EventType.IncrementalSnapshot,
21632 data: _extends({
21633 source: IncrementalSource.Mutation
21634 }, m)
21635 });
21636 };
21637 var wrappedScrollEmit = function(p) {
21638 return wrappedEmit({
21639 type: EventType.IncrementalSnapshot,
21640 data: _extends({
21641 source: IncrementalSource.Scroll
21642 }, p)
21643 });
21644 };
21645 var wrappedCanvasMutationEmit = function(p) {
21646 return wrappedEmit({
21647 type: EventType.IncrementalSnapshot,
21648 data: _extends({
21649 source: IncrementalSource.CanvasMutation
21650 }, p)
21651 });
21652 };
21653 var wrappedAdoptedStyleSheetEmit = function(a2) {
21654 return wrappedEmit({
21655 type: EventType.IncrementalSnapshot,
21656 data: _extends({
21657 source: IncrementalSource.AdoptedStyleSheet
21658 }, a2)
21659 });
21660 };
21661 var stylesheetManager = new StylesheetManager({
21662 mutationCb: wrappedMutationEmit,
21663 adoptedStyleSheetCb: wrappedAdoptedStyleSheetEmit
21664 });
21665 var iframeManager = new IframeManager({
21666 mirror: mirror,
21667 mutationCb: wrappedMutationEmit,
21668 stylesheetManager: stylesheetManager,
21669 recordCrossOriginIframes: recordCrossOriginIframes,
21670 wrappedEmit: wrappedEmit
21671 });
21672 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
21673 var plugin3 = _step.value;
21674 if (plugin3.getMirror) plugin3.getMirror({
21675 nodeMirror: mirror,
21676 crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,
21677 crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror
21678 });
21679 }
21680 var processedNodeManager = new ProcessedNodeManager();
21681 canvasManager = new CanvasManager({
21682 recordCanvas: recordCanvas,
21683 mutationCb: wrappedCanvasMutationEmit,
21684 win: window,
21685 blockClass: blockClass,
21686 blockSelector: blockSelector,
21687 mirror: mirror,
21688 sampling: sampling.canvas,
21689 dataURLOptions: dataURLOptions
21690 });
21691 var shadowDomManager = new ShadowDomManager({
21692 mutationCb: wrappedMutationEmit,
21693 scrollCb: wrappedScrollEmit,
21694 bypassOptions: {
21695 blockClass: blockClass,
21696 blockSelector: blockSelector,
21697 maskTextClass: maskTextClass,
21698 maskTextSelector: maskTextSelector,
21699 inlineStylesheet: inlineStylesheet,
21700 maskInputOptions: maskInputOptions,
21701 dataURLOptions: dataURLOptions,
21702 maskTextFn: maskTextFn,
21703 maskInputFn: maskInputFn,
21704 recordCanvas: recordCanvas,
21705 inlineImages: inlineImages,
21706 sampling: sampling,
21707 slimDOMOptions: slimDOMOptions,
21708 iframeManager: iframeManager,
21709 stylesheetManager: stylesheetManager,
21710 canvasManager: canvasManager,
21711 keepIframeSrcFn: keepIframeSrcFn,
21712 processedNodeManager: processedNodeManager
21713 },
21714 mirror: mirror
21715 });
21716 takeFullSnapshot$1 = function(isCheckout) {
21717 if (isCheckout === void 0) isCheckout = false;
21718 if (!recordDOM) {
21719 return;
21720 }
21721 wrappedEmit({
21722 type: EventType.Meta,
21723 data: {
21724 href: window.location.href,
21725 width: getWindowWidth(),
21726 height: getWindowHeight()
21727 }
21728 }, isCheckout);
21729 stylesheetManager.reset();
21730 shadowDomManager.init();
21731 mutationBuffers.forEach(function(buf) {
21732 return buf.lock();
21733 });
21734 var node2 = snapshot(document, {
21735 mirror: mirror,
21736 blockClass: blockClass,
21737 blockSelector: blockSelector,
21738 maskTextClass: maskTextClass,
21739 maskTextSelector: maskTextSelector,
21740 inlineStylesheet: inlineStylesheet,
21741 maskAllInputs: maskInputOptions,
21742 maskTextFn: maskTextFn,
21743 maskInputFn: maskInputFn,
21744 slimDOM: slimDOMOptions,
21745 dataURLOptions: dataURLOptions,
21746 recordCanvas: recordCanvas,
21747 inlineImages: inlineImages,
21748 onSerialize: function(n2) {
21749 if (isSerializedIframe(n2, mirror)) {
21750 iframeManager.addIframe(n2);
21751 }
21752 if (isSerializedStylesheet(n2, mirror)) {
21753 stylesheetManager.trackLinkElement(n2);
21754 }
21755 if (hasShadowRoot(n2)) {
21756 shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
21757 }
21758 },
21759 onIframeLoad: function(iframe, childSn) {
21760 iframeManager.attachIframe(iframe, childSn);
21761 shadowDomManager.observeAttachShadow(iframe);
21762 },
21763 onStylesheetLoad: function(linkEl, childSn) {
21764 stylesheetManager.attachLinkElement(linkEl, childSn);
21765 },
21766 keepIframeSrcFn: keepIframeSrcFn
21767 });
21768 if (!node2) {
21769 return console.warn("Failed to snapshot the document");
21770 }
21771 wrappedEmit({
21772 type: EventType.FullSnapshot,
21773 data: {
21774 node: node2,
21775 initialOffset: getWindowScroll(window)
21776 }
21777 }, isCheckout);
21778 mutationBuffers.forEach(function(buf) {
21779 return buf.unlock();
21780 });
21781 if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0) stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.getId(document));
21782 };
21783 try {
21784 var handlers = [];
21785 var observe = function(doc) {
21786 var _a2;
21787 return callbackWrapper(initObservers)({
21788 mutationCb: wrappedMutationEmit,
21789 mousemoveCb: function(positions, source) {
21790 return wrappedEmit({
21791 type: EventType.IncrementalSnapshot,
21792 data: {
21793 source: source,
21794 positions: positions
21795 }
21796 });
21797 },
21798 mouseInteractionCb: function(d) {
21799 return wrappedEmit({
21800 type: EventType.IncrementalSnapshot,
21801 data: _extends({
21802 source: IncrementalSource.MouseInteraction
21803 }, d)
21804 });
21805 },
21806 scrollCb: wrappedScrollEmit,
21807 viewportResizeCb: function(d) {
21808 return wrappedEmit({
21809 type: EventType.IncrementalSnapshot,
21810 data: _extends({
21811 source: IncrementalSource.ViewportResize
21812 }, d)
21813 });
21814 },
21815 inputCb: function(v2) {
21816 return wrappedEmit({
21817 type: EventType.IncrementalSnapshot,
21818 data: _extends({
21819 source: IncrementalSource.Input
21820 }, v2)
21821 });
21822 },
21823 mediaInteractionCb: function(p) {
21824 return wrappedEmit({
21825 type: EventType.IncrementalSnapshot,
21826 data: _extends({
21827 source: IncrementalSource.MediaInteraction
21828 }, p)
21829 });
21830 },
21831 styleSheetRuleCb: function(r2) {
21832 return wrappedEmit({
21833 type: EventType.IncrementalSnapshot,
21834 data: _extends({
21835 source: IncrementalSource.StyleSheetRule
21836 }, r2)
21837 });
21838 },
21839 styleDeclarationCb: function(r2) {
21840 return wrappedEmit({
21841 type: EventType.IncrementalSnapshot,
21842 data: _extends({
21843 source: IncrementalSource.StyleDeclaration
21844 }, r2)
21845 });
21846 },
21847 canvasMutationCb: wrappedCanvasMutationEmit,
21848 fontCb: function(p) {
21849 return wrappedEmit({
21850 type: EventType.IncrementalSnapshot,
21851 data: _extends({
21852 source: IncrementalSource.Font
21853 }, p)
21854 });
21855 },
21856 selectionCb: function(p) {
21857 wrappedEmit({
21858 type: EventType.IncrementalSnapshot,
21859 data: _extends({
21860 source: IncrementalSource.Selection
21861 }, p)
21862 });
21863 },
21864 customElementCb: function(c2) {
21865 wrappedEmit({
21866 type: EventType.IncrementalSnapshot,
21867 data: _extends({
21868 source: IncrementalSource.CustomElement
21869 }, c2)
21870 });
21871 },
21872 blockClass: blockClass,
21873 ignoreClass: ignoreClass,
21874 ignoreSelector: ignoreSelector,
21875 maskTextClass: maskTextClass,
21876 maskTextSelector: maskTextSelector,
21877 maskInputOptions: maskInputOptions,
21878 inlineStylesheet: inlineStylesheet,
21879 sampling: sampling,
21880 recordDOM: recordDOM,
21881 recordCanvas: recordCanvas,
21882 inlineImages: inlineImages,
21883 userTriggeredOnInput: userTriggeredOnInput,
21884 collectFonts: collectFonts,
21885 doc: doc,
21886 maskInputFn: maskInputFn,
21887 maskTextFn: maskTextFn,
21888 keepIframeSrcFn: keepIframeSrcFn,
21889 blockSelector: blockSelector,
21890 slimDOMOptions: slimDOMOptions,
21891 dataURLOptions: dataURLOptions,
21892 mirror: mirror,
21893 iframeManager: iframeManager,
21894 stylesheetManager: stylesheetManager,
21895 shadowDomManager: shadowDomManager,
21896 processedNodeManager: processedNodeManager,
21897 canvasManager: canvasManager,
21898 ignoreCSSAttributes: ignoreCSSAttributes,
21899 plugins: ((_a2 = plugins == null ? void 0 : plugins.filter(function(p) {
21900 return p.observer;
21901 })) == null ? void 0 : _a2.map(function(p) {
21902 return {
21903 observer: p.observer,
21904 options: p.options,
21905 callback: function(payload) {
21906 return wrappedEmit({
21907 type: EventType.Plugin,
21908 data: {
21909 plugin: p.name,
21910 payload: payload
21911 }
21912 });
21913 }
21914 };
21915 })) || []
21916 }, hooks);
21917 };
21918 iframeManager.addLoadListener(function(iframeEl) {
21919 try {
21920 handlers.push(observe(iframeEl.contentDocument));
21921 } catch (error) {
21922 console.warn(error);
21923 }
21924 });
21925 var init = function() {
21926 takeFullSnapshot$1();
21927 handlers.push(observe(document));
21928 recording = true;
21929 };
21930 if (document.readyState === "interactive" || document.readyState === "complete") {
21931 init();
21932 } else {
21933 handlers.push(on("DOMContentLoaded", function() {
21934 wrappedEmit({
21935 type: EventType.DomContentLoaded,
21936 data: {}
21937 });
21938 if (recordAfter === "DOMContentLoaded") init();
21939 }));
21940 handlers.push(on("load", function() {
21941 wrappedEmit({
21942 type: EventType.Load,
21943 data: {}
21944 });
21945 if (recordAfter === "load") init();
21946 }, window));
21947 }
21948 return function() {
21949 handlers.forEach(function(handler) {
21950 try {
21951 handler();
21952 } catch (error) {
21953 var msg = String(error).toLowerCase();
21954 if (!msg.includes("cross-origin")) {
21955 console.warn(error);
21956 }
21957 }
21958 });
21959 processedNodeManager.destroy();
21960 recording = false;
21961 unregisterErrorHandler();
21962 };
21963 } catch (error) {
21964 console.warn(error);
21965 }
21966 }
21967 record.addCustomEvent = function(tag, payload) {
21968 if (!recording) {
21969 throw new Error("please add custom event after start recording");
21970 }
21971 wrappedEmit({
21972 type: EventType.Custom,
21973 data: {
21974 tag: tag,
21975 payload: payload
21976 }
21977 });
21978 };
21979 record.freezePage = function() {
21980 mutationBuffers.forEach(function(buf) {
21981 return buf.freeze();
21982 });
21983 };
21984 record.takeFullSnapshot = function(isCheckout) {
21985 if (!recording) {
21986 throw new Error("please take full snapshot after start recording");
21987 }
21988 takeFullSnapshot$1(isCheckout);
21989 };
21990 record.mirror = mirror;
21991 var n;
21992 !function(t2) {
21993 t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
21994 }(n || (n = {}));
21995 record.addCustomEvent;
21996 record.freezePage;
21997 record.takeFullSnapshot;
21998
21999 var setImmediate = win['setImmediate'];
22000 var builtInProp, cycle, schedulingQueue,
22001 ToString = Object.prototype.toString,
22002 timer = (typeof setImmediate !== 'undefined') ?
22003 function timer(fn) { return setImmediate(fn); } :
22004 setTimeout;
22005
22006 // dammit, IE8.
22007 try {
22008 Object.defineProperty({},'x',{});
22009 builtInProp = function builtInProp(obj,name,val,config) {
22010 return Object.defineProperty(obj,name,{
22011 value: val,
22012 writable: true,
22013 configurable: config !== false
22014 });
22015 };
22016 }
22017 catch (err) {
22018 builtInProp = function builtInProp(obj,name,val) {
22019 obj[name] = val;
22020 return obj;
22021 };
22022 }
22023
22024 // Note: using a queue instead of array for efficiency
22025 schedulingQueue = (function Queue() {
22026 var first, last, item;
22027
22028 function Item(fn,self) {
22029 this.fn = fn;
22030 this.self = self;
22031 this.next = void 0;
22032 }
22033
22034 return {
22035 add: function add(fn,self) {
22036 item = new Item(fn,self);
22037 if (last) {
22038 last.next = item;
22039 }
22040 else {
22041 first = item;
22042 }
22043 last = item;
22044 item = void 0;
22045 },
22046 drain: function drain() {
22047 var f = first;
22048 first = last = cycle = void 0;
22049
22050 while (f) {
22051 f.fn.call(f.self);
22052 f = f.next;
22053 }
22054 }
22055 };
22056 })();
22057
22058 function schedule(fn,self) {
22059 schedulingQueue.add(fn,self);
22060 if (!cycle) {
22061 cycle = timer(schedulingQueue.drain);
22062 }
22063 }
22064
22065 // promise duck typing
22066 function isThenable(o) {
22067 var _then, oType = typeof o;
22068
22069 if (o !== null && (oType === 'object' || oType === 'function')) {
22070 _then = o.then;
22071 }
22072 return typeof _then === 'function' ? _then : false;
22073 }
22074
22075 function notify() {
22076 for (var i=0; i<this.chain.length; i++) {
22077 notifyIsolated(
22078 this,
22079 (this.state === 1) ? this.chain[i].success : this.chain[i].failure,
22080 this.chain[i]
22081 );
22082 }
22083 this.chain.length = 0;
22084 }
22085
22086 // NOTE: This is a separate function to isolate
22087 // the `try..catch` so that other code can be
22088 // optimized better
22089 function notifyIsolated(self,cb,chain) {
22090 var ret, _then;
22091 try {
22092 if (cb === false) {
22093 chain.reject(self.msg);
22094 }
22095 else {
22096 if (cb === true) {
22097 ret = self.msg;
22098 }
22099 else {
22100 ret = cb.call(void 0,self.msg);
22101 }
22102
22103 if (ret === chain.promise) {
22104 chain.reject(TypeError('Promise-chain cycle'));
22105 }
22106 // eslint-disable-next-line no-cond-assign
22107 else if (_then = isThenable(ret)) {
22108 _then.call(ret,chain.resolve,chain.reject);
22109 }
22110 else {
22111 chain.resolve(ret);
22112 }
22113 }
22114 }
22115 catch (err) {
22116 chain.reject(err);
22117 }
22118 }
22119
22120 function resolve(msg) {
22121 var _then, self = this;
22122
22123 // already triggered?
22124 if (self.triggered) { return; }
22125
22126 self.triggered = true;
22127
22128 // unwrap
22129 if (self.def) {
22130 self = self.def;
22131 }
22132
22133 try {
22134 // eslint-disable-next-line no-cond-assign
22135 if (_then = isThenable(msg)) {
22136 schedule(function(){
22137 var defWrapper = new MakeDefWrapper(self);
22138 try {
22139 _then.call(msg,
22140 function $resolve$(){ resolve.apply(defWrapper,arguments); },
22141 function $reject$(){ reject.apply(defWrapper,arguments); }
22142 );
22143 }
22144 catch (err) {
22145 reject.call(defWrapper,err);
22146 }
22147 });
22148 }
22149 else {
22150 self.msg = msg;
22151 self.state = 1;
22152 if (self.chain.length > 0) {
22153 schedule(notify,self);
22154 }
22155 }
22156 }
22157 catch (err) {
22158 reject.call(new MakeDefWrapper(self),err);
22159 }
22160 }
22161
22162 function reject(msg) {
22163 var self = this;
22164
22165 // already triggered?
22166 if (self.triggered) { return; }
22167
22168 self.triggered = true;
22169
22170 // unwrap
22171 if (self.def) {
22172 self = self.def;
22173 }
22174
22175 self.msg = msg;
22176 self.state = 2;
22177 if (self.chain.length > 0) {
22178 schedule(notify,self);
22179 }
22180 }
22181
22182 function iteratePromises(Constructor,arr,resolver,rejecter) {
22183 for (var idx=0; idx<arr.length; idx++) {
22184 (function IIFE(idx){
22185 Constructor.resolve(arr[idx])
22186 .then(
22187 function $resolver$(msg){
22188 resolver(idx,msg);
22189 },
22190 rejecter
22191 );
22192 })(idx);
22193 }
22194 }
22195
22196 function MakeDefWrapper(self) {
22197 this.def = self;
22198 this.triggered = false;
22199 }
22200
22201 function MakeDef(self) {
22202 this.promise = self;
22203 this.state = 0;
22204 this.triggered = false;
22205 this.chain = [];
22206 this.msg = void 0;
22207 }
22208
22209 function NpoPromise(executor) {
22210 if (typeof executor !== 'function') {
22211 throw TypeError('Not a function');
22212 }
22213
22214 if (this['__NPO__'] !== 0) {
22215 throw TypeError('Not a promise');
22216 }
22217
22218 // instance shadowing the inherited "brand"
22219 // to signal an already "initialized" promise
22220 this['__NPO__'] = 1;
22221
22222 var def = new MakeDef(this);
22223
22224 this['then'] = function then(success,failure) {
22225 var o = {
22226 success: typeof success === 'function' ? success : true,
22227 failure: typeof failure === 'function' ? failure : false
22228 };
22229 // Note: `then(..)` itself can be borrowed to be used against
22230 // a different promise constructor for making the chained promise,
22231 // by substituting a different `this` binding.
22232 o.promise = new this.constructor(function extractChain(resolve,reject) {
22233 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22234 throw TypeError('Not a function');
22235 }
22236
22237 o.resolve = resolve;
22238 o.reject = reject;
22239 });
22240 def.chain.push(o);
22241
22242 if (def.state !== 0) {
22243 schedule(notify,def);
22244 }
22245
22246 return o.promise;
22247 };
22248 this['catch'] = function $catch$(failure) {
22249 return this.then(void 0,failure);
22250 };
22251
22252 try {
22253 executor.call(
22254 void 0,
22255 function publicResolve(msg){
22256 resolve.call(def,msg);
22257 },
22258 function publicReject(msg) {
22259 reject.call(def,msg);
22260 }
22261 );
22262 }
22263 catch (err) {
22264 reject.call(def,err);
22265 }
22266 }
22267
22268 var PromisePrototype = builtInProp({},'constructor',NpoPromise,
22269 /*configurable=*/false
22270 );
22271
22272 // Note: Android 4 cannot use `Object.defineProperty(..)` here
22273 NpoPromise.prototype = PromisePrototype;
22274
22275 // built-in "brand" to signal an "uninitialized" promise
22276 builtInProp(PromisePrototype,'__NPO__',0,
22277 /*configurable=*/false
22278 );
22279
22280 builtInProp(NpoPromise,'resolve',function Promise$resolve(msg) {
22281 var Constructor = this;
22282
22283 // spec mandated checks
22284 // note: best "isPromise" check that's practical for now
22285 if (msg && typeof msg === 'object' && msg['__NPO__'] === 1) {
22286 return msg;
22287 }
22288
22289 return new Constructor(function executor(resolve,reject){
22290 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22291 throw TypeError('Not a function');
22292 }
22293
22294 resolve(msg);
22295 });
22296 });
22297
22298 builtInProp(NpoPromise,'reject',function Promise$reject(msg) {
22299 return new this(function executor(resolve,reject){
22300 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22301 throw TypeError('Not a function');
22302 }
22303
22304 reject(msg);
22305 });
22306 });
22307
22308 builtInProp(NpoPromise,'all',function Promise$all(arr) {
22309 var Constructor = this;
22310
22311 // spec mandated checks
22312 if (ToString.call(arr) !== '[object Array]') {
22313 return Constructor.reject(TypeError('Not an array'));
22314 }
22315 if (arr.length === 0) {
22316 return Constructor.resolve([]);
22317 }
22318
22319 return new Constructor(function executor(resolve,reject){
22320 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22321 throw TypeError('Not a function');
22322 }
22323
22324 var len = arr.length, msgs = Array(len), count = 0;
22325
22326 iteratePromises(Constructor,arr,function resolver(idx,msg) {
22327 msgs[idx] = msg;
22328 if (++count === len) {
22329 resolve(msgs);
22330 }
22331 },reject);
22332 });
22333 });
22334
22335 builtInProp(NpoPromise,'race',function Promise$race(arr) {
22336 var Constructor = this;
22337
22338 // spec mandated checks
22339 if (ToString.call(arr) !== '[object Array]') {
22340 return Constructor.reject(TypeError('Not an array'));
22341 }
22342
22343 return new Constructor(function executor(resolve,reject){
22344 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22345 throw TypeError('Not a function');
22346 }
22347
22348 iteratePromises(Constructor,arr,function resolver(idx,msg){
22349 resolve(msg);
22350 },reject);
22351 });
22352 });
22353
22354 var PromisePolyfill;
22355 if (typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]') !== -1) {
22356 PromisePolyfill = Promise;
22357 } else {
22358 PromisePolyfill = NpoPromise;
22359 }
22360
22361 var Config = {
22362 DEBUG: false,
22363 LIB_VERSION: '2.71.1'
22364 };
22365
22366 /* eslint camelcase: "off", eqeqeq: "off" */
22367
22368 // Maximum allowed session recording length
22369 var MAX_RECORDING_MS = 24 * 60 * 60 * 1000; // 24 hours
22370 // Maximum allowed value for minimum session recording length
22371 var MAX_VALUE_FOR_MIN_RECORDING_MS = 8 * 1000; // 8 seconds
22372
22373 /*
22374 * Saved references to long variable names, so that closure compiler can
22375 * minimize file size.
22376 */
22377
22378 var ArrayProto = Array.prototype,
22379 FuncProto = Function.prototype,
22380 ObjProto = Object.prototype,
22381 slice = ArrayProto.slice,
22382 toString = ObjProto.toString,
22383 hasOwnProperty = ObjProto.hasOwnProperty,
22384 windowConsole = win.console,
22385 navigator = win.navigator,
22386 document$1 = win.document,
22387 windowOpera = win.opera,
22388 screen = win.screen,
22389 userAgent = navigator.userAgent;
22390
22391 var nativeBind = FuncProto.bind,
22392 nativeForEach = ArrayProto.forEach,
22393 nativeIndexOf = ArrayProto.indexOf,
22394 nativeMap = ArrayProto.map,
22395 nativeIsArray = Array.isArray,
22396 breaker = {};
22397
22398 var _ = {
22399 trim: function(str) {
22400 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
22401 return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
22402 }
22403 };
22404
22405 // Console override
22406 var console$1 = {
22407 /** @type {function(...*)} */
22408 log: function() {
22409 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22410 try {
22411 windowConsole.log.apply(windowConsole, arguments);
22412 } catch (err) {
22413 _.each(arguments, function(arg) {
22414 windowConsole.log(arg);
22415 });
22416 }
22417 }
22418 },
22419 /** @type {function(...*)} */
22420 warn: function() {
22421 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22422 var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
22423 try {
22424 windowConsole.warn.apply(windowConsole, args);
22425 } catch (err) {
22426 _.each(args, function(arg) {
22427 windowConsole.warn(arg);
22428 });
22429 }
22430 }
22431 },
22432 /** @type {function(...*)} */
22433 error: function() {
22434 if (Config.DEBUG && !_.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 /** @type {function(...*)} */
22446 critical: function() {
22447 if (!_.isUndefined(windowConsole) && windowConsole) {
22448 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22449 try {
22450 windowConsole.error.apply(windowConsole, args);
22451 } catch (err) {
22452 _.each(args, function(arg) {
22453 windowConsole.error(arg);
22454 });
22455 }
22456 }
22457 }
22458 };
22459
22460 var log_func_with_prefix = function(func, prefix) {
22461 return function() {
22462 arguments[0] = '[' + prefix + '] ' + arguments[0];
22463 return func.apply(console$1, arguments);
22464 };
22465 };
22466 var console_with_prefix = function(prefix) {
22467 return {
22468 log: log_func_with_prefix(console$1.log, prefix),
22469 error: log_func_with_prefix(console$1.error, prefix),
22470 critical: log_func_with_prefix(console$1.critical, prefix)
22471 };
22472 };
22473
22474
22475 var safewrap = function(f) {
22476 return function() {
22477 try {
22478 return f.apply(this, arguments);
22479 } catch (e) {
22480 console$1.critical('Implementation error. Please turn on debug and contact support@mixpanel.com.');
22481 if (Config.DEBUG){
22482 console$1.critical(e);
22483 }
22484 }
22485 };
22486 };
22487
22488 var safewrapClass = function(klass) {
22489 var proto = klass.prototype;
22490 for (var func in proto) {
22491 if (typeof(proto[func]) === 'function') {
22492 proto[func] = safewrap(proto[func]);
22493 }
22494 }
22495 };
22496
22497
22498 // UNDERSCORE
22499 // Embed part of the Underscore Library
22500 _.bind = function(func, context) {
22501 var args, bound;
22502 if (nativeBind && func.bind === nativeBind) {
22503 return nativeBind.apply(func, slice.call(arguments, 1));
22504 }
22505 if (!_.isFunction(func)) {
22506 throw new TypeError();
22507 }
22508 args = slice.call(arguments, 2);
22509 bound = function() {
22510 if (!(this instanceof bound)) {
22511 return func.apply(context, args.concat(slice.call(arguments)));
22512 }
22513 var ctor = {};
22514 ctor.prototype = func.prototype;
22515 var self = new ctor();
22516 ctor.prototype = null;
22517 var result = func.apply(self, args.concat(slice.call(arguments)));
22518 if (Object(result) === result) {
22519 return result;
22520 }
22521 return self;
22522 };
22523 return bound;
22524 };
22525
22526 /**
22527 * @param {*=} obj
22528 * @param {function(...*)=} iterator
22529 * @param {Object=} context
22530 */
22531 _.each = function(obj, iterator, context) {
22532 if (obj === null || obj === undefined) {
22533 return;
22534 }
22535 if (nativeForEach && obj.forEach === nativeForEach) {
22536 obj.forEach(iterator, context);
22537 } else if (obj.length === +obj.length) {
22538 for (var i = 0, l = obj.length; i < l; i++) {
22539 if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
22540 return;
22541 }
22542 }
22543 } else {
22544 for (var key in obj) {
22545 if (hasOwnProperty.call(obj, key)) {
22546 if (iterator.call(context, obj[key], key, obj) === breaker) {
22547 return;
22548 }
22549 }
22550 }
22551 }
22552 };
22553
22554 _.extend = function(obj) {
22555 _.each(slice.call(arguments, 1), function(source) {
22556 for (var prop in source) {
22557 if (source[prop] !== void 0) {
22558 obj[prop] = source[prop];
22559 }
22560 }
22561 });
22562 return obj;
22563 };
22564
22565 _.isArray = nativeIsArray || function(obj) {
22566 return toString.call(obj) === '[object Array]';
22567 };
22568
22569 // from a comment on http://dbj.org/dbj/?p=286
22570 // fails on only one very rare and deliberate custom object:
22571 // var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
22572 _.isFunction = function(f) {
22573 try {
22574 return /^\s*\bfunction\b/.test(f);
22575 } catch (x) {
22576 return false;
22577 }
22578 };
22579
22580 _.isArguments = function(obj) {
22581 return !!(obj && hasOwnProperty.call(obj, 'callee'));
22582 };
22583
22584 _.toArray = function(iterable) {
22585 if (!iterable) {
22586 return [];
22587 }
22588 if (iterable.toArray) {
22589 return iterable.toArray();
22590 }
22591 if (_.isArray(iterable)) {
22592 return slice.call(iterable);
22593 }
22594 if (_.isArguments(iterable)) {
22595 return slice.call(iterable);
22596 }
22597 return _.values(iterable);
22598 };
22599
22600 _.map = function(arr, callback, context) {
22601 if (nativeMap && arr.map === nativeMap) {
22602 return arr.map(callback, context);
22603 } else {
22604 var results = [];
22605 _.each(arr, function(item) {
22606 results.push(callback.call(context, item));
22607 });
22608 return results;
22609 }
22610 };
22611
22612 _.keys = function(obj) {
22613 var results = [];
22614 if (obj === null) {
22615 return results;
22616 }
22617 _.each(obj, function(value, key) {
22618 results[results.length] = key;
22619 });
22620 return results;
22621 };
22622
22623 _.values = function(obj) {
22624 var results = [];
22625 if (obj === null) {
22626 return results;
22627 }
22628 _.each(obj, function(value) {
22629 results[results.length] = value;
22630 });
22631 return results;
22632 };
22633
22634 _.include = function(obj, target) {
22635 var found = false;
22636 if (obj === null) {
22637 return found;
22638 }
22639 if (nativeIndexOf && obj.indexOf === nativeIndexOf) {
22640 return obj.indexOf(target) != -1;
22641 }
22642 _.each(obj, function(value) {
22643 if (found || (found = (value === target))) {
22644 return breaker;
22645 }
22646 });
22647 return found;
22648 };
22649
22650 _.includes = function(str, needle) {
22651 return str.indexOf(needle) !== -1;
22652 };
22653
22654 // Underscore Addons
22655 _.inherit = function(subclass, superclass) {
22656 subclass.prototype = new superclass();
22657 subclass.prototype.constructor = subclass;
22658 subclass.superclass = superclass.prototype;
22659 return subclass;
22660 };
22661
22662 _.isObject = function(obj) {
22663 return (obj === Object(obj) && !_.isArray(obj));
22664 };
22665
22666 _.isEmptyObject = function(obj) {
22667 if (_.isObject(obj)) {
22668 for (var key in obj) {
22669 if (hasOwnProperty.call(obj, key)) {
22670 return false;
22671 }
22672 }
22673 return true;
22674 }
22675 return false;
22676 };
22677
22678 _.isUndefined = function(obj) {
22679 return obj === void 0;
22680 };
22681
22682 _.isString = function(obj) {
22683 return toString.call(obj) == '[object String]';
22684 };
22685
22686 _.isDate = function(obj) {
22687 return toString.call(obj) == '[object Date]';
22688 };
22689
22690 _.isNumber = function(obj) {
22691 return toString.call(obj) == '[object Number]';
22692 };
22693
22694 _.isElement = function(obj) {
22695 return !!(obj && obj.nodeType === 1);
22696 };
22697
22698 _.encodeDates = function(obj) {
22699 _.each(obj, function(v, k) {
22700 if (_.isDate(v)) {
22701 obj[k] = _.formatDate(v);
22702 } else if (_.isObject(v)) {
22703 obj[k] = _.encodeDates(v); // recurse
22704 }
22705 });
22706 return obj;
22707 };
22708
22709 _.timestamp = function() {
22710 Date.now = Date.now || function() {
22711 return +new Date;
22712 };
22713 return Date.now();
22714 };
22715
22716 _.formatDate = function(d) {
22717 // YYYY-MM-DDTHH:MM:SS in UTC
22718 function pad(n) {
22719 return n < 10 ? '0' + n : n;
22720 }
22721 return d.getUTCFullYear() + '-' +
22722 pad(d.getUTCMonth() + 1) + '-' +
22723 pad(d.getUTCDate()) + 'T' +
22724 pad(d.getUTCHours()) + ':' +
22725 pad(d.getUTCMinutes()) + ':' +
22726 pad(d.getUTCSeconds());
22727 };
22728
22729 _.strip_empty_properties = function(p) {
22730 var ret = {};
22731 _.each(p, function(v, k) {
22732 if (_.isString(v) && v.length > 0) {
22733 ret[k] = v;
22734 }
22735 });
22736 return ret;
22737 };
22738
22739 /*
22740 * this function returns a copy of object after truncating it. If
22741 * passed an Array or Object it will iterate through obj and
22742 * truncate all the values recursively.
22743 */
22744 _.truncate = function(obj, length) {
22745 var ret;
22746
22747 if (typeof(obj) === 'string') {
22748 ret = obj.slice(0, length);
22749 } else if (_.isArray(obj)) {
22750 ret = [];
22751 _.each(obj, function(val) {
22752 ret.push(_.truncate(val, length));
22753 });
22754 } else if (_.isObject(obj)) {
22755 ret = {};
22756 _.each(obj, function(val, key) {
22757 ret[key] = _.truncate(val, length);
22758 });
22759 } else {
22760 ret = obj;
22761 }
22762
22763 return ret;
22764 };
22765
22766 _.JSONEncode = (function() {
22767 return function(mixed_val) {
22768 var value = mixed_val;
22769 var quote = function(string) {
22770 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
22771 var meta = { // table of character substitutions
22772 '\b': '\\b',
22773 '\t': '\\t',
22774 '\n': '\\n',
22775 '\f': '\\f',
22776 '\r': '\\r',
22777 '"': '\\"',
22778 '\\': '\\\\'
22779 };
22780
22781 escapable.lastIndex = 0;
22782 return escapable.test(string) ?
22783 '"' + string.replace(escapable, function(a) {
22784 var c = meta[a];
22785 return typeof c === 'string' ? c :
22786 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
22787 }) + '"' :
22788 '"' + string + '"';
22789 };
22790
22791 var str = function(key, holder) {
22792 var gap = '';
22793 var indent = ' ';
22794 var i = 0; // The loop counter.
22795 var k = ''; // The member key.
22796 var v = ''; // The member value.
22797 var length = 0;
22798 var mind = gap;
22799 var partial = [];
22800 var value = holder[key];
22801
22802 // If the value has a toJSON method, call it to obtain a replacement value.
22803 if (value && typeof value === 'object' &&
22804 typeof value.toJSON === 'function') {
22805 value = value.toJSON(key);
22806 }
22807
22808 // What happens next depends on the value's type.
22809 switch (typeof value) {
22810 case 'string':
22811 return quote(value);
22812
22813 case 'number':
22814 // JSON numbers must be finite. Encode non-finite numbers as null.
22815 return isFinite(value) ? String(value) : 'null';
22816
22817 case 'boolean':
22818 case 'null':
22819 // If the value is a boolean or null, convert it to a string. Note:
22820 // typeof null does not produce 'null'. The case is included here in
22821 // the remote chance that this gets fixed someday.
22822
22823 return String(value);
22824
22825 case 'object':
22826 // If the type is 'object', we might be dealing with an object or an array or
22827 // null.
22828 // Due to a specification blunder in ECMAScript, typeof null is 'object',
22829 // so watch out for that case.
22830 if (!value) {
22831 return 'null';
22832 }
22833
22834 // Make an array to hold the partial results of stringifying this object value.
22835 gap += indent;
22836 partial = [];
22837
22838 // Is the value an array?
22839 if (toString.apply(value) === '[object Array]') {
22840 // The value is an array. Stringify every element. Use null as a placeholder
22841 // for non-JSON values.
22842
22843 length = value.length;
22844 for (i = 0; i < length; i += 1) {
22845 partial[i] = str(i, value) || 'null';
22846 }
22847
22848 // Join all of the elements together, separated with commas, and wrap them in
22849 // brackets.
22850 v = partial.length === 0 ? '[]' :
22851 gap ? '[\n' + gap +
22852 partial.join(',\n' + gap) + '\n' +
22853 mind + ']' :
22854 '[' + partial.join(',') + ']';
22855 gap = mind;
22856 return v;
22857 }
22858
22859 // Iterate through all of the keys in the object.
22860 for (k in value) {
22861 if (hasOwnProperty.call(value, k)) {
22862 v = str(k, value);
22863 if (v) {
22864 partial.push(quote(k) + (gap ? ': ' : ':') + v);
22865 }
22866 }
22867 }
22868
22869 // Join all of the member texts together, separated with commas,
22870 // and wrap them in braces.
22871 v = partial.length === 0 ? '{}' :
22872 gap ? '{' + partial.join(',') + '' +
22873 mind + '}' : '{' + partial.join(',') + '}';
22874 gap = mind;
22875 return v;
22876 }
22877 };
22878
22879 // Make a fake root object containing our value under the key of ''.
22880 // Return the result of stringifying the value.
22881 return str('', {
22882 '': value
22883 });
22884 };
22885 })();
22886
22887 /**
22888 * From https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
22889 * Slightly modified to throw a real Error rather than a POJO
22890 */
22891 _.JSONDecode = (function() {
22892 var at, // The index of the current character
22893 ch, // The current character
22894 escapee = {
22895 '"': '"',
22896 '\\': '\\',
22897 '/': '/',
22898 'b': '\b',
22899 'f': '\f',
22900 'n': '\n',
22901 'r': '\r',
22902 't': '\t'
22903 },
22904 text,
22905 error = function(m) {
22906 var e = new SyntaxError(m);
22907 e.at = at;
22908 e.text = text;
22909 throw e;
22910 },
22911 next = function(c) {
22912 // If a c parameter is provided, verify that it matches the current character.
22913 if (c && c !== ch) {
22914 error('Expected \'' + c + '\' instead of \'' + ch + '\'');
22915 }
22916 // Get the next character. When there are no more characters,
22917 // return the empty string.
22918 ch = text.charAt(at);
22919 at += 1;
22920 return ch;
22921 },
22922 number = function() {
22923 // Parse a number value.
22924 var number,
22925 string = '';
22926
22927 if (ch === '-') {
22928 string = '-';
22929 next('-');
22930 }
22931 while (ch >= '0' && ch <= '9') {
22932 string += ch;
22933 next();
22934 }
22935 if (ch === '.') {
22936 string += '.';
22937 while (next() && ch >= '0' && ch <= '9') {
22938 string += ch;
22939 }
22940 }
22941 if (ch === 'e' || ch === 'E') {
22942 string += ch;
22943 next();
22944 if (ch === '-' || ch === '+') {
22945 string += ch;
22946 next();
22947 }
22948 while (ch >= '0' && ch <= '9') {
22949 string += ch;
22950 next();
22951 }
22952 }
22953 number = +string;
22954 if (!isFinite(number)) {
22955 error('Bad number');
22956 } else {
22957 return number;
22958 }
22959 },
22960
22961 string = function() {
22962 // Parse a string value.
22963 var hex,
22964 i,
22965 string = '',
22966 uffff;
22967 // When parsing for string values, we must look for " and \ characters.
22968 if (ch === '"') {
22969 while (next()) {
22970 if (ch === '"') {
22971 next();
22972 return string;
22973 }
22974 if (ch === '\\') {
22975 next();
22976 if (ch === 'u') {
22977 uffff = 0;
22978 for (i = 0; i < 4; i += 1) {
22979 hex = parseInt(next(), 16);
22980 if (!isFinite(hex)) {
22981 break;
22982 }
22983 uffff = uffff * 16 + hex;
22984 }
22985 string += String.fromCharCode(uffff);
22986 } else if (typeof escapee[ch] === 'string') {
22987 string += escapee[ch];
22988 } else {
22989 break;
22990 }
22991 } else {
22992 string += ch;
22993 }
22994 }
22995 }
22996 error('Bad string');
22997 },
22998 white = function() {
22999 // Skip whitespace.
23000 while (ch && ch <= ' ') {
23001 next();
23002 }
23003 },
23004 word = function() {
23005 // true, false, or null.
23006 switch (ch) {
23007 case 't':
23008 next('t');
23009 next('r');
23010 next('u');
23011 next('e');
23012 return true;
23013 case 'f':
23014 next('f');
23015 next('a');
23016 next('l');
23017 next('s');
23018 next('e');
23019 return false;
23020 case 'n':
23021 next('n');
23022 next('u');
23023 next('l');
23024 next('l');
23025 return null;
23026 }
23027 error('Unexpected "' + ch + '"');
23028 },
23029 value, // Placeholder for the value function.
23030 array = function() {
23031 // Parse an array value.
23032 var array = [];
23033
23034 if (ch === '[') {
23035 next('[');
23036 white();
23037 if (ch === ']') {
23038 next(']');
23039 return array; // empty array
23040 }
23041 while (ch) {
23042 array.push(value());
23043 white();
23044 if (ch === ']') {
23045 next(']');
23046 return array;
23047 }
23048 next(',');
23049 white();
23050 }
23051 }
23052 error('Bad array');
23053 },
23054 object = function() {
23055 // Parse an object value.
23056 var key,
23057 object = {};
23058
23059 if (ch === '{') {
23060 next('{');
23061 white();
23062 if (ch === '}') {
23063 next('}');
23064 return object; // empty object
23065 }
23066 while (ch) {
23067 key = string();
23068 white();
23069 next(':');
23070 if (Object.hasOwnProperty.call(object, key)) {
23071 error('Duplicate key "' + key + '"');
23072 }
23073 object[key] = value();
23074 white();
23075 if (ch === '}') {
23076 next('}');
23077 return object;
23078 }
23079 next(',');
23080 white();
23081 }
23082 }
23083 error('Bad object');
23084 };
23085
23086 value = function() {
23087 // Parse a JSON value. It could be an object, an array, a string,
23088 // a number, or a word.
23089 white();
23090 switch (ch) {
23091 case '{':
23092 return object();
23093 case '[':
23094 return array();
23095 case '"':
23096 return string();
23097 case '-':
23098 return number();
23099 default:
23100 return ch >= '0' && ch <= '9' ? number() : word();
23101 }
23102 };
23103
23104 // Return the json_parse function. It will have access to all of the
23105 // above functions and variables.
23106 return function(source) {
23107 var result;
23108
23109 text = source;
23110 at = 0;
23111 ch = ' ';
23112 result = value();
23113 white();
23114 if (ch) {
23115 error('Syntax error');
23116 }
23117
23118 return result;
23119 };
23120 })();
23121
23122 _.base64Encode = function(data) {
23123 var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
23124 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
23125 ac = 0,
23126 enc = '',
23127 tmp_arr = [];
23128
23129 if (!data) {
23130 return data;
23131 }
23132
23133 data = _.utf8Encode(data);
23134
23135 do { // pack three octets into four hexets
23136 o1 = data.charCodeAt(i++);
23137 o2 = data.charCodeAt(i++);
23138 o3 = data.charCodeAt(i++);
23139
23140 bits = o1 << 16 | o2 << 8 | o3;
23141
23142 h1 = bits >> 18 & 0x3f;
23143 h2 = bits >> 12 & 0x3f;
23144 h3 = bits >> 6 & 0x3f;
23145 h4 = bits & 0x3f;
23146
23147 // use hexets to index into b64, and append result to encoded string
23148 tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
23149 } while (i < data.length);
23150
23151 enc = tmp_arr.join('');
23152
23153 switch (data.length % 3) {
23154 case 1:
23155 enc = enc.slice(0, -2) + '==';
23156 break;
23157 case 2:
23158 enc = enc.slice(0, -1) + '=';
23159 break;
23160 }
23161
23162 return enc;
23163 };
23164
23165 _.utf8Encode = function(string) {
23166 string = (string + '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
23167
23168 var utftext = '',
23169 start,
23170 end;
23171 var stringl = 0,
23172 n;
23173
23174 start = end = 0;
23175 stringl = string.length;
23176
23177 for (n = 0; n < stringl; n++) {
23178 var c1 = string.charCodeAt(n);
23179 var enc = null;
23180
23181 if (c1 < 128) {
23182 end++;
23183 } else if ((c1 > 127) && (c1 < 2048)) {
23184 enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128);
23185 } else {
23186 enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128);
23187 }
23188 if (enc !== null) {
23189 if (end > start) {
23190 utftext += string.substring(start, end);
23191 }
23192 utftext += enc;
23193 start = end = n + 1;
23194 }
23195 }
23196
23197 if (end > start) {
23198 utftext += string.substring(start, string.length);
23199 }
23200
23201 return utftext;
23202 };
23203
23204 _.UUID = function() {
23205 try {
23206 // use native Crypto API when available
23207 return win['crypto']['randomUUID']();
23208 } catch (err) {
23209 // fall back to generating our own UUID
23210 // based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
23211 var uuid = new Array(36);
23212 for (var i = 0; i < 36; i++) {
23213 uuid[i] = Math.floor(Math.random() * 16);
23214 }
23215 uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
23216 uuid[19] = uuid[19] &= -5; // set bit 6 of clock-seq-and-reserved to zero
23217 uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
23218 uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
23219
23220 return _.map(uuid, function(x) {
23221 return x.toString(16);
23222 }).join('');
23223 }
23224 };
23225
23226 // _.isBlockedUA()
23227 // This is to block various web spiders from executing our JS and
23228 // sending false tracking data
23229 var BLOCKED_UA_STRS = [
23230 'ahrefsbot',
23231 'ahrefssiteaudit',
23232 'amazonbot',
23233 'baiduspider',
23234 'bingbot',
23235 'bingpreview',
23236 'chrome-lighthouse',
23237 'facebookexternal',
23238 'petalbot',
23239 'pinterest',
23240 'screaming frog',
23241 'yahoo! slurp',
23242 'yandex',
23243
23244 // a whole bunch of goog-specific crawlers
23245 // https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
23246 'adsbot-google',
23247 'apis-google',
23248 'duplexweb-google',
23249 'feedfetcher-google',
23250 'google favicon',
23251 'google web preview',
23252 'google-read-aloud',
23253 'googlebot',
23254 'googleweblight',
23255 'mediapartners-google',
23256 'storebot-google'
23257 ];
23258 _.isBlockedUA = function(ua) {
23259 var i;
23260 ua = ua.toLowerCase();
23261 for (i = 0; i < BLOCKED_UA_STRS.length; i++) {
23262 if (ua.indexOf(BLOCKED_UA_STRS[i]) !== -1) {
23263 return true;
23264 }
23265 }
23266 return false;
23267 };
23268
23269 /**
23270 * @param {Object=} formdata
23271 * @param {string=} arg_separator
23272 */
23273 _.HTTPBuildQuery = function(formdata, arg_separator) {
23274 var use_val, use_key, tmp_arr = [];
23275
23276 if (_.isUndefined(arg_separator)) {
23277 arg_separator = '&';
23278 }
23279
23280 _.each(formdata, function(val, key) {
23281 use_val = encodeURIComponent(val.toString());
23282 use_key = encodeURIComponent(key);
23283 tmp_arr[tmp_arr.length] = use_key + '=' + use_val;
23284 });
23285
23286 return tmp_arr.join(arg_separator);
23287 };
23288
23289 _.getQueryParam = function(url, param) {
23290 // Expects a raw URL
23291
23292 param = param.replace(/[[]/g, '\\[').replace(/[\]]/g, '\\]');
23293 var regexS = '[\\?&]' + param + '=([^&#]*)',
23294 regex = new RegExp(regexS),
23295 results = regex.exec(url);
23296 if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
23297 return '';
23298 } else {
23299 var result = results[1];
23300 try {
23301 result = decodeURIComponent(result);
23302 } catch(err) {
23303 console$1.error('Skipping decoding for malformed query param: ' + result);
23304 }
23305 return result.replace(/\+/g, ' ');
23306 }
23307 };
23308
23309
23310 // _.cookie
23311 // Methods partially borrowed from quirksmode.org/js/cookies.html
23312 _.cookie = {
23313 get: function(name) {
23314 var nameEQ = name + '=';
23315 var ca = document$1.cookie.split(';');
23316 for (var i = 0; i < ca.length; i++) {
23317 var c = ca[i];
23318 while (c.charAt(0) == ' ') {
23319 c = c.substring(1, c.length);
23320 }
23321 if (c.indexOf(nameEQ) === 0) {
23322 return decodeURIComponent(c.substring(nameEQ.length, c.length));
23323 }
23324 }
23325 return null;
23326 },
23327
23328 parse: function(name) {
23329 var cookie;
23330 try {
23331 cookie = _.JSONDecode(_.cookie.get(name)) || {};
23332 } catch (err) {
23333 // noop
23334 }
23335 return cookie;
23336 },
23337
23338 set_seconds: function(name, value, seconds, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23339 var cdomain = '',
23340 expires = '',
23341 secure = '';
23342
23343 if (domain_override) {
23344 cdomain = '; domain=' + domain_override;
23345 } else if (is_cross_subdomain) {
23346 var domain = extract_domain(document$1.location.hostname);
23347 cdomain = domain ? '; domain=.' + domain : '';
23348 }
23349
23350 if (seconds) {
23351 var date = new Date();
23352 date.setTime(date.getTime() + (seconds * 1000));
23353 expires = '; expires=' + date.toGMTString();
23354 }
23355
23356 if (is_cross_site) {
23357 is_secure = true;
23358 secure = '; SameSite=None';
23359 }
23360 if (is_secure) {
23361 secure += '; secure';
23362 }
23363
23364 document$1.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23365 },
23366
23367 set: function(name, value, days, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23368 var cdomain = '', expires = '', secure = '';
23369
23370 if (domain_override) {
23371 cdomain = '; domain=' + domain_override;
23372 } else if (is_cross_subdomain) {
23373 var domain = extract_domain(document$1.location.hostname);
23374 cdomain = domain ? '; domain=.' + domain : '';
23375 }
23376
23377 if (days) {
23378 var date = new Date();
23379 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
23380 expires = '; expires=' + date.toGMTString();
23381 }
23382
23383 if (is_cross_site) {
23384 is_secure = true;
23385 secure = '; SameSite=None';
23386 }
23387 if (is_secure) {
23388 secure += '; secure';
23389 }
23390
23391 var new_cookie_val = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23392 document$1.cookie = new_cookie_val;
23393 return new_cookie_val;
23394 },
23395
23396 remove: function(name, is_cross_subdomain, domain_override) {
23397 _.cookie.set(name, '', -1, is_cross_subdomain, false, false, domain_override);
23398 }
23399 };
23400
23401 var _testStorageSupported = function (storage) {
23402 var supported = true;
23403 try {
23404 var key = '__mplss_' + cheap_guid(8),
23405 val = 'xyz';
23406 storage.setItem(key, val);
23407 if (storage.getItem(key) !== val) {
23408 supported = false;
23409 }
23410 storage.removeItem(key);
23411 } catch (err) {
23412 supported = false;
23413 }
23414 return supported;
23415 };
23416
23417 var _localStorageSupported = null;
23418 var localStorageSupported = function(storage, forceCheck) {
23419 if (_localStorageSupported !== null && !forceCheck) {
23420 return _localStorageSupported;
23421 }
23422 return _localStorageSupported = _testStorageSupported(storage || win.localStorage);
23423 };
23424
23425 var _sessionStorageSupported = null;
23426 var sessionStorageSupported = function(storage, forceCheck) {
23427 if (_sessionStorageSupported !== null && !forceCheck) {
23428 return _sessionStorageSupported;
23429 }
23430 return _sessionStorageSupported = _testStorageSupported(storage || win.sessionStorage);
23431 };
23432
23433 function _storageWrapper(storage, name, is_supported_fn) {
23434 var log_error = function(msg) {
23435 console$1.error(name + ' error: ' + msg);
23436 };
23437
23438 return {
23439 is_supported: function(forceCheck) {
23440 var supported = is_supported_fn(storage, forceCheck);
23441 if (!supported) {
23442 console$1.error(name + ' unsupported');
23443 }
23444 return supported;
23445 },
23446 error: log_error,
23447 get: function(key) {
23448 try {
23449 return storage.getItem(key);
23450 } catch (err) {
23451 log_error(err);
23452 }
23453 return null;
23454 },
23455 parse: function(key) {
23456 try {
23457 return _.JSONDecode(storage.getItem(key)) || {};
23458 } catch (err) {
23459 // noop
23460 }
23461 return null;
23462 },
23463 set: function(key, value) {
23464 try {
23465 storage.setItem(key, value);
23466 } catch (err) {
23467 log_error(err);
23468 }
23469 },
23470 remove: function(key) {
23471 try {
23472 storage.removeItem(key);
23473 } catch (err) {
23474 log_error(err);
23475 }
23476 }
23477 };
23478 }
23479
23480 _.localStorage = _storageWrapper(win.localStorage, 'localStorage', localStorageSupported);
23481 _.sessionStorage = _storageWrapper(win.sessionStorage, 'sessionStorage', sessionStorageSupported);
23482
23483 _.register_event = (function() {
23484 // written by Dean Edwards, 2005
23485 // with input from Tino Zijdel - crisp@xs4all.nl
23486 // with input from Carl Sverre - mail@carlsverre.com
23487 // with input from Mixpanel
23488 // http://dean.edwards.name/weblog/2005/10/add-event/
23489 // https://gist.github.com/1930440
23490
23491 /**
23492 * @param {Object} element
23493 * @param {string} type
23494 * @param {function(...*)} handler
23495 * @param {boolean=} oldSchool
23496 * @param {boolean=} useCapture
23497 */
23498 var register_event = function(element, type, handler, oldSchool, useCapture) {
23499 if (!element) {
23500 console$1.error('No valid element provided to register_event');
23501 return;
23502 }
23503
23504 if (element.addEventListener && !oldSchool) {
23505 element.addEventListener(type, handler, !!useCapture);
23506 } else {
23507 var ontype = 'on' + type;
23508 var old_handler = element[ontype]; // can be undefined
23509 element[ontype] = makeHandler(element, handler, old_handler);
23510 }
23511 };
23512
23513 function makeHandler(element, new_handler, old_handlers) {
23514 var handler = function(event) {
23515 event = event || fixEvent(win.event);
23516
23517 // this basically happens in firefox whenever another script
23518 // overwrites the onload callback and doesn't pass the event
23519 // object to previously defined callbacks. All the browsers
23520 // that don't define window.event implement addEventListener
23521 // so the dom_loaded handler will still be fired as usual.
23522 if (!event) {
23523 return undefined;
23524 }
23525
23526 var ret = true;
23527 var old_result, new_result;
23528
23529 if (_.isFunction(old_handlers)) {
23530 old_result = old_handlers(event);
23531 }
23532 new_result = new_handler.call(element, event);
23533
23534 if ((false === old_result) || (false === new_result)) {
23535 ret = false;
23536 }
23537
23538 return ret;
23539 };
23540
23541 return handler;
23542 }
23543
23544 function fixEvent(event) {
23545 if (event) {
23546 event.preventDefault = fixEvent.preventDefault;
23547 event.stopPropagation = fixEvent.stopPropagation;
23548 }
23549 return event;
23550 }
23551 fixEvent.preventDefault = function() {
23552 this.returnValue = false;
23553 };
23554 fixEvent.stopPropagation = function() {
23555 this.cancelBubble = true;
23556 };
23557
23558 return register_event;
23559 })();
23560
23561
23562 var TOKEN_MATCH_REGEX = new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');
23563
23564 _.dom_query = (function() {
23565 /* document.getElementsBySelector(selector)
23566 - returns an array of element objects from the current document
23567 matching the CSS selector. Selectors can contain element names,
23568 class names and ids and can be nested. For example:
23569
23570 elements = document.getElementsBySelector('div#main p a.external')
23571
23572 Will return an array of all 'a' elements with 'external' in their
23573 class attribute that are contained inside 'p' elements that are
23574 contained inside the 'div' element which has id="main"
23575
23576 New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
23577 See http://www.w3.org/TR/css3-selectors/#attribute-selectors
23578
23579 Version 0.4 - Simon Willison, March 25th 2003
23580 -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
23581 -- Opera 7 fails
23582
23583 Version 0.5 - Carl Sverre, Jan 7th 2013
23584 -- Now uses jQuery-esque `hasClass` for testing class name
23585 equality. This fixes a bug related to '-' characters being
23586 considered not part of a 'word' in regex.
23587 */
23588
23589 function getAllChildren(e) {
23590 // Returns all children of element. Workaround required for IE5/Windows. Ugh.
23591 return e.all ? e.all : e.getElementsByTagName('*');
23592 }
23593
23594 var bad_whitespace = /[\t\r\n]/g;
23595
23596 function hasClass(elem, selector) {
23597 var className = ' ' + selector + ' ';
23598 return ((' ' + elem.className + ' ').replace(bad_whitespace, ' ').indexOf(className) >= 0);
23599 }
23600
23601 function getElementsBySelector(selector) {
23602 // Attempt to fail gracefully in lesser browsers
23603 if (!document$1.getElementsByTagName) {
23604 return [];
23605 }
23606 // Split selector in to tokens
23607 var tokens = selector.split(' ');
23608 var token, bits, tagName, found, foundCount, i, j, k, elements, currentContextIndex;
23609 var currentContext = [document$1];
23610 for (i = 0; i < tokens.length; i++) {
23611 token = tokens[i].replace(/^\s+/, '').replace(/\s+$/, '');
23612 if (token.indexOf('#') > -1) {
23613 // Token is an ID selector
23614 bits = token.split('#');
23615 tagName = bits[0];
23616 var id = bits[1];
23617 var element = document$1.getElementById(id);
23618 if (!element || (tagName && element.nodeName.toLowerCase() != tagName)) {
23619 // element not found or tag with that ID not found, return false
23620 return [];
23621 }
23622 // Set currentContext to contain just this element
23623 currentContext = [element];
23624 continue; // Skip to next token
23625 }
23626 if (token.indexOf('.') > -1) {
23627 // Token contains a class selector
23628 bits = token.split('.');
23629 tagName = bits[0];
23630 var className = bits[1];
23631 if (!tagName) {
23632 tagName = '*';
23633 }
23634 // Get elements matching tag, filter them for class selector
23635 found = [];
23636 foundCount = 0;
23637 for (j = 0; j < currentContext.length; j++) {
23638 if (tagName == '*') {
23639 elements = getAllChildren(currentContext[j]);
23640 } else {
23641 elements = currentContext[j].getElementsByTagName(tagName);
23642 }
23643 for (k = 0; k < elements.length; k++) {
23644 found[foundCount++] = elements[k];
23645 }
23646 }
23647 currentContext = [];
23648 currentContextIndex = 0;
23649 for (j = 0; j < found.length; j++) {
23650 if (found[j].className &&
23651 _.isString(found[j].className) && // some SVG elements have classNames which are not strings
23652 hasClass(found[j], className)
23653 ) {
23654 currentContext[currentContextIndex++] = found[j];
23655 }
23656 }
23657 continue; // Skip to next token
23658 }
23659 // Code to deal with attribute selectors
23660 var token_match = token.match(TOKEN_MATCH_REGEX);
23661 if (token_match) {
23662 tagName = token_match[1];
23663 var attrName = token_match[2];
23664 var attrOperator = token_match[3];
23665 var attrValue = token_match[4];
23666 if (!tagName) {
23667 tagName = '*';
23668 }
23669 // Grab all of the tagName elements within current context
23670 found = [];
23671 foundCount = 0;
23672 for (j = 0; j < currentContext.length; j++) {
23673 if (tagName == '*') {
23674 elements = getAllChildren(currentContext[j]);
23675 } else {
23676 elements = currentContext[j].getElementsByTagName(tagName);
23677 }
23678 for (k = 0; k < elements.length; k++) {
23679 found[foundCount++] = elements[k];
23680 }
23681 }
23682 currentContext = [];
23683 currentContextIndex = 0;
23684 var checkFunction; // This function will be used to filter the elements
23685 switch (attrOperator) {
23686 case '=': // Equality
23687 checkFunction = function(e) {
23688 return (e.getAttribute(attrName) == attrValue);
23689 };
23690 break;
23691 case '~': // Match one of space seperated words
23692 checkFunction = function(e) {
23693 return (e.getAttribute(attrName).match(new RegExp('\\b' + attrValue + '\\b')));
23694 };
23695 break;
23696 case '|': // Match start with value followed by optional hyphen
23697 checkFunction = function(e) {
23698 return (e.getAttribute(attrName).match(new RegExp('^' + attrValue + '-?')));
23699 };
23700 break;
23701 case '^': // Match starts with value
23702 checkFunction = function(e) {
23703 return (e.getAttribute(attrName).indexOf(attrValue) === 0);
23704 };
23705 break;
23706 case '$': // Match ends with value - fails with "Warning" in Opera 7
23707 checkFunction = function(e) {
23708 return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length);
23709 };
23710 break;
23711 case '*': // Match ends with value
23712 checkFunction = function(e) {
23713 return (e.getAttribute(attrName).indexOf(attrValue) > -1);
23714 };
23715 break;
23716 default:
23717 // Just test for existence of attribute
23718 checkFunction = function(e) {
23719 return e.getAttribute(attrName);
23720 };
23721 }
23722 currentContext = [];
23723 currentContextIndex = 0;
23724 for (j = 0; j < found.length; j++) {
23725 if (checkFunction(found[j])) {
23726 currentContext[currentContextIndex++] = found[j];
23727 }
23728 }
23729 // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
23730 continue; // Skip to next token
23731 }
23732 // If we get here, token is JUST an element (not a class or ID selector)
23733 tagName = token;
23734 found = [];
23735 foundCount = 0;
23736 for (j = 0; j < currentContext.length; j++) {
23737 elements = currentContext[j].getElementsByTagName(tagName);
23738 for (k = 0; k < elements.length; k++) {
23739 found[foundCount++] = elements[k];
23740 }
23741 }
23742 currentContext = found;
23743 }
23744 return currentContext;
23745 }
23746
23747 return function(query) {
23748 if (_.isElement(query)) {
23749 return [query];
23750 } else if (_.isObject(query) && !_.isUndefined(query.length)) {
23751 return query;
23752 } else {
23753 return getElementsBySelector.call(this, query);
23754 }
23755 };
23756 })();
23757
23758 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'];
23759 var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'sccid', 'ttclid', 'twclid', 'wbraid'];
23760
23761 _.info = {
23762 campaignParams: function(default_value) {
23763 var kw = '',
23764 params = {};
23765 _.each(CAMPAIGN_KEYWORDS, function(kwkey) {
23766 kw = _.getQueryParam(document$1.URL, kwkey);
23767 if (kw.length) {
23768 params[kwkey] = kw;
23769 } else if (default_value !== undefined) {
23770 params[kwkey] = default_value;
23771 }
23772 });
23773
23774 return params;
23775 },
23776
23777 clickParams: function() {
23778 var id = '',
23779 params = {};
23780 _.each(CLICK_IDS, function(idkey) {
23781 id = _.getQueryParam(document$1.URL, idkey);
23782 if (id.length) {
23783 params[idkey] = id;
23784 }
23785 });
23786
23787 return params;
23788 },
23789
23790 marketingParams: function() {
23791 return _.extend(_.info.campaignParams(), _.info.clickParams());
23792 },
23793
23794 searchEngine: function(referrer) {
23795 if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
23796 return 'google';
23797 } else if (referrer.search('https?://(.*)bing.com') === 0) {
23798 return 'bing';
23799 } else if (referrer.search('https?://(.*)yahoo.com') === 0) {
23800 return 'yahoo';
23801 } else if (referrer.search('https?://(.*)duckduckgo.com') === 0) {
23802 return 'duckduckgo';
23803 } else {
23804 return null;
23805 }
23806 },
23807
23808 searchInfo: function(referrer) {
23809 var search = _.info.searchEngine(referrer),
23810 param = (search != 'yahoo') ? 'q' : 'p',
23811 ret = {};
23812
23813 if (search !== null) {
23814 ret['$search_engine'] = search;
23815
23816 var keyword = _.getQueryParam(referrer, param);
23817 if (keyword.length) {
23818 ret['mp_keyword'] = keyword;
23819 }
23820 }
23821
23822 return ret;
23823 },
23824
23825 /**
23826 * This function detects which browser is running this script.
23827 * The order of the checks are important since many user agents
23828 * include key words used in later checks.
23829 */
23830 browser: function(user_agent, vendor, opera) {
23831 vendor = vendor || ''; // vendor is undefined for at least IE9
23832 if (opera || _.includes(user_agent, ' OPR/')) {
23833 if (_.includes(user_agent, 'Mini')) {
23834 return 'Opera Mini';
23835 }
23836 return 'Opera';
23837 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
23838 return 'BlackBerry';
23839 } else if (_.includes(user_agent, 'IEMobile') || _.includes(user_agent, 'WPDesktop')) {
23840 return 'Internet Explorer Mobile';
23841 } else if (_.includes(user_agent, 'SamsungBrowser/')) {
23842 // https://developer.samsung.com/internet/user-agent-string-format
23843 return 'Samsung Internet';
23844 } else if (_.includes(user_agent, 'Edge') || _.includes(user_agent, 'Edg/')) {
23845 return 'Microsoft Edge';
23846 } else if (_.includes(user_agent, 'FBIOS')) {
23847 return 'Facebook Mobile';
23848 } else if (_.includes(user_agent, 'Whale/')) {
23849 // https://user-agents.net/browsers/whale-browser
23850 return 'Whale Browser';
23851 } else if (_.includes(user_agent, 'Chrome')) {
23852 return 'Chrome';
23853 } else if (_.includes(user_agent, 'CriOS')) {
23854 return 'Chrome iOS';
23855 } else if (_.includes(user_agent, 'UCWEB') || _.includes(user_agent, 'UCBrowser')) {
23856 return 'UC Browser';
23857 } else if (_.includes(user_agent, 'FxiOS')) {
23858 return 'Firefox iOS';
23859 } else if (_.includes(vendor, 'Apple')) {
23860 if (_.includes(user_agent, 'Mobile')) {
23861 return 'Mobile Safari';
23862 }
23863 return 'Safari';
23864 } else if (_.includes(user_agent, 'Android')) {
23865 return 'Android Mobile';
23866 } else if (_.includes(user_agent, 'Konqueror')) {
23867 return 'Konqueror';
23868 } else if (_.includes(user_agent, 'Firefox')) {
23869 return 'Firefox';
23870 } else if (_.includes(user_agent, 'MSIE') || _.includes(user_agent, 'Trident/')) {
23871 return 'Internet Explorer';
23872 } else if (_.includes(user_agent, 'Gecko')) {
23873 return 'Mozilla';
23874 } else {
23875 return '';
23876 }
23877 },
23878
23879 /**
23880 * This function detects which browser version is running this script,
23881 * parsing major and minor version (e.g., 42.1). User agent strings from:
23882 * http://www.useragentstring.com/pages/useragentstring.php
23883 */
23884 browserVersion: function(userAgent, vendor, opera) {
23885 var browser = _.info.browser(userAgent, vendor, opera);
23886 var versionRegexs = {
23887 'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/,
23888 'Microsoft Edge': /Edge?\/(\d+(\.\d+)?)/,
23889 'Chrome': /Chrome\/(\d+(\.\d+)?)/,
23890 'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/,
23891 'UC Browser' : /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,
23892 'Safari': /Version\/(\d+(\.\d+)?)/,
23893 'Mobile Safari': /Version\/(\d+(\.\d+)?)/,
23894 'Opera': /(Opera|OPR)\/(\d+(\.\d+)?)/,
23895 'Firefox': /Firefox\/(\d+(\.\d+)?)/,
23896 'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/,
23897 'Konqueror': /Konqueror:(\d+(\.\d+)?)/,
23898 'BlackBerry': /BlackBerry (\d+(\.\d+)?)/,
23899 'Android Mobile': /android\s(\d+(\.\d+)?)/,
23900 'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
23901 'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
23902 'Mozilla': /rv:(\d+(\.\d+)?)/,
23903 'Whale Browser': /Whale\/(\d+(\.\d+)?)/
23904 };
23905 var regex = versionRegexs[browser];
23906 if (regex === undefined) {
23907 return null;
23908 }
23909 var matches = userAgent.match(regex);
23910 if (!matches) {
23911 return null;
23912 }
23913 return parseFloat(matches[matches.length - 2]);
23914 },
23915
23916 os: function() {
23917 var a = userAgent;
23918 if (/Windows/i.test(a)) {
23919 if (/Phone/.test(a) || /WPDesktop/.test(a)) {
23920 return 'Windows Phone';
23921 }
23922 return 'Windows';
23923 } else if (/(iPhone|iPad|iPod)/.test(a)) {
23924 return 'iOS';
23925 } else if (/Android/.test(a)) {
23926 return 'Android';
23927 } else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {
23928 return 'BlackBerry';
23929 } else if (/Mac/i.test(a)) {
23930 return 'Mac OS X';
23931 } else if (/Linux/.test(a)) {
23932 return 'Linux';
23933 } else if (/CrOS/.test(a)) {
23934 return 'Chrome OS';
23935 } else {
23936 return '';
23937 }
23938 },
23939
23940 device: function(user_agent) {
23941 if (/Windows Phone/i.test(user_agent) || /WPDesktop/.test(user_agent)) {
23942 return 'Windows Phone';
23943 } else if (/iPad/.test(user_agent)) {
23944 return 'iPad';
23945 } else if (/iPod/.test(user_agent)) {
23946 return 'iPod Touch';
23947 } else if (/iPhone/.test(user_agent)) {
23948 return 'iPhone';
23949 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
23950 return 'BlackBerry';
23951 } else if (/Android/.test(user_agent)) {
23952 return 'Android';
23953 } else {
23954 return '';
23955 }
23956 },
23957
23958 referringDomain: function(referrer) {
23959 var split = referrer.split('/');
23960 if (split.length >= 3) {
23961 return split[2];
23962 }
23963 return '';
23964 },
23965
23966 currentUrl: function() {
23967 return win.location.href;
23968 },
23969
23970 properties: function(extra_props) {
23971 if (typeof extra_props !== 'object') {
23972 extra_props = {};
23973 }
23974 return _.extend(_.strip_empty_properties({
23975 '$os': _.info.os(),
23976 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
23977 '$referrer': document$1.referrer,
23978 '$referring_domain': _.info.referringDomain(document$1.referrer),
23979 '$device': _.info.device(userAgent)
23980 }), {
23981 '$current_url': _.info.currentUrl(),
23982 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera),
23983 '$screen_height': screen.height,
23984 '$screen_width': screen.width,
23985 'mp_lib': 'web',
23986 '$lib_version': Config.LIB_VERSION,
23987 '$insert_id': cheap_guid(),
23988 'time': _.timestamp() / 1000 // epoch time in seconds
23989 }, _.strip_empty_properties(extra_props));
23990 },
23991
23992 people_properties: function() {
23993 return _.extend(_.strip_empty_properties({
23994 '$os': _.info.os(),
23995 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera)
23996 }), {
23997 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera)
23998 });
23999 },
24000
24001 mpPageViewProperties: function() {
24002 return _.strip_empty_properties({
24003 'current_page_title': document$1.title,
24004 'current_domain': win.location.hostname,
24005 'current_url_path': win.location.pathname,
24006 'current_url_protocol': win.location.protocol,
24007 'current_url_search': win.location.search
24008 });
24009 }
24010 };
24011
24012 /**
24013 * Returns a throttled function that will only run at most every `waitMs` and returns a promise that resolves with the next invocation.
24014 * Throttled calls will build up a batch of args and invoke the callback with all args since the last invocation.
24015 */
24016 var batchedThrottle = function (fn, waitMs) {
24017 var timeoutPromise = null;
24018 var throttledItems = [];
24019 return function (item) {
24020 var self = this;
24021 throttledItems.push(item);
24022
24023 if (!timeoutPromise) {
24024 timeoutPromise = new PromisePolyfill(function (resolve) {
24025 setTimeout(function () {
24026 var returnValue = fn.apply(self, [throttledItems]);
24027 timeoutPromise = null;
24028 throttledItems = [];
24029 resolve(returnValue);
24030 }, waitMs);
24031 });
24032 }
24033 return timeoutPromise;
24034 };
24035 };
24036
24037 var cheap_guid = function(maxlen) {
24038 var guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
24039 return maxlen ? guid.substring(0, maxlen) : guid;
24040 };
24041
24042 /**
24043 * Generates a W3C traceparent header for easy interop with distributed tracing systems i.e Open Telemetry
24044 * https://www.w3.org/TR/trace-context/#traceparent-header
24045 */
24046 var generateTraceparent = function() {
24047 var traceID = _.UUID().replace(/-/g, '');
24048 var parentID = _.UUID().replace(/-/g, '').substring(0, 16);
24049
24050 // Sampled trace
24051 var traceFlags = '01';
24052
24053 return '00-' + traceID + '-' + parentID + '-' + traceFlags;
24054 };
24055
24056 // naive way to extract domain name (example.com) from full hostname (my.sub.example.com)
24057 var SIMPLE_DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]*\.[a-z]+$/i;
24058 // this next one attempts to account for some ccSLDs, e.g. extracting oxford.ac.uk from www.oxford.ac.uk
24059 var DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;
24060 /**
24061 * Attempts to extract main domain name from full hostname, using a few blunt heuristics. For
24062 * common TLDs like .com/.org that always have a simple SLD.TLD structure (example.com), we
24063 * simply extract the last two .-separated parts of the hostname (SIMPLE_DOMAIN_MATCH_REGEX).
24064 * For others, we attempt to account for short ccSLD+TLD combos (.ac.uk) with the legacy
24065 * DOMAIN_MATCH_REGEX (kept to maintain backwards compatibility with existing Mixpanel
24066 * integrations). The only _reliable_ way to extract domain from hostname is with an up-to-date
24067 * list like at https://publicsuffix.org/ so for cases that this helper fails at, the SDK
24068 * offers the 'cookie_domain' config option to set it explicitly.
24069 * @example
24070 * extract_domain('my.sub.example.com')
24071 * // 'example.com'
24072 */
24073 var extract_domain = function(hostname) {
24074 var domain_regex = DOMAIN_MATCH_REGEX;
24075 var parts = hostname.split('.');
24076 var tld = parts[parts.length - 1];
24077 if (tld.length > 4 || tld === 'com' || tld === 'org') {
24078 domain_regex = SIMPLE_DOMAIN_MATCH_REGEX;
24079 }
24080 var matches = hostname.match(domain_regex);
24081 return matches ? matches[0] : '';
24082 };
24083
24084 /**
24085 * Check whether we have network connection. default to true for browsers that don't support navigator.onLine (IE)
24086 * @returns {boolean}
24087 */
24088 var isOnline = function() {
24089 var onLine = win.navigator['onLine'];
24090 return _.isUndefined(onLine) || onLine;
24091 };
24092
24093 var NOOP_FUNC = function () {};
24094
24095 var JSONStringify = null, JSONParse = null;
24096 if (typeof JSON !== 'undefined') {
24097 JSONStringify = JSON.stringify;
24098 JSONParse = JSON.parse;
24099 }
24100 JSONStringify = JSONStringify || _.JSONEncode;
24101 JSONParse = JSONParse || _.JSONDecode;
24102
24103 // UNMINIFIED EXPORTS (for closure compiler)
24104 _['info'] = _.info;
24105 _['info']['browser'] = _.info.browser;
24106 _['info']['browserVersion'] = _.info.browserVersion;
24107 _['info']['device'] = _.info.device;
24108 _['info']['properties'] = _.info.properties;
24109 _['isBlockedUA'] = _.isBlockedUA;
24110 _['isEmptyObject'] = _.isEmptyObject;
24111 _['isObject'] = _.isObject;
24112 _['JSONDecode'] = _.JSONDecode;
24113 _['JSONEncode'] = _.JSONEncode;
24114 _['toArray'] = _.toArray;
24115 _['NPO'] = NpoPromise;
24116
24117 var MIXPANEL_DB_NAME = 'mixpanelBrowserDb';
24118
24119 var RECORDING_EVENTS_STORE_NAME = 'mixpanelRecordingEvents';
24120 var RECORDING_REGISTRY_STORE_NAME = 'mixpanelRecordingRegistry';
24121
24122 // note: increment the version number when adding new object stores
24123 var DB_VERSION = 1;
24124 var OBJECT_STORES = [RECORDING_EVENTS_STORE_NAME, RECORDING_REGISTRY_STORE_NAME];
24125
24126 /**
24127 * @type {import('./wrapper').StorageWrapper}
24128 */
24129 var IDBStorageWrapper = function (storeName) {
24130 /**
24131 * @type {Promise<IDBDatabase>|null}
24132 */
24133 this.dbPromise = null;
24134 this.storeName = storeName;
24135 };
24136
24137 IDBStorageWrapper.prototype._openDb = function () {
24138 return new PromisePolyfill(function (resolve, reject) {
24139 var openRequest = win.indexedDB.open(MIXPANEL_DB_NAME, DB_VERSION);
24140 openRequest['onerror'] = function () {
24141 reject(openRequest.error);
24142 };
24143
24144 openRequest['onsuccess'] = function () {
24145 resolve(openRequest.result);
24146 };
24147
24148 openRequest['onupgradeneeded'] = function (ev) {
24149 var db = ev.target.result;
24150
24151 OBJECT_STORES.forEach(function (storeName) {
24152 db.createObjectStore(storeName);
24153 });
24154 };
24155 });
24156 };
24157
24158 IDBStorageWrapper.prototype.init = function () {
24159 if (!win.indexedDB) {
24160 return PromisePolyfill.reject('indexedDB is not supported in this browser');
24161 }
24162
24163 if (!this.dbPromise) {
24164 this.dbPromise = this._openDb();
24165 }
24166
24167 return this.dbPromise
24168 .then(function (dbOrError) {
24169 if (dbOrError instanceof win['IDBDatabase']) {
24170 return PromisePolyfill.resolve();
24171 } else {
24172 return PromisePolyfill.reject(dbOrError);
24173 }
24174 });
24175 };
24176
24177 IDBStorageWrapper.prototype.isInitialized = function () {
24178 return !!this.dbPromise;
24179 };
24180
24181 /**
24182 * @param {IDBTransactionMode} mode
24183 * @param {function(IDBObjectStore): void} storeCb
24184 */
24185 IDBStorageWrapper.prototype.makeTransaction = function (mode, storeCb) {
24186 var storeName = this.storeName;
24187 var doTransaction = function (db) {
24188 return new PromisePolyfill(function (resolve, reject) {
24189 var transaction = db.transaction(storeName, mode);
24190 transaction.oncomplete = function () {
24191 resolve(transaction);
24192 };
24193 transaction.onabort = transaction.onerror = function () {
24194 reject(transaction.error);
24195 };
24196
24197 storeCb(transaction.objectStore(storeName));
24198 });
24199 };
24200
24201 return this.dbPromise
24202 .then(doTransaction)
24203 .catch(function (err) {
24204 if (err && err['name'] === 'InvalidStateError') {
24205 // try reopening the DB if the connection is closed
24206 this.dbPromise = this._openDb();
24207 return this.dbPromise.then(doTransaction);
24208 } else {
24209 return PromisePolyfill.reject(err);
24210 }
24211 }.bind(this));
24212 };
24213
24214 IDBStorageWrapper.prototype.setItem = function (key, value) {
24215 return this.makeTransaction('readwrite', function (objectStore) {
24216 objectStore.put(value, key);
24217 });
24218 };
24219
24220 IDBStorageWrapper.prototype.getItem = function (key) {
24221 var req;
24222 return this.makeTransaction('readonly', function (objectStore) {
24223 req = objectStore.get(key);
24224 }).then(function () {
24225 return req.result;
24226 });
24227 };
24228
24229 IDBStorageWrapper.prototype.removeItem = function (key) {
24230 return this.makeTransaction('readwrite', function (objectStore) {
24231 objectStore.delete(key);
24232 });
24233 };
24234
24235 IDBStorageWrapper.prototype.getAll = function () {
24236 var req;
24237 return this.makeTransaction('readonly', function (objectStore) {
24238 req = objectStore.getAll();
24239 }).then(function () {
24240 return req.result;
24241 });
24242 };
24243
24244 /**
24245 * GDPR utils
24246 *
24247 * The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
24248 * and privacy for all individuals within the European Union. It addresses the export of personal
24249 * data outside the EU. The GDPR aims primarily to give control back to citizens and residents
24250 * over their personal data and to simplify the regulatory environment for international business
24251 * by unifying the regulation within the EU.
24252 *
24253 * This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
24254 * These functions are used internally by the SDK and are not intended to be publicly exposed.
24255 */
24256
24257
24258 /**
24259 * A function used to track a Mixpanel event (e.g. MixpanelLib.track)
24260 * @callback trackFunction
24261 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
24262 * @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.
24263 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
24264 */
24265
24266 /** Public **/
24267
24268 var GDPR_DEFAULT_PERSISTENCE_PREFIX = '__mp_opt_in_out_';
24269
24270 /**
24271 * Opt the user in to data tracking and cookies/localstorage for the given token
24272 * @param {string} token - Mixpanel project tracking token
24273 * @param {Object} [options]
24274 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24275 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24276 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24277 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24278 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24279 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24280 * @param {string} [options.cookieDomain] - custom cookie domain
24281 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24282 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24283 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24284 */
24285 function optIn(token, options) {
24286 _optInOut(true, token, options);
24287 }
24288
24289 /**
24290 * Opt the user out of data tracking and cookies/localstorage for the given token
24291 * @param {string} token - Mixpanel project tracking token
24292 * @param {Object} [options]
24293 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24294 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24295 * @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires
24296 * @param {string} [options.cookieDomain] - custom cookie domain
24297 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24298 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not
24299 * @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not
24300 */
24301 function optOut(token, options) {
24302 _optInOut(false, token, options);
24303 }
24304
24305 /**
24306 * Check whether the user has opted in to data tracking and cookies/localstorage for the given token
24307 * @param {string} token - Mixpanel project tracking token
24308 * @param {Object} [options]
24309 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24310 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24311 * @returns {boolean} whether the user has opted in to the given opt type
24312 */
24313 function hasOptedIn(token, options) {
24314 return _getStorageValue(token, options) === '1';
24315 }
24316
24317 /**
24318 * Check whether the user has opted out of data tracking and cookies/localstorage for the given token
24319 * @param {string} token - Mixpanel project tracking token
24320 * @param {Object} [options]
24321 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24322 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24323 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24324 * @returns {boolean} whether the user has opted out of the given opt type
24325 */
24326 function hasOptedOut(token, options) {
24327 if (_hasDoNotTrackFlagOn(options)) {
24328 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"');
24329 return true;
24330 }
24331 var optedOut = _getStorageValue(token, options) === '0';
24332 if (optedOut) {
24333 console$1.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
24334 }
24335 return optedOut;
24336 }
24337
24338 /**
24339 * Wrap a MixpanelLib 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 addOptOutCheckMixpanelLib(method) {
24346 return _addOptOutCheck(method, function(name) {
24347 return this.get_config(name);
24348 });
24349 }
24350
24351 /**
24352 * Wrap a MixpanelPeople 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 addOptOutCheckMixpanelPeople(method) {
24359 return _addOptOutCheck(method, function(name) {
24360 return this._get_config(name);
24361 });
24362 }
24363
24364 /**
24365 * Wrap a MixpanelGroup method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24366 * If the user has opted out, return early instead of executing the method.
24367 * If a callback argument was provided, execute it passing the 0 error code.
24368 * @param {function} method - wrapped method to be executed if the user has not opted out
24369 * @returns {*} the result of executing method OR undefined if the user has opted out
24370 */
24371 function addOptOutCheckMixpanelGroup(method) {
24372 return _addOptOutCheck(method, function(name) {
24373 return this._get_config(name);
24374 });
24375 }
24376
24377 /**
24378 * Clear the user's opt in/out status of data tracking and cookies/localstorage for the given token
24379 * @param {string} token - Mixpanel project tracking token
24380 * @param {Object} [options]
24381 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24382 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24383 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24384 * @param {string} [options.cookieDomain] - custom cookie domain
24385 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24386 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24387 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24388 */
24389 function clearOptInOut(token, options) {
24390 options = options || {};
24391 _getStorage(options).remove(
24392 _getStorageKey(token, options), !!options.crossSubdomainCookie, options.cookieDomain
24393 );
24394 }
24395
24396 /** Private **/
24397
24398 /**
24399 * Get storage util
24400 * @param {Object} [options]
24401 * @param {string} [options.persistenceType]
24402 * @returns {object} either _.cookie or _.localstorage
24403 */
24404 function _getStorage(options) {
24405 options = options || {};
24406 return options.persistenceType === 'localStorage' ? _.localStorage : _.cookie;
24407 }
24408
24409 /**
24410 * Get the name of the cookie that is used for the given opt type (tracking, cookie, etc.)
24411 * @param {string} token - Mixpanel project tracking token
24412 * @param {Object} [options]
24413 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24414 * @returns {string} the name of the cookie for the given opt type
24415 */
24416 function _getStorageKey(token, options) {
24417 options = options || {};
24418 return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
24419 }
24420
24421 /**
24422 * Get the value of the cookie that is used for the given opt type (tracking, cookie, etc.)
24423 * @param {string} token - Mixpanel project tracking token
24424 * @param {Object} [options]
24425 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24426 * @returns {string} the value of the cookie for the given opt type
24427 */
24428 function _getStorageValue(token, options) {
24429 return _getStorage(options).get(_getStorageKey(token, options));
24430 }
24431
24432 /**
24433 * Check whether the user has set the DNT/doNotTrack setting to true in their browser
24434 * @param {Object} [options]
24435 * @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests
24436 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24437 * @returns {boolean} whether the DNT setting is true
24438 */
24439 function _hasDoNotTrackFlagOn(options) {
24440 if (options && options.ignoreDnt) {
24441 return false;
24442 }
24443 var win$1 = (options && options.window) || win;
24444 var nav = win$1['navigator'] || {};
24445 var hasDntOn = false;
24446
24447 _.each([
24448 nav['doNotTrack'], // standard
24449 nav['msDoNotTrack'],
24450 win$1['doNotTrack']
24451 ], function(dntValue) {
24452 if (_.includes([true, 1, '1', 'yes'], dntValue)) {
24453 hasDntOn = true;
24454 }
24455 });
24456
24457 return hasDntOn;
24458 }
24459
24460 /**
24461 * Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type
24462 * @param {boolean} optValue - whether to opt the user in or out for the given opt type
24463 * @param {string} token - Mixpanel project tracking token
24464 * @param {Object} [options]
24465 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24466 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24467 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24468 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24469 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24470 * @param {string} [options.cookieDomain] - custom cookie domain
24471 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24472 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24473 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24474 */
24475 function _optInOut(optValue, token, options) {
24476 if (!_.isString(token) || !token.length) {
24477 console$1.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token');
24478 return;
24479 }
24480
24481 options = options || {};
24482
24483 _getStorage(options).set(
24484 _getStorageKey(token, options),
24485 optValue ? 1 : 0,
24486 _.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
24487 !!options.crossSubdomainCookie,
24488 !!options.secureCookie,
24489 !!options.crossSiteCookie,
24490 options.cookieDomain
24491 );
24492
24493 if (options.track && optValue) { // only track event if opting in (optValue=true)
24494 options.track(options.trackEventName || '$opt_in', options.trackProperties, {
24495 'send_immediately': true
24496 });
24497 }
24498 }
24499
24500 /**
24501 * Wrap a method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24502 * If the user has opted out, return early instead of executing the method.
24503 * If a callback argument was provided, execute it passing the 0 error code.
24504 * @param {function} method - wrapped method to be executed if the user has not opted out
24505 * @param {function} getConfigValue - getter function for the Mixpanel API token and other options to be used with opt-out check
24506 * @returns {*} the result of executing method OR undefined if the user has opted out
24507 */
24508 function _addOptOutCheck(method, getConfigValue) {
24509 return function() {
24510 var optedOut = false;
24511
24512 try {
24513 var token = getConfigValue.call(this, 'token');
24514 var ignoreDnt = getConfigValue.call(this, 'ignore_dnt');
24515 var persistenceType = getConfigValue.call(this, 'opt_out_tracking_persistence_type');
24516 var persistencePrefix = getConfigValue.call(this, 'opt_out_tracking_cookie_prefix');
24517 var win = getConfigValue.call(this, 'window'); // used to override window during browser tests
24518
24519 if (token) { // if there was an issue getting the token, continue method execution as normal
24520 optedOut = hasOptedOut(token, {
24521 ignoreDnt: ignoreDnt,
24522 persistenceType: persistenceType,
24523 persistencePrefix: persistencePrefix,
24524 window: win
24525 });
24526 }
24527 } catch(err) {
24528 console$1.error('Unexpected error when checking tracking opt-out status: ' + err);
24529 }
24530
24531 if (!optedOut) {
24532 return method.apply(this, arguments);
24533 }
24534
24535 var callback = arguments[arguments.length - 1];
24536 if (typeof(callback) === 'function') {
24537 callback(0);
24538 }
24539
24540 return;
24541 };
24542 }
24543
24544 var logger$6 = console_with_prefix('lock');
24545
24546 /**
24547 * SharedLock: a mutex built on HTML5 localStorage, to ensure that only one browser
24548 * window/tab at a time will be able to access shared resources.
24549 *
24550 * Based on the Alur and Taubenfeld fast lock
24551 * (http://www.cs.rochester.edu/research/synchronization/pseudocode/fastlock.html)
24552 * with an added timeout to ensure there will be eventual progress in the event
24553 * that a window is closed in the middle of the callback.
24554 *
24555 * Implementation based on the original version by David Wolever (https://github.com/wolever)
24556 * at https://gist.github.com/wolever/5fd7573d1ef6166e8f8c4af286a69432.
24557 *
24558 * @example
24559 * const myLock = new SharedLock('some-key');
24560 * myLock.withLock(function() {
24561 * console.log('I hold the mutex!');
24562 * });
24563 *
24564 * @constructor
24565 */
24566 var SharedLock = function(key, options) {
24567 options = options || {};
24568
24569 this.storageKey = key;
24570 this.storage = options.storage || win.localStorage;
24571 this.pollIntervalMS = options.pollIntervalMS || 100;
24572 this.timeoutMS = options.timeoutMS || 2000;
24573
24574 // dependency-inject promise implementation for testing purposes
24575 this.promiseImpl = options.promiseImpl || PromisePolyfill;
24576 };
24577
24578 // pass in a specific pid to test contention scenarios; otherwise
24579 // it is chosen randomly for each acquisition attempt
24580 SharedLock.prototype.withLock = function(lockedCB, pid) {
24581 var Promise = this.promiseImpl;
24582 return new Promise(_.bind(function (resolve, reject) {
24583 var i = pid || (new Date().getTime() + '|' + Math.random());
24584 var startTime = new Date().getTime();
24585 var key = this.storageKey;
24586 var pollIntervalMS = this.pollIntervalMS;
24587 var timeoutMS = this.timeoutMS;
24588 var storage = this.storage;
24589
24590 var keyX = key + ':X';
24591 var keyY = key + ':Y';
24592 var keyZ = key + ':Z';
24593
24594 var delay = function(cb) {
24595 if (new Date().getTime() - startTime > timeoutMS) {
24596 logger$6.error('Timeout waiting for mutex on ' + key + '; clearing lock. [' + i + ']');
24597 storage.removeItem(keyZ);
24598 storage.removeItem(keyY);
24599 loop();
24600 return;
24601 }
24602 setTimeout(function() {
24603 try {
24604 cb();
24605 } catch(err) {
24606 reject(err);
24607 }
24608 }, pollIntervalMS * (Math.random() + 0.1));
24609 };
24610
24611 var waitFor = function(predicate, cb) {
24612 if (predicate()) {
24613 cb();
24614 } else {
24615 delay(function() {
24616 waitFor(predicate, cb);
24617 });
24618 }
24619 };
24620
24621 var getSetY = function() {
24622 var valY = storage.getItem(keyY);
24623 if (valY && valY !== i) { // if Y == i then this process already has the lock (useful for test cases)
24624 return false;
24625 } else {
24626 storage.setItem(keyY, i);
24627 if (storage.getItem(keyY) === i) {
24628 return true;
24629 } else {
24630 if (!localStorageSupported(storage, true)) {
24631 reject(new Error('localStorage support dropped while acquiring lock'));
24632 }
24633 return false;
24634 }
24635 }
24636 };
24637
24638 var loop = function() {
24639 storage.setItem(keyX, i);
24640
24641 waitFor(getSetY, function() {
24642 if (storage.getItem(keyX) === i) {
24643 criticalSection();
24644 return;
24645 }
24646
24647 delay(function() {
24648 if (storage.getItem(keyY) !== i) {
24649 loop();
24650 return;
24651 }
24652 waitFor(function() {
24653 return !storage.getItem(keyZ);
24654 }, criticalSection);
24655 });
24656 });
24657 };
24658
24659 var criticalSection = function() {
24660 storage.setItem(keyZ, '1');
24661 var removeLock = function () {
24662 storage.removeItem(keyZ);
24663 if (storage.getItem(keyY) === i) {
24664 storage.removeItem(keyY);
24665 }
24666 if (storage.getItem(keyX) === i) {
24667 storage.removeItem(keyX);
24668 }
24669 };
24670
24671 lockedCB()
24672 .then(function (ret) {
24673 removeLock();
24674 resolve(ret);
24675 })
24676 .catch(function (err) {
24677 removeLock();
24678 reject(err);
24679 });
24680 };
24681
24682 try {
24683 if (localStorageSupported(storage, true)) {
24684 loop();
24685 } else {
24686 throw new Error('localStorage support check failed');
24687 }
24688 } catch(err) {
24689 reject(err);
24690 }
24691 }, this));
24692 };
24693
24694 /**
24695 * @type {import('./wrapper').StorageWrapper}
24696 */
24697 var LocalStorageWrapper = function (storageOverride) {
24698 this.storage = storageOverride || win.localStorage;
24699 };
24700
24701 LocalStorageWrapper.prototype.init = function () {
24702 return PromisePolyfill.resolve();
24703 };
24704
24705 LocalStorageWrapper.prototype.isInitialized = function () {
24706 return true;
24707 };
24708
24709 LocalStorageWrapper.prototype.setItem = function (key, value) {
24710 return new PromisePolyfill(_.bind(function (resolve, reject) {
24711 try {
24712 this.storage.setItem(key, JSONStringify(value));
24713 } catch (e) {
24714 reject(e);
24715 }
24716 resolve();
24717 }, this));
24718 };
24719
24720 LocalStorageWrapper.prototype.getItem = function (key) {
24721 return new PromisePolyfill(_.bind(function (resolve, reject) {
24722 var item;
24723 try {
24724 item = JSONParse(this.storage.getItem(key));
24725 } catch (e) {
24726 reject(e);
24727 }
24728 resolve(item);
24729 }, this));
24730 };
24731
24732 LocalStorageWrapper.prototype.removeItem = function (key) {
24733 return new PromisePolyfill(_.bind(function (resolve, reject) {
24734 try {
24735 this.storage.removeItem(key);
24736 } catch (e) {
24737 reject(e);
24738 }
24739 resolve();
24740 }, this));
24741 };
24742
24743 var logger$5 = console_with_prefix('batch');
24744
24745 /**
24746 * RequestQueue: queue for batching API requests with localStorage backup for retries.
24747 * Maintains an in-memory queue which represents the source of truth for the current
24748 * page, but also writes all items out to a copy in the browser's localStorage, which
24749 * can be read on subsequent pageloads and retried. For batchability, all the request
24750 * items in the queue should be of the same type (events, people updates, group updates)
24751 * so they can be sent in a single request to the same API endpoint.
24752 *
24753 * LocalStorage keying and locking: In order for reloads and subsequent pageloads of
24754 * the same site to access the same persisted data, they must share the same localStorage
24755 * key (for instance based on project token and queue type). Therefore access to the
24756 * localStorage entry is guarded by an asynchronous mutex (SharedLock) to prevent
24757 * simultaneously open windows/tabs from overwriting each other's data (which would lead
24758 * to data loss in some situations).
24759 * @constructor
24760 */
24761 var RequestQueue = function (storageKey, options) {
24762 options = options || {};
24763 this.storageKey = storageKey;
24764 this.usePersistence = options.usePersistence;
24765 if (this.usePersistence) {
24766 this.queueStorage = options.queueStorage || new LocalStorageWrapper();
24767 this.lock = new SharedLock(storageKey, {
24768 storage: options.sharedLockStorage || win.localStorage,
24769 timeoutMS: options.sharedLockTimeoutMS,
24770 });
24771 }
24772 this.reportError = options.errorReporter || _.bind(logger$5.error, logger$5);
24773
24774 this.pid = options.pid || null; // pass pid to test out storage lock contention scenarios
24775
24776 this.memQueue = [];
24777 this.initialized = false;
24778
24779 if (options.enqueueThrottleMs) {
24780 this.enqueuePersisted = batchedThrottle(_.bind(this._enqueuePersisted, this), options.enqueueThrottleMs);
24781 } else {
24782 this.enqueuePersisted = _.bind(function (queueEntry) {
24783 return this._enqueuePersisted([queueEntry]);
24784 }, this);
24785 }
24786 };
24787
24788 RequestQueue.prototype.ensureInit = function () {
24789 if (this.initialized || !this.usePersistence) {
24790 return PromisePolyfill.resolve();
24791 }
24792
24793 return this.queueStorage
24794 .init()
24795 .then(_.bind(function () {
24796 this.initialized = true;
24797 }, this))
24798 .catch(_.bind(function (err) {
24799 this.reportError('Error initializing queue persistence. Disabling persistence', err);
24800 this.initialized = true;
24801 this.usePersistence = false;
24802 }, this));
24803 };
24804
24805 /**
24806 * Add one item to queues (memory and localStorage). The queued entry includes
24807 * the given item along with an auto-generated ID and a "flush-after" timestamp.
24808 * It is expected that the item will be sent over the network and dequeued
24809 * before the flush-after time; if this doesn't happen it is considered orphaned
24810 * (e.g., the original tab where it was enqueued got closed before it could be
24811 * sent) and the item can be sent by any tab that finds it in localStorage.
24812 *
24813 * The final callback param is called with a param indicating success or
24814 * failure of the enqueue operation; it is asynchronous because the localStorage
24815 * lock is asynchronous.
24816 */
24817 RequestQueue.prototype.enqueue = function (item, flushInterval) {
24818 var queueEntry = {
24819 'id': cheap_guid(),
24820 'flushAfter': new Date().getTime() + flushInterval * 2,
24821 'payload': item
24822 };
24823
24824 if (!this.usePersistence) {
24825 this.memQueue.push(queueEntry);
24826 return PromisePolyfill.resolve(true);
24827 } else {
24828 return this.enqueuePersisted(queueEntry);
24829 }
24830 };
24831
24832 RequestQueue.prototype._enqueuePersisted = function (queueEntries) {
24833 var enqueueItem = _.bind(function () {
24834 return this.ensureInit()
24835 .then(_.bind(function () {
24836 return this.readFromStorage();
24837 }, this))
24838 .then(_.bind(function (storedQueue) {
24839 return this.saveToStorage(storedQueue.concat(queueEntries));
24840 }, this))
24841 .then(_.bind(function (succeeded) {
24842 // only add to in-memory queue when storage succeeds
24843 if (succeeded) {
24844 this.memQueue = this.memQueue.concat(queueEntries);
24845 }
24846
24847 return succeeded;
24848 }, this))
24849 .catch(_.bind(function (err) {
24850 this.reportError('Error enqueueing items', err, queueEntries);
24851 return false;
24852 }, this));
24853 }, this);
24854
24855 return this.lock
24856 .withLock(enqueueItem, this.pid)
24857 .catch(_.bind(function (err) {
24858 this.reportError('Error acquiring storage lock', err);
24859 return false;
24860 }, this));
24861 };
24862
24863 /**
24864 * Read out the given number of queue entries. If this.memQueue
24865 * has fewer than batchSize items, then look for "orphaned" items
24866 * in the persisted queue (items where the 'flushAfter' time has
24867 * already passed).
24868 */
24869 RequestQueue.prototype.fillBatch = function (batchSize) {
24870 var batch = this.memQueue.slice(0, batchSize);
24871 if (this.usePersistence && batch.length < batchSize) {
24872 // don't need lock just to read events; localStorage is thread-safe
24873 // and the worst that could happen is a duplicate send of some
24874 // orphaned events, which will be deduplicated on the server side
24875 return this.ensureInit()
24876 .then(_.bind(function () {
24877 return this.readFromStorage();
24878 }, this))
24879 .then(_.bind(function (storedQueue) {
24880 if (storedQueue.length) {
24881 // item IDs already in batch; don't duplicate out of storage
24882 var idsInBatch = {}; // poor man's Set
24883 _.each(batch, function (item) {
24884 idsInBatch[item['id']] = true;
24885 });
24886
24887 for (var i = 0; i < storedQueue.length; i++) {
24888 var item = storedQueue[i];
24889 if (new Date().getTime() > item['flushAfter'] && !idsInBatch[item['id']]) {
24890 item.orphaned = true;
24891 batch.push(item);
24892 if (batch.length >= batchSize) {
24893 break;
24894 }
24895 }
24896 }
24897 }
24898
24899 return batch;
24900 }, this));
24901 } else {
24902 return PromisePolyfill.resolve(batch);
24903 }
24904 };
24905
24906 /**
24907 * Remove items with matching 'id' from array (immutably)
24908 * also remove any item without a valid id (e.g., malformed
24909 * storage entries).
24910 */
24911 var filterOutIDsAndInvalid = function (items, idSet) {
24912 var filteredItems = [];
24913 _.each(items, function (item) {
24914 if (item['id'] && !idSet[item['id']]) {
24915 filteredItems.push(item);
24916 }
24917 });
24918 return filteredItems;
24919 };
24920
24921 /**
24922 * Remove items with matching IDs from both in-memory queue
24923 * and persisted queue
24924 */
24925 RequestQueue.prototype.removeItemsByID = function (ids) {
24926 var idSet = {}; // poor man's Set
24927 _.each(ids, function (id) {
24928 idSet[id] = true;
24929 });
24930
24931 this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
24932 if (!this.usePersistence) {
24933 return PromisePolyfill.resolve(true);
24934 } else {
24935 var removeFromStorage = _.bind(function () {
24936 return this.ensureInit()
24937 .then(_.bind(function () {
24938 return this.readFromStorage();
24939 }, this))
24940 .then(_.bind(function (storedQueue) {
24941 storedQueue = filterOutIDsAndInvalid(storedQueue, idSet);
24942 return this.saveToStorage(storedQueue);
24943 }, this))
24944 .then(_.bind(function () {
24945 return this.readFromStorage();
24946 }, this))
24947 .then(_.bind(function (storedQueue) {
24948 // an extra check: did storage report success but somehow
24949 // the items are still there?
24950 for (var i = 0; i < storedQueue.length; i++) {
24951 var item = storedQueue[i];
24952 if (item['id'] && !!idSet[item['id']]) {
24953 throw new Error('Item not removed from storage');
24954 }
24955 }
24956 return true;
24957 }, this))
24958 .catch(_.bind(function (err) {
24959 this.reportError('Error removing items', err, ids);
24960 return false;
24961 }, this));
24962 }, this);
24963
24964 return this.lock
24965 .withLock(removeFromStorage, this.pid)
24966 .catch(_.bind(function (err) {
24967 this.reportError('Error acquiring storage lock', err);
24968 if (!localStorageSupported(this.lock.storage, true)) {
24969 // Looks like localStorage writes have stopped working sometime after
24970 // initialization (probably full), and so nobody can acquire locks
24971 // anymore. Consider it temporarily safe to remove items without the
24972 // lock, since nobody's writing successfully anyway.
24973 return removeFromStorage()
24974 .then(_.bind(function (success) {
24975 if (!success) {
24976 // OK, we couldn't even write out the smaller queue. Try clearing it
24977 // entirely.
24978 return this.queueStorage.removeItem(this.storageKey).then(function () {
24979 return success;
24980 });
24981 }
24982 return success;
24983 }, this))
24984 .catch(_.bind(function (err) {
24985 this.reportError('Error clearing queue', err);
24986 return false;
24987 }, this));
24988 } else {
24989 return false;
24990 }
24991 }, this));
24992 }
24993 };
24994
24995 // internal helper for RequestQueue.updatePayloads
24996 var updatePayloads = function (existingItems, itemsToUpdate) {
24997 var newItems = [];
24998 _.each(existingItems, function (item) {
24999 var id = item['id'];
25000 if (id in itemsToUpdate) {
25001 var newPayload = itemsToUpdate[id];
25002 if (newPayload !== null) {
25003 item['payload'] = newPayload;
25004 newItems.push(item);
25005 }
25006 } else {
25007 // no update
25008 newItems.push(item);
25009 }
25010 });
25011 return newItems;
25012 };
25013
25014 /**
25015 * Update payloads of given items in both in-memory queue and
25016 * persisted queue. Items set to null are removed from queues.
25017 */
25018 RequestQueue.prototype.updatePayloads = function (itemsToUpdate) {
25019 this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
25020 if (!this.usePersistence) {
25021 return PromisePolyfill.resolve(true);
25022 } else {
25023 return this.lock
25024 .withLock(_.bind(function lockAcquired() {
25025 return this.ensureInit()
25026 .then(_.bind(function () {
25027 return this.readFromStorage();
25028 }, this))
25029 .then(_.bind(function (storedQueue) {
25030 storedQueue = updatePayloads(storedQueue, itemsToUpdate);
25031 return this.saveToStorage(storedQueue);
25032 }, this))
25033 .catch(_.bind(function (err) {
25034 this.reportError('Error updating items', itemsToUpdate, err);
25035 return false;
25036 }, this));
25037 }, this), this.pid)
25038 .catch(_.bind(function (err) {
25039 this.reportError('Error acquiring storage lock', err);
25040 return false;
25041 }, this));
25042 }
25043 };
25044
25045 /**
25046 * Read and parse items array from localStorage entry, handling
25047 * malformed/missing data if necessary.
25048 */
25049 RequestQueue.prototype.readFromStorage = function () {
25050 return this.ensureInit()
25051 .then(_.bind(function () {
25052 return this.queueStorage.getItem(this.storageKey);
25053 }, this))
25054 .then(_.bind(function (storageEntry) {
25055 if (storageEntry) {
25056 if (!_.isArray(storageEntry)) {
25057 this.reportError('Invalid storage entry:', storageEntry);
25058 storageEntry = null;
25059 }
25060 }
25061 return storageEntry || [];
25062 }, this))
25063 .catch(_.bind(function (err) {
25064 this.reportError('Error retrieving queue', err);
25065 return [];
25066 }, this));
25067 };
25068
25069 /**
25070 * Serialize the given items array to localStorage.
25071 */
25072 RequestQueue.prototype.saveToStorage = function (queue) {
25073 return this.ensureInit()
25074 .then(_.bind(function () {
25075 return this.queueStorage.setItem(this.storageKey, queue);
25076 }, this))
25077 .then(function () {
25078 return true;
25079 })
25080 .catch(_.bind(function (err) {
25081 this.reportError('Error saving queue', err);
25082 return false;
25083 }, this));
25084 };
25085
25086 /**
25087 * Clear out queues (memory and localStorage).
25088 */
25089 RequestQueue.prototype.clear = function () {
25090 this.memQueue = [];
25091
25092 if (this.usePersistence) {
25093 return this.ensureInit()
25094 .then(_.bind(function () {
25095 return this.queueStorage.removeItem(this.storageKey);
25096 }, this));
25097 } else {
25098 return PromisePolyfill.resolve();
25099 }
25100 };
25101
25102 // maximum interval between request retries after exponential backoff
25103 var MAX_RETRY_INTERVAL_MS = 10 * 60 * 1000; // 10 minutes
25104
25105 var logger$4 = console_with_prefix('batch');
25106
25107 /**
25108 * RequestBatcher: manages the queueing, flushing, retry etc of requests of one
25109 * type (events, people, groups).
25110 * Uses RequestQueue to manage the backing store.
25111 * @constructor
25112 */
25113 var RequestBatcher = function(storageKey, options) {
25114 this.errorReporter = options.errorReporter;
25115 this.queue = new RequestQueue(storageKey, {
25116 errorReporter: _.bind(this.reportError, this),
25117 queueStorage: options.queueStorage,
25118 sharedLockStorage: options.sharedLockStorage,
25119 sharedLockTimeoutMS: options.sharedLockTimeoutMS,
25120 usePersistence: options.usePersistence,
25121 enqueueThrottleMs: options.enqueueThrottleMs
25122 });
25123
25124 this.libConfig = options.libConfig;
25125 this.sendRequest = options.sendRequestFunc;
25126 this.beforeSendHook = options.beforeSendHook;
25127 this.stopAllBatching = options.stopAllBatchingFunc;
25128
25129 // seed variable batch size + flush interval with configured values
25130 this.batchSize = this.libConfig['batch_size'];
25131 this.flushInterval = this.libConfig['batch_flush_interval_ms'];
25132
25133 this.stopped = !this.libConfig['batch_autostart'];
25134 this.consecutiveRemovalFailures = 0;
25135
25136 // extra client-side dedupe
25137 this.itemIdsSentSuccessfully = {};
25138
25139 // Make the flush occur at the interval specified by flushIntervalMs, default behavior will attempt consecutive flushes
25140 // as long as the queue is not empty. This is useful for high-frequency events like Session Replay where we might end up
25141 // in a request loop and get ratelimited by the server.
25142 this.flushOnlyOnInterval = options.flushOnlyOnInterval || false;
25143
25144 this._flushPromise = null;
25145 };
25146
25147 /**
25148 * Add one item to queue.
25149 */
25150 RequestBatcher.prototype.enqueue = function(item) {
25151 return this.queue.enqueue(item, this.flushInterval);
25152 };
25153
25154 /**
25155 * Start flushing batches at the configured time interval. Must call
25156 * this method upon SDK init in order to send anything over the network.
25157 */
25158 RequestBatcher.prototype.start = function() {
25159 this.stopped = false;
25160 this.consecutiveRemovalFailures = 0;
25161 return this.flush();
25162 };
25163
25164 /**
25165 * Stop flushing batches. Can be restarted by calling start().
25166 */
25167 RequestBatcher.prototype.stop = function() {
25168 this.stopped = true;
25169 if (this.timeoutID) {
25170 clearTimeout(this.timeoutID);
25171 this.timeoutID = null;
25172 }
25173 };
25174
25175 /**
25176 * Clear out queue.
25177 */
25178 RequestBatcher.prototype.clear = function() {
25179 return this.queue.clear();
25180 };
25181
25182 /**
25183 * Restore batch size configuration to whatever is set in the main SDK.
25184 */
25185 RequestBatcher.prototype.resetBatchSize = function() {
25186 this.batchSize = this.libConfig['batch_size'];
25187 };
25188
25189 /**
25190 * Restore flush interval time configuration to whatever is set in the main SDK.
25191 */
25192 RequestBatcher.prototype.resetFlush = function() {
25193 this.scheduleFlush(this.libConfig['batch_flush_interval_ms']);
25194 };
25195
25196 /**
25197 * Schedule the next flush in the given number of milliseconds.
25198 */
25199 RequestBatcher.prototype.scheduleFlush = function(flushMS) {
25200 this.flushInterval = flushMS;
25201 if (!this.stopped) { // don't schedule anymore if batching has been stopped
25202 this.timeoutID = setTimeout(_.bind(function() {
25203 if (!this.stopped) {
25204 this._flushPromise = this.flush();
25205 }
25206 }, this), this.flushInterval);
25207 }
25208 };
25209
25210 /**
25211 * Send a request using the sendRequest callback, but promisified.
25212 * TODO: sendRequest should be promisified in the first place.
25213 */
25214 RequestBatcher.prototype.sendRequestPromise = function(data, options) {
25215 return new PromisePolyfill(_.bind(function(resolve) {
25216 this.sendRequest(data, options, resolve);
25217 }, this));
25218 };
25219
25220
25221 /**
25222 * Flush one batch to network. Depending on success/failure modes, it will either
25223 * remove the batch from the queue or leave it in for retry, and schedule the next
25224 * flush. In cases of most network or API failures, it will back off exponentially
25225 * when retrying.
25226 * @param {Object} [options]
25227 * @param {boolean} [options.sendBeacon] - whether to send batch with
25228 * navigator.sendBeacon (only useful for sending batches before page unloads, as
25229 * sendBeacon offers no callbacks or status indications)
25230 */
25231 RequestBatcher.prototype.flush = function(options) {
25232 if (this.requestInProgress) {
25233 logger$4.log('Flush: Request already in progress');
25234 return PromisePolyfill.resolve();
25235 }
25236
25237 this.requestInProgress = true;
25238
25239 options = options || {};
25240 var timeoutMS = this.libConfig['batch_request_timeout_ms'];
25241 var startTime = new Date().getTime();
25242 var currentBatchSize = this.batchSize;
25243
25244 return this.queue.fillBatch(currentBatchSize)
25245 .then(_.bind(function(batch) {
25246
25247 // if there's more items in the queue than the batch size, attempt
25248 // to flush again after the current batch is done.
25249 var attemptSecondaryFlush = batch.length === currentBatchSize;
25250 var dataForRequest = [];
25251 var transformedItems = {};
25252 _.each(batch, function(item) {
25253 var payload = item['payload'];
25254 if (this.beforeSendHook && !item.orphaned) {
25255 payload = this.beforeSendHook(payload);
25256 }
25257 if (payload) {
25258 // mp_sent_by_lib_version prop captures which lib version actually
25259 // sends each event (regardless of which version originally queued
25260 // it for sending)
25261 if (payload['event'] && payload['properties']) {
25262 payload['properties'] = _.extend(
25263 {},
25264 payload['properties'],
25265 {'mp_sent_by_lib_version': Config.LIB_VERSION}
25266 );
25267 }
25268 var addPayload = true;
25269 var itemId = item['id'];
25270 if (itemId) {
25271 if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
25272 this.reportError('[dupe] item ID sent too many times, not sending', {
25273 item: item,
25274 batchSize: batch.length,
25275 timesSent: this.itemIdsSentSuccessfully[itemId]
25276 });
25277 addPayload = false;
25278 }
25279 } else {
25280 this.reportError('[dupe] found item with no ID', {item: item});
25281 }
25282
25283 if (addPayload) {
25284 dataForRequest.push(payload);
25285 }
25286 }
25287 transformedItems[item['id']] = payload;
25288 }, this);
25289
25290 if (dataForRequest.length < 1) {
25291 this.requestInProgress = false;
25292 this.resetFlush();
25293 return PromisePolyfill.resolve(); // nothing to do
25294 }
25295
25296 var removeItemsFromQueue = _.bind(function () {
25297 return this.queue
25298 .removeItemsByID(
25299 _.map(batch, function (item) {
25300 return item['id'];
25301 })
25302 )
25303 .then(_.bind(function (succeeded) {
25304 // client-side dedupe
25305 _.each(batch, _.bind(function(item) {
25306 var itemId = item['id'];
25307 if (itemId) {
25308 this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
25309 this.itemIdsSentSuccessfully[itemId]++;
25310 if (this.itemIdsSentSuccessfully[itemId] > 5) {
25311 this.reportError('[dupe] item ID sent too many times', {
25312 item: item,
25313 batchSize: batch.length,
25314 timesSent: this.itemIdsSentSuccessfully[itemId]
25315 });
25316 }
25317 } else {
25318 this.reportError('[dupe] found item with no ID while removing', {item: item});
25319 }
25320 }, this));
25321
25322 if (succeeded) {
25323 this.consecutiveRemovalFailures = 0;
25324 if (this.flushOnlyOnInterval && !attemptSecondaryFlush) {
25325 this.resetFlush(); // schedule next batch with a delay
25326 return PromisePolyfill.resolve();
25327 } else {
25328 return this.flush(); // handle next batch if the queue isn't empty
25329 }
25330 } else {
25331 if (++this.consecutiveRemovalFailures > 5) {
25332 this.reportError('Too many queue failures; disabling batching system.');
25333 this.stopAllBatching();
25334 } else {
25335 this.resetFlush();
25336 }
25337 return PromisePolyfill.resolve();
25338 }
25339 }, this));
25340 }, this);
25341
25342 var batchSendCallback = _.bind(function(res) {
25343 this.requestInProgress = false;
25344
25345 try {
25346
25347 // handle API response in a try-catch to make sure we can reset the
25348 // flush operation if something goes wrong
25349
25350 if (options.unloading) {
25351 // update persisted data to include hook transformations
25352 return this.queue.updatePayloads(transformedItems);
25353 } else if (
25354 _.isObject(res) &&
25355 res.error === 'timeout' &&
25356 new Date().getTime() - startTime >= timeoutMS
25357 ) {
25358 this.reportError('Network timeout; retrying');
25359 return this.flush();
25360 } else if (
25361 _.isObject(res) &&
25362 (
25363 res.httpStatusCode >= 500
25364 || res.httpStatusCode === 429
25365 || (res.httpStatusCode <= 0 && !isOnline())
25366 || res.error === 'timeout'
25367 )
25368 ) {
25369 // network or API error, or 429 Too Many Requests, retry
25370 var retryMS = this.flushInterval * 2;
25371 if (res.retryAfter) {
25372 retryMS = (parseInt(res.retryAfter, 10) * 1000) || retryMS;
25373 }
25374 retryMS = Math.min(MAX_RETRY_INTERVAL_MS, retryMS);
25375 this.reportError('Error; retry in ' + retryMS + ' ms');
25376 this.scheduleFlush(retryMS);
25377 return PromisePolyfill.resolve();
25378 } else if (_.isObject(res) && res.httpStatusCode === 413) {
25379 // 413 Payload Too Large
25380 if (batch.length > 1) {
25381 var halvedBatchSize = Math.max(1, Math.floor(currentBatchSize / 2));
25382 this.batchSize = Math.min(this.batchSize, halvedBatchSize, batch.length - 1);
25383 this.reportError('413 response; reducing batch size to ' + this.batchSize);
25384 this.resetFlush();
25385 return PromisePolyfill.resolve();
25386 } else {
25387 this.reportError('Single-event request too large; dropping', batch);
25388 this.resetBatchSize();
25389 return removeItemsFromQueue();
25390 }
25391 } else {
25392 // successful network request+response; remove each item in batch from queue
25393 // (even if it was e.g. a 400, in which case retrying won't help)
25394 return removeItemsFromQueue();
25395 }
25396 } catch(err) {
25397 this.reportError('Error handling API response', err);
25398 this.resetFlush();
25399 }
25400 }, this);
25401 var requestOptions = {
25402 method: 'POST',
25403 verbose: true,
25404 ignore_json_errors: true, // eslint-disable-line camelcase
25405 timeout_ms: timeoutMS // eslint-disable-line camelcase
25406 };
25407 if (options.unloading) {
25408 requestOptions.transport = 'sendBeacon';
25409 }
25410 logger$4.log('MIXPANEL REQUEST:', dataForRequest);
25411 return this.sendRequestPromise(dataForRequest, requestOptions).then(batchSendCallback);
25412 }, this))
25413 .catch(_.bind(function(err) {
25414 this.reportError('Error flushing request queue', err);
25415 this.resetFlush();
25416 }, this));
25417 };
25418
25419 /**
25420 * Log error to global logger and optional user-defined logger.
25421 */
25422 RequestBatcher.prototype.reportError = function(msg, err) {
25423 logger$4.error.apply(logger$4.error, arguments);
25424 if (this.errorReporter) {
25425 try {
25426 if (!(err instanceof Error)) {
25427 err = new Error(msg);
25428 }
25429 this.errorReporter(msg, err);
25430 } catch(err) {
25431 logger$4.error(err);
25432 }
25433 }
25434 };
25435
25436 /**
25437 * @param {import('./session-recording').SerializedRecording} serializedRecording
25438 * @returns {boolean}
25439 */
25440 var isRecordingExpired = function(serializedRecording) {
25441 var now = Date.now();
25442 return !serializedRecording || now > serializedRecording['maxExpires'] || now > serializedRecording['idleExpires'];
25443 };
25444
25445 var RECORD_ENQUEUE_THROTTLE_MS = 250;
25446
25447 var logger$3 = console_with_prefix('recorder');
25448 var CompressionStream = win['CompressionStream'];
25449
25450 var RECORDER_BATCHER_LIB_CONFIG = {
25451 'batch_size': 1000,
25452 'batch_flush_interval_ms': 10 * 1000,
25453 'batch_request_timeout_ms': 90 * 1000,
25454 'batch_autostart': true
25455 };
25456
25457 var ACTIVE_SOURCES = new Set([
25458 IncrementalSource.MouseMove,
25459 IncrementalSource.MouseInteraction,
25460 IncrementalSource.Scroll,
25461 IncrementalSource.ViewportResize,
25462 IncrementalSource.Input,
25463 IncrementalSource.TouchMove,
25464 IncrementalSource.MediaInteraction,
25465 IncrementalSource.Drag,
25466 IncrementalSource.Selection,
25467 ]);
25468
25469 function isUserEvent(ev) {
25470 return ev.type === EventType.IncrementalSnapshot && ACTIVE_SOURCES.has(ev.data.source);
25471 }
25472
25473 /**
25474 * @typedef {Object} SerializedRecording
25475 * @property {number} idleExpires
25476 * @property {number} maxExpires
25477 * @property {number} replayStartTime
25478 * @property {number} seqNo
25479 * @property {string} batchStartUrl
25480 * @property {string} replayId
25481 * @property {string} tabId
25482 * @property {string} replayStartUrl
25483 */
25484
25485 /**
25486 * @typedef {Object} SessionRecordingOptions
25487 * @property {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
25488 * @property {String} [options.replayId] - unique uuid for a single replay
25489 * @property {Function} [options.onIdleTimeout] - callback when a recording reaches idle timeout
25490 * @property {Function} [options.onMaxLengthReached] - callback when a recording reaches its maximum length
25491 * @property {Function} [options.rrwebRecord] - rrweb's `record` function
25492 * @property {Function} [options.onBatchSent] - callback when a batch of events is sent to the server
25493 * @property {Storage} [options.sharedLockStorage] - optional storage for shared lock, used for test dependency injection
25494 * optional properties for deserialization:
25495 * @property {number} idleExpires
25496 * @property {number} maxExpires
25497 * @property {number} replayStartTime
25498 * @property {number} seqNo
25499 * @property {string} batchStartUrl
25500 * @property {string} replayStartUrl
25501 */
25502
25503 /**
25504 * @typedef {Object} UserIdInfo
25505 * @property {string} distinct_id
25506 * @property {string} user_id
25507 * @property {string} device_id
25508 */
25509
25510
25511 /**
25512 * This class encapsulates a single session recording and its lifecycle.
25513 * @param {SessionRecordingOptions} options
25514 */
25515 var SessionRecording = function(options) {
25516 this._mixpanel = options.mixpanelInstance;
25517 this._onIdleTimeout = options.onIdleTimeout || NOOP_FUNC;
25518 this._onMaxLengthReached = options.onMaxLengthReached || NOOP_FUNC;
25519 this._onBatchSent = options.onBatchSent || NOOP_FUNC;
25520 this._rrwebRecord = options.rrwebRecord || null;
25521
25522 // internal rrweb stopRecording function
25523 this._stopRecording = null;
25524 this.replayId = options.replayId;
25525
25526 this.batchStartUrl = options.batchStartUrl || null;
25527 this.replayStartUrl = options.replayStartUrl || null;
25528 this.idleExpires = options.idleExpires || null;
25529 this.maxExpires = options.maxExpires || null;
25530 this.replayStartTime = options.replayStartTime || null;
25531 this.seqNo = options.seqNo || 0;
25532
25533 this.idleTimeoutId = null;
25534 this.maxTimeoutId = null;
25535
25536 this.recordMaxMs = MAX_RECORDING_MS;
25537 this.recordMinMs = 0;
25538
25539 // disable persistence if localStorage is not supported
25540 // request-queue will automatically disable persistence if indexedDB fails to initialize
25541 var usePersistence = localStorageSupported(options.sharedLockStorage, true) && !this.getConfig('disable_persistence');
25542
25543 // each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
25544 this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
25545 this.queueStorage = new IDBStorageWrapper(RECORDING_EVENTS_STORE_NAME);
25546 this.batcher = new RequestBatcher(this.batcherKey, {
25547 errorReporter: this.reportError.bind(this),
25548 flushOnlyOnInterval: true,
25549 libConfig: RECORDER_BATCHER_LIB_CONFIG,
25550 sendRequestFunc: this.flushEventsWithOptOut.bind(this),
25551 queueStorage: this.queueStorage,
25552 sharedLockStorage: options.sharedLockStorage,
25553 usePersistence: usePersistence,
25554 stopAllBatchingFunc: this.stopRecording.bind(this),
25555
25556 // increased throttle and shared lock timeout because recording events are very high frequency.
25557 // this will minimize the amount of lock contention between enqueued events.
25558 // for session recordings there is a lock for each tab anyway, so there's no risk of deadlock between tabs.
25559 enqueueThrottleMs: RECORD_ENQUEUE_THROTTLE_MS,
25560 sharedLockTimeoutMS: 10 * 1000,
25561 });
25562 };
25563
25564 /**
25565 * @returns {UserIdInfo}
25566 */
25567 SessionRecording.prototype.getUserIdInfo = function () {
25568 if (this.finalFlushUserIdInfo) {
25569 return this.finalFlushUserIdInfo;
25570 }
25571
25572 var userIdInfo = {
25573 'distinct_id': String(this._mixpanel.get_distinct_id()),
25574 };
25575
25576 // send ID management props if they exist
25577 var deviceId = this._mixpanel.get_property('$device_id');
25578 if (deviceId) {
25579 userIdInfo['$device_id'] = deviceId;
25580 }
25581 var userId = this._mixpanel.get_property('$user_id');
25582 if (userId) {
25583 userIdInfo['$user_id'] = userId;
25584 }
25585 return userIdInfo;
25586 };
25587
25588 SessionRecording.prototype.unloadPersistedData = function () {
25589 this.batcher.stop();
25590 return this.batcher.flush()
25591 .then(function () {
25592 return this.queueStorage.removeItem(this.batcherKey);
25593 }.bind(this));
25594 };
25595
25596 SessionRecording.prototype.getConfig = function(configVar) {
25597 return this._mixpanel.get_config(configVar);
25598 };
25599
25600 // Alias for getConfig, used by the common addOptOutCheckMixpanelLib function which
25601 // reaches into this class instance and expects the snake case version of the function.
25602 // eslint-disable-next-line camelcase
25603 SessionRecording.prototype.get_config = function(configVar) {
25604 return this.getConfig(configVar);
25605 };
25606
25607 SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
25608 if (this._rrwebRecord === null) {
25609 this.reportError('rrweb record function not provided. ');
25610 return;
25611 }
25612
25613 if (this._stopRecording !== null) {
25614 logger$3.log('Recording already in progress, skipping startRecording.');
25615 return;
25616 }
25617
25618 this.recordMaxMs = this.getConfig('record_max_ms');
25619 if (this.recordMaxMs > MAX_RECORDING_MS) {
25620 this.recordMaxMs = MAX_RECORDING_MS;
25621 logger$3.critical('record_max_ms cannot be greater than ' + MAX_RECORDING_MS + 'ms. Capping value.');
25622 }
25623
25624 if (!this.maxExpires) {
25625 this.maxExpires = new Date().getTime() + this.recordMaxMs;
25626 }
25627
25628 this.recordMinMs = this.getConfig('record_min_ms');
25629 if (this.recordMinMs > MAX_VALUE_FOR_MIN_RECORDING_MS) {
25630 this.recordMinMs = MAX_VALUE_FOR_MIN_RECORDING_MS;
25631 logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
25632 }
25633
25634 if (!this.replayStartTime) {
25635 this.replayStartTime = new Date().getTime();
25636 this.batchStartUrl = _.info.currentUrl();
25637 this.replayStartUrl = _.info.currentUrl();
25638 }
25639
25640 if (shouldStopBatcher || this.recordMinMs > 0) {
25641 // the primary case for shouldStopBatcher is when we're starting recording after a reset
25642 // and don't want to send anything over the network until there's
25643 // actual user activity
25644 // this also applies if the minimum recording length has not been hit yet
25645 // so that we don't send data until we know the recording will be long enough
25646 this.batcher.stop();
25647 } else {
25648 this.batcher.start();
25649 }
25650
25651 var resetIdleTimeout = function () {
25652 clearTimeout(this.idleTimeoutId);
25653 var idleTimeoutMs = this.getConfig('record_idle_timeout_ms');
25654 this.idleTimeoutId = setTimeout(this._onIdleTimeout, idleTimeoutMs);
25655 this.idleExpires = new Date().getTime() + idleTimeoutMs;
25656 }.bind(this);
25657 resetIdleTimeout();
25658
25659 var blockSelector = this.getConfig('record_block_selector');
25660 if (blockSelector === '' || blockSelector === null) {
25661 blockSelector = undefined;
25662 }
25663
25664 try {
25665 this._stopRecording = this._rrwebRecord({
25666 'emit': function (ev) {
25667 if (this.idleExpires && this.idleExpires < ev.timestamp) {
25668 this._onIdleTimeout();
25669 return;
25670 }
25671 if (isUserEvent(ev)) {
25672 if (this.batcher.stopped && new Date().getTime() - this.replayStartTime >= this.recordMinMs) {
25673 // start flushing again after user activity
25674 this.batcher.start();
25675 }
25676 resetIdleTimeout();
25677 }
25678 // promise only used to await during tests
25679 this.__enqueuePromise = this.batcher.enqueue(ev);
25680 }.bind(this),
25681 'blockClass': this.getConfig('record_block_class'),
25682 'blockSelector': blockSelector,
25683 'collectFonts': this.getConfig('record_collect_fonts'),
25684 'dataURLOptions': { // canvas image options (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL)
25685 'type': 'image/webp',
25686 'quality': 0.6
25687 },
25688 'maskAllInputs': true,
25689 'maskTextClass': this.getConfig('record_mask_text_class'),
25690 'maskTextSelector': this.getConfig('record_mask_text_selector'),
25691 'recordCanvas': this.getConfig('record_canvas'),
25692 'sampling': {
25693 'canvas': 15
25694 }
25695 });
25696 } catch (err) {
25697 this.reportError('Unexpected error when starting rrweb recording.', err);
25698 }
25699
25700 if (typeof this._stopRecording !== 'function') {
25701 this.reportError('rrweb failed to start, skipping this recording.');
25702 this._stopRecording = null;
25703 this.stopRecording(); // stop batcher looping and any timeouts
25704 return;
25705 }
25706
25707 var maxTimeoutMs = this.maxExpires - new Date().getTime();
25708 this.maxTimeoutId = setTimeout(this._onMaxLengthReached.bind(this), maxTimeoutMs);
25709 };
25710
25711 SessionRecording.prototype.stopRecording = function (skipFlush) {
25712 // store the user ID info in case this is getting called in mixpanel.reset()
25713 this.finalFlushUserIdInfo = this.getUserIdInfo();
25714
25715 if (!this.isRrwebStopped()) {
25716 try {
25717 this._stopRecording();
25718 } catch (err) {
25719 this.reportError('Error with rrweb stopRecording', err);
25720 }
25721 this._stopRecording = null;
25722 }
25723
25724 var flushPromise;
25725 if (this.batcher.stopped) {
25726 // never got user activity to flush after reset, so just clear the batcher
25727 flushPromise = this.batcher.clear();
25728 } else if (!skipFlush) {
25729 // flush any remaining events from running batcher
25730 flushPromise = this.batcher.flush();
25731 }
25732 this.batcher.stop();
25733
25734 clearTimeout(this.idleTimeoutId);
25735 clearTimeout(this.maxTimeoutId);
25736 return flushPromise;
25737 };
25738
25739 SessionRecording.prototype.isRrwebStopped = function () {
25740 return this._stopRecording === null;
25741 };
25742
25743
25744 /**
25745 * Flushes the current batch of events to the server, but passes an opt-out callback to make sure
25746 * we stop recording and dump any queued events if the user has opted out.
25747 */
25748 SessionRecording.prototype.flushEventsWithOptOut = function (data, options, cb) {
25749 var onOptOut = function (code) {
25750 // addOptOutCheckMixpanelLib invokes this function with code=0 when the user has opted out
25751 if (code === 0) {
25752 this.stopRecording();
25753 cb({error: 'Tracking has been opted out, stopping recording.'});
25754 }
25755 }.bind(this);
25756
25757 this._flushEvents(data, options, cb, onOptOut);
25758 };
25759
25760 /**
25761 * @returns {SerializedRecording}
25762 */
25763 SessionRecording.prototype.serialize = function () {
25764 // don't break if mixpanel instance was destroyed at some point
25765 var tabId;
25766 try {
25767 tabId = this._mixpanel.get_tab_id();
25768 } catch (e) {
25769 this.reportError('Error getting tab ID for serialization ', e);
25770 tabId = null;
25771 }
25772
25773 return {
25774 'replayId': this.replayId,
25775 'seqNo': this.seqNo,
25776 'replayStartTime': this.replayStartTime,
25777 'batchStartUrl': this.batchStartUrl,
25778 'replayStartUrl': this.replayStartUrl,
25779 'idleExpires': this.idleExpires,
25780 'maxExpires': this.maxExpires,
25781 'tabId': tabId,
25782 };
25783 };
25784
25785
25786 /**
25787 * @static
25788 * @param {SerializedRecording} serializedRecording
25789 * @param {SessionRecordingOptions} options
25790 * @returns {SessionRecording}
25791 */
25792 SessionRecording.deserialize = function (serializedRecording, options) {
25793 var recording = new SessionRecording(_.extend({}, options, {
25794 replayId: serializedRecording['replayId'],
25795 batchStartUrl: serializedRecording['batchStartUrl'],
25796 replayStartUrl: serializedRecording['replayStartUrl'],
25797 idleExpires: serializedRecording['idleExpires'],
25798 maxExpires: serializedRecording['maxExpires'],
25799 replayStartTime: serializedRecording['replayStartTime'],
25800 seqNo: serializedRecording['seqNo'],
25801 sharedLockStorage: options.sharedLockStorage,
25802 }));
25803
25804 return recording;
25805 };
25806
25807 SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, reqBody, callback) {
25808 var onSuccess = function (response, responseBody) {
25809 // Update batch specific props only if the request was successful to guarantee ordering.
25810 // RequestBatcher will always flush the next batch after the previous one succeeds.
25811 // extra check to see if the replay ID has changed so that we don't increment the seqNo on the wrong replay
25812 if (response.status === 200 && this.replayId === currentReplayId) {
25813 this.seqNo++;
25814 this.batchStartUrl = _.info.currentUrl();
25815 }
25816
25817 this._onBatchSent();
25818 callback({
25819 status: 0,
25820 httpStatusCode: response.status,
25821 responseBody: responseBody,
25822 retryAfter: response.headers.get('Retry-After')
25823 });
25824 }.bind(this);
25825 var apiHost = (this._mixpanel.get_api_host && this._mixpanel.get_api_host('record')) || this.getConfig('api_host');
25826 win['fetch'](apiHost + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
25827 'method': 'POST',
25828 'headers': {
25829 'Authorization': 'Basic ' + btoa(this.getConfig('token') + ':'),
25830 'Content-Type': 'application/octet-stream'
25831 },
25832 'body': reqBody,
25833 }).then(function (response) {
25834 response.json().then(function (responseBody) {
25835 onSuccess(response, responseBody);
25836 }).catch(function (error) {
25837 callback({error: error});
25838 });
25839 }).catch(function (error) {
25840 callback({error: error, httpStatusCode: 0});
25841 });
25842 };
25843
25844 SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (data, options, callback) {
25845 var numEvents = data.length;
25846
25847 if (numEvents > 0) {
25848 var replayId = this.replayId;
25849
25850 // each rrweb event has a timestamp - leverage those to get time properties
25851 var batchStartTime = Infinity;
25852 var batchEndTime = -Infinity;
25853 var hasFullSnapshot = false;
25854 for (var i = 0; i < numEvents; i++) {
25855 batchStartTime = Math.min(batchStartTime, data[i].timestamp);
25856 batchEndTime = Math.max(batchEndTime, data[i].timestamp);
25857 if (data[i].type === EventType.FullSnapshot) {
25858 hasFullSnapshot = true;
25859 }
25860 }
25861
25862 if (this.seqNo === 0) {
25863 if (!hasFullSnapshot) {
25864 callback({error: 'First batch does not contain a full snapshot. Aborting recording.'});
25865 this.stopRecording(true);
25866 return;
25867 }
25868 this.replayStartTime = batchStartTime;
25869 } else if (!this.replayStartTime) {
25870 this.reportError('Replay start time not set but seqNo is not 0. Using current batch start time as a fallback.');
25871 this.replayStartTime = batchStartTime;
25872 }
25873
25874 var replayLengthMs = batchEndTime - this.replayStartTime;
25875
25876 var reqParams = {
25877 '$current_url': this.batchStartUrl,
25878 '$lib_version': Config.LIB_VERSION,
25879 'batch_start_time': batchStartTime / 1000,
25880 'mp_lib': 'web',
25881 'replay_id': replayId,
25882 'replay_length_ms': replayLengthMs,
25883 'replay_start_time': this.replayStartTime / 1000,
25884 'replay_start_url': this.replayStartUrl,
25885 'seq': this.seqNo
25886 };
25887 var eventsJson = JSON.stringify(data);
25888 Object.assign(reqParams, this.getUserIdInfo());
25889
25890 if (CompressionStream) {
25891 var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
25892 var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
25893 new Response(gzipStream)
25894 .blob()
25895 .then(function(compressedBlob) {
25896 reqParams['format'] = 'gzip';
25897 this._sendRequest(replayId, reqParams, compressedBlob, callback);
25898 }.bind(this));
25899 } else {
25900 reqParams['format'] = 'body';
25901 this._sendRequest(replayId, reqParams, eventsJson, callback);
25902 }
25903 }
25904 });
25905
25906
25907 SessionRecording.prototype.reportError = function(msg, err) {
25908 logger$3.error.apply(logger$3.error, arguments);
25909 try {
25910 if (!err && !(msg instanceof Error)) {
25911 msg = new Error(msg);
25912 }
25913 this.getConfig('error_reporter')(msg, err);
25914 } catch(err) {
25915 logger$3.error(err);
25916 }
25917 };
25918
25919 /**
25920 * Module for handling the storage and retrieval of recording metadata as well as any active recordings.
25921 * Makes sure that only one tab can be recording at a time.
25922 */
25923 var RecordingRegistry = function (options) {
25924 /** @type {IDBStorageWrapper} */
25925 this.idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
25926 this.errorReporter = options.errorReporter;
25927 this.mixpanelInstance = options.mixpanelInstance;
25928 this.sharedLockStorage = options.sharedLockStorage;
25929 };
25930
25931 RecordingRegistry.prototype.isPersistenceEnabled = function() {
25932 return !this.mixpanelInstance.get_config('disable_persistence');
25933 };
25934
25935 RecordingRegistry.prototype.handleError = function (err) {
25936 this.errorReporter('IndexedDB error: ', err);
25937 };
25938
25939 /**
25940 * @param {import('./session-recording').SerializedRecording} serializedRecording
25941 */
25942 RecordingRegistry.prototype.setActiveRecording = function (serializedRecording) {
25943 if (!this.isPersistenceEnabled()) {
25944 return PromisePolyfill.resolve();
25945 }
25946
25947 var tabId = serializedRecording['tabId'];
25948 if (!tabId) {
25949 console.warn('No tab ID is set, cannot persist recording metadata.');
25950 return PromisePolyfill.resolve();
25951 }
25952
25953 return this.idb.init()
25954 .then(function () {
25955 return this.idb.setItem(tabId, serializedRecording);
25956 }.bind(this))
25957 .catch(this.handleError.bind(this));
25958 };
25959
25960 /**
25961 * @returns {Promise<import('./session-recording').SerializedRecording>}
25962 */
25963 RecordingRegistry.prototype.getActiveRecording = function () {
25964 if (!this.isPersistenceEnabled()) {
25965 return PromisePolyfill.resolve(null);
25966 }
25967
25968 return this.idb.init()
25969 .then(function () {
25970 return this.idb.getItem(this.mixpanelInstance.get_tab_id());
25971 }.bind(this))
25972 .then(function (serializedRecording) {
25973 return isRecordingExpired(serializedRecording) ? null : serializedRecording;
25974 }.bind(this))
25975 .catch(this.handleError.bind(this));
25976 };
25977
25978 RecordingRegistry.prototype.clearActiveRecording = function () {
25979 if (this.isPersistenceEnabled()) {
25980 // mark recording as expired instead of deleting it in case the page unloads mid-flush and doesn't make it to ingestion.
25981 // this will ensure the next pageload will flush the remaining events, but not try to continue the recording.
25982 return this.markActiveRecordingExpired();
25983 } else {
25984 return this.deleteActiveRecording();
25985 }
25986 };
25987
25988 RecordingRegistry.prototype.markActiveRecordingExpired = function () {
25989 return this.getActiveRecording()
25990 .then(function (serializedRecording) {
25991 if (serializedRecording) {
25992 serializedRecording['maxExpires'] = 0;
25993 return this.setActiveRecording(serializedRecording);
25994 }
25995 }.bind(this))
25996 .catch(this.handleError.bind(this));
25997 };
25998
25999 RecordingRegistry.prototype.deleteActiveRecording = function () {
26000 // avoid initializing IDB if this registry instance hasn't already written a recording
26001 if (this.idb.isInitialized()) {
26002 return this.idb.removeItem(this.mixpanelInstance.get_tab_id())
26003 .catch(this.handleError.bind(this));
26004 } else {
26005 return PromisePolyfill.resolve();
26006 }
26007 };
26008
26009 /**
26010 * Flush any inactive recordings from the registry to minimize data loss.
26011 * The main idea here is that we can flush remaining rrweb events on the next page load if a tab is closed mid-batch.
26012 */
26013 RecordingRegistry.prototype.flushInactiveRecordings = function () {
26014 if (!this.isPersistenceEnabled()) {
26015 return PromisePolyfill.resolve([]);
26016 }
26017
26018 return this.idb.init()
26019 .then(function() {
26020 return this.idb.getAll();
26021 }.bind(this))
26022 .then(function (serializedRecordings) {
26023 // clean up any expired recordings from the registry, non-expired ones may be active in other tabs
26024 var unloadPromises = serializedRecordings
26025 .filter(function (serializedRecording) {
26026 return isRecordingExpired(serializedRecording);
26027 })
26028 .map(function (serializedRecording) {
26029 var sessionRecording = SessionRecording.deserialize(serializedRecording, {
26030 mixpanelInstance: this.mixpanelInstance,
26031 sharedLockStorage: this.sharedLockStorage
26032 });
26033 return sessionRecording.unloadPersistedData()
26034 .then(function () {
26035 // expired recording was successfully flushed, we can clean it up from the registry
26036 return this.idb.removeItem(serializedRecording['tabId']);
26037 }.bind(this))
26038 .catch(this.handleError.bind(this));
26039 }.bind(this));
26040
26041 return PromisePolyfill.all(unloadPromises);
26042 }.bind(this))
26043 .catch(this.handleError.bind(this));
26044 };
26045
26046 var logger$2 = console_with_prefix('recorder');
26047
26048 /**
26049 * Recorder API: bundles rrweb and and exposes methods to start and stop recordings.
26050 * @param {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
26051 */
26052 var MixpanelRecorder = function(mixpanelInstance, rrwebRecord, sharedLockStorage) {
26053 this.mixpanelInstance = mixpanelInstance;
26054 this.rrwebRecord = rrwebRecord || record;
26055 this.sharedLockStorage = sharedLockStorage;
26056
26057 /**
26058 * @member {import('./registry').RecordingRegistry}
26059 */
26060 this.recordingRegistry = new RecordingRegistry({
26061 mixpanelInstance: this.mixpanelInstance,
26062 errorReporter: logger$2.error,
26063 sharedLockStorage: sharedLockStorage
26064 });
26065 this._flushInactivePromise = this.recordingRegistry.flushInactiveRecordings();
26066
26067 this.activeRecording = null;
26068 this.stopRecordingInProgress = false;
26069 };
26070
26071 MixpanelRecorder.prototype.startRecording = function(options) {
26072 options = options || {};
26073 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26074 logger$2.log('Recording already in progress, skipping startRecording.');
26075 return;
26076 }
26077
26078 var onIdleTimeout = function () {
26079 logger$2.log('Idle timeout reached, restarting recording.');
26080 this.resetRecording();
26081 }.bind(this);
26082
26083 var onMaxLengthReached = function () {
26084 logger$2.log('Max recording length reached, stopping recording.');
26085 this.resetRecording();
26086 }.bind(this);
26087
26088 var onBatchSent = function () {
26089 this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26090 this['__flushPromise'] = this.activeRecording.batcher._flushPromise;
26091 }.bind(this);
26092
26093 /**
26094 * @type {import('./session-recording').SessionRecordingOptions}
26095 */
26096 var sessionRecordingOptions = {
26097 mixpanelInstance: this.mixpanelInstance,
26098 onBatchSent: onBatchSent,
26099 onIdleTimeout: onIdleTimeout,
26100 onMaxLengthReached: onMaxLengthReached,
26101 replayId: _.UUID(),
26102 rrwebRecord: this.rrwebRecord,
26103 sharedLockStorage: this.sharedLockStorage
26104 };
26105
26106 if (options.activeSerializedRecording) {
26107 this.activeRecording = SessionRecording.deserialize(options.activeSerializedRecording, sessionRecordingOptions);
26108 } else {
26109 this.activeRecording = new SessionRecording(sessionRecordingOptions);
26110 }
26111
26112 this.activeRecording.startRecording(options.shouldStopBatcher);
26113 return this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26114 };
26115
26116 MixpanelRecorder.prototype.stopRecording = function() {
26117 // Prevents activeSerializedRecording from being reused when stopping the recording.
26118 this.stopRecordingInProgress = true;
26119 return this._stopCurrentRecording(false, true).then(function() {
26120 return this.recordingRegistry.clearActiveRecording();
26121 }.bind(this)).then(function() {
26122 this.stopRecordingInProgress = false;
26123 }.bind(this));
26124 };
26125
26126 MixpanelRecorder.prototype.pauseRecording = function() {
26127 return this._stopCurrentRecording(false);
26128 };
26129
26130 MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush, disableActiveRecording) {
26131 if (this.activeRecording) {
26132 var stopRecordingPromise = this.activeRecording.stopRecording(skipFlush);
26133 if (disableActiveRecording) {
26134 this.activeRecording = null;
26135 }
26136 return stopRecordingPromise;
26137 }
26138 return PromisePolyfill.resolve();
26139 };
26140
26141 MixpanelRecorder.prototype.resumeRecording = function (startNewIfInactive) {
26142 if (this.activeRecording && this.activeRecording.isRrwebStopped()) {
26143 this.activeRecording.startRecording(false);
26144 return PromisePolyfill.resolve(null);
26145 }
26146
26147 return this.recordingRegistry.getActiveRecording()
26148 .then(function (activeSerializedRecording) {
26149 if (activeSerializedRecording && !this.stopRecordingInProgress) {
26150 return this.startRecording({activeSerializedRecording: activeSerializedRecording});
26151 } else if (startNewIfInactive) {
26152 return this.startRecording({shouldStopBatcher: false});
26153 } else {
26154 logger$2.log('No resumable recording found.');
26155 return null;
26156 }
26157 }.bind(this));
26158 };
26159
26160
26161 MixpanelRecorder.prototype.resetRecording = function () {
26162 this.stopRecording();
26163 this.startRecording({shouldStopBatcher: true});
26164 };
26165
26166 MixpanelRecorder.prototype.getActiveReplayId = function () {
26167 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26168 return this.activeRecording.replayId;
26169 } else {
26170 return null;
26171 }
26172 };
26173
26174 // getter so that older mixpanel-core versions can still retrieve the replay ID
26175 // when pulling the latest recorder bundle from the CDN
26176 Object.defineProperty(MixpanelRecorder.prototype, 'replayId', {
26177 get: function () {
26178 return this.getActiveReplayId();
26179 }
26180 });
26181
26182 win['__mp_recorder'] = MixpanelRecorder;
26183
26184 // stateless utils
26185 // mostly from https://github.com/mixpanel/mixpanel-js/blob/989ada50f518edab47b9c4fd9535f9fbd5ec5fc0/src/autotrack-utils.js
26186
26187
26188 var EV_CHANGE = 'change';
26189 var EV_CLICK = 'click';
26190 var EV_HASHCHANGE = 'hashchange';
26191 var EV_INPUT = 'input';
26192 var EV_LOAD = 'load';
26193 var EV_MP_LOCATION_CHANGE = 'mp_locationchange';
26194 var EV_POPSTATE = 'popstate';
26195 // TODO scrollend isn't available in Safari: document or polyfill?
26196 var EV_SCROLLEND = 'scrollend';
26197 var EV_SCROLL = 'scroll';
26198 var EV_SELECT = 'select';
26199 var EV_SUBMIT = 'submit';
26200 var EV_TOGGLE = 'toggle';
26201 var EV_VISIBILITYCHANGE = 'visibilitychange';
26202
26203 var CLICK_EVENT_PROPS = [
26204 'clientX', 'clientY',
26205 'offsetX', 'offsetY',
26206 'pageX', 'pageY',
26207 'screenX', 'screenY',
26208 'x', 'y'
26209 ];
26210 var OPT_IN_CLASSES = ['mp-include'];
26211 var OPT_OUT_CLASSES = ['mp-no-track'];
26212 var SENSITIVE_DATA_CLASSES = OPT_OUT_CLASSES.concat(['mp-sensitive']);
26213 var TRACKED_ATTRS = [
26214 'aria-label', 'aria-labelledby', 'aria-describedby',
26215 'href', 'name', 'role', 'title', 'type'
26216 ];
26217
26218 var INTERACTIVE_ARIA_ROLES = {
26219 'button': true,
26220 'checkbox': true,
26221 'combobox': true,
26222 'grid': true,
26223 'link': true,
26224 'listbox': true,
26225 'menu': true,
26226 'menubar': true,
26227 'menuitem': true,
26228 'menuitemcheckbox': true,
26229 'menuitemradio': true,
26230 'navigation': true,
26231 'option': true,
26232 'radio': true,
26233 'radiogroup': true,
26234 'searchbox': true,
26235 'slider': true,
26236 'spinbutton': true,
26237 'switch': true,
26238 'tab': true,
26239 'tablist': true,
26240 'textbox': true,
26241 'tree': true,
26242 'treegrid': true,
26243 'treeitem': true
26244 };
26245
26246 var ALWAYS_NON_INTERACTIVE_TAGS = {
26247 // Document metadata
26248 'base': true,
26249 'head': true,
26250 'html': true,
26251 'link': true,
26252 'meta': true,
26253 'script': true,
26254 'style': true,
26255 'title': true,
26256 // Text formatting
26257 'br': true,
26258 'hr': true,
26259 'wbr': true,
26260 // Other
26261 'noscript': true,
26262 'picture': true,
26263 'source': true,
26264 'template': true,
26265 'track': true
26266 };
26267
26268 // Common container tags that need additional checks
26269 var TEXT_CONTAINER_TAGS = {
26270 'article': true,
26271 'div': true,
26272 'h1': true,
26273 'h2': true,
26274 'h3': true,
26275 'h4': true,
26276 'h5': true,
26277 'h6': true,
26278 'p': true,
26279 'section': true,
26280 'span': true
26281 };
26282
26283 var EVENT_HANDLER_ATTRIBUTES = [
26284 'onclick', 'onmousedown', 'onmouseup', 'onpointerdown', 'onpointerup', 'ontouchend', 'ontouchstart'
26285 ];
26286
26287 var MAX_DEPTH = 5;
26288
26289 var logger$1 = console_with_prefix('autocapture');
26290
26291
26292 function getClasses(el) {
26293 var classes = {};
26294 var classList = getClassName(el).split(' ');
26295 for (var i = 0; i < classList.length; i++) {
26296 var cls = classList[i];
26297 if (cls) {
26298 classes[cls] = true;
26299 }
26300 }
26301 return classes;
26302 }
26303
26304 /*
26305 * Get the className of an element, accounting for edge cases where element.className is an object
26306 * @param {Element} el - element to get the className of
26307 * @returns {string} the element's class
26308 */
26309 function getClassName(el) {
26310 switch(typeof el.className) {
26311 case 'string':
26312 return el.className;
26313 case 'object': // handle cases where className might be SVGAnimatedString or some other type
26314 return el.className.baseVal || el.getAttribute('class') || '';
26315 default: // future proof
26316 return '';
26317 }
26318 }
26319
26320 function getPreviousElementSibling(el) {
26321 if (el.previousElementSibling) {
26322 return el.previousElementSibling;
26323 } else {
26324 do {
26325 el = el.previousSibling;
26326 } while (el && !isElementNode(el));
26327 return el;
26328 }
26329 }
26330
26331 function getPropertiesFromElement(el, ev, blockAttrsSet, extraAttrs, allowElementCallback, allowSelectors) {
26332 var props = {
26333 '$classes': getClassName(el).split(' '),
26334 '$tag_name': el.tagName.toLowerCase()
26335 };
26336 var elId = el.id;
26337 if (elId) {
26338 props['$id'] = elId;
26339 }
26340
26341 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors)) {
26342 _.each(TRACKED_ATTRS.concat(extraAttrs), function(attr) {
26343 if (el.hasAttribute(attr) && !blockAttrsSet[attr]) {
26344 var attrVal = el.getAttribute(attr);
26345 if (shouldTrackValue(attrVal)) {
26346 props['$attr-' + attr] = attrVal;
26347 }
26348 }
26349 });
26350 }
26351
26352 var nthChild = 1;
26353 var nthOfType = 1;
26354 var currentElem = el;
26355 while (currentElem = getPreviousElementSibling(currentElem)) { // eslint-disable-line no-cond-assign
26356 nthChild++;
26357 if (currentElem.tagName === el.tagName) {
26358 nthOfType++;
26359 }
26360 }
26361 props['$nth_child'] = nthChild;
26362 props['$nth_of_type'] = nthOfType;
26363
26364 return props;
26365 }
26366
26367 function getPropsForDOMEvent(ev, config) {
26368 var allowElementCallback = config.allowElementCallback;
26369 var allowSelectors = config.allowSelectors || [];
26370 var blockAttrs = config.blockAttrs || [];
26371 var blockElementCallback = config.blockElementCallback;
26372 var blockSelectors = config.blockSelectors || [];
26373 var captureTextContent = config.captureTextContent || false;
26374 var captureExtraAttrs = config.captureExtraAttrs || [];
26375 var capturedForHeatMap = config.capturedForHeatMap || false;
26376
26377 // convert array to set every time, as the config may have changed
26378 var blockAttrsSet = {};
26379 _.each(blockAttrs, function(attr) {
26380 blockAttrsSet[attr] = true;
26381 });
26382
26383 var props = null;
26384
26385 var target = typeof ev.target === 'undefined' ? ev.srcElement : ev.target;
26386 if (isTextNode(target)) { // defeat Safari bug (see: http://www.quirksmode.org/js/events_properties.html)
26387 target = target.parentNode;
26388 }
26389
26390 if (
26391 shouldTrackDomEvent(target, ev) &&
26392 isElementAllowed(target, ev, allowElementCallback, allowSelectors) &&
26393 !isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26394 ) {
26395 var targetElementList = [target];
26396 var curEl = target;
26397 while (curEl.parentNode && !isTag(curEl, 'body')) {
26398 targetElementList.push(curEl.parentNode);
26399 curEl = curEl.parentNode;
26400 }
26401
26402 var elementsJson = [];
26403 var href, explicitNoTrack = false;
26404 _.each(targetElementList, function(el) {
26405 var shouldTrackDetails = shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors);
26406
26407 // if the element or a parent element is an anchor tag
26408 // include the href as a property
26409 if (!blockAttrsSet['href'] && el.tagName.toLowerCase() === 'a') {
26410 href = el.getAttribute('href');
26411 href = shouldTrackDetails && shouldTrackValue(href) && href;
26412 }
26413
26414 if (isElementBlocked(el, ev, blockElementCallback, blockSelectors)) {
26415 explicitNoTrack = true;
26416 }
26417
26418 elementsJson.push(getPropertiesFromElement(el, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors));
26419 }, this);
26420
26421 if (!explicitNoTrack) {
26422 var docElement = document$1['documentElement'];
26423 props = {
26424 '$event_type': ev.type,
26425 '$host': win.location.host,
26426 '$pathname': win.location.pathname,
26427 '$elements': elementsJson,
26428 '$el_attr__href': href,
26429 '$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
26430 '$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0),
26431 '$pageHeight': document$1['body']['offsetHeight'] || 0,
26432 '$pageWidth': document$1['body']['offsetWidth'] || 0,
26433 };
26434 _.each(captureExtraAttrs, function(attr) {
26435 if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
26436 var attrVal = target.getAttribute(attr);
26437 if (shouldTrackValue(attrVal)) {
26438 props['$el_attr__' + attr] = attrVal;
26439 }
26440 }
26441 });
26442
26443 if (captureTextContent) {
26444 elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26445 if (elementText && elementText.length) {
26446 props['$el_text'] = elementText;
26447 }
26448 }
26449
26450 if (ev.type === EV_CLICK) {
26451 _.each(CLICK_EVENT_PROPS, function(prop) {
26452 if (prop in ev) {
26453 props['$' + prop] = ev[prop];
26454 }
26455 });
26456 if (capturedForHeatMap) {
26457 props['$captured_for_heatmap'] = true;
26458 }
26459 target = guessRealClickTarget(ev);
26460 }
26461 // prioritize text content from "real" click target if different from original target
26462 if (captureTextContent) {
26463 var elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26464 if (elementText && elementText.length) {
26465 props['$el_text'] = elementText;
26466 }
26467 }
26468
26469 if (target) {
26470 // target may have been recalculated; check allowlists and blocklists again
26471 if (
26472 !isElementAllowed(target, ev, allowElementCallback, allowSelectors) ||
26473 isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26474 ) {
26475 return null;
26476 }
26477
26478 var targetProps = getPropertiesFromElement(target, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors);
26479 props['$target'] = targetProps;
26480 // pull up more props onto main event props
26481 props['$el_classes'] = targetProps['$classes'];
26482 _.extend(props, _.strip_empty_properties({
26483 '$el_id': targetProps['$id'],
26484 '$el_tag_name': targetProps['$tag_name']
26485 }));
26486 }
26487 }
26488 }
26489
26490 return props;
26491 }
26492
26493
26494 /**
26495 * Get the direct text content of an element, protecting against sensitive data collection.
26496 * Concats textContent of each of the element's text node children; this avoids potential
26497 * collection of sensitive data that could happen if we used element.textContent and the
26498 * element had sensitive child elements, since element.textContent includes child content.
26499 * Scrubs values that look like they could be sensitive (i.e. cc or ssn number).
26500 * @param {Element} el - element to get the text of
26501 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
26502 * @returns {string} the element's direct text content
26503 */
26504 function getSafeText(el, ev, allowElementCallback, allowSelectors) {
26505 var elText = '';
26506
26507 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) && el.childNodes && el.childNodes.length) {
26508 _.each(el.childNodes, function(child) {
26509 if (isTextNode(child) && child.textContent) {
26510 elText += _.trim(child.textContent)
26511 // scrub potentially sensitive values
26512 .split(/(\s+)/).filter(shouldTrackValue).join('')
26513 // normalize whitespace
26514 .replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ')
26515 // truncate
26516 .substring(0, 255);
26517 }
26518 });
26519 }
26520
26521 return _.trim(elText);
26522 }
26523
26524 function guessRealClickTarget(ev) {
26525 var target = ev.target;
26526 var composedPath = ev['composedPath']();
26527 for (var i = 0; i < composedPath.length; i++) {
26528 var node = composedPath[i];
26529 if (
26530 isTag(node, 'a') ||
26531 isTag(node, 'button') ||
26532 isTag(node, 'input') ||
26533 isTag(node, 'select') ||
26534 (node.getAttribute && node.getAttribute('role') === 'button')
26535 ) {
26536 target = node;
26537 break;
26538 }
26539 if (node === target) {
26540 break;
26541 }
26542 }
26543 return target;
26544 }
26545
26546 function isElementAllowed(el, ev, allowElementCallback, allowSelectors) {
26547 if (allowElementCallback) {
26548 try {
26549 if (!allowElementCallback(el, ev)) {
26550 return false;
26551 }
26552 } catch (err) {
26553 logger$1.critical('Error while checking element in allowElementCallback', err);
26554 return false;
26555 }
26556 }
26557
26558 if (!allowSelectors.length) {
26559 // no allowlist; all elements are fair game
26560 return true;
26561 }
26562
26563 for (var i = 0; i < allowSelectors.length; i++) {
26564 var sel = allowSelectors[i];
26565 try {
26566 if (el['matches'](sel)) {
26567 return true;
26568 }
26569 } catch (err) {
26570 logger$1.critical('Error while checking selector: ' + sel, err);
26571 }
26572 }
26573 return false;
26574 }
26575
26576 function isElementBlocked(el, ev, blockElementCallback, blockSelectors) {
26577 var i;
26578
26579 if (blockElementCallback) {
26580 try {
26581 if (blockElementCallback(el, ev)) {
26582 return true;
26583 }
26584 } catch (err) {
26585 logger$1.critical('Error while checking element in blockElementCallback', err);
26586 return true;
26587 }
26588 }
26589
26590 if (blockSelectors && blockSelectors.length) {
26591 // programmatically prevent tracking of elements that match CSS selectors
26592 for (i = 0; i < blockSelectors.length; i++) {
26593 var sel = blockSelectors[i];
26594 try {
26595 if (el['matches'](sel)) {
26596 return true;
26597 }
26598 } catch (err) {
26599 logger$1.critical('Error while checking selector: ' + sel, err);
26600 }
26601 }
26602 }
26603
26604 // allow users to programmatically prevent tracking of elements by adding default classes such as 'mp-no-track'
26605 var classes = getClasses(el);
26606 for (i = 0; i < OPT_OUT_CLASSES.length; i++) {
26607 if (classes[OPT_OUT_CLASSES[i]]) {
26608 return true;
26609 }
26610 }
26611
26612 return false;
26613 }
26614
26615 /*
26616 * Check whether a DOM node has nodeType Node.ELEMENT_NODE
26617 * @param {Node} node - node to check
26618 * @returns {boolean} whether node is of the correct nodeType
26619 */
26620 function isElementNode(node) {
26621 return node && node.nodeType === 1; // Node.ELEMENT_NODE - use integer constant for browser portability
26622 }
26623
26624 /*
26625 * Check whether an element is of a given tag type.
26626 * Due to potential reference discrepancies (such as the webcomponents.js polyfill),
26627 * we want to match tagNames instead of specific references because something like
26628 * element === document.body won't always work because element might not be a native
26629 * element.
26630 * @param {Element} el - element to check
26631 * @param {string} tag - tag name (e.g., "div")
26632 * @returns {boolean} whether el is of the given tag type
26633 */
26634 function isTag(el, tag) {
26635 return el && el.tagName && el.tagName.toLowerCase() === tag.toLowerCase();
26636 }
26637
26638 /*
26639 * Check whether a DOM node is a TEXT_NODE
26640 * @param {Node} node - node to check
26641 * @returns {boolean} whether node is of type Node.TEXT_NODE
26642 */
26643 function isTextNode(node) {
26644 return node && node.nodeType === 3; // Node.TEXT_NODE - use integer constant for browser portability
26645 }
26646
26647 function minDOMApisSupported() {
26648 try {
26649 var testEl = document$1.createElement('div');
26650 return !!testEl['matches'];
26651 } catch (err) {
26652 return false;
26653 }
26654 }
26655
26656 function weakSetSupported() {
26657 return typeof WeakSet !== 'undefined';
26658 }
26659
26660 /*
26661 * Check whether a DOM event should be "tracked" or if it may contain sensitive data
26662 * using a variety of heuristics.
26663 * @param {Element} el - element to check
26664 * @param {Event} ev - event to check
26665 * @returns {boolean} whether the event should be tracked
26666 */
26667 function shouldTrackDomEvent(el, ev) {
26668 if (!el || isTag(el, 'html') || !isElementNode(el)) {
26669 return false;
26670 }
26671 var tag = el.tagName.toLowerCase();
26672 switch (tag) {
26673 case 'form':
26674 return ev.type === EV_SUBMIT;
26675 case 'input':
26676 if (['button', 'submit'].indexOf(el.getAttribute('type')) === -1) {
26677 return ev.type === EV_CHANGE;
26678 } else {
26679 return ev.type === EV_CLICK;
26680 }
26681 case 'select':
26682 case 'textarea':
26683 return ev.type === EV_CHANGE;
26684 default:
26685 return ev.type === EV_CLICK;
26686 }
26687 }
26688
26689 /*
26690 * Check whether a DOM element should be "tracked" or if it may contain sensitive data
26691 * using a variety of heuristics.
26692 * @param {Element} el - element to check
26693 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
26694 * @returns {boolean} whether the element should be tracked
26695 */
26696 function shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) {
26697 var i;
26698
26699 if (!isElementAllowed(el, ev, allowElementCallback, allowSelectors)) {
26700 return false;
26701 }
26702
26703 for (var curEl = el; curEl.parentNode && !isTag(curEl, 'body'); curEl = curEl.parentNode) {
26704 var classes = getClasses(curEl);
26705 for (i = 0; i < SENSITIVE_DATA_CLASSES.length; i++) {
26706 if (classes[SENSITIVE_DATA_CLASSES[i]]) {
26707 return false;
26708 }
26709 }
26710 }
26711
26712 var elClasses = getClasses(el);
26713 for (i = 0; i < OPT_IN_CLASSES.length; i++) {
26714 if (elClasses[OPT_IN_CLASSES[i]]) {
26715 return true;
26716 }
26717 }
26718
26719 // don't send data from inputs or similar elements since there will always be
26720 // a risk of clientside javascript placing sensitive data in attributes
26721 if (
26722 isTag(el, 'input') ||
26723 isTag(el, 'select') ||
26724 isTag(el, 'textarea') ||
26725 el.getAttribute('contenteditable') === 'true'
26726 ) {
26727 return false;
26728 }
26729
26730 // don't include hidden or password fields
26731 var type = el.type || '';
26732 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"]
26733 switch(type.toLowerCase()) {
26734 case 'hidden':
26735 return false;
26736 case 'password':
26737 return false;
26738 }
26739 }
26740
26741 // filter out data from fields that look like sensitive fields
26742 var name = el.name || el.id || '';
26743 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"]
26744 var sensitiveNameRegex = /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i;
26745 if (sensitiveNameRegex.test(name.replace(/[^a-zA-Z0-9]/g, ''))) {
26746 return false;
26747 }
26748 }
26749
26750 return true;
26751 }
26752
26753
26754 /*
26755 * Check whether a string value should be "tracked" or if it may contain sensitive data
26756 * using a variety of heuristics.
26757 * @param {string} value - string value to check
26758 * @returns {boolean} whether the element should be tracked
26759 */
26760 function shouldTrackValue(value) {
26761 if (value === null || _.isUndefined(value)) {
26762 return false;
26763 }
26764
26765 if (typeof value === 'string') {
26766 value = _.trim(value);
26767
26768 // check to see if input value looks like a credit card number
26769 // see: https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch04s20.html
26770 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}))$/;
26771 if (ccRegex.test((value || '').replace(/[- ]/g, ''))) {
26772 return false;
26773 }
26774
26775 // check to see if input value looks like a social security number
26776 var ssnRegex = /(^\d{3}-?\d{2}-?\d{4}$)/;
26777 if (ssnRegex.test(value)) {
26778 return false;
26779 }
26780 }
26781
26782 return true;
26783 }
26784
26785 /**
26786 * Creates a cross-browser compatible scroll end function with appropriate event listener.
26787 * For browsers that support scrollend, returns the original function with scrollend event.
26788 * For browsers without scrollend support, returns a debounced function that triggers
26789 * 100ms after the last scroll event to simulate scrollend behavior.
26790 * @param {Function} originalFunction - The function to call when scrolling ends
26791 * @returns {Object} Object containing listener function and eventType string
26792 * @returns {Function} returns.listener - The wrapped function to use as event listener
26793 * @returns {string} returns.eventType - The event type to listen for ('scrollend' or 'scroll')
26794 */
26795 function getPolyfillScrollEndFunction(originalFunction) {
26796 var supportsScrollEnd = 'onscrollend' in win;
26797 var polyfillFunction = safewrap(originalFunction);
26798 var polyfillEvent = EV_SCROLLEND;
26799 if (!supportsScrollEnd) {
26800 // Polyfill for browsers without scrollend support: wait 100ms after the last scroll event
26801 // https://developer.chrome.com/blog/scrollend-a-new-javascript-event
26802 var scrollTimer = null;
26803 var scrollDelayMs = 100;
26804
26805 polyfillFunction = safewrap(function() {
26806 clearTimeout(scrollTimer);
26807 scrollTimer = setTimeout(originalFunction, scrollDelayMs);
26808 });
26809
26810 polyfillEvent = EV_SCROLL;
26811 }
26812
26813 return {
26814 listener: polyfillFunction,
26815 eventType: polyfillEvent
26816 };
26817 }
26818
26819 function hasInlineEventHandlers(element) {
26820 for (var i = 0; i < EVENT_HANDLER_ATTRIBUTES.length; i++) {
26821 if (element.hasAttribute(EVENT_HANDLER_ATTRIBUTES[i])) {
26822 return true;
26823 }
26824 }
26825 return false;
26826 }
26827
26828 function hasInteractiveAriaRole(element) {
26829 var role = element.getAttribute('role');
26830 if (!role) return false;
26831
26832 // Handle invalid markup where multiple roles might be specified
26833 // Only the first token is recognized per ARIA spec
26834 var primaryRole = role.trim().split(/\s+/)[0].toLowerCase();
26835
26836 return INTERACTIVE_ARIA_ROLES[primaryRole];
26837 }
26838
26839 function hasAnyInteractivityIndicators(element) {
26840 var tagName = element.tagName.toLowerCase();
26841
26842 // Check for interactive HTML elements
26843 if (tagName === 'button' ||
26844 tagName === 'input' ||
26845 tagName === 'select' ||
26846 tagName === 'textarea' ||
26847 tagName === 'details' ||
26848 tagName === 'dialog') {
26849 return true;
26850 }
26851
26852 if (element.isContentEditable) {
26853 return true;
26854 }
26855
26856 if (element.onclick || element.onmousedown || element.onmouseup || element.ontouchstart || element.ontouchend) {
26857 return true;
26858 }
26859
26860 if (hasInlineEventHandlers(element)) {
26861 return true;
26862 }
26863
26864 if (hasInteractiveAriaRole(element)) {
26865 return true;
26866 }
26867
26868 if (tagName === 'a' && element.hasAttribute('href')) {
26869 return true;
26870 }
26871
26872 if (element.hasAttribute('tabindex')) {
26873 return true;
26874 }
26875
26876 return false;
26877 }
26878
26879
26880 function isDefinitelyNonInteractive(element) {
26881 if (!element || !element.tagName) {
26882 return true;
26883 }
26884
26885 var tagName = element.tagName.toLowerCase();
26886
26887 // These tags are definitely non-interactive
26888 if (ALWAYS_NON_INTERACTIVE_TAGS[tagName]) {
26889 return true;
26890 }
26891
26892 // For all other elements, we can only be certain they're non-interactive if they lack ALL indicators of interactivity
26893 // Check for any signs of interactivity
26894 if (hasAnyInteractivityIndicators(element)) {
26895 return false;
26896 }
26897
26898 // Check parent chain for interactive context
26899 var parent = element.parentElement;
26900 var depth = 0;
26901
26902 while (parent && depth < MAX_DEPTH) {
26903 if (hasAnyInteractivityIndicators(parent)) {
26904 return false; // Element is inside an interactive parent
26905 }
26906
26907 if (parent.getRootNode && parent.getRootNode() !== document$1) {
26908 var root = parent.getRootNode();
26909 if (root.host && hasAnyInteractivityIndicators(root.host)) {
26910 return false; // Inside an interactive shadow host
26911 }
26912 }
26913
26914 parent = parent.parentElement;
26915 depth++;
26916 }
26917
26918 // Pure text containers without any interactive context
26919 if (TEXT_CONTAINER_TAGS[tagName]) {
26920 // These are non-interactive ONLY if they have no interactive indicators (already checked as part of hasAnyInteractivityIndicators)
26921 return true;
26922 }
26923
26924 // Default: we can't be certain it's non-interactive
26925 return false;
26926 }
26927
26928 /** @const */ var DEFAULT_RAGE_CLICK_THRESHOLD_PX = 30;
26929 /** @const */ var DEFAULT_RAGE_CLICK_TIMEOUT_MS = 1000;
26930 /** @const */ var DEFAULT_RAGE_CLICK_CLICK_COUNT = 4;
26931
26932 function RageClickTracker() {
26933 this.clicks = [];
26934 }
26935
26936 RageClickTracker.prototype.isRageClick = function(x, y, options) {
26937 options = options || {};
26938 var thresholdPx = options['threshold_px'] || DEFAULT_RAGE_CLICK_THRESHOLD_PX;
26939 var timeoutMs = options['timeout_ms'] || DEFAULT_RAGE_CLICK_TIMEOUT_MS;
26940 var clickCount = options['click_count'] || DEFAULT_RAGE_CLICK_CLICK_COUNT;
26941 var timestamp = Date.now();
26942
26943 var lastClick = this.clicks[this.clicks.length - 1];
26944 if (
26945 lastClick &&
26946 timestamp - lastClick.timestamp < timeoutMs &&
26947 Math.sqrt(Math.pow(x - lastClick.x, 2) + Math.pow(y - lastClick.y, 2)) < thresholdPx
26948 ) {
26949 this.clicks.push({ x: x, y: y, timestamp: timestamp });
26950 if (this.clicks.length >= clickCount) {
26951 this.clicks = [];
26952 return true;
26953 }
26954 } else {
26955 this.clicks = [{ x: x, y: y, timestamp: timestamp }];
26956 }
26957 return false;
26958 };
26959
26960 function ShadowDOMObserver(changeCallback, observerConfig) {
26961 this.changeCallback = changeCallback || function() {};
26962 this.observerConfig = observerConfig;
26963
26964 this.observedShadowRoots = null;
26965 this.shadowObservers = [];
26966 }
26967
26968 ShadowDOMObserver.prototype.getEventTarget = function(event) {
26969 if (!this.observedShadowRoots) {
26970 return;
26971 }
26972 var path = this.getComposedPath(event);
26973 if (path && path.length) {
26974 return path[0];
26975 }
26976
26977 return event['target'] || event['srcElement'];
26978 };
26979
26980
26981 ShadowDOMObserver.prototype.getComposedPath = function(event) {
26982 if ('composedPath' in event) {
26983 return event['composedPath']();
26984 }
26985
26986 return [];
26987 };
26988 ShadowDOMObserver.prototype.observeFromEvent = function(event) {
26989 if (!this.observedShadowRoots) {
26990 return;
26991 }
26992
26993 var path = this.getComposedPath(event);
26994
26995 // Check each element in path for shadow roots
26996 for (var i = 0; i < path.length; i++) {
26997 var element = path[i];
26998
26999 if (element && element.shadowRoot) {
27000 this.observeShadowRoot(element.shadowRoot);
27001 }
27002 }
27003 };
27004
27005
27006 ShadowDOMObserver.prototype.observeShadowRoot = function(shadowRoot) {
27007 if (!this.observedShadowRoots || this.observedShadowRoots.has(shadowRoot)) {
27008 return;
27009 }
27010
27011 var self = this;
27012
27013 try {
27014 this.observedShadowRoots.add(shadowRoot);
27015
27016 var observer = new window.MutationObserver(function() {
27017 self.changeCallback();
27018 });
27019
27020 observer.observe(shadowRoot, this.observerConfig);
27021 this.shadowObservers.push(observer);
27022 } catch (e) {
27023 logger$1.critical('Error while observing shadow root', e);
27024 }
27025 };
27026
27027
27028 ShadowDOMObserver.prototype.start = function() {
27029 if (this.observedShadowRoots) {
27030 return;
27031 }
27032
27033 if (!weakSetSupported()) {
27034 logger$1.critical('Shadow DOM observation unavailable: WeakSet not supported');
27035 return;
27036 }
27037
27038 this.observedShadowRoots = new WeakSet();
27039 };
27040
27041 ShadowDOMObserver.prototype.stop = function() {
27042 if (!this.observedShadowRoots) {
27043 return;
27044 }
27045
27046 for (var i = 0; i < this.shadowObservers.length; i++) {
27047 try {
27048 this.shadowObservers[i].disconnect();
27049 } catch (e) {
27050 logger$1.critical('Error while disconnecting shadow DOM observer', e);
27051 }
27052 }
27053 this.shadowObservers = [];
27054 this.observedShadowRoots = null;
27055 };
27056
27057 /** @const */ var DEFAULT_DEAD_CLICK_TIMEOUT_MS = 500;
27058 /** @const */ var INTERACTION_EVENTS = [EV_CHANGE, EV_INPUT, EV_SUBMIT, EV_SELECT, EV_TOGGLE];
27059 /** @const */ var LAYOUT_EVENTS = [EV_SCROLLEND];
27060 /** @const */ var NAVIGATION_EVENTS = [EV_HASHCHANGE];
27061 /** @const */ var MUTATION_OBSERVER_CONFIG = {
27062 characterData: true,
27063 childList: true,
27064 subtree: true,
27065 attributes: true,
27066 attributeFilter: ['style', 'class', 'hidden', 'checked', 'selected', 'value', 'display', 'visibility']
27067 };
27068
27069
27070 function DeadClickTracker(onDeadClickCallback) {
27071 this.eventListeners = [];
27072 this.mutationObserver = null;
27073 this.shadowDOMObserver = null;
27074
27075 this.isTracking = false;
27076 this.lastChangeEventTimestamp = 0;
27077 this.pendingClicks = [];
27078 this.onDeadClickCallback = onDeadClickCallback;
27079 this.processingActive = false;
27080 this.processingTimeout = null;
27081 }
27082
27083
27084 DeadClickTracker.prototype.addClick = function(event) {
27085 var element = this.shadowDOMObserver && this.shadowDOMObserver.getEventTarget(event);
27086
27087 if (!element) {
27088 element = event['target'] || event['srcElement'];
27089 }
27090
27091 if (!element || isDefinitelyNonInteractive(element)) {
27092 return false;
27093 }
27094
27095 if (this.shadowDOMObserver) {
27096 this.shadowDOMObserver.observeFromEvent(event);
27097 }
27098 this.pendingClicks.push({
27099 element: element,
27100 event: event,
27101 timestamp: Date.now()
27102 });
27103 return true;
27104 };
27105
27106 DeadClickTracker.prototype.trackClick = function(event, config) {
27107 if (!this.isTracking) {
27108 return false;
27109 }
27110
27111 var added = this.addClick(event);
27112 if (added) {
27113 this.triggerProcessing(config);
27114 }
27115 return added;
27116 };
27117
27118 DeadClickTracker.prototype.getDeadClicks = function(config) {
27119 if (this.pendingClicks.length === 0) {
27120 return [];
27121 }
27122
27123 var timeoutMs = config['timeout_ms'];
27124 var now = Date.now();
27125 var clicksToEvaluate = this.pendingClicks.slice(); // Copy array
27126 this.pendingClicks = []; // Clear original
27127
27128 var deadClicks = [];
27129
27130 for (var i = 0; i < clicksToEvaluate.length; i++) {
27131 var click = clicksToEvaluate[i];
27132
27133 if (now - click.timestamp >= timeoutMs) {
27134 // Click has exceeded timeout, check if it's dead by looking for changes after this specific click
27135 if (!this.hasChangesAfter(click.timestamp)) {
27136 deadClicks.push(click);
27137 }
27138 } else {
27139 // Still pending - add back
27140 this.pendingClicks.push(click);
27141 }
27142 }
27143
27144 return deadClicks;
27145 };
27146
27147 DeadClickTracker.prototype.hasChangesAfter = function(timestamp) {
27148 // 100ms tolerance for race condition between when we record the click and the change event
27149 return this.lastChangeEventTimestamp >= (timestamp - 100);
27150 };
27151
27152 DeadClickTracker.prototype.recordChangeEvent = function() {
27153 this.lastChangeEventTimestamp = Date.now();
27154 };
27155
27156 DeadClickTracker.prototype.triggerProcessing = function(config) {
27157 // Prevent multiple concurrent processing chains
27158 if (this.processingActive) {
27159 return;
27160 }
27161 this.processingActive = true;
27162 this.processRecursively(config);
27163 };
27164
27165 DeadClickTracker.prototype.processRecursively = function(config) {
27166 if (!this.isTracking || !this.onDeadClickCallback) {
27167 this.processingActive = false;
27168 return;
27169 }
27170
27171 var timeoutMs = config['timeout_ms'];
27172 var self = this;
27173
27174 this.processingTimeout = setTimeout(function() {
27175 if (!self.processingActive) {
27176 return;
27177 }
27178
27179 var deadClicks = self.getDeadClicks(config);
27180
27181 for (var i = 0; i < deadClicks.length; i++) {
27182 self.onDeadClickCallback(deadClicks[i].event);
27183 }
27184
27185 if (self.pendingClicks.length > 0) {
27186 self.processRecursively(config);
27187 } else {
27188 self.processingActive = false;
27189 }
27190 }, timeoutMs);
27191 };
27192
27193 DeadClickTracker.prototype.startTracking = function() {
27194 if (this.isTracking) {
27195 return;
27196 }
27197
27198 this.isTracking = true;
27199
27200 var self = this;
27201
27202 INTERACTION_EVENTS.forEach(function(event) {
27203 var handler = function() {
27204 self.recordChangeEvent();
27205 };
27206 document.addEventListener(event, handler, { capture: true, passive: true });
27207 self.eventListeners.push({ target: document, event: event, handler: handler, options: { capture: true, passive: true } });
27208 });
27209 NAVIGATION_EVENTS.forEach(function(event) {
27210 var handler = function() {
27211 self.recordChangeEvent();
27212 };
27213 window.addEventListener(event, handler);
27214 self.eventListeners.push({ target: window, event: event, handler: handler });
27215 });
27216 LAYOUT_EVENTS.forEach(function(event) {
27217 var handler = function() {
27218 self.recordChangeEvent();
27219 };
27220 window.addEventListener(event, handler, { passive: true });
27221 self.eventListeners.push({ target: window, event: event, handler: handler, options: { passive: true } });
27222 });
27223 var selectionHandler = function() {
27224 self.recordChangeEvent();
27225 };
27226 document.addEventListener('selectionchange', selectionHandler);
27227 self.eventListeners.push({ target: document, event: 'selectionchange', handler: selectionHandler });
27228
27229 // Set up MutationObserver
27230 if (window.MutationObserver) {
27231 try {
27232 this.mutationObserver = new window.MutationObserver(function() {
27233 self.recordChangeEvent();
27234 });
27235
27236 this.mutationObserver.observe(document.body || document.documentElement, MUTATION_OBSERVER_CONFIG);
27237 } catch (e) {
27238 logger$1.critical('Error while setting up mutation observer', e);
27239 }
27240 }
27241
27242 // Set up Shadow DOM observer
27243 if (window.customElements) {
27244 try {
27245 this.shadowDOMObserver = new ShadowDOMObserver(
27246 function() {
27247 self.recordChangeEvent();
27248 },
27249 MUTATION_OBSERVER_CONFIG
27250 );
27251 this.shadowDOMObserver.start();
27252 } catch (e) {
27253 logger$1.critical('Error while setting up shadow DOM observer', e);
27254 this.shadowDOMObserver = null;
27255 }
27256 }
27257 };
27258
27259 DeadClickTracker.prototype.stopTracking = function() {
27260 if (!this.isTracking) {
27261 return;
27262 }
27263
27264 this.isTracking = false;
27265 this.pendingClicks = [];
27266 this.lastChangeEventTimestamp = 0;
27267 this.processingActive = false;
27268
27269 if (this.processingTimeout) {
27270 clearTimeout(this.processingTimeout);
27271 this.processingTimeout = null;
27272 }
27273
27274 // Remove all event listeners
27275 for (var i = 0; i < this.eventListeners.length; i++) {
27276 var listener = this.eventListeners[i];
27277 try {
27278 listener.target.removeEventListener(listener.event, listener.handler, listener.options);
27279 } catch (e) {
27280 logger$1.critical('Error while removing event listener', e);
27281 }
27282 }
27283 this.eventListeners = [];
27284
27285 if (this.mutationObserver) {
27286 try {
27287 this.mutationObserver.disconnect();
27288 } catch (e) {
27289 logger$1.critical('Error while disconnecting mutation observer', e);
27290 }
27291 this.mutationObserver = null;
27292 }
27293
27294 if (this.shadowDOMObserver) {
27295 try {
27296 this.shadowDOMObserver.stop();
27297 } catch (e) {
27298 logger$1.critical('Error while stopping shadow DOM observer', e);
27299 }
27300 this.shadowDOMObserver = null;
27301 }
27302 };
27303
27304 var AUTOCAPTURE_CONFIG_KEY = 'autocapture';
27305 var LEGACY_PAGEVIEW_CONFIG_KEY = 'track_pageview';
27306
27307 var PAGEVIEW_OPTION_FULL_URL = 'full-url';
27308 var PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING = 'url-with-path-and-query-string';
27309 var PAGEVIEW_OPTION_URL_WITH_PATH = 'url-with-path';
27310
27311 var CONFIG_ALLOW_ELEMENT_CALLBACK = 'allow_element_callback';
27312 var CONFIG_ALLOW_SELECTORS = 'allow_selectors';
27313 var CONFIG_ALLOW_URL_REGEXES = 'allow_url_regexes';
27314 var CONFIG_BLOCK_ATTRS = 'block_attrs';
27315 var CONFIG_BLOCK_ELEMENT_CALLBACK = 'block_element_callback';
27316 var CONFIG_BLOCK_SELECTORS = 'block_selectors';
27317 var CONFIG_BLOCK_URL_REGEXES = 'block_url_regexes';
27318 var CONFIG_CAPTURE_EXTRA_ATTRS = 'capture_extra_attrs';
27319 var CONFIG_CAPTURE_TEXT_CONTENT = 'capture_text_content';
27320 var CONFIG_SCROLL_CAPTURE_ALL = 'scroll_capture_all';
27321 var CONFIG_SCROLL_CHECKPOINTS = 'scroll_depth_percent_checkpoints';
27322 var CONFIG_TRACK_CLICK = 'click';
27323 var CONFIG_TRACK_DEAD_CLICK = 'dead_click';
27324 var CONFIG_TRACK_INPUT = 'input';
27325 var CONFIG_TRACK_PAGEVIEW = 'pageview';
27326 var CONFIG_TRACK_RAGE_CLICK = 'rage_click';
27327 var CONFIG_TRACK_SCROLL = 'scroll';
27328 var CONFIG_TRACK_PAGE_LEAVE = 'page_leave';
27329 var CONFIG_TRACK_SUBMIT = 'submit';
27330
27331 var CONFIG_DEFAULTS$1 = {};
27332 CONFIG_DEFAULTS$1[CONFIG_ALLOW_SELECTORS] = [];
27333 CONFIG_DEFAULTS$1[CONFIG_ALLOW_URL_REGEXES] = [];
27334 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ATTRS] = [];
27335 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ELEMENT_CALLBACK] = null;
27336 CONFIG_DEFAULTS$1[CONFIG_BLOCK_SELECTORS] = [];
27337 CONFIG_DEFAULTS$1[CONFIG_BLOCK_URL_REGEXES] = [];
27338 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_EXTRA_ATTRS] = [];
27339 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_TEXT_CONTENT] = false;
27340 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CAPTURE_ALL] = false;
27341 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CHECKPOINTS] = [25, 50, 75, 100];
27342 CONFIG_DEFAULTS$1[CONFIG_TRACK_CLICK] = true;
27343 CONFIG_DEFAULTS$1[CONFIG_TRACK_DEAD_CLICK] = true;
27344 CONFIG_DEFAULTS$1[CONFIG_TRACK_INPUT] = true;
27345 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGEVIEW] = PAGEVIEW_OPTION_FULL_URL;
27346 CONFIG_DEFAULTS$1[CONFIG_TRACK_RAGE_CLICK] = true;
27347 CONFIG_DEFAULTS$1[CONFIG_TRACK_SCROLL] = true;
27348 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGE_LEAVE] = false;
27349 CONFIG_DEFAULTS$1[CONFIG_TRACK_SUBMIT] = true;
27350
27351 var DEFAULT_PROPS = {
27352 '$mp_autocapture': true
27353 };
27354
27355 var MP_EV_CLICK = '$mp_click';
27356 var MP_EV_DEAD_CLICK = '$mp_dead_click';
27357 var MP_EV_INPUT = '$mp_input_change';
27358 var MP_EV_RAGE_CLICK = '$mp_rage_click';
27359 var MP_EV_SCROLL = '$mp_scroll';
27360 var MP_EV_SUBMIT = '$mp_submit';
27361 var MP_EV_PAGE_LEAVE = '$mp_page_leave';
27362
27363 /**
27364 * Autocapture: manages automatic event tracking
27365 * @constructor
27366 */
27367 var Autocapture = function(mp) {
27368 this.mp = mp;
27369 this.maxScrollViewDepth = 0;
27370 this.hasTrackedScrollSession = false;
27371 this.previousScrollHeight = 0;
27372 };
27373
27374 Autocapture.prototype.init = function() {
27375 if (!minDOMApisSupported()) {
27376 logger$1.critical('Autocapture unavailable: missing required DOM APIs');
27377 return;
27378 }
27379 this.initPageListeners();
27380 this.initPageviewTracking();
27381 this.initClickTracking();
27382 this.initDeadClickTracking();
27383 this.initInputTracking();
27384 this.initScrollTracking();
27385 this.initSubmitTracking();
27386 this.initRageClickTracking();
27387 this.initPageLeaveTracking();
27388 };
27389
27390 Autocapture.prototype.getFullConfig = function() {
27391 var autocaptureConfig = this.mp.get_config(AUTOCAPTURE_CONFIG_KEY);
27392 if (!autocaptureConfig) {
27393 // Autocapture is completely off
27394 return {};
27395 } else if (_.isObject(autocaptureConfig)) {
27396 return _.extend({}, CONFIG_DEFAULTS$1, autocaptureConfig);
27397 } else {
27398 // Autocapture config is non-object truthy value, return default
27399 return CONFIG_DEFAULTS$1;
27400 }
27401 };
27402
27403 Autocapture.prototype.getConfig = function(key) {
27404 return this.getFullConfig()[key];
27405 };
27406
27407 Autocapture.prototype.currentUrlBlocked = function() {
27408 var i;
27409 var currentUrl = _.info.currentUrl();
27410
27411 var allowUrlRegexes = this.getConfig(CONFIG_ALLOW_URL_REGEXES) || [];
27412 if (allowUrlRegexes.length) {
27413 // we're using an allowlist, only track if current URL matches
27414 var allowed = false;
27415 for (i = 0; i < allowUrlRegexes.length; i++) {
27416 var allowRegex = allowUrlRegexes[i];
27417 try {
27418 if (currentUrl.match(allowRegex)) {
27419 allowed = true;
27420 break;
27421 }
27422 } catch (err) {
27423 logger$1.critical('Error while checking block URL regex: ' + allowRegex, err);
27424 return true;
27425 }
27426 }
27427 if (!allowed) {
27428 // wasn't allowed by any regex
27429 return true;
27430 }
27431 }
27432
27433 var blockUrlRegexes = this.getConfig(CONFIG_BLOCK_URL_REGEXES) || [];
27434 if (!blockUrlRegexes || !blockUrlRegexes.length) {
27435 return false;
27436 }
27437
27438 for (i = 0; i < blockUrlRegexes.length; i++) {
27439 try {
27440 if (currentUrl.match(blockUrlRegexes[i])) {
27441 return true;
27442 }
27443 } catch (err) {
27444 logger$1.critical('Error while checking block URL regex: ' + blockUrlRegexes[i], err);
27445 return true;
27446 }
27447 }
27448 return false;
27449 };
27450
27451 Autocapture.prototype.pageviewTrackingConfig = function() {
27452 // supports both autocapture config and old track_pageview config
27453 if (this.mp.get_config(AUTOCAPTURE_CONFIG_KEY)) {
27454 return this.getConfig(CONFIG_TRACK_PAGEVIEW);
27455 } else {
27456 return this.mp.get_config(LEGACY_PAGEVIEW_CONFIG_KEY);
27457 }
27458 };
27459
27460 // helper for event handlers
27461 Autocapture.prototype.trackDomEvent = function(ev, mpEventName) {
27462 if (this.currentUrlBlocked()) {
27463 return;
27464 }
27465
27466 var isCapturedForHeatMap = this.mp.is_recording_heatmap_data() && (
27467 (mpEventName === MP_EV_CLICK && !this.getConfig(CONFIG_TRACK_CLICK)) ||
27468 (mpEventName === MP_EV_RAGE_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK)) ||
27469 (mpEventName === MP_EV_DEAD_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK))
27470 );
27471
27472 var props = getPropsForDOMEvent(ev, {
27473 allowElementCallback: this.getConfig(CONFIG_ALLOW_ELEMENT_CALLBACK),
27474 allowSelectors: this.getConfig(CONFIG_ALLOW_SELECTORS),
27475 blockAttrs: this.getConfig(CONFIG_BLOCK_ATTRS),
27476 blockElementCallback: this.getConfig(CONFIG_BLOCK_ELEMENT_CALLBACK),
27477 blockSelectors: this.getConfig(CONFIG_BLOCK_SELECTORS),
27478 captureExtraAttrs: this.getConfig(CONFIG_CAPTURE_EXTRA_ATTRS),
27479 captureTextContent: this.getConfig(CONFIG_CAPTURE_TEXT_CONTENT),
27480 capturedForHeatMap: isCapturedForHeatMap,
27481 });
27482 if (props) {
27483 _.extend(props, DEFAULT_PROPS);
27484 this.mp.track(mpEventName, props);
27485 }
27486 };
27487
27488 Autocapture.prototype.initPageListeners = function() {
27489 win.removeEventListener(EV_POPSTATE, this.listenerPopstate);
27490 win.removeEventListener(EV_HASHCHANGE, this.listenerHashchange);
27491
27492 if (!this.pageviewTrackingConfig() && !this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
27493 // These are all the configs that use these listeners
27494 return;
27495 }
27496
27497 this.listenerPopstate = function() {
27498 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27499 };
27500 this.listenerHashchange = function() {
27501 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27502 };
27503
27504 win.addEventListener(EV_POPSTATE, this.listenerPopstate);
27505 win.addEventListener(EV_HASHCHANGE, this.listenerHashchange);
27506 var nativePushState = win.history.pushState;
27507 if (typeof nativePushState === 'function') {
27508 win.history.pushState = function(state, unused, url) {
27509 nativePushState.call(win.history, state, unused, url);
27510 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27511 };
27512 }
27513 var nativeReplaceState = win.history.replaceState;
27514 if (typeof nativeReplaceState === 'function') {
27515 win.history.replaceState = function(state, unused, url) {
27516 nativeReplaceState.call(win.history, state, unused, url);
27517 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27518 };
27519 }
27520 };
27521
27522 Autocapture.prototype._getClickTrackingConfig = function(configKey) {
27523 var config = this.getConfig(configKey);
27524
27525 if (!config) {
27526 return null; // click tracking disabled
27527 }
27528
27529 if (config === true) {
27530 return {}; // use defaults
27531 }
27532
27533 if (typeof config === 'object') {
27534 return config; // use custom configuration
27535 }
27536
27537 return {}; // fallback to defaults for any other truthy value
27538 };
27539
27540 Autocapture.prototype._trackPageLeave = function(ev, currentUrl, currentScrollHeight) {
27541 if (this.hasTrackedScrollSession) {
27542 // User has navigated away already ending their impression.
27543 return;
27544 }
27545
27546 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.is_recording_heatmap_data()) {
27547 return;
27548 }
27549
27550 this.hasTrackedScrollSession = true;
27551 var viewportHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
27552 var scrollPercentage = Math.round(Math.max(this.maxScrollViewDepth - viewportHeight, 0) / (currentScrollHeight - viewportHeight) * 100);
27553 var foldLinePercentage = Math.round((viewportHeight / currentScrollHeight) * 100);
27554 if (currentScrollHeight <= viewportHeight) {
27555 // If the content fits within the viewport, consider it fully scrolled
27556 scrollPercentage = 100;
27557 foldLinePercentage = 100;
27558 }
27559
27560 var props = _.extend({
27561 '$max_scroll_view_depth': this.maxScrollViewDepth,
27562 '$max_scroll_percentage': scrollPercentage,
27563 '$fold_line_percentage': foldLinePercentage,
27564 '$scroll_height': currentScrollHeight,
27565 '$event_type': ev.type,
27566 '$current_url': currentUrl || _.info.currentUrl(),
27567 '$viewportHeight': viewportHeight, // This is the fold line
27568 '$viewportWidth': Math.max(document$1.documentElement.clientWidth, win.innerWidth || 0),
27569 '$captured_for_heatmap': this.mp.is_recording_heatmap_data()
27570 }, DEFAULT_PROPS);
27571
27572 // Send with beacon transport to ensure event is sent before unload
27573 this.mp.track(MP_EV_PAGE_LEAVE, props, {transport: 'sendBeacon'});
27574 };
27575
27576 Autocapture.prototype._initScrollDepthTracking = function() {
27577 win.removeEventListener(EV_SCROLL, this.listenerScrollDepth);
27578 win.removeEventListener(EV_SCROLLEND, this.listenerScrollDepth);
27579
27580 if (!this.mp.get_config('record_heatmap_data')) {
27581 return;
27582 }
27583
27584 logger$1.log('Initializing scroll depth tracking');
27585
27586 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
27587
27588 var updateScrollDepth = function() {
27589 if (this.currentUrlBlocked()) {
27590 return;
27591 }
27592 var scrollViewHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0) + win.scrollY;
27593 if (scrollViewHeight > this.maxScrollViewDepth) {
27594 this.maxScrollViewDepth = scrollViewHeight;
27595 }
27596 this.previousScrollHeight = document$1.body.scrollHeight;
27597 }.bind(this);
27598
27599 var scrollEndPolyfill = getPolyfillScrollEndFunction(updateScrollDepth);
27600 this.listenerScrollDepth = scrollEndPolyfill.listener;
27601 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScrollDepth);
27602 };
27603
27604 Autocapture.prototype.initClickTracking = function() {
27605 win.removeEventListener(EV_CLICK, this.listenerClick);
27606
27607 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.get_config('record_heatmap_data')) {
27608 return;
27609 }
27610 logger$1.log('Initializing click tracking');
27611
27612 this.listenerClick = function(ev) {
27613 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.is_recording_heatmap_data()) {
27614 return;
27615 }
27616 this.trackDomEvent(ev, MP_EV_CLICK);
27617 }.bind(this);
27618 win.addEventListener(EV_CLICK, this.listenerClick);
27619 };
27620
27621 Autocapture.prototype.initDeadClickTracking = function() {
27622 var deadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
27623
27624 if (!deadClickConfig && !this.mp.get_config('record_heatmap_data')) {
27625 this.stopDeadClickTracking();
27626 return;
27627 }
27628
27629 logger$1.log('Initializing dead click tracking');
27630 if (!this._deadClickTracker) {
27631 this._deadClickTracker = new DeadClickTracker(function(deadClickEvent) {
27632 this.trackDomEvent(deadClickEvent, MP_EV_DEAD_CLICK);
27633 }.bind(this));
27634 this._deadClickTracker.startTracking();
27635 }
27636
27637 if (!this.listenerDeadClick) {
27638 this.listenerDeadClick = function(ev) {
27639 var currentDeadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
27640 if (!currentDeadClickConfig && !this.mp.is_recording_heatmap_data()) {
27641 return;
27642 }
27643 if (this.currentUrlBlocked()) {
27644 return;
27645 }
27646 // Normalize config to ensure timeout_ms is always set
27647 var normalizedConfig = currentDeadClickConfig || {};
27648 if (!normalizedConfig['timeout_ms']) {
27649 normalizedConfig['timeout_ms'] = DEFAULT_DEAD_CLICK_TIMEOUT_MS;
27650 }
27651 this._deadClickTracker.trackClick(ev, normalizedConfig);
27652 }.bind(this);
27653 win.addEventListener(EV_CLICK, this.listenerDeadClick);
27654 }
27655 };
27656
27657 Autocapture.prototype.initInputTracking = function() {
27658 win.removeEventListener(EV_CHANGE, this.listenerChange);
27659
27660 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
27661 return;
27662 }
27663 logger$1.log('Initializing input tracking');
27664
27665 this.listenerChange = function(ev) {
27666 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
27667 return;
27668 }
27669 this.trackDomEvent(ev, MP_EV_INPUT);
27670 }.bind(this);
27671 win.addEventListener(EV_CHANGE, this.listenerChange);
27672 };
27673
27674 Autocapture.prototype.initPageviewTracking = function() {
27675 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
27676
27677 if (!this.pageviewTrackingConfig()) {
27678 return;
27679 }
27680 logger$1.log('Initializing pageview tracking');
27681
27682 var previousTrackedUrl = '';
27683 var tracked = false;
27684 if (!this.currentUrlBlocked()) {
27685 tracked = this.mp.track_pageview(DEFAULT_PROPS);
27686 }
27687 if (tracked) {
27688 previousTrackedUrl = _.info.currentUrl();
27689 }
27690
27691 this.listenerLocationchange = safewrap(function() {
27692 if (this.currentUrlBlocked()) {
27693 return;
27694 }
27695
27696 var currentUrl = _.info.currentUrl();
27697 var shouldTrack = false;
27698 var didPathChange = currentUrl.split('#')[0].split('?')[0] !== previousTrackedUrl.split('#')[0].split('?')[0];
27699 var trackPageviewOption = this.pageviewTrackingConfig();
27700 if (trackPageviewOption === PAGEVIEW_OPTION_FULL_URL) {
27701 shouldTrack = currentUrl !== previousTrackedUrl;
27702 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING) {
27703 shouldTrack = currentUrl.split('#')[0] !== previousTrackedUrl.split('#')[0];
27704 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH) {
27705 shouldTrack = didPathChange;
27706 }
27707
27708 if (shouldTrack) {
27709 var tracked = this.mp.track_pageview(DEFAULT_PROPS);
27710 if (tracked) {
27711 previousTrackedUrl = currentUrl;
27712 }
27713 if (didPathChange) {
27714 this.lastScrollCheckpoint = 0;
27715 logger$1.log('Path change: re-initializing scroll depth checkpoints');
27716 }
27717 }
27718 }.bind(this));
27719 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
27720 };
27721
27722 Autocapture.prototype.initRageClickTracking = function() {
27723 win.removeEventListener(EV_CLICK, this.listenerRageClick);
27724
27725 var rageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
27726 if (!rageClickConfig && !this.mp.get_config('record_heatmap_data')) {
27727 return;
27728 }
27729
27730 logger$1.log('Initializing rage click tracking');
27731 if (!this._rageClickTracker) {
27732 this._rageClickTracker = new RageClickTracker();
27733 }
27734
27735 this.listenerRageClick = function(ev) {
27736 var currentRageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
27737 if (!currentRageClickConfig && !this.mp.is_recording_heatmap_data()) {
27738 return;
27739 }
27740
27741 if (this.currentUrlBlocked()) {
27742 return;
27743 }
27744
27745 if (this._rageClickTracker.isRageClick(ev['pageX'], ev['pageY'], currentRageClickConfig)) {
27746 this.trackDomEvent(ev, MP_EV_RAGE_CLICK);
27747 }
27748 }.bind(this);
27749 win.addEventListener(EV_CLICK, this.listenerRageClick);
27750 };
27751
27752 Autocapture.prototype.initScrollTracking = function() {
27753 win.removeEventListener(EV_SCROLLEND, this.listenerScroll);
27754 win.removeEventListener(EV_SCROLL, this.listenerScroll);
27755
27756
27757 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
27758 return;
27759 }
27760 logger$1.log('Initializing scroll tracking');
27761 this.lastScrollCheckpoint = 0;
27762
27763 var scrollTrackFunction = function() {
27764 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
27765 return;
27766 }
27767 if (this.currentUrlBlocked()) {
27768 return;
27769 }
27770
27771 var shouldTrack = this.getConfig(CONFIG_SCROLL_CAPTURE_ALL);
27772 var scrollCheckpoints = (this.getConfig(CONFIG_SCROLL_CHECKPOINTS) || [])
27773 .slice()
27774 .sort(function(a, b) { return a - b; });
27775
27776 var scrollTop = win.scrollY;
27777 var props = _.extend({'$scroll_top': scrollTop}, DEFAULT_PROPS);
27778 try {
27779 var scrollHeight = document$1.body.scrollHeight;
27780 var scrollPercentage = Math.round((scrollTop / (scrollHeight - win.innerHeight)) * 100);
27781 props['$scroll_height'] = scrollHeight;
27782 props['$scroll_percentage'] = scrollPercentage;
27783 if (scrollPercentage > this.lastScrollCheckpoint) {
27784 for (var i = 0; i < scrollCheckpoints.length; i++) {
27785 var checkpoint = scrollCheckpoints[i];
27786 if (
27787 scrollPercentage >= checkpoint &&
27788 this.lastScrollCheckpoint < checkpoint
27789 ) {
27790 props['$scroll_checkpoint'] = checkpoint;
27791 this.lastScrollCheckpoint = checkpoint;
27792 shouldTrack = true;
27793 }
27794 }
27795 }
27796 } catch (err) {
27797 logger$1.critical('Error while calculating scroll percentage', err);
27798 }
27799 if (shouldTrack) {
27800 this.mp.track(MP_EV_SCROLL, props);
27801 }
27802 }.bind(this);
27803
27804 var scrollEndPolyfill = getPolyfillScrollEndFunction(scrollTrackFunction);
27805 this.listenerScroll = scrollEndPolyfill.listener;
27806 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScroll);
27807 };
27808
27809 Autocapture.prototype.initSubmitTracking = function() {
27810 win.removeEventListener(EV_SUBMIT, this.listenerSubmit);
27811
27812 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
27813 return;
27814 }
27815 logger$1.log('Initializing submit tracking');
27816
27817 this.listenerSubmit = function(ev) {
27818 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
27819 return;
27820 }
27821 this.trackDomEvent(ev, MP_EV_SUBMIT);
27822 }.bind(this);
27823 win.addEventListener(EV_SUBMIT, this.listenerSubmit);
27824 };
27825
27826 Autocapture.prototype.initPageLeaveTracking = function() {
27827 // Capture page_leave both when the user navigates away from the page (visibilitychange) as well
27828 // as when they navigate to a different page within the SPA (popstate/pushstate/hashchange).
27829 document$1.removeEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
27830 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
27831 win.removeEventListener(EV_LOAD, this.listenerPageLoad);
27832
27833 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
27834 return;
27835 }
27836
27837 logger$1.log('Initializing page visibility tracking.');
27838 this._initScrollDepthTracking();
27839 var previousTrackedUrl = _.info.currentUrl();
27840
27841 // Initialize previousScrollHeight on `load` which handles async loading
27842 // https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
27843 this.listenerPageLoad = function() {
27844 this.previousScrollHeight = document$1.body.scrollHeight;
27845 }.bind(this);
27846 win.addEventListener(EV_LOAD, this.listenerPageLoad);
27847
27848 // Track page navigation events similar to how initPageviewTracking does it
27849 this.listenerPageLeaveLocationchange = safewrap(function(ev) {
27850 if (this.currentUrlBlocked()) {
27851 return;
27852 }
27853
27854 var currentUrl = _.info.currentUrl();
27855 // Track all URL changes including query string or fragment changes as separate scroll sessions
27856 var shouldTrack = currentUrl !== previousTrackedUrl;
27857
27858 if (shouldTrack) {
27859 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
27860 previousTrackedUrl = currentUrl;
27861 // Fragment navigation should call scroll(end) and trigger listener, don't add window.scrollY here.
27862 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
27863 this.previousScrollHeight = document$1.body.scrollHeight;
27864 this.hasTrackedScrollSession = false;
27865 }
27866 }.bind(this));
27867 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
27868
27869 this.listenerPageLeaveVisibilitychange = function(ev) {
27870 if (document$1.hidden) {
27871 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
27872 }
27873 }.bind(this);
27874 document$1.addEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
27875 };
27876
27877 Autocapture.prototype.stopDeadClickTracking = function() {
27878 if (this.listenerDeadClick) {
27879 win.removeEventListener(EV_CLICK, this.listenerDeadClick);
27880 this.listenerDeadClick = null;
27881 }
27882
27883 if (this._deadClickTracker) {
27884 this._deadClickTracker.stopTracking();
27885 this._deadClickTracker = null;
27886 }
27887 };
27888
27889 // TODO integrate error_reporter from mixpanel instance
27890 safewrapClass(Autocapture);
27891
27892 var logger = console_with_prefix('flags');
27893
27894 var FLAGS_CONFIG_KEY = 'flags';
27895
27896 var CONFIG_CONTEXT = 'context';
27897 var CONFIG_DEFAULTS = {};
27898 CONFIG_DEFAULTS[CONFIG_CONTEXT] = {};
27899
27900 /**
27901 * FeatureFlagManager: support for Mixpanel's feature flagging product
27902 * @constructor
27903 */
27904 var FeatureFlagManager = function(initOptions) {
27905 this.fetch = win['fetch'];
27906 this.getFullApiRoute = initOptions.getFullApiRoute;
27907 this.getMpConfig = initOptions.getConfigFunc;
27908 this.setMpConfig = initOptions.setConfigFunc;
27909 this.getMpProperty = initOptions.getPropertyFunc;
27910 this.track = initOptions.trackingFunc;
27911 };
27912
27913 FeatureFlagManager.prototype.init = function() {
27914 if (!this.minApisSupported()) {
27915 logger.critical('Feature Flags unavailable: missing minimum required APIs');
27916 return;
27917 }
27918
27919 this.flags = null;
27920 this.fetchFlags();
27921
27922 this.trackedFeatures = new Set();
27923 };
27924
27925 FeatureFlagManager.prototype.getFullConfig = function() {
27926 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
27927 if (!ffConfig) {
27928 // flags are completely off
27929 return {};
27930 } else if (_.isObject(ffConfig)) {
27931 return _.extend({}, CONFIG_DEFAULTS, ffConfig);
27932 } else {
27933 // config is non-object truthy value, return default
27934 return CONFIG_DEFAULTS;
27935 }
27936 };
27937
27938 FeatureFlagManager.prototype.getConfig = function(key) {
27939 return this.getFullConfig()[key];
27940 };
27941
27942 FeatureFlagManager.prototype.isSystemEnabled = function() {
27943 return !!this.getMpConfig(FLAGS_CONFIG_KEY);
27944 };
27945
27946 FeatureFlagManager.prototype.updateContext = function(newContext, options) {
27947 if (!this.isSystemEnabled()) {
27948 logger.critical('Feature Flags not enabled, cannot update context');
27949 return Promise.resolve();
27950 }
27951
27952 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
27953 if (!_.isObject(ffConfig)) {
27954 ffConfig = {};
27955 }
27956 var oldContext = (options && options['replace']) ? {} : this.getConfig(CONFIG_CONTEXT);
27957 ffConfig[CONFIG_CONTEXT] = _.extend({}, oldContext, newContext);
27958
27959 this.setMpConfig(FLAGS_CONFIG_KEY, ffConfig);
27960 return this.fetchFlags();
27961 };
27962
27963 FeatureFlagManager.prototype.areFlagsReady = function() {
27964 if (!this.isSystemEnabled()) {
27965 logger.error('Feature Flags not enabled');
27966 }
27967 return !!this.flags;
27968 };
27969
27970 FeatureFlagManager.prototype.fetchFlags = function() {
27971 if (!this.isSystemEnabled()) {
27972 return Promise.resolve();
27973 }
27974
27975 var distinctId = this.getMpProperty('distinct_id');
27976 var deviceId = this.getMpProperty('$device_id');
27977 var traceparent = generateTraceparent();
27978 logger.log('Fetching flags for distinct ID: ' + distinctId);
27979
27980 var context = _.extend({'distinct_id': distinctId, 'device_id': deviceId}, this.getConfig(CONFIG_CONTEXT));
27981 var searchParams = new URLSearchParams();
27982 searchParams.set('context', JSON.stringify(context));
27983 searchParams.set('token', this.getMpConfig('token'));
27984 searchParams.set('mp_lib', 'web');
27985 searchParams.set('$lib_version', Config.LIB_VERSION);
27986 var url = this.getFullApiRoute() + '?' + searchParams.toString();
27987
27988 this._fetchInProgressStartTime = Date.now();
27989 this.fetchPromise = this.fetch.call(win, url, {
27990 'method': 'GET',
27991 'headers': {
27992 'Authorization': 'Basic ' + btoa(this.getMpConfig('token') + ':'),
27993 'traceparent': traceparent
27994 }
27995 }).then(function(response) {
27996 this.markFetchComplete();
27997 return response.json().then(function(responseBody) {
27998 var responseFlags = responseBody['flags'];
27999 if (!responseFlags) {
28000 throw new Error('No flags in API response');
28001 }
28002 var flags = new Map();
28003 _.each(responseFlags, function(data, key) {
28004 flags.set(key, {
28005 'key': data['variant_key'],
28006 'value': data['variant_value'],
28007 'experiment_id': data['experiment_id'],
28008 'is_experiment_active': data['is_experiment_active'],
28009 'is_qa_tester': data['is_qa_tester']
28010 });
28011 });
28012 this.flags = flags;
28013 this._traceparent = traceparent;
28014 }.bind(this)).catch(function(error) {
28015 this.markFetchComplete();
28016 logger.error(error);
28017 }.bind(this));
28018 }.bind(this)).catch(function(error) {
28019 this.markFetchComplete();
28020 logger.error(error);
28021 }.bind(this));
28022
28023 return this.fetchPromise;
28024 };
28025
28026 FeatureFlagManager.prototype.markFetchComplete = function() {
28027 if (!this._fetchInProgressStartTime) {
28028 logger.error('Fetch in progress started time not set, cannot mark fetch complete');
28029 return;
28030 }
28031 this._fetchStartTime = this._fetchInProgressStartTime;
28032 this._fetchCompleteTime = Date.now();
28033 this._fetchLatency = this._fetchCompleteTime - this._fetchStartTime;
28034 this._fetchInProgressStartTime = null;
28035 };
28036
28037 FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
28038 if (!this.fetchPromise) {
28039 return new Promise(function(resolve) {
28040 logger.critical('Feature Flags not initialized');
28041 resolve(fallback);
28042 });
28043 }
28044
28045 return this.fetchPromise.then(function() {
28046 return this.getVariantSync(featureName, fallback);
28047 }.bind(this)).catch(function(error) {
28048 logger.error(error);
28049 return fallback;
28050 });
28051 };
28052
28053 FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
28054 if (!this.areFlagsReady()) {
28055 logger.log('Flags not loaded yet');
28056 return fallback;
28057 }
28058 var feature = this.flags.get(featureName);
28059 if (!feature) {
28060 logger.log('No flag found: "' + featureName + '"');
28061 return fallback;
28062 }
28063 this.trackFeatureCheck(featureName, feature);
28064 return feature;
28065 };
28066
28067 FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
28068 return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
28069 return feature['value'];
28070 }).catch(function(error) {
28071 logger.error(error);
28072 return fallbackValue;
28073 });
28074 };
28075
28076 // TODO remove deprecated method
28077 FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
28078 logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
28079 return this.getVariantValue(featureName, fallbackValue);
28080 };
28081
28082 FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
28083 return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
28084 };
28085
28086 FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
28087 return this.getVariantValue(featureName).then(function() {
28088 return this.isEnabledSync(featureName, fallbackValue);
28089 }.bind(this)).catch(function(error) {
28090 logger.error(error);
28091 return fallbackValue;
28092 });
28093 };
28094
28095 FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
28096 fallbackValue = fallbackValue || false;
28097 var val = this.getVariantValueSync(featureName, fallbackValue);
28098 if (val !== true && val !== false) {
28099 logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
28100 val = fallbackValue;
28101 }
28102 return val;
28103 };
28104
28105 FeatureFlagManager.prototype.trackFeatureCheck = function(featureName, feature) {
28106 if (this.trackedFeatures.has(featureName)) {
28107 return;
28108 }
28109 this.trackedFeatures.add(featureName);
28110
28111 var trackingProperties = {
28112 'Experiment name': featureName,
28113 'Variant name': feature['key'],
28114 '$experiment_type': 'feature_flag',
28115 'Variant fetch start time': new Date(this._fetchStartTime).toISOString(),
28116 'Variant fetch complete time': new Date(this._fetchCompleteTime).toISOString(),
28117 'Variant fetch latency (ms)': this._fetchLatency,
28118 'Variant fetch traceparent': this._traceparent,
28119 };
28120
28121 if (feature['experiment_id'] !== 'undefined') {
28122 trackingProperties['$experiment_id'] = feature['experiment_id'];
28123 }
28124 if (feature['is_experiment_active'] !== 'undefined') {
28125 trackingProperties['$is_experiment_active'] = feature['is_experiment_active'];
28126 }
28127 if (feature['is_qa_tester'] !== 'undefined') {
28128 trackingProperties['$is_qa_tester'] = feature['is_qa_tester'];
28129 }
28130
28131 this.track('$experiment_started', trackingProperties);
28132 };
28133
28134 FeatureFlagManager.prototype.minApisSupported = function() {
28135 return !!this.fetch &&
28136 typeof Promise !== 'undefined' &&
28137 typeof Map !== 'undefined' &&
28138 typeof Set !== 'undefined';
28139 };
28140
28141 safewrapClass(FeatureFlagManager);
28142
28143 FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
28144 FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
28145 FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
28146 FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
28147 FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
28148 FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
28149 FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
28150 FeatureFlagManager.prototype['update_context'] = FeatureFlagManager.prototype.updateContext;
28151
28152 // Deprecated method
28153 FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
28154
28155 /* eslint camelcase: "off" */
28156
28157
28158 /**
28159 * DomTracker Object
28160 * @constructor
28161 */
28162 var DomTracker = function() {};
28163
28164
28165 // interface
28166 DomTracker.prototype.create_properties = function() {};
28167 DomTracker.prototype.event_handler = function() {};
28168 DomTracker.prototype.after_track_handler = function() {};
28169
28170 DomTracker.prototype.init = function(mixpanel_instance) {
28171 this.mp = mixpanel_instance;
28172 return this;
28173 };
28174
28175 /**
28176 * @param {Object|string} query
28177 * @param {string} event_name
28178 * @param {Object=} properties
28179 * @param {function=} user_callback
28180 */
28181 DomTracker.prototype.track = function(query, event_name, properties, user_callback) {
28182 var that = this;
28183 var elements = _.dom_query(query);
28184
28185 if (elements.length === 0) {
28186 console$1.error('The DOM query (' + query + ') returned 0 elements');
28187 return;
28188 }
28189
28190 _.each(elements, function(element) {
28191 _.register_event(element, this.override_event, function(e) {
28192 var options = {};
28193 var props = that.create_properties(properties, this);
28194 var timeout = that.mp.get_config('track_links_timeout');
28195
28196 that.event_handler(e, this, options);
28197
28198 // in case the mixpanel servers don't get back to us in time
28199 window.setTimeout(that.track_callback(user_callback, props, options, true), timeout);
28200
28201 // fire the tracking event
28202 that.mp.track(event_name, props, that.track_callback(user_callback, props, options));
28203 });
28204 }, this);
28205
28206 return true;
28207 };
28208
28209 /**
28210 * @param {function} user_callback
28211 * @param {Object} props
28212 * @param {boolean=} timeout_occured
28213 */
28214 DomTracker.prototype.track_callback = function(user_callback, props, options, timeout_occured) {
28215 timeout_occured = timeout_occured || false;
28216 var that = this;
28217
28218 return function() {
28219 // options is referenced from both callbacks, so we can have
28220 // a 'lock' of sorts to ensure only one fires
28221 if (options.callback_fired) { return; }
28222 options.callback_fired = true;
28223
28224 if (user_callback && user_callback(timeout_occured, props) === false) {
28225 // user can prevent the default functionality by
28226 // returning false from their callback
28227 return;
28228 }
28229
28230 that.after_track_handler(props, options, timeout_occured);
28231 };
28232 };
28233
28234 DomTracker.prototype.create_properties = function(properties, element) {
28235 var props;
28236
28237 if (typeof(properties) === 'function') {
28238 props = properties(element);
28239 } else {
28240 props = _.extend({}, properties);
28241 }
28242
28243 return props;
28244 };
28245
28246 /**
28247 * LinkTracker Object
28248 * @constructor
28249 * @extends DomTracker
28250 */
28251 var LinkTracker = function() {
28252 this.override_event = 'click';
28253 };
28254 _.inherit(LinkTracker, DomTracker);
28255
28256 LinkTracker.prototype.create_properties = function(properties, element) {
28257 var props = LinkTracker.superclass.create_properties.apply(this, arguments);
28258
28259 if (element.href) { props['url'] = element.href; }
28260
28261 return props;
28262 };
28263
28264 LinkTracker.prototype.event_handler = function(evt, element, options) {
28265 options.new_tab = (
28266 evt.which === 2 ||
28267 evt.metaKey ||
28268 evt.ctrlKey ||
28269 element.target === '_blank'
28270 );
28271 options.href = element.href;
28272
28273 if (!options.new_tab) {
28274 evt.preventDefault();
28275 }
28276 };
28277
28278 LinkTracker.prototype.after_track_handler = function(props, options) {
28279 if (options.new_tab) { return; }
28280
28281 setTimeout(function() {
28282 window.location = options.href;
28283 }, 0);
28284 };
28285
28286 /**
28287 * FormTracker Object
28288 * @constructor
28289 * @extends DomTracker
28290 */
28291 var FormTracker = function() {
28292 this.override_event = 'submit';
28293 };
28294 _.inherit(FormTracker, DomTracker);
28295
28296 FormTracker.prototype.event_handler = function(evt, element, options) {
28297 options.element = element;
28298 evt.preventDefault();
28299 };
28300
28301 FormTracker.prototype.after_track_handler = function(props, options) {
28302 setTimeout(function() {
28303 options.element.submit();
28304 }, 0);
28305 };
28306
28307 /* eslint camelcase: "off" */
28308
28309
28310 /** @const */ var SET_ACTION = '$set';
28311 /** @const */ var SET_ONCE_ACTION = '$set_once';
28312 /** @const */ var UNSET_ACTION = '$unset';
28313 /** @const */ var ADD_ACTION = '$add';
28314 /** @const */ var APPEND_ACTION = '$append';
28315 /** @const */ var UNION_ACTION = '$union';
28316 /** @const */ var REMOVE_ACTION = '$remove';
28317 /** @const */ var DELETE_ACTION = '$delete';
28318
28319 // Common internal methods for mixpanel.people and mixpanel.group APIs.
28320 // These methods shouldn't involve network I/O.
28321 var apiActions = {
28322 set_action: function(prop, to) {
28323 var data = {};
28324 var $set = {};
28325 if (_.isObject(prop)) {
28326 _.each(prop, function(v, k) {
28327 if (!this._is_reserved_property(k)) {
28328 $set[k] = v;
28329 }
28330 }, this);
28331 } else {
28332 $set[prop] = to;
28333 }
28334
28335 data[SET_ACTION] = $set;
28336 return data;
28337 },
28338
28339 unset_action: function(prop) {
28340 var data = {};
28341 var $unset = [];
28342 if (!_.isArray(prop)) {
28343 prop = [prop];
28344 }
28345
28346 _.each(prop, function(k) {
28347 if (!this._is_reserved_property(k)) {
28348 $unset.push(k);
28349 }
28350 }, this);
28351
28352 data[UNSET_ACTION] = $unset;
28353 return data;
28354 },
28355
28356 set_once_action: function(prop, to) {
28357 var data = {};
28358 var $set_once = {};
28359 if (_.isObject(prop)) {
28360 _.each(prop, function(v, k) {
28361 if (!this._is_reserved_property(k)) {
28362 $set_once[k] = v;
28363 }
28364 }, this);
28365 } else {
28366 $set_once[prop] = to;
28367 }
28368 data[SET_ONCE_ACTION] = $set_once;
28369 return data;
28370 },
28371
28372 union_action: function(list_name, values) {
28373 var data = {};
28374 var $union = {};
28375 if (_.isObject(list_name)) {
28376 _.each(list_name, function(v, k) {
28377 if (!this._is_reserved_property(k)) {
28378 $union[k] = _.isArray(v) ? v : [v];
28379 }
28380 }, this);
28381 } else {
28382 $union[list_name] = _.isArray(values) ? values : [values];
28383 }
28384 data[UNION_ACTION] = $union;
28385 return data;
28386 },
28387
28388 append_action: function(list_name, value) {
28389 var data = {};
28390 var $append = {};
28391 if (_.isObject(list_name)) {
28392 _.each(list_name, function(v, k) {
28393 if (!this._is_reserved_property(k)) {
28394 $append[k] = v;
28395 }
28396 }, this);
28397 } else {
28398 $append[list_name] = value;
28399 }
28400 data[APPEND_ACTION] = $append;
28401 return data;
28402 },
28403
28404 remove_action: function(list_name, value) {
28405 var data = {};
28406 var $remove = {};
28407 if (_.isObject(list_name)) {
28408 _.each(list_name, function(v, k) {
28409 if (!this._is_reserved_property(k)) {
28410 $remove[k] = v;
28411 }
28412 }, this);
28413 } else {
28414 $remove[list_name] = value;
28415 }
28416 data[REMOVE_ACTION] = $remove;
28417 return data;
28418 },
28419
28420 delete_action: function() {
28421 var data = {};
28422 data[DELETE_ACTION] = '';
28423 return data;
28424 }
28425 };
28426
28427 /* eslint camelcase: "off" */
28428
28429 /**
28430 * Mixpanel Group Object
28431 * @constructor
28432 */
28433 var MixpanelGroup = function() {};
28434
28435 _.extend(MixpanelGroup.prototype, apiActions);
28436
28437 MixpanelGroup.prototype._init = function(mixpanel_instance, group_key, group_id) {
28438 this._mixpanel = mixpanel_instance;
28439 this._group_key = group_key;
28440 this._group_id = group_id;
28441 };
28442
28443 /**
28444 * Set properties on a group.
28445 *
28446 * ### Usage:
28447 *
28448 * mixpanel.get_group('company', 'mixpanel').set('Location', '405 Howard');
28449 *
28450 * // or set multiple properties at once
28451 * mixpanel.get_group('company', 'mixpanel').set({
28452 * 'Location': '405 Howard',
28453 * 'Founded' : 2009,
28454 * });
28455 * // properties can be strings, integers, dates, or lists
28456 *
28457 * @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.
28458 * @param {*} [to] A value to set on the given property name
28459 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28460 */
28461 MixpanelGroup.prototype.set = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28462 var data = this.set_action(prop, to);
28463 if (_.isObject(prop)) {
28464 callback = to;
28465 }
28466 return this._send_request(data, callback);
28467 });
28468
28469 /**
28470 * Set properties on a group, only if they do not yet exist.
28471 * This will not overwrite previous group property values, unlike
28472 * group.set().
28473 *
28474 * ### Usage:
28475 *
28476 * mixpanel.get_group('company', 'mixpanel').set_once('Location', '405 Howard');
28477 *
28478 * // or set multiple properties at once
28479 * mixpanel.get_group('company', 'mixpanel').set_once({
28480 * 'Location': '405 Howard',
28481 * 'Founded' : 2009,
28482 * });
28483 * // properties can be strings, integers, lists or dates
28484 *
28485 * @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.
28486 * @param {*} [to] A value to set on the given property name
28487 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28488 */
28489 MixpanelGroup.prototype.set_once = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28490 var data = this.set_once_action(prop, to);
28491 if (_.isObject(prop)) {
28492 callback = to;
28493 }
28494 return this._send_request(data, callback);
28495 });
28496
28497 /**
28498 * Unset properties on a group permanently.
28499 *
28500 * ### Usage:
28501 *
28502 * mixpanel.get_group('company', 'mixpanel').unset('Founded');
28503 *
28504 * @param {String} prop The name of the property.
28505 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28506 */
28507 MixpanelGroup.prototype.unset = addOptOutCheckMixpanelGroup(function(prop, callback) {
28508 var data = this.unset_action(prop);
28509 return this._send_request(data, callback);
28510 });
28511
28512 /**
28513 * Merge a given list with a list-valued group property, excluding duplicate values.
28514 *
28515 * ### Usage:
28516 *
28517 * // merge a value to a list, creating it if needed
28518 * mixpanel.get_group('company', 'mixpanel').union('Location', ['San Francisco', 'London']);
28519 *
28520 * @param {String} list_name Name of the property.
28521 * @param {Array} values Values to merge with the given property
28522 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28523 */
28524 MixpanelGroup.prototype.union = addOptOutCheckMixpanelGroup(function(list_name, values, callback) {
28525 if (_.isObject(list_name)) {
28526 callback = values;
28527 }
28528 var data = this.union_action(list_name, values);
28529 return this._send_request(data, callback);
28530 });
28531
28532 /**
28533 * Permanently delete a group.
28534 *
28535 * ### Usage:
28536 *
28537 * mixpanel.get_group('company', 'mixpanel').delete();
28538 *
28539 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28540 */
28541 MixpanelGroup.prototype['delete'] = addOptOutCheckMixpanelGroup(function(callback) {
28542 // bracket notation above prevents a minification error related to reserved words
28543 var data = this.delete_action();
28544 return this._send_request(data, callback);
28545 });
28546
28547 /**
28548 * Remove a property from a group. The value will be ignored if doesn't exist.
28549 *
28550 * ### Usage:
28551 *
28552 * mixpanel.get_group('company', 'mixpanel').remove('Location', 'London');
28553 *
28554 * @param {String} list_name Name of the property.
28555 * @param {Object} value Value to remove from the given group property
28556 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28557 */
28558 MixpanelGroup.prototype.remove = addOptOutCheckMixpanelGroup(function(list_name, value, callback) {
28559 var data = this.remove_action(list_name, value);
28560 return this._send_request(data, callback);
28561 });
28562
28563 MixpanelGroup.prototype._send_request = function(data, callback) {
28564 data['$group_key'] = this._group_key;
28565 data['$group_id'] = this._group_id;
28566 data['$token'] = this._get_config('token');
28567
28568 var date_encoded_data = _.encodeDates(data);
28569 return this._mixpanel._track_or_batch({
28570 type: 'groups',
28571 data: date_encoded_data,
28572 endpoint: this._mixpanel.get_api_host('groups') + '/' + this._get_config('api_routes')['groups'],
28573 batcher: this._mixpanel.request_batchers.groups
28574 }, callback);
28575 };
28576
28577 MixpanelGroup.prototype._is_reserved_property = function(prop) {
28578 return prop === '$group_key' || prop === '$group_id';
28579 };
28580
28581 MixpanelGroup.prototype._get_config = function(conf) {
28582 return this._mixpanel.get_config(conf);
28583 };
28584
28585 MixpanelGroup.prototype.toString = function() {
28586 return this._mixpanel.toString() + '.group.' + this._group_key + '.' + this._group_id;
28587 };
28588
28589 // MixpanelGroup Exports
28590 MixpanelGroup.prototype['remove'] = MixpanelGroup.prototype.remove;
28591 MixpanelGroup.prototype['set'] = MixpanelGroup.prototype.set;
28592 MixpanelGroup.prototype['set_once'] = MixpanelGroup.prototype.set_once;
28593 MixpanelGroup.prototype['union'] = MixpanelGroup.prototype.union;
28594 MixpanelGroup.prototype['unset'] = MixpanelGroup.prototype.unset;
28595 MixpanelGroup.prototype['toString'] = MixpanelGroup.prototype.toString;
28596
28597 /* eslint camelcase: "off" */
28598
28599 /**
28600 * Mixpanel People Object
28601 * @constructor
28602 */
28603 var MixpanelPeople = function() {};
28604
28605 _.extend(MixpanelPeople.prototype, apiActions);
28606
28607 MixpanelPeople.prototype._init = function(mixpanel_instance) {
28608 this._mixpanel = mixpanel_instance;
28609 };
28610
28611 /*
28612 * Set properties on a user record.
28613 *
28614 * ### Usage:
28615 *
28616 * mixpanel.people.set('gender', 'm');
28617 *
28618 * // or set multiple properties at once
28619 * mixpanel.people.set({
28620 * 'Company': 'Acme',
28621 * 'Plan': 'Premium',
28622 * 'Upgrade date': new Date()
28623 * });
28624 * // properties can be strings, integers, dates, or lists
28625 *
28626 * @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.
28627 * @param {*} [to] A value to set on the given property name
28628 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28629 */
28630 MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
28631 var data = this.set_action(prop, to);
28632 if (_.isObject(prop)) {
28633 callback = to;
28634 }
28635 // make sure that the referrer info has been updated and saved
28636 if (this._get_config('save_referrer')) {
28637 this._mixpanel['persistence'].update_referrer_info(document.referrer);
28638 }
28639
28640 // update $set object with default people properties
28641 data[SET_ACTION] = _.extend(
28642 {},
28643 _.info.people_properties(),
28644 data[SET_ACTION]
28645 );
28646 return this._send_request(data, callback);
28647 });
28648
28649 /*
28650 * Set properties on a user record, only if they do not yet exist.
28651 * This will not overwrite previous people property values, unlike
28652 * people.set().
28653 *
28654 * ### Usage:
28655 *
28656 * mixpanel.people.set_once('First Login Date', new Date());
28657 *
28658 * // or set multiple properties at once
28659 * mixpanel.people.set_once({
28660 * 'First Login Date': new Date(),
28661 * 'Starting Plan': 'Premium'
28662 * });
28663 *
28664 * // properties can be strings, integers or dates
28665 *
28666 * @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.
28667 * @param {*} [to] A value to set on the given property name
28668 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28669 */
28670 MixpanelPeople.prototype.set_once = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
28671 var data = this.set_once_action(prop, to);
28672 if (_.isObject(prop)) {
28673 callback = to;
28674 }
28675 return this._send_request(data, callback);
28676 });
28677
28678 /*
28679 * Unset properties on a user record (permanently removes the properties and their values from a profile).
28680 *
28681 * ### Usage:
28682 *
28683 * mixpanel.people.unset('gender');
28684 *
28685 * // or unset multiple properties at once
28686 * mixpanel.people.unset(['gender', 'Company']);
28687 *
28688 * @param {Array|String} prop If a string, this is the name of the property. If an array, this is a list of property names.
28689 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28690 */
28691 MixpanelPeople.prototype.unset = addOptOutCheckMixpanelPeople(function(prop, callback) {
28692 var data = this.unset_action(prop);
28693 return this._send_request(data, callback);
28694 });
28695
28696 /*
28697 * Increment/decrement numeric people analytics properties.
28698 *
28699 * ### Usage:
28700 *
28701 * mixpanel.people.increment('page_views', 1);
28702 *
28703 * // or, for convenience, if you're just incrementing a counter by
28704 * // 1, you can simply do
28705 * mixpanel.people.increment('page_views');
28706 *
28707 * // to decrement a counter, pass a negative number
28708 * mixpanel.people.increment('credits_left', -1);
28709 *
28710 * // like mixpanel.people.set(), you can increment multiple
28711 * // properties at once:
28712 * mixpanel.people.increment({
28713 * counter1: 1,
28714 * counter2: 6
28715 * });
28716 *
28717 * @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.
28718 * @param {Number} [by] An amount to increment the given property
28719 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28720 */
28721 MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop, by, callback) {
28722 var data = {};
28723 var $add = {};
28724 if (_.isObject(prop)) {
28725 _.each(prop, function(v, k) {
28726 if (!this._is_reserved_property(k)) {
28727 if (isNaN(parseFloat(v))) {
28728 console$1.error('Invalid increment value passed to mixpanel.people.increment - must be a number');
28729 return;
28730 } else {
28731 $add[k] = v;
28732 }
28733 }
28734 }, this);
28735 callback = by;
28736 } else {
28737 // convenience: mixpanel.people.increment('property'); will
28738 // increment 'property' by 1
28739 if (_.isUndefined(by)) {
28740 by = 1;
28741 }
28742 $add[prop] = by;
28743 }
28744 data[ADD_ACTION] = $add;
28745
28746 return this._send_request(data, callback);
28747 });
28748
28749 /*
28750 * Append a value to a list-valued people analytics property.
28751 *
28752 * ### Usage:
28753 *
28754 * // append a value to a list, creating it if needed
28755 * mixpanel.people.append('pages_visited', 'homepage');
28756 *
28757 * // like mixpanel.people.set(), you can append multiple
28758 * // properties at once:
28759 * mixpanel.people.append({
28760 * list1: 'bob',
28761 * list2: 123
28762 * });
28763 *
28764 * @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.
28765 * @param {*} [value] value An item to append to the list
28766 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28767 */
28768 MixpanelPeople.prototype.append = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
28769 if (_.isObject(list_name)) {
28770 callback = value;
28771 }
28772 var data = this.append_action(list_name, value);
28773 return this._send_request(data, callback);
28774 });
28775
28776 /*
28777 * Remove a value from a list-valued people analytics property.
28778 *
28779 * ### Usage:
28780 *
28781 * mixpanel.people.remove('School', 'UCB');
28782 *
28783 * @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.
28784 * @param {*} [value] value Item to remove from the list
28785 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28786 */
28787 MixpanelPeople.prototype.remove = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
28788 if (_.isObject(list_name)) {
28789 callback = value;
28790 }
28791 var data = this.remove_action(list_name, value);
28792 return this._send_request(data, callback);
28793 });
28794
28795 /*
28796 * Merge a given list with a list-valued people analytics property,
28797 * excluding duplicate values.
28798 *
28799 * ### Usage:
28800 *
28801 * // merge a value to a list, creating it if needed
28802 * mixpanel.people.union('pages_visited', 'homepage');
28803 *
28804 * // like mixpanel.people.set(), you can append multiple
28805 * // properties at once:
28806 * mixpanel.people.union({
28807 * list1: 'bob',
28808 * list2: 123
28809 * });
28810 *
28811 * // like mixpanel.people.append(), you can append multiple
28812 * // values to the same list:
28813 * mixpanel.people.union({
28814 * list1: ['bob', 'billy']
28815 * });
28816 *
28817 * @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.
28818 * @param {*} [value] Value / values to merge with the given property
28819 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28820 */
28821 MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name, values, callback) {
28822 if (_.isObject(list_name)) {
28823 callback = values;
28824 }
28825 var data = this.union_action(list_name, values);
28826 return this._send_request(data, callback);
28827 });
28828
28829 /*
28830 * Record that you have charged the current user a certain amount
28831 * of money. Charges recorded with track_charge() will appear in the
28832 * Mixpanel revenue report.
28833 *
28834 * ### Usage:
28835 *
28836 * // charge a user $50
28837 * mixpanel.people.track_charge(50);
28838 *
28839 * // charge a user $30.50 on the 2nd of january
28840 * mixpanel.people.track_charge(30.50, {
28841 * '$time': new Date('jan 1 2012')
28842 * });
28843 *
28844 * @param {Number} amount The amount of money charged to the current user
28845 * @param {Object} [properties] An associative array of properties associated with the charge
28846 * @param {Function} [callback] If provided, the callback will be called when the server responds
28847 * @deprecated
28848 */
28849 MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
28850 console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
28851 });
28852
28853 /*
28854 * Permanently clear all revenue report transactions from the
28855 * current user's people analytics profile.
28856 *
28857 * ### Usage:
28858 *
28859 * mixpanel.people.clear_charges();
28860 *
28861 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
28862 * @deprecated
28863 */
28864 MixpanelPeople.prototype.clear_charges = function(callback) {
28865 return this.set('$transactions', [], callback);
28866 };
28867
28868 /*
28869 * Permanently deletes the current people analytics profile from
28870 * Mixpanel (using the current distinct_id).
28871 *
28872 * ### Usage:
28873 *
28874 * // remove the all data you have stored about the current user
28875 * mixpanel.people.delete_user();
28876 *
28877 */
28878 MixpanelPeople.prototype.delete_user = function() {
28879 if (!this._identify_called()) {
28880 console$1.error('mixpanel.people.delete_user() requires you to call identify() first');
28881 return;
28882 }
28883 var data = {'$delete': this._mixpanel.get_distinct_id()};
28884 return this._send_request(data);
28885 };
28886
28887 MixpanelPeople.prototype.toString = function() {
28888 return this._mixpanel.toString() + '.people';
28889 };
28890
28891 MixpanelPeople.prototype._send_request = function(data, callback) {
28892 data['$token'] = this._get_config('token');
28893 data['$distinct_id'] = this._mixpanel.get_distinct_id();
28894 var device_id = this._mixpanel.get_property('$device_id');
28895 var user_id = this._mixpanel.get_property('$user_id');
28896 var had_persisted_distinct_id = this._mixpanel.get_property('$had_persisted_distinct_id');
28897 if (device_id) {
28898 data['$device_id'] = device_id;
28899 }
28900 if (user_id) {
28901 data['$user_id'] = user_id;
28902 }
28903 if (had_persisted_distinct_id) {
28904 data['$had_persisted_distinct_id'] = had_persisted_distinct_id;
28905 }
28906
28907 var date_encoded_data = _.encodeDates(data);
28908
28909 if (!this._identify_called()) {
28910 this._enqueue(data);
28911 if (!_.isUndefined(callback)) {
28912 if (this._get_config('verbose')) {
28913 callback({status: -1, error: null});
28914 } else {
28915 callback(-1);
28916 }
28917 }
28918 return _.truncate(date_encoded_data, 255);
28919 }
28920
28921 return this._mixpanel._track_or_batch({
28922 type: 'people',
28923 data: date_encoded_data,
28924 endpoint: this._mixpanel.get_api_host('people') + '/' + this._get_config('api_routes')['engage'],
28925 batcher: this._mixpanel.request_batchers.people
28926 }, callback);
28927 };
28928
28929 MixpanelPeople.prototype._get_config = function(conf_var) {
28930 return this._mixpanel.get_config(conf_var);
28931 };
28932
28933 MixpanelPeople.prototype._identify_called = function() {
28934 return this._mixpanel._flags.identify_called === true;
28935 };
28936
28937 // Queue up engage operations if identify hasn't been called yet.
28938 MixpanelPeople.prototype._enqueue = function(data) {
28939 if (SET_ACTION in data) {
28940 this._mixpanel['persistence']._add_to_people_queue(SET_ACTION, data);
28941 } else if (SET_ONCE_ACTION in data) {
28942 this._mixpanel['persistence']._add_to_people_queue(SET_ONCE_ACTION, data);
28943 } else if (UNSET_ACTION in data) {
28944 this._mixpanel['persistence']._add_to_people_queue(UNSET_ACTION, data);
28945 } else if (ADD_ACTION in data) {
28946 this._mixpanel['persistence']._add_to_people_queue(ADD_ACTION, data);
28947 } else if (APPEND_ACTION in data) {
28948 this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, data);
28949 } else if (REMOVE_ACTION in data) {
28950 this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, data);
28951 } else if (UNION_ACTION in data) {
28952 this._mixpanel['persistence']._add_to_people_queue(UNION_ACTION, data);
28953 } else {
28954 console$1.error('Invalid call to _enqueue():', data);
28955 }
28956 };
28957
28958 MixpanelPeople.prototype._flush_one_queue = function(action, action_method, callback, queue_to_params_fn) {
28959 var _this = this;
28960 var queued_data = _.extend({}, this._mixpanel['persistence'].load_queue(action));
28961 var action_params = queued_data;
28962
28963 if (!_.isUndefined(queued_data) && _.isObject(queued_data) && !_.isEmptyObject(queued_data)) {
28964 _this._mixpanel['persistence']._pop_from_people_queue(action, queued_data);
28965 _this._mixpanel['persistence'].save();
28966 if (queue_to_params_fn) {
28967 action_params = queue_to_params_fn(queued_data);
28968 }
28969 action_method.call(_this, action_params, function(response, data) {
28970 // on bad response, we want to add it back to the queue
28971 if (response === 0) {
28972 _this._mixpanel['persistence']._add_to_people_queue(action, queued_data);
28973 }
28974 if (!_.isUndefined(callback)) {
28975 callback(response, data);
28976 }
28977 });
28978 }
28979 };
28980
28981 // Flush queued engage operations - order does not matter,
28982 // and there are network level race conditions anyway
28983 MixpanelPeople.prototype._flush = function(
28984 _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
28985 ) {
28986 var _this = this;
28987
28988 this._flush_one_queue(SET_ACTION, this.set, _set_callback);
28989 this._flush_one_queue(SET_ONCE_ACTION, this.set_once, _set_once_callback);
28990 this._flush_one_queue(UNSET_ACTION, this.unset, _unset_callback, function(queue) { return _.keys(queue); });
28991 this._flush_one_queue(ADD_ACTION, this.increment, _add_callback);
28992 this._flush_one_queue(UNION_ACTION, this.union, _union_callback);
28993
28994 // we have to fire off each $append individually since there is
28995 // no concat method server side
28996 var $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
28997 if (!_.isUndefined($append_queue) && _.isArray($append_queue) && $append_queue.length) {
28998 var $append_item;
28999 var append_callback = function(response, data) {
29000 if (response === 0) {
29001 _this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, $append_item);
29002 }
29003 if (!_.isUndefined(_append_callback)) {
29004 _append_callback(response, data);
29005 }
29006 };
29007 for (var i = $append_queue.length - 1; i >= 0; i--) {
29008 $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29009 $append_item = $append_queue.pop();
29010 _this._mixpanel['persistence'].save();
29011 if (!_.isEmptyObject($append_item)) {
29012 _this.append($append_item, append_callback);
29013 }
29014 }
29015 }
29016
29017 // same for $remove
29018 var $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29019 if (!_.isUndefined($remove_queue) && _.isArray($remove_queue) && $remove_queue.length) {
29020 var $remove_item;
29021 var remove_callback = function(response, data) {
29022 if (response === 0) {
29023 _this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, $remove_item);
29024 }
29025 if (!_.isUndefined(_remove_callback)) {
29026 _remove_callback(response, data);
29027 }
29028 };
29029 for (var j = $remove_queue.length - 1; j >= 0; j--) {
29030 $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29031 $remove_item = $remove_queue.pop();
29032 _this._mixpanel['persistence'].save();
29033 if (!_.isEmptyObject($remove_item)) {
29034 _this.remove($remove_item, remove_callback);
29035 }
29036 }
29037 }
29038 };
29039
29040 MixpanelPeople.prototype._is_reserved_property = function(prop) {
29041 return prop === '$distinct_id' || prop === '$token' || prop === '$device_id' || prop === '$user_id' || prop === '$had_persisted_distinct_id';
29042 };
29043
29044 // MixpanelPeople Exports
29045 MixpanelPeople.prototype['set'] = MixpanelPeople.prototype.set;
29046 MixpanelPeople.prototype['set_once'] = MixpanelPeople.prototype.set_once;
29047 MixpanelPeople.prototype['unset'] = MixpanelPeople.prototype.unset;
29048 MixpanelPeople.prototype['increment'] = MixpanelPeople.prototype.increment;
29049 MixpanelPeople.prototype['append'] = MixpanelPeople.prototype.append;
29050 MixpanelPeople.prototype['remove'] = MixpanelPeople.prototype.remove;
29051 MixpanelPeople.prototype['union'] = MixpanelPeople.prototype.union;
29052 MixpanelPeople.prototype['track_charge'] = MixpanelPeople.prototype.track_charge;
29053 MixpanelPeople.prototype['clear_charges'] = MixpanelPeople.prototype.clear_charges;
29054 MixpanelPeople.prototype['delete_user'] = MixpanelPeople.prototype.delete_user;
29055 MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
29056
29057 /* eslint camelcase: "off" */
29058
29059
29060 /*
29061 * Constants
29062 */
29063 /** @const */ var SET_QUEUE_KEY = '__mps';
29064 /** @const */ var SET_ONCE_QUEUE_KEY = '__mpso';
29065 /** @const */ var UNSET_QUEUE_KEY = '__mpus';
29066 /** @const */ var ADD_QUEUE_KEY = '__mpa';
29067 /** @const */ var APPEND_QUEUE_KEY = '__mpap';
29068 /** @const */ var REMOVE_QUEUE_KEY = '__mpr';
29069 /** @const */ var UNION_QUEUE_KEY = '__mpu';
29070 // This key is deprecated, but we want to check for it to see whether aliasing is allowed.
29071 /** @const */ var PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id';
29072 /** @const */ var ALIAS_ID_KEY = '__alias';
29073 /** @const */ var EVENT_TIMERS_KEY = '__timers';
29074 /** @const */ var RESERVED_PROPERTIES = [
29075 SET_QUEUE_KEY,
29076 SET_ONCE_QUEUE_KEY,
29077 UNSET_QUEUE_KEY,
29078 ADD_QUEUE_KEY,
29079 APPEND_QUEUE_KEY,
29080 REMOVE_QUEUE_KEY,
29081 UNION_QUEUE_KEY,
29082 PEOPLE_DISTINCT_ID_KEY,
29083 ALIAS_ID_KEY,
29084 EVENT_TIMERS_KEY
29085 ];
29086
29087 /**
29088 * Mixpanel Persistence Object
29089 * @constructor
29090 */
29091 var MixpanelPersistence = function(config) {
29092 this['props'] = {};
29093 this.campaign_params_saved = false;
29094
29095 if (config['persistence_name']) {
29096 this.name = 'mp_' + config['persistence_name'];
29097 } else {
29098 this.name = 'mp_' + config['token'] + '_mixpanel';
29099 }
29100
29101 var storage_type = config['persistence'];
29102 if (storage_type !== 'cookie' && storage_type !== 'localStorage') {
29103 console$1.critical('Unknown persistence type ' + storage_type + '; falling back to cookie');
29104 storage_type = config['persistence'] = 'cookie';
29105 }
29106
29107 if (storage_type === 'localStorage' && _.localStorage.is_supported()) {
29108 this.storage = _.localStorage;
29109 } else {
29110 this.storage = _.cookie;
29111 }
29112
29113 this.load();
29114 this.update_config(config);
29115 this.upgrade();
29116 this.save();
29117 };
29118
29119 MixpanelPersistence.prototype.properties = function() {
29120 var p = {};
29121
29122 this.load();
29123
29124 // Filter out reserved properties
29125 _.each(this['props'], function(v, k) {
29126 if (!_.include(RESERVED_PROPERTIES, k)) {
29127 p[k] = v;
29128 }
29129 });
29130 return p;
29131 };
29132
29133 MixpanelPersistence.prototype.load = function() {
29134 if (this.disabled) { return; }
29135
29136 var entry = this.storage.parse(this.name);
29137
29138 if (entry) {
29139 this['props'] = _.extend({}, entry);
29140 }
29141 };
29142
29143 MixpanelPersistence.prototype.upgrade = function() {
29144 var old_cookie,
29145 old_localstorage;
29146
29147 // if transferring from cookie to localStorage or vice-versa, copy existing
29148 // super properties over to new storage mode
29149 if (this.storage === _.localStorage) {
29150 old_cookie = _.cookie.parse(this.name);
29151
29152 _.cookie.remove(this.name);
29153 _.cookie.remove(this.name, true);
29154
29155 if (old_cookie) {
29156 this.register_once(old_cookie);
29157 }
29158 } else if (this.storage === _.cookie) {
29159 old_localstorage = _.localStorage.parse(this.name);
29160
29161 _.localStorage.remove(this.name);
29162
29163 if (old_localstorage) {
29164 this.register_once(old_localstorage);
29165 }
29166 }
29167 };
29168
29169 MixpanelPersistence.prototype.save = function() {
29170 if (this.disabled) { return; }
29171
29172 this.storage.set(
29173 this.name,
29174 JSONStringify(this['props']),
29175 this.expire_days,
29176 this.cross_subdomain,
29177 this.secure,
29178 this.cross_site,
29179 this.cookie_domain
29180 );
29181 };
29182
29183 MixpanelPersistence.prototype.load_prop = function(key) {
29184 this.load();
29185 return this['props'][key];
29186 };
29187
29188 MixpanelPersistence.prototype.remove = function() {
29189 // remove both domain and subdomain cookies
29190 this.storage.remove(this.name, false, this.cookie_domain);
29191 this.storage.remove(this.name, true, this.cookie_domain);
29192 };
29193
29194 // removes the storage entry and deletes all loaded data
29195 // forced name for tests
29196 MixpanelPersistence.prototype.clear = function() {
29197 this.remove();
29198 this['props'] = {};
29199 };
29200
29201 /**
29202 * @param {Object} props
29203 * @param {*=} default_value
29204 * @param {number=} days
29205 */
29206 MixpanelPersistence.prototype.register_once = function(props, default_value, days) {
29207 if (_.isObject(props)) {
29208 if (typeof(default_value) === 'undefined') { default_value = 'None'; }
29209 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29210
29211 this.load();
29212
29213 _.each(props, function(val, prop) {
29214 if (!this['props'].hasOwnProperty(prop) || this['props'][prop] === default_value) {
29215 this['props'][prop] = val;
29216 }
29217 }, this);
29218
29219 this.save();
29220
29221 return true;
29222 }
29223 return false;
29224 };
29225
29226 /**
29227 * @param {Object} props
29228 * @param {number=} days
29229 */
29230 MixpanelPersistence.prototype.register = function(props, days) {
29231 if (_.isObject(props)) {
29232 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29233
29234 this.load();
29235 _.extend(this['props'], props);
29236 this.save();
29237
29238 return true;
29239 }
29240 return false;
29241 };
29242
29243 MixpanelPersistence.prototype.unregister = function(prop) {
29244 this.load();
29245 if (prop in this['props']) {
29246 delete this['props'][prop];
29247 this.save();
29248 }
29249 };
29250
29251 MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
29252 this.register(_.info.searchInfo(referrer));
29253 };
29254
29255 // EXPORTED METHOD, we test this directly.
29256 MixpanelPersistence.prototype.update_referrer_info = function(referrer) {
29257 // If referrer doesn't exist, we want to note the fact that it was type-in traffic.
29258 this.register_once({
29259 '$initial_referrer': referrer || '$direct',
29260 '$initial_referring_domain': _.info.referringDomain(referrer) || '$direct'
29261 }, '');
29262 };
29263
29264 MixpanelPersistence.prototype.get_referrer_info = function() {
29265 return _.strip_empty_properties({
29266 '$initial_referrer': this['props']['$initial_referrer'],
29267 '$initial_referring_domain': this['props']['$initial_referring_domain']
29268 });
29269 };
29270
29271 MixpanelPersistence.prototype.update_config = function(config) {
29272 this.default_expiry = this.expire_days = config['cookie_expiration'];
29273 this.set_disabled(config['disable_persistence']);
29274 this.set_cookie_domain(config['cookie_domain']);
29275 this.set_cross_site(config['cross_site_cookie']);
29276 this.set_cross_subdomain(config['cross_subdomain_cookie']);
29277 this.set_secure(config['secure_cookie']);
29278 };
29279
29280 MixpanelPersistence.prototype.set_disabled = function(disabled) {
29281 this.disabled = disabled;
29282 if (this.disabled) {
29283 this.remove();
29284 } else {
29285 this.save();
29286 }
29287 };
29288
29289 MixpanelPersistence.prototype.set_cookie_domain = function(cookie_domain) {
29290 if (cookie_domain !== this.cookie_domain) {
29291 this.remove();
29292 this.cookie_domain = cookie_domain;
29293 this.save();
29294 }
29295 };
29296
29297 MixpanelPersistence.prototype.set_cross_site = function(cross_site) {
29298 if (cross_site !== this.cross_site) {
29299 this.cross_site = cross_site;
29300 this.remove();
29301 this.save();
29302 }
29303 };
29304
29305 MixpanelPersistence.prototype.set_cross_subdomain = function(cross_subdomain) {
29306 if (cross_subdomain !== this.cross_subdomain) {
29307 this.cross_subdomain = cross_subdomain;
29308 this.remove();
29309 this.save();
29310 }
29311 };
29312
29313 MixpanelPersistence.prototype.get_cross_subdomain = function() {
29314 return this.cross_subdomain;
29315 };
29316
29317 MixpanelPersistence.prototype.set_secure = function(secure) {
29318 if (secure !== this.secure) {
29319 this.secure = secure ? true : false;
29320 this.remove();
29321 this.save();
29322 }
29323 };
29324
29325 MixpanelPersistence.prototype._add_to_people_queue = function(queue, data) {
29326 var q_key = this._get_queue_key(queue),
29327 q_data = data[queue],
29328 set_q = this._get_or_create_queue(SET_ACTION),
29329 set_once_q = this._get_or_create_queue(SET_ONCE_ACTION),
29330 unset_q = this._get_or_create_queue(UNSET_ACTION),
29331 add_q = this._get_or_create_queue(ADD_ACTION),
29332 union_q = this._get_or_create_queue(UNION_ACTION),
29333 remove_q = this._get_or_create_queue(REMOVE_ACTION, []),
29334 append_q = this._get_or_create_queue(APPEND_ACTION, []);
29335
29336 if (q_key === SET_QUEUE_KEY) {
29337 // Update the set queue - we can override any existing values
29338 _.extend(set_q, q_data);
29339 // if there was a pending increment, override it
29340 // with the set.
29341 this._pop_from_people_queue(ADD_ACTION, q_data);
29342 // if there was a pending union, override it
29343 // with the set.
29344 this._pop_from_people_queue(UNION_ACTION, q_data);
29345 this._pop_from_people_queue(UNSET_ACTION, q_data);
29346 } else if (q_key === SET_ONCE_QUEUE_KEY) {
29347 // only queue the data if there is not already a set_once call for it.
29348 _.each(q_data, function(v, k) {
29349 if (!(k in set_once_q)) {
29350 set_once_q[k] = v;
29351 }
29352 });
29353 this._pop_from_people_queue(UNSET_ACTION, q_data);
29354 } else if (q_key === UNSET_QUEUE_KEY) {
29355 _.each(q_data, function(prop) {
29356
29357 // undo previously-queued actions on this key
29358 _.each([set_q, set_once_q, add_q, union_q], function(enqueued_obj) {
29359 if (prop in enqueued_obj) {
29360 delete enqueued_obj[prop];
29361 }
29362 });
29363 _.each(append_q, function(append_obj) {
29364 if (prop in append_obj) {
29365 delete append_obj[prop];
29366 }
29367 });
29368
29369 unset_q[prop] = true;
29370
29371 });
29372 } else if (q_key === ADD_QUEUE_KEY) {
29373 _.each(q_data, function(v, k) {
29374 // If it exists in the set queue, increment
29375 // the value
29376 if (k in set_q) {
29377 set_q[k] += v;
29378 } else {
29379 // If it doesn't exist, update the add
29380 // queue
29381 if (!(k in add_q)) {
29382 add_q[k] = 0;
29383 }
29384 add_q[k] += v;
29385 }
29386 }, this);
29387 this._pop_from_people_queue(UNSET_ACTION, q_data);
29388 } else if (q_key === UNION_QUEUE_KEY) {
29389 _.each(q_data, function(v, k) {
29390 if (_.isArray(v)) {
29391 if (!(k in union_q)) {
29392 union_q[k] = [];
29393 }
29394 // Prevent duplicate values
29395 _.each(v, function(item) {
29396 if (!_.include(union_q[k], item)) {
29397 union_q[k].push(item);
29398 }
29399 });
29400 }
29401 });
29402 this._pop_from_people_queue(UNSET_ACTION, q_data);
29403 } else if (q_key === REMOVE_QUEUE_KEY) {
29404 remove_q.push(q_data);
29405 this._pop_from_people_queue(APPEND_ACTION, q_data);
29406 } else if (q_key === APPEND_QUEUE_KEY) {
29407 append_q.push(q_data);
29408 this._pop_from_people_queue(UNSET_ACTION, q_data);
29409 }
29410
29411 console$1.log('MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):');
29412 console$1.log(data);
29413
29414 this.save();
29415 };
29416
29417 MixpanelPersistence.prototype._pop_from_people_queue = function(queue, data) {
29418 var q = this['props'][this._get_queue_key(queue)];
29419 if (!_.isUndefined(q)) {
29420 _.each(data, function(v, k) {
29421 if (queue === APPEND_ACTION || queue === REMOVE_ACTION) {
29422 // list actions: only remove if both k+v match
29423 // e.g. remove should not override append in a case like
29424 // append({foo: 'bar'}); remove({foo: 'qux'})
29425 _.each(q, function(queued_action) {
29426 if (queued_action[k] === v) {
29427 delete queued_action[k];
29428 }
29429 });
29430 } else {
29431 delete q[k];
29432 }
29433 }, this);
29434 }
29435 };
29436
29437 MixpanelPersistence.prototype.load_queue = function(queue) {
29438 return this.load_prop(this._get_queue_key(queue));
29439 };
29440
29441 MixpanelPersistence.prototype._get_queue_key = function(queue) {
29442 if (queue === SET_ACTION) {
29443 return SET_QUEUE_KEY;
29444 } else if (queue === SET_ONCE_ACTION) {
29445 return SET_ONCE_QUEUE_KEY;
29446 } else if (queue === UNSET_ACTION) {
29447 return UNSET_QUEUE_KEY;
29448 } else if (queue === ADD_ACTION) {
29449 return ADD_QUEUE_KEY;
29450 } else if (queue === APPEND_ACTION) {
29451 return APPEND_QUEUE_KEY;
29452 } else if (queue === REMOVE_ACTION) {
29453 return REMOVE_QUEUE_KEY;
29454 } else if (queue === UNION_ACTION) {
29455 return UNION_QUEUE_KEY;
29456 } else {
29457 console$1.error('Invalid queue:', queue);
29458 }
29459 };
29460
29461 MixpanelPersistence.prototype._get_or_create_queue = function(queue, default_val) {
29462 var key = this._get_queue_key(queue);
29463 default_val = _.isUndefined(default_val) ? {} : default_val;
29464 return this['props'][key] || (this['props'][key] = default_val);
29465 };
29466
29467 MixpanelPersistence.prototype.set_event_timer = function(event_name, timestamp) {
29468 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29469 timers[event_name] = timestamp;
29470 this['props'][EVENT_TIMERS_KEY] = timers;
29471 this.save();
29472 };
29473
29474 MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
29475 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29476 var timestamp = timers[event_name];
29477 if (!_.isUndefined(timestamp)) {
29478 delete this['props'][EVENT_TIMERS_KEY][event_name];
29479 this.save();
29480 }
29481 return timestamp;
29482 };
29483
29484 /* eslint camelcase: "off" */
29485
29486 /*
29487 * Mixpanel JS Library
29488 *
29489 * Copyright 2012, Mixpanel, Inc. All Rights Reserved
29490 * http://mixpanel.com/
29491 *
29492 * Includes portions of Underscore.js
29493 * http://documentcloud.github.com/underscore/
29494 * (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
29495 * Released under the MIT License.
29496 */
29497
29498 /*
29499 SIMPLE STYLE GUIDE:
29500
29501 this.x === public function
29502 this._x === internal - only use within this file
29503 this.__x === private - only use within the class
29504
29505 Globals should be all caps
29506 */
29507
29508 var init_type; // MODULE or SNIPPET loader
29509 // allow bundlers to specify how extra code (recorder bundle) should be loaded
29510 // eslint-disable-next-line no-unused-vars
29511 var load_extra_bundle = function(src, _onload) {
29512 throw new Error(src + ' not available in this build.');
29513 };
29514
29515 var mixpanel_master; // main mixpanel instance / object
29516 var INIT_MODULE = 0;
29517 var INIT_SNIPPET = 1;
29518
29519 var IDENTITY_FUNC = function(x) {return x;};
29520
29521 /** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
29522 /** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
29523 /** @const */ var PAYLOAD_TYPE_JSON = 'json';
29524 /** @const */ var DEVICE_ID_PREFIX = '$device:';
29525
29526
29527 /*
29528 * Dynamic... constants? Is that an oxymoron?
29529 */
29530 // http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
29531 // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#withCredentials
29532 var USE_XHR = (win.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest());
29533
29534 // IE<10 does not support cross-origin XHR's but script tags
29535 // with defer won't block window.onload; ENQUEUE_REQUESTS
29536 // should only be true for Opera<12
29537 var ENQUEUE_REQUESTS = !USE_XHR && (userAgent.indexOf('MSIE') === -1) && (userAgent.indexOf('Mozilla') === -1);
29538
29539 // save reference to navigator.sendBeacon so it can be minified
29540 var sendBeacon = null;
29541 if (navigator['sendBeacon']) {
29542 sendBeacon = function() {
29543 // late reference to navigator.sendBeacon to allow patching/spying
29544 return navigator['sendBeacon'].apply(navigator, arguments);
29545 };
29546 }
29547
29548 var DEFAULT_API_ROUTES = {
29549 'track': 'track/',
29550 'engage': 'engage/',
29551 'groups': 'groups/',
29552 'record': 'record/',
29553 'flags': 'flags/'
29554 };
29555
29556 /*
29557 * Module-level globals
29558 */
29559 var DEFAULT_CONFIG = {
29560 'api_host': 'https://api-js.mixpanel.com',
29561 'api_hosts': {},
29562 'api_routes': DEFAULT_API_ROUTES,
29563 'api_extra_query_params': {},
29564 'api_method': 'POST',
29565 'api_transport': 'XHR',
29566 'api_payload_format': PAYLOAD_TYPE_BASE64,
29567 'app_host': 'https://mixpanel.com',
29568 'autocapture': false,
29569 'cdn': 'https://cdn.mxpnl.com',
29570 'cross_site_cookie': false,
29571 'cross_subdomain_cookie': true,
29572 'error_reporter': NOOP_FUNC,
29573 'flags': false,
29574 'persistence': 'cookie',
29575 'persistence_name': '',
29576 'cookie_domain': '',
29577 'cookie_name': '',
29578 'loaded': NOOP_FUNC,
29579 'mp_loader': null,
29580 'track_marketing': true,
29581 'track_pageview': false,
29582 'skip_first_touch_marketing': false,
29583 'store_google': true,
29584 'stop_utm_persistence': false,
29585 'save_referrer': true,
29586 'test': false,
29587 'verbose': false,
29588 'img': false,
29589 'debug': false,
29590 'track_links_timeout': 300,
29591 'cookie_expiration': 365,
29592 'upgrade': false,
29593 'disable_persistence': false,
29594 'disable_cookie': false,
29595 'secure_cookie': false,
29596 'ip': true,
29597 'opt_out_tracking_by_default': false,
29598 'opt_out_persistence_by_default': false,
29599 'opt_out_tracking_persistence_type': 'localStorage',
29600 'opt_out_tracking_cookie_prefix': null,
29601 'property_blacklist': [],
29602 'xhr_headers': {}, // { header: value, header2: value }
29603 'ignore_dnt': false,
29604 'batch_requests': true,
29605 'batch_size': 50,
29606 'batch_flush_interval_ms': 5000,
29607 'batch_request_timeout_ms': 90000,
29608 'batch_autostart': true,
29609 'hooks': {},
29610 'record_block_class': new RegExp('^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$'),
29611 'record_block_selector': 'img, video, audio',
29612 'record_canvas': false,
29613 'record_collect_fonts': false,
29614 'record_heatmap_data': false,
29615 'record_idle_timeout_ms': 30 * 60 * 1000, // 30 minutes
29616 'record_mask_text_class': new RegExp('^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$'),
29617 'record_mask_text_selector': '*',
29618 'record_max_ms': MAX_RECORDING_MS,
29619 'record_min_ms': 0,
29620 'record_sessions_percent': 0,
29621 'recorder_src': 'https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js'
29622 };
29623
29624 var DOM_LOADED = false;
29625
29626 /**
29627 * Mixpanel Library Object
29628 * @constructor
29629 */
29630 var MixpanelLib = function() {};
29631
29632
29633 /**
29634 * create_mplib(token:string, config:object, name:string)
29635 *
29636 * This function is used by the init method of MixpanelLib objects
29637 * as well as the main initializer at the end of the JSLib (that
29638 * initializes document.mixpanel as well as any additional instances
29639 * declared before this file has loaded).
29640 */
29641 var create_mplib = function(token, config, name) {
29642 var instance,
29643 target = (name === PRIMARY_INSTANCE_NAME) ? mixpanel_master : mixpanel_master[name];
29644
29645 if (target && init_type === INIT_MODULE) {
29646 instance = target;
29647 } else {
29648 if (target && !_.isArray(target)) {
29649 console$1.error('You have already initialized ' + name);
29650 return;
29651 }
29652 instance = new MixpanelLib();
29653 }
29654
29655 instance._cached_groups = {}; // cache groups in a pool
29656
29657 instance._init(token, config, name);
29658
29659 instance['people'] = new MixpanelPeople();
29660 instance['people']._init(instance);
29661
29662 if (!instance.get_config('skip_first_touch_marketing')) {
29663 // We need null UTM params in the object because
29664 // UTM parameters act as a tuple. If any UTM param
29665 // is present, then we set all UTM params including
29666 // empty ones together
29667 var utm_params = _.info.campaignParams(null);
29668 var initial_utm_params = {};
29669 var has_utm = false;
29670 _.each(utm_params, function(utm_value, utm_key) {
29671 initial_utm_params['initial_' + utm_key] = utm_value;
29672 if (utm_value) {
29673 has_utm = true;
29674 }
29675 });
29676 if (has_utm) {
29677 instance['people'].set_once(initial_utm_params);
29678 }
29679 }
29680
29681 // if any instance on the page has debug = true, we set the
29682 // global debug to be true
29683 Config.DEBUG = Config.DEBUG || instance.get_config('debug');
29684
29685 // if target is not defined, we called init after the lib already
29686 // loaded, so there won't be an array of things to execute
29687 if (!_.isUndefined(target) && _.isArray(target)) {
29688 // Crunch through the people queue first - we queue this data up &
29689 // flush on identify, so it's better to do all these operations first
29690 instance._execute_array.call(instance['people'], target['people']);
29691 instance._execute_array(target);
29692 }
29693
29694 return instance;
29695 };
29696
29697 // Initialization methods
29698
29699 /**
29700 * This function initializes a new instance of the Mixpanel tracking object.
29701 * All new instances are added to the main mixpanel object as sub properties (such as
29702 * mixpanel.library_name) and also returned by this function. To define a
29703 * second instance on the page, you would call:
29704 *
29705 * mixpanel.init('new token', { your: 'config' }, 'library_name');
29706 *
29707 * and use it like so:
29708 *
29709 * mixpanel.library_name.track(...);
29710 *
29711 * @param {String} token Your Mixpanel API token
29712 * @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>.
29713 * @param {String} [name] The name for the new mixpanel instance that you want created
29714 */
29715 MixpanelLib.prototype.init = function (token, config, name) {
29716 if (_.isUndefined(name)) {
29717 this.report_error('You must name your new library: init(token, config, name)');
29718 return;
29719 }
29720 if (name === PRIMARY_INSTANCE_NAME) {
29721 this.report_error('You must initialize the main mixpanel object right after you include the Mixpanel js snippet');
29722 return;
29723 }
29724
29725 var instance = create_mplib(token, config, name);
29726 mixpanel_master[name] = instance;
29727 instance._loaded();
29728
29729 return instance;
29730 };
29731
29732 // mixpanel._init(token:string, config:object, name:string)
29733 //
29734 // This function sets up the current instance of the mixpanel
29735 // library. The difference between this method and the init(...)
29736 // method is this one initializes the actual instance, whereas the
29737 // init(...) method sets up a new library and calls _init on it.
29738 //
29739 MixpanelLib.prototype._init = function(token, config, name) {
29740 config = config || {};
29741
29742 this['__loaded'] = true;
29743 this['config'] = {};
29744
29745 var variable_features = {};
29746
29747 // default to JSON payload for standard mixpanel.com API hosts
29748 if (!('api_payload_format' in config)) {
29749 var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
29750 if (api_host.match(/\.mixpanel\.com/)) {
29751 variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
29752 }
29753 }
29754
29755 this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
29756 'name': name,
29757 'token': token,
29758 'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
29759 }));
29760
29761 this['_jsc'] = NOOP_FUNC;
29762
29763 this.__dom_loaded_queue = [];
29764 this.__request_queue = [];
29765 this.__disabled_events = [];
29766 this._flags = {
29767 'disable_all_events': false,
29768 'identify_called': false
29769 };
29770
29771 // set up request queueing/batching
29772 this.request_batchers = {};
29773 this._batch_requests = this.get_config('batch_requests');
29774 if (this._batch_requests) {
29775 if (!_.localStorage.is_supported(true) || !USE_XHR) {
29776 this._batch_requests = false;
29777 console$1.log('Turning off Mixpanel request-queueing; needs XHR and localStorage support');
29778 _.each(this.get_batcher_configs(), function(batcher_config) {
29779 console$1.log('Clearing batch queue ' + batcher_config.queue_key);
29780 _.localStorage.remove(batcher_config.queue_key);
29781 });
29782 } else {
29783 this.init_batchers();
29784 if (sendBeacon && win.addEventListener) {
29785 // Before page closes or hides (user tabs away etc), attempt to flush any events
29786 // queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
29787 // events will not be removed from the persistent store; if the site is loaded again,
29788 // the events will be flushed again on startup and deduplicated on the Mixpanel server
29789 // side.
29790 // There is no reliable way to capture only page close events, so we lean on the
29791 // visibilitychange and pagehide events as recommended at
29792 // https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event#usage_notes.
29793 // These events fire when the user clicks away from the current page/tab, so will occur
29794 // more frequently than page unload, but are the only mechanism currently for capturing
29795 // this scenario somewhat reliably.
29796 var flush_on_unload = _.bind(function() {
29797 if (!this.request_batchers.events.stopped) {
29798 this.request_batchers.events.flush({unloading: true});
29799 }
29800 }, this);
29801 win.addEventListener('pagehide', function(ev) {
29802 if (ev['persisted']) {
29803 flush_on_unload();
29804 }
29805 });
29806 win.addEventListener('visibilitychange', function() {
29807 if (document$1['visibilityState'] === 'hidden') {
29808 flush_on_unload();
29809 }
29810 });
29811 }
29812 }
29813 }
29814
29815 this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config']);
29816 this.unpersisted_superprops = {};
29817 this._gdpr_init();
29818
29819 var uuid = _.UUID();
29820 if (!this.get_distinct_id()) {
29821 // There is no need to set the distinct id
29822 // or the device id if something was already stored
29823 // in the persitence
29824 this.register_once({
29825 'distinct_id': DEVICE_ID_PREFIX + uuid,
29826 '$device_id': uuid
29827 }, '');
29828 }
29829
29830 this.flags = new FeatureFlagManager({
29831 getFullApiRoute: _.bind(function() {
29832 return this.get_api_host('flags') + '/' + this.get_config('api_routes')['flags'];
29833 }, this),
29834 getConfigFunc: _.bind(this.get_config, this),
29835 setConfigFunc: _.bind(this.set_config, this),
29836 getPropertyFunc: _.bind(this.get_property, this),
29837 trackingFunc: _.bind(this.track, this)
29838 });
29839 this.flags.init();
29840 this['flags'] = this.flags;
29841
29842 this.autocapture = new Autocapture(this);
29843 this.autocapture.init();
29844
29845 this._init_tab_id();
29846 this._check_and_start_session_recording();
29847 };
29848
29849 /**
29850 * Assigns a unique UUID to this tab / window by leveraging sessionStorage.
29851 * This is primarily used for session recording, where data must be isolated to the current tab.
29852 */
29853 MixpanelLib.prototype._init_tab_id = function() {
29854 if (this.get_config('disable_persistence')) {
29855 console$1.log('Tab ID initialization skipped due to disable_persistence config');
29856 } else if (_.sessionStorage.is_supported()) {
29857 try {
29858 var key_suffix = this.get_config('name') + '_' + this.get_config('token');
29859 var tab_id_key = 'mp_tab_id_' + key_suffix;
29860
29861 // A flag is used to determine if sessionStorage is copied over and we need to generate a new tab ID.
29862 // This enforces a unique ID in the cases like duplicated tab, window.open(...)
29863 var should_generate_new_tab_id_key = 'mp_gen_new_tab_id_' + key_suffix;
29864 if (_.sessionStorage.get(should_generate_new_tab_id_key) || !_.sessionStorage.get(tab_id_key)) {
29865 _.sessionStorage.set(tab_id_key, '$tab-' + _.UUID());
29866 }
29867
29868 _.sessionStorage.set(should_generate_new_tab_id_key, '1');
29869 this.tab_id = _.sessionStorage.get(tab_id_key);
29870
29871 // 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,
29872 // but reliable in cases where the user remains in the tab e.g. a refresh or href navigation.
29873 // If the flag is absent, this indicates to the next SDK instance that we can reuse the stored tab_id.
29874 win.addEventListener('beforeunload', function () {
29875 _.sessionStorage.remove(should_generate_new_tab_id_key);
29876 });
29877 } catch(err) {
29878 this.report_error('Error initializing tab id', err);
29879 }
29880 } else {
29881 this.report_error('Session storage is not supported, cannot keep track of unique tab ID.');
29882 }
29883 };
29884
29885 MixpanelLib.prototype.get_tab_id = function () {
29886 return this.tab_id || null;
29887 };
29888
29889 MixpanelLib.prototype._should_load_recorder = function () {
29890 if (this.get_config('disable_persistence')) {
29891 console$1.log('Load recorder check skipped due to disable_persistence config');
29892 return Promise.resolve(false);
29893 }
29894
29895 var recording_registry_idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
29896 var tab_id = this.get_tab_id();
29897 return recording_registry_idb.init()
29898 .then(function () {
29899 return recording_registry_idb.getAll();
29900 })
29901 .then(function (recordings) {
29902 for (var i = 0; i < recordings.length; i++) {
29903 // if there are expired recordings in the registry, we should load the recorder to flush them
29904 // if there's a recording for this tab id, we should load the recorder to continue the recording
29905 if (isRecordingExpired(recordings[i]) || recordings[i]['tabId'] === tab_id) {
29906 return true;
29907 }
29908 }
29909 return false;
29910 })
29911 .catch(_.bind(function (err) {
29912 this.report_error('Error checking recording registry', err);
29913 }, this));
29914 };
29915
29916 MixpanelLib.prototype._check_and_start_session_recording = addOptOutCheckMixpanelLib(function(force_start) {
29917 if (!win['MutationObserver']) {
29918 console$1.critical('Browser does not support MutationObserver; skipping session recording');
29919 return;
29920 }
29921
29922 var loadRecorder = _.bind(function(startNewIfInactive) {
29923 var handleLoadedRecorder = _.bind(function() {
29924 this._recorder = this._recorder || new win['__mp_recorder'](this);
29925 this._recorder['resumeRecording'](startNewIfInactive);
29926 }, this);
29927
29928 if (_.isUndefined(win['__mp_recorder'])) {
29929 load_extra_bundle(this.get_config('recorder_src'), handleLoadedRecorder);
29930 } else {
29931 handleLoadedRecorder();
29932 }
29933 }, this);
29934
29935 /**
29936 * If the user is sampled or start_session_recording is called, we always load the recorder since it's guaranteed a recording should start.
29937 * 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.
29938 */
29939 var is_sampled = this.get_config('record_sessions_percent') > 0 && Math.random() * 100 <= this.get_config('record_sessions_percent');
29940 if (force_start || is_sampled) {
29941 loadRecorder(true);
29942 } else {
29943 this._should_load_recorder()
29944 .then(function (shouldLoad) {
29945 if (shouldLoad) {
29946 loadRecorder(false);
29947 }
29948 });
29949 }
29950 });
29951
29952 MixpanelLib.prototype.start_session_recording = function () {
29953 this._check_and_start_session_recording(true);
29954 };
29955
29956 MixpanelLib.prototype.stop_session_recording = function () {
29957 if (this._recorder) {
29958 return this._recorder['stopRecording']();
29959 }
29960 return Promise.resolve();
29961 };
29962
29963 MixpanelLib.prototype.pause_session_recording = function () {
29964 if (this._recorder) {
29965 return this._recorder['pauseRecording']();
29966 }
29967 return Promise.resolve();
29968 };
29969
29970 MixpanelLib.prototype.resume_session_recording = function () {
29971 if (this._recorder) {
29972 return this._recorder['resumeRecording']();
29973 }
29974 return Promise.resolve();
29975 };
29976
29977 MixpanelLib.prototype.is_recording_heatmap_data = function () {
29978 return this._get_session_replay_id() && this.get_config('record_heatmap_data');
29979 };
29980
29981 MixpanelLib.prototype.get_session_recording_properties = function () {
29982 var props = {};
29983 var replay_id = this._get_session_replay_id();
29984 if (replay_id) {
29985 props['$mp_replay_id'] = replay_id;
29986 }
29987 return props;
29988 };
29989
29990 MixpanelLib.prototype.get_session_replay_url = function () {
29991 var replay_url = null;
29992 var replay_id = this._get_session_replay_id();
29993 if (replay_id) {
29994 var query_params = _.HTTPBuildQuery({
29995 'replay_id': replay_id,
29996 'distinct_id': this.get_distinct_id(),
29997 'token': this.get_config('token')
29998 });
29999 replay_url = 'https://mixpanel.com/projects/replay-redirect?' + query_params;
30000 }
30001 return replay_url;
30002 };
30003
30004 MixpanelLib.prototype._get_session_replay_id = function () {
30005 var replay_id = null;
30006 if (this._recorder) {
30007 replay_id = this._recorder['replayId'];
30008 }
30009 return replay_id || null;
30010 };
30011
30012 // "private" public method to reach into the recorder in test cases
30013 MixpanelLib.prototype.__get_recorder = function () {
30014 return this._recorder;
30015 };
30016
30017 // Private methods
30018
30019 MixpanelLib.prototype._loaded = function() {
30020 this.get_config('loaded')(this);
30021 this._set_default_superprops();
30022 this['people'].set_once(this['persistence'].get_referrer_info());
30023
30024 // `store_google` is now deprecated and previously stored UTM parameters are cleared
30025 // from persistence by default.
30026 if (this.get_config('store_google') && this.get_config('stop_utm_persistence')) {
30027 var utm_params = _.info.campaignParams(null);
30028 _.each(utm_params, function(_utm_value, utm_key) {
30029 // We need to unregister persisted UTM parameters so old values
30030 // are not mixed with the new UTM parameters
30031 this.unregister(utm_key);
30032 }.bind(this));
30033 }
30034 };
30035
30036 // update persistence with info on referrer, UTM params, etc
30037 MixpanelLib.prototype._set_default_superprops = function() {
30038 this['persistence'].update_search_keyword(document$1.referrer);
30039 // Registering super properties for UTM persistence by 'store_google' is deprecated.
30040 if (this.get_config('store_google') && !this.get_config('stop_utm_persistence')) {
30041 this.register(_.info.campaignParams());
30042 }
30043 if (this.get_config('save_referrer')) {
30044 this['persistence'].update_referrer_info(document$1.referrer);
30045 }
30046 };
30047
30048 MixpanelLib.prototype._dom_loaded = function() {
30049 _.each(this.__dom_loaded_queue, function(item) {
30050 this._track_dom.apply(this, item);
30051 }, this);
30052
30053 if (!this.has_opted_out_tracking()) {
30054 _.each(this.__request_queue, function(item) {
30055 this._send_request.apply(this, item);
30056 }, this);
30057 }
30058
30059 delete this.__dom_loaded_queue;
30060 delete this.__request_queue;
30061 };
30062
30063 MixpanelLib.prototype._track_dom = function(DomClass, args) {
30064 if (this.get_config('img')) {
30065 this.report_error('You can\'t use DOM tracking functions with img = true.');
30066 return false;
30067 }
30068
30069 if (!DOM_LOADED) {
30070 this.__dom_loaded_queue.push([DomClass, args]);
30071 return false;
30072 }
30073
30074 var dt = new DomClass().init(this);
30075 return dt.track.apply(dt, args);
30076 };
30077
30078 /**
30079 * _prepare_callback() should be called by callers of _send_request for use
30080 * as the callback argument.
30081 *
30082 * If there is no callback, this returns null.
30083 * If we are going to make XHR/XDR requests, this returns a function.
30084 * If we are going to use script tags, this returns a string to use as the
30085 * callback GET param.
30086 */
30087 MixpanelLib.prototype._prepare_callback = function(callback, data) {
30088 if (_.isUndefined(callback)) {
30089 return null;
30090 }
30091
30092 if (USE_XHR) {
30093 var callback_function = function(response) {
30094 callback(response, data);
30095 };
30096 return callback_function;
30097 } else {
30098 // if the user gives us a callback, we store as a random
30099 // property on this instances jsc function and update our
30100 // callback string to reflect that.
30101 var jsc = this['_jsc'];
30102 var randomized_cb = '' + Math.floor(Math.random() * 100000000);
30103 var callback_string = this.get_config('callback_fn') + '[' + randomized_cb + ']';
30104 jsc[randomized_cb] = function(response) {
30105 delete jsc[randomized_cb];
30106 callback(response, data);
30107 };
30108 return callback_string;
30109 }
30110 };
30111
30112 MixpanelLib.prototype._send_request = function(url, data, options, callback) {
30113 var succeeded = true;
30114
30115 if (ENQUEUE_REQUESTS) {
30116 this.__request_queue.push(arguments);
30117 return succeeded;
30118 }
30119
30120 var DEFAULT_OPTIONS = {
30121 method: this.get_config('api_method'),
30122 transport: this.get_config('api_transport'),
30123 verbose: this.get_config('verbose')
30124 };
30125 var body_data = null;
30126
30127 if (!callback && (_.isFunction(options) || typeof options === 'string')) {
30128 callback = options;
30129 options = null;
30130 }
30131 options = _.extend(DEFAULT_OPTIONS, options || {});
30132 if (!USE_XHR) {
30133 options.method = 'GET';
30134 }
30135 var use_post = options.method === 'POST';
30136 var use_sendBeacon = sendBeacon && use_post && options.transport.toLowerCase() === 'sendbeacon';
30137
30138 // needed to correctly format responses
30139 var verbose_mode = options.verbose;
30140 if (data['verbose']) { verbose_mode = true; }
30141
30142 if (this.get_config('test')) { data['test'] = 1; }
30143 if (verbose_mode) { data['verbose'] = 1; }
30144 if (this.get_config('img')) { data['img'] = 1; }
30145 if (!USE_XHR) {
30146 if (callback) {
30147 data['callback'] = callback;
30148 } else if (verbose_mode || this.get_config('test')) {
30149 // Verbose output (from verbose mode, or an error in test mode) is a json blob,
30150 // which by itself is not valid javascript. Without a callback, this verbose output will
30151 // cause an error when returned via jsonp, so we force a no-op callback param.
30152 // See the ECMA script spec: http://www.ecma-international.org/ecma-262/5.1/#sec-12.4
30153 data['callback'] = '(function(){})';
30154 }
30155 }
30156
30157 data['ip'] = this.get_config('ip')?1:0;
30158 data['_'] = new Date().getTime().toString();
30159
30160 if (use_post) {
30161 body_data = 'data=' + encodeURIComponent(data['data']);
30162 delete data['data'];
30163 }
30164
30165 _.extend(data, this.get_config('api_extra_query_params'));
30166
30167 url += '?' + _.HTTPBuildQuery(data);
30168
30169 var lib = this;
30170 if ('img' in data) {
30171 var img = document$1.createElement('img');
30172 img.src = url;
30173 document$1.body.appendChild(img);
30174 } else if (use_sendBeacon) {
30175 try {
30176 succeeded = sendBeacon(url, body_data);
30177 } catch (e) {
30178 lib.report_error(e);
30179 succeeded = false;
30180 }
30181 try {
30182 if (callback) {
30183 callback(succeeded ? 1 : 0);
30184 }
30185 } catch (e) {
30186 lib.report_error(e);
30187 }
30188 } else if (USE_XHR) {
30189 try {
30190 var req = new XMLHttpRequest();
30191 req.open(options.method, url, true);
30192
30193 var headers = this.get_config('xhr_headers');
30194 if (use_post) {
30195 headers['Content-Type'] = 'application/x-www-form-urlencoded';
30196 }
30197 _.each(headers, function(headerValue, headerName) {
30198 req.setRequestHeader(headerName, headerValue);
30199 });
30200
30201 if (options.timeout_ms && typeof req.timeout !== 'undefined') {
30202 req.timeout = options.timeout_ms;
30203 var start_time = new Date().getTime();
30204 }
30205
30206 // send the mp_optout cookie
30207 // withCredentials cannot be modified until after calling .open on Android and Mobile Safari
30208 req.withCredentials = true;
30209 req.onreadystatechange = function () {
30210 if (req.readyState === 4) { // XMLHttpRequest.DONE == 4, except in safari 4
30211 if (req.status === 200) {
30212 if (callback) {
30213 if (verbose_mode) {
30214 var response;
30215 try {
30216 response = _.JSONDecode(req.responseText);
30217 } catch (e) {
30218 lib.report_error(e);
30219 if (options.ignore_json_errors) {
30220 response = req.responseText;
30221 } else {
30222 return;
30223 }
30224 }
30225 callback(response);
30226 } else {
30227 callback(Number(req.responseText));
30228 }
30229 }
30230 } else {
30231 var error;
30232 if (
30233 req.timeout &&
30234 !req.status &&
30235 new Date().getTime() - start_time >= req.timeout
30236 ) {
30237 error = 'timeout';
30238 } else {
30239 error = 'Bad HTTP status: ' + req.status + ' ' + req.statusText;
30240 }
30241 lib.report_error(error);
30242 if (callback) {
30243 if (verbose_mode) {
30244 var response_headers = req['responseHeaders'] || {};
30245 callback({status: 0, httpStatusCode: req['status'], error: error, retryAfter: response_headers['Retry-After']});
30246 } else {
30247 callback(0);
30248 }
30249 }
30250 }
30251 }
30252 };
30253 req.send(body_data);
30254 } catch (e) {
30255 lib.report_error(e);
30256 succeeded = false;
30257 }
30258 } else {
30259 var script = document$1.createElement('script');
30260 script.type = 'text/javascript';
30261 script.async = true;
30262 script.defer = true;
30263 script.src = url;
30264 var s = document$1.getElementsByTagName('script')[0];
30265 s.parentNode.insertBefore(script, s);
30266 }
30267
30268 return succeeded;
30269 };
30270
30271 /**
30272 * _execute_array() deals with processing any mixpanel function
30273 * calls that were called before the Mixpanel library were loaded
30274 * (and are thus stored in an array so they can be called later)
30275 *
30276 * Note: we fire off all the mixpanel function calls && user defined
30277 * functions BEFORE we fire off mixpanel tracking calls. This is so
30278 * identify/register/set_config calls can properly modify early
30279 * tracking calls.
30280 *
30281 * @param {Array} array
30282 */
30283 MixpanelLib.prototype._execute_array = function(array) {
30284 var fn_name, alias_calls = [], other_calls = [], tracking_calls = [];
30285 _.each(array, function(item) {
30286 if (item) {
30287 fn_name = item[0];
30288 if (_.isArray(fn_name)) {
30289 tracking_calls.push(item); // chained call e.g. mixpanel.get_group().set()
30290 } else if (typeof(item) === 'function') {
30291 item.call(this);
30292 } else if (_.isArray(item) && fn_name === 'alias') {
30293 alias_calls.push(item);
30294 } else if (_.isArray(item) && fn_name.indexOf('track') !== -1 && typeof(this[fn_name]) === 'function') {
30295 tracking_calls.push(item);
30296 } else {
30297 other_calls.push(item);
30298 }
30299 }
30300 }, this);
30301
30302 var execute = function(calls, context) {
30303 _.each(calls, function(item) {
30304 if (_.isArray(item[0])) {
30305 // chained call
30306 var caller = context;
30307 _.each(item, function(call) {
30308 caller = caller[call[0]].apply(caller, call.slice(1));
30309 });
30310 } else {
30311 this[item[0]].apply(this, item.slice(1));
30312 }
30313 }, context);
30314 };
30315
30316 execute(alias_calls, this);
30317 execute(other_calls, this);
30318 execute(tracking_calls, this);
30319 };
30320
30321 // request queueing utils
30322
30323 MixpanelLib.prototype.are_batchers_initialized = function() {
30324 return !!this.request_batchers.events;
30325 };
30326
30327 MixpanelLib.prototype.get_batcher_configs = function() {
30328 var queue_prefix = '__mpq_' + this.get_config('token');
30329 this._batcher_configs = this._batcher_configs || {
30330 events: {type: 'events', api_name: 'track', queue_key: queue_prefix + '_ev'},
30331 people: {type: 'people', api_name: 'engage', queue_key: queue_prefix + '_pp'},
30332 groups: {type: 'groups', api_name: 'groups', queue_key: queue_prefix + '_gr'}
30333 };
30334 return this._batcher_configs;
30335 };
30336
30337 MixpanelLib.prototype.init_batchers = function() {
30338 if (!this.are_batchers_initialized()) {
30339 var batcher_for = _.bind(function(attrs) {
30340 return new RequestBatcher(
30341 attrs.queue_key,
30342 {
30343 libConfig: this['config'],
30344 errorReporter: this.get_config('error_reporter'),
30345 sendRequestFunc: _.bind(function(data, options, cb) {
30346 var api_routes = this.get_config('api_routes');
30347 this._send_request(
30348 this.get_api_host(attrs.api_name) + '/' + api_routes[attrs.api_name],
30349 this._encode_data_for_request(data),
30350 options,
30351 this._prepare_callback(cb, data)
30352 );
30353 }, this),
30354 beforeSendHook: _.bind(function(item) {
30355 return this._run_hook('before_send_' + attrs.type, item);
30356 }, this),
30357 stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
30358 usePersistence: true,
30359 }
30360 );
30361 }, this);
30362 var batcher_configs = this.get_batcher_configs();
30363 this.request_batchers = {
30364 events: batcher_for(batcher_configs.events),
30365 people: batcher_for(batcher_configs.people),
30366 groups: batcher_for(batcher_configs.groups)
30367 };
30368 }
30369 if (this.get_config('batch_autostart')) {
30370 this.start_batch_senders();
30371 }
30372 };
30373
30374 MixpanelLib.prototype.start_batch_senders = function() {
30375 this._batchers_were_started = true;
30376 if (this.are_batchers_initialized()) {
30377 this._batch_requests = true;
30378 _.each(this.request_batchers, function(batcher) {
30379 batcher.start();
30380 });
30381 }
30382 };
30383
30384 MixpanelLib.prototype.stop_batch_senders = function() {
30385 this._batch_requests = false;
30386 _.each(this.request_batchers, function(batcher) {
30387 batcher.stop();
30388 batcher.clear();
30389 });
30390 };
30391
30392 /**
30393 * push() keeps the standard async-array-push
30394 * behavior around after the lib is loaded.
30395 * This is only useful for external integrations that
30396 * do not wish to rely on our convenience methods
30397 * (created in the snippet).
30398 *
30399 * ### Usage:
30400 * mixpanel.push(['register', { a: 'b' }]);
30401 *
30402 * @param {Array} item A [function_name, args...] array to be executed
30403 */
30404 MixpanelLib.prototype.push = function(item) {
30405 this._execute_array([item]);
30406 };
30407
30408 /**
30409 * Disable events on the Mixpanel object. If passed no arguments,
30410 * this function disables tracking of any event. If passed an
30411 * array of event names, those events will be disabled, but other
30412 * events will continue to be tracked.
30413 *
30414 * Note: this function does not stop other mixpanel functions from
30415 * firing, such as register() or people.set().
30416 *
30417 * @param {Array} [events] An array of event names to disable
30418 */
30419 MixpanelLib.prototype.disable = function(events) {
30420 if (typeof(events) === 'undefined') {
30421 this._flags.disable_all_events = true;
30422 } else {
30423 this.__disabled_events = this.__disabled_events.concat(events);
30424 }
30425 };
30426
30427 MixpanelLib.prototype._encode_data_for_request = function(data) {
30428 var encoded_data = JSONStringify(data);
30429 if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
30430 encoded_data = _.base64Encode(encoded_data);
30431 }
30432 return {'data': encoded_data};
30433 };
30434
30435 // internal method for handling track vs batch-enqueue logic
30436 MixpanelLib.prototype._track_or_batch = function(options, callback) {
30437 var truncated_data = _.truncate(options.data, 255);
30438 var endpoint = options.endpoint;
30439 var batcher = options.batcher;
30440 var should_send_immediately = options.should_send_immediately;
30441 var send_request_options = options.send_request_options || {};
30442 callback = callback || NOOP_FUNC;
30443
30444 var request_enqueued_or_initiated = true;
30445 var send_request_immediately = _.bind(function() {
30446 if (!send_request_options.skip_hooks) {
30447 truncated_data = this._run_hook('before_send_' + options.type, truncated_data);
30448 }
30449 if (truncated_data) {
30450 console$1.log('MIXPANEL REQUEST:');
30451 console$1.log(truncated_data);
30452 return this._send_request(
30453 endpoint,
30454 this._encode_data_for_request(truncated_data),
30455 send_request_options,
30456 this._prepare_callback(callback, truncated_data)
30457 );
30458 } else {
30459 return null;
30460 }
30461 }, this);
30462
30463 if (this._batch_requests && !should_send_immediately) {
30464 batcher.enqueue(truncated_data).then(function(succeeded) {
30465 if (succeeded) {
30466 callback(1, truncated_data);
30467 } else {
30468 send_request_immediately();
30469 }
30470 });
30471 } else {
30472 request_enqueued_or_initiated = send_request_immediately();
30473 }
30474
30475 return request_enqueued_or_initiated && truncated_data;
30476 };
30477
30478 /**
30479 * Track an event. This is the most important and
30480 * frequently used Mixpanel function.
30481 *
30482 * ### Usage:
30483 *
30484 * // track an event named 'Registered'
30485 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
30486 *
30487 * // track an event using navigator.sendBeacon
30488 * mixpanel.track('Left page', {'duration_seconds': 35}, {transport: 'sendBeacon'});
30489 *
30490 * To track link clicks or form submissions, see track_links() or track_forms().
30491 *
30492 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
30493 * @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.
30494 * @param {Object} [options] Optional configuration for this track request.
30495 * @param {String} [options.transport] Transport method for network request ('xhr' or 'sendBeacon').
30496 * @param {Boolean} [options.send_immediately] Whether to bypass batching/queueing and send track request immediately.
30497 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
30498 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
30499 * with the tracking payload sent to the API server is returned; otherwise false.
30500 */
30501 MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
30502 if (!callback && typeof options === 'function') {
30503 callback = options;
30504 options = null;
30505 }
30506 options = options || {};
30507 var transport = options['transport']; // external API, don't minify 'transport' prop
30508 if (transport) {
30509 options.transport = transport; // 'transport' prop name can be minified internally
30510 }
30511 var should_send_immediately = options['send_immediately'];
30512 if (typeof callback !== 'function') {
30513 callback = NOOP_FUNC;
30514 }
30515
30516 if (_.isUndefined(event_name)) {
30517 this.report_error('No event name provided to mixpanel.track');
30518 return;
30519 }
30520
30521 if (this._event_is_disabled(event_name)) {
30522 callback(0);
30523 return;
30524 }
30525
30526 // set defaults
30527 properties = _.extend({}, properties);
30528 properties['token'] = this.get_config('token');
30529
30530 // set $duration if time_event was previously called for this event
30531 var start_timestamp = this['persistence'].remove_event_timer(event_name);
30532 if (!_.isUndefined(start_timestamp)) {
30533 var duration_in_ms = new Date().getTime() - start_timestamp;
30534 properties['$duration'] = parseFloat((duration_in_ms / 1000).toFixed(3));
30535 }
30536
30537 this._set_default_superprops();
30538
30539 var marketing_properties = this.get_config('track_marketing')
30540 ? _.info.marketingParams()
30541 : {};
30542
30543 // note: extend writes to the first object, so lets make sure we
30544 // don't write to the persistence properties object and info
30545 // properties object by passing in a new object
30546
30547 // update properties with pageview info and super-properties
30548 properties = _.extend(
30549 {},
30550 _.info.properties({'mp_loader': this.get_config('mp_loader')}),
30551 marketing_properties,
30552 this['persistence'].properties(),
30553 this.unpersisted_superprops,
30554 this.get_session_recording_properties(),
30555 properties
30556 );
30557
30558 var property_blacklist = this.get_config('property_blacklist');
30559 if (_.isArray(property_blacklist)) {
30560 _.each(property_blacklist, function(blacklisted_prop) {
30561 delete properties[blacklisted_prop];
30562 });
30563 } else {
30564 this.report_error('Invalid value for property_blacklist config: ' + property_blacklist);
30565 }
30566
30567 var data = {
30568 'event': event_name,
30569 'properties': properties
30570 };
30571 var ret = this._track_or_batch({
30572 type: 'events',
30573 data: data,
30574 endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
30575 batcher: this.request_batchers.events,
30576 should_send_immediately: should_send_immediately,
30577 send_request_options: options
30578 }, callback);
30579
30580 return ret;
30581 });
30582
30583 /**
30584 * Register the current user into one/many groups.
30585 *
30586 * ### Usage:
30587 *
30588 * mixpanel.set_group('company', ['mixpanel', 'google']) // an array of IDs
30589 * mixpanel.set_group('company', 'mixpanel')
30590 * mixpanel.set_group('company', 128746312)
30591 *
30592 * @param {String} group_key Group key
30593 * @param {Array|String|Number} group_ids An array of group IDs, or a singular group ID
30594 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30595 *
30596 */
30597 MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key, group_ids, callback) {
30598 if (!_.isArray(group_ids)) {
30599 group_ids = [group_ids];
30600 }
30601 var prop = {};
30602 prop[group_key] = group_ids;
30603 this.register(prop);
30604 return this['people'].set(group_key, group_ids, callback);
30605 });
30606
30607 /**
30608 * Add a new group for this user.
30609 *
30610 * ### Usage:
30611 *
30612 * mixpanel.add_group('company', 'mixpanel')
30613 *
30614 * @param {String} group_key Group key
30615 * @param {*} group_id A valid Mixpanel property type
30616 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30617 */
30618 MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
30619 var old_values = this.get_property(group_key);
30620 var prop = {};
30621 if (old_values === undefined) {
30622 prop[group_key] = [group_id];
30623 this.register(prop);
30624 } else {
30625 if (old_values.indexOf(group_id) === -1) {
30626 old_values.push(group_id);
30627 prop[group_key] = old_values;
30628 this.register(prop);
30629 }
30630 }
30631 return this['people'].union(group_key, group_id, callback);
30632 });
30633
30634 /**
30635 * Remove a group from this user.
30636 *
30637 * ### Usage:
30638 *
30639 * mixpanel.remove_group('company', 'mixpanel')
30640 *
30641 * @param {String} group_key Group key
30642 * @param {*} group_id A valid Mixpanel property type
30643 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30644 */
30645 MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
30646 var old_value = this.get_property(group_key);
30647 // if the value doesn't exist, the persistent store is unchanged
30648 if (old_value !== undefined) {
30649 var idx = old_value.indexOf(group_id);
30650 if (idx > -1) {
30651 old_value.splice(idx, 1);
30652 this.register({group_key: old_value});
30653 }
30654 if (old_value.length === 0) {
30655 this.unregister(group_key);
30656 }
30657 }
30658 return this['people'].remove(group_key, group_id, callback);
30659 });
30660
30661 /**
30662 * Track an event with specific groups.
30663 *
30664 * ### Usage:
30665 *
30666 * mixpanel.track_with_groups('purchase', {'product': 'iphone'}, {'University': ['UCB', 'UCLA']})
30667 *
30668 * @param {String} event_name The name of the event (see `mixpanel.track()`)
30669 * @param {Object=} properties A set of properties to include with the event you're sending (see `mixpanel.track()`)
30670 * @param {Object=} groups An object mapping group name keys to one or more values
30671 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
30672 */
30673 MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(event_name, properties, groups, callback) {
30674 var tracking_props = _.extend({}, properties || {});
30675 _.each(groups, function(v, k) {
30676 if (v !== null && v !== undefined) {
30677 tracking_props[k] = v;
30678 }
30679 });
30680 return this.track(event_name, tracking_props, callback);
30681 });
30682
30683 MixpanelLib.prototype._create_map_key = function (group_key, group_id) {
30684 return group_key + '_' + JSON.stringify(group_id);
30685 };
30686
30687 MixpanelLib.prototype._remove_group_from_cache = function (group_key, group_id) {
30688 delete this._cached_groups[this._create_map_key(group_key, group_id)];
30689 };
30690
30691 /**
30692 * Look up reference to a Mixpanel group
30693 *
30694 * ### Usage:
30695 *
30696 * mixpanel.get_group(group_key, group_id)
30697 *
30698 * @param {String} group_key Group key
30699 * @param {Object} group_id A valid Mixpanel property type
30700 * @returns {Object} A MixpanelGroup identifier
30701 */
30702 MixpanelLib.prototype.get_group = function (group_key, group_id) {
30703 var map_key = this._create_map_key(group_key, group_id);
30704 var group = this._cached_groups[map_key];
30705 if (group === undefined || group._group_key !== group_key || group._group_id !== group_id) {
30706 group = new MixpanelGroup();
30707 group._init(this, group_key, group_id);
30708 this._cached_groups[map_key] = group;
30709 }
30710 return group;
30711 };
30712
30713 /**
30714 * Track a default Mixpanel page view event, which includes extra default event properties to
30715 * improve page view data.
30716 *
30717 * ### Usage:
30718 *
30719 * // track a default $mp_web_page_view event
30720 * mixpanel.track_pageview();
30721 *
30722 * // track a page view event with additional event properties
30723 * mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
30724 *
30725 * // example approach to track page views on different page types as event properties
30726 * mixpanel.track_pageview({'page': 'pricing'});
30727 * mixpanel.track_pageview({'page': 'homepage'});
30728 *
30729 * // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
30730 * // individual pages on the same site or product. Use cases for custom event_name may be page
30731 * // views on different products or internal applications that are considered completely separate
30732 * mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
30733 *
30734 * ### Notes:
30735 *
30736 * The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
30737 * may be turned on for tracking page loads automatically.
30738 *
30739 * // track only page loads
30740 * mixpanel.init(PROJECT_TOKEN, {track_pageview: true});
30741 *
30742 * // track when the URL changes in any manner
30743 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'full-url'});
30744 *
30745 * // track when the URL changes, ignoring any changes in the hash part
30746 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path-and-query-string'});
30747 *
30748 * // track when the path changes, ignoring any query parameter or hash changes
30749 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path'});
30750 *
30751 * @param {Object} [properties] An optional set of additional properties to send with the page view event
30752 * @param {Object} [options] Page view tracking options
30753 * @param {String} [options.event_name] - Alternate name for the tracking event
30754 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
30755 * with the tracking payload sent to the API server is returned; otherwise false.
30756 */
30757 MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
30758 if (typeof properties !== 'object') {
30759 properties = {};
30760 }
30761 options = options || {};
30762 var event_name = options['event_name'] || '$mp_web_page_view';
30763
30764 var default_page_properties = _.extend(
30765 _.info.mpPageViewProperties(),
30766 _.info.campaignParams(),
30767 _.info.clickParams()
30768 );
30769
30770 var event_properties = _.extend(
30771 {},
30772 default_page_properties,
30773 properties
30774 );
30775
30776 return this.track(event_name, event_properties);
30777 });
30778
30779 /**
30780 * Track clicks on a set of document elements. Selector must be a
30781 * valid query. Elements must exist on the page at the time track_links is called.
30782 *
30783 * ### Usage:
30784 *
30785 * // track click for link id #nav
30786 * mixpanel.track_links('#nav', 'Clicked Nav Link');
30787 *
30788 * ### Notes:
30789 *
30790 * This function will wait up to 300 ms for the Mixpanel
30791 * servers to respond. If they have not responded by that time
30792 * it will head to the link without ensuring that your event
30793 * has been tracked. To configure this timeout please see the
30794 * set_config() documentation below.
30795 *
30796 * If you pass a function in as the properties argument, the
30797 * function will receive the DOMElement that triggered the
30798 * event as an argument. You are expected to return an object
30799 * from the function; any properties defined on this object
30800 * will be sent to mixpanel as event properties.
30801 *
30802 * @type {Function}
30803 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
30804 * @param {String} event_name The name of the event to track
30805 * @param {Object|Function} [properties] A properties object or function that returns a dictionary of properties when passed a DOMElement
30806 */
30807 MixpanelLib.prototype.track_links = function() {
30808 return this._track_dom.call(this, LinkTracker, arguments);
30809 };
30810
30811 /**
30812 * Track form submissions. Selector must be a valid query.
30813 *
30814 * ### Usage:
30815 *
30816 * // track submission for form id 'register'
30817 * mixpanel.track_forms('#register', 'Created Account');
30818 *
30819 * ### Notes:
30820 *
30821 * This function will wait up to 300 ms for the mixpanel
30822 * servers to respond, if they have not responded by that time
30823 * it will head to the link without ensuring that your event
30824 * has been tracked. To configure this timeout please see the
30825 * set_config() documentation below.
30826 *
30827 * If you pass a function in as the properties argument, the
30828 * function will receive the DOMElement that triggered the
30829 * event as an argument. You are expected to return an object
30830 * from the function; any properties defined on this object
30831 * will be sent to mixpanel as event properties.
30832 *
30833 * @type {Function}
30834 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
30835 * @param {String} event_name The name of the event to track
30836 * @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
30837 */
30838 MixpanelLib.prototype.track_forms = function() {
30839 return this._track_dom.call(this, FormTracker, arguments);
30840 };
30841
30842 /**
30843 * Time an event by including the time between this call and a
30844 * later 'track' call for the same event in the properties sent
30845 * with the event.
30846 *
30847 * ### Usage:
30848 *
30849 * // time an event named 'Registered'
30850 * mixpanel.time_event('Registered');
30851 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
30852 *
30853 * When called for a particular event name, the next track call for that event
30854 * name will include the elapsed time between the 'time_event' and 'track'
30855 * calls. This value is stored as seconds in the '$duration' property.
30856 *
30857 * @param {String} event_name The name of the event.
30858 */
30859 MixpanelLib.prototype.time_event = function(event_name) {
30860 if (_.isUndefined(event_name)) {
30861 this.report_error('No event name provided to mixpanel.time_event');
30862 return;
30863 }
30864
30865 if (this._event_is_disabled(event_name)) {
30866 return;
30867 }
30868
30869 this['persistence'].set_event_timer(event_name, new Date().getTime());
30870 };
30871
30872 var REGISTER_DEFAULTS = {
30873 'persistent': true
30874 };
30875 /**
30876 * Helper to parse options param for register methods, maintaining
30877 * legacy support for plain "days" param instead of options object
30878 * @param {Number|Object} [days_or_options] 'days' option (Number), or Options object for register methods
30879 * @returns {Object} options object
30880 */
30881 var options_for_register = function(days_or_options) {
30882 var options;
30883 if (_.isObject(days_or_options)) {
30884 options = days_or_options;
30885 } else if (!_.isUndefined(days_or_options)) {
30886 options = {'days': days_or_options};
30887 } else {
30888 options = {};
30889 }
30890 return _.extend({}, REGISTER_DEFAULTS, options);
30891 };
30892
30893 /**
30894 * Register a set of super properties, which are included with all
30895 * events. This will overwrite previous super property values.
30896 *
30897 * ### Usage:
30898 *
30899 * // register 'Gender' as a super property
30900 * mixpanel.register({'Gender': 'Female'});
30901 *
30902 * // register several super properties when a user signs up
30903 * mixpanel.register({
30904 * 'Email': 'jdoe@example.com',
30905 * 'Account Type': 'Free'
30906 * });
30907 *
30908 * // register only for the current pageload
30909 * mixpanel.register({'Name': 'Pat'}, {persistent: false});
30910 *
30911 * @param {Object} properties An associative array of properties to store about the user
30912 * @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)
30913 * @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)
30914 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
30915 */
30916 MixpanelLib.prototype.register = function(props, days_or_options) {
30917 var options = options_for_register(days_or_options);
30918 if (options['persistent']) {
30919 this['persistence'].register(props, options['days']);
30920 } else {
30921 _.extend(this.unpersisted_superprops, props);
30922 }
30923 };
30924
30925 /**
30926 * Register a set of super properties only once. This will not
30927 * overwrite previous super property values, unlike register().
30928 *
30929 * ### Usage:
30930 *
30931 * // register a super property for the first time only
30932 * mixpanel.register_once({
30933 * 'First Login Date': new Date().toISOString()
30934 * });
30935 *
30936 * // register once, only for the current pageload
30937 * mixpanel.register_once({
30938 * 'First interaction time': new Date().toISOString()
30939 * }, 'None', {persistent: false});
30940 *
30941 * ### Notes:
30942 *
30943 * If default_value is specified, current super properties
30944 * with that value will be overwritten.
30945 *
30946 * @param {Object} properties An associative array of properties to store about the user
30947 * @param {*} [default_value] Value to override if already set in super properties (ex: 'False') Default: 'None'
30948 * @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)
30949 * @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)
30950 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
30951 */
30952 MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
30953 var options = options_for_register(days_or_options);
30954 if (options['persistent']) {
30955 this['persistence'].register_once(props, default_value, options['days']);
30956 } else {
30957 if (typeof(default_value) === 'undefined') {
30958 default_value = 'None';
30959 }
30960 _.each(props, function(val, prop) {
30961 if (!this.unpersisted_superprops.hasOwnProperty(prop) || this.unpersisted_superprops[prop] === default_value) {
30962 this.unpersisted_superprops[prop] = val;
30963 }
30964 }, this);
30965 }
30966 };
30967
30968 /**
30969 * Delete a super property stored with the current user.
30970 *
30971 * @param {String} property The name of the super property to remove
30972 * @param {Object} [options]
30973 * @param {boolean} [options.persistent=true] - whether to look in persistent storage (cookie/localStorage)
30974 */
30975 MixpanelLib.prototype.unregister = function(property, options) {
30976 options = options_for_register(options);
30977 if (options['persistent']) {
30978 this['persistence'].unregister(property);
30979 } else {
30980 delete this.unpersisted_superprops[property];
30981 }
30982 };
30983
30984 MixpanelLib.prototype._register_single = function(prop, value) {
30985 var props = {};
30986 props[prop] = value;
30987 this.register(props);
30988 };
30989
30990 /**
30991 * Identify a user with a unique ID to track user activity across
30992 * devices, tie a user to their events, and create a user profile.
30993 * If you never call this method, unique visitors are tracked using
30994 * a UUID generated the first time they visit the site.
30995 *
30996 * Call identify when you know the identity of the current user,
30997 * typically after login or signup. We recommend against using
30998 * identify for anonymous visitors to your site.
30999 *
31000 * ### Notes:
31001 * If your project has
31002 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31003 * enabled, the identify method will connect pre- and
31004 * post-authentication events when appropriate.
31005 *
31006 * If your project does not have ID Merge enabled, identify will
31007 * change the user's local distinct_id to the unique ID you pass.
31008 * Events tracked prior to authentication will not be connected
31009 * to the same user identity. If ID Merge is disabled, alias can
31010 * be used to connect pre- and post-registration events.
31011 *
31012 * @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.
31013 */
31014 MixpanelLib.prototype.identify = function(
31015 new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
31016 ) {
31017 // Optional Parameters
31018 // _set_callback:function A callback to be run if and when the People set queue is flushed
31019 // _add_callback:function A callback to be run if and when the People add queue is flushed
31020 // _append_callback:function A callback to be run if and when the People append queue is flushed
31021 // _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
31022 // _union_callback:function A callback to be run if and when the People union queue is flushed
31023 // _unset_callback:function A callback to be run if and when the People unset queue is flushed
31024
31025 var previous_distinct_id = this.get_distinct_id();
31026 if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
31027 // we allow the following condition if previous distinct_id is same as new_distinct_id
31028 // so that you can force flush people updates for anonymous profiles.
31029 if (typeof new_distinct_id === 'string' && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
31030 this.report_error('distinct_id cannot have $device: prefix');
31031 return -1;
31032 }
31033 this.register({'$user_id': new_distinct_id});
31034 }
31035
31036 if (!this.get_property('$device_id')) {
31037 // The persisted distinct id might not actually be a device id at all
31038 // it might be a distinct id of the user from before
31039 var device_id = previous_distinct_id;
31040 this.register_once({
31041 '$had_persisted_distinct_id': true,
31042 '$device_id': device_id
31043 }, '');
31044 }
31045
31046 // identify only changes the distinct id if it doesn't match either the existing or the alias;
31047 // if it's new, blow away the alias as well.
31048 if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
31049 this.unregister(ALIAS_ID_KEY);
31050 this.register({'distinct_id': new_distinct_id});
31051 }
31052 this._flags.identify_called = true;
31053 // Flush any queued up people requests
31054 this['people']._flush(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback);
31055
31056 // send an $identify event any time the distinct_id is changing - logic on the server
31057 // will determine whether or not to do anything with it.
31058 if (new_distinct_id !== previous_distinct_id) {
31059 this.track('$identify', {
31060 'distinct_id': new_distinct_id,
31061 '$anon_distinct_id': previous_distinct_id
31062 }, {skip_hooks: true});
31063 }
31064
31065 // check feature flags again if distinct id has changed
31066 if (new_distinct_id !== previous_distinct_id) {
31067 this.flags.fetchFlags();
31068 }
31069 };
31070
31071 /**
31072 * Clears super properties and generates a new random distinct_id for this instance.
31073 * Useful for clearing data when a user logs out.
31074 */
31075 MixpanelLib.prototype.reset = function() {
31076 this.stop_session_recording();
31077 this['persistence'].clear();
31078 this._flags.identify_called = false;
31079 var uuid = _.UUID();
31080 this.register_once({
31081 'distinct_id': DEVICE_ID_PREFIX + uuid,
31082 '$device_id': uuid
31083 }, '');
31084 this._check_and_start_session_recording();
31085 };
31086
31087 /**
31088 * Returns the current distinct id of the user. This is either the id automatically
31089 * generated by the library or the id that has been passed by a call to identify().
31090 *
31091 * ### Notes:
31092 *
31093 * get_distinct_id() can only be called after the Mixpanel library has finished loading.
31094 * init() has a loaded function available to handle this automatically. For example:
31095 *
31096 * // set distinct_id after the mixpanel library has loaded
31097 * mixpanel.init('YOUR PROJECT TOKEN', {
31098 * loaded: function(mixpanel) {
31099 * distinct_id = mixpanel.get_distinct_id();
31100 * }
31101 * });
31102 */
31103 MixpanelLib.prototype.get_distinct_id = function() {
31104 return this.get_property('distinct_id');
31105 };
31106
31107 /**
31108 * The alias method creates an alias which Mixpanel will use to
31109 * remap one id to another. Multiple aliases can point to the
31110 * same identifier.
31111 *
31112 * The following is a valid use of alias:
31113 *
31114 * mixpanel.alias('new_id', 'existing_id');
31115 * // You can add multiple id aliases to the existing ID
31116 * mixpanel.alias('newer_id', 'existing_id');
31117 *
31118 * Aliases can also be chained - the following is a valid example:
31119 *
31120 * mixpanel.alias('new_id', 'existing_id');
31121 * // chain newer_id - new_id - existing_id
31122 * mixpanel.alias('newer_id', 'new_id');
31123 *
31124 * Aliases cannot point to multiple identifiers - the following
31125 * example will not work:
31126 *
31127 * mixpanel.alias('new_id', 'existing_id');
31128 * // this is invalid as 'new_id' already points to 'existing_id'
31129 * mixpanel.alias('new_id', 'newer_id');
31130 *
31131 * ### Notes:
31132 *
31133 * If your project does not have
31134 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31135 * enabled, the best practice is to call alias once when a unique
31136 * ID is first created for a user (e.g., when a user first registers
31137 * for an account). Do not use alias multiple times for a single
31138 * user without ID Merge enabled.
31139 *
31140 * @param {String} alias A unique identifier that you want to use for this user in the future.
31141 * @param {String} [original] The current identifier being used for this user.
31142 */
31143 MixpanelLib.prototype.alias = function(alias, original) {
31144 // If the $people_distinct_id key exists in persistence, there has been a previous
31145 // mixpanel.people.identify() call made for this user. It is VERY BAD to make an alias with
31146 // this ID, as it will duplicate users.
31147 if (alias === this.get_property(PEOPLE_DISTINCT_ID_KEY)) {
31148 this.report_error('Attempting to create alias for existing People user - aborting.');
31149 return -2;
31150 }
31151
31152 var _this = this;
31153 if (_.isUndefined(original)) {
31154 original = this.get_distinct_id();
31155 }
31156 if (alias !== original) {
31157 this._register_single(ALIAS_ID_KEY, alias);
31158 return this.track('$create_alias', {
31159 'alias': alias,
31160 'distinct_id': original
31161 }, {
31162 skip_hooks: true
31163 }, function() {
31164 // Flush the people queue
31165 _this.identify(alias);
31166 });
31167 } else {
31168 this.report_error('alias matches current distinct_id - skipping api call.');
31169 this.identify(alias);
31170 return -1;
31171 }
31172 };
31173
31174 /**
31175 * Provide a string to recognize the user by. The string passed to
31176 * this method will appear in the Mixpanel Streams product rather
31177 * than an automatically generated name. Name tags do not have to
31178 * be unique.
31179 *
31180 * This value will only be included in Streams data.
31181 *
31182 * @param {String} name_tag A human readable name for the user
31183 * @deprecated
31184 */
31185 MixpanelLib.prototype.name_tag = function(name_tag) {
31186 this._register_single('mp_name_tag', name_tag);
31187 };
31188
31189 /**
31190 * Update the configuration of a mixpanel library instance.
31191 *
31192 * The default config is:
31193 *
31194 * {
31195 * // host for requests (customizable for e.g. a local proxy)
31196 * api_host: 'https://api-js.mixpanel.com',
31197 *
31198 * // endpoints for different types of requests
31199 * api_routes: {
31200 * track: 'track/',
31201 * engage: 'engage/',
31202 * groups: 'groups/',
31203 * }
31204 *
31205 * // HTTP method for tracking requests
31206 * api_method: 'POST'
31207 *
31208 * // transport for sending requests ('XHR' or 'sendBeacon')
31209 * // NB: sendBeacon should only be used for scenarios such as
31210 * // page unload where a "best-effort" attempt to send is
31211 * // acceptable; the sendBeacon API does not support callbacks
31212 * // or any way to know the result of the request. Mixpanel
31213 * // tracking via sendBeacon will not support any event-
31214 * // batching or retry mechanisms.
31215 * api_transport: 'XHR'
31216 *
31217 * // request-batching/queueing/retry
31218 * batch_requests: true,
31219 *
31220 * // maximum number of events/updates to send in a single
31221 * // network request
31222 * batch_size: 50,
31223 *
31224 * // milliseconds to wait between sending batch requests
31225 * batch_flush_interval_ms: 5000,
31226 *
31227 * // milliseconds to wait for network responses to batch requests
31228 * // before they are considered timed-out and retried
31229 * batch_request_timeout_ms: 90000,
31230 *
31231 * // override value for cookie domain, only useful for ensuring
31232 * // correct cross-subdomain cookies on unusual domains like
31233 * // subdomain.mainsite.avocat.fr; NB this cannot be used to
31234 * // set cookies on a different domain than the current origin
31235 * cookie_domain: ''
31236 *
31237 * // super properties cookie expiration (in days)
31238 * cookie_expiration: 365
31239 *
31240 * // if true, cookie will be set with SameSite=None; Secure
31241 * // this is only useful in special situations, like embedded
31242 * // 3rd-party iframes that set up a Mixpanel instance
31243 * cross_site_cookie: false
31244 *
31245 * // super properties span subdomains
31246 * cross_subdomain_cookie: true
31247 *
31248 * // debug mode
31249 * debug: false
31250 *
31251 * // if this is true, the mixpanel cookie or localStorage entry
31252 * // will be deleted, and no user persistence will take place
31253 * disable_persistence: false
31254 *
31255 * // if this is true, Mixpanel will automatically determine
31256 * // City, Region and Country data using the IP address of
31257 * //the client
31258 * ip: true
31259 *
31260 * // opt users out of tracking by this Mixpanel instance by default
31261 * opt_out_tracking_by_default: false
31262 *
31263 * // opt users out of browser data storage by this Mixpanel instance by default
31264 * opt_out_persistence_by_default: false
31265 *
31266 * // persistence mechanism used by opt-in/opt-out methods - cookie
31267 * // or localStorage - falls back to cookie if localStorage is unavailable
31268 * opt_out_tracking_persistence_type: 'localStorage'
31269 *
31270 * // customize the name of cookie/localStorage set by opt-in/opt-out methods
31271 * opt_out_tracking_cookie_prefix: null
31272 *
31273 * // type of persistent store for super properties (cookie/
31274 * // localStorage) if set to 'localStorage', any existing
31275 * // mixpanel cookie value with the same persistence_name
31276 * // will be transferred to localStorage and deleted
31277 * persistence: 'cookie'
31278 *
31279 * // name for super properties persistent store
31280 * persistence_name: ''
31281 *
31282 * // names of properties/superproperties which should never
31283 * // be sent with track() calls
31284 * property_blacklist: []
31285 *
31286 * // if this is true, mixpanel cookies will be marked as
31287 * // secure, meaning they will only be transmitted over https
31288 * secure_cookie: false
31289 *
31290 * // disables enriching user profiles with first touch marketing data
31291 * skip_first_touch_marketing: false
31292 *
31293 * // the amount of time track_links will
31294 * // wait for Mixpanel's servers to respond
31295 * track_links_timeout: 300
31296 *
31297 * // adds any UTM parameters and click IDs present on the page to any events fired
31298 * track_marketing: true
31299 *
31300 * // enables automatic page view tracking using default page view events through
31301 * // the track_pageview() method
31302 * track_pageview: false
31303 *
31304 * // if you set upgrade to be true, the library will check for
31305 * // a cookie from our old js library and import super
31306 * // properties from it, then the old cookie is deleted
31307 * // The upgrade config option only works in the initialization,
31308 * // so make sure you set it when you create the library.
31309 * upgrade: false
31310 *
31311 * // extra HTTP request headers to set for each API request, in
31312 * // the format {'Header-Name': value}
31313 * xhr_headers: {}
31314 *
31315 * // whether to ignore or respect the web browser's Do Not Track setting
31316 * ignore_dnt: false
31317 * }
31318 *
31319 *
31320 * @param {Object} config A dictionary of new configuration values to update
31321 */
31322 MixpanelLib.prototype.set_config = function(config) {
31323 if (_.isObject(config)) {
31324 _.extend(this['config'], config);
31325
31326 var new_batch_size = config['batch_size'];
31327 if (new_batch_size) {
31328 _.each(this.request_batchers, function(batcher) {
31329 batcher.resetBatchSize();
31330 });
31331 }
31332
31333 if (!this.get_config('persistence_name')) {
31334 this['config']['persistence_name'] = this['config']['cookie_name'];
31335 }
31336 if (!this.get_config('disable_persistence')) {
31337 this['config']['disable_persistence'] = this['config']['disable_cookie'];
31338 }
31339
31340 if (this['persistence']) {
31341 this['persistence'].update_config(this['config']);
31342 }
31343 Config.DEBUG = Config.DEBUG || this.get_config('debug');
31344
31345 if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
31346 this.autocapture.init();
31347 }
31348 }
31349 };
31350
31351 /**
31352 * returns the current config object for the library.
31353 */
31354 MixpanelLib.prototype.get_config = function(prop_name) {
31355 return this['config'][prop_name];
31356 };
31357
31358 /**
31359 * Fetch a hook function from config, with safe default, and run it
31360 * against the given arguments
31361 * @param {string} hook_name which hook to retrieve
31362 * @returns {any|null} return value of user-provided hook, or null if nothing was returned
31363 */
31364 MixpanelLib.prototype._run_hook = function(hook_name) {
31365 var ret = (this['config']['hooks'][hook_name] || IDENTITY_FUNC).apply(this, slice.call(arguments, 1));
31366 if (typeof ret === 'undefined') {
31367 this.report_error(hook_name + ' hook did not return a value');
31368 ret = null;
31369 }
31370 return ret;
31371 };
31372
31373 /**
31374 * Returns the value of the super property named property_name. If no such
31375 * property is set, get_property() will return the undefined value.
31376 *
31377 * ### Notes:
31378 *
31379 * get_property() can only be called after the Mixpanel library has finished loading.
31380 * init() has a loaded function available to handle this automatically. For example:
31381 *
31382 * // grab value for 'user_id' after the mixpanel library has loaded
31383 * mixpanel.init('YOUR PROJECT TOKEN', {
31384 * loaded: function(mixpanel) {
31385 * user_id = mixpanel.get_property('user_id');
31386 * }
31387 * });
31388 *
31389 * @param {String} property_name The name of the super property you want to retrieve
31390 */
31391 MixpanelLib.prototype.get_property = function(property_name) {
31392 return this['persistence'].load_prop([property_name]);
31393 };
31394
31395 /**
31396 * Get the API host for a specific endpoint type, falling back to the default api_host if not specified
31397 *
31398 * @param {String} endpoint_type The type of endpoint (e.g., "events", "people", "groups")
31399 * @returns {String} The API host to use for this endpoint
31400 */
31401 MixpanelLib.prototype.get_api_host = function(endpoint_type) {
31402 return this.get_config('api_hosts')[endpoint_type] || this.get_config('api_host');
31403 };
31404
31405 MixpanelLib.prototype.toString = function() {
31406 var name = this.get_config('name');
31407 if (name !== PRIMARY_INSTANCE_NAME) {
31408 name = PRIMARY_INSTANCE_NAME + '.' + name;
31409 }
31410 return name;
31411 };
31412
31413 MixpanelLib.prototype._event_is_disabled = function(event_name) {
31414 return _.isBlockedUA(userAgent) ||
31415 this._flags.disable_all_events ||
31416 _.include(this.__disabled_events, event_name);
31417 };
31418
31419 // perform some housekeeping around GDPR opt-in/out state
31420 MixpanelLib.prototype._gdpr_init = function() {
31421 var is_localStorage_requested = this.get_config('opt_out_tracking_persistence_type') === 'localStorage';
31422
31423 // try to convert opt-in/out cookies to localStorage if possible
31424 if (is_localStorage_requested && _.localStorage.is_supported()) {
31425 if (!this.has_opted_in_tracking() && this.has_opted_in_tracking({'persistence_type': 'cookie'})) {
31426 this.opt_in_tracking({'enable_persistence': false});
31427 }
31428 if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({'persistence_type': 'cookie'})) {
31429 this.opt_out_tracking({'clear_persistence': false});
31430 }
31431 this.clear_opt_in_out_tracking({
31432 'persistence_type': 'cookie',
31433 'enable_persistence': false
31434 });
31435 }
31436
31437 // check whether the user has already opted out - if so, clear & disable persistence
31438 if (this.has_opted_out_tracking()) {
31439 this._gdpr_update_persistence({'clear_persistence': true});
31440
31441 // check whether we should opt out by default
31442 // note: we don't clear persistence here by default since opt-out default state is often
31443 // used as an initial state while GDPR information is being collected
31444 } else if (!this.has_opted_in_tracking() && (
31445 this.get_config('opt_out_tracking_by_default') || _.cookie.get('mp_optout')
31446 )) {
31447 _.cookie.remove('mp_optout');
31448 this.opt_out_tracking({
31449 'clear_persistence': this.get_config('opt_out_persistence_by_default')
31450 });
31451 }
31452 };
31453
31454 /**
31455 * Enable or disable persistence based on options
31456 * only enable/disable if persistence is not already in this state
31457 * @param {boolean} [options.clear_persistence] If true, will delete all data stored by the sdk in persistence and disable it
31458 * @param {boolean} [options.enable_persistence] If true, will re-enable sdk persistence
31459 */
31460 MixpanelLib.prototype._gdpr_update_persistence = function(options) {
31461 var disabled;
31462 if (options && options['clear_persistence']) {
31463 disabled = true;
31464 } else if (options && options['enable_persistence']) {
31465 disabled = false;
31466 } else {
31467 return;
31468 }
31469
31470 if (!this.get_config('disable_persistence') && this['persistence'].disabled !== disabled) {
31471 this['persistence'].set_disabled(disabled);
31472 }
31473
31474 if (disabled) {
31475 this.stop_batch_senders();
31476 this.stop_session_recording();
31477 } else {
31478 // only start batchers after opt-in if they have previously been started
31479 // in order to avoid unintentionally starting up batching for the first time
31480 if (this._batchers_were_started) {
31481 this.start_batch_senders();
31482 }
31483 }
31484 };
31485
31486 // call a base gdpr function after constructing the appropriate token and options args
31487 MixpanelLib.prototype._gdpr_call_func = function(func, options) {
31488 options = _.extend({
31489 'track': _.bind(this.track, this),
31490 'persistence_type': this.get_config('opt_out_tracking_persistence_type'),
31491 'cookie_prefix': this.get_config('opt_out_tracking_cookie_prefix'),
31492 'cookie_expiration': this.get_config('cookie_expiration'),
31493 'cross_site_cookie': this.get_config('cross_site_cookie'),
31494 'cross_subdomain_cookie': this.get_config('cross_subdomain_cookie'),
31495 'cookie_domain': this.get_config('cookie_domain'),
31496 'secure_cookie': this.get_config('secure_cookie'),
31497 'ignore_dnt': this.get_config('ignore_dnt')
31498 }, options);
31499
31500 // check if localStorage can be used for recording opt out status, fall back to cookie if not
31501 if (!_.localStorage.is_supported()) {
31502 options['persistence_type'] = 'cookie';
31503 }
31504
31505 return func(this.get_config('token'), {
31506 track: options['track'],
31507 trackEventName: options['track_event_name'],
31508 trackProperties: options['track_properties'],
31509 persistenceType: options['persistence_type'],
31510 persistencePrefix: options['cookie_prefix'],
31511 cookieDomain: options['cookie_domain'],
31512 cookieExpiration: options['cookie_expiration'],
31513 crossSiteCookie: options['cross_site_cookie'],
31514 crossSubdomainCookie: options['cross_subdomain_cookie'],
31515 secureCookie: options['secure_cookie'],
31516 ignoreDnt: options['ignore_dnt']
31517 });
31518 };
31519
31520 /**
31521 * Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
31522 *
31523 * ### Usage:
31524 *
31525 * // opt user in
31526 * mixpanel.opt_in_tracking();
31527 *
31528 * // opt user in with specific event name, properties, cookie configuration
31529 * mixpanel.opt_in_tracking({
31530 * track_event_name: 'User opted in',
31531 * track_event_properties: {
31532 * 'Email': 'jdoe@example.com'
31533 * },
31534 * cookie_expiration: 30,
31535 * secure_cookie: true
31536 * });
31537 *
31538 * @param {Object} [options] A dictionary of config options to override
31539 * @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)
31540 * @param {string} [options.track_event_name=$opt_in] Event name to be used for tracking the opt-in action
31541 * @param {Object} [options.track_properties] Set of properties to be tracked along with the opt-in action
31542 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
31543 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31544 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31545 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
31546 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
31547 * @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)
31548 * @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)
31549 * @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)
31550 */
31551 MixpanelLib.prototype.opt_in_tracking = function(options) {
31552 options = _.extend({
31553 'enable_persistence': true
31554 }, options);
31555
31556 this._gdpr_call_func(optIn, options);
31557 this._gdpr_update_persistence(options);
31558 };
31559
31560 /**
31561 * Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
31562 *
31563 * ### Usage:
31564 *
31565 * // opt user out
31566 * mixpanel.opt_out_tracking();
31567 *
31568 * // opt user out with different cookie configuration from Mixpanel instance
31569 * mixpanel.opt_out_tracking({
31570 * cookie_expiration: 30,
31571 * secure_cookie: true
31572 * });
31573 *
31574 * @param {Object} [options] A dictionary of config options to override
31575 * @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
31576 * @param {boolean} [options.clear_persistence=true] If true, will delete all data stored by the sdk in persistence
31577 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31578 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31579 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
31580 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
31581 * @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)
31582 * @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)
31583 * @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)
31584 */
31585 MixpanelLib.prototype.opt_out_tracking = function(options) {
31586 options = _.extend({
31587 'clear_persistence': true,
31588 'delete_user': true
31589 }, options);
31590
31591 // delete user and clear charges since these methods may be disabled by opt-out
31592 if (options['delete_user'] && this['people'] && this['people']._identify_called()) {
31593 this['people'].delete_user();
31594 this['people'].clear_charges();
31595 }
31596
31597 this._gdpr_call_func(optOut, options);
31598 this._gdpr_update_persistence(options);
31599 };
31600
31601 /**
31602 * Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
31603 *
31604 * ### Usage:
31605 *
31606 * var has_opted_in = mixpanel.has_opted_in_tracking();
31607 * // use has_opted_in value
31608 *
31609 * @param {Object} [options] A dictionary of config options to override
31610 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31611 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31612 * @returns {boolean} current opt-in status
31613 */
31614 MixpanelLib.prototype.has_opted_in_tracking = function(options) {
31615 return this._gdpr_call_func(hasOptedIn, options);
31616 };
31617
31618 /**
31619 * Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
31620 *
31621 * ### Usage:
31622 *
31623 * var has_opted_out = mixpanel.has_opted_out_tracking();
31624 * // use has_opted_out value
31625 *
31626 * @param {Object} [options] A dictionary of config options to override
31627 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31628 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31629 * @returns {boolean} current opt-out status
31630 */
31631 MixpanelLib.prototype.has_opted_out_tracking = function(options) {
31632 return this._gdpr_call_func(hasOptedOut, options);
31633 };
31634
31635 /**
31636 * Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
31637 *
31638 * ### Usage:
31639 *
31640 * // clear user's opt-in/out status
31641 * mixpanel.clear_opt_in_out_tracking();
31642 *
31643 * // clear user's opt-in/out status with specific cookie configuration - should match
31644 * // configuration used when opt_in_tracking/opt_out_tracking methods were called.
31645 * mixpanel.clear_opt_in_out_tracking({
31646 * cookie_expiration: 30,
31647 * secure_cookie: true
31648 * });
31649 *
31650 * @param {Object} [options] A dictionary of config options to override
31651 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
31652 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
31653 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
31654 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
31655 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
31656 * @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)
31657 * @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)
31658 * @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)
31659 */
31660 MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
31661 options = _.extend({
31662 'enable_persistence': true
31663 }, options);
31664
31665 this._gdpr_call_func(clearOptInOut, options);
31666 this._gdpr_update_persistence(options);
31667 };
31668
31669 MixpanelLib.prototype.report_error = function(msg, err) {
31670 console$1.error.apply(console$1.error, arguments);
31671 try {
31672 if (!err && !(msg instanceof Error)) {
31673 msg = new Error(msg);
31674 }
31675 this.get_config('error_reporter')(msg, err);
31676 } catch(err) {
31677 console$1.error(err);
31678 }
31679 };
31680
31681 // EXPORTS (for closure compiler)
31682
31683 // MixpanelLib Exports
31684 MixpanelLib.prototype['init'] = MixpanelLib.prototype.init;
31685 MixpanelLib.prototype['reset'] = MixpanelLib.prototype.reset;
31686 MixpanelLib.prototype['disable'] = MixpanelLib.prototype.disable;
31687 MixpanelLib.prototype['time_event'] = MixpanelLib.prototype.time_event;
31688 MixpanelLib.prototype['track'] = MixpanelLib.prototype.track;
31689 MixpanelLib.prototype['track_links'] = MixpanelLib.prototype.track_links;
31690 MixpanelLib.prototype['track_forms'] = MixpanelLib.prototype.track_forms;
31691 MixpanelLib.prototype['track_pageview'] = MixpanelLib.prototype.track_pageview;
31692 MixpanelLib.prototype['register'] = MixpanelLib.prototype.register;
31693 MixpanelLib.prototype['register_once'] = MixpanelLib.prototype.register_once;
31694 MixpanelLib.prototype['unregister'] = MixpanelLib.prototype.unregister;
31695 MixpanelLib.prototype['identify'] = MixpanelLib.prototype.identify;
31696 MixpanelLib.prototype['alias'] = MixpanelLib.prototype.alias;
31697 MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
31698 MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
31699 MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
31700 MixpanelLib.prototype['get_api_host'] = MixpanelLib.prototype.get_api_host;
31701 MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
31702 MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
31703 MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
31704 MixpanelLib.prototype['opt_out_tracking'] = MixpanelLib.prototype.opt_out_tracking;
31705 MixpanelLib.prototype['opt_in_tracking'] = MixpanelLib.prototype.opt_in_tracking;
31706 MixpanelLib.prototype['has_opted_out_tracking'] = MixpanelLib.prototype.has_opted_out_tracking;
31707 MixpanelLib.prototype['has_opted_in_tracking'] = MixpanelLib.prototype.has_opted_in_tracking;
31708 MixpanelLib.prototype['clear_opt_in_out_tracking'] = MixpanelLib.prototype.clear_opt_in_out_tracking;
31709 MixpanelLib.prototype['get_group'] = MixpanelLib.prototype.get_group;
31710 MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
31711 MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
31712 MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
31713 MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
31714 MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
31715 MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;
31716 MixpanelLib.prototype['start_session_recording'] = MixpanelLib.prototype.start_session_recording;
31717 MixpanelLib.prototype['stop_session_recording'] = MixpanelLib.prototype.stop_session_recording;
31718 MixpanelLib.prototype['pause_session_recording'] = MixpanelLib.prototype.pause_session_recording;
31719 MixpanelLib.prototype['resume_session_recording'] = MixpanelLib.prototype.resume_session_recording;
31720 MixpanelLib.prototype['get_session_recording_properties'] = MixpanelLib.prototype.get_session_recording_properties;
31721 MixpanelLib.prototype['get_session_replay_url'] = MixpanelLib.prototype.get_session_replay_url;
31722 MixpanelLib.prototype['get_tab_id'] = MixpanelLib.prototype.get_tab_id;
31723 MixpanelLib.prototype['DEFAULT_API_ROUTES'] = DEFAULT_API_ROUTES;
31724
31725 // Exports intended only for testing
31726 MixpanelLib.prototype['__get_recorder'] = MixpanelLib.prototype.__get_recorder;
31727
31728 // MixpanelPersistence Exports
31729 MixpanelPersistence.prototype['properties'] = MixpanelPersistence.prototype.properties;
31730 MixpanelPersistence.prototype['update_search_keyword'] = MixpanelPersistence.prototype.update_search_keyword;
31731 MixpanelPersistence.prototype['update_referrer_info'] = MixpanelPersistence.prototype.update_referrer_info;
31732 MixpanelPersistence.prototype['get_cross_subdomain'] = MixpanelPersistence.prototype.get_cross_subdomain;
31733 MixpanelPersistence.prototype['clear'] = MixpanelPersistence.prototype.clear;
31734
31735
31736 var instances = {};
31737 var extend_mp = function() {
31738 // add all the sub mixpanel instances
31739 _.each(instances, function(instance, name) {
31740 if (name !== PRIMARY_INSTANCE_NAME) { mixpanel_master[name] = instance; }
31741 });
31742
31743 // add private functions as _
31744 mixpanel_master['_'] = _;
31745 };
31746
31747 var override_mp_init_func = function() {
31748 // we override the snippets init function to handle the case where a
31749 // user initializes the mixpanel library after the script loads & runs
31750 mixpanel_master['init'] = function(token, config, name) {
31751 if (name) {
31752 // initialize a sub library
31753 if (!mixpanel_master[name]) {
31754 mixpanel_master[name] = instances[name] = create_mplib(token, config, name);
31755 mixpanel_master[name]._loaded();
31756 }
31757 return mixpanel_master[name];
31758 } else {
31759 var instance = mixpanel_master;
31760
31761 if (instances[PRIMARY_INSTANCE_NAME]) {
31762 // main mixpanel lib already initialized
31763 instance = instances[PRIMARY_INSTANCE_NAME];
31764 } else if (token) {
31765 // intialize the main mixpanel lib
31766 instance = create_mplib(token, config, PRIMARY_INSTANCE_NAME);
31767 instance._loaded();
31768 instances[PRIMARY_INSTANCE_NAME] = instance;
31769 }
31770
31771 mixpanel_master = instance;
31772 if (init_type === INIT_SNIPPET) {
31773 win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
31774 }
31775 extend_mp();
31776 }
31777 };
31778 };
31779
31780 var add_dom_loaded_handler = function() {
31781 // Cross browser DOM Loaded support
31782 function dom_loaded_handler() {
31783 // function flag since we only want to execute this once
31784 if (dom_loaded_handler.done) { return; }
31785 dom_loaded_handler.done = true;
31786
31787 DOM_LOADED = true;
31788 ENQUEUE_REQUESTS = false;
31789
31790 _.each(instances, function(inst) {
31791 inst._dom_loaded();
31792 });
31793 }
31794
31795 function do_scroll_check() {
31796 try {
31797 document$1.documentElement.doScroll('left');
31798 } catch(e) {
31799 setTimeout(do_scroll_check, 1);
31800 return;
31801 }
31802
31803 dom_loaded_handler();
31804 }
31805
31806 if (document$1.addEventListener) {
31807 if (document$1.readyState === 'complete') {
31808 // safari 4 can fire the DOMContentLoaded event before loading all
31809 // external JS (including this file). you will see some copypasta
31810 // on the internet that checks for 'complete' and 'loaded', but
31811 // 'loaded' is an IE thing
31812 dom_loaded_handler();
31813 } else {
31814 document$1.addEventListener('DOMContentLoaded', dom_loaded_handler, false);
31815 }
31816 } else if (document$1.attachEvent) {
31817 // IE
31818 document$1.attachEvent('onreadystatechange', dom_loaded_handler);
31819
31820 // check to make sure we arn't in a frame
31821 var toplevel = false;
31822 try {
31823 toplevel = win.frameElement === null;
31824 } catch(e) {
31825 // noop
31826 }
31827
31828 if (document$1.documentElement.doScroll && toplevel) {
31829 do_scroll_check();
31830 }
31831 }
31832
31833 // fallback handler, always will work
31834 _.register_event(win, 'load', dom_loaded_handler, true);
31835 };
31836
31837 function init_as_module(bundle_loader) {
31838 load_extra_bundle = bundle_loader;
31839 init_type = INIT_MODULE;
31840 mixpanel_master = new MixpanelLib();
31841
31842 override_mp_init_func();
31843 mixpanel_master['init']();
31844 add_dom_loaded_handler();
31845
31846 return mixpanel_master;
31847 }
31848
31849 // For loading separate bundles asynchronously via script tag
31850 // so that we don't load them until they are needed at runtime.
31851
31852 // For builds that have everything in one bundle, no extra work.
31853 function loadNoop (_src, onload) {
31854 onload();
31855 }
31856
31857 /* eslint camelcase: "off" */
31858
31859 var mixpanel = init_as_module(loadNoop);
31860
31861
31862
31863
31864 /***/ }),
31865
31866 /***/ "../node_modules/redux-thunk/es/index.js":
31867 /*!***********************************************!*\
31868 !*** ../node_modules/redux-thunk/es/index.js ***!
31869 \***********************************************/
31870 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
31871
31872 "use strict";
31873 __webpack_require__.r(__webpack_exports__);
31874 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
31875 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
31876 /* harmony export */ });
31877 /** A function that accepts a potential "extra argument" value to be injected later,
31878 * and returns an instance of the thunk middleware that uses that value
31879 */
31880 function createThunkMiddleware(extraArgument) {
31881 // Standard Redux middleware definition pattern:
31882 // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
31883 var middleware = function middleware(_ref) {
31884 var dispatch = _ref.dispatch,
31885 getState = _ref.getState;
31886 return function (next) {
31887 return function (action) {
31888 // The thunk middleware looks for any functions that were passed to `store.dispatch`.
31889 // If this "action" is really a function, call it and return the result.
31890 if (typeof action === 'function') {
31891 // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
31892 return action(dispatch, getState, extraArgument);
31893 } // Otherwise, pass the action down the middleware chain as usual
31894
31895
31896 return next(action);
31897 };
31898 };
31899 };
31900
31901 return middleware;
31902 }
31903
31904 var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
31905 // with whatever "extra arg" they want to inject into their thunks
31906
31907 thunk.withExtraArgument = createThunkMiddleware;
31908 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (thunk);
31909
31910 /***/ }),
31911
31912 /***/ "../node_modules/redux/es/redux.js":
31913 /*!*****************************************!*\
31914 !*** ../node_modules/redux/es/redux.js ***!
31915 \*****************************************/
31916 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
31917
31918 "use strict";
31919 __webpack_require__.r(__webpack_exports__);
31920 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
31921 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* binding */ ActionTypes),
31922 /* harmony export */ applyMiddleware: () => (/* binding */ applyMiddleware),
31923 /* harmony export */ bindActionCreators: () => (/* binding */ bindActionCreators),
31924 /* harmony export */ combineReducers: () => (/* binding */ combineReducers),
31925 /* harmony export */ compose: () => (/* binding */ compose),
31926 /* harmony export */ createStore: () => (/* binding */ createStore),
31927 /* harmony export */ legacy_createStore: () => (/* binding */ legacy_createStore)
31928 /* harmony export */ });
31929 /* 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");
31930
31931
31932 /**
31933 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
31934 *
31935 * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
31936 * during build.
31937 * @param {number} code
31938 */
31939 function formatProdErrorMessage(code) {
31940 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. ';
31941 }
31942
31943 // Inlined version of the `symbol-observable` polyfill
31944 var $$observable = (function () {
31945 return typeof Symbol === 'function' && Symbol.observable || '@@observable';
31946 })();
31947
31948 /**
31949 * These are private action types reserved by Redux.
31950 * For any unknown actions, you must return the current state.
31951 * If the current state is undefined, you must return the initial state.
31952 * Do not reference these action types directly in your code.
31953 */
31954 var randomString = function randomString() {
31955 return Math.random().toString(36).substring(7).split('').join('.');
31956 };
31957
31958 var ActionTypes = {
31959 INIT: "@@redux/INIT" + randomString(),
31960 REPLACE: "@@redux/REPLACE" + randomString(),
31961 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
31962 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
31963 }
31964 };
31965
31966 /**
31967 * @param {any} obj The object to inspect.
31968 * @returns {boolean} True if the argument appears to be a plain object.
31969 */
31970 function isPlainObject(obj) {
31971 if (typeof obj !== 'object' || obj === null) return false;
31972 var proto = obj;
31973
31974 while (Object.getPrototypeOf(proto) !== null) {
31975 proto = Object.getPrototypeOf(proto);
31976 }
31977
31978 return Object.getPrototypeOf(obj) === proto;
31979 }
31980
31981 // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
31982 function miniKindOf(val) {
31983 if (val === void 0) return 'undefined';
31984 if (val === null) return 'null';
31985 var type = typeof val;
31986
31987 switch (type) {
31988 case 'boolean':
31989 case 'string':
31990 case 'number':
31991 case 'symbol':
31992 case 'function':
31993 {
31994 return type;
31995 }
31996 }
31997
31998 if (Array.isArray(val)) return 'array';
31999 if (isDate(val)) return 'date';
32000 if (isError(val)) return 'error';
32001 var constructorName = ctorName(val);
32002
32003 switch (constructorName) {
32004 case 'Symbol':
32005 case 'Promise':
32006 case 'WeakMap':
32007 case 'WeakSet':
32008 case 'Map':
32009 case 'Set':
32010 return constructorName;
32011 } // other
32012
32013
32014 return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
32015 }
32016
32017 function ctorName(val) {
32018 return typeof val.constructor === 'function' ? val.constructor.name : null;
32019 }
32020
32021 function isError(val) {
32022 return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
32023 }
32024
32025 function isDate(val) {
32026 if (val instanceof Date) return true;
32027 return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
32028 }
32029
32030 function kindOf(val) {
32031 var typeOfVal = typeof val;
32032
32033 if (true) {
32034 typeOfVal = miniKindOf(val);
32035 }
32036
32037 return typeOfVal;
32038 }
32039
32040 /**
32041 * @deprecated
32042 *
32043 * **We recommend using the `configureStore` method
32044 * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
32045 *
32046 * Redux Toolkit is our recommended approach for writing Redux logic today,
32047 * including store setup, reducers, data fetching, and more.
32048 *
32049 * **For more details, please read this Redux docs page:**
32050 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32051 *
32052 * `configureStore` from Redux Toolkit is an improved version of `createStore` that
32053 * simplifies setup and helps avoid common bugs.
32054 *
32055 * You should not be using the `redux` core package by itself today, except for learning purposes.
32056 * The `createStore` method from the core `redux` package will not be removed, but we encourage
32057 * all users to migrate to using Redux Toolkit for all Redux code.
32058 *
32059 * If you want to use `createStore` without this visual deprecation warning, use
32060 * the `legacy_createStore` import instead:
32061 *
32062 * `import { legacy_createStore as createStore} from 'redux'`
32063 *
32064 */
32065
32066 function createStore(reducer, preloadedState, enhancer) {
32067 var _ref2;
32068
32069 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
32070 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.');
32071 }
32072
32073 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
32074 enhancer = preloadedState;
32075 preloadedState = undefined;
32076 }
32077
32078 if (typeof enhancer !== 'undefined') {
32079 if (typeof enhancer !== 'function') {
32080 throw new Error( false ? 0 : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
32081 }
32082
32083 return enhancer(createStore)(reducer, preloadedState);
32084 }
32085
32086 if (typeof reducer !== 'function') {
32087 throw new Error( false ? 0 : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
32088 }
32089
32090 var currentReducer = reducer;
32091 var currentState = preloadedState;
32092 var currentListeners = [];
32093 var nextListeners = currentListeners;
32094 var isDispatching = false;
32095 /**
32096 * This makes a shallow copy of currentListeners so we can use
32097 * nextListeners as a temporary list while dispatching.
32098 *
32099 * This prevents any bugs around consumers calling
32100 * subscribe/unsubscribe in the middle of a dispatch.
32101 */
32102
32103 function ensureCanMutateNextListeners() {
32104 if (nextListeners === currentListeners) {
32105 nextListeners = currentListeners.slice();
32106 }
32107 }
32108 /**
32109 * Reads the state tree managed by the store.
32110 *
32111 * @returns {any} The current state tree of your application.
32112 */
32113
32114
32115 function getState() {
32116 if (isDispatching) {
32117 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.');
32118 }
32119
32120 return currentState;
32121 }
32122 /**
32123 * Adds a change listener. It will be called any time an action is dispatched,
32124 * and some part of the state tree may potentially have changed. You may then
32125 * call `getState()` to read the current state tree inside the callback.
32126 *
32127 * You may call `dispatch()` from a change listener, with the following
32128 * caveats:
32129 *
32130 * 1. The subscriptions are snapshotted just before every `dispatch()` call.
32131 * If you subscribe or unsubscribe while the listeners are being invoked, this
32132 * will not have any effect on the `dispatch()` that is currently in progress.
32133 * However, the next `dispatch()` call, whether nested or not, will use a more
32134 * recent snapshot of the subscription list.
32135 *
32136 * 2. The listener should not expect to see all state changes, as the state
32137 * might have been updated multiple times during a nested `dispatch()` before
32138 * the listener is called. It is, however, guaranteed that all subscribers
32139 * registered before the `dispatch()` started will be called with the latest
32140 * state by the time it exits.
32141 *
32142 * @param {Function} listener A callback to be invoked on every dispatch.
32143 * @returns {Function} A function to remove this change listener.
32144 */
32145
32146
32147 function subscribe(listener) {
32148 if (typeof listener !== 'function') {
32149 throw new Error( false ? 0 : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
32150 }
32151
32152 if (isDispatching) {
32153 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.');
32154 }
32155
32156 var isSubscribed = true;
32157 ensureCanMutateNextListeners();
32158 nextListeners.push(listener);
32159 return function unsubscribe() {
32160 if (!isSubscribed) {
32161 return;
32162 }
32163
32164 if (isDispatching) {
32165 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.');
32166 }
32167
32168 isSubscribed = false;
32169 ensureCanMutateNextListeners();
32170 var index = nextListeners.indexOf(listener);
32171 nextListeners.splice(index, 1);
32172 currentListeners = null;
32173 };
32174 }
32175 /**
32176 * Dispatches an action. It is the only way to trigger a state change.
32177 *
32178 * The `reducer` function, used to create the store, will be called with the
32179 * current state tree and the given `action`. Its return value will
32180 * be considered the **next** state of the tree, and the change listeners
32181 * will be notified.
32182 *
32183 * The base implementation only supports plain object actions. If you want to
32184 * dispatch a Promise, an Observable, a thunk, or something else, you need to
32185 * wrap your store creating function into the corresponding middleware. For
32186 * example, see the documentation for the `redux-thunk` package. Even the
32187 * middleware will eventually dispatch plain object actions using this method.
32188 *
32189 * @param {Object} action A plain object representing “what changed”. It is
32190 * a good idea to keep actions serializable so you can record and replay user
32191 * sessions, or use the time travelling `redux-devtools`. An action must have
32192 * a `type` property which may not be `undefined`. It is a good idea to use
32193 * string constants for action types.
32194 *
32195 * @returns {Object} For convenience, the same action object you dispatched.
32196 *
32197 * Note that, if you use a custom middleware, it may wrap `dispatch()` to
32198 * return something else (for example, a Promise you can await).
32199 */
32200
32201
32202 function dispatch(action) {
32203 if (!isPlainObject(action)) {
32204 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.");
32205 }
32206
32207 if (typeof action.type === 'undefined') {
32208 throw new Error( false ? 0 : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
32209 }
32210
32211 if (isDispatching) {
32212 throw new Error( false ? 0 : 'Reducers may not dispatch actions.');
32213 }
32214
32215 try {
32216 isDispatching = true;
32217 currentState = currentReducer(currentState, action);
32218 } finally {
32219 isDispatching = false;
32220 }
32221
32222 var listeners = currentListeners = nextListeners;
32223
32224 for (var i = 0; i < listeners.length; i++) {
32225 var listener = listeners[i];
32226 listener();
32227 }
32228
32229 return action;
32230 }
32231 /**
32232 * Replaces the reducer currently used by the store to calculate the state.
32233 *
32234 * You might need this if your app implements code splitting and you want to
32235 * load some of the reducers dynamically. You might also need this if you
32236 * implement a hot reloading mechanism for Redux.
32237 *
32238 * @param {Function} nextReducer The reducer for the store to use instead.
32239 * @returns {void}
32240 */
32241
32242
32243 function replaceReducer(nextReducer) {
32244 if (typeof nextReducer !== 'function') {
32245 throw new Error( false ? 0 : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
32246 }
32247
32248 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
32249 // Any reducers that existed in both the new and old rootReducer
32250 // will receive the previous state. This effectively populates
32251 // the new state tree with any relevant data from the old one.
32252
32253 dispatch({
32254 type: ActionTypes.REPLACE
32255 });
32256 }
32257 /**
32258 * Interoperability point for observable/reactive libraries.
32259 * @returns {observable} A minimal observable of state changes.
32260 * For more information, see the observable proposal:
32261 * https://github.com/tc39/proposal-observable
32262 */
32263
32264
32265 function observable() {
32266 var _ref;
32267
32268 var outerSubscribe = subscribe;
32269 return _ref = {
32270 /**
32271 * The minimal observable subscription method.
32272 * @param {Object} observer Any object that can be used as an observer.
32273 * The observer object should have a `next` method.
32274 * @returns {subscription} An object with an `unsubscribe` method that can
32275 * be used to unsubscribe the observable from the store, and prevent further
32276 * emission of values from the observable.
32277 */
32278 subscribe: function subscribe(observer) {
32279 if (typeof observer !== 'object' || observer === null) {
32280 throw new Error( false ? 0 : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
32281 }
32282
32283 function observeState() {
32284 if (observer.next) {
32285 observer.next(getState());
32286 }
32287 }
32288
32289 observeState();
32290 var unsubscribe = outerSubscribe(observeState);
32291 return {
32292 unsubscribe: unsubscribe
32293 };
32294 }
32295 }, _ref[$$observable] = function () {
32296 return this;
32297 }, _ref;
32298 } // When a store is created, an "INIT" action is dispatched so that every
32299 // reducer returns their initial state. This effectively populates
32300 // the initial state tree.
32301
32302
32303 dispatch({
32304 type: ActionTypes.INIT
32305 });
32306 return _ref2 = {
32307 dispatch: dispatch,
32308 subscribe: subscribe,
32309 getState: getState,
32310 replaceReducer: replaceReducer
32311 }, _ref2[$$observable] = observable, _ref2;
32312 }
32313 /**
32314 * Creates a Redux store that holds the state tree.
32315 *
32316 * **We recommend using `configureStore` from the
32317 * `@reduxjs/toolkit` package**, which replaces `createStore`:
32318 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32319 *
32320 * The only way to change the data in the store is to call `dispatch()` on it.
32321 *
32322 * There should only be a single store in your app. To specify how different
32323 * parts of the state tree respond to actions, you may combine several reducers
32324 * into a single reducer function by using `combineReducers`.
32325 *
32326 * @param {Function} reducer A function that returns the next state tree, given
32327 * the current state tree and the action to handle.
32328 *
32329 * @param {any} [preloadedState] The initial state. You may optionally specify it
32330 * to hydrate the state from the server in universal apps, or to restore a
32331 * previously serialized user session.
32332 * If you use `combineReducers` to produce the root reducer function, this must be
32333 * an object with the same shape as `combineReducers` keys.
32334 *
32335 * @param {Function} [enhancer] The store enhancer. You may optionally specify it
32336 * to enhance the store with third-party capabilities such as middleware,
32337 * time travel, persistence, etc. The only store enhancer that ships with Redux
32338 * is `applyMiddleware()`.
32339 *
32340 * @returns {Store} A Redux store that lets you read the state, dispatch actions
32341 * and subscribe to changes.
32342 */
32343
32344 var legacy_createStore = createStore;
32345
32346 /**
32347 * Prints a warning in the console if it exists.
32348 *
32349 * @param {String} message The warning message.
32350 * @returns {void}
32351 */
32352 function warning(message) {
32353 /* eslint-disable no-console */
32354 if (typeof console !== 'undefined' && typeof console.error === 'function') {
32355 console.error(message);
32356 }
32357 /* eslint-enable no-console */
32358
32359
32360 try {
32361 // This error was thrown as a convenience so that if you enable
32362 // "break on all exceptions" in your console,
32363 // it would pause the execution at this line.
32364 throw new Error(message);
32365 } catch (e) {} // eslint-disable-line no-empty
32366
32367 }
32368
32369 function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
32370 var reducerKeys = Object.keys(reducers);
32371 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
32372
32373 if (reducerKeys.length === 0) {
32374 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
32375 }
32376
32377 if (!isPlainObject(inputState)) {
32378 return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
32379 }
32380
32381 var unexpectedKeys = Object.keys(inputState).filter(function (key) {
32382 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
32383 });
32384 unexpectedKeys.forEach(function (key) {
32385 unexpectedKeyCache[key] = true;
32386 });
32387 if (action && action.type === ActionTypes.REPLACE) return;
32388
32389 if (unexpectedKeys.length > 0) {
32390 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.");
32391 }
32392 }
32393
32394 function assertReducerShape(reducers) {
32395 Object.keys(reducers).forEach(function (key) {
32396 var reducer = reducers[key];
32397 var initialState = reducer(undefined, {
32398 type: ActionTypes.INIT
32399 });
32400
32401 if (typeof initialState === 'undefined') {
32402 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.");
32403 }
32404
32405 if (typeof reducer(undefined, {
32406 type: ActionTypes.PROBE_UNKNOWN_ACTION()
32407 }) === 'undefined') {
32408 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.");
32409 }
32410 });
32411 }
32412 /**
32413 * Turns an object whose values are different reducer functions, into a single
32414 * reducer function. It will call every child reducer, and gather their results
32415 * into a single state object, whose keys correspond to the keys of the passed
32416 * reducer functions.
32417 *
32418 * @param {Object} reducers An object whose values correspond to different
32419 * reducer functions that need to be combined into one. One handy way to obtain
32420 * it is to use ES6 `import * as reducers` syntax. The reducers may never return
32421 * undefined for any action. Instead, they should return their initial state
32422 * if the state passed to them was undefined, and the current state for any
32423 * unrecognized action.
32424 *
32425 * @returns {Function} A reducer function that invokes every reducer inside the
32426 * passed object, and builds a state object with the same shape.
32427 */
32428
32429
32430 function combineReducers(reducers) {
32431 var reducerKeys = Object.keys(reducers);
32432 var finalReducers = {};
32433
32434 for (var i = 0; i < reducerKeys.length; i++) {
32435 var key = reducerKeys[i];
32436
32437 if (true) {
32438 if (typeof reducers[key] === 'undefined') {
32439 warning("No reducer provided for key \"" + key + "\"");
32440 }
32441 }
32442
32443 if (typeof reducers[key] === 'function') {
32444 finalReducers[key] = reducers[key];
32445 }
32446 }
32447
32448 var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
32449 // keys multiple times.
32450
32451 var unexpectedKeyCache;
32452
32453 if (true) {
32454 unexpectedKeyCache = {};
32455 }
32456
32457 var shapeAssertionError;
32458
32459 try {
32460 assertReducerShape(finalReducers);
32461 } catch (e) {
32462 shapeAssertionError = e;
32463 }
32464
32465 return function combination(state, action) {
32466 if (state === void 0) {
32467 state = {};
32468 }
32469
32470 if (shapeAssertionError) {
32471 throw shapeAssertionError;
32472 }
32473
32474 if (true) {
32475 var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
32476
32477 if (warningMessage) {
32478 warning(warningMessage);
32479 }
32480 }
32481
32482 var hasChanged = false;
32483 var nextState = {};
32484
32485 for (var _i = 0; _i < finalReducerKeys.length; _i++) {
32486 var _key = finalReducerKeys[_i];
32487 var reducer = finalReducers[_key];
32488 var previousStateForKey = state[_key];
32489 var nextStateForKey = reducer(previousStateForKey, action);
32490
32491 if (typeof nextStateForKey === 'undefined') {
32492 var actionType = action && action.type;
32493 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.");
32494 }
32495
32496 nextState[_key] = nextStateForKey;
32497 hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
32498 }
32499
32500 hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
32501 return hasChanged ? nextState : state;
32502 };
32503 }
32504
32505 function bindActionCreator(actionCreator, dispatch) {
32506 return function () {
32507 return dispatch(actionCreator.apply(this, arguments));
32508 };
32509 }
32510 /**
32511 * Turns an object whose values are action creators, into an object with the
32512 * same keys, but with every function wrapped into a `dispatch` call so they
32513 * may be invoked directly. This is just a convenience method, as you can call
32514 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
32515 *
32516 * For convenience, you can also pass an action creator as the first argument,
32517 * and get a dispatch wrapped function in return.
32518 *
32519 * @param {Function|Object} actionCreators An object whose values are action
32520 * creator functions. One handy way to obtain it is to use ES6 `import * as`
32521 * syntax. You may also pass a single function.
32522 *
32523 * @param {Function} dispatch The `dispatch` function available on your Redux
32524 * store.
32525 *
32526 * @returns {Function|Object} The object mimicking the original object, but with
32527 * every action creator wrapped into the `dispatch` call. If you passed a
32528 * function as `actionCreators`, the return value will also be a single
32529 * function.
32530 */
32531
32532
32533 function bindActionCreators(actionCreators, dispatch) {
32534 if (typeof actionCreators === 'function') {
32535 return bindActionCreator(actionCreators, dispatch);
32536 }
32537
32538 if (typeof actionCreators !== 'object' || actionCreators === null) {
32539 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\"?");
32540 }
32541
32542 var boundActionCreators = {};
32543
32544 for (var key in actionCreators) {
32545 var actionCreator = actionCreators[key];
32546
32547 if (typeof actionCreator === 'function') {
32548 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
32549 }
32550 }
32551
32552 return boundActionCreators;
32553 }
32554
32555 /**
32556 * Composes single-argument functions from right to left. The rightmost
32557 * function can take multiple arguments as it provides the signature for
32558 * the resulting composite function.
32559 *
32560 * @param {...Function} funcs The functions to compose.
32561 * @returns {Function} A function obtained by composing the argument functions
32562 * from right to left. For example, compose(f, g, h) is identical to doing
32563 * (...args) => f(g(h(...args))).
32564 */
32565 function compose() {
32566 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
32567 funcs[_key] = arguments[_key];
32568 }
32569
32570 if (funcs.length === 0) {
32571 return function (arg) {
32572 return arg;
32573 };
32574 }
32575
32576 if (funcs.length === 1) {
32577 return funcs[0];
32578 }
32579
32580 return funcs.reduce(function (a, b) {
32581 return function () {
32582 return a(b.apply(void 0, arguments));
32583 };
32584 });
32585 }
32586
32587 /**
32588 * Creates a store enhancer that applies middleware to the dispatch method
32589 * of the Redux store. This is handy for a variety of tasks, such as expressing
32590 * asynchronous actions in a concise manner, or logging every action payload.
32591 *
32592 * See `redux-thunk` package as an example of the Redux middleware.
32593 *
32594 * Because middleware is potentially asynchronous, this should be the first
32595 * store enhancer in the composition chain.
32596 *
32597 * Note that each middleware will be given the `dispatch` and `getState` functions
32598 * as named arguments.
32599 *
32600 * @param {...Function} middlewares The middleware chain to be applied.
32601 * @returns {Function} A store enhancer applying the middleware.
32602 */
32603
32604 function applyMiddleware() {
32605 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
32606 middlewares[_key] = arguments[_key];
32607 }
32608
32609 return function (createStore) {
32610 return function () {
32611 var store = createStore.apply(void 0, arguments);
32612
32613 var _dispatch = function dispatch() {
32614 throw new Error( false ? 0 : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
32615 };
32616
32617 var middlewareAPI = {
32618 getState: store.getState,
32619 dispatch: function dispatch() {
32620 return _dispatch.apply(void 0, arguments);
32621 }
32622 };
32623 var chain = middlewares.map(function (middleware) {
32624 return middleware(middlewareAPI);
32625 });
32626 _dispatch = compose.apply(void 0, chain)(store.dispatch);
32627 return (0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])((0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])({}, store), {}, {
32628 dispatch: _dispatch
32629 });
32630 };
32631 };
32632 }
32633
32634
32635
32636
32637 /***/ }),
32638
32639 /***/ "../node_modules/reselect/es/defaultMemoize.js":
32640 /*!*****************************************************!*\
32641 !*** ../node_modules/reselect/es/defaultMemoize.js ***!
32642 \*****************************************************/
32643 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32644
32645 "use strict";
32646 __webpack_require__.r(__webpack_exports__);
32647 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32648 /* harmony export */ createCacheKeyComparator: () => (/* binding */ createCacheKeyComparator),
32649 /* harmony export */ defaultEqualityCheck: () => (/* binding */ defaultEqualityCheck),
32650 /* harmony export */ defaultMemoize: () => (/* binding */ defaultMemoize)
32651 /* harmony export */ });
32652 // Cache implementation based on Erik Rasmussen's `lru-memoize`:
32653 // https://github.com/erikras/lru-memoize
32654 var NOT_FOUND = 'NOT_FOUND';
32655
32656 function createSingletonCache(equals) {
32657 var entry;
32658 return {
32659 get: function get(key) {
32660 if (entry && equals(entry.key, key)) {
32661 return entry.value;
32662 }
32663
32664 return NOT_FOUND;
32665 },
32666 put: function put(key, value) {
32667 entry = {
32668 key: key,
32669 value: value
32670 };
32671 },
32672 getEntries: function getEntries() {
32673 return entry ? [entry] : [];
32674 },
32675 clear: function clear() {
32676 entry = undefined;
32677 }
32678 };
32679 }
32680
32681 function createLruCache(maxSize, equals) {
32682 var entries = [];
32683
32684 function get(key) {
32685 var cacheIndex = entries.findIndex(function (entry) {
32686 return equals(key, entry.key);
32687 }); // We found a cached entry
32688
32689 if (cacheIndex > -1) {
32690 var entry = entries[cacheIndex]; // Cached entry not at top of cache, move it to the top
32691
32692 if (cacheIndex > 0) {
32693 entries.splice(cacheIndex, 1);
32694 entries.unshift(entry);
32695 }
32696
32697 return entry.value;
32698 } // No entry found in cache, return sentinel
32699
32700
32701 return NOT_FOUND;
32702 }
32703
32704 function put(key, value) {
32705 if (get(key) === NOT_FOUND) {
32706 // TODO Is unshift slow?
32707 entries.unshift({
32708 key: key,
32709 value: value
32710 });
32711
32712 if (entries.length > maxSize) {
32713 entries.pop();
32714 }
32715 }
32716 }
32717
32718 function getEntries() {
32719 return entries;
32720 }
32721
32722 function clear() {
32723 entries = [];
32724 }
32725
32726 return {
32727 get: get,
32728 put: put,
32729 getEntries: getEntries,
32730 clear: clear
32731 };
32732 }
32733
32734 var defaultEqualityCheck = function defaultEqualityCheck(a, b) {
32735 return a === b;
32736 };
32737 function createCacheKeyComparator(equalityCheck) {
32738 return function areArgumentsShallowlyEqual(prev, next) {
32739 if (prev === null || next === null || prev.length !== next.length) {
32740 return false;
32741 } // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
32742
32743
32744 var length = prev.length;
32745
32746 for (var i = 0; i < length; i++) {
32747 if (!equalityCheck(prev[i], next[i])) {
32748 return false;
32749 }
32750 }
32751
32752 return true;
32753 };
32754 }
32755 // defaultMemoize now supports a configurable cache size with LRU behavior,
32756 // and optional comparison of the result value with existing values
32757 function defaultMemoize(func, equalityCheckOrOptions) {
32758 var providedOptions = typeof equalityCheckOrOptions === 'object' ? equalityCheckOrOptions : {
32759 equalityCheck: equalityCheckOrOptions
32760 };
32761 var _providedOptions$equa = providedOptions.equalityCheck,
32762 equalityCheck = _providedOptions$equa === void 0 ? defaultEqualityCheck : _providedOptions$equa,
32763 _providedOptions$maxS = providedOptions.maxSize,
32764 maxSize = _providedOptions$maxS === void 0 ? 1 : _providedOptions$maxS,
32765 resultEqualityCheck = providedOptions.resultEqualityCheck;
32766 var comparator = createCacheKeyComparator(equalityCheck);
32767 var cache = maxSize === 1 ? createSingletonCache(comparator) : createLruCache(maxSize, comparator); // we reference arguments instead of spreading them for performance reasons
32768
32769 function memoized() {
32770 var value = cache.get(arguments);
32771
32772 if (value === NOT_FOUND) {
32773 // @ts-ignore
32774 value = func.apply(null, arguments);
32775
32776 if (resultEqualityCheck) {
32777 var entries = cache.getEntries();
32778 var matchingEntry = entries.find(function (entry) {
32779 return resultEqualityCheck(entry.value, value);
32780 });
32781
32782 if (matchingEntry) {
32783 value = matchingEntry.value;
32784 }
32785 }
32786
32787 cache.put(arguments, value);
32788 }
32789
32790 return value;
32791 }
32792
32793 memoized.clearCache = function () {
32794 return cache.clear();
32795 };
32796
32797 return memoized;
32798 }
32799
32800 /***/ }),
32801
32802 /***/ "../node_modules/reselect/es/index.js":
32803 /*!********************************************!*\
32804 !*** ../node_modules/reselect/es/index.js ***!
32805 \********************************************/
32806 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32807
32808 "use strict";
32809 __webpack_require__.r(__webpack_exports__);
32810 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32811 /* harmony export */ createSelector: () => (/* binding */ createSelector),
32812 /* harmony export */ createSelectorCreator: () => (/* binding */ createSelectorCreator),
32813 /* harmony export */ createStructuredSelector: () => (/* binding */ createStructuredSelector),
32814 /* harmony export */ defaultEqualityCheck: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultEqualityCheck),
32815 /* harmony export */ defaultMemoize: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize)
32816 /* harmony export */ });
32817 /* harmony import */ var _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultMemoize */ "../node_modules/reselect/es/defaultMemoize.js");
32818
32819
32820
32821 function getDependencies(funcs) {
32822 var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
32823
32824 if (!dependencies.every(function (dep) {
32825 return typeof dep === 'function';
32826 })) {
32827 var dependencyTypes = dependencies.map(function (dep) {
32828 return typeof dep === 'function' ? "function " + (dep.name || 'unnamed') + "()" : typeof dep;
32829 }).join(', ');
32830 throw new Error("createSelector expects all input-selectors to be functions, but received the following types: [" + dependencyTypes + "]");
32831 }
32832
32833 return dependencies;
32834 }
32835
32836 function createSelectorCreator(memoize) {
32837 for (var _len = arguments.length, memoizeOptionsFromArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
32838 memoizeOptionsFromArgs[_key - 1] = arguments[_key];
32839 }
32840
32841 var createSelector = function createSelector() {
32842 for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
32843 funcs[_key2] = arguments[_key2];
32844 }
32845
32846 var _recomputations = 0;
32847
32848 var _lastResult; // Due to the intricacies of rest params, we can't do an optional arg after `...funcs`.
32849 // So, start by declaring the default value here.
32850 // (And yes, the words 'memoize' and 'options' appear too many times in this next sequence.)
32851
32852
32853 var directlyPassedOptions = {
32854 memoizeOptions: undefined
32855 }; // Normally, the result func or "output selector" is the last arg
32856
32857 var resultFunc = funcs.pop(); // If the result func is actually an _object_, assume it's our options object
32858
32859 if (typeof resultFunc === 'object') {
32860 directlyPassedOptions = resultFunc; // and pop the real result func off
32861
32862 resultFunc = funcs.pop();
32863 }
32864
32865 if (typeof resultFunc !== 'function') {
32866 throw new Error("createSelector expects an output function after the inputs, but received: [" + typeof resultFunc + "]");
32867 } // Determine which set of options we're using. Prefer options passed directly,
32868 // but fall back to options given to createSelectorCreator.
32869
32870
32871 var _directlyPassedOption = directlyPassedOptions,
32872 _directlyPassedOption2 = _directlyPassedOption.memoizeOptions,
32873 memoizeOptions = _directlyPassedOption2 === void 0 ? memoizeOptionsFromArgs : _directlyPassedOption2; // Simplifying assumption: it's unlikely that the first options arg of the provided memoizer
32874 // is an array. In most libs I've looked at, it's an equality function or options object.
32875 // Based on that, if `memoizeOptions` _is_ an array, we assume it's a full
32876 // user-provided array of options. Otherwise, it must be just the _first_ arg, and so
32877 // we wrap it in an array so we can apply it.
32878
32879 var finalMemoizeOptions = Array.isArray(memoizeOptions) ? memoizeOptions : [memoizeOptions];
32880 var dependencies = getDependencies(funcs);
32881 var memoizedResultFunc = memoize.apply(void 0, [function recomputationWrapper() {
32882 _recomputations++; // apply arguments instead of spreading for performance.
32883
32884 return resultFunc.apply(null, arguments);
32885 }].concat(finalMemoizeOptions)); // If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
32886
32887 var selector = memoize(function dependenciesChecker() {
32888 var params = [];
32889 var length = dependencies.length;
32890
32891 for (var i = 0; i < length; i++) {
32892 // apply arguments instead of spreading and mutate a local list of params for performance.
32893 // @ts-ignore
32894 params.push(dependencies[i].apply(null, arguments));
32895 } // apply arguments instead of spreading for performance.
32896
32897
32898 _lastResult = memoizedResultFunc.apply(null, params);
32899 return _lastResult;
32900 });
32901 Object.assign(selector, {
32902 resultFunc: resultFunc,
32903 memoizedResultFunc: memoizedResultFunc,
32904 dependencies: dependencies,
32905 lastResult: function lastResult() {
32906 return _lastResult;
32907 },
32908 recomputations: function recomputations() {
32909 return _recomputations;
32910 },
32911 resetRecomputations: function resetRecomputations() {
32912 return _recomputations = 0;
32913 }
32914 });
32915 return selector;
32916 }; // @ts-ignore
32917
32918
32919 return createSelector;
32920 }
32921 var createSelector = /* #__PURE__ */createSelectorCreator(_defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize);
32922 // Manual definition of state and output arguments
32923 var createStructuredSelector = function createStructuredSelector(selectors, selectorCreator) {
32924 if (selectorCreator === void 0) {
32925 selectorCreator = createSelector;
32926 }
32927
32928 if (typeof selectors !== 'object') {
32929 throw new Error('createStructuredSelector expects first argument to be an object ' + ("where each property is a selector, instead received a " + typeof selectors));
32930 }
32931
32932 var objectKeys = Object.keys(selectors);
32933 var resultSelector = selectorCreator( // @ts-ignore
32934 objectKeys.map(function (key) {
32935 return selectors[key];
32936 }), function () {
32937 for (var _len3 = arguments.length, values = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
32938 values[_key3] = arguments[_key3];
32939 }
32940
32941 return values.reduce(function (composition, value, index) {
32942 composition[objectKeys[index]] = value;
32943 return composition;
32944 }, {});
32945 });
32946 return resultSelector;
32947 };
32948
32949 /***/ }),
32950
32951 /***/ "@wordpress/i18n":
32952 /*!**************************!*\
32953 !*** external "wp.i18n" ***!
32954 \**************************/
32955 /***/ ((module) => {
32956
32957 "use strict";
32958 module.exports = wp.i18n;
32959
32960 /***/ })
32961
32962 /******/ });
32963 /************************************************************************/
32964 /******/ // The module cache
32965 /******/ var __webpack_module_cache__ = {};
32966 /******/
32967 /******/ // The require function
32968 /******/ function __webpack_require__(moduleId) {
32969 /******/ // Check if module is in cache
32970 /******/ var cachedModule = __webpack_module_cache__[moduleId];
32971 /******/ if (cachedModule !== undefined) {
32972 /******/ return cachedModule.exports;
32973 /******/ }
32974 /******/ // Create a new module (and put it into the cache)
32975 /******/ var module = __webpack_module_cache__[moduleId] = {
32976 /******/ // no module.id needed
32977 /******/ // no module.loaded needed
32978 /******/ exports: {}
32979 /******/ };
32980 /******/
32981 /******/ // Execute the module function
32982 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
32983 /******/
32984 /******/ // Return the exports of the module
32985 /******/ return module.exports;
32986 /******/ }
32987 /******/
32988 /************************************************************************/
32989 /******/ /* webpack/runtime/define property getters */
32990 /******/ (() => {
32991 /******/ // define getter functions for harmony exports
32992 /******/ __webpack_require__.d = (exports, definition) => {
32993 /******/ for(var key in definition) {
32994 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
32995 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
32996 /******/ }
32997 /******/ }
32998 /******/ };
32999 /******/ })();
33000 /******/
33001 /******/ /* webpack/runtime/global */
33002 /******/ (() => {
33003 /******/ __webpack_require__.g = (function() {
33004 /******/ if (typeof globalThis === 'object') return globalThis;
33005 /******/ try {
33006 /******/ return this || new Function('return this')();
33007 /******/ } catch (e) {
33008 /******/ if (typeof window === 'object') return window;
33009 /******/ }
33010 /******/ })();
33011 /******/ })();
33012 /******/
33013 /******/ /* webpack/runtime/hasOwnProperty shorthand */
33014 /******/ (() => {
33015 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
33016 /******/ })();
33017 /******/
33018 /******/ /* webpack/runtime/make namespace object */
33019 /******/ (() => {
33020 /******/ // define __esModule on exports
33021 /******/ __webpack_require__.r = (exports) => {
33022 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
33023 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
33024 /******/ }
33025 /******/ Object.defineProperty(exports, '__esModule', { value: true });
33026 /******/ };
33027 /******/ })();
33028 /******/
33029 /************************************************************************/
33030 var __webpack_exports__ = {};
33031 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
33032 (() => {
33033 "use strict";
33034 /*!******************************************!*\
33035 !*** ../core/common/assets/js/common.js ***!
33036 \******************************************/
33037
33038
33039 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
33040 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
33041 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
33042 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
33043 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
33044 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
33045 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
33046 var _helpers = _interopRequireDefault(__webpack_require__(/*! ./utils/helpers */ "../core/common/assets/js/utils/helpers.js"));
33047 var _storage = _interopRequireDefault(__webpack_require__(/*! ./utils/storage */ "../core/common/assets/js/utils/storage.js"));
33048 var _debug = _interopRequireDefault(__webpack_require__(/*! ./utils/debug */ "../core/common/assets/js/utils/debug.js"));
33049 var _ajax = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/ajax/assets/js/ajax */ "../core/common/modules/ajax/assets/js/ajax.js"));
33050 var _finder = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/finder/assets/js/finder */ "../core/common/modules/finder/assets/js/finder.js"));
33051 var _connect = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/connect/assets/js/connect */ "../core/common/modules/connect/assets/js/connect.js"));
33052 var _component = _interopRequireDefault(__webpack_require__(/*! ./components/wordpress/component */ "../core/common/assets/js/components/wordpress/component.js"));
33053 var _component2 = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/data/component */ "../core/common/modules/event-tracker/assets/js/data/component.js"));
33054 var _events = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/events */ "../core/common/modules/event-tracker/assets/js/events.js"));
33055 var _module = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/events-manager/assets/js/module */ "../core/common/modules/events-manager/assets/js/module.js"));
33056 var _notifications = _interopRequireDefault(__webpack_require__(/*! elementor-utils/notifications */ "../assets/dev/js/utils/notifications.js"));
33057 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)); }
33058 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
33059 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; }
33060 var ElementorCommonApp = /*#__PURE__*/function (_elementorModules$Vie) {
33061 function ElementorCommonApp() {
33062 (0, _classCallCheck2.default)(this, ElementorCommonApp);
33063 return _callSuper(this, ElementorCommonApp, arguments);
33064 }
33065 (0, _inherits2.default)(ElementorCommonApp, _elementorModules$Vie);
33066 return (0, _createClass2.default)(ElementorCommonApp, [{
33067 key: "setMarionetteTemplateCompiler",
33068 value: function setMarionetteTemplateCompiler() {
33069 Marionette.TemplateCache.prototype.compileTemplate = function (rawTemplate, options) {
33070 options = {
33071 evaluate: /<#([\s\S]+?)#>/g,
33072 interpolate: /{{{([\s\S]+?)}}}/g,
33073 escape: /{{([^}]+?)}}(?!})/g
33074 };
33075 return _.template(rawTemplate, options);
33076 };
33077 }
33078 }, {
33079 key: "getDefaultElements",
33080 value: function getDefaultElements() {
33081 return {
33082 $window: jQuery(window),
33083 $document: jQuery(document),
33084 $body: jQuery(document.body)
33085 };
33086 }
33087 }, {
33088 key: "initComponents",
33089 value: function initComponents() {
33090 this.events = new _events.default();
33091 this.eventsManager = new _module.default();
33092 this.debug = new _debug.default();
33093 this.helpers = new _helpers.default();
33094 this.storage = new _storage.default();
33095 this.dialogsManager = new DialogsManager.Instance();
33096 this.notifications = new _notifications.default();
33097 this.api = window.$e;
33098 $e.components.register(new _component2.default());
33099 elementorCommon.elements.$window.on('elementor:init-components', function () {
33100 $e.components.register(new _component.default());
33101 });
33102 this.initModules();
33103 }
33104 }, {
33105 key: "initModules",
33106 value: function initModules() {
33107 var _this = this;
33108 var activeModules = this.config.activeModules;
33109 var modules = {
33110 ajax: _ajax.default,
33111 finder: _finder.default,
33112 connect: _connect.default
33113 };
33114 activeModules.forEach(function (name) {
33115 if (modules[name]) {
33116 _this[name] = new modules[name](_this.config[name]);
33117 }
33118 });
33119 }
33120 }, {
33121 key: "compileArrayTemplateArgs",
33122 value: function compileArrayTemplateArgs(template, templateArgs) {
33123 return template.replace(/%(?:(\d+)\$)?s/g, function (match, number) {
33124 if (!number) {
33125 number = 1;
33126 }
33127 number--;
33128 return undefined !== templateArgs[number] ? templateArgs[number] : match;
33129 });
33130 }
33131 }, {
33132 key: "compileObjectTemplateArgs",
33133 value: function compileObjectTemplateArgs(template, templateArgs) {
33134 return template.replace(/{{(?:([ \w]+))}}/g, function (match, name) {
33135 return templateArgs[name] ? templateArgs[name] : match;
33136 });
33137 }
33138 }, {
33139 key: "compileTemplate",
33140 value: function compileTemplate(template, templateArgs) {
33141 return jQuery.isPlainObject(templateArgs) ? this.compileObjectTemplateArgs(template, templateArgs) : this.compileArrayTemplateArgs(template, templateArgs);
33142 }
33143 }, {
33144 key: "translate",
33145 value: function translate(stringKey, context, templateArgs, i18nStack) {
33146 if (context) {
33147 i18nStack = this.config[context].i18n;
33148 }
33149 if (!i18nStack) {
33150 i18nStack = this.config.i18n;
33151 }
33152 var string = i18nStack[stringKey];
33153 if (undefined === string) {
33154 string = stringKey;
33155 }
33156 if (templateArgs) {
33157 string = this.compileTemplate(string, templateArgs);
33158 }
33159 return string;
33160 }
33161 }, {
33162 key: "onInit",
33163 value: function onInit() {
33164 _superPropGet(ElementorCommonApp, "onInit", this, 3)([]);
33165 this.config = elementorCommonConfig;
33166 this.setMarionetteTemplateCompiler();
33167 }
33168 }]);
33169 }(elementorModules.ViewModule);
33170 window.elementorCommon = new ElementorCommonApp();
33171 elementorCommon.initComponents();
33172 })();
33173
33174 /******/ })()
33175 ;
33176 //# sourceMappingURL=common.js.map