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

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

33,685 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/editor-one-events.js":
5 /*!**********************************************************!*\
6 !*** ../assets/dev/js/editor/utils/editor-one-events.js ***!
7 \**********************************************************/
8 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
9
10 "use strict";
11
12
13 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
14 Object.defineProperty(exports, "__esModule", ({
15 value: true
16 }));
17 exports["default"] = exports.createDebouncedWidgetPanelSearch = exports.createDebouncedFinderSearch = exports.EditorOneEventManager = void 0;
18 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
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 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; }
22 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; }
23 var EditorOneEventManager = exports.EditorOneEventManager = /*#__PURE__*/function () {
24 function EditorOneEventManager() {
25 (0, _classCallCheck2.default)(this, EditorOneEventManager);
26 }
27 return (0, _createClass2.default)(EditorOneEventManager, null, [{
28 key: "getEventsManager",
29 value: function getEventsManager() {
30 var _elementorCommon;
31 return (_elementorCommon = elementorCommon) === null || _elementorCommon === void 0 ? void 0 : _elementorCommon.eventsManager;
32 }
33 }, {
34 key: "getConfig",
35 value: function getConfig() {
36 var _this$getEventsManage;
37 return (_this$getEventsManage = this.getEventsManager()) === null || _this$getEventsManage === void 0 ? void 0 : _this$getEventsManage.config;
38 }
39 }, {
40 key: "canSendEvents",
41 value: function canSendEvents() {
42 var _elementorCommon2;
43 return ((_elementorCommon2 = elementorCommon) === null || _elementorCommon2 === void 0 || (_elementorCommon2 = _elementorCommon2.config) === null || _elementorCommon2 === void 0 || (_elementorCommon2 = _elementorCommon2.editor_events) === null || _elementorCommon2 === void 0 ? void 0 : _elementorCommon2.can_send_events) || false;
44 }
45 }, {
46 key: "isEventsManagerAvailable",
47 value: function isEventsManagerAvailable() {
48 var eventsManager = this.getEventsManager();
49 return eventsManager && 'function' === typeof eventsManager.dispatchEvent;
50 }
51 }, {
52 key: "dispatchEvent",
53 value: function dispatchEvent(eventName, payload) {
54 if (!this.isEventsManagerAvailable() || !this.canSendEvents()) {
55 return false;
56 }
57 try {
58 return this.getEventsManager().dispatchEvent(eventName, payload);
59 } catch (error) {
60 return false;
61 }
62 }
63 }, {
64 key: "toLowerSnake",
65 value: function toLowerSnake(value) {
66 if (!value || 'string' !== typeof value) {
67 return value;
68 }
69 return value.replace(/\s+/g, '_').toLowerCase();
70 }
71 }, {
72 key: "decodeHtmlEntities",
73 value: function decodeHtmlEntities(text) {
74 if (!text || 'string' !== typeof text) {
75 return text;
76 }
77 var doc = new DOMParser().parseFromString(text, 'text/html');
78 return doc.body.textContent || text;
79 }
80 }, {
81 key: "isInEditorContext",
82 value: function isInEditorContext() {
83 var _window$elementor;
84 return 'undefined' !== typeof window.elementor && !!((_window$elementor = window.elementor) !== null && _window$elementor !== void 0 && _window$elementor.documents);
85 }
86 }, {
87 key: "getFinderContext",
88 value: function getFinderContext() {
89 var _config$appTypes, _config$appTypes2, _config$locations, _config$locations2;
90 var config = this.getConfig();
91 var isEditor = this.isInEditorContext();
92 return {
93 windowName: isEditor ? config === null || config === void 0 || (_config$appTypes = config.appTypes) === null || _config$appTypes === void 0 ? void 0 : _config$appTypes.editor : config === null || config === void 0 || (_config$appTypes2 = config.appTypes) === null || _config$appTypes2 === void 0 ? void 0 : _config$appTypes2.wpAdmin,
94 targetLocation: this.toLowerSnake(isEditor ? config === null || config === void 0 || (_config$locations = config.locations) === null || _config$locations === void 0 ? void 0 : _config$locations.topBar : config === null || config === void 0 || (_config$locations2 = config.locations) === null || _config$locations2 === void 0 ? void 0 : _config$locations2.sidebar)
95 };
96 }
97 }, {
98 key: "createBasePayload",
99 value: function createBasePayload() {
100 var _config$appTypes$edit, _config$appTypes3, _config$appTypes$edit2, _config$appTypes4;
101 var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
102 var config = this.getConfig();
103 return _objectSpread({
104 app_type: (_config$appTypes$edit = config === null || config === void 0 || (_config$appTypes3 = config.appTypes) === null || _config$appTypes3 === void 0 ? void 0 : _config$appTypes3.editor) !== null && _config$appTypes$edit !== void 0 ? _config$appTypes$edit : 'editor',
105 window_name: (_config$appTypes$edit2 = config === null || config === void 0 || (_config$appTypes4 = config.appTypes) === null || _config$appTypes4 === void 0 ? void 0 : _config$appTypes4.editor) !== null && _config$appTypes$edit2 !== void 0 ? _config$appTypes$edit2 : 'editor'
106 }, overrides);
107 }
108 }, {
109 key: "sendTopBarPublishDropdown",
110 value: function sendTopBarPublishDropdown(targetName) {
111 var _config$names, _config$triggers, _config$targetTypes, _config$interactionRe, _config$locations3, _config$secondaryLoca, _config$targetTypes2;
112 var config = this.getConfig();
113 return this.dispatchEvent(config === null || config === void 0 || (_config$names = config.names) === null || _config$names === void 0 || (_config$names = _config$names.editorOne) === null || _config$names === void 0 ? void 0 : _config$names.topBarPublishDropdown, this.createBasePayload({
114 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers = config.triggers) === null || _config$triggers === void 0 ? void 0 : _config$triggers.click),
115 target_type: config === null || config === void 0 || (_config$targetTypes = config.targetTypes) === null || _config$targetTypes === void 0 ? void 0 : _config$targetTypes.dropdownItem,
116 target_name: targetName,
117 interaction_result: config === null || config === void 0 || (_config$interactionRe = config.interactionResults) === null || _config$interactionRe === void 0 ? void 0 : _config$interactionRe.actionSelected,
118 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations3 = config.locations) === null || _config$locations3 === void 0 ? void 0 : _config$locations3.topBar),
119 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca = config.secondaryLocations) === null || _config$secondaryLoca === void 0 ? void 0 : _config$secondaryLoca.publishDropdown),
120 location_l2: config === null || config === void 0 || (_config$targetTypes2 = config.targetTypes) === null || _config$targetTypes2 === void 0 ? void 0 : _config$targetTypes2.dropdownItem,
121 interaction_description: 'User selected an action from the publish dropdown'
122 }));
123 }
124 }, {
125 key: "sendTopBarPageList",
126 value: function sendTopBarPageList(targetName) {
127 var _config$names2, _config$triggers2, _config$targetTypes3, _config$interactionRe2, _config$interactionRe3, _config$locations4, _config$secondaryLoca2, _config$targetTypes4;
128 var isCreate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
129 var config = this.getConfig();
130 return this.dispatchEvent(config === null || config === void 0 || (_config$names2 = config.names) === null || _config$names2 === void 0 || (_config$names2 = _config$names2.editorOne) === null || _config$names2 === void 0 ? void 0 : _config$names2.topBarPageList, this.createBasePayload({
131 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers2 = config.triggers) === null || _config$triggers2 === void 0 ? void 0 : _config$triggers2.click),
132 target_type: config === null || config === void 0 || (_config$targetTypes3 = config.targetTypes) === null || _config$targetTypes3 === void 0 ? void 0 : _config$targetTypes3.dropdownItem,
133 target_name: targetName,
134 interaction_result: isCreate ? config === null || config === void 0 || (_config$interactionRe2 = config.interactionResults) === null || _config$interactionRe2 === void 0 ? void 0 : _config$interactionRe2.create : config === null || config === void 0 || (_config$interactionRe3 = config.interactionResults) === null || _config$interactionRe3 === void 0 ? void 0 : _config$interactionRe3.navigate,
135 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations4 = config.locations) === null || _config$locations4 === void 0 ? void 0 : _config$locations4.topBar),
136 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca2 = config.secondaryLocations) === null || _config$secondaryLoca2 === void 0 ? void 0 : _config$secondaryLoca2.pageListDropdown),
137 location_l2: config === null || config === void 0 || (_config$targetTypes4 = config.targetTypes) === null || _config$targetTypes4 === void 0 ? void 0 : _config$targetTypes4.dropdownItem,
138 interaction_description: 'User selected an action from the page list dropdown'
139 }));
140 }
141 }, {
142 key: "sendSiteSettingsSession",
143 value: function sendSiteSettingsSession(_ref) {
144 var _config$names3, _config$triggers3, _config$interactionRe4, _config$locations5, _config$secondaryLoca3;
145 var targetType = _ref.targetType,
146 _ref$visitedItems = _ref.visitedItems,
147 visitedItems = _ref$visitedItems === void 0 ? [] : _ref$visitedItems,
148 _ref$savedItems = _ref.savedItems,
149 savedItems = _ref$savedItems === void 0 ? [] : _ref$savedItems,
150 state = _ref.state;
151 var config = this.getConfig();
152 return this.dispatchEvent(config === null || config === void 0 || (_config$names3 = config.names) === null || _config$names3 === void 0 || (_config$names3 = _config$names3.editorOne) === null || _config$names3 === void 0 ? void 0 : _config$names3.siteSettingsSession, this.createBasePayload({
153 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers3 = config.triggers) === null || _config$triggers3 === void 0 ? void 0 : _config$triggers3.click),
154 target_type: targetType,
155 target_name: 'site_settings',
156 interaction_result: config === null || config === void 0 || (_config$interactionRe4 = config.interactionResults) === null || _config$interactionRe4 === void 0 ? void 0 : _config$interactionRe4.sessionEnd,
157 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations5 = config.locations) === null || _config$locations5 === void 0 ? void 0 : _config$locations5.leftPanel),
158 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca3 = config.secondaryLocations) === null || _config$secondaryLoca3 === void 0 ? void 0 : _config$secondaryLoca3.siteSettings),
159 interaction_description: 'Records areas visited as part of the site setting session',
160 metadata: {
161 visited_items: visitedItems,
162 saved_items: savedItems
163 },
164 state: state
165 }));
166 }
167 }, {
168 key: "sendELibraryNav",
169 value: function sendELibraryNav(tabName) {
170 var _config$names4, _config$triggers4, _config$targetTypes5, _config$interactionRe5, _config$locations6, _config$secondaryLoca4;
171 var config = this.getConfig();
172 return this.dispatchEvent(config === null || config === void 0 || (_config$names4 = config.names) === null || _config$names4 === void 0 || (_config$names4 = _config$names4.editorOne) === null || _config$names4 === void 0 ? void 0 : _config$names4.eLibraryNav, this.createBasePayload({
173 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers4 = config.triggers) === null || _config$triggers4 === void 0 ? void 0 : _config$triggers4.tabSelect),
174 target_type: config === null || config === void 0 || (_config$targetTypes5 = config.targetTypes) === null || _config$targetTypes5 === void 0 ? void 0 : _config$targetTypes5.tab,
175 target_name: this.toLowerSnake(tabName),
176 interaction_result: config === null || config === void 0 || (_config$interactionRe5 = config.interactionResults) === null || _config$interactionRe5 === void 0 ? void 0 : _config$interactionRe5.tabChanged,
177 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations6 = config.locations) === null || _config$locations6 === void 0 ? void 0 : _config$locations6.elementorLibrary),
178 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca4 = config.secondaryLocations) === null || _config$secondaryLoca4 === void 0 ? void 0 : _config$secondaryLoca4.libraryTabs),
179 interaction_description: 'User navigates within elementor library'
180 }));
181 }
182 }, {
183 key: "sendELibraryInsert",
184 value: function sendELibraryInsert(_ref2) {
185 var _config$triggers5, _config$targetTypes6, _config$interactionRe6, _config$locations7, _config$secondaryLoca5, _config$names5;
186 var assetId = _ref2.assetId,
187 assetName = _ref2.assetName,
188 libraryType = _ref2.libraryType,
189 _ref2$proRequired = _ref2.proRequired,
190 proRequired = _ref2$proRequired === void 0 ? false : _ref2$proRequired;
191 var config = this.getConfig();
192 var payload = this.createBasePayload({
193 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers5 = config.triggers) === null || _config$triggers5 === void 0 ? void 0 : _config$triggers5.insert),
194 target_type: config === null || config === void 0 || (_config$targetTypes6 = config.targetTypes) === null || _config$targetTypes6 === void 0 ? void 0 : _config$targetTypes6.button,
195 target_name: String(assetId),
196 interaction_result: config === null || config === void 0 || (_config$interactionRe6 = config.interactionResults) === null || _config$interactionRe6 === void 0 ? void 0 : _config$interactionRe6.assetInserted,
197 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations7 = config.locations) === null || _config$locations7 === void 0 ? void 0 : _config$locations7.elementorLibrary),
198 location_l1: this.toLowerSnake(libraryType),
199 location_l2: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca5 = config.secondaryLocations) === null || _config$secondaryLoca5 === void 0 ? void 0 : _config$secondaryLoca5.assetCard),
200 interaction_description: 'User inserts block/pages from elementor library',
201 metadata: {
202 template_id: String(assetId),
203 template_name: this.decodeHtmlEntities(assetName) || ''
204 }
205 });
206 if (proRequired) {
207 payload.state = 'pro_plan_required';
208 }
209 return this.dispatchEvent(config === null || config === void 0 || (_config$names5 = config.names) === null || _config$names5 === void 0 || (_config$names5 = _config$names5.editorOne) === null || _config$names5 === void 0 ? void 0 : _config$names5.eLibraryInsert, payload);
210 }
211 }, {
212 key: "sendELibraryFavorite",
213 value: function sendELibraryFavorite(_ref3) {
214 var _config$triggers6, _config$targetTypes7, _config$interactionRe7, _config$locations8, _config$secondaryLoca6, _config$names6;
215 var assetId = _ref3.assetId,
216 assetName = _ref3.assetName,
217 libraryType = _ref3.libraryType,
218 isFavorite = _ref3.isFavorite,
219 _ref3$proRequired = _ref3.proRequired,
220 proRequired = _ref3$proRequired === void 0 ? false : _ref3$proRequired;
221 var config = this.getConfig();
222 var payload = this.createBasePayload({
223 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers6 = config.triggers) === null || _config$triggers6 === void 0 ? void 0 : _config$triggers6.click),
224 target_type: config === null || config === void 0 || (_config$targetTypes7 = config.targetTypes) === null || _config$targetTypes7 === void 0 ? void 0 : _config$targetTypes7.toggle,
225 target_name: String(assetId),
226 interaction_result: config === null || config === void 0 || (_config$interactionRe7 = config.interactionResults) === null || _config$interactionRe7 === void 0 ? void 0 : _config$interactionRe7.assetFavorite,
227 target_value: Boolean(isFavorite),
228 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations8 = config.locations) === null || _config$locations8 === void 0 ? void 0 : _config$locations8.elementorLibrary),
229 location_l1: this.toLowerSnake(libraryType),
230 location_l2: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca6 = config.secondaryLocations) === null || _config$secondaryLoca6 === void 0 ? void 0 : _config$secondaryLoca6.assetCard),
231 interaction_description: 'User favorite block/pages from elementor library',
232 metadata: {
233 template_id: String(assetId),
234 template_name: this.decodeHtmlEntities(assetName) || ''
235 }
236 });
237 if (proRequired) {
238 payload.state = 'pro_plan_required';
239 }
240 return this.dispatchEvent(config === null || config === void 0 || (_config$names6 = config.names) === null || _config$names6 === void 0 || (_config$names6 = _config$names6.editorOne) === null || _config$names6 === void 0 ? void 0 : _config$names6.eLibraryFavorite, payload);
241 }
242 }, {
243 key: "sendELibraryGenerateAi",
244 value: function sendELibraryGenerateAi(_ref4) {
245 var _config$names7, _config$triggers7, _config$targetTypes8, _config$interactionRe8, _config$locations9, _config$secondaryLoca7;
246 var assetId = _ref4.assetId,
247 assetName = _ref4.assetName,
248 libraryType = _ref4.libraryType;
249 var config = this.getConfig();
250 return this.dispatchEvent(config === null || config === void 0 || (_config$names7 = config.names) === null || _config$names7 === void 0 || (_config$names7 = _config$names7.editorOne) === null || _config$names7 === void 0 ? void 0 : _config$names7.eLibraryGenerateAi, this.createBasePayload({
251 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers7 = config.triggers) === null || _config$triggers7 === void 0 ? void 0 : _config$triggers7.click),
252 target_type: config === null || config === void 0 || (_config$targetTypes8 = config.targetTypes) === null || _config$targetTypes8 === void 0 ? void 0 : _config$targetTypes8.button,
253 target_name: String(assetId),
254 interaction_result: config === null || config === void 0 || (_config$interactionRe8 = config.interactionResults) === null || _config$interactionRe8 === void 0 ? void 0 : _config$interactionRe8.aiGenerate,
255 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations9 = config.locations) === null || _config$locations9 === void 0 ? void 0 : _config$locations9.elementorLibrary),
256 location_l1: this.toLowerSnake(libraryType),
257 location_l2: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca7 = config.secondaryLocations) === null || _config$secondaryLoca7 === void 0 ? void 0 : _config$secondaryLoca7.assetCard),
258 interaction_description: 'User generated block/page based on a library asset',
259 metadata: {
260 template_id: String(assetId),
261 template_name: this.decodeHtmlEntities(assetName) || ''
262 }
263 }));
264 }
265 }, {
266 key: "sendFinderSearchInput",
267 value: function sendFinderSearchInput(_ref5) {
268 var _config$triggers8, _config$targetTypes9, _config$interactionRe9, _config$interactionRe0, _config$secondaryLoca8, _config$names8;
269 var resultsCount = _ref5.resultsCount,
270 _ref5$searchTerm = _ref5.searchTerm,
271 searchTerm = _ref5$searchTerm === void 0 ? null : _ref5$searchTerm;
272 var config = this.getConfig();
273 var hasResults = resultsCount > 0;
274 var finderContext = this.getFinderContext();
275 var payload = this.createBasePayload({
276 window_name: finderContext.windowName,
277 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers8 = config.triggers) === null || _config$triggers8 === void 0 ? void 0 : _config$triggers8.typing),
278 target_type: config === null || config === void 0 || (_config$targetTypes9 = config.targetTypes) === null || _config$targetTypes9 === void 0 ? void 0 : _config$targetTypes9.searchInput,
279 target_name: 'finder',
280 interaction_result: hasResults ? config === null || config === void 0 || (_config$interactionRe9 = config.interactionResults) === null || _config$interactionRe9 === void 0 ? void 0 : _config$interactionRe9.resultsUpdated : config === null || config === void 0 || (_config$interactionRe0 = config.interactionResults) === null || _config$interactionRe0 === void 0 ? void 0 : _config$interactionRe0.noResults,
281 target_location: finderContext.targetLocation,
282 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca8 = config.secondaryLocations) === null || _config$secondaryLoca8 === void 0 ? void 0 : _config$secondaryLoca8.finder),
283 interaction_description: 'Finder search input, follows debounce behavior',
284 metadata: {
285 results_count: resultsCount
286 }
287 });
288 if (!hasResults && searchTerm) {
289 payload.metadata.search_term = searchTerm;
290 }
291 return this.dispatchEvent(config === null || config === void 0 || (_config$names8 = config.names) === null || _config$names8 === void 0 || (_config$names8 = _config$names8.editorOne) === null || _config$names8 === void 0 ? void 0 : _config$names8.finderSearchInput, payload);
292 }
293 }, {
294 key: "sendFinderResultSelect",
295 value: function sendFinderResultSelect(choice) {
296 var _config$names9, _config$triggers9, _config$targetTypes0, _config$interactionRe1, _config$secondaryLoca9, _config$secondaryLoca0;
297 var config = this.getConfig();
298 var finderContext = this.getFinderContext();
299 return this.dispatchEvent(config === null || config === void 0 || (_config$names9 = config.names) === null || _config$names9 === void 0 || (_config$names9 = _config$names9.editorOne) === null || _config$names9 === void 0 ? void 0 : _config$names9.finderResultSelect, this.createBasePayload({
300 window_name: finderContext.windowName,
301 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers9 = config.triggers) === null || _config$triggers9 === void 0 ? void 0 : _config$triggers9.click),
302 target_type: config === null || config === void 0 || (_config$targetTypes0 = config.targetTypes) === null || _config$targetTypes0 === void 0 ? void 0 : _config$targetTypes0.searchResult,
303 target_name: choice,
304 interaction_result: config === null || config === void 0 || (_config$interactionRe1 = config.interactionResults) === null || _config$interactionRe1 === void 0 ? void 0 : _config$interactionRe1.selected,
305 target_location: finderContext.targetLocation,
306 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca9 = config.secondaryLocations) === null || _config$secondaryLoca9 === void 0 ? void 0 : _config$secondaryLoca9.finder),
307 location_l2: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca0 = config.secondaryLocations) === null || _config$secondaryLoca0 === void 0 ? void 0 : _config$secondaryLoca0.finderResults),
308 interaction_description: 'Finder search results was selected'
309 }));
310 }
311 }, {
312 key: "sendCanvasEmptyBoxAction",
313 value: function sendCanvasEmptyBoxAction(_ref6) {
314 var _config$triggers0, _config$targetTypes1, _config$interactionRe10, _config$locations0, _config$secondaryLoca1, _config$names0;
315 var targetName = _ref6.targetName,
316 _ref6$metadata = _ref6.metadata,
317 metadata = _ref6$metadata === void 0 ? {} : _ref6$metadata,
318 _ref6$containerCreate = _ref6.containerCreated,
319 containerCreated = _ref6$containerCreate === void 0 ? null : _ref6$containerCreate;
320 var config = this.getConfig();
321 var payload = this.createBasePayload({
322 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers0 = config.triggers) === null || _config$triggers0 === void 0 ? void 0 : _config$triggers0.click),
323 target_type: config === null || config === void 0 || (_config$targetTypes1 = config.targetTypes) === null || _config$targetTypes1 === void 0 ? void 0 : _config$targetTypes1.buttons,
324 target_name: targetName,
325 interaction_result: config === null || config === void 0 || (_config$interactionRe10 = config.interactionResults) === null || _config$interactionRe10 === void 0 ? void 0 : _config$interactionRe10.selected,
326 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations0 = config.locations) === null || _config$locations0 === void 0 ? void 0 : _config$locations0.canvas),
327 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca1 = config.secondaryLocations) === null || _config$secondaryLoca1 === void 0 ? void 0 : _config$secondaryLoca1.emptyBox),
328 interaction_description: 'Empty box on canvas actions'
329 });
330 if (Object.keys(metadata).length > 0) {
331 payload.metadata = metadata;
332 }
333 if (containerCreated !== null) {
334 payload.state = containerCreated;
335 }
336 return this.dispatchEvent(config === null || config === void 0 || (_config$names0 = config.names) === null || _config$names0 === void 0 || (_config$names0 = _config$names0.editorOne) === null || _config$names0 === void 0 ? void 0 : _config$names0.canvasEmptyBoxAction, payload);
337 }
338 }, {
339 key: "sendWidgetPanelSearch",
340 value: function sendWidgetPanelSearch(_ref7) {
341 var _config$triggers1, _config$targetTypes10, _config$interactionRe11, _config$interactionRe12, _config$locations1, _config$locations10, _config$secondaryLoca10, _config$names1;
342 var resultsCount = _ref7.resultsCount,
343 _ref7$userInput = _ref7.userInput,
344 userInput = _ref7$userInput === void 0 ? null : _ref7$userInput;
345 var config = this.getConfig();
346 var hasResults = resultsCount > 0;
347 var payload = this.createBasePayload({
348 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers1 = config.triggers) === null || _config$triggers1 === void 0 ? void 0 : _config$triggers1.typing),
349 target_type: config === null || config === void 0 || (_config$targetTypes10 = config.targetTypes) === null || _config$targetTypes10 === void 0 ? void 0 : _config$targetTypes10.searchWidget,
350 target_name: 'search_widget',
351 interaction_result: hasResults ? config === null || config === void 0 || (_config$interactionRe11 = config.interactionResults) === null || _config$interactionRe11 === void 0 ? void 0 : _config$interactionRe11.resultsUpdated : config === null || config === void 0 || (_config$interactionRe12 = config.interactionResults) === null || _config$interactionRe12 === void 0 ? void 0 : _config$interactionRe12.noResults,
352 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations1 = config.locations) === null || _config$locations1 === void 0 ? void 0 : _config$locations1.leftPanel),
353 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$locations10 = config.locations) === null || _config$locations10 === void 0 ? void 0 : _config$locations10.widgetPanel),
354 location_l2: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca10 = config.secondaryLocations) === null || _config$secondaryLoca10 === void 0 ? void 0 : _config$secondaryLoca10.searchBar),
355 interaction_description: 'Widget search input, follows debounce behavior'
356 });
357 if (!hasResults && userInput) {
358 payload.metadata = {
359 user_input: userInput
360 };
361 }
362 return this.dispatchEvent(config === null || config === void 0 || (_config$names1 = config.names) === null || _config$names1 === void 0 || (_config$names1 = _config$names1.editorOne) === null || _config$names1 === void 0 ? void 0 : _config$names1.widgetPanelSearch, payload);
363 }
364 }]);
365 }();
366 var createDebouncedFinderSearch = exports.createDebouncedFinderSearch = function createDebouncedFinderSearch() {
367 var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 300;
368 return _.debounce(function (resultsCount, searchTerm) {
369 EditorOneEventManager.sendFinderSearchInput({
370 resultsCount: resultsCount,
371 searchTerm: searchTerm
372 });
373 }, delay);
374 };
375 var createDebouncedWidgetPanelSearch = exports.createDebouncedWidgetPanelSearch = function createDebouncedWidgetPanelSearch() {
376 var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2000;
377 return _.debounce(function (resultsCount, userInput) {
378 EditorOneEventManager.sendWidgetPanelSearch({
379 resultsCount: resultsCount,
380 userInput: userInput
381 });
382 }, delay);
383 };
384 var _default = exports["default"] = EditorOneEventManager;
385
386 /***/ }),
387
388 /***/ "../assets/dev/js/editor/utils/files-upload-handler.js":
389 /*!*************************************************************!*\
390 !*** ../assets/dev/js/editor/utils/files-upload-handler.js ***!
391 \*************************************************************/
392 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
393
394 "use strict";
395 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
396
397
398 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
399 Object.defineProperty(exports, "__esModule", ({
400 value: true
401 }));
402 exports["default"] = void 0;
403 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
404 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
405 var FilesUploadHandler = exports["default"] = /*#__PURE__*/function () {
406 function FilesUploadHandler() {
407 (0, _classCallCheck2.default)(this, FilesUploadHandler);
408 }
409 return (0, _createClass2.default)(FilesUploadHandler, null, [{
410 key: "isUploadEnabled",
411 value: function isUploadEnabled(mediaType) {
412 var unfilteredFilesTypes = ['svg', 'application/json'];
413 if (!unfilteredFilesTypes.includes(mediaType)) {
414 return true;
415 }
416 return elementorCommon.config.filesUpload.unfilteredFiles;
417 }
418 }, {
419 key: "setUploadTypeCaller",
420 value: function setUploadTypeCaller(frame) {
421 frame.uploader.uploader.param('uploadTypeCaller', 'elementor-wp-media-upload');
422 }
423 }, {
424 key: "getUnfilteredFilesNonAdminDialog",
425 value: function getUnfilteredFilesNonAdminDialog() {
426 return elementorCommon.dialogsManager.createWidget('alert', {
427 id: 'e-unfiltered-files-disabled-dialog',
428 headerMessage: __('Sorry, you can\'t upload that file yet', 'elementor'),
429 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'),
430 strings: {
431 confirm: __('Got it', 'elementor')
432 }
433 });
434 }
435 }, {
436 key: "getUnfilteredFilesNotEnabledDialog",
437 value: function getUnfilteredFilesNotEnabledDialog(callback) {
438 var elementorInstance = window.elementorAdmin || window.elementor;
439 if (!elementorInstance.config.user.is_administrator) {
440 return this.getUnfilteredFilesNonAdminDialog();
441 }
442 var onConfirm = function onConfirm() {
443 elementorCommon.ajax.addRequest('enable_unfiltered_files_upload', {}, true);
444 elementorCommon.config.filesUpload.unfilteredFiles = true;
445 callback();
446 };
447 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);
448 }
449 }, {
450 key: "getUnfilteredFilesNotEnabledImportTemplateDialog",
451 value: function getUnfilteredFilesNotEnabledImportTemplateDialog(callback) {
452 if (!(window.elementorAdmin || window.elementor).config.user.is_administrator) {
453 return this.getUnfilteredFilesNonAdminDialog();
454 }
455 return elementorCommon.dialogsManager.createWidget('confirm', {
456 id: 'e-enable-unfiltered-files-dialog-import-template',
457 headerMessage: __('Enable Unfiltered File Uploads', 'elementor'),
458 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'),
459 position: {
460 my: 'center center',
461 at: 'center center'
462 },
463 strings: {
464 confirm: __('Enable and Import', 'elementor'),
465 cancel: __('Import Without Enabling', 'elementor')
466 },
467 onConfirm: function onConfirm() {
468 elementorCommon.ajax.addRequest('enable_unfiltered_files_upload', {
469 success: function success() {
470 // This utility is used in both the admin and the Editor.
471 elementorCommon.config.filesUpload.unfilteredFiles = true;
472 callback();
473 }
474 }, true);
475 },
476 onCancel: function onCancel() {
477 return callback();
478 }
479 });
480 }
481 }]);
482 }();
483
484 /***/ }),
485
486 /***/ "../assets/dev/js/editor/utils/is-instanceof.js":
487 /*!******************************************************!*\
488 !*** ../assets/dev/js/editor/utils/is-instanceof.js ***!
489 \******************************************************/
490 /***/ ((__unused_webpack_module, exports) => {
491
492 "use strict";
493
494
495 Object.defineProperty(exports, "__esModule", ({
496 value: true
497 }));
498 exports["default"] = void 0;
499 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; } } }; }
500 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; } }
501 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; }
502 /**
503 * Some FileAPI objects such as FileList, DataTransferItem and DataTransferItemList has inconsistency with the retrieved
504 * object (from events, etc.) and the actual JavaScript object so a regular instanceof doesn't work. This function can
505 * check whether it's instanceof by using the objects constructor and prototype names.
506 *
507 * @param object
508 * @param constructors
509 * @return {boolean}
510 */
511 var _default = exports["default"] = function _default(object, constructors) {
512 constructors = Array.isArray(constructors) ? constructors : [constructors];
513 var _iterator = _createForOfIteratorHelper(constructors),
514 _step;
515 try {
516 for (_iterator.s(); !(_step = _iterator.n()).done;) {
517 var constructor = _step.value;
518 if (object.constructor.name === constructor.prototype[Symbol.toStringTag]) {
519 return true;
520 }
521 }
522 } catch (err) {
523 _iterator.e(err);
524 } finally {
525 _iterator.f();
526 }
527 return false;
528 };
529
530 /***/ }),
531
532 /***/ "../assets/dev/js/modules/imports/args-object.js":
533 /*!*******************************************************!*\
534 !*** ../assets/dev/js/modules/imports/args-object.js ***!
535 \*******************************************************/
536 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
537
538 "use strict";
539
540
541 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
542 Object.defineProperty(exports, "__esModule", ({
543 value: true
544 }));
545 exports["default"] = void 0;
546 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
547 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
548 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
549 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
550 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
551 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
552 var _instanceType = _interopRequireDefault(__webpack_require__(/*! ./instance-type */ "../assets/dev/js/modules/imports/instance-type.js"));
553 var _isInstanceof = _interopRequireDefault(__webpack_require__(/*! ../../editor/utils/is-instanceof */ "../assets/dev/js/editor/utils/is-instanceof.js"));
554 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)); }
555 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
556 var ArgsObject = exports["default"] = /*#__PURE__*/function (_InstanceType) {
557 /**
558 * Function constructor().
559 *
560 * Create ArgsObject.
561 *
562 * @param {{}} args
563 */
564 function ArgsObject(args) {
565 var _this;
566 (0, _classCallCheck2.default)(this, ArgsObject);
567 _this = _callSuper(this, ArgsObject);
568 _this.args = args;
569 return _this;
570 }
571
572 /**
573 * Function requireArgument().
574 *
575 * Validate property in args.
576 *
577 * @param {string} property
578 * @param {{}} args
579 *
580 * @throws {Error}
581 */
582 (0, _inherits2.default)(ArgsObject, _InstanceType);
583 return (0, _createClass2.default)(ArgsObject, [{
584 key: "requireArgument",
585 value: function requireArgument(property) {
586 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.args;
587 if (!Object.prototype.hasOwnProperty.call(args, property)) {
588 throw Error("".concat(property, " is required."));
589 }
590 }
591
592 /**
593 * Function requireArgumentType().
594 *
595 * Validate property in args using `type === typeof(args.whatever)`.
596 *
597 * @param {string} property
598 * @param {string} type
599 * @param {{}} args
600 *
601 * @throws {Error}
602 */
603 }, {
604 key: "requireArgumentType",
605 value: function requireArgumentType(property, type) {
606 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
607 this.requireArgument(property, args);
608 if ((0, _typeof2.default)(args[property]) !== type) {
609 throw Error("".concat(property, " invalid type: ").concat(type, "."));
610 }
611 }
612
613 /**
614 * Function requireArgumentInstance().
615 *
616 * Validate property in args using `args.whatever instanceof instance`.
617 *
618 * @param {string} property
619 * @param {*} instance
620 * @param {{}} args
621 *
622 * @throws {Error}
623 */
624 }, {
625 key: "requireArgumentInstance",
626 value: function requireArgumentInstance(property, instance) {
627 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
628 this.requireArgument(property, args);
629 if (!(args[property] instanceof instance) && !(0, _isInstanceof.default)(args[property], instance)) {
630 throw Error("".concat(property, " invalid instance."));
631 }
632 }
633
634 /**
635 * Function requireArgumentConstructor().
636 *
637 * Validate property in args using `type === args.whatever.constructor`.
638 *
639 * @param {string} property
640 * @param {*} type
641 * @param {{}} args
642 *
643 * @throws {Error}
644 */
645 }, {
646 key: "requireArgumentConstructor",
647 value: function requireArgumentConstructor(property, type) {
648 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
649 this.requireArgument(property, args);
650
651 // Note: Converting the constructor to string in order to avoid equation issues
652 // due to different memory addresses between iframes (window.Object !== window.top.Object).
653 if (args[property].constructor.toString() !== type.prototype.constructor.toString()) {
654 throw Error("".concat(property, " invalid constructor type."));
655 }
656 }
657 }], [{
658 key: "getInstanceType",
659 value: function getInstanceType() {
660 return 'ArgsObject';
661 }
662 }]);
663 }(_instanceType.default);
664
665 /***/ }),
666
667 /***/ "../assets/dev/js/modules/imports/instance-type.js":
668 /*!*********************************************************!*\
669 !*** ../assets/dev/js/modules/imports/instance-type.js ***!
670 \*********************************************************/
671 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
672
673 "use strict";
674
675
676 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
677 Object.defineProperty(exports, "__esModule", ({
678 value: true
679 }));
680 exports["default"] = void 0;
681 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
682 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
683 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
684 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
685 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; }
686 var InstanceType = exports["default"] = /*#__PURE__*/function () {
687 function InstanceType() {
688 var _this = this;
689 (0, _classCallCheck2.default)(this, InstanceType);
690 // Since anonymous classes sometimes do not get validated by babel, do it manually.
691 var target = this instanceof InstanceType ? this.constructor : void 0;
692 var prototypes = [];
693 while (target.__proto__ && target.__proto__.name) {
694 prototypes.push(target.__proto__);
695 target = target.__proto__;
696 }
697 prototypes.reverse().forEach(function (proto) {
698 return _this instanceof proto;
699 });
700 }
701 return (0, _createClass2.default)(InstanceType, null, [{
702 key: Symbol.hasInstance,
703 value: function value(target) {
704 /**
705 * This is function extending being called each time JS uses instanceOf, since babel use it each time it create new class
706 * its give's opportunity to mange capabilities of instanceOf operator.
707 * saving current class each time will give option later to handle instanceOf manually.
708 */
709 var result = _superPropGet(InstanceType, Symbol.hasInstance, this, 2)([target]);
710
711 // Act normal when validate a class, which does not have instance type.
712 if (target && !target.constructor.getInstanceType) {
713 return result;
714 }
715 if (target) {
716 if (!target.instanceTypes) {
717 target.instanceTypes = [];
718 }
719 if (!result) {
720 if (this.getInstanceType() === target.constructor.getInstanceType()) {
721 result = true;
722 }
723 }
724 if (result) {
725 var name = this.getInstanceType === InstanceType.getInstanceType ? 'BaseInstanceType' : this.getInstanceType();
726 if (-1 === target.instanceTypes.indexOf(name)) {
727 target.instanceTypes.push(name);
728 }
729 }
730 }
731 if (!result && target) {
732 // Check if the given 'target', is instance of known types.
733 result = target.instanceTypes && Array.isArray(target.instanceTypes) && -1 !== target.instanceTypes.indexOf(this.getInstanceType());
734 }
735 return result;
736 }
737 }, {
738 key: "getInstanceType",
739 value: function getInstanceType() {
740 elementorModules.ForceMethodImplementation();
741 }
742 }]);
743 }();
744
745 /***/ }),
746
747 /***/ "../assets/dev/js/modules/imports/module.js":
748 /*!**************************************************!*\
749 !*** ../assets/dev/js/modules/imports/module.js ***!
750 \**************************************************/
751 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
752
753 "use strict";
754
755
756 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
757 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
758 var Module = function Module() {
759 var $ = jQuery,
760 instanceParams = arguments,
761 self = this,
762 events = {};
763 var settings;
764 var ensureClosureMethods = function ensureClosureMethods() {
765 $.each(self, function (methodName) {
766 var oldMethod = self[methodName];
767 if ('function' !== typeof oldMethod) {
768 return;
769 }
770 self[methodName] = function () {
771 return oldMethod.apply(self, arguments);
772 };
773 });
774 };
775 var initSettings = function initSettings() {
776 settings = self.getDefaultSettings();
777 var instanceSettings = instanceParams[0];
778 if (instanceSettings) {
779 $.extend(true, settings, instanceSettings);
780 }
781 };
782 var init = function init() {
783 self.__construct.apply(self, instanceParams);
784 ensureClosureMethods();
785 initSettings();
786 self.trigger('init');
787 };
788 this.getItems = function (items, itemKey) {
789 if (itemKey) {
790 var keyStack = itemKey.split('.'),
791 currentKey = keyStack.splice(0, 1);
792 if (!keyStack.length) {
793 return items[currentKey];
794 }
795 if (!items[currentKey]) {
796 return;
797 }
798 return this.getItems(items[currentKey], keyStack.join('.'));
799 }
800 return items;
801 };
802 this.getSettings = function (setting) {
803 return this.getItems(settings, setting);
804 };
805 this.setSettings = function (settingKey, value, settingsContainer) {
806 if (!settingsContainer) {
807 settingsContainer = settings;
808 }
809 if ('object' === (0, _typeof2.default)(settingKey)) {
810 $.extend(settingsContainer, settingKey);
811 return self;
812 }
813 var keyStack = settingKey.split('.'),
814 currentKey = keyStack.splice(0, 1);
815 if (!keyStack.length) {
816 settingsContainer[currentKey] = value;
817 return self;
818 }
819 if (!settingsContainer[currentKey]) {
820 settingsContainer[currentKey] = {};
821 }
822 return self.setSettings(keyStack.join('.'), value, settingsContainer[currentKey]);
823 };
824 this.getErrorMessage = function (type, functionName) {
825 var message;
826 switch (type) {
827 case 'forceMethodImplementation':
828 message = "The method '".concat(functionName, "' must to be implemented in the inheritor child.");
829 break;
830 default:
831 message = 'An error occurs';
832 }
833 return message;
834 };
835
836 // TODO: This function should be deleted ?.
837 this.forceMethodImplementation = function (functionName) {
838 throw new Error(this.getErrorMessage('forceMethodImplementation', functionName));
839 };
840 this.on = function (eventName, callback) {
841 if ('object' === (0, _typeof2.default)(eventName)) {
842 $.each(eventName, function (singleEventName) {
843 self.on(singleEventName, this);
844 });
845 return self;
846 }
847 var eventNames = eventName.split(' ');
848 eventNames.forEach(function (singleEventName) {
849 if (!events[singleEventName]) {
850 events[singleEventName] = [];
851 }
852 events[singleEventName].push(callback);
853 });
854 return self;
855 };
856 this.off = function (eventName, callback) {
857 if (!events[eventName]) {
858 return self;
859 }
860 if (!callback) {
861 delete events[eventName];
862 return self;
863 }
864 var callbackIndex = events[eventName].indexOf(callback);
865 if (-1 !== callbackIndex) {
866 delete events[eventName][callbackIndex];
867
868 // Reset array index (for next off on same event).
869 events[eventName] = events[eventName].filter(function (val) {
870 return val;
871 });
872 }
873 return self;
874 };
875 this.trigger = function (eventName) {
876 var methodName = 'on' + eventName[0].toUpperCase() + eventName.slice(1),
877 params = Array.prototype.slice.call(arguments, 1);
878 if (self[methodName]) {
879 self[methodName].apply(self, params);
880 }
881 var callbacks = events[eventName];
882 if (!callbacks) {
883 return self;
884 }
885 $.each(callbacks, function (index, callback) {
886 callback.apply(self, params);
887 });
888 return self;
889 };
890 init();
891 };
892 Module.prototype.__construct = function () {};
893 Module.prototype.getDefaultSettings = function () {
894 return {};
895 };
896 Module.prototype.getConstructorID = function () {
897 return this.constructor.name;
898 };
899 Module.extend = function (properties) {
900 var $ = jQuery,
901 parent = this;
902 var child = function child() {
903 return parent.apply(this, arguments);
904 };
905 $.extend(child, parent);
906 child.prototype = Object.create($.extend({}, parent.prototype, properties));
907 child.prototype.constructor = child;
908 child.__super__ = parent.prototype;
909 return child;
910 };
911 module.exports = Module;
912
913 /***/ }),
914
915 /***/ "../assets/dev/js/utils/notifications.js":
916 /*!***********************************************!*\
917 !*** ../assets/dev/js/utils/notifications.js ***!
918 \***********************************************/
919 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
920
921 "use strict";
922
923
924 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
925 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
926 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; }
927 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; }
928 module.exports = elementorModules.Module.extend({
929 initToast: function initToast() {
930 var toast = elementorCommon.dialogsManager.createWidget('buttons', {
931 id: 'elementor-toast',
932 position: {
933 my: 'center bottom',
934 at: 'center bottom-10',
935 of: '#elementor-panel-inner',
936 autoRefresh: true
937 },
938 hide: {
939 onClick: true,
940 auto: true,
941 autoDelay: 10000
942 },
943 effects: {
944 show: function show() {
945 var $widget = toast.getElements('widget');
946 $widget.show();
947 toast.refreshPosition();
948 var top = parseInt($widget.css('top'), 10);
949 $widget.hide().css('top', top + 100);
950 $widget.animate({
951 opacity: 'show',
952 height: 'show',
953 paddingBottom: 'show',
954 paddingTop: 'show',
955 top: top
956 }, {
957 easing: 'linear',
958 duration: 300
959 });
960 },
961 hide: function hide() {
962 var $widget = toast.getElements('widget'),
963 top = parseInt($widget.css('top'), 10);
964 $widget.animate({
965 opacity: 'hide',
966 height: 'hide',
967 paddingBottom: 'hide',
968 paddingTop: 'hide',
969 top: top + 100
970 }, {
971 easing: 'linear',
972 duration: 300
973 });
974 }
975 },
976 button: {
977 tag: 'div'
978 }
979 });
980 this.getToast = function () {
981 return toast;
982 };
983 },
984 showToast: function showToast(options) {
985 var toast = this.getToast();
986 toast.setMessage(options.message);
987 toast.getElements('buttonsWrapper').empty();
988 var isPositionValid = this.isPositionValid(options === null || options === void 0 ? void 0 : options.position);
989 if (!isPositionValid) {
990 this.positionToWindow();
991 }
992 if (options !== null && options !== void 0 && options.position && isPositionValid) {
993 toast.setSettings('position', options.position);
994 }
995 if (options.buttons) {
996 options.buttons.forEach(function (button) {
997 toast.addButton(button);
998 });
999 }
1000 if (options.classes) {
1001 toast.getElements('widget').addClass(options.classes);
1002 }
1003 if (options.sticky) {
1004 toast.setSettings({
1005 hide: {
1006 auto: false,
1007 onClick: false
1008 }
1009 });
1010 }
1011 return toast.show();
1012 },
1013 isPositionValid: function isPositionValid(position) {
1014 var _position$of;
1015 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;
1016 if (!positionToCheck) {
1017 return false;
1018 }
1019 return !!document.querySelector(positionToCheck);
1020 },
1021 positionToWindow: function positionToWindow() {
1022 var toast = this.getToast();
1023 var position = _objectSpread(_objectSpread({}, toast.getSettings('position')), {}, {
1024 my: 'right top',
1025 at: 'right-10 top+42',
1026 // 42px is the default admin bar height + 10px
1027 of: ''
1028 });
1029 toast.setSettings('position', position);
1030 toast.getElements('widget').addClass('dialog-position-window');
1031 },
1032 onInit: function onInit() {
1033 this.initToast();
1034 }
1035 });
1036
1037 /***/ }),
1038
1039 /***/ "../assets/dev/js/utils/tiers.js":
1040 /*!***************************************!*\
1041 !*** ../assets/dev/js/utils/tiers.js ***!
1042 \***************************************/
1043 /***/ ((__unused_webpack_module, exports) => {
1044
1045 "use strict";
1046
1047
1048 Object.defineProperty(exports, "__esModule", ({
1049 value: true
1050 }));
1051 exports.isTierAtLeast = exports.TIERS_PRIORITY = exports.TIERS = void 0;
1052 var TIERS_PRIORITY = exports.TIERS_PRIORITY = Object.freeze(['free', 'essential', 'essential-oct2023', 'advanced', 'expert', 'agency']);
1053
1054 /**
1055 * @type {Readonly<{
1056 * free: string;
1057 * essential: string;
1058 * 'essential-oct2023': string;
1059 * advanced: string;
1060 * expert: string;
1061 * agency: string;
1062 * }>}
1063 */
1064 var TIERS = exports.TIERS = Object.freeze(TIERS_PRIORITY.reduce(function (acc, tier) {
1065 acc[tier] = tier;
1066 return acc;
1067 }, {}));
1068 var isTierAtLeast = exports.isTierAtLeast = function isTierAtLeast(currentTier, expectedTier) {
1069 var currentTierIndex = TIERS_PRIORITY.indexOf(currentTier);
1070 var expectedTierIndex = TIERS_PRIORITY.indexOf(expectedTier);
1071 if (-1 === currentTierIndex || -1 === expectedTierIndex) {
1072 return false;
1073 }
1074 return currentTierIndex >= expectedTierIndex;
1075 };
1076
1077 /***/ }),
1078
1079 /***/ "../assets/dev/js/utils/time.js":
1080 /*!**************************************!*\
1081 !*** ../assets/dev/js/utils/time.js ***!
1082 \**************************************/
1083 /***/ ((__unused_webpack_module, exports) => {
1084
1085 "use strict";
1086
1087
1088 Object.defineProperty(exports, "__esModule", ({
1089 value: true
1090 }));
1091 exports["default"] = getUserTimestamp;
1092 /**
1093 * Returns the timestamp in ISO8601 format with the UTC timezone offset.
1094 *
1095 * @since 3.6.0
1096 *
1097 * @param {Date} date
1098 * @return {Date} timestamp
1099 */
1100 function getUserTimestamp() {
1101 var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
1102 var timezoneOffset = date.getTimezoneOffset();
1103
1104 // Local time for the user
1105 var UTCTimestamp = new Date(date.getTime() - timezoneOffset * 60000).toISOString();
1106
1107 // Remove the Z suffix from the string.
1108 UTCTimestamp = UTCTimestamp.slice(0, -1);
1109
1110 // Create the offset string in the format `+HH:00` (or minus (-) prefix for negative offset instead of plus)
1111 var decimalTimezoneOffset = timezoneOffset / 60,
1112 // Negative offsets include a '-' sign in the getTimezoneOffset value, positive values need a '+' prefix (ISO8601).
1113 sign = 0 <= decimalTimezoneOffset ? '+' : '-',
1114 hours = Math.abs(Math.floor(decimalTimezoneOffset)),
1115 minutes = Math.abs(decimalTimezoneOffset % 1) * 60,
1116 addZeroToHour = 10 > hours ? '0' : '',
1117 addZeroToMinutes = 10 > minutes ? '0' : '';
1118 var formattedTimezoneOffset = sign + addZeroToHour + hours + ':' + addZeroToMinutes + minutes;
1119 return UTCTimestamp + formattedTimezoneOffset;
1120 }
1121
1122 /***/ }),
1123
1124 /***/ "../core/common/assets/js/components/wordpress/commands-data/index.js":
1125 /*!****************************************************************************!*\
1126 !*** ../core/common/assets/js/components/wordpress/commands-data/index.js ***!
1127 \****************************************************************************/
1128 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1129
1130 "use strict";
1131
1132
1133 Object.defineProperty(exports, "__esModule", ({
1134 value: true
1135 }));
1136 Object.defineProperty(exports, "Media", ({
1137 enumerable: true,
1138 get: function get() {
1139 return _media.Media;
1140 }
1141 }));
1142 var _media = __webpack_require__(/*! ./media */ "../core/common/assets/js/components/wordpress/commands-data/media.js");
1143
1144 /***/ }),
1145
1146 /***/ "../core/common/assets/js/components/wordpress/commands-data/media.js":
1147 /*!****************************************************************************!*\
1148 !*** ../core/common/assets/js/components/wordpress/commands-data/media.js ***!
1149 \****************************************************************************/
1150 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1151
1152 "use strict";
1153 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
1154
1155
1156 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1157 Object.defineProperty(exports, "__esModule", ({
1158 value: true
1159 }));
1160 exports.Media = void 0;
1161 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
1162 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
1163 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1164 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1165 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1166 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1167 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
1168 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1169 var _commandData = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-data */ "../modules/web-cli/assets/js/modules/command-data.js"));
1170 var _filesUploadHandler = _interopRequireDefault(__webpack_require__(/*! elementor-editor/utils/files-upload-handler */ "../assets/dev/js/editor/utils/files-upload-handler.js"));
1171 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)); }
1172 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1173 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; }
1174 var Media = exports.Media = /*#__PURE__*/function (_CommandData) {
1175 function Media() {
1176 (0, _classCallCheck2.default)(this, Media);
1177 return _callSuper(this, Media, arguments);
1178 }
1179 (0, _inherits2.default)(Media, _CommandData);
1180 return (0, _createClass2.default)(Media, [{
1181 key: "validateArgs",
1182 value: function validateArgs() {
1183 this.requireArgumentInstance('file', File);
1184 }
1185 }, {
1186 key: "getRequestData",
1187 value: function getRequestData() {
1188 var requestData = _superPropGet(Media, "getRequestData", this, 3)([]);
1189 requestData.namespace = 'wp';
1190 requestData.version = '2';
1191 return requestData;
1192 }
1193 }, {
1194 key: "applyBeforeCreate",
1195 value: function applyBeforeCreate(args) {
1196 var _args$options;
1197 args.headers = {
1198 'Content-Disposition': "attachment; filename=".concat(this.file.name),
1199 'Content-Type': this.file.type
1200 };
1201 args.query = {
1202 uploadTypeCaller: 'elementor-wp-media-upload'
1203 };
1204 args.data = this.file;
1205 if ((_args$options = args.options) !== null && _args$options !== void 0 && _args$options.progress) {
1206 this.toast = elementor.notifications.showToast({
1207 // eslint-disable-next-line @wordpress/i18n-ellipsis
1208 message: __('Uploading...'),
1209 sticky: true
1210 });
1211 }
1212 return args;
1213 }
1214 }, {
1215 key: "applyAfterCreate",
1216 value: function applyAfterCreate(data, args) {
1217 var _args$options2;
1218 if ((_args$options2 = args.options) !== null && _args$options2 !== void 0 && _args$options2.progress) {
1219 this.toast.hide();
1220 }
1221 return data;
1222 }
1223 }, {
1224 key: "run",
1225 value: function () {
1226 var _run = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
1227 return _regenerator.default.wrap(function (_context) {
1228 while (1) switch (_context.prev = _context.next) {
1229 case 0:
1230 this.file = this.args.file;
1231 if (!(this.file.size > parseInt(window._wpPluploadSettings.defaults.filters.max_file_size, 10))) {
1232 _context.next = 1;
1233 break;
1234 }
1235 throw new Error(__('The file exceeds the maximum upload size for this site.', 'elementor'));
1236 case 1:
1237 if (!(!window._wpPluploadSettings.defaults.filters.mime_types[0].extensions.split(',').includes(this.file.name.split('.').pop()) && !elementor.config.filesUpload.unfilteredFiles)) {
1238 _context.next = 2;
1239 break;
1240 }
1241 _filesUploadHandler.default.getUnfilteredFilesNotEnabledDialog(function () {}).show();
1242 return _context.abrupt("return");
1243 case 2:
1244 _context.next = 3;
1245 return _superPropGet(Media, "run", this, 3)([]);
1246 case 3:
1247 return _context.abrupt("return", _context.sent);
1248 case 4:
1249 case "end":
1250 return _context.stop();
1251 }
1252 }, _callee, this);
1253 }));
1254 function run() {
1255 return _run.apply(this, arguments);
1256 }
1257 return run;
1258 }()
1259 }], [{
1260 key: "getEndpointFormat",
1261 value: function getEndpointFormat() {
1262 // 'wp/media' to 'media' since `requestData.namespace` is 'wp'.
1263 return 'media';
1264 }
1265 }]);
1266 }(_commandData.default);
1267
1268 /***/ }),
1269
1270 /***/ "../core/common/assets/js/components/wordpress/component.js":
1271 /*!******************************************************************!*\
1272 !*** ../core/common/assets/js/components/wordpress/component.js ***!
1273 \******************************************************************/
1274 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1275
1276 "use strict";
1277
1278
1279 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1280 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
1281 Object.defineProperty(exports, "__esModule", ({
1282 value: true
1283 }));
1284 exports["default"] = void 0;
1285 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1286 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1287 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1288 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1289 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1290 var _componentBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
1291 var dataCommands = _interopRequireWildcard(__webpack_require__(/*! ./commands-data/ */ "../core/common/assets/js/components/wordpress/commands-data/index.js"));
1292 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); }
1293 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)); }
1294 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1295 var Component = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
1296 function Component() {
1297 (0, _classCallCheck2.default)(this, Component);
1298 return _callSuper(this, Component, arguments);
1299 }
1300 (0, _inherits2.default)(Component, _ComponentBase);
1301 return (0, _createClass2.default)(Component, [{
1302 key: "getNamespace",
1303 value: function getNamespace() {
1304 return 'wp';
1305 }
1306 }, {
1307 key: "defaultData",
1308 value: function defaultData() {
1309 return this.importCommands(dataCommands);
1310 }
1311 }]);
1312 }(_componentBase.default);
1313
1314 /***/ }),
1315
1316 /***/ "../core/common/assets/js/utils/debug.js":
1317 /*!***********************************************!*\
1318 !*** ../core/common/assets/js/utils/debug.js ***!
1319 \***********************************************/
1320 /***/ ((module) => {
1321
1322 "use strict";
1323
1324
1325 // Moved from assets/dev/js/editor/utils
1326 var Debug = function Debug() {
1327 var self = this,
1328 errorStack = [],
1329 settings = {},
1330 elements = {};
1331 var initSettings = function initSettings() {
1332 settings = {
1333 debounceDelay: 500,
1334 urlsToWatch: ['elementor/assets']
1335 };
1336 };
1337 var initElements = function initElements() {
1338 elements.$window = jQuery(window);
1339 };
1340 var onError = function onError(event) {
1341 var _event$originalEvent;
1342 var error = (_event$originalEvent = event.originalEvent) === null || _event$originalEvent === void 0 ? void 0 : _event$originalEvent.error;
1343 if (!error) {
1344 return;
1345 }
1346 var isInWatchList = false,
1347 urlsToWatch = settings.urlsToWatch;
1348 jQuery.each(urlsToWatch, function () {
1349 if (-1 !== error.stack.indexOf(this)) {
1350 isInWatchList = true;
1351 return false;
1352 }
1353 });
1354 if (!isInWatchList) {
1355 return;
1356 }
1357 self.addError({
1358 type: error.name,
1359 message: error.message,
1360 url: event.originalEvent.filename,
1361 line: event.originalEvent.lineno,
1362 column: event.originalEvent.colno
1363 });
1364 };
1365 var bindEvents = function bindEvents() {
1366 elements.$window.on('error', onError);
1367 };
1368 var init = function init() {
1369 initSettings();
1370 initElements();
1371 bindEvents();
1372 self.sendErrors = _.debounce(self.sendErrors, settings.debounceDelay);
1373 };
1374 this.addURLToWatch = function (url) {
1375 settings.urlsToWatch.push(url);
1376 };
1377 this.addCustomError = function (error, category, tag) {
1378 var errorInfo = {
1379 type: error.name,
1380 message: error.message,
1381 url: error.fileName || error.sourceURL,
1382 line: error.lineNumber || error.line,
1383 column: error.columnNumber || error.column,
1384 customFields: {
1385 category: category || 'general',
1386 tag: tag
1387 }
1388 };
1389 if (!errorInfo.url) {
1390 var stackInfo = error.stack.match(/\n {4}at (.*?(?=:(\d+):(\d+)))/);
1391 if (stackInfo) {
1392 errorInfo.url = stackInfo[1];
1393 errorInfo.line = stackInfo[2];
1394 errorInfo.column = stackInfo[3];
1395 }
1396 }
1397 this.addError(errorInfo);
1398 };
1399 this.addError = function (errorParams) {
1400 var defaultParams = {
1401 type: 'Error',
1402 timestamp: Math.floor(new Date().getTime() / 1000),
1403 message: null,
1404 url: null,
1405 line: null,
1406 column: null,
1407 customFields: {}
1408 };
1409 errorStack.push(jQuery.extend(true, defaultParams, errorParams));
1410 self.sendErrors();
1411 };
1412 this.sendErrors = function () {
1413 // Avoid recursions on errors in ajax
1414 elements.$window.off('error', onError);
1415 jQuery.ajax({
1416 url: elementorCommon.config.ajax.url,
1417 method: 'POST',
1418 data: {
1419 action: 'elementor_js_log',
1420 _nonce: elementorCommon.ajax.getSettings('nonce'),
1421 data: errorStack
1422 },
1423 success: function success() {
1424 errorStack = [];
1425
1426 // Restore error handler
1427 elements.$window.on('error', onError);
1428 }
1429 });
1430 };
1431 init();
1432 };
1433 module.exports = Debug;
1434
1435 /***/ }),
1436
1437 /***/ "../core/common/assets/js/utils/helpers.js":
1438 /*!*************************************************!*\
1439 !*** ../core/common/assets/js/utils/helpers.js ***!
1440 \*************************************************/
1441 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1442
1443 "use strict";
1444
1445
1446 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1447 Object.defineProperty(exports, "__esModule", ({
1448 value: true
1449 }));
1450 exports["default"] = void 0;
1451 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1452 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1453 var Helpers = exports["default"] = /*#__PURE__*/function () {
1454 function Helpers() {
1455 (0, _classCallCheck2.default)(this, Helpers);
1456 }
1457 return (0, _createClass2.default)(Helpers, [{
1458 key: "consoleWarn",
1459 value:
1460 /**
1461 * @param {*} args
1462 * @deprecated since 3.7.0, use `elementorDevTools.consoleWarn()` instead.
1463 */
1464 function consoleWarn() {
1465 var _elementorDevTools;
1466 (_elementorDevTools = elementorDevTools).consoleWarn.apply(_elementorDevTools, arguments);
1467
1468 // This is is self is deprecated.
1469 elementorDevTools.deprecation.deprecated('elementorCommon.helpers.consoleWarn()', '3.7.0', 'elementorDevTools.consoleWarn()');
1470 }
1471
1472 /**
1473 * @param {string} message
1474 * @deprecated since 3.7.0, use `console.error()` instead.
1475 */
1476 }, {
1477 key: "consoleError",
1478 value: function consoleError(message) {
1479 // eslint-disable-next-line no-console
1480 console.error(message);
1481
1482 // This is is self is deprecated.
1483 elementorDevTools.deprecation.deprecated('elementorCommon.helpers.consoleError()', '3.7.0', 'console.error()');
1484 }
1485 }, {
1486 key: "cloneObject",
1487 value: function cloneObject(object) {
1488 return JSON.parse(JSON.stringify(object));
1489 }
1490 }, {
1491 key: "upperCaseWords",
1492 value: function upperCaseWords(string) {
1493 return (string + '').replace(/^(.)|\s+(.)/g, function ($1) {
1494 return $1.toUpperCase();
1495 });
1496 }
1497 }, {
1498 key: "getUniqueId",
1499 value: function getUniqueId() {
1500 return Math.random().toString(16).substr(2, 7);
1501 }
1502 }]);
1503 }();
1504
1505 /***/ }),
1506
1507 /***/ "../core/common/assets/js/utils/storage.js":
1508 /*!*************************************************!*\
1509 !*** ../core/common/assets/js/utils/storage.js ***!
1510 \*************************************************/
1511 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1512
1513 "use strict";
1514
1515
1516 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1517 Object.defineProperty(exports, "__esModule", ({
1518 value: true
1519 }));
1520 exports["default"] = void 0;
1521 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1522 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1523 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1524 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1525 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1526 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)); }
1527 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1528 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1529 function _default() {
1530 (0, _classCallCheck2.default)(this, _default);
1531 return _callSuper(this, _default, arguments);
1532 }
1533 (0, _inherits2.default)(_default, _elementorModules$Mod);
1534 return (0, _createClass2.default)(_default, [{
1535 key: "get",
1536 value: function get(key, options) {
1537 options = options || {};
1538 var storage;
1539 try {
1540 storage = options.session ? sessionStorage : localStorage;
1541 } catch (e) {
1542 return key ? undefined : {};
1543 }
1544 var elementorStorage = storage.getItem('elementor');
1545 if (elementorStorage) {
1546 elementorStorage = JSON.parse(elementorStorage);
1547 } else {
1548 elementorStorage = {};
1549 }
1550 if (!elementorStorage.__expiration) {
1551 elementorStorage.__expiration = {};
1552 }
1553 var expiration = elementorStorage.__expiration;
1554 var expirationToCheck = [];
1555 if (key) {
1556 if (expiration[key]) {
1557 expirationToCheck = [key];
1558 }
1559 } else {
1560 expirationToCheck = Object.keys(expiration);
1561 }
1562 var entryExpired = false;
1563 expirationToCheck.forEach(function (expirationKey) {
1564 if (new Date(expiration[expirationKey]) < new Date()) {
1565 delete elementorStorage[expirationKey];
1566 delete expiration[expirationKey];
1567 entryExpired = true;
1568 }
1569 });
1570 if (entryExpired) {
1571 this.save(elementorStorage, options.session);
1572 }
1573 if (key) {
1574 return elementorStorage[key];
1575 }
1576 return elementorStorage;
1577 }
1578 }, {
1579 key: "set",
1580 value: function set(key, value, options) {
1581 options = options || {};
1582 var elementorStorage = this.get(null, options);
1583 elementorStorage[key] = value;
1584 if (options.lifetimeInSeconds) {
1585 var date = new Date();
1586 date.setTime(date.getTime() + options.lifetimeInSeconds * 1000);
1587 elementorStorage.__expiration[key] = date.getTime();
1588 }
1589 this.save(elementorStorage, options.session);
1590 }
1591 }, {
1592 key: "save",
1593 value: function save(object, session) {
1594 var storage;
1595 try {
1596 storage = session ? sessionStorage : localStorage;
1597 } catch (e) {
1598 return;
1599 }
1600 storage.setItem('elementor', JSON.stringify(object));
1601 }
1602 }]);
1603 }(elementorModules.Module);
1604
1605 /***/ }),
1606
1607 /***/ "../core/common/modules/ajax/assets/js/ajax.js":
1608 /*!*****************************************************!*\
1609 !*** ../core/common/modules/ajax/assets/js/ajax.js ***!
1610 \*****************************************************/
1611 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1612
1613 "use strict";
1614
1615
1616 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1617 Object.defineProperty(exports, "__esModule", ({
1618 value: true
1619 }));
1620 exports["default"] = void 0;
1621 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
1622 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1623 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1624 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1625 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1626 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1627 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)); }
1628 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1629 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1630 function _default() {
1631 var _this;
1632 (0, _classCallCheck2.default)(this, _default);
1633 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1634 args[_key] = arguments[_key];
1635 }
1636 _this = _callSuper(this, _default, [].concat(args));
1637 _this.requests = {};
1638 _this.cache = {};
1639 _this.initRequestConstants();
1640 _this.debounceSendBatch = _.debounce(_this.sendBatch.bind(_this), 500);
1641 return _this;
1642 }
1643 (0, _inherits2.default)(_default, _elementorModules$Mod);
1644 return (0, _createClass2.default)(_default, [{
1645 key: "getDefaultSettings",
1646 value: function getDefaultSettings() {
1647 return {
1648 ajaxParams: {
1649 type: 'POST',
1650 url: elementorCommon.config.ajax.url,
1651 data: {},
1652 dataType: 'json'
1653 },
1654 actionPrefix: 'elementor_'
1655 };
1656 }
1657 }, {
1658 key: "initRequestConstants",
1659 value: function initRequestConstants() {
1660 this.requestConstants = {
1661 _nonce: this.getSettings('nonce')
1662 };
1663 }
1664 }, {
1665 key: "addRequestConstant",
1666 value: function addRequestConstant(key, value) {
1667 this.requestConstants[key] = value;
1668 }
1669 }, {
1670 key: "getCacheKey",
1671 value: function getCacheKey(request) {
1672 return JSON.stringify({
1673 unique_id: request.unique_id,
1674 data: request.data
1675 });
1676 }
1677 }, {
1678 key: "loadObjects",
1679 value: function loadObjects(options) {
1680 var _this2 = this;
1681 var dataCollection = {};
1682 var deferredArray = [];
1683 if (options.before) {
1684 options.before();
1685 }
1686 options.ids.forEach(function (objectId) {
1687 deferredArray.push(_this2.load({
1688 action: options.action,
1689 unique_id: options.data.unique_id + objectId,
1690 data: jQuery.extend({
1691 id: objectId
1692 }, options.data)
1693 }).done(function (data) {
1694 return dataCollection = jQuery.extend(dataCollection, data);
1695 }));
1696 });
1697 jQuery.when.apply(jQuery, deferredArray).done(function () {
1698 return options.success(dataCollection);
1699 });
1700 }
1701 }, {
1702 key: "load",
1703 value: function load(request, immediately) {
1704 var _this3 = this;
1705 if (!request.unique_id) {
1706 request.unique_id = request.action;
1707 }
1708 if (request.before) {
1709 request.before();
1710 }
1711 var deferred;
1712 var cacheKey = this.getCacheKey(request);
1713 if (_.has(this.cache, cacheKey)) {
1714 deferred = jQuery.Deferred().done(request.success).resolve(this.cache[cacheKey]);
1715 } else {
1716 deferred = this.addRequest(request.action, {
1717 data: request.data,
1718 unique_id: request.unique_id,
1719 success: function success(data) {
1720 return _this3.cache[cacheKey] = data;
1721 }
1722 }, immediately).done(request.success);
1723 }
1724 return deferred;
1725 }
1726 }, {
1727 key: "cancelRequest",
1728 value: function cancelRequest(requestId) {
1729 var request = this.requests[requestId];
1730 if (!request) {
1731 return null;
1732 }
1733 if (request.options.deferred.jqXhr) {
1734 return request.options.deferred.jqXhr.abort('Request canceled');
1735 }
1736 if (request.options.deferred) {
1737 return request.options.deferred.reject('Request canceled');
1738 }
1739 }
1740 }, {
1741 key: "addRequest",
1742 value: function addRequest(action, options, immediately) {
1743 options = options || {};
1744 if (!options.unique_id) {
1745 options.unique_id = action;
1746 }
1747 options.deferred = jQuery.Deferred().done(options.success).fail(options.error).always(options.complete);
1748 var request = {
1749 action: action,
1750 options: options
1751 };
1752 if (immediately) {
1753 var requests = {};
1754 requests[options.unique_id] = request;
1755 options.deferred.jqXhr = this.sendBatch(requests);
1756 } else {
1757 this.requests[options.unique_id] = request;
1758 this.debounceSendBatch();
1759 }
1760 return options.deferred;
1761 }
1762 }, {
1763 key: "sendBatch",
1764 value: function sendBatch(requests) {
1765 var actions = {};
1766 if (!requests) {
1767 requests = this.requests;
1768
1769 // Empty for next batch.
1770 this.requests = {};
1771 }
1772 Object.entries(requests).forEach(function (_ref) {
1773 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
1774 id = _ref2[0],
1775 request = _ref2[1];
1776 return actions[id] = {
1777 action: request.action,
1778 data: request.options.data
1779 };
1780 });
1781 return this.send('ajax', {
1782 data: {
1783 actions: JSON.stringify(actions)
1784 },
1785 success: function success(data) {
1786 Object.entries(data.responses).forEach(function (_ref3) {
1787 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
1788 id = _ref4[0],
1789 response = _ref4[1];
1790 var options = requests[id].options;
1791 if (options) {
1792 if (response.success) {
1793 options.deferred.resolve(response.data);
1794 } else if (!response.success) {
1795 options.deferred.reject(response.data);
1796 }
1797 }
1798 });
1799 },
1800 error: function error(data) {
1801 return Object.values(requests).forEach(function (args) {
1802 if (args.options) {
1803 args.options.deferred.reject(data);
1804 }
1805 });
1806 }
1807 });
1808 }
1809 }, {
1810 key: "prepareSend",
1811 value: function prepareSend(action, options) {
1812 var _this4 = this;
1813 var settings = this.getSettings(),
1814 ajaxParams = elementorCommon.helpers.cloneObject(settings.ajaxParams);
1815 options = options || {};
1816 action = settings.actionPrefix + action;
1817 jQuery.extend(ajaxParams, options);
1818 var requestConstants = elementorCommon.helpers.cloneObject(this.requestConstants);
1819 requestConstants.action = action;
1820 var isFormData = ajaxParams.data instanceof FormData;
1821 Object.entries(requestConstants).forEach(function (_ref5) {
1822 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
1823 key = _ref6[0],
1824 value = _ref6[1];
1825 if (isFormData) {
1826 ajaxParams.data.append(key, value);
1827 } else {
1828 ajaxParams.data[key] = value;
1829 }
1830 });
1831 var successCallback = ajaxParams.success,
1832 errorCallback = ajaxParams.error;
1833 if (successCallback || errorCallback) {
1834 ajaxParams.success = function (response) {
1835 if (response.success && successCallback) {
1836 successCallback(response.data);
1837 }
1838 if (!response.success && errorCallback) {
1839 errorCallback(response.data);
1840 }
1841 };
1842 if (errorCallback) {
1843 ajaxParams.error = function (data) {
1844 return errorCallback(data);
1845 };
1846 } else {
1847 ajaxParams.error = function (xmlHttpRequest) {
1848 if (xmlHttpRequest.readyState || 'abort' !== xmlHttpRequest.statusText) {
1849 _this4.trigger('request:unhandledError', xmlHttpRequest);
1850 }
1851 };
1852 }
1853 }
1854 return ajaxParams;
1855 }
1856 }, {
1857 key: "send",
1858 value: function send(action, options) {
1859 return jQuery.ajax(this.prepareSend(action, options));
1860 }
1861 }, {
1862 key: "addRequestCache",
1863 value: function addRequestCache(request, data) {
1864 var cacheKey = this.getCacheKey(request);
1865 this.cache[cacheKey] = data;
1866 }
1867 }, {
1868 key: "invalidateCache",
1869 value: function invalidateCache(request) {
1870 var cacheKey = this.getCacheKey(request);
1871 delete this.cache[cacheKey];
1872 }
1873 }]);
1874 }(elementorModules.Module);
1875
1876 /***/ }),
1877
1878 /***/ "../core/common/modules/connect/assets/js/connect.js":
1879 /*!***********************************************************!*\
1880 !*** ../core/common/modules/connect/assets/js/connect.js ***!
1881 \***********************************************************/
1882 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1883
1884 "use strict";
1885 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
1886
1887
1888 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1889 Object.defineProperty(exports, "__esModule", ({
1890 value: true
1891 }));
1892 exports["default"] = void 0;
1893 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1894 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1895 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1896 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1897 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
1898 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1899 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)); }
1900 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1901 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; }
1902 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Vie) {
1903 function _default() {
1904 (0, _classCallCheck2.default)(this, _default);
1905 return _callSuper(this, _default, arguments);
1906 }
1907 (0, _inherits2.default)(_default, _elementorModules$Vie);
1908 return (0, _createClass2.default)(_default, [{
1909 key: "addPopupPlugin",
1910 value: function addPopupPlugin() {
1911 var counter = 0;
1912 jQuery.fn.elementorConnect = function (options) {
1913 var _this = this;
1914 // Open the Connect Dialog in a popup window.
1915 if (options !== null && options !== void 0 && options.popup) {
1916 jQuery(this).on('click', function (event) {
1917 var _options$popup, _options$popup2;
1918 event.preventDefault();
1919 var width = ((_options$popup = options.popup) === null || _options$popup === void 0 ? void 0 : _options$popup.width) || 600,
1920 height = ((_options$popup2 = options.popup) === null || _options$popup2 === void 0 ? void 0 : _options$popup2.height) || 700;
1921 window.open(jQuery(_this).attr('href') + '&mode=popup', 'elementorConnect', "toolbar=no, menubar=no, width=".concat(width, ", height=").concat(height, ", top=200, left=0"));
1922 });
1923 delete options.popup;
1924 }
1925 var settings = jQuery.extend({
1926 // These are the defaults.
1927 success: function success() {
1928 return location.reload();
1929 },
1930 error: function error() {
1931 elementor.notifications.showToast({
1932 message: __('Unable to connect', 'elementor')
1933 });
1934 },
1935 parseUrl: function parseUrl(url) {
1936 return url;
1937 } // Allow to change the url, e.g: replace placeholders like '%%template_type%%' with actual value.
1938 }, options);
1939 this.each(function () {
1940 counter++;
1941 var $this = jQuery(this),
1942 callbackId = 'cb' + counter;
1943 $this.attr({
1944 target: '_blank',
1945 rel: 'opener',
1946 href: settings.parseUrl($this.attr('href') + '&mode=popup&callback_id=' + callbackId)
1947 });
1948 elementorCommon.elements.$window.on('elementor/connect/success/' + callbackId, settings.success).on('elementor/connect/error/' + callbackId, settings.error);
1949 });
1950 return this;
1951 };
1952 }
1953 }, {
1954 key: "getDefaultSettings",
1955 value: function getDefaultSettings() {
1956 return {
1957 selectors: {
1958 connectButton: '#elementor-template-library-connect__button'
1959 }
1960 };
1961 }
1962 }, {
1963 key: "getDefaultElements",
1964 value: function getDefaultElements() {
1965 return {
1966 $connectButton: jQuery(this.getSettings('selectors.connectButton'))
1967 };
1968 }
1969 }, {
1970 key: "applyPopup",
1971 value: function applyPopup() {
1972 this.elements.$connectButton.elementorConnect();
1973 }
1974 }, {
1975 key: "onInit",
1976 value: function onInit() {
1977 _superPropGet(_default, "onInit", this, 3)([]);
1978 this.addPopupPlugin();
1979 this.applyPopup();
1980 }
1981 }]);
1982 }(elementorModules.ViewModule);
1983
1984 /***/ }),
1985
1986 /***/ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js":
1987 /*!**********************************************************************************!*\
1988 !*** ../core/common/modules/event-tracker/assets/js/data/commands-data/index.js ***!
1989 \**********************************************************************************/
1990 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1991
1992 "use strict";
1993
1994
1995 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1996 Object.defineProperty(exports, "__esModule", ({
1997 value: true
1998 }));
1999 exports.Index = void 0;
2000 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2001 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2002 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2003 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2004 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2005 var _commandData = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-data */ "../modules/web-cli/assets/js/modules/command-data.js"));
2006 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)); }
2007 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2008 var Index = exports.Index = /*#__PURE__*/function (_CommandData) {
2009 function Index() {
2010 (0, _classCallCheck2.default)(this, Index);
2011 return _callSuper(this, Index, arguments);
2012 }
2013 (0, _inherits2.default)(Index, _CommandData);
2014 return (0, _createClass2.default)(Index, null, [{
2015 key: "getEndpointFormat",
2016 value: function getEndpointFormat() {
2017 return 'send-event';
2018 }
2019 }]);
2020 }(_commandData.default);
2021
2022 /***/ }),
2023
2024 /***/ "../core/common/modules/event-tracker/assets/js/data/component.js":
2025 /*!************************************************************************!*\
2026 !*** ../core/common/modules/event-tracker/assets/js/data/component.js ***!
2027 \************************************************************************/
2028 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2029
2030 "use strict";
2031
2032
2033 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2034 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2035 Object.defineProperty(exports, "__esModule", ({
2036 value: true
2037 }));
2038 exports["default"] = void 0;
2039 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2040 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2041 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2042 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2043 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2044 var _componentBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
2045 var commandsData = _interopRequireWildcard(__webpack_require__(/*! ./commands-data/ */ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js"));
2046 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); }
2047 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)); }
2048 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2049 var Component = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
2050 function Component() {
2051 (0, _classCallCheck2.default)(this, Component);
2052 return _callSuper(this, Component, arguments);
2053 }
2054 (0, _inherits2.default)(Component, _ComponentBase);
2055 return (0, _createClass2.default)(Component, [{
2056 key: "getNamespace",
2057 value: function getNamespace() {
2058 return 'event-tracker';
2059 }
2060 }, {
2061 key: "defaultData",
2062 value: function defaultData() {
2063 return this.importCommands(commandsData);
2064 }
2065 }]);
2066 }(_componentBase.default);
2067
2068 /***/ }),
2069
2070 /***/ "../core/common/modules/event-tracker/assets/js/events.js":
2071 /*!****************************************************************!*\
2072 !*** ../core/common/modules/event-tracker/assets/js/events.js ***!
2073 \****************************************************************/
2074 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2075
2076 "use strict";
2077
2078
2079 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2080 Object.defineProperty(exports, "__esModule", ({
2081 value: true
2082 }));
2083 exports["default"] = void 0;
2084 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2085 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2086 var _time = _interopRequireDefault(__webpack_require__(/*! elementor-utils/time */ "../assets/dev/js/utils/time.js"));
2087 var Events = exports["default"] = /*#__PURE__*/function () {
2088 function Events() {
2089 (0, _classCallCheck2.default)(this, Events);
2090 }
2091 return (0, _createClass2.default)(Events, [{
2092 key: "dispatchEvent",
2093 value: function dispatchEvent(eventData) {
2094 if (!eventData) {
2095 return;
2096 }
2097 eventData.ts = (0, _time.default)();
2098
2099 // No need to wait for response, no need to block browser in any way.
2100 $e.data.create('event-tracker/index', {
2101 event_data: eventData
2102 });
2103 }
2104 }]);
2105 }();
2106
2107 /***/ }),
2108
2109 /***/ "../core/common/modules/events-manager/assets/js/events-config.js":
2110 /*!************************************************************************!*\
2111 !*** ../core/common/modules/events-manager/assets/js/events-config.js ***!
2112 \************************************************************************/
2113 /***/ ((__unused_webpack_module, exports) => {
2114
2115 "use strict";
2116
2117
2118 Object.defineProperty(exports, "__esModule", ({
2119 value: true
2120 }));
2121 exports["default"] = void 0;
2122 var eventsConfig = {
2123 appTypes: {
2124 editor: 'editor',
2125 wpAdmin: 'wpadmin'
2126 },
2127 targetTypes: {
2128 dropdownItem: 'dropdown_item',
2129 button: 'button',
2130 tab: 'tab',
2131 toggle: 'toggle',
2132 searchInput: 'search_input',
2133 searchResult: 'search_result',
2134 buttons: 'buttons',
2135 searchWidget: 'search_widget'
2136 },
2137 interactionResults: {
2138 actionSelected: 'action_selected',
2139 navigate: 'navigate',
2140 create: 'create',
2141 sessionEnd: 'session_end',
2142 tabChanged: 'tab_changed',
2143 assetInserted: 'asset_inserted',
2144 assetFavorite: 'asset_favorite',
2145 aiGenerate: 'ai_generate',
2146 resultsUpdated: 'results_updated',
2147 noResults: 'no_results',
2148 selected: 'selected'
2149 },
2150 targetNames: {
2151 publishDropdown: {
2152 saveDraft: 'save_draft',
2153 saveAsTemplate: 'save_as_template',
2154 viewPage: 'view_page',
2155 copyAndShare: 'copy_and_share'
2156 },
2157 pageList: {
2158 addNewPage: 'add_new_page'
2159 }
2160 },
2161 triggers: {
2162 click: 'Click',
2163 rightClick: 'Right Click',
2164 doubleClick: 'Double Click',
2165 accordionClick: 'Accordion Click',
2166 toggleClick: 'Toggle Click',
2167 dropdownClick: 'Click Dropdown',
2168 editorLoaded: 'Editor Loaded',
2169 visible: 'Visible',
2170 pageLoaded: 'Page Loaded',
2171 typing: 'Typing',
2172 tabSelect: 'Tab Select',
2173 insert: 'Insert'
2174 },
2175 locations: {
2176 widgetPanel: 'Widget Panel',
2177 topBar: 'Top Bar',
2178 sidebar: 'Sidebar',
2179 elementorEditor: 'Elementor Editor',
2180 templatesLibrary: {
2181 library: 'Templates Library'
2182 },
2183 app: {
2184 import: 'Import Kit',
2185 export: 'Export Kit',
2186 kitLibrary: 'Kit Library',
2187 cloudKitLibrary: 'Cloud Kit Library'
2188 },
2189 variables: 'Variables Panel',
2190 variablesManager: 'Variables Manager',
2191 admin: 'WP admin',
2192 structurePanel: 'Structure Panel',
2193 canvas: 'Canvas',
2194 leftPanel: 'Left Panel',
2195 elementorLibrary: 'Elementor Library'
2196 },
2197 secondaryLocations: {
2198 layout: 'Layout Section',
2199 basic: 'Basic Section',
2200 'pro-elements': 'Pro Section',
2201 general: 'General Section',
2202 'theme-elements': 'Site Section',
2203 'theme-elements-single': 'Single Section',
2204 'woocommerce-elements': 'WooCommerce Section',
2205 wordpress: 'WordPress Section',
2206 categories: 'Widgets Tab',
2207 global: 'Globals Tab',
2208 'whats-new': 'What\'s New',
2209 'document-settings': 'Document Settings icon',
2210 'preview-page': 'Preview Page',
2211 'publish-button': 'Publish Button',
2212 'widget-panel': 'Widget Panel Icon',
2213 finder: 'Finder',
2214 help: 'Help',
2215 elementorLogoDropdown: 'top_bar_elementor_logo_dropdown',
2216 elementorLogo: 'Elementor Logo',
2217 eLogoMenu: 'E-logo Menu',
2218 notes: 'Notes',
2219 siteSettings: 'Site Settings',
2220 structure: 'Structure',
2221 documentNameDropdown: 'Document Name dropdown',
2222 responsiveControls: 'Responsive controls',
2223 launchpad: 'launchpad',
2224 checklistHeader: 'Checklist Header',
2225 checklistSteps: 'Checklist Steps',
2226 userPreferences: 'User Preferences',
2227 contextMenu: 'Context Menu',
2228 templateLibrary: {
2229 saveModal: 'Save to Modal',
2230 moveModal: 'Move to Modal',
2231 bulkMoveModal: 'Bulk Move to Modal',
2232 copyModal: 'Copy to Modal',
2233 bulkCopyModal: 'Bulk Copy to Modal',
2234 saveModalSelectFolder: 'Save to Modal - select folder',
2235 saveModalSelectConnect: 'Save to Modal - connect',
2236 saveModalSelectUpgrade: 'Save to Modal - upgrade',
2237 importModal: 'Import Modal',
2238 newFolderModal: 'New Folder Modal',
2239 deleteDialog: 'Delete Dialog',
2240 deleteFolderDialog: 'Delete Folder Dialog',
2241 renameDialog: 'Rename Dialog',
2242 createFolderDialog: 'Create Folder Dialog',
2243 applySettingsDialog: 'Apply Settings Dialog',
2244 cloudTab: 'Cloud Tab',
2245 siteTab: 'Site Tab',
2246 cloudTabFolder: 'Cloud Tab - Folder',
2247 cloudTabConnect: 'Cloud Tab - Connect',
2248 cloudTabUpgrade: 'Cloud Tab - Upgrade',
2249 morePopup: 'Context Menu',
2250 quotaBar: 'Quota Bar'
2251 },
2252 kitLibrary: {
2253 cloudKitLibrary: 'kits_cloud_library',
2254 cloudKitLibraryConnect: 'kits_cloud_library_connect',
2255 cloudKitLibraryUpgrade: 'kits_cloud_library_upgrade',
2256 kitExportCustomization: 'kit_export_customization',
2257 kitExport: 'kit_export',
2258 kitExportCustomizationEdit: 'kit_export_customization_edit',
2259 kitExportSummary: 'kit_export_summary',
2260 kitImportUploadBox: 'kit_import_upload_box',
2261 kitImportCustomization: 'kit_import_customization',
2262 kitImportSummary: 'kit_import_summary'
2263 },
2264 variablesPopover: 'Variables Popover',
2265 admin: {
2266 pluginToolsTab: 'plugin_tools_tab',
2267 pluginWebsiteTemplatesTab: 'plugin_website_templates_tab'
2268 },
2269 componentsTab: 'Components Tab',
2270 canvasElement: 'Canvas Element',
2271 publishDropdown: 'Publish Dropdown',
2272 pageListDropdown: 'Page List Dropdown',
2273 emptyBox: 'Empty Box',
2274 searchBar: 'Search Bar',
2275 finderResults: 'Finder Results',
2276 libraryTabs: 'Library Tabs',
2277 assetCard: 'Asset Card'
2278 },
2279 elements: {
2280 accordionSection: 'Accordion section',
2281 buttonIcon: 'Button Icon',
2282 mainCta: 'Main CTA',
2283 button: 'Button',
2284 link: 'Link',
2285 dropdown: 'Dropdown',
2286 toggle: 'Toggle',
2287 launchpadChecklist: 'Checklist popup'
2288 },
2289 names: {
2290 v1: {
2291 layout: 'v1_widgets_tab_layout_section',
2292 basic: 'v1_widgets_tab_basic_section',
2293 'pro-elements': 'v1_widgets_tab_pro_section',
2294 general: 'v1_widgets_tab_general_section',
2295 'theme-elements': 'v1_widgets_tab_site_section',
2296 'theme-elements-single': 'v1_widgets_tab_single_section',
2297 'woocommerce-elements': 'v1_widgets_tab_woocommerce_section',
2298 wordpress: 'v1_widgets_tab_wordpress_section',
2299 categories: 'v1_widgets_tab',
2300 global: 'v1_globals_tab'
2301 },
2302 topBar: {
2303 whatsNew: 'top_bar_whats_new',
2304 documentSettings: 'top_bar_document_settings_icon',
2305 previewPage: 'top_bar_preview_page',
2306 publishButton: 'top_bar_publish_button',
2307 widgetPanel: 'top_bar_widget_panel_icon',
2308 finder: 'top_bar_finder',
2309 help: 'top_bar_help',
2310 history: 'top_bar_elementor_logo_dropdown_history',
2311 userPreferences: 'top_bar_elementor_logo_dropdown_user_preferences',
2312 keyboardShortcuts: 'top_bar_elementor_logo_dropdown_keyboard_shortcuts',
2313 exitToWordpress: 'top_bar_elementor_logo_dropdown_exit_to_wordpress',
2314 themeBuilder: 'top_bar_elementor_logo_dropdown_theme_builder',
2315 notes: 'top_bar_notes',
2316 siteSettings: 'top_bar_site_setting',
2317 structure: 'top_bar_structure',
2318 documentNameDropdown: 'top_bar_document_name_dropdown',
2319 responsiveControls: 'top_bar_responsive_controls',
2320 launchpadOn: 'top_bar_checklist_icon_show',
2321 launchpadOff: 'top_bar_checklist_icon_hide',
2322 elementorLogoDropdown: 'open_e_menu',
2323 connectAccount: 'connect_account',
2324 accountConnected: 'account_connected'
2325 },
2326 // ChecklistSteps event names are generated dynamically, based on stepId and action type taken: title, action, done, undone, upgrade
2327 elementorEditor: {
2328 checklist: {
2329 checklistHeaderClose: 'checklist_header_close_icon',
2330 checklistFirstPopup: 'checklist popup triggered'
2331 },
2332 userPreferences: {
2333 checklistShow: 'checklist_userpreferences_toggle_show',
2334 checklistHide: 'checklist_userpreferences_toggle_hide'
2335 }
2336 },
2337 variables: {
2338 open: 'open_variables_popover',
2339 add: 'add_new_variable',
2340 connect: 'connect_variable',
2341 save: 'save_new_variable',
2342 openManager: 'open_variables_manager',
2343 saveChanges: 'save_variables_changes',
2344 delete: 'delete_variable'
2345 },
2346 components: {
2347 createClicked: 'component_create_clicked',
2348 createCancelled: 'component_creation_cancelled',
2349 created: 'component_created',
2350 instanceAdded: 'component_instance_added',
2351 edited: 'component_edited',
2352 propertiesPanelOpened: 'component_properties_panel_opened',
2353 propertiesGroupCreated: 'component_properties_group_created',
2354 propertyExposed: 'component_property_exposed',
2355 propertyRemoved: 'component_property_removed'
2356 },
2357 global_classes: {
2358 classApplied: 'class_applied',
2359 classRemoved: 'class_removed',
2360 classManagerFilterCleared: 'class_manager_filter_cleared',
2361 classDeleted: 'class_deleted',
2362 classPublishConflict: 'class_publish_conflict',
2363 classRenamed: 'class_renamed',
2364 classCreated: 'class_created',
2365 classManagerSearched: 'class_manager_searched',
2366 classManagerFiltersOpened: 'class_manager_filters_opened',
2367 classManagerOpened: 'class_manager_opened',
2368 classManagerReorder: 'class_manager_reorder',
2369 classManagerFilterUsed: 'class_manager_filter_used',
2370 classUsageLocate: 'class_usage_locate',
2371 classUsageHovered: 'class_usage_hovered',
2372 classStyled: 'class_styled',
2373 classStateClicked: 'class_state_clicked',
2374 classUsageClicked: 'class_usage_clicked',
2375 classDuplicate: 'class_duplicate'
2376 },
2377 editorOne: {
2378 topBarPublishDropdown: 'top_bar_publish_dropdown',
2379 topBarPageList: 'top_bar_page_list',
2380 siteSettingsSession: 'site_settings_session',
2381 eLibraryNav: 'e_library_nav',
2382 eLibraryInsert: 'e_library_insert',
2383 eLibraryFavorite: 'e_library_favorite',
2384 eLibraryGenerateAi: 'e_library_generate_ai',
2385 finderSearchInput: 'finder_search_input',
2386 finderResultSelect: 'finder_result_select',
2387 canvasEmptyBoxAction: 'canvas_empty_box_action',
2388 widgetPanelSearch: 'widget_panel_search'
2389 }
2390 }
2391 };
2392 var _default = exports["default"] = eventsConfig;
2393
2394 /***/ }),
2395
2396 /***/ "../core/common/modules/events-manager/assets/js/module.js":
2397 /*!*****************************************************************!*\
2398 !*** ../core/common/modules/events-manager/assets/js/module.js ***!
2399 \*****************************************************************/
2400 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2401
2402 "use strict";
2403
2404
2405 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2406 Object.defineProperty(exports, "__esModule", ({
2407 value: true
2408 }));
2409 exports["default"] = void 0;
2410 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
2411 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
2412 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2413 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2414 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2415 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2416 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2417 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2418 var _eventsConfig = _interopRequireDefault(__webpack_require__(/*! ./events-config */ "../core/common/modules/events-manager/assets/js/events-config.js"));
2419 var _mixpanelBrowser = _interopRequireDefault(__webpack_require__(/*! mixpanel-browser */ "../node_modules/mixpanel-browser/dist/mixpanel.module.js"));
2420 var _tiers = __webpack_require__(/*! elementor-utils/tiers */ "../assets/dev/js/utils/tiers.js");
2421 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; }
2422 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; }
2423 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)); }
2424 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2425 function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
2426 function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
2427 function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
2428 function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
2429 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"); }
2430 var _sessionRecordingInProgress = /*#__PURE__*/new WeakMap();
2431 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2432 function _default() {
2433 var _this;
2434 (0, _classCallCheck2.default)(this, _default);
2435 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2436 args[_key] = arguments[_key];
2437 }
2438 _this = _callSuper(this, _default, [].concat(args));
2439 (0, _defineProperty2.default)(_this, "trackingEnabled", false);
2440 _classPrivateFieldInitSpec(_this, _sessionRecordingInProgress, false);
2441 return _this;
2442 }
2443 (0, _inherits2.default)(_default, _elementorModules$Mod);
2444 return (0, _createClass2.default)(_default, [{
2445 key: "onInit",
2446 value: function onInit() {
2447 var _this2 = this;
2448 this.config = _eventsConfig.default;
2449 if (!this.canSendEvents()) {
2450 return;
2451 }
2452 this.initializeMixpanel(function () {
2453 return _this2.enableTracking();
2454 });
2455 }
2456 }, {
2457 key: "initializeMixpanel",
2458 value: function initializeMixpanel(onLoaded) {
2459 var _elementorCommon$conf;
2460 _mixpanelBrowser.default.init((_elementorCommon$conf = elementorCommon.config.editor_events) === null || _elementorCommon$conf === void 0 ? void 0 : _elementorCommon$conf.token, {
2461 persistence: 'localStorage',
2462 autocapture: false,
2463 record_sessions_percent: 0,
2464 record_idle_timeout_ms: 60000,
2465 record_max_ms: 300000,
2466 record_mask_text_selector: '',
2467 flags: true,
2468 api_hosts: {
2469 flags: 'https://api-eu.mixpanel.com'
2470 },
2471 loaded: onLoaded
2472 });
2473 }
2474 }, {
2475 key: "enableTracking",
2476 value: function enableTracking() {
2477 var _elementorCommon$conf2;
2478 if (!this.isMixpanelReady()) {
2479 return;
2480 }
2481 var userId = (_elementorCommon$conf2 = elementorCommon.config.library_connect) === null || _elementorCommon$conf2 === void 0 ? void 0 : _elementorCommon$conf2.user_id;
2482 if (userId) {
2483 var _elementorCommon$conf3;
2484 _mixpanelBrowser.default.identify(userId);
2485 _mixpanelBrowser.default.register({
2486 appType: 'Editor'
2487 });
2488 _mixpanelBrowser.default.people.set_once({
2489 $user_id: userId,
2490 $last_login: new Date().toISOString(),
2491 $plan_type: ((_elementorCommon$conf3 = elementorCommon.config.library_connect) === null || _elementorCommon$conf3 === void 0 ? void 0 : _elementorCommon$conf3.plan_type) || _tiers.TIERS.free
2492 });
2493 }
2494 this.trackingEnabled = true;
2495 }
2496 }, {
2497 key: "dispatchEvent",
2498 value: function dispatchEvent(name, data) {
2499 var _elementorCommon$conf4, _elementorCommon$conf5, _elementorCommon$conf6, _elementorCommon$conf7, _elementorCommon$conf8, _elementorCommon$conf9, _elementorCommon$conf0, _elementorCommon$conf1, _elementorCommon$conf10;
2500 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2501 if (!this.canSendEvents()) {
2502 return;
2503 }
2504 if (!this.trackingEnabled) {
2505 this.enableTracking();
2506 }
2507 var eventData = _objectSpread({
2508 user_id: ((_elementorCommon$conf4 = elementorCommon.config.library_connect) === null || _elementorCommon$conf4 === void 0 ? void 0 : _elementorCommon$conf4.user_id) || null,
2509 user_roles: ((_elementorCommon$conf5 = elementorCommon.config.library_connect) === null || _elementorCommon$conf5 === void 0 ? void 0 : _elementorCommon$conf5.user_roles) || [],
2510 subscription_id: ((_elementorCommon$conf6 = elementorCommon.config.editor_events) === null || _elementorCommon$conf6 === void 0 ? void 0 : _elementorCommon$conf6.subscription_id) || null,
2511 user_tier: ((_elementorCommon$conf7 = elementorCommon.config.library_connect) === null || _elementorCommon$conf7 === void 0 ? void 0 : _elementorCommon$conf7.current_access_tier) || null,
2512 url: (_elementorCommon$conf8 = elementorCommon.config.editor_events) === null || _elementorCommon$conf8 === void 0 ? void 0 : _elementorCommon$conf8.site_url,
2513 wp_version: (_elementorCommon$conf9 = elementorCommon.config.editor_events) === null || _elementorCommon$conf9 === void 0 ? void 0 : _elementorCommon$conf9.wp_version,
2514 client_id: (_elementorCommon$conf0 = elementorCommon.config.editor_events) === null || _elementorCommon$conf0 === void 0 ? void 0 : _elementorCommon$conf0.site_key,
2515 app_version: (_elementorCommon$conf1 = elementorCommon.config.editor_events) === null || _elementorCommon$conf1 === void 0 ? void 0 : _elementorCommon$conf1.elementor_version,
2516 site_language: (_elementorCommon$conf10 = elementorCommon.config.editor_events) === null || _elementorCommon$conf10 === void 0 ? void 0 : _elementorCommon$conf10.site_language
2517 }, data);
2518 _mixpanelBrowser.default.track(name, eventData, options);
2519 }
2520 }, {
2521 key: "startSessionRecording",
2522 value: function startSessionRecording() {
2523 if (!this.canSendEvents() || this.isSessionRecordingInProgress()) {
2524 return;
2525 }
2526 if (!this.trackingEnabled) {
2527 this.enableTracking();
2528 }
2529 _mixpanelBrowser.default.start_session_recording();
2530 this.setSessionRecordingInProgress(true);
2531 }
2532 }, {
2533 key: "stopSessionRecording",
2534 value: function stopSessionRecording() {
2535 if (!this.canSendEvents() || !this.isSessionRecordingInProgress()) {
2536 return;
2537 }
2538 _mixpanelBrowser.default.stop_session_recording();
2539 this.setSessionRecordingInProgress(false);
2540 }
2541 }, {
2542 key: "setSessionRecordingInProgress",
2543 value: function setSessionRecordingInProgress(value) {
2544 if ('boolean' !== typeof value) {
2545 return;
2546 }
2547 _classPrivateFieldSet(_sessionRecordingInProgress, this, value);
2548 }
2549 }, {
2550 key: "isSessionRecordingInProgress",
2551 value: function isSessionRecordingInProgress() {
2552 return _classPrivateFieldGet(_sessionRecordingInProgress, this);
2553 }
2554 }, {
2555 key: "featureFlagIsActive",
2556 value: function () {
2557 var _featureFlagIsActive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(flagName) {
2558 var _mixpanel$flags;
2559 var isEnabled;
2560 return _regenerator.default.wrap(function (_context) {
2561 while (1) switch (_context.prev = _context.next) {
2562 case 0:
2563 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))) {
2564 _context.next = 1;
2565 break;
2566 }
2567 return _context.abrupt("return", false);
2568 case 1:
2569 _context.next = 2;
2570 return _mixpanelBrowser.default.flags.is_enabled(flagName, false);
2571 case 2:
2572 isEnabled = _context.sent;
2573 return _context.abrupt("return", true === isEnabled);
2574 case 3:
2575 case "end":
2576 return _context.stop();
2577 }
2578 }, _callee);
2579 }));
2580 function featureFlagIsActive(_x) {
2581 return _featureFlagIsActive.apply(this, arguments);
2582 }
2583 return featureFlagIsActive;
2584 }()
2585 }, {
2586 key: "getExperimentVariant",
2587 value: function () {
2588 var _getExperimentVariant = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(experimentName) {
2589 var defaultValue,
2590 _elementorCommon$conf11,
2591 _elementorCommon$conf12,
2592 isAbTestingEnabled,
2593 variant,
2594 _args2 = arguments,
2595 _t;
2596 return _regenerator.default.wrap(function (_context2) {
2597 while (1) switch (_context2.prev = _context2.next) {
2598 case 0:
2599 defaultValue = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 'control';
2600 _context2.prev = 1;
2601 if (this.canSendEvents()) {
2602 _context2.next = 2;
2603 break;
2604 }
2605 return _context2.abrupt("return", defaultValue);
2606 case 2:
2607 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;
2608 if (isAbTestingEnabled) {
2609 _context2.next = 3;
2610 break;
2611 }
2612 return _context2.abrupt("return", defaultValue);
2613 case 3:
2614 if (_mixpanelBrowser.default) {
2615 _context2.next = 4;
2616 break;
2617 }
2618 return _context2.abrupt("return", defaultValue);
2619 case 4:
2620 if (!this.trackingEnabled) {
2621 this.enableTracking();
2622 }
2623 if (_mixpanelBrowser.default.flags) {
2624 _context2.next = 5;
2625 break;
2626 }
2627 return _context2.abrupt("return", defaultValue);
2628 case 5:
2629 if (!('function' !== typeof _mixpanelBrowser.default.flags.get_variant_value)) {
2630 _context2.next = 6;
2631 break;
2632 }
2633 return _context2.abrupt("return", defaultValue);
2634 case 6:
2635 _context2.next = 7;
2636 return _mixpanelBrowser.default.flags.get_variant_value(experimentName, defaultValue);
2637 case 7:
2638 variant = _context2.sent;
2639 if (!(undefined === variant || null === variant)) {
2640 _context2.next = 8;
2641 break;
2642 }
2643 return _context2.abrupt("return", defaultValue);
2644 case 8:
2645 return _context2.abrupt("return", variant);
2646 case 9:
2647 _context2.prev = 9;
2648 _t = _context2["catch"](1);
2649 return _context2.abrupt("return", defaultValue);
2650 case 10:
2651 case "end":
2652 return _context2.stop();
2653 }
2654 }, _callee2, this, [[1, 9]]);
2655 }));
2656 function getExperimentVariant(_x2) {
2657 return _getExperimentVariant.apply(this, arguments);
2658 }
2659 return getExperimentVariant;
2660 }()
2661 }, {
2662 key: "startExperiment",
2663 value: function startExperiment(experimentName, experimentVariant) {
2664 if (!this.trackingEnabled) {
2665 return;
2666 }
2667 _mixpanelBrowser.default.track('$experiment_started', {
2668 'Experiment name': experimentName,
2669 'Variant name': experimentVariant
2670 });
2671 }
2672 }, {
2673 key: "isMixpanelReady",
2674 value: function isMixpanelReady() {
2675 if ('undefined' === typeof _mixpanelBrowser.default || !_mixpanelBrowser.default) {
2676 return false;
2677 }
2678 try {
2679 var distinctId = _mixpanelBrowser.default.get_distinct_id();
2680 return distinctId !== undefined && distinctId !== null;
2681 } catch (error) {
2682 return false;
2683 }
2684 }
2685 }, {
2686 key: "canSendEvents",
2687 value: function canSendEvents() {
2688 var _elementorCommon;
2689 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);
2690 }
2691 }]);
2692 }(elementorModules.Module);
2693
2694 /***/ }),
2695
2696 /***/ "../core/common/modules/finder/assets/js/commands/index.js":
2697 /*!*****************************************************************!*\
2698 !*** ../core/common/modules/finder/assets/js/commands/index.js ***!
2699 \*****************************************************************/
2700 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2701
2702 "use strict";
2703
2704
2705 Object.defineProperty(exports, "__esModule", ({
2706 value: true
2707 }));
2708 Object.defineProperty(exports, "NavigateDown", ({
2709 enumerable: true,
2710 get: function get() {
2711 return _navigateDown.NavigateDown;
2712 }
2713 }));
2714 Object.defineProperty(exports, "NavigateSelect", ({
2715 enumerable: true,
2716 get: function get() {
2717 return _navigateSelect.NavigateSelect;
2718 }
2719 }));
2720 Object.defineProperty(exports, "NavigateUp", ({
2721 enumerable: true,
2722 get: function get() {
2723 return _navigateUp.NavigateUp;
2724 }
2725 }));
2726 var _navigateDown = __webpack_require__(/*! ./navigate-down */ "../core/common/modules/finder/assets/js/commands/navigate-down.js");
2727 var _navigateSelect = __webpack_require__(/*! ./navigate-select */ "../core/common/modules/finder/assets/js/commands/navigate-select.js");
2728 var _navigateUp = __webpack_require__(/*! ./navigate-up */ "../core/common/modules/finder/assets/js/commands/navigate-up.js");
2729
2730 /***/ }),
2731
2732 /***/ "../core/common/modules/finder/assets/js/commands/navigate-down.js":
2733 /*!*************************************************************************!*\
2734 !*** ../core/common/modules/finder/assets/js/commands/navigate-down.js ***!
2735 \*************************************************************************/
2736 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2737
2738 "use strict";
2739
2740
2741 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2742 Object.defineProperty(exports, "__esModule", ({
2743 value: true
2744 }));
2745 exports["default"] = exports.NavigateDown = void 0;
2746 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2747 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2748 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2749 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2750 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2751 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2752 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)); }
2753 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2754 var NavigateDown = exports.NavigateDown = /*#__PURE__*/function (_CommandBase) {
2755 function NavigateDown() {
2756 (0, _classCallCheck2.default)(this, NavigateDown);
2757 return _callSuper(this, NavigateDown, arguments);
2758 }
2759 (0, _inherits2.default)(NavigateDown, _CommandBase);
2760 return (0, _createClass2.default)(NavigateDown, [{
2761 key: "apply",
2762 value: function apply() {
2763 this.component.getItemsView().activateNextItem();
2764 }
2765 }]);
2766 }(_commandBase.default);
2767 var _default = exports["default"] = NavigateDown;
2768
2769 /***/ }),
2770
2771 /***/ "../core/common/modules/finder/assets/js/commands/navigate-select.js":
2772 /*!***************************************************************************!*\
2773 !*** ../core/common/modules/finder/assets/js/commands/navigate-select.js ***!
2774 \***************************************************************************/
2775 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2776
2777 "use strict";
2778
2779
2780 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2781 Object.defineProperty(exports, "__esModule", ({
2782 value: true
2783 }));
2784 exports["default"] = exports.NavigateSelect = void 0;
2785 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2786 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2787 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2788 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2789 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2790 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2791 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)); }
2792 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2793 var NavigateSelect = exports.NavigateSelect = /*#__PURE__*/function (_CommandBase) {
2794 function NavigateSelect() {
2795 (0, _classCallCheck2.default)(this, NavigateSelect);
2796 return _callSuper(this, NavigateSelect, arguments);
2797 }
2798 (0, _inherits2.default)(NavigateSelect, _CommandBase);
2799 return (0, _createClass2.default)(NavigateSelect, [{
2800 key: "apply",
2801 value: function apply(args) {
2802 this.component.getItemsView().goToActiveItem(args);
2803 }
2804 }]);
2805 }(_commandBase.default);
2806 var _default = exports["default"] = NavigateSelect;
2807
2808 /***/ }),
2809
2810 /***/ "../core/common/modules/finder/assets/js/commands/navigate-up.js":
2811 /*!***********************************************************************!*\
2812 !*** ../core/common/modules/finder/assets/js/commands/navigate-up.js ***!
2813 \***********************************************************************/
2814 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2815
2816 "use strict";
2817
2818
2819 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2820 Object.defineProperty(exports, "__esModule", ({
2821 value: true
2822 }));
2823 exports["default"] = exports.NavigateUp = void 0;
2824 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2825 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2826 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2827 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2828 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2829 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2830 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2831 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2832 var NavigateUp = exports.NavigateUp = /*#__PURE__*/function (_CommandBase) {
2833 function NavigateUp() {
2834 (0, _classCallCheck2.default)(this, NavigateUp);
2835 return _callSuper(this, NavigateUp, arguments);
2836 }
2837 (0, _inherits2.default)(NavigateUp, _CommandBase);
2838 return (0, _createClass2.default)(NavigateUp, [{
2839 key: "apply",
2840 value: function apply() {
2841 this.component.getItemsView().activateNextItem(true);
2842 }
2843 }]);
2844 }(_commandBase.default);
2845 var _default = exports["default"] = NavigateUp;
2846
2847 /***/ }),
2848
2849 /***/ "../core/common/modules/finder/assets/js/component.js":
2850 /*!************************************************************!*\
2851 !*** ../core/common/modules/finder/assets/js/component.js ***!
2852 \************************************************************/
2853 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2854
2855 "use strict";
2856
2857
2858 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2859 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2860 Object.defineProperty(exports, "__esModule", ({
2861 value: true
2862 }));
2863 exports["default"] = void 0;
2864 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2865 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2866 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2867 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2868 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2869 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2870 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2871 var _componentModalBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-modal-base */ "../modules/web-cli/assets/js/modules/component-modal-base.js"));
2872 var _layout = _interopRequireDefault(__webpack_require__(/*! ./modal/views/layout */ "../core/common/modules/finder/assets/js/modal/views/layout.js"));
2873 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../core/common/modules/finder/assets/js/commands/index.js"));
2874 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); }
2875 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; }
2876 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; }
2877 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)); }
2878 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2879 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; }
2880 var Component = exports["default"] = /*#__PURE__*/function (_ComponentModalBase) {
2881 function Component() {
2882 (0, _classCallCheck2.default)(this, Component);
2883 return _callSuper(this, Component, arguments);
2884 }
2885 (0, _inherits2.default)(Component, _ComponentModalBase);
2886 return (0, _createClass2.default)(Component, [{
2887 key: "getNamespace",
2888 value: function getNamespace() {
2889 return 'finder';
2890 }
2891 }, {
2892 key: "defaultShortcuts",
2893 value: function defaultShortcuts() {
2894 var _this = this;
2895 return {
2896 '': {
2897 keys: 'ctrl+e'
2898 },
2899 'navigate-down': {
2900 keys: 'down',
2901 scopes: [this.getNamespace()],
2902 dependency: function dependency() {
2903 return _this.getItemsView();
2904 }
2905 },
2906 'navigate-up': {
2907 keys: 'up',
2908 scopes: [this.getNamespace()],
2909 dependency: function dependency() {
2910 return _this.getItemsView();
2911 }
2912 },
2913 'navigate-select': {
2914 keys: 'enter',
2915 scopes: [this.getNamespace()],
2916 dependency: function dependency() {
2917 return _this.getItemsView().$activeItem;
2918 }
2919 }
2920 };
2921 }
2922 }, {
2923 key: "defaultCommands",
2924 value: function defaultCommands() {
2925 var modalCommands = _superPropGet(Component, "defaultCommands", this, 3)([]);
2926 return _objectSpread(_objectSpread({
2927 'navigate/down': function navigate_down() {
2928 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/down' )", '3.0.0', "$e.run( 'finder/navigate-down' )");
2929 $e.run('finder/navigate-down');
2930 },
2931 'navigate/up': function navigate_up() {
2932 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/up' )", '3.0.0', "$e.run( 'finder/navigate-up' )");
2933 $e.run('finder/navigate-up');
2934 },
2935 'navigate/select': function navigate_select(event) {
2936 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/select', event )", '3.0.0', "$e.run( 'finder/navigate-select', event )");
2937
2938 // TODO: Fix $e.shortcuts use args. ( args.event ).
2939 $e.run('finder/navigate-select', event);
2940 }
2941 }, modalCommands), this.importCommands(commands));
2942 }
2943 }, {
2944 key: "getModalLayout",
2945 value: function getModalLayout() {
2946 return _layout.default;
2947 }
2948 }, {
2949 key: "getItemsView",
2950 value: function getItemsView() {
2951 return this.layout.modalContent.currentView.content.currentView;
2952 }
2953 }]);
2954 }(_componentModalBase.default);
2955
2956 /***/ }),
2957
2958 /***/ "../core/common/modules/finder/assets/js/finder.js":
2959 /*!*********************************************************!*\
2960 !*** ../core/common/modules/finder/assets/js/finder.js ***!
2961 \*********************************************************/
2962 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2963
2964 "use strict";
2965
2966
2967 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2968 Object.defineProperty(exports, "__esModule", ({
2969 value: true
2970 }));
2971 exports["default"] = void 0;
2972 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2973 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2974 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2975 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2976 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2977 var _component = _interopRequireDefault(__webpack_require__(/*! ./component */ "../core/common/modules/finder/assets/js/component.js"));
2978 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)); }
2979 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2980 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2981 function _default() {
2982 (0, _classCallCheck2.default)(this, _default);
2983 return _callSuper(this, _default, arguments);
2984 }
2985 (0, _inherits2.default)(_default, _elementorModules$Mod);
2986 return (0, _createClass2.default)(_default, [{
2987 key: "onInit",
2988 value: function onInit() {
2989 // TODO: Temp fix, do not load finder in theme-builder.
2990 // Better to pass into '$e' constructor the app owner. ( admin, editor, preview, iframe ).
2991 if (window.top !== window) {
2992 return;
2993 }
2994 this.channel = Backbone.Radio.channel('ELEMENTOR:finder');
2995 $e.components.register(new _component.default({
2996 manager: this
2997 }));
2998 }
2999 }]);
3000 }(elementorModules.Module);
3001
3002 /***/ }),
3003
3004 /***/ "../core/common/modules/finder/assets/js/modal/model/item.js":
3005 /*!*******************************************************************!*\
3006 !*** ../core/common/modules/finder/assets/js/modal/model/item.js ***!
3007 \*******************************************************************/
3008 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3009
3010 "use strict";
3011
3012
3013 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3014 Object.defineProperty(exports, "__esModule", ({
3015 value: true
3016 }));
3017 exports["default"] = void 0;
3018 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3019 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3020 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3021 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3022 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3023 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)); }
3024 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3025 var _default = exports["default"] = /*#__PURE__*/function (_Backbone$Model) {
3026 function _default() {
3027 (0, _classCallCheck2.default)(this, _default);
3028 return _callSuper(this, _default, arguments);
3029 }
3030 (0, _inherits2.default)(_default, _Backbone$Model);
3031 return (0, _createClass2.default)(_default, [{
3032 key: "defaults",
3033 value: function defaults() {
3034 return {
3035 description: '',
3036 icon: 'settings',
3037 url: '',
3038 keywords: [],
3039 actions: [],
3040 lock: null
3041 };
3042 }
3043 }]);
3044 }(Backbone.Model);
3045
3046 /***/ }),
3047
3048 /***/ "../core/common/modules/finder/assets/js/modal/views/categories.js":
3049 /*!*************************************************************************!*\
3050 !*** ../core/common/modules/finder/assets/js/modal/views/categories.js ***!
3051 \*************************************************************************/
3052 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3053
3054 "use strict";
3055
3056
3057 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3058 Object.defineProperty(exports, "__esModule", ({
3059 value: true
3060 }));
3061 exports["default"] = void 0;
3062 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3063 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3064 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3065 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3066 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3067 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
3068 var _dynamicCategory = _interopRequireDefault(__webpack_require__(/*! ./dynamic-category */ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js"));
3069 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)); }
3070 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3071 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
3072 function _default() {
3073 (0, _classCallCheck2.default)(this, _default);
3074 return _callSuper(this, _default, arguments);
3075 }
3076 (0, _inherits2.default)(_default, _Marionette$Composite);
3077 return (0, _createClass2.default)(_default, [{
3078 key: "id",
3079 value: function id() {
3080 return 'elementor-finder__results-container';
3081 }
3082 }, {
3083 key: "ui",
3084 value: function ui() {
3085 this.selectors = {
3086 noResults: '#elementor-finder__no-results',
3087 categoryItem: '.elementor-finder__results__item'
3088 };
3089 return this.selectors;
3090 }
3091 }, {
3092 key: "events",
3093 value: function events() {
3094 return {
3095 'mouseenter @ui.categoryItem': 'onCategoryItemMouseEnter'
3096 };
3097 }
3098 }, {
3099 key: "getTemplate",
3100 value: function getTemplate() {
3101 return '#tmpl-elementor-finder-results-container';
3102 }
3103 }, {
3104 key: "getChildView",
3105 value: function getChildView(childModel) {
3106 return childModel.get('dynamic') ? _dynamicCategory.default : _category.default;
3107 }
3108 }, {
3109 key: "initialize",
3110 value: function initialize() {
3111 this.$activeItem = null;
3112 this.childViewContainer = '#elementor-finder__results';
3113 this.collection = new Backbone.Collection(Object.values(elementorCommon.finder.getSettings('data')));
3114 }
3115 }, {
3116 key: "activateItem",
3117 value: function activateItem($item) {
3118 if (this.$activeItem) {
3119 this.$activeItem.removeClass('elementor-active');
3120 }
3121 $item.addClass('elementor-active');
3122 this.$activeItem = $item;
3123 }
3124 }, {
3125 key: "activateNextItem",
3126 value: function activateNextItem(reverse) {
3127 var $allItems = jQuery(this.selectors.categoryItem);
3128 var nextItemIndex = 0;
3129 if (this.$activeItem) {
3130 nextItemIndex = $allItems.index(this.$activeItem) + (reverse ? -1 : 1);
3131 if (nextItemIndex >= $allItems.length) {
3132 nextItemIndex = 0;
3133 } else if (nextItemIndex < 0) {
3134 nextItemIndex = $allItems.length - 1;
3135 }
3136 }
3137 var $nextItem = $allItems.eq(nextItemIndex);
3138 this.activateItem($nextItem);
3139 $nextItem[0].scrollIntoView({
3140 block: 'nearest'
3141 });
3142 }
3143 }, {
3144 key: "goToActiveItem",
3145 value: function goToActiveItem(event) {
3146 var $a = this.$activeItem.children('a'),
3147 isControlClicked = $e.shortcuts.isControlEvent(event);
3148 if (isControlClicked) {
3149 $a.attr('target', '_blank');
3150 }
3151 $a[0].click();
3152 if (isControlClicked) {
3153 $a.removeAttr('target');
3154 }
3155 }
3156 }, {
3157 key: "onCategoryItemMouseEnter",
3158 value: function onCategoryItemMouseEnter(event) {
3159 this.activateItem(jQuery(event.currentTarget));
3160 }
3161 }, {
3162 key: "onChildviewToggleVisibility",
3163 value: function onChildviewToggleVisibility() {
3164 var allCategoriesAreEmpty = this.children.every(function (child) {
3165 return !child.isVisible;
3166 });
3167 this.ui.noResults.toggle(allCategoriesAreEmpty);
3168 }
3169 }]);
3170 }(Marionette.CompositeView);
3171
3172 /***/ }),
3173
3174 /***/ "../core/common/modules/finder/assets/js/modal/views/category.js":
3175 /*!***********************************************************************!*\
3176 !*** ../core/common/modules/finder/assets/js/modal/views/category.js ***!
3177 \***********************************************************************/
3178 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3179
3180 "use strict";
3181
3182
3183 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3184 Object.defineProperty(exports, "__esModule", ({
3185 value: true
3186 }));
3187 exports["default"] = void 0;
3188 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3189 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3190 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3191 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3192 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3193 var _item = _interopRequireDefault(__webpack_require__(/*! ./item */ "../core/common/modules/finder/assets/js/modal/views/item.js"));
3194 var _item2 = _interopRequireDefault(__webpack_require__(/*! ../model/item */ "../core/common/modules/finder/assets/js/modal/model/item.js"));
3195 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)); }
3196 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3197 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
3198 function _default() {
3199 (0, _classCallCheck2.default)(this, _default);
3200 return _callSuper(this, _default, arguments);
3201 }
3202 (0, _inherits2.default)(_default, _Marionette$Composite);
3203 return (0, _createClass2.default)(_default, [{
3204 key: "className",
3205 value: function className() {
3206 return 'elementor-finder__results__category';
3207 }
3208 }, {
3209 key: "getTemplate",
3210 value: function getTemplate() {
3211 return '#tmpl-elementor-finder__results__category';
3212 }
3213 }, {
3214 key: "getChildView",
3215 value: function getChildView() {
3216 return _item.default;
3217 }
3218 }, {
3219 key: "initialize",
3220 value: function initialize() {
3221 this.childViewContainer = '.elementor-finder__results__category__items';
3222 this.isVisible = true;
3223 var items = this.model.get('items');
3224 if (items) {
3225 items = Object.values(items);
3226 }
3227 this.collection = new Backbone.Collection(items, {
3228 model: _item2.default
3229 });
3230 }
3231 }, {
3232 key: "filter",
3233 value: function filter(childModel) {
3234 var textFilter = this.getTextFilter();
3235 if (childModel.get('title').toLowerCase().indexOf(textFilter) >= 0) {
3236 return true;
3237 }
3238 return childModel.get('keywords').some(function (keyword) {
3239 return keyword.indexOf(textFilter) >= 0;
3240 });
3241 }
3242 }, {
3243 key: "getTextFilter",
3244 value: function getTextFilter() {
3245 return elementorCommon.finder.channel.request('filter:text').trim().toLowerCase();
3246 }
3247 }, {
3248 key: "toggleElement",
3249 value: function toggleElement() {
3250 var isCurrentlyVisible = !!this.children.length;
3251 if (isCurrentlyVisible !== this.isVisible) {
3252 this.isVisible = isCurrentlyVisible;
3253 this.$el.toggle(isCurrentlyVisible);
3254 this.triggerMethod('toggle:visibility');
3255 }
3256 }
3257 }, {
3258 key: "onRender",
3259 value: function onRender() {
3260 this.listenTo(elementorCommon.finder.channel, 'filter:change', this.onFilterChange.bind(this));
3261 }
3262 }, {
3263 key: "onFilterChange",
3264 value: function onFilterChange() {
3265 this._renderChildren();
3266 }
3267 }, {
3268 key: "onRenderCollection",
3269 value: function onRenderCollection() {
3270 this.toggleElement();
3271 }
3272 }]);
3273 }(Marionette.CompositeView);
3274
3275 /***/ }),
3276
3277 /***/ "../core/common/modules/finder/assets/js/modal/views/content.js":
3278 /*!**********************************************************************!*\
3279 !*** ../core/common/modules/finder/assets/js/modal/views/content.js ***!
3280 \**********************************************************************/
3281 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3282
3283 "use strict";
3284
3285
3286 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3287 Object.defineProperty(exports, "__esModule", ({
3288 value: true
3289 }));
3290 exports["default"] = void 0;
3291 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3292 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3293 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3294 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3295 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3296 var _categories = _interopRequireDefault(__webpack_require__(/*! ./categories */ "../core/common/modules/finder/assets/js/modal/views/categories.js"));
3297 var _editorOneEvents = __webpack_require__(/*! elementor-editor-utils/editor-one-events */ "../assets/dev/js/editor/utils/editor-one-events.js");
3298 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)); }
3299 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3300 var FINDER_SEARCH_DEBOUNCE_MS = 300;
3301 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$LayoutVie) {
3302 function _default() {
3303 (0, _classCallCheck2.default)(this, _default);
3304 return _callSuper(this, _default, arguments);
3305 }
3306 (0, _inherits2.default)(_default, _Marionette$LayoutVie);
3307 return (0, _createClass2.default)(_default, [{
3308 key: "id",
3309 value: function id() {
3310 return 'elementor-finder';
3311 }
3312 }, {
3313 key: "getTemplate",
3314 value: function getTemplate() {
3315 return '#tmpl-elementor-finder';
3316 }
3317 }, {
3318 key: "ui",
3319 value: function ui() {
3320 return {
3321 searchInput: '#elementor-finder__search__input'
3322 };
3323 }
3324 }, {
3325 key: "events",
3326 value: function events() {
3327 return {
3328 'input @ui.searchInput': 'onSearchInputInput'
3329 };
3330 }
3331 }, {
3332 key: "regions",
3333 value: function regions() {
3334 return {
3335 content: '#elementor-finder__content'
3336 };
3337 }
3338 }, {
3339 key: "initialize",
3340 value: function initialize() {
3341 this.debouncedTrackSearch = (0, _editorOneEvents.createDebouncedFinderSearch)(FINDER_SEARCH_DEBOUNCE_MS);
3342 }
3343 }, {
3344 key: "showCategoriesView",
3345 value: function showCategoriesView() {
3346 this.content.show(new _categories.default());
3347 }
3348 }, {
3349 key: "getResultsCount",
3350 value: function getResultsCount() {
3351 if (!this.content.currentView) {
3352 return 0;
3353 }
3354 var $visibleItems = this.content.currentView.$el.find('.elementor-finder__results__item:visible');
3355 return $visibleItems.length;
3356 }
3357 }, {
3358 key: "onSearchInputInput",
3359 value: function onSearchInputInput() {
3360 var _this = this;
3361 var value = this.ui.searchInput.val();
3362 if (value) {
3363 elementorCommon.finder.channel.reply('filter:text', value).trigger('filter:change');
3364 if (!(this.content.currentView instanceof _categories.default)) {
3365 this.showCategoriesView();
3366 }
3367 setTimeout(function () {
3368 var resultsCount = _this.getResultsCount();
3369 _this.debouncedTrackSearch(resultsCount, value);
3370 }, 50);
3371 }
3372 this.content.currentView.$el.toggle(!!value);
3373 }
3374 }, {
3375 key: "onDestroy",
3376 value: function onDestroy() {
3377 var _this$debouncedTrackS;
3378 if ((_this$debouncedTrackS = this.debouncedTrackSearch) !== null && _this$debouncedTrackS !== void 0 && _this$debouncedTrackS.cancel) {
3379 this.debouncedTrackSearch.cancel();
3380 }
3381 }
3382 }]);
3383 }(Marionette.LayoutView);
3384
3385 /***/ }),
3386
3387 /***/ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js":
3388 /*!*******************************************************************************!*\
3389 !*** ../core/common/modules/finder/assets/js/modal/views/dynamic-category.js ***!
3390 \*******************************************************************************/
3391 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3392
3393 "use strict";
3394
3395
3396 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3397 Object.defineProperty(exports, "__esModule", ({
3398 value: true
3399 }));
3400 exports["default"] = void 0;
3401 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3402 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3403 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3404 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3405 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3406 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3407 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
3408 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)); }
3409 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3410 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; }
3411 var _default = exports["default"] = /*#__PURE__*/function (_Category) {
3412 function _default() {
3413 (0, _classCallCheck2.default)(this, _default);
3414 return _callSuper(this, _default, arguments);
3415 }
3416 (0, _inherits2.default)(_default, _Category);
3417 return (0, _createClass2.default)(_default, [{
3418 key: "className",
3419 value: function className() {
3420 return _superPropGet(_default, "className", this, 3)([]) + ' elementor-finder__results__category--dynamic';
3421 }
3422 }, {
3423 key: "ui",
3424 value: function ui() {
3425 return {
3426 title: '.elementor-finder__results__category__title'
3427 };
3428 }
3429 }, {
3430 key: "fetchData",
3431 value: function fetchData() {
3432 var _this = this;
3433 this.ui.loadingIcon.show();
3434 elementorCommon.ajax.addRequest('finder_get_category_items', {
3435 data: {
3436 category: this.model.get('name'),
3437 filter: this.getTextFilter()
3438 },
3439 success: function success(data) {
3440 if (_this.isDestroyed) {
3441 return;
3442 }
3443 _this.collection.set(data);
3444 _this.toggleElement();
3445 _this.ui.loadingIcon.hide();
3446 }
3447 });
3448 }
3449 }, {
3450 key: "filter",
3451 value: function filter() {
3452 return true;
3453 }
3454 }, {
3455 key: "onFilterChange",
3456 value: function onFilterChange() {
3457 this.fetchData();
3458 }
3459 }, {
3460 key: "onRender",
3461 value: function onRender() {
3462 _superPropGet(_default, "onRender", this, 3)([]);
3463 this.ui.loadingIcon = jQuery('<i>', {
3464 class: 'eicon-loading eicon-animation-spin'
3465 });
3466 this.ui.title.after(this.ui.loadingIcon);
3467 this.fetchData();
3468 }
3469 }]);
3470 }(_category.default);
3471
3472 /***/ }),
3473
3474 /***/ "../core/common/modules/finder/assets/js/modal/views/item.js":
3475 /*!*******************************************************************!*\
3476 !*** ../core/common/modules/finder/assets/js/modal/views/item.js ***!
3477 \*******************************************************************/
3478 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3479
3480 "use strict";
3481 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3482
3483
3484 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3485 Object.defineProperty(exports, "__esModule", ({
3486 value: true
3487 }));
3488 exports["default"] = void 0;
3489 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3490 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3491 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3492 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3493 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3494 var _editorOneEvents = __webpack_require__(/*! elementor-editor-utils/editor-one-events */ "../assets/dev/js/editor/utils/editor-one-events.js");
3495 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)); }
3496 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3497 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$ItemView) {
3498 function _default() {
3499 (0, _classCallCheck2.default)(this, _default);
3500 return _callSuper(this, _default, arguments);
3501 }
3502 (0, _inherits2.default)(_default, _Marionette$ItemView);
3503 return (0, _createClass2.default)(_default, [{
3504 key: "className",
3505 value: function className() {
3506 return 'elementor-finder__results__item';
3507 }
3508 }, {
3509 key: "getTemplate",
3510 value: function getTemplate() {
3511 return '#tmpl-elementor-finder__results__item';
3512 }
3513 }, {
3514 key: "events",
3515 value: function events() {
3516 this.$el[0].addEventListener('click', this.onClick.bind(this), true);
3517 }
3518 }, {
3519 key: "trackResultSelect",
3520 value: function trackResultSelect() {
3521 var title = this.model.get('title');
3522 _editorOneEvents.EditorOneEventManager.sendFinderResultSelect(title);
3523 }
3524 }, {
3525 key: "onClick",
3526 value: function onClick(e) {
3527 var _this = this;
3528 var lockOptions = this.model.get('lock');
3529 if (!(lockOptions !== null && lockOptions !== void 0 && lockOptions.is_locked)) {
3530 this.trackResultSelect();
3531 return;
3532 }
3533 e.preventDefault();
3534 e.stopImmediatePropagation();
3535 elementorCommon.dialogsManager.createWidget('confirm', {
3536 id: 'elementor-finder__lock-dialog',
3537 headerMessage: lockOptions.content.heading,
3538 message: lockOptions.content.description,
3539 position: {
3540 my: 'center center',
3541 at: 'center center'
3542 },
3543 strings: {
3544 confirm: lockOptions.button.text,
3545 cancel: __('Cancel', 'elementor')
3546 },
3547 onConfirm: function onConfirm() {
3548 _this.trackResultSelect();
3549 var link = _this.replaceLockLinkPlaceholders(lockOptions.button.url);
3550 window.open(link, '_blank');
3551 }
3552 }).show();
3553 }
3554 }, {
3555 key: "replaceLockLinkPlaceholders",
3556 value: function replaceLockLinkPlaceholders(link) {
3557 return link.replace(/%%utm_source%%/g, 'finder').replace(/%%utm_medium%%/g, 'wp-dash');
3558 }
3559 }]);
3560 }(Marionette.ItemView);
3561
3562 /***/ }),
3563
3564 /***/ "../core/common/modules/finder/assets/js/modal/views/layout.js":
3565 /*!*********************************************************************!*\
3566 !*** ../core/common/modules/finder/assets/js/modal/views/layout.js ***!
3567 \*********************************************************************/
3568 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3569
3570 "use strict";
3571 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3572
3573
3574 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3575 Object.defineProperty(exports, "__esModule", ({
3576 value: true
3577 }));
3578 exports["default"] = void 0;
3579 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3580 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3581 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3582 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3583 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3584 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3585 var _content = _interopRequireDefault(__webpack_require__(/*! ./content */ "../core/common/modules/finder/assets/js/modal/views/content.js"));
3586 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)); }
3587 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3588 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; }
3589 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$com) {
3590 function _default() {
3591 (0, _classCallCheck2.default)(this, _default);
3592 return _callSuper(this, _default, arguments);
3593 }
3594 (0, _inherits2.default)(_default, _elementorModules$com);
3595 return (0, _createClass2.default)(_default, [{
3596 key: "getModalOptions",
3597 value: function getModalOptions() {
3598 return {
3599 id: 'elementor-finder__modal',
3600 draggable: true,
3601 effects: {
3602 show: 'show',
3603 hide: 'hide'
3604 },
3605 position: {
3606 enable: false
3607 }
3608 };
3609 }
3610 }, {
3611 key: "getLogoOptions",
3612 value: function getLogoOptions() {
3613 return {
3614 title: __('Finder', 'elementor')
3615 };
3616 }
3617 }, {
3618 key: "initialize",
3619 value: function initialize() {
3620 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3621 args[_key] = arguments[_key];
3622 }
3623 _superPropGet(_default, "initialize", this, 3)(args);
3624 this.showLogo();
3625 this.showContentView();
3626 }
3627 }, {
3628 key: "showContentView",
3629 value: function showContentView() {
3630 this.modalContent.show(new _content.default());
3631 }
3632 }, {
3633 key: "showModal",
3634 value: function showModal() {
3635 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3636 args[_key2] = arguments[_key2];
3637 }
3638 _superPropGet(_default, "showModal", this, 3)(args);
3639 this.modalContent.currentView.ui.searchInput.focus();
3640 }
3641 }]);
3642 }(elementorModules.common.views.modal.Layout);
3643
3644 /***/ }),
3645
3646 /***/ "../modules/web-cli/assets/js/core/data/errors/base-error.js":
3647 /*!*******************************************************************!*\
3648 !*** ../modules/web-cli/assets/js/core/data/errors/base-error.js ***!
3649 \*******************************************************************/
3650 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3651
3652 "use strict";
3653
3654
3655 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3656 Object.defineProperty(exports, "__esModule", ({
3657 value: true
3658 }));
3659 exports["default"] = void 0;
3660 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3661 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3662 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3663 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3664 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3665 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
3666 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3667 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3668 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../../../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
3669 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; }
3670 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; }
3671 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)); }
3672 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3673 var BaseError = exports["default"] = /*#__PURE__*/function (_Error) {
3674 /**
3675 * Error constructor.
3676 *
3677 * @param {string} message
3678 * @param {string} code
3679 * @param {*} data
3680 */
3681 function BaseError() {
3682 var _this;
3683 var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
3684 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3685 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3686 (0, _classCallCheck2.default)(this, BaseError);
3687 _this = _callSuper(this, BaseError, [message]);
3688 /**
3689 * The server error code.
3690 *
3691 * @type {string}
3692 */
3693 (0, _defineProperty2.default)(_this, "code", '');
3694 /**
3695 * Additional data about the current error.
3696 *
3697 * @type {*[]}
3698 */
3699 (0, _defineProperty2.default)(_this, "data", []);
3700 _this.code = code;
3701 _this.data = data;
3702 return _this;
3703 }
3704
3705 /**
3706 * Notify a message when the error occurs.
3707 */
3708 (0, _inherits2.default)(BaseError, _Error);
3709 return (0, _createClass2.default)(BaseError, [{
3710 key: "notify",
3711 value: function notify() {
3712 _console.default.error(_objectSpread({
3713 message: this.message
3714 }, this));
3715 }
3716 }], [{
3717 key: "create",
3718 value:
3719 /**
3720 * Static helper function to create the error.
3721 *
3722 * @param {string} message
3723 * @param {string} code
3724 * @param {*} data
3725 * @return {BaseError} error
3726 */
3727 function create(message) {
3728 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3729 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3730 return new this(message, code, data);
3731 }
3732
3733 /**
3734 * Returns the status code of the error.
3735 */
3736 }, {
3737 key: "getHTTPErrorCode",
3738 value: function getHTTPErrorCode() {
3739 (0, _forceMethodImplementation.default)();
3740 }
3741 }]);
3742 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
3743
3744 /***/ }),
3745
3746 /***/ "../modules/web-cli/assets/js/core/data/errors/default-error.js":
3747 /*!**********************************************************************!*\
3748 !*** ../modules/web-cli/assets/js/core/data/errors/default-error.js ***!
3749 \**********************************************************************/
3750 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3751
3752 "use strict";
3753
3754
3755 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3756 Object.defineProperty(exports, "__esModule", ({
3757 value: true
3758 }));
3759 exports["default"] = exports.DefaultError = void 0;
3760 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3761 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3762 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3763 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3764 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3765 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3766 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)); }
3767 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3768 var DefaultError = exports.DefaultError = /*#__PURE__*/function (_BaseError) {
3769 function DefaultError() {
3770 (0, _classCallCheck2.default)(this, DefaultError);
3771 return _callSuper(this, DefaultError, arguments);
3772 }
3773 (0, _inherits2.default)(DefaultError, _BaseError);
3774 return (0, _createClass2.default)(DefaultError, null, [{
3775 key: "getHTTPErrorCode",
3776 value: function getHTTPErrorCode() {
3777 return 501;
3778 }
3779 }]);
3780 }(_baseError.default);
3781 var _default = exports["default"] = DefaultError;
3782
3783 /***/ }),
3784
3785 /***/ "../modules/web-cli/assets/js/core/data/errors/error-404.js":
3786 /*!******************************************************************!*\
3787 !*** ../modules/web-cli/assets/js/core/data/errors/error-404.js ***!
3788 \******************************************************************/
3789 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3790
3791 "use strict";
3792
3793
3794 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3795 Object.defineProperty(exports, "__esModule", ({
3796 value: true
3797 }));
3798 exports["default"] = exports.Error404 = void 0;
3799 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3800 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3801 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3802 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3803 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3804 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3805 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3806 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)); }
3807 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3808 var Error404 = exports.Error404 = /*#__PURE__*/function (_BaseError) {
3809 function Error404() {
3810 (0, _classCallCheck2.default)(this, Error404);
3811 return _callSuper(this, Error404, arguments);
3812 }
3813 (0, _inherits2.default)(Error404, _BaseError);
3814 return (0, _createClass2.default)(Error404, [{
3815 key: "notify",
3816 value: function notify() {
3817 _console.default.warn(this.message);
3818 }
3819 }], [{
3820 key: "getHTTPErrorCode",
3821 value: function getHTTPErrorCode() {
3822 return 404;
3823 }
3824 }]);
3825 }(_baseError.default);
3826 var _default = exports["default"] = Error404;
3827
3828 /***/ }),
3829
3830 /***/ "../modules/web-cli/assets/js/core/data/errors/index.js":
3831 /*!**************************************************************!*\
3832 !*** ../modules/web-cli/assets/js/core/data/errors/index.js ***!
3833 \**************************************************************/
3834 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3835
3836 "use strict";
3837
3838
3839 Object.defineProperty(exports, "__esModule", ({
3840 value: true
3841 }));
3842 Object.defineProperty(exports, "DefaultError", ({
3843 enumerable: true,
3844 get: function get() {
3845 return _defaultError.DefaultError;
3846 }
3847 }));
3848 Object.defineProperty(exports, "Error404", ({
3849 enumerable: true,
3850 get: function get() {
3851 return _error.Error404;
3852 }
3853 }));
3854 var _defaultError = __webpack_require__(/*! ./default-error */ "../modules/web-cli/assets/js/core/data/errors/default-error.js");
3855 var _error = __webpack_require__(/*! ./error-404 */ "../modules/web-cli/assets/js/core/data/errors/error-404.js");
3856
3857 /***/ }),
3858
3859 /***/ "../modules/web-cli/assets/js/modules/command-base.js":
3860 /*!************************************************************!*\
3861 !*** ../modules/web-cli/assets/js/modules/command-base.js ***!
3862 \************************************************************/
3863 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3864
3865 "use strict";
3866
3867
3868 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3869 Object.defineProperty(exports, "__esModule", ({
3870 value: true
3871 }));
3872 exports["default"] = void 0;
3873 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3874 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3875 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3876 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3877 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3878 var _commandInfra = _interopRequireDefault(__webpack_require__(/*! ./command-infra */ "../modules/web-cli/assets/js/modules/command-infra.js"));
3879 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3880 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)); }
3881 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3882 /**
3883 * @name $e.modules.CommandBase
3884 */
3885 var CommandBase = exports["default"] = /*#__PURE__*/function (_CommandInfra) {
3886 function CommandBase() {
3887 (0, _classCallCheck2.default)(this, CommandBase);
3888 return _callSuper(this, CommandBase, arguments);
3889 }
3890 (0, _inherits2.default)(CommandBase, _CommandInfra);
3891 return (0, _createClass2.default)(CommandBase, [{
3892 key: "onBeforeRun",
3893 value: function onBeforeRun() {
3894 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3895 $e.hooks.runUIBefore(this.command, args);
3896 }
3897 }, {
3898 key: "onAfterRun",
3899 value: function onAfterRun() {
3900 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3901 var result = arguments.length > 1 ? arguments[1] : undefined;
3902 $e.hooks.runUIAfter(this.command, args, result);
3903 }
3904 }, {
3905 key: "onBeforeApply",
3906 value: function onBeforeApply() {
3907 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3908 $e.hooks.runDataDependency(this.command, args);
3909 }
3910 }, {
3911 key: "onAfterApply",
3912 value: function onAfterApply() {
3913 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3914 var result = arguments.length > 1 ? arguments[1] : undefined;
3915 return $e.hooks.runDataAfter(this.command, args, result);
3916 }
3917 }, {
3918 key: "onCatchApply",
3919 value: function onCatchApply(e) {
3920 this.runCatchHooks(e);
3921 }
3922
3923 /**
3924 * Run all the catch hooks.
3925 *
3926 * @param {Error} e
3927 */
3928 }, {
3929 key: "runCatchHooks",
3930 value: function runCatchHooks(e) {
3931 $e.hooks.runDataCatch(this.command, this.args, e);
3932 $e.hooks.runUICatch(this.command, this.args, e);
3933 }
3934
3935 /**
3936 * TODO - Remove - Backwards compatibility.
3937 *
3938 * Function requireContainer().
3939 *
3940 * Validate `arg.container` & `arg.containers`.
3941 *
3942 * @param {{}} args
3943 * @deprecated since 3.7.0, extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase` instead.
3944 *
3945 * @throws {Error}
3946 */
3947 }, {
3948 key: "requireContainer",
3949 value: function requireContainer() {
3950 var _this = this;
3951 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
3952 _deprecation.default.deprecated('requireContainer()', '3.7.0', 'Extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase`');
3953 if (!args.container && !args.containers) {
3954 throw Error('container or containers are required.');
3955 }
3956 if (args.container && args.containers) {
3957 throw Error('container and containers cannot go together please select one of them.');
3958 }
3959 var containers = args.containers || [args.container];
3960 containers.forEach(function (container) {
3961 _this.requireArgumentInstance('container', elementorModules.editor.Container, {
3962 container: container
3963 });
3964 });
3965 }
3966 }], [{
3967 key: "getInstanceType",
3968 value: function getInstanceType() {
3969 return 'CommandBase';
3970 }
3971 }]);
3972 }(_commandInfra.default);
3973
3974 /***/ }),
3975
3976 /***/ "../modules/web-cli/assets/js/modules/command-callback-base.js":
3977 /*!*********************************************************************!*\
3978 !*** ../modules/web-cli/assets/js/modules/command-callback-base.js ***!
3979 \*********************************************************************/
3980 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3981
3982 "use strict";
3983
3984
3985 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3986 Object.defineProperty(exports, "__esModule", ({
3987 value: true
3988 }));
3989 exports["default"] = void 0;
3990 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3991 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3992 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3993 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3994 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3995 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3996 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)); }
3997 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3998 /**
3999 * To support pure callbacks in the API(commands.js), to ensure they have registered with the proper context.
4000 */
4001 var CommandCallbackBase = exports["default"] = /*#__PURE__*/function (_CommandBase) {
4002 function CommandCallbackBase() {
4003 (0, _classCallCheck2.default)(this, CommandCallbackBase);
4004 return _callSuper(this, CommandCallbackBase, arguments);
4005 }
4006 (0, _inherits2.default)(CommandCallbackBase, _CommandBase);
4007 return (0, _createClass2.default)(CommandCallbackBase, [{
4008 key: "apply",
4009 value: function apply() {
4010 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4011 return this.constructor.getCallback()(args);
4012 }
4013 }], [{
4014 key: "getInstanceType",
4015 value: function getInstanceType() {
4016 return 'CommandCallbackBase';
4017 }
4018
4019 /**
4020 * Get original callback of the command.
4021 *
4022 * Support pure callbacks ( Non command-base ).
4023 *
4024 * @return {()=>{}} Command Results.
4025 */
4026 }, {
4027 key: "getCallback",
4028 value: function getCallback() {
4029 return this.registerConfig.callback;
4030 }
4031 }]);
4032 }(_commandBase.default);
4033
4034 /***/ }),
4035
4036 /***/ "../modules/web-cli/assets/js/modules/command-data.js":
4037 /*!************************************************************!*\
4038 !*** ../modules/web-cli/assets/js/modules/command-data.js ***!
4039 \************************************************************/
4040 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4041
4042 "use strict";
4043
4044
4045 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4046 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
4047 Object.defineProperty(exports, "__esModule", ({
4048 value: true
4049 }));
4050 exports["default"] = void 0;
4051 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4052 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4053 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4054 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4055 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4056 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4057 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4058 var errors = _interopRequireWildcard(__webpack_require__(/*! ../core/data/errors/ */ "../modules/web-cli/assets/js/core/data/errors/index.js"));
4059 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); }
4060 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)); }
4061 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4062 /**
4063 * @name $e.modules.CommandData
4064 */
4065 /**
4066 * @typedef {('create'|'delete'|'get'|'update'|'options')} DataTypes
4067 */
4068 /**
4069 * @typedef {{}} RequestData
4070 */
4071 /**
4072 * @typedef {import('../core/data/errors/base-error')} BaseError
4073 */
4074 var CommandData = exports["default"] = /*#__PURE__*/function (_CommandBase) {
4075 function CommandData(args) {
4076 var _this$args$options;
4077 var _this;
4078 var commandsAPI = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $e.data;
4079 (0, _classCallCheck2.default)(this, CommandData);
4080 _this = _callSuper(this, CommandData, [args, commandsAPI]);
4081 /**
4082 * Data returned from remote.
4083 *
4084 * @type {*}
4085 */
4086 (0, _defineProperty2.default)(_this, "data", void 0);
4087 /**
4088 * Fetch type.
4089 *
4090 * @type {DataTypes}
4091 */
4092 (0, _defineProperty2.default)(_this, "type", void 0);
4093 if ((_this$args$options = _this.args.options) !== null && _this$args$options !== void 0 && _this$args$options.type) {
4094 _this.type = _this.args.options.type;
4095 }
4096 return _this;
4097 }
4098
4099 /**
4100 * Function getEndpointFormat().
4101 *
4102 * @return {null|string} endpoint format
4103 */
4104 (0, _inherits2.default)(CommandData, _CommandBase);
4105 return (0, _createClass2.default)(CommandData, [{
4106 key: "getApplyMethods",
4107 value:
4108 /**
4109 * @param {DataTypes} type
4110 *
4111 * @return {boolean|{before: (function(*=): {}), after: (function({}, *=): {})}} apply methods
4112 */
4113 function getApplyMethods() {
4114 var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.type;
4115 var before, after;
4116 switch (type) {
4117 case 'create':
4118 before = this.applyBeforeCreate;
4119 after = this.applyAfterCreate;
4120 break;
4121 case 'delete':
4122 before = this.applyBeforeDelete;
4123 after = this.applyAfterDelete;
4124 break;
4125 case 'get':
4126 before = this.applyBeforeGet;
4127 after = this.applyAfterGet;
4128 break;
4129 case 'update':
4130 before = this.applyBeforeUpdate;
4131 after = this.applyAfterUpdate;
4132 break;
4133 case 'options':
4134 before = this.applyBeforeOptions;
4135 after = this.applyAfterOptions;
4136 break;
4137 default:
4138 return false;
4139 }
4140 return {
4141 before: before.bind(this),
4142 after: after.bind(this)
4143 };
4144 }
4145
4146 /**
4147 * Function getRequestData().
4148 *
4149 * @return {RequestData} request data
4150 */
4151 }, {
4152 key: "getRequestData",
4153 value: function getRequestData() {
4154 return {
4155 type: this.type,
4156 args: this.args,
4157 timestamp: new Date().getTime(),
4158 component: this.component,
4159 command: this.command,
4160 endpoint: $e.data.commandToEndpoint(this.command, JSON.parse(JSON.stringify(this.args)), this.constructor.getEndpointFormat())
4161 };
4162 }
4163 }, {
4164 key: "apply",
4165 value: function apply() {
4166 var _this2 = this;
4167 var applyMethods = this.getApplyMethods();
4168
4169 // Run 'before' method.
4170 this.args = applyMethods.before(this.args);
4171 var requestData = this.getRequestData();
4172 return $e.data.fetch(requestData).then(function (data) {
4173 _this2.data = data;
4174
4175 // Run 'after' method.
4176 _this2.data = applyMethods.after(data, _this2.args);
4177 _this2.data = {
4178 data: _this2.data
4179 };
4180
4181 // Append requestData.
4182 _this2.data = Object.assign({
4183 __requestData__: requestData
4184 }, _this2.data);
4185 return _this2.data;
4186 });
4187 }
4188
4189 /**
4190 * @param {*} [args={}]
4191 * @return {{}} filtered args
4192 */
4193 }, {
4194 key: "applyBeforeCreate",
4195 value: function applyBeforeCreate() {
4196 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4197 return args;
4198 }
4199
4200 /**
4201 * @param {{}} data
4202 * @param {*} [args={}]
4203 * @return {{}} filtered result
4204 */
4205 }, {
4206 key: "applyAfterCreate",
4207 value: function applyAfterCreate(data) {
4208 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4209 // eslint-disable-line no-unused-vars
4210 return data;
4211 }
4212
4213 /**
4214 * @param {*} [args={}]
4215 * @return {{}} filtered args
4216 */
4217 }, {
4218 key: "applyBeforeDelete",
4219 value: function applyBeforeDelete() {
4220 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4221 return args;
4222 }
4223
4224 /**
4225 * @param {{}} data
4226 * @param {*} [args={}]
4227 * @return {{}} filtered result
4228 */
4229 }, {
4230 key: "applyAfterDelete",
4231 value: function applyAfterDelete(data) {
4232 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4233 // eslint-disable-line no-unused-vars
4234 return data;
4235 }
4236
4237 /**
4238 * @param {*} [args={}]
4239 * @return {{}} filtered args
4240 */
4241 }, {
4242 key: "applyBeforeGet",
4243 value: function applyBeforeGet() {
4244 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4245 return args;
4246 }
4247
4248 /**
4249 * @param {{}} data
4250 * @param {*} [args={}]
4251 * @return {{}} filtered result
4252 */
4253 }, {
4254 key: "applyAfterGet",
4255 value: function applyAfterGet(data) {
4256 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4257 // eslint-disable-line no-unused-vars
4258 return data;
4259 }
4260
4261 /**
4262 * @param {*} [args={}]
4263 * @return {{}} filtered args
4264 */
4265 }, {
4266 key: "applyBeforeUpdate",
4267 value: function applyBeforeUpdate() {
4268 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4269 return args;
4270 }
4271
4272 /**
4273 * @param {{}} data
4274 * @param {*} [args={}]
4275 * @return {{}} filtered result
4276 */
4277 }, {
4278 key: "applyAfterUpdate",
4279 value: function applyAfterUpdate(data) {
4280 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4281 // eslint-disable-line no-unused-vars
4282 return data;
4283 }
4284
4285 /**
4286 * @param {*} [args={}]
4287 * @return {{}} filtered args
4288 */
4289 }, {
4290 key: "applyBeforeOptions",
4291 value: function applyBeforeOptions() {
4292 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4293 return args;
4294 }
4295
4296 /**
4297 * @param {{}} data
4298 * @param {*} [args={}]
4299 * @return {{}} filtered result
4300 */
4301 }, {
4302 key: "applyAfterOptions",
4303 value: function applyAfterOptions(data) {
4304 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4305 // eslint-disable-line no-unused-vars
4306 return data;
4307 }
4308
4309 /**
4310 * @param {BaseError} e
4311 */
4312 }, {
4313 key: "applyAfterCatch",
4314 value: function applyAfterCatch(e) {
4315 e.notify();
4316 }
4317 }, {
4318 key: "onCatchApply",
4319 value: function onCatchApply(e) {
4320 var _e;
4321 // TODO: If the errors that returns from the server is consistent remove the '?' from 'e'
4322 var httpErrorCode = ((_e = e) === null || _e === void 0 || (_e = _e.data) === null || _e === void 0 ? void 0 : _e.status) || 501;
4323 var dataError = Object.values(errors).find(function (error) {
4324 return error.getHTTPErrorCode() === httpErrorCode;
4325 });
4326 if (!dataError) {
4327 dataError = errors.DefaultError;
4328 }
4329 e = dataError.create(e.message, e.code, e.data || []);
4330 this.runCatchHooks(e);
4331 this.applyAfterCatch(e);
4332 }
4333 }], [{
4334 key: "getInstanceType",
4335 value: function getInstanceType() {
4336 return 'CommandData';
4337 }
4338 }, {
4339 key: "getEndpointFormat",
4340 value: function getEndpointFormat() {
4341 return null;
4342 }
4343 }]);
4344 }(_commandBase.default);
4345
4346 /***/ }),
4347
4348 /***/ "../modules/web-cli/assets/js/modules/command-infra.js":
4349 /*!*************************************************************!*\
4350 !*** ../modules/web-cli/assets/js/modules/command-infra.js ***!
4351 \*************************************************************/
4352 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4353
4354 "use strict";
4355
4356
4357 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4358 Object.defineProperty(exports, "__esModule", ({
4359 value: true
4360 }));
4361 exports["default"] = void 0;
4362 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4363 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4364 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4365 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4366 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4367 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4368 var _argsObject = _interopRequireDefault(__webpack_require__(/*! elementor-assets-js/modules/imports/args-object */ "../assets/dev/js/modules/imports/args-object.js"));
4369 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4370 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)); }
4371 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4372 /**
4373 * @typedef {import('../modules/component-base')} ComponentBase
4374 */
4375 var CommandInfra = exports["default"] = /*#__PURE__*/function (_ArgsObject) {
4376 /**
4377 * Function constructor().
4378 *
4379 * Create Commands Base.
4380 *
4381 * @param {{}} args
4382 */
4383 function CommandInfra() {
4384 var _this;
4385 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4386 (0, _classCallCheck2.default)(this, CommandInfra);
4387 _this = _callSuper(this, CommandInfra, [args]);
4388 if (!_this.constructor.registerConfig) {
4389 throw RangeError('Doing it wrong: Each command type should have `registerConfig`.');
4390 }
4391
4392 // Acknowledge self about which command it run.
4393 _this.command = _this.constructor.getCommand();
4394
4395 // Assign instance of current component.
4396 _this.component = _this.constructor.getComponent();
4397
4398 // Who ever need do something before without `super` the constructor can use `initialize` method.
4399 _this.initialize(args);
4400
4401 // Refresh args, maybe the changed via `initialize`.
4402 args = _this.args;
4403
4404 // Validate args before run.
4405 _this.validateArgs(args);
4406 return _this;
4407 }
4408
4409 /**
4410 * Function initialize().
4411 *
4412 * Initialize command, called after construction.
4413 *
4414 * @param {{}} args
4415 */
4416 (0, _inherits2.default)(CommandInfra, _ArgsObject);
4417 return (0, _createClass2.default)(CommandInfra, [{
4418 key: "currentCommand",
4419 get:
4420 /**
4421 * @deprecated since 3.7.0, use `this.command` instead.
4422 */
4423 function get() {
4424 _deprecation.default.deprecated('this.currentCommand', '3.7.0', 'this.command');
4425 return this.command;
4426 }
4427 }, {
4428 key: "initialize",
4429 value: function initialize() {
4430 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4431 } // eslint-disable-line no-unused-vars
4432
4433 /**
4434 * Function validateArgs().
4435 *
4436 * Validate command arguments.
4437 *
4438 * @param {{}} args
4439 */
4440 }, {
4441 key: "validateArgs",
4442 value: function validateArgs() {
4443 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4444 } // eslint-disable-line no-unused-vars
4445
4446 // eslint-disable-next-line jsdoc/require-returns-check
4447 /**
4448 * Function apply().
4449 *
4450 * Do the actual command.
4451 *
4452 * @param {{}} args
4453 *
4454 * @return {*} Command results.
4455 */
4456 }, {
4457 key: "apply",
4458 value: function apply() {
4459 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4460 // eslint-disable-line no-unused-vars
4461 elementorModules.ForceMethodImplementation();
4462 }
4463
4464 /**
4465 * Function run().
4466 *
4467 * Run command with history & hooks.
4468 *
4469 * @return {*} Command results.
4470 */
4471 }, {
4472 key: "run",
4473 value: function run() {
4474 return this.apply(this.args);
4475 }
4476
4477 /**
4478 * Function onBeforeRun.
4479 *
4480 * Called before run().
4481 *
4482 * @param {{}} args
4483 */
4484 }, {
4485 key: "onBeforeRun",
4486 value: function onBeforeRun() {
4487 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4488 } // eslint-disable-line no-unused-vars
4489
4490 /**
4491 * Function onAfterRun.
4492 *
4493 * Called after run().
4494 *
4495 * @param {{}} args
4496 * @param {*} result
4497 */
4498 }, {
4499 key: "onAfterRun",
4500 value: function onAfterRun() {
4501 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4502 var result = arguments.length > 1 ? arguments[1] : undefined;
4503 } // eslint-disable-line no-unused-vars
4504
4505 /**
4506 * Function onBeforeApply.
4507 *
4508 * Called before apply().
4509 *
4510 * @param {{}} args
4511 */
4512 }, {
4513 key: "onBeforeApply",
4514 value: function onBeforeApply() {
4515 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4516 } // eslint-disable-line no-unused-vars
4517
4518 /**
4519 * Function onAfterApply.
4520 *
4521 * Called after apply().
4522 *
4523 * @param {{}} args
4524 * @param {*} result
4525 */
4526 }, {
4527 key: "onAfterApply",
4528 value: function onAfterApply() {
4529 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4530 var result = arguments.length > 1 ? arguments[1] : undefined;
4531 } // eslint-disable-line no-unused-vars
4532
4533 /**
4534 * Function onCatchApply.
4535 *
4536 * Called after apply() failed.
4537 *
4538 * @param {Error} e
4539 */
4540 }, {
4541 key: "onCatchApply",
4542 value: function onCatchApply(e) {} // eslint-disable-line no-unused-vars
4543 }], [{
4544 key: "getInstanceType",
4545 value: function getInstanceType() {
4546 return 'CommandInfra';
4547 }
4548
4549 /**
4550 * Get info of command.
4551 *
4552 * @return {Object} Extra information about the command.
4553 */
4554 }, {
4555 key: "getInfo",
4556 value: function getInfo() {
4557 return {};
4558 }
4559
4560 /**
4561 * @return {string} Self command name.
4562 */
4563 }, {
4564 key: "getCommand",
4565 value: function getCommand() {
4566 return this.registerConfig.command;
4567 }
4568
4569 /**
4570 * @return {ComponentBase} Self component
4571 */
4572 }, {
4573 key: "getComponent",
4574 value: function getComponent() {
4575 return this.registerConfig.component;
4576 }
4577 }, {
4578 key: "setRegisterConfig",
4579 value: function setRegisterConfig(config) {
4580 this.registerConfig = Object.freeze(config);
4581 }
4582 }]);
4583 }(_argsObject.default);
4584 /**
4585 * @type {Object}
4586 */
4587 (0, _defineProperty2.default)(CommandInfra, "registerConfig", null);
4588
4589 /***/ }),
4590
4591 /***/ "../modules/web-cli/assets/js/modules/commands/close.js":
4592 /*!**************************************************************!*\
4593 !*** ../modules/web-cli/assets/js/modules/commands/close.js ***!
4594 \**************************************************************/
4595 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4596
4597 "use strict";
4598
4599
4600 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4601 Object.defineProperty(exports, "__esModule", ({
4602 value: true
4603 }));
4604 exports["default"] = exports.Close = void 0;
4605 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4606 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4607 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4608 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4609 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4610 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4611 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)); }
4612 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4613 var Close = exports.Close = /*#__PURE__*/function (_CommandBase) {
4614 function Close() {
4615 (0, _classCallCheck2.default)(this, Close);
4616 return _callSuper(this, Close, arguments);
4617 }
4618 (0, _inherits2.default)(Close, _CommandBase);
4619 return (0, _createClass2.default)(Close, [{
4620 key: "apply",
4621 value: function apply() {
4622 this.component.close();
4623 }
4624 }]);
4625 }(_commandBase.default);
4626 var _default = exports["default"] = Close;
4627
4628 /***/ }),
4629
4630 /***/ "../modules/web-cli/assets/js/modules/commands/index.js":
4631 /*!**************************************************************!*\
4632 !*** ../modules/web-cli/assets/js/modules/commands/index.js ***!
4633 \**************************************************************/
4634 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4635
4636 "use strict";
4637
4638
4639 Object.defineProperty(exports, "__esModule", ({
4640 value: true
4641 }));
4642 Object.defineProperty(exports, "Close", ({
4643 enumerable: true,
4644 get: function get() {
4645 return _close.Close;
4646 }
4647 }));
4648 Object.defineProperty(exports, "Open", ({
4649 enumerable: true,
4650 get: function get() {
4651 return _open.Open;
4652 }
4653 }));
4654 Object.defineProperty(exports, "Toggle", ({
4655 enumerable: true,
4656 get: function get() {
4657 return _toggle.Toggle;
4658 }
4659 }));
4660 var _close = __webpack_require__(/*! ./close */ "../modules/web-cli/assets/js/modules/commands/close.js");
4661 var _open = __webpack_require__(/*! ./open */ "../modules/web-cli/assets/js/modules/commands/open.js");
4662 var _toggle = __webpack_require__(/*! ./toggle */ "../modules/web-cli/assets/js/modules/commands/toggle.js");
4663
4664 /***/ }),
4665
4666 /***/ "../modules/web-cli/assets/js/modules/commands/open.js":
4667 /*!*************************************************************!*\
4668 !*** ../modules/web-cli/assets/js/modules/commands/open.js ***!
4669 \*************************************************************/
4670 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4671
4672 "use strict";
4673
4674
4675 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4676 Object.defineProperty(exports, "__esModule", ({
4677 value: true
4678 }));
4679 exports["default"] = exports.Open = void 0;
4680 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4681 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4682 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4683 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4684 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4685 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4686 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)); }
4687 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4688 var Open = exports.Open = /*#__PURE__*/function (_CommandBase) {
4689 function Open() {
4690 (0, _classCallCheck2.default)(this, Open);
4691 return _callSuper(this, Open, arguments);
4692 }
4693 (0, _inherits2.default)(Open, _CommandBase);
4694 return (0, _createClass2.default)(Open, [{
4695 key: "apply",
4696 value: function apply() {
4697 $e.route(this.component.getNamespace());
4698 }
4699 }]);
4700 }(_commandBase.default);
4701 var _default = exports["default"] = Open;
4702
4703 /***/ }),
4704
4705 /***/ "../modules/web-cli/assets/js/modules/commands/toggle.js":
4706 /*!***************************************************************!*\
4707 !*** ../modules/web-cli/assets/js/modules/commands/toggle.js ***!
4708 \***************************************************************/
4709 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4710
4711 "use strict";
4712
4713
4714 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4715 Object.defineProperty(exports, "__esModule", ({
4716 value: true
4717 }));
4718 exports["default"] = exports.Toggle = void 0;
4719 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4720 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4721 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4722 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4723 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4724 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4725 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)); }
4726 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4727 var Toggle = exports.Toggle = /*#__PURE__*/function (_CommandBase) {
4728 function Toggle() {
4729 (0, _classCallCheck2.default)(this, Toggle);
4730 return _callSuper(this, Toggle, arguments);
4731 }
4732 (0, _inherits2.default)(Toggle, _CommandBase);
4733 return (0, _createClass2.default)(Toggle, [{
4734 key: "apply",
4735 value: function apply() {
4736 if (this.component.isOpen) {
4737 this.component.close();
4738 } else {
4739 $e.route(this.component.getNamespace());
4740 }
4741 }
4742 }]);
4743 }(_commandBase.default);
4744 var _default = exports["default"] = Toggle;
4745
4746 /***/ }),
4747
4748 /***/ "../modules/web-cli/assets/js/modules/component-base.js":
4749 /*!**************************************************************!*\
4750 !*** ../modules/web-cli/assets/js/modules/component-base.js ***!
4751 \**************************************************************/
4752 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4753
4754 "use strict";
4755
4756
4757 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4758 Object.defineProperty(exports, "__esModule", ({
4759 value: true
4760 }));
4761 exports["default"] = void 0;
4762 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4763 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4764 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4765 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4766 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4767 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4768 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4769 var _commandCallbackBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-callback-base */ "../modules/web-cli/assets/js/modules/command-callback-base.js"));
4770 var _toolkit = __webpack_require__(/*! @reduxjs/toolkit */ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js");
4771 var _module = _interopRequireDefault(__webpack_require__(/*! elementor/assets/dev/js/modules/imports/module.js */ "../assets/dev/js/modules/imports/module.js"));
4772 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4773 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4774 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; }
4775 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; }
4776 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)); }
4777 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4778 /**
4779 * @typedef {import('./command-infra')} CommandInfra
4780 * @typedef {import('./hook-base')} HookBase
4781 * @typedef {import('../core/states/ui-state-base')} UiStateBase
4782 */
4783 var ComponentBase = exports["default"] = /*#__PURE__*/function (_Module) {
4784 function ComponentBase() {
4785 (0, _classCallCheck2.default)(this, ComponentBase);
4786 return _callSuper(this, ComponentBase, arguments);
4787 }
4788 (0, _inherits2.default)(ComponentBase, _Module);
4789 return (0, _createClass2.default)(ComponentBase, [{
4790 key: "__construct",
4791 value: function __construct() {
4792 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4793 if (args.manager) {
4794 this.manager = args.manager;
4795 }
4796 this.commands = this.defaultCommands();
4797 this.commandsInternal = this.defaultCommandsInternal();
4798 this.hooks = this.defaultHooks();
4799 this.routes = this.defaultRoutes();
4800 this.tabs = this.defaultTabs();
4801 this.shortcuts = this.defaultShortcuts();
4802 this.utils = this.defaultUtils();
4803 this.data = this.defaultData();
4804 this.uiStates = this.defaultUiStates();
4805 this.states = this.defaultStates();
4806 this.defaultRoute = '';
4807 this.currentTab = '';
4808 }
4809 }, {
4810 key: "registerAPI",
4811 value: function registerAPI() {
4812 var _this = this;
4813 Object.entries(this.getTabs()).forEach(function (tab) {
4814 return _this.registerTabRoute(tab[0]);
4815 });
4816 Object.entries(this.getRoutes()).forEach(function (_ref) {
4817 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
4818 route = _ref2[0],
4819 callback = _ref2[1];
4820 return _this.registerRoute(route, callback);
4821 });
4822 Object.entries(this.getCommands()).forEach(function (_ref3) {
4823 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
4824 command = _ref4[0],
4825 callback = _ref4[1];
4826 return _this.registerCommand(command, callback);
4827 });
4828 Object.entries(this.getCommandsInternal()).forEach(function (_ref5) {
4829 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
4830 command = _ref6[0],
4831 callback = _ref6[1];
4832 return _this.registerCommandInternal(command, callback);
4833 });
4834 Object.values(this.getHooks()).forEach(function (instance) {
4835 return _this.registerHook(instance);
4836 });
4837 Object.entries(this.getData()).forEach(function (_ref7) {
4838 var _ref8 = (0, _slicedToArray2.default)(_ref7, 2),
4839 command = _ref8[0],
4840 callback = _ref8[1];
4841 return _this.registerData(command, callback);
4842 });
4843 Object.values(this.getUiStates()).forEach(function (instance) {
4844 return _this.registerUiState(instance);
4845 });
4846 Object.entries(this.getStates()).forEach(function (_ref9) {
4847 var _ref0 = (0, _slicedToArray2.default)(_ref9, 2),
4848 id = _ref0[0],
4849 state = _ref0[1];
4850 return _this.registerState(id, state);
4851 });
4852 }
4853
4854 // eslint-disable-next-line jsdoc/require-returns-check
4855 /**
4856 * @return {string} namespace
4857 */
4858 }, {
4859 key: "getNamespace",
4860 value: function getNamespace() {
4861 (0, _forceMethodImplementation.default)();
4862 }
4863
4864 /**
4865 * @deprecated since 3.7.0, use `getServiceName()` instead.
4866 */
4867 }, {
4868 key: "getRootContainer",
4869 value: function getRootContainer() {
4870 _deprecation.default.deprecated('getRootContainer()', '3.7.0', 'getServiceName()');
4871 return this.getServiceName();
4872 }
4873 }, {
4874 key: "getServiceName",
4875 value: function getServiceName() {
4876 return this.getNamespace().split('/')[0];
4877 }
4878 }, {
4879 key: "store",
4880 get: function get() {
4881 return $e.store.get(this.getNamespace());
4882 }
4883 }, {
4884 key: "defaultTabs",
4885 value: function defaultTabs() {
4886 return {};
4887 }
4888 }, {
4889 key: "defaultRoutes",
4890 value: function defaultRoutes() {
4891 return {};
4892 }
4893 }, {
4894 key: "defaultCommands",
4895 value: function defaultCommands() {
4896 return {};
4897 }
4898 }, {
4899 key: "defaultCommandsInternal",
4900 value: function defaultCommandsInternal() {
4901 return {};
4902 }
4903 }, {
4904 key: "defaultHooks",
4905 value: function defaultHooks() {
4906 return {};
4907 }
4908
4909 /**
4910 * Get the component's default UI states.
4911 *
4912 * @return {Object} default UI states
4913 */
4914 }, {
4915 key: "defaultUiStates",
4916 value: function defaultUiStates() {
4917 return {};
4918 }
4919
4920 /**
4921 * Get the component's Redux slice settings.
4922 *
4923 * @return {Object} Redux slice settings
4924 */
4925 }, {
4926 key: "defaultStates",
4927 value: function defaultStates() {
4928 return {};
4929 }
4930 }, {
4931 key: "defaultShortcuts",
4932 value: function defaultShortcuts() {
4933 return {};
4934 }
4935 }, {
4936 key: "defaultUtils",
4937 value: function defaultUtils() {
4938 return {};
4939 }
4940 }, {
4941 key: "defaultData",
4942 value: function defaultData() {
4943 return {};
4944 }
4945 }, {
4946 key: "getCommands",
4947 value: function getCommands() {
4948 return this.commands;
4949 }
4950 }, {
4951 key: "getCommandsInternal",
4952 value: function getCommandsInternal() {
4953 return this.commandsInternal;
4954 }
4955 }, {
4956 key: "getHooks",
4957 value: function getHooks() {
4958 return this.hooks;
4959 }
4960
4961 /**
4962 * Retrieve the component's UI states.
4963 *
4964 * @return {Object} UI states
4965 */
4966 }, {
4967 key: "getUiStates",
4968 value: function getUiStates() {
4969 return this.uiStates;
4970 }
4971
4972 /**
4973 * Retrieve the component's Redux Slice.
4974 *
4975 * @return {Object} Redux Slice
4976 */
4977 }, {
4978 key: "getStates",
4979 value: function getStates() {
4980 return this.states;
4981 }
4982 }, {
4983 key: "getRoutes",
4984 value: function getRoutes() {
4985 return this.routes;
4986 }
4987 }, {
4988 key: "getTabs",
4989 value: function getTabs() {
4990 return this.tabs;
4991 }
4992 }, {
4993 key: "getShortcuts",
4994 value: function getShortcuts() {
4995 return this.shortcuts;
4996 }
4997 }, {
4998 key: "getData",
4999 value: function getData() {
5000 return this.data;
5001 }
5002
5003 /**
5004 * @param {string} command
5005 * @param {(()=>{}|CommandInfra)} context
5006 * @param {'default'|'internal'|'data'} commandsType
5007 */
5008 }, {
5009 key: "registerCommand",
5010 value: function registerCommand(command, context) {
5011 var commandsType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'default';
5012 var commandsManager;
5013 switch (commandsType) {
5014 case 'default':
5015 commandsManager = $e.commands;
5016 break;
5017 case 'internal':
5018 commandsManager = $e.commandsInternal;
5019 break;
5020 case 'data':
5021 commandsManager = $e.data;
5022 break;
5023 default:
5024 throw new Error("Invalid commands type: '".concat(command, "'"));
5025 }
5026 var fullCommand = this.getNamespace() + '/' + command,
5027 instanceType = context.getInstanceType ? context.getInstanceType() : false,
5028 registerConfig = {
5029 command: fullCommand,
5030 component: this
5031 };
5032
5033 // Support pure callback.
5034 if (!instanceType) {
5035 if ($e.devTools) {
5036 $e.devTools.log.warn("Attach command-callback-base, on command: '".concat(fullCommand, "', context is unknown type."));
5037 }
5038 registerConfig.callback = context;
5039
5040 // Unique class.
5041 context = /*#__PURE__*/function (_CommandCallbackBase) {
5042 function context() {
5043 (0, _classCallCheck2.default)(this, context);
5044 return _callSuper(this, context, arguments);
5045 }
5046 (0, _inherits2.default)(context, _CommandCallbackBase);
5047 return (0, _createClass2.default)(context);
5048 }(_commandCallbackBase.default);
5049 }
5050 context.setRegisterConfig(registerConfig);
5051 commandsManager.register(this, command, context);
5052 }
5053
5054 /**
5055 * @param {HookBase} instance
5056 */
5057 }, {
5058 key: "registerHook",
5059 value: function registerHook(instance) {
5060 return instance.register();
5061 }
5062 }, {
5063 key: "registerCommandInternal",
5064 value: function registerCommandInternal(command, context) {
5065 this.registerCommand(command, context, 'internal');
5066 }
5067
5068 /**
5069 * Register a UI state.
5070 *
5071 * @param {UiStateBase} instance - UI state instance.
5072 *
5073 * @return {void}
5074 */
5075 }, {
5076 key: "registerUiState",
5077 value: function registerUiState(instance) {
5078 $e.uiStates.register(instance);
5079 }
5080
5081 /**
5082 * Register a Redux Slice.
5083 *
5084 * @param {string} id - State id.
5085 * @param {Object} stateConfig - The state config.
5086 *
5087 * @return {void}
5088 */
5089 }, {
5090 key: "registerState",
5091 value: function registerState(id, stateConfig) {
5092 id = this.getNamespace() + (id ? "/".concat(id) : '');
5093 var slice = (0, _toolkit.createSlice)(_objectSpread(_objectSpread({}, stateConfig), {}, {
5094 name: id
5095 }));
5096 $e.store.register(id, slice);
5097 }
5098 }, {
5099 key: "registerRoute",
5100 value: function registerRoute(route, callback) {
5101 $e.routes.register(this, route, callback);
5102 }
5103 }, {
5104 key: "registerData",
5105 value: function registerData(command, context) {
5106 this.registerCommand(command, context, 'data');
5107 }
5108 }, {
5109 key: "unregisterRoute",
5110 value: function unregisterRoute(route) {
5111 $e.routes.unregister(this, route);
5112 }
5113 }, {
5114 key: "registerTabRoute",
5115 value: function registerTabRoute(tab) {
5116 var _this2 = this;
5117 this.registerRoute(tab, function (args) {
5118 return _this2.activateTab(tab, args);
5119 });
5120 }
5121 }, {
5122 key: "dependency",
5123 value: function dependency() {
5124 return true;
5125 }
5126 }, {
5127 key: "open",
5128 value: function open() {
5129 return true;
5130 }
5131 }, {
5132 key: "close",
5133 value: function close() {
5134 if (!this.isOpen) {
5135 return false;
5136 }
5137 this.isOpen = false;
5138 this.inactivate();
5139 $e.routes.clearCurrent(this.getNamespace());
5140 $e.routes.clearHistory(this.getServiceName());
5141 return true;
5142 }
5143 }, {
5144 key: "activate",
5145 value: function activate() {
5146 $e.components.activate(this.getNamespace());
5147 }
5148 }, {
5149 key: "inactivate",
5150 value: function inactivate() {
5151 $e.components.inactivate(this.getNamespace());
5152 }
5153 }, {
5154 key: "isActive",
5155 value: function isActive() {
5156 return $e.components.isActive(this.getNamespace());
5157 }
5158 }, {
5159 key: "onRoute",
5160 value: function onRoute(route) {
5161 this.toggleRouteClass(route, true);
5162 this.toggleHistoryClass();
5163 this.activate();
5164 this.trigger('route/open', route);
5165 }
5166 }, {
5167 key: "onCloseRoute",
5168 value: function onCloseRoute(route) {
5169 this.toggleRouteClass(route, false);
5170 this.inactivate();
5171 this.trigger('route/close', route);
5172 }
5173 }, {
5174 key: "setDefaultRoute",
5175 value: function setDefaultRoute(route) {
5176 this.defaultRoute = this.getNamespace() + '/' + route;
5177 }
5178 }, {
5179 key: "getDefaultRoute",
5180 value: function getDefaultRoute() {
5181 return this.defaultRoute;
5182 }
5183 }, {
5184 key: "removeTab",
5185 value: function removeTab(tab) {
5186 delete this.tabs[tab];
5187 this.unregisterRoute(tab);
5188 }
5189 }, {
5190 key: "hasTab",
5191 value: function hasTab(tab) {
5192 return !!this.tabs[tab];
5193 }
5194 }, {
5195 key: "addTab",
5196 value: function addTab(tab, args, position) {
5197 var _this3 = this;
5198 this.tabs[tab] = args;
5199 // It can be 0.
5200 if ('undefined' !== typeof position) {
5201 var newTabs = {};
5202 var ids = Object.keys(this.tabs);
5203 // Remove new tab
5204 ids.pop();
5205
5206 // Add it to position.
5207 ids.splice(position, 0, tab);
5208 ids.forEach(function (id) {
5209 newTabs[id] = _this3.tabs[id];
5210 });
5211 this.tabs = newTabs;
5212 }
5213 this.registerTabRoute(tab);
5214 }
5215 }, {
5216 key: "getTabsWrapperSelector",
5217 value: function getTabsWrapperSelector() {
5218 return '';
5219 }
5220 }, {
5221 key: "getTabRoute",
5222 value: function getTabRoute(tab) {
5223 return this.getNamespace() + '/' + tab;
5224 }
5225 }, {
5226 key: "renderTab",
5227 value: function renderTab(tab) {} // eslint-disable-line
5228 }, {
5229 key: "activateTab",
5230 value: function activateTab(tab, args) {
5231 var _this4 = this;
5232 this.renderTab(tab, args);
5233 jQuery(this.getTabsWrapperSelector() + ' .elementor-component-tab').off('click').on('click', function (event) {
5234 $e.route(_this4.getTabRoute(event.currentTarget.dataset.tab), args);
5235 }).removeClass('elementor-active').filter('[data-tab="' + tab + '"]').addClass('elementor-active');
5236 }
5237 }, {
5238 key: "getActiveTabConfig",
5239 value: function getActiveTabConfig() {
5240 return this.tabs[this.currentTab] || {};
5241 }
5242 }, {
5243 key: "getBodyClass",
5244 value: function getBodyClass(route) {
5245 return 'e-route-' + route.replace(/\//g, '-');
5246 }
5247
5248 /**
5249 * If command includes uppercase character convert it to lowercase and add `-`.
5250 * e.g: `CopyAll` is converted to `copy-all`.
5251 *
5252 * @param {string} commandName
5253 */
5254 }, {
5255 key: "normalizeCommandName",
5256 value: function normalizeCommandName(commandName) {
5257 return commandName.replace(/[A-Z]/g, function (match, offset) {
5258 return (offset > 0 ? '-' : '') + match.toLowerCase();
5259 });
5260 }
5261
5262 /**
5263 * @param {{}} commandsFromImport
5264 * @return {{}} imported commands
5265 */
5266 }, {
5267 key: "importCommands",
5268 value: function importCommands(commandsFromImport) {
5269 var _this5 = this;
5270 var commands = {};
5271
5272 // Convert `Commands` to `ComponentBase` workable format.
5273 Object.entries(commandsFromImport).forEach(function (_ref1) {
5274 var _ref10 = (0, _slicedToArray2.default)(_ref1, 2),
5275 className = _ref10[0],
5276 Class = _ref10[1];
5277 var command = _this5.normalizeCommandName(className);
5278 commands[command] = Class;
5279 });
5280 return commands;
5281 }
5282 }, {
5283 key: "importHooks",
5284 value: function importHooks(hooksFromImport) {
5285 var hooks = {};
5286 for (var key in hooksFromImport) {
5287 var hook = new hooksFromImport[key]();
5288 hooks[hook.getId()] = hook;
5289 }
5290 return hooks;
5291 }
5292
5293 /**
5294 * Import & initialize the component's UI states.
5295 * Should be used inside `defaultUiState()`.
5296 *
5297 * @param {Object} statesFromImport - UI states from import.
5298 *
5299 * @return {Object} UI States
5300 */
5301 }, {
5302 key: "importUiStates",
5303 value: function importUiStates(statesFromImport) {
5304 var _this6 = this;
5305 var uiStates = {};
5306 Object.values(statesFromImport).forEach(function (className) {
5307 var uiState = new className(_this6);
5308 uiStates[uiState.getId()] = uiState;
5309 });
5310 return uiStates;
5311 }
5312
5313 /**
5314 * Set a UI state value.
5315 * TODO: Should we provide such function? Maybe the developer should implicitly pass the full state ID?
5316 *
5317 * @param {string} state - Non-prefixed state ID.
5318 * @param {*} value - New state value.
5319 *
5320 * @return {void}
5321 */
5322 }, {
5323 key: "setUiState",
5324 value: function setUiState(state, value) {
5325 $e.uiStates.set("".concat(this.getNamespace(), "/").concat(state), value);
5326 }
5327 }, {
5328 key: "toggleRouteClass",
5329 value: function toggleRouteClass(route, state) {
5330 document.body.classList.toggle(this.getBodyClass(route), state);
5331 }
5332 }, {
5333 key: "toggleHistoryClass",
5334 value: function toggleHistoryClass() {
5335 document.body.classList.toggle('e-routes-has-history', !!$e.routes.getHistory(this.getServiceName()).length);
5336 }
5337 }]);
5338 }(_module.default);
5339
5340 /***/ }),
5341
5342 /***/ "../modules/web-cli/assets/js/modules/component-modal-base.js":
5343 /*!********************************************************************!*\
5344 !*** ../modules/web-cli/assets/js/modules/component-modal-base.js ***!
5345 \********************************************************************/
5346 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5347
5348 "use strict";
5349
5350
5351 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5352 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
5353 Object.defineProperty(exports, "__esModule", ({
5354 value: true
5355 }));
5356 exports["default"] = void 0;
5357 var _readOnlyError2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/readOnlyError */ "../node_modules/@babel/runtime/helpers/readOnlyError.js"));
5358 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5359 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5360 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5361 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5362 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
5363 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5364 var _componentBase = _interopRequireDefault(__webpack_require__(/*! ./component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
5365 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../modules/web-cli/assets/js/modules/commands/index.js"));
5366 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
5367 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); }
5368 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)); }
5369 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5370 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; }
5371 var ComponentModalBase = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
5372 function ComponentModalBase() {
5373 (0, _classCallCheck2.default)(this, ComponentModalBase);
5374 return _callSuper(this, ComponentModalBase, arguments);
5375 }
5376 (0, _inherits2.default)(ComponentModalBase, _ComponentBase);
5377 return (0, _createClass2.default)(ComponentModalBase, [{
5378 key: "registerAPI",
5379 value: function registerAPI() {
5380 var _this = this;
5381 _superPropGet(ComponentModalBase, "registerAPI", this, 3)([]);
5382 $e.shortcuts.register('esc', {
5383 scopes: [this.getNamespace()],
5384 callback: function callback() {
5385 return _this.close();
5386 }
5387 });
5388 }
5389 }, {
5390 key: "defaultCommands",
5391 value: function defaultCommands() {
5392 return this.importCommands(commands);
5393 }
5394 }, {
5395 key: "defaultRoutes",
5396 value: function defaultRoutes() {
5397 return {
5398 '': function _() {/* Nothing to do, it's already rendered. */}
5399 };
5400 }
5401 }, {
5402 key: "open",
5403 value: function open() {
5404 var _this2 = this;
5405 if (!this.layout) {
5406 var layout = this.getModalLayout();
5407 this.layout = new layout({
5408 component: this
5409 });
5410 this.layout.getModal().on('hide', function () {
5411 return _this2.close();
5412 });
5413 }
5414 this.layout.showModal();
5415 return true;
5416 }
5417 }, {
5418 key: "close",
5419 value: function close() {
5420 if (!_superPropGet(ComponentModalBase, "close", this, 3)([])) {
5421 return false;
5422 }
5423 var close = elementor.hooks.applyFilters('component/modal/close', this.layout.getModal().hide.bind(this.layout.getModal()), this);
5424 close();
5425 return true;
5426 }
5427 }, {
5428 key: "getModalLayout",
5429 value: function getModalLayout() {
5430 (0, _forceMethodImplementation.default)();
5431 }
5432 }]);
5433 }(_componentBase.default);
5434
5435 /***/ }),
5436
5437 /***/ "../modules/web-cli/assets/js/utils/console.js":
5438 /*!*****************************************************!*\
5439 !*** ../modules/web-cli/assets/js/utils/console.js ***!
5440 \*****************************************************/
5441 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5442
5443 "use strict";
5444
5445
5446 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5447 Object.defineProperty(exports, "__esModule", ({
5448 value: true
5449 }));
5450 exports["default"] = void 0;
5451 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5452 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5453 var Console = exports["default"] = /*#__PURE__*/function () {
5454 function Console() {
5455 (0, _classCallCheck2.default)(this, Console);
5456 }
5457 return (0, _createClass2.default)(Console, null, [{
5458 key: "error",
5459 value: function error(message) {
5460 // Show an error if devTools is available.
5461 if ($e.devTools) {
5462 $e.devTools.log.error(message);
5463 }
5464
5465 // If not a 'Hook-Break' then show error.
5466 if (!(message instanceof $e.modules.HookBreak)) {
5467 // eslint-disable-next-line no-console
5468 console.error(message);
5469 }
5470 }
5471 }, {
5472 key: "warn",
5473 value: function warn() {
5474 var _console;
5475 var style = "font-size: 12px; background-image: url(\"".concat(elementorWebCliConfig.urls.assets, "images/logo-icon.png\"); background-repeat: no-repeat; background-size: contain;");
5476 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5477 args[_key] = arguments[_key];
5478 }
5479 args.unshift('%c %c', style, '');
5480 (_console = console).warn.apply(_console, args); // eslint-disable-line no-console
5481 }
5482 }]);
5483 }();
5484
5485 /***/ }),
5486
5487 /***/ "../modules/web-cli/assets/js/utils/deprecation.js":
5488 /*!*********************************************************!*\
5489 !*** ../modules/web-cli/assets/js/utils/deprecation.js ***!
5490 \*********************************************************/
5491 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5492
5493 "use strict";
5494
5495
5496 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5497 Object.defineProperty(exports, "__esModule", ({
5498 value: true
5499 }));
5500 exports["default"] = void 0;
5501 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
5502 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5503 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5504 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
5505 // Copied from `modules/dev-tools/assets/js/deprecation.js`
5506 /**
5507 * @typedef {Object} Version
5508 * @property {number} major1 The first number
5509 * @property {number} major2 The second number
5510 * @property {number} minor The third number
5511 * @property {string} build The fourth number
5512 */
5513
5514 var softDeprecated = function softDeprecated(name, version, replacement) {
5515 if (elementorWebCliConfig.isDebug) {
5516 deprecatedMessage('soft', name, version, replacement);
5517 }
5518 };
5519 var hardDeprecated = function hardDeprecated(name, version, replacement) {
5520 deprecatedMessage('hard', name, version, replacement);
5521 };
5522 var deprecatedMessage = function deprecatedMessage(type, name, version, replacement) {
5523 var message = "`".concat(name, "` is ").concat(type, " deprecated since ").concat(version);
5524 if (replacement) {
5525 message += " - Use `".concat(replacement, "` instead");
5526 }
5527 _console.default.warn(message);
5528 };
5529 var Deprecation = exports["default"] = /*#__PURE__*/function () {
5530 function Deprecation() {
5531 (0, _classCallCheck2.default)(this, Deprecation);
5532 }
5533 return (0, _createClass2.default)(Deprecation, null, [{
5534 key: "deprecated",
5535 value: function deprecated(name, version, replacement) {
5536 if (this.isHardDeprecated(version)) {
5537 hardDeprecated(name, version, replacement);
5538 } else {
5539 softDeprecated(name, version, replacement);
5540 }
5541 }
5542
5543 /**
5544 * @param {string} version
5545 *
5546 * @return {Version}
5547 */
5548 }, {
5549 key: "parseVersion",
5550 value: function parseVersion(version) {
5551 var versionParts = version.split('.');
5552 if (versionParts.length < 3 || versionParts.length > 4) {
5553 throw new RangeError('Invalid Semantic Version string provided');
5554 }
5555 var _versionParts = (0, _slicedToArray2.default)(versionParts, 4),
5556 major1 = _versionParts[0],
5557 major2 = _versionParts[1],
5558 minor = _versionParts[2],
5559 _versionParts$ = _versionParts[3],
5560 build = _versionParts$ === void 0 ? '' : _versionParts$;
5561 return {
5562 major1: parseInt(major1),
5563 major2: parseInt(major2),
5564 minor: parseInt(minor),
5565 build: build
5566 };
5567 }
5568
5569 /**
5570 * Get total of major.
5571 *
5572 * 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,
5573 * versions with major2 more then 9 will be added to total.
5574 *
5575 * @param {Version} versionObj
5576 *
5577 * @return {number}
5578 */
5579 }, {
5580 key: "getTotalMajor",
5581 value: function getTotalMajor(versionObj) {
5582 var total = parseInt("".concat(versionObj.major1).concat(versionObj.major2, "0"));
5583 total = Number((total / 10).toFixed(0));
5584 if (versionObj.major2 > 9) {
5585 total = versionObj.major2 - 9;
5586 }
5587 return total;
5588 }
5589
5590 /**
5591 * @param {string} version1
5592 * @param {string} version2
5593 *
5594 * @return {number}
5595 */
5596 }, {
5597 key: "compareVersion",
5598 value: function compareVersion(version1, version2) {
5599 var _this = this;
5600 return [this.parseVersion(version1), this.parseVersion(version2)].map(function (versionObj) {
5601 return _this.getTotalMajor(versionObj);
5602 }).reduce(function (acc, major) {
5603 return acc - major;
5604 });
5605 }
5606
5607 /**
5608 * @param {string} version
5609 *
5610 * @return {boolean}
5611 */
5612 }, {
5613 key: "isSoftDeprecated",
5614 value: function isSoftDeprecated(version) {
5615 var total = this.compareVersion(version, elementorWebCliConfig.version);
5616 return total <= 4;
5617 }
5618
5619 /**
5620 * @param {string} version
5621 * @return {boolean}
5622 */
5623 }, {
5624 key: "isHardDeprecated",
5625 value: function isHardDeprecated(version) {
5626 var total = this.compareVersion(version, elementorWebCliConfig.version);
5627 return total < 0 || total >= 8;
5628 }
5629 }]);
5630 }();
5631
5632 /***/ }),
5633
5634 /***/ "../modules/web-cli/assets/js/utils/force-method-implementation.js":
5635 /*!*************************************************************************!*\
5636 !*** ../modules/web-cli/assets/js/utils/force-method-implementation.js ***!
5637 \*************************************************************************/
5638 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5639
5640 "use strict";
5641
5642
5643 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5644 Object.defineProperty(exports, "__esModule", ({
5645 value: true
5646 }));
5647 exports["default"] = exports.ForceMethodImplementation = void 0;
5648 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5649 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5650 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5651 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5652 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5653 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
5654 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)); }
5655 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5656 // TODO: Copied from `assets/dev/js/modules/imports/force-method-implementation.js`;
5657 var ForceMethodImplementation = exports.ForceMethodImplementation = /*#__PURE__*/function (_Error) {
5658 function ForceMethodImplementation() {
5659 var _this;
5660 var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5661 (0, _classCallCheck2.default)(this, ForceMethodImplementation);
5662 _this = _callSuper(this, ForceMethodImplementation, ["".concat(info.isStatic ? 'static ' : '').concat(info.fullName, "() should be implemented, please provide '").concat(info.functionName || info.fullName, "' functionality.")]);
5663 Error.captureStackTrace(_this, ForceMethodImplementation);
5664 return _this;
5665 }
5666 (0, _inherits2.default)(ForceMethodImplementation, _Error);
5667 return (0, _createClass2.default)(ForceMethodImplementation);
5668 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
5669 var _default = exports["default"] = function _default() {
5670 var stack = Error().stack,
5671 caller = stack.split('\n')[2].trim(),
5672 callerName = caller.startsWith('at new') ? 'constructor' : caller.split(' ')[1],
5673 info = {};
5674 info.functionName = callerName;
5675 info.fullName = callerName;
5676 if (info.functionName.includes('.')) {
5677 var parts = info.functionName.split('.');
5678 info.className = parts[0];
5679 info.functionName = parts[1];
5680 } else {
5681 info.isStatic = true;
5682 }
5683 throw new ForceMethodImplementation(info);
5684 };
5685
5686 /***/ }),
5687
5688 /***/ "../node_modules/@babel/runtime/helpers/OverloadYield.js":
5689 /*!***************************************************************!*\
5690 !*** ../node_modules/@babel/runtime/helpers/OverloadYield.js ***!
5691 \***************************************************************/
5692 /***/ ((module) => {
5693
5694 function _OverloadYield(e, d) {
5695 this.v = e, this.k = d;
5696 }
5697 module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
5698
5699 /***/ }),
5700
5701 /***/ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
5702 /*!******************************************************************!*\
5703 !*** ../node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
5704 \******************************************************************/
5705 /***/ ((module) => {
5706
5707 function _arrayLikeToArray(r, a) {
5708 (null == a || a > r.length) && (a = r.length);
5709 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
5710 return n;
5711 }
5712 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
5713
5714 /***/ }),
5715
5716 /***/ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js":
5717 /*!****************************************************************!*\
5718 !*** ../node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
5719 \****************************************************************/
5720 /***/ ((module) => {
5721
5722 function _arrayWithHoles(r) {
5723 if (Array.isArray(r)) return r;
5724 }
5725 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
5726
5727 /***/ }),
5728
5729 /***/ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js":
5730 /*!***********************************************************************!*\
5731 !*** ../node_modules/@babel/runtime/helpers/assertThisInitialized.js ***!
5732 \***********************************************************************/
5733 /***/ ((module) => {
5734
5735 function _assertThisInitialized(e) {
5736 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5737 return e;
5738 }
5739 module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
5740
5741 /***/ }),
5742
5743 /***/ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js":
5744 /*!******************************************************************!*\
5745 !*** ../node_modules/@babel/runtime/helpers/asyncToGenerator.js ***!
5746 \******************************************************************/
5747 /***/ ((module) => {
5748
5749 function asyncGeneratorStep(n, t, e, r, o, a, c) {
5750 try {
5751 var i = n[a](c),
5752 u = i.value;
5753 } catch (n) {
5754 return void e(n);
5755 }
5756 i.done ? t(u) : Promise.resolve(u).then(r, o);
5757 }
5758 function _asyncToGenerator(n) {
5759 return function () {
5760 var t = this,
5761 e = arguments;
5762 return new Promise(function (r, o) {
5763 var a = n.apply(t, e);
5764 function _next(n) {
5765 asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
5766 }
5767 function _throw(n) {
5768 asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
5769 }
5770 _next(void 0);
5771 });
5772 };
5773 }
5774 module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5775
5776 /***/ }),
5777
5778 /***/ "../node_modules/@babel/runtime/helpers/classCallCheck.js":
5779 /*!****************************************************************!*\
5780 !*** ../node_modules/@babel/runtime/helpers/classCallCheck.js ***!
5781 \****************************************************************/
5782 /***/ ((module) => {
5783
5784 function _classCallCheck(a, n) {
5785 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
5786 }
5787 module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
5788
5789 /***/ }),
5790
5791 /***/ "../node_modules/@babel/runtime/helpers/construct.js":
5792 /*!***********************************************************!*\
5793 !*** ../node_modules/@babel/runtime/helpers/construct.js ***!
5794 \***********************************************************/
5795 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5796
5797 var isNativeReflectConstruct = __webpack_require__(/*! ./isNativeReflectConstruct.js */ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js");
5798 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5799 function _construct(t, e, r) {
5800 if (isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
5801 var o = [null];
5802 o.push.apply(o, e);
5803 var p = new (t.bind.apply(t, o))();
5804 return r && setPrototypeOf(p, r.prototype), p;
5805 }
5806 module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5807
5808 /***/ }),
5809
5810 /***/ "../node_modules/@babel/runtime/helpers/createClass.js":
5811 /*!*************************************************************!*\
5812 !*** ../node_modules/@babel/runtime/helpers/createClass.js ***!
5813 \*************************************************************/
5814 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5815
5816 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5817 function _defineProperties(e, r) {
5818 for (var t = 0; t < r.length; t++) {
5819 var o = r[t];
5820 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
5821 }
5822 }
5823 function _createClass(e, r, t) {
5824 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
5825 writable: !1
5826 }), e;
5827 }
5828 module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
5829
5830 /***/ }),
5831
5832 /***/ "../node_modules/@babel/runtime/helpers/defineProperty.js":
5833 /*!****************************************************************!*\
5834 !*** ../node_modules/@babel/runtime/helpers/defineProperty.js ***!
5835 \****************************************************************/
5836 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5837
5838 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5839 function _defineProperty(e, r, t) {
5840 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5841 value: t,
5842 enumerable: !0,
5843 configurable: !0,
5844 writable: !0
5845 }) : e[r] = t, e;
5846 }
5847 module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
5848
5849 /***/ }),
5850
5851 /***/ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js":
5852 /*!********************************************************************!*\
5853 !*** ../node_modules/@babel/runtime/helpers/esm/defineProperty.js ***!
5854 \********************************************************************/
5855 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5856
5857 "use strict";
5858 __webpack_require__.r(__webpack_exports__);
5859 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5860 /* harmony export */ "default": () => (/* binding */ _defineProperty)
5861 /* harmony export */ });
5862 /* harmony import */ var _toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js");
5863
5864 function _defineProperty(e, r, t) {
5865 return (r = (0,_toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r)) in e ? Object.defineProperty(e, r, {
5866 value: t,
5867 enumerable: !0,
5868 configurable: !0,
5869 writable: !0
5870 }) : e[r] = t, e;
5871 }
5872
5873
5874 /***/ }),
5875
5876 /***/ "../node_modules/@babel/runtime/helpers/esm/objectSpread2.js":
5877 /*!*******************************************************************!*\
5878 !*** ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js ***!
5879 \*******************************************************************/
5880 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5881
5882 "use strict";
5883 __webpack_require__.r(__webpack_exports__);
5884 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5885 /* harmony export */ "default": () => (/* binding */ _objectSpread2)
5886 /* harmony export */ });
5887 /* harmony import */ var _defineProperty_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defineProperty.js */ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js");
5888
5889 function ownKeys(e, r) {
5890 var t = Object.keys(e);
5891 if (Object.getOwnPropertySymbols) {
5892 var o = Object.getOwnPropertySymbols(e);
5893 r && (o = o.filter(function (r) {
5894 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5895 })), t.push.apply(t, o);
5896 }
5897 return t;
5898 }
5899 function _objectSpread2(e) {
5900 for (var r = 1; r < arguments.length; r++) {
5901 var t = null != arguments[r] ? arguments[r] : {};
5902 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
5903 (0,_defineProperty_js__WEBPACK_IMPORTED_MODULE_0__["default"])(e, r, t[r]);
5904 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
5905 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5906 });
5907 }
5908 return e;
5909 }
5910
5911
5912 /***/ }),
5913
5914 /***/ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js":
5915 /*!*****************************************************************!*\
5916 !*** ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js ***!
5917 \*****************************************************************/
5918 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5919
5920 "use strict";
5921 __webpack_require__.r(__webpack_exports__);
5922 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5923 /* harmony export */ "default": () => (/* binding */ toPrimitive)
5924 /* harmony export */ });
5925 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5926
5927 function toPrimitive(t, r) {
5928 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(t) || !t) return t;
5929 var e = t[Symbol.toPrimitive];
5930 if (void 0 !== e) {
5931 var i = e.call(t, r || "default");
5932 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i)) return i;
5933 throw new TypeError("@@toPrimitive must return a primitive value.");
5934 }
5935 return ("string" === r ? String : Number)(t);
5936 }
5937
5938
5939 /***/ }),
5940
5941 /***/ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js":
5942 /*!*******************************************************************!*\
5943 !*** ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js ***!
5944 \*******************************************************************/
5945 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5946
5947 "use strict";
5948 __webpack_require__.r(__webpack_exports__);
5949 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5950 /* harmony export */ "default": () => (/* binding */ toPropertyKey)
5951 /* harmony export */ });
5952 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5953 /* harmony import */ var _toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js");
5954
5955
5956 function toPropertyKey(t) {
5957 var i = (0,_toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__["default"])(t, "string");
5958 return "symbol" == (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i) ? i : i + "";
5959 }
5960
5961
5962 /***/ }),
5963
5964 /***/ "../node_modules/@babel/runtime/helpers/esm/typeof.js":
5965 /*!************************************************************!*\
5966 !*** ../node_modules/@babel/runtime/helpers/esm/typeof.js ***!
5967 \************************************************************/
5968 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5969
5970 "use strict";
5971 __webpack_require__.r(__webpack_exports__);
5972 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5973 /* harmony export */ "default": () => (/* binding */ _typeof)
5974 /* harmony export */ });
5975 function _typeof(o) {
5976 "@babel/helpers - typeof";
5977
5978 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
5979 return typeof o;
5980 } : function (o) {
5981 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
5982 }, _typeof(o);
5983 }
5984
5985
5986 /***/ }),
5987
5988 /***/ "../node_modules/@babel/runtime/helpers/get.js":
5989 /*!*****************************************************!*\
5990 !*** ../node_modules/@babel/runtime/helpers/get.js ***!
5991 \*****************************************************/
5992 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5993
5994 var superPropBase = __webpack_require__(/*! ./superPropBase.js */ "../node_modules/@babel/runtime/helpers/superPropBase.js");
5995 function _get() {
5996 return module.exports = _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
5997 var p = superPropBase(e, t);
5998 if (p) {
5999 var n = Object.getOwnPropertyDescriptor(p, t);
6000 return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
6001 }
6002 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _get.apply(null, arguments);
6003 }
6004 module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
6005
6006 /***/ }),
6007
6008 /***/ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js":
6009 /*!****************************************************************!*\
6010 !*** ../node_modules/@babel/runtime/helpers/getPrototypeOf.js ***!
6011 \****************************************************************/
6012 /***/ ((module) => {
6013
6014 function _getPrototypeOf(t) {
6015 return module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
6016 return t.__proto__ || Object.getPrototypeOf(t);
6017 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _getPrototypeOf(t);
6018 }
6019 module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6020
6021 /***/ }),
6022
6023 /***/ "../node_modules/@babel/runtime/helpers/inherits.js":
6024 /*!**********************************************************!*\
6025 !*** ../node_modules/@babel/runtime/helpers/inherits.js ***!
6026 \**********************************************************/
6027 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6028
6029 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6030 function _inherits(t, e) {
6031 if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
6032 t.prototype = Object.create(e && e.prototype, {
6033 constructor: {
6034 value: t,
6035 writable: !0,
6036 configurable: !0
6037 }
6038 }), Object.defineProperty(t, "prototype", {
6039 writable: !1
6040 }), e && setPrototypeOf(t, e);
6041 }
6042 module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
6043
6044 /***/ }),
6045
6046 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
6047 /*!***********************************************************************!*\
6048 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
6049 \***********************************************************************/
6050 /***/ ((module) => {
6051
6052 function _interopRequireDefault(e) {
6053 return e && e.__esModule ? e : {
6054 "default": e
6055 };
6056 }
6057 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
6058
6059 /***/ }),
6060
6061 /***/ "../node_modules/@babel/runtime/helpers/isNativeFunction.js":
6062 /*!******************************************************************!*\
6063 !*** ../node_modules/@babel/runtime/helpers/isNativeFunction.js ***!
6064 \******************************************************************/
6065 /***/ ((module) => {
6066
6067 function _isNativeFunction(t) {
6068 try {
6069 return -1 !== Function.toString.call(t).indexOf("[native code]");
6070 } catch (n) {
6071 return "function" == typeof t;
6072 }
6073 }
6074 module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
6075
6076 /***/ }),
6077
6078 /***/ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js":
6079 /*!**************************************************************************!*\
6080 !*** ../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js ***!
6081 \**************************************************************************/
6082 /***/ ((module) => {
6083
6084 function _isNativeReflectConstruct() {
6085 try {
6086 var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
6087 } catch (t) {}
6088 return (module.exports = _isNativeReflectConstruct = function _isNativeReflectConstruct() {
6089 return !!t;
6090 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6091 }
6092 module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
6093
6094 /***/ }),
6095
6096 /***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
6097 /*!**********************************************************************!*\
6098 !*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
6099 \**********************************************************************/
6100 /***/ ((module) => {
6101
6102 function _iterableToArrayLimit(r, l) {
6103 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
6104 if (null != t) {
6105 var e,
6106 n,
6107 i,
6108 u,
6109 a = [],
6110 f = !0,
6111 o = !1;
6112 try {
6113 if (i = (t = t.call(r)).next, 0 === l) {
6114 if (Object(t) !== t) return;
6115 f = !1;
6116 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
6117 } catch (r) {
6118 o = !0, n = r;
6119 } finally {
6120 try {
6121 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
6122 } finally {
6123 if (o) throw n;
6124 }
6125 }
6126 return a;
6127 }
6128 }
6129 module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
6130
6131 /***/ }),
6132
6133 /***/ "../node_modules/@babel/runtime/helpers/nonIterableRest.js":
6134 /*!*****************************************************************!*\
6135 !*** ../node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
6136 \*****************************************************************/
6137 /***/ ((module) => {
6138
6139 function _nonIterableRest() {
6140 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6141 }
6142 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
6143
6144 /***/ }),
6145
6146 /***/ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js":
6147 /*!***************************************************************************!*\
6148 !*** ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js ***!
6149 \***************************************************************************/
6150 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6151
6152 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6153 var assertThisInitialized = __webpack_require__(/*! ./assertThisInitialized.js */ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js");
6154 function _possibleConstructorReturn(t, e) {
6155 if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
6156 if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
6157 return assertThisInitialized(t);
6158 }
6159 module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
6160
6161 /***/ }),
6162
6163 /***/ "../node_modules/@babel/runtime/helpers/readOnlyError.js":
6164 /*!***************************************************************!*\
6165 !*** ../node_modules/@babel/runtime/helpers/readOnlyError.js ***!
6166 \***************************************************************/
6167 /***/ ((module) => {
6168
6169 function _readOnlyError(r) {
6170 throw new TypeError('"' + r + '" is read-only');
6171 }
6172 module.exports = _readOnlyError, module.exports.__esModule = true, module.exports["default"] = module.exports;
6173
6174 /***/ }),
6175
6176 /***/ "../node_modules/@babel/runtime/helpers/regenerator.js":
6177 /*!*************************************************************!*\
6178 !*** ../node_modules/@babel/runtime/helpers/regenerator.js ***!
6179 \*************************************************************/
6180 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6181
6182 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
6183 function _regenerator() {
6184 /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
6185 var e,
6186 t,
6187 r = "function" == typeof Symbol ? Symbol : {},
6188 n = r.iterator || "@@iterator",
6189 o = r.toStringTag || "@@toStringTag";
6190 function i(r, n, o, i) {
6191 var c = n && n.prototype instanceof Generator ? n : Generator,
6192 u = Object.create(c.prototype);
6193 return regeneratorDefine(u, "_invoke", function (r, n, o) {
6194 var i,
6195 c,
6196 u,
6197 f = 0,
6198 p = o || [],
6199 y = !1,
6200 G = {
6201 p: 0,
6202 n: 0,
6203 v: e,
6204 a: d,
6205 f: d.bind(e, 4),
6206 d: function d(t, r) {
6207 return i = t, c = 0, u = e, G.n = r, a;
6208 }
6209 };
6210 function d(r, n) {
6211 for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
6212 var o,
6213 i = p[t],
6214 d = G.p,
6215 l = i[2];
6216 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));
6217 }
6218 if (o || r > 1) return a;
6219 throw y = !0, n;
6220 }
6221 return function (o, p, l) {
6222 if (f > 1) throw TypeError("Generator is already running");
6223 for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
6224 i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
6225 try {
6226 if (f = 2, i) {
6227 if (c || (o = "next"), t = i[o]) {
6228 if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
6229 if (!t.done) return t;
6230 u = t.value, c < 2 && (c = 0);
6231 } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
6232 i = e;
6233 } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
6234 } catch (t) {
6235 i = e, c = 1, u = t;
6236 } finally {
6237 f = 1;
6238 }
6239 }
6240 return {
6241 value: t,
6242 done: y
6243 };
6244 };
6245 }(r, o, i), !0), u;
6246 }
6247 var a = {};
6248 function Generator() {}
6249 function GeneratorFunction() {}
6250 function GeneratorFunctionPrototype() {}
6251 t = Object.getPrototypeOf;
6252 var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
6253 return this;
6254 }), t),
6255 u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
6256 function f(e) {
6257 return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
6258 }
6259 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 () {
6260 return this;
6261 }), regeneratorDefine(u, "toString", function () {
6262 return "[object Generator]";
6263 }), (module.exports = _regenerator = function _regenerator() {
6264 return {
6265 w: i,
6266 m: f
6267 };
6268 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6269 }
6270 module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
6271
6272 /***/ }),
6273
6274 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js":
6275 /*!******************************************************************!*\
6276 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsync.js ***!
6277 \******************************************************************/
6278 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6279
6280 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
6281 function _regeneratorAsync(n, e, r, t, o) {
6282 var a = regeneratorAsyncGen(n, e, r, t, o);
6283 return a.next().then(function (n) {
6284 return n.done ? n.value : a.next();
6285 });
6286 }
6287 module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
6288
6289 /***/ }),
6290
6291 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js":
6292 /*!*********************************************************************!*\
6293 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js ***!
6294 \*********************************************************************/
6295 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6296
6297 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
6298 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
6299 function _regeneratorAsyncGen(r, e, t, o, n) {
6300 return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
6301 }
6302 module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
6303
6304 /***/ }),
6305
6306 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js":
6307 /*!**************************************************************************!*\
6308 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js ***!
6309 \**************************************************************************/
6310 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6311
6312 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
6313 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
6314 function AsyncIterator(t, e) {
6315 function n(r, o, i, f) {
6316 try {
6317 var c = t[r](o),
6318 u = c.value;
6319 return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
6320 n("next", t, i, f);
6321 }, function (t) {
6322 n("throw", t, i, f);
6323 }) : e.resolve(u).then(function (t) {
6324 c.value = t, i(c);
6325 }, function (t) {
6326 return n("throw", t, i, f);
6327 });
6328 } catch (t) {
6329 f(t);
6330 }
6331 }
6332 var r;
6333 this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
6334 return this;
6335 })), regeneratorDefine(this, "_invoke", function (t, o, i) {
6336 function f() {
6337 return new e(function (e, r) {
6338 n(t, i, e, r);
6339 });
6340 }
6341 return r = r ? r.then(f, f) : f();
6342 }, !0);
6343 }
6344 module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
6345
6346 /***/ }),
6347
6348 /***/ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js":
6349 /*!*******************************************************************!*\
6350 !*** ../node_modules/@babel/runtime/helpers/regeneratorDefine.js ***!
6351 \*******************************************************************/
6352 /***/ ((module) => {
6353
6354 function _regeneratorDefine(e, r, n, t) {
6355 var i = Object.defineProperty;
6356 try {
6357 i({}, "", {});
6358 } catch (e) {
6359 i = 0;
6360 }
6361 module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
6362 function o(r, n) {
6363 _regeneratorDefine(e, r, function (e) {
6364 return this._invoke(r, n, e);
6365 });
6366 }
6367 r ? i ? i(e, r, {
6368 value: n,
6369 enumerable: !t,
6370 configurable: !t,
6371 writable: !t
6372 }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
6373 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
6374 }
6375 module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
6376
6377 /***/ }),
6378
6379 /***/ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js":
6380 /*!*****************************************************************!*\
6381 !*** ../node_modules/@babel/runtime/helpers/regeneratorKeys.js ***!
6382 \*****************************************************************/
6383 /***/ ((module) => {
6384
6385 function _regeneratorKeys(e) {
6386 var n = Object(e),
6387 r = [];
6388 for (var t in n) r.unshift(t);
6389 return function e() {
6390 for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
6391 return e.done = !0, e;
6392 };
6393 }
6394 module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
6395
6396 /***/ }),
6397
6398 /***/ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js":
6399 /*!********************************************************************!*\
6400 !*** ../node_modules/@babel/runtime/helpers/regeneratorRuntime.js ***!
6401 \********************************************************************/
6402 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6403
6404 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
6405 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
6406 var regeneratorAsync = __webpack_require__(/*! ./regeneratorAsync.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js");
6407 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
6408 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
6409 var regeneratorKeys = __webpack_require__(/*! ./regeneratorKeys.js */ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js");
6410 var regeneratorValues = __webpack_require__(/*! ./regeneratorValues.js */ "../node_modules/@babel/runtime/helpers/regeneratorValues.js");
6411 function _regeneratorRuntime() {
6412 "use strict";
6413
6414 var r = regenerator(),
6415 e = r.m(_regeneratorRuntime),
6416 t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
6417 function n(r) {
6418 var e = "function" == typeof r && r.constructor;
6419 return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
6420 }
6421 var o = {
6422 "throw": 1,
6423 "return": 2,
6424 "break": 3,
6425 "continue": 3
6426 };
6427 function a(r) {
6428 var e, t;
6429 return function (n) {
6430 e || (e = {
6431 stop: function stop() {
6432 return t(n.a, 2);
6433 },
6434 "catch": function _catch() {
6435 return n.v;
6436 },
6437 abrupt: function abrupt(r, e) {
6438 return t(n.a, o[r], e);
6439 },
6440 delegateYield: function delegateYield(r, o, a) {
6441 return e.resultName = o, t(n.d, regeneratorValues(r), a);
6442 },
6443 finish: function finish(r) {
6444 return t(n.f, r);
6445 }
6446 }, t = function t(r, _t, o) {
6447 n.p = e.prev, n.n = e.next;
6448 try {
6449 return r(_t, o);
6450 } finally {
6451 e.next = n.n;
6452 }
6453 }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
6454 try {
6455 return r.call(this, e);
6456 } finally {
6457 n.p = e.prev, n.n = e.next;
6458 }
6459 };
6460 }
6461 return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
6462 return {
6463 wrap: function wrap(e, t, n, o) {
6464 return r.w(a(e), t, n, o && o.reverse());
6465 },
6466 isGeneratorFunction: n,
6467 mark: r.m,
6468 awrap: function awrap(r, e) {
6469 return new OverloadYield(r, e);
6470 },
6471 AsyncIterator: regeneratorAsyncIterator,
6472 async: function async(r, e, t, o, u) {
6473 return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
6474 },
6475 keys: regeneratorKeys,
6476 values: regeneratorValues
6477 };
6478 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6479 }
6480 module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
6481
6482 /***/ }),
6483
6484 /***/ "../node_modules/@babel/runtime/helpers/regeneratorValues.js":
6485 /*!*******************************************************************!*\
6486 !*** ../node_modules/@babel/runtime/helpers/regeneratorValues.js ***!
6487 \*******************************************************************/
6488 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6489
6490 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6491 function _regeneratorValues(e) {
6492 if (null != e) {
6493 var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
6494 r = 0;
6495 if (t) return t.call(e);
6496 if ("function" == typeof e.next) return e;
6497 if (!isNaN(e.length)) return {
6498 next: function next() {
6499 return e && r >= e.length && (e = void 0), {
6500 value: e && e[r++],
6501 done: !e
6502 };
6503 }
6504 };
6505 }
6506 throw new TypeError(_typeof(e) + " is not iterable");
6507 }
6508 module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
6509
6510 /***/ }),
6511
6512 /***/ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js":
6513 /*!****************************************************************!*\
6514 !*** ../node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
6515 \****************************************************************/
6516 /***/ ((module) => {
6517
6518 function _setPrototypeOf(t, e) {
6519 return module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
6520 return t.__proto__ = e, t;
6521 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _setPrototypeOf(t, e);
6522 }
6523 module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6524
6525 /***/ }),
6526
6527 /***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js":
6528 /*!***************************************************************!*\
6529 !*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***!
6530 \***************************************************************/
6531 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6532
6533 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js");
6534 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
6535 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
6536 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "../node_modules/@babel/runtime/helpers/nonIterableRest.js");
6537 function _slicedToArray(r, e) {
6538 return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();
6539 }
6540 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6541
6542 /***/ }),
6543
6544 /***/ "../node_modules/@babel/runtime/helpers/superPropBase.js":
6545 /*!***************************************************************!*\
6546 !*** ../node_modules/@babel/runtime/helpers/superPropBase.js ***!
6547 \***************************************************************/
6548 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6549
6550 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6551 function _superPropBase(t, o) {
6552 for (; !{}.hasOwnProperty.call(t, o) && null !== (t = getPrototypeOf(t)););
6553 return t;
6554 }
6555 module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
6556
6557 /***/ }),
6558
6559 /***/ "../node_modules/@babel/runtime/helpers/toPrimitive.js":
6560 /*!*************************************************************!*\
6561 !*** ../node_modules/@babel/runtime/helpers/toPrimitive.js ***!
6562 \*************************************************************/
6563 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6564
6565 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6566 function toPrimitive(t, r) {
6567 if ("object" != _typeof(t) || !t) return t;
6568 var e = t[Symbol.toPrimitive];
6569 if (void 0 !== e) {
6570 var i = e.call(t, r || "default");
6571 if ("object" != _typeof(i)) return i;
6572 throw new TypeError("@@toPrimitive must return a primitive value.");
6573 }
6574 return ("string" === r ? String : Number)(t);
6575 }
6576 module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
6577
6578 /***/ }),
6579
6580 /***/ "../node_modules/@babel/runtime/helpers/toPropertyKey.js":
6581 /*!***************************************************************!*\
6582 !*** ../node_modules/@babel/runtime/helpers/toPropertyKey.js ***!
6583 \***************************************************************/
6584 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6585
6586 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6587 var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/toPrimitive.js");
6588 function toPropertyKey(t) {
6589 var i = toPrimitive(t, "string");
6590 return "symbol" == _typeof(i) ? i : i + "";
6591 }
6592 module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
6593
6594 /***/ }),
6595
6596 /***/ "../node_modules/@babel/runtime/helpers/typeof.js":
6597 /*!********************************************************!*\
6598 !*** ../node_modules/@babel/runtime/helpers/typeof.js ***!
6599 \********************************************************/
6600 /***/ ((module) => {
6601
6602 function _typeof(o) {
6603 "@babel/helpers - typeof";
6604
6605 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
6606 return typeof o;
6607 } : function (o) {
6608 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
6609 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
6610 }
6611 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
6612
6613 /***/ }),
6614
6615 /***/ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
6616 /*!****************************************************************************!*\
6617 !*** ../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
6618 \****************************************************************************/
6619 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6620
6621 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
6622 function _unsupportedIterableToArray(r, a) {
6623 if (r) {
6624 if ("string" == typeof r) return arrayLikeToArray(r, a);
6625 var t = {}.toString.call(r).slice(8, -1);
6626 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;
6627 }
6628 }
6629 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6630
6631 /***/ }),
6632
6633 /***/ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js":
6634 /*!*****************************************************************!*\
6635 !*** ../node_modules/@babel/runtime/helpers/wrapNativeSuper.js ***!
6636 \*****************************************************************/
6637 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6638
6639 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6640 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6641 var isNativeFunction = __webpack_require__(/*! ./isNativeFunction.js */ "../node_modules/@babel/runtime/helpers/isNativeFunction.js");
6642 var construct = __webpack_require__(/*! ./construct.js */ "../node_modules/@babel/runtime/helpers/construct.js");
6643 function _wrapNativeSuper(t) {
6644 var r = "function" == typeof Map ? new Map() : void 0;
6645 return module.exports = _wrapNativeSuper = function _wrapNativeSuper(t) {
6646 if (null === t || !isNativeFunction(t)) return t;
6647 if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
6648 if (void 0 !== r) {
6649 if (r.has(t)) return r.get(t);
6650 r.set(t, Wrapper);
6651 }
6652 function Wrapper() {
6653 return construct(t, arguments, getPrototypeOf(this).constructor);
6654 }
6655 return Wrapper.prototype = Object.create(t.prototype, {
6656 constructor: {
6657 value: Wrapper,
6658 enumerable: !1,
6659 writable: !0,
6660 configurable: !0
6661 }
6662 }), setPrototypeOf(Wrapper, t);
6663 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _wrapNativeSuper(t);
6664 }
6665 module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
6666
6667 /***/ }),
6668
6669 /***/ "../node_modules/@babel/runtime/regenerator/index.js":
6670 /*!***********************************************************!*\
6671 !*** ../node_modules/@babel/runtime/regenerator/index.js ***!
6672 \***********************************************************/
6673 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6674
6675 // TODO(Babel 8): Remove this file.
6676
6677 var runtime = __webpack_require__(/*! ../helpers/regeneratorRuntime */ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js")();
6678 module.exports = runtime;
6679
6680 // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
6681 try {
6682 regeneratorRuntime = runtime;
6683 } catch (accidentalStrictMode) {
6684 if (typeof globalThis === "object") {
6685 globalThis.regeneratorRuntime = runtime;
6686 } else {
6687 Function("r", "regeneratorRuntime = r")(runtime);
6688 }
6689 }
6690
6691
6692 /***/ }),
6693
6694 /***/ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js":
6695 /*!******************************************************************!*\
6696 !*** ../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js ***!
6697 \******************************************************************/
6698 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6699
6700 "use strict";
6701 __webpack_require__.r(__webpack_exports__);
6702 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6703 /* harmony export */ EnhancerArray: () => (/* binding */ EnhancerArray),
6704 /* harmony export */ MiddlewareArray: () => (/* binding */ MiddlewareArray),
6705 /* harmony export */ SHOULD_AUTOBATCH: () => (/* binding */ SHOULD_AUTOBATCH),
6706 /* harmony export */ TaskAbortError: () => (/* binding */ TaskAbortError),
6707 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.__DO_NOT_USE__ActionTypes),
6708 /* harmony export */ addListener: () => (/* binding */ addListener),
6709 /* harmony export */ applyMiddleware: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware),
6710 /* harmony export */ autoBatchEnhancer: () => (/* binding */ autoBatchEnhancer),
6711 /* harmony export */ bindActionCreators: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.bindActionCreators),
6712 /* harmony export */ clearAllListeners: () => (/* binding */ clearAllListeners),
6713 /* harmony export */ combineReducers: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers),
6714 /* harmony export */ compose: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.compose),
6715 /* harmony export */ configureStore: () => (/* binding */ configureStore),
6716 /* harmony export */ createAction: () => (/* binding */ createAction),
6717 /* harmony export */ createActionCreatorInvariantMiddleware: () => (/* binding */ createActionCreatorInvariantMiddleware),
6718 /* harmony export */ createAsyncThunk: () => (/* binding */ createAsyncThunk),
6719 /* harmony export */ createDraftSafeSelector: () => (/* binding */ createDraftSafeSelector),
6720 /* harmony export */ createEntityAdapter: () => (/* binding */ createEntityAdapter),
6721 /* harmony export */ createImmutableStateInvariantMiddleware: () => (/* binding */ createImmutableStateInvariantMiddleware),
6722 /* harmony export */ createListenerMiddleware: () => (/* binding */ createListenerMiddleware),
6723 /* harmony export */ createNextState: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__["default"]),
6724 /* harmony export */ createReducer: () => (/* binding */ createReducer),
6725 /* harmony export */ createSelector: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector),
6726 /* harmony export */ createSerializableStateInvariantMiddleware: () => (/* binding */ createSerializableStateInvariantMiddleware),
6727 /* harmony export */ createSlice: () => (/* binding */ createSlice),
6728 /* harmony export */ createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.createStore),
6729 /* harmony export */ current: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.current),
6730 /* harmony export */ findNonSerializableValue: () => (/* binding */ findNonSerializableValue),
6731 /* harmony export */ freeze: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.freeze),
6732 /* harmony export */ getDefaultMiddleware: () => (/* binding */ getDefaultMiddleware),
6733 /* harmony export */ getType: () => (/* binding */ getType),
6734 /* harmony export */ isAction: () => (/* binding */ isAction),
6735 /* harmony export */ isActionCreator: () => (/* binding */ isActionCreator),
6736 /* harmony export */ isAllOf: () => (/* binding */ isAllOf),
6737 /* harmony export */ isAnyOf: () => (/* binding */ isAnyOf),
6738 /* harmony export */ isAsyncThunkAction: () => (/* binding */ isAsyncThunkAction),
6739 /* harmony export */ isDraft: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.isDraft),
6740 /* harmony export */ isFluxStandardAction: () => (/* binding */ isFSA),
6741 /* harmony export */ isFulfilled: () => (/* binding */ isFulfilled),
6742 /* harmony export */ isImmutableDefault: () => (/* binding */ isImmutableDefault),
6743 /* harmony export */ isPending: () => (/* binding */ isPending),
6744 /* harmony export */ isPlain: () => (/* binding */ isPlain),
6745 /* harmony export */ isPlainObject: () => (/* binding */ isPlainObject),
6746 /* harmony export */ isRejected: () => (/* binding */ isRejected),
6747 /* harmony export */ isRejectedWithValue: () => (/* binding */ isRejectedWithValue),
6748 /* harmony export */ legacy_createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.legacy_createStore),
6749 /* harmony export */ miniSerializeError: () => (/* binding */ miniSerializeError),
6750 /* harmony export */ nanoid: () => (/* binding */ nanoid),
6751 /* harmony export */ original: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.original),
6752 /* harmony export */ prepareAutoBatched: () => (/* binding */ prepareAutoBatched),
6753 /* harmony export */ removeListener: () => (/* binding */ removeListener),
6754 /* harmony export */ unwrapResult: () => (/* binding */ unwrapResult)
6755 /* harmony export */ });
6756 /* harmony import */ var immer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! immer */ "../node_modules/immer/dist/immer.esm.mjs");
6757 /* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! redux */ "../node_modules/redux/es/redux.js");
6758 /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! reselect */ "../node_modules/reselect/es/index.js");
6759 /* harmony import */ var redux_thunk__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! redux-thunk */ "../node_modules/redux-thunk/es/index.js");
6760 var __extends = (undefined && undefined.__extends) || (function () {
6761 var extendStatics = function (d, b) {
6762 extendStatics = Object.setPrototypeOf ||
6763 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6764 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6765 return extendStatics(d, b);
6766 };
6767 return function (d, b) {
6768 if (typeof b !== "function" && b !== null)
6769 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
6770 extendStatics(d, b);
6771 function __() { this.constructor = d; }
6772 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6773 };
6774 })();
6775 var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
6776 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6777 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6778 function verb(n) { return function (v) { return step([n, v]); }; }
6779 function step(op) {
6780 if (f) throw new TypeError("Generator is already executing.");
6781 while (_) try {
6782 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;
6783 if (y = 0, t) op = [op[0] & 2, t.value];
6784 switch (op[0]) {
6785 case 0: case 1: t = op; break;
6786 case 4: _.label++; return { value: op[1], done: false };
6787 case 5: _.label++; y = op[1]; op = [0]; continue;
6788 case 7: op = _.ops.pop(); _.trys.pop(); continue;
6789 default:
6790 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6791 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6792 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6793 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6794 if (t[2]) _.ops.pop();
6795 _.trys.pop(); continue;
6796 }
6797 op = body.call(thisArg, _);
6798 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6799 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6800 }
6801 };
6802 var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
6803 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
6804 to[j] = from[i];
6805 return to;
6806 };
6807 var __defProp = Object.defineProperty;
6808 var __defProps = Object.defineProperties;
6809 var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6810 var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6811 var __hasOwnProp = Object.prototype.hasOwnProperty;
6812 var __propIsEnum = Object.prototype.propertyIsEnumerable;
6813 var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
6814 var __spreadValues = function (a, b) {
6815 for (var prop in b || (b = {}))
6816 if (__hasOwnProp.call(b, prop))
6817 __defNormalProp(a, prop, b[prop]);
6818 if (__getOwnPropSymbols)
6819 for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
6820 var prop = _c[_i];
6821 if (__propIsEnum.call(b, prop))
6822 __defNormalProp(a, prop, b[prop]);
6823 }
6824 return a;
6825 };
6826 var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
6827 var __async = function (__this, __arguments, generator) {
6828 return new Promise(function (resolve, reject) {
6829 var fulfilled = function (value) {
6830 try {
6831 step(generator.next(value));
6832 }
6833 catch (e) {
6834 reject(e);
6835 }
6836 };
6837 var rejected = function (value) {
6838 try {
6839 step(generator.throw(value));
6840 }
6841 catch (e) {
6842 reject(e);
6843 }
6844 };
6845 var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
6846 step((generator = generator.apply(__this, __arguments)).next());
6847 });
6848 };
6849 // src/index.ts
6850
6851
6852
6853
6854 // src/createDraftSafeSelector.ts
6855
6856
6857 var createDraftSafeSelector = function () {
6858 var args = [];
6859 for (var _i = 0; _i < arguments.length; _i++) {
6860 args[_i] = arguments[_i];
6861 }
6862 var selector = reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector.apply(void 0, args);
6863 var wrappedSelector = function (value) {
6864 var rest = [];
6865 for (var _i = 1; _i < arguments.length; _i++) {
6866 rest[_i - 1] = arguments[_i];
6867 }
6868 return selector.apply(void 0, __spreadArray([(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(value) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__.current)(value) : value], rest));
6869 };
6870 return wrappedSelector;
6871 };
6872 // src/configureStore.ts
6873
6874 // src/devtoolsExtension.ts
6875
6876 var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
6877 if (arguments.length === 0)
6878 return void 0;
6879 if (typeof arguments[0] === "object")
6880 return redux__WEBPACK_IMPORTED_MODULE_1__.compose;
6881 return redux__WEBPACK_IMPORTED_MODULE_1__.compose.apply(null, arguments);
6882 };
6883 var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function () {
6884 return function (noop2) {
6885 return noop2;
6886 };
6887 };
6888 // src/isPlainObject.ts
6889 function isPlainObject(value) {
6890 if (typeof value !== "object" || value === null)
6891 return false;
6892 var proto = Object.getPrototypeOf(value);
6893 if (proto === null)
6894 return true;
6895 var baseProto = proto;
6896 while (Object.getPrototypeOf(baseProto) !== null) {
6897 baseProto = Object.getPrototypeOf(baseProto);
6898 }
6899 return proto === baseProto;
6900 }
6901 // src/getDefaultMiddleware.ts
6902
6903 // src/tsHelpers.ts
6904 var hasMatchFunction = function (v) {
6905 return v && typeof v.match === "function";
6906 };
6907 // src/createAction.ts
6908 function createAction(type, prepareAction) {
6909 function actionCreator() {
6910 var args = [];
6911 for (var _i = 0; _i < arguments.length; _i++) {
6912 args[_i] = arguments[_i];
6913 }
6914 if (prepareAction) {
6915 var prepared = prepareAction.apply(void 0, args);
6916 if (!prepared) {
6917 throw new Error("prepareAction did not return an object");
6918 }
6919 return __spreadValues(__spreadValues({
6920 type: type,
6921 payload: prepared.payload
6922 }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
6923 }
6924 return { type: type, payload: args[0] };
6925 }
6926 actionCreator.toString = function () { return "" + type; };
6927 actionCreator.type = type;
6928 actionCreator.match = function (action) { return action.type === type; };
6929 return actionCreator;
6930 }
6931 function isAction(action) {
6932 return isPlainObject(action) && "type" in action;
6933 }
6934 function isActionCreator(action) {
6935 return typeof action === "function" && "type" in action && hasMatchFunction(action);
6936 }
6937 function isFSA(action) {
6938 return isAction(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
6939 }
6940 function isValidKey(key) {
6941 return ["type", "payload", "error", "meta"].indexOf(key) > -1;
6942 }
6943 function getType(actionCreator) {
6944 return "" + actionCreator;
6945 }
6946 // src/actionCreatorInvariantMiddleware.ts
6947 function getMessage(type) {
6948 var splitType = type ? ("" + type).split("/") : [];
6949 var actionName = splitType[splitType.length - 1] || "actionCreator";
6950 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.";
6951 }
6952 function createActionCreatorInvariantMiddleware(options) {
6953 if (options === void 0) { options = {}; }
6954 if (false) // removed by dead control flow
6955 {}
6956 var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
6957 return function () { return function (next) { return function (action) {
6958 if (isActionCreator2(action)) {
6959 console.warn(getMessage(action.type));
6960 }
6961 return next(action);
6962 }; }; };
6963 }
6964 // src/utils.ts
6965
6966 function getTimeMeasureUtils(maxDelay, fnName) {
6967 var elapsed = 0;
6968 return {
6969 measureTime: function (fn) {
6970 var started = Date.now();
6971 try {
6972 return fn();
6973 }
6974 finally {
6975 var finished = Date.now();
6976 elapsed += finished - started;
6977 }
6978 },
6979 warnIfExceeded: function () {
6980 if (elapsed > maxDelay) {
6981 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.");
6982 }
6983 }
6984 };
6985 }
6986 var MiddlewareArray = /** @class */ (function (_super) {
6987 __extends(MiddlewareArray, _super);
6988 function MiddlewareArray() {
6989 var args = [];
6990 for (var _i = 0; _i < arguments.length; _i++) {
6991 args[_i] = arguments[_i];
6992 }
6993 var _this = _super.apply(this, args) || this;
6994 Object.setPrototypeOf(_this, MiddlewareArray.prototype);
6995 return _this;
6996 }
6997 Object.defineProperty(MiddlewareArray, Symbol.species, {
6998 get: function () {
6999 return MiddlewareArray;
7000 },
7001 enumerable: false,
7002 configurable: true
7003 });
7004 MiddlewareArray.prototype.concat = function () {
7005 var arr = [];
7006 for (var _i = 0; _i < arguments.length; _i++) {
7007 arr[_i] = arguments[_i];
7008 }
7009 return _super.prototype.concat.apply(this, arr);
7010 };
7011 MiddlewareArray.prototype.prepend = function () {
7012 var arr = [];
7013 for (var _i = 0; _i < arguments.length; _i++) {
7014 arr[_i] = arguments[_i];
7015 }
7016 if (arr.length === 1 && Array.isArray(arr[0])) {
7017 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
7018 }
7019 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
7020 };
7021 return MiddlewareArray;
7022 }(Array));
7023 var EnhancerArray = /** @class */ (function (_super) {
7024 __extends(EnhancerArray, _super);
7025 function EnhancerArray() {
7026 var args = [];
7027 for (var _i = 0; _i < arguments.length; _i++) {
7028 args[_i] = arguments[_i];
7029 }
7030 var _this = _super.apply(this, args) || this;
7031 Object.setPrototypeOf(_this, EnhancerArray.prototype);
7032 return _this;
7033 }
7034 Object.defineProperty(EnhancerArray, Symbol.species, {
7035 get: function () {
7036 return EnhancerArray;
7037 },
7038 enumerable: false,
7039 configurable: true
7040 });
7041 EnhancerArray.prototype.concat = function () {
7042 var arr = [];
7043 for (var _i = 0; _i < arguments.length; _i++) {
7044 arr[_i] = arguments[_i];
7045 }
7046 return _super.prototype.concat.apply(this, arr);
7047 };
7048 EnhancerArray.prototype.prepend = function () {
7049 var arr = [];
7050 for (var _i = 0; _i < arguments.length; _i++) {
7051 arr[_i] = arguments[_i];
7052 }
7053 if (arr.length === 1 && Array.isArray(arr[0])) {
7054 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
7055 }
7056 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
7057 };
7058 return EnhancerArray;
7059 }(Array));
7060 function freezeDraftable(val) {
7061 return (0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(val) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(val, function () {
7062 }) : val;
7063 }
7064 // src/immutableStateInvariantMiddleware.ts
7065 var isProduction = "development" === "production";
7066 var prefix = "Invariant failed";
7067 function invariant(condition, message) {
7068 if (condition) {
7069 return;
7070 }
7071 if (isProduction) {
7072 throw new Error(prefix);
7073 }
7074 throw new Error(prefix + ": " + (message || ""));
7075 }
7076 function stringify(obj, serializer, indent, decycler) {
7077 return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
7078 }
7079 function getSerialize(serializer, decycler) {
7080 var stack = [], keys = [];
7081 if (!decycler)
7082 decycler = function (_, value) {
7083 if (stack[0] === value)
7084 return "[Circular ~]";
7085 return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
7086 };
7087 return function (key, value) {
7088 if (stack.length > 0) {
7089 var thisPos = stack.indexOf(this);
7090 ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
7091 ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
7092 if (~stack.indexOf(value))
7093 value = decycler.call(this, key, value);
7094 }
7095 else
7096 stack.push(value);
7097 return serializer == null ? value : serializer.call(this, key, value);
7098 };
7099 }
7100 function isImmutableDefault(value) {
7101 return typeof value !== "object" || value == null || Object.isFrozen(value);
7102 }
7103 function trackForMutations(isImmutable, ignorePaths, obj) {
7104 var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
7105 return {
7106 detectMutations: function () {
7107 return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
7108 }
7109 };
7110 }
7111 function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
7112 if (ignorePaths === void 0) { ignorePaths = []; }
7113 if (path === void 0) { path = ""; }
7114 if (checkedObjects === void 0) { checkedObjects = new Set(); }
7115 var tracked = { value: obj };
7116 if (!isImmutable(obj) && !checkedObjects.has(obj)) {
7117 checkedObjects.add(obj);
7118 tracked.children = {};
7119 for (var key in obj) {
7120 var childPath = path ? path + "." + key : key;
7121 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
7122 continue;
7123 }
7124 tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
7125 }
7126 }
7127 return tracked;
7128 }
7129 function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
7130 if (ignoredPaths === void 0) { ignoredPaths = []; }
7131 if (sameParentRef === void 0) { sameParentRef = false; }
7132 if (path === void 0) { path = ""; }
7133 var prevObj = trackedProperty ? trackedProperty.value : void 0;
7134 var sameRef = prevObj === obj;
7135 if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
7136 return { wasMutated: true, path: path };
7137 }
7138 if (isImmutable(prevObj) || isImmutable(obj)) {
7139 return { wasMutated: false };
7140 }
7141 var keysToDetect = {};
7142 for (var key in trackedProperty.children) {
7143 keysToDetect[key] = true;
7144 }
7145 for (var key in obj) {
7146 keysToDetect[key] = true;
7147 }
7148 var hasIgnoredPaths = ignoredPaths.length > 0;
7149 var _loop_1 = function (key) {
7150 var nestedPath = path ? path + "." + key : key;
7151 if (hasIgnoredPaths) {
7152 var hasMatches = ignoredPaths.some(function (ignored) {
7153 if (ignored instanceof RegExp) {
7154 return ignored.test(nestedPath);
7155 }
7156 return nestedPath === ignored;
7157 });
7158 if (hasMatches) {
7159 return "continue";
7160 }
7161 }
7162 var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
7163 if (result.wasMutated) {
7164 return { value: result };
7165 }
7166 };
7167 for (var key in keysToDetect) {
7168 var state_1 = _loop_1(key);
7169 if (typeof state_1 === "object")
7170 return state_1.value;
7171 }
7172 return { wasMutated: false };
7173 }
7174 function createImmutableStateInvariantMiddleware(options) {
7175 if (options === void 0) { options = {}; }
7176 if (false) // removed by dead control flow
7177 {}
7178 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;
7179 ignoredPaths = ignoredPaths || ignore;
7180 var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
7181 return function (_c) {
7182 var getState = _c.getState;
7183 var state = getState();
7184 var tracker = track(state);
7185 var result;
7186 return function (next) { return function (action) {
7187 var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
7188 measureUtils.measureTime(function () {
7189 state = getState();
7190 result = tracker.detectMutations();
7191 tracker = track(state);
7192 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)");
7193 });
7194 var dispatchedAction = next(action);
7195 measureUtils.measureTime(function () {
7196 state = getState();
7197 result = tracker.detectMutations();
7198 tracker = track(state);
7199 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)");
7200 });
7201 measureUtils.warnIfExceeded();
7202 return dispatchedAction;
7203 }; };
7204 };
7205 }
7206 // src/serializableStateInvariantMiddleware.ts
7207 function isPlain(val) {
7208 var type = typeof val;
7209 return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
7210 }
7211 function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
7212 if (path === void 0) { path = ""; }
7213 if (isSerializable === void 0) { isSerializable = isPlain; }
7214 if (ignoredPaths === void 0) { ignoredPaths = []; }
7215 var foundNestedSerializable;
7216 if (!isSerializable(value)) {
7217 return {
7218 keyPath: path || "<root>",
7219 value: value
7220 };
7221 }
7222 if (typeof value !== "object" || value === null) {
7223 return false;
7224 }
7225 if (cache == null ? void 0 : cache.has(value))
7226 return false;
7227 var entries = getEntries != null ? getEntries(value) : Object.entries(value);
7228 var hasIgnoredPaths = ignoredPaths.length > 0;
7229 var _loop_2 = function (key, nestedValue) {
7230 var nestedPath = path ? path + "." + key : key;
7231 if (hasIgnoredPaths) {
7232 var hasMatches = ignoredPaths.some(function (ignored) {
7233 if (ignored instanceof RegExp) {
7234 return ignored.test(nestedPath);
7235 }
7236 return nestedPath === ignored;
7237 });
7238 if (hasMatches) {
7239 return "continue";
7240 }
7241 }
7242 if (!isSerializable(nestedValue)) {
7243 return { value: {
7244 keyPath: nestedPath,
7245 value: nestedValue
7246 } };
7247 }
7248 if (typeof nestedValue === "object") {
7249 foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
7250 if (foundNestedSerializable) {
7251 return { value: foundNestedSerializable };
7252 }
7253 }
7254 };
7255 for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
7256 var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
7257 var state_2 = _loop_2(key, nestedValue);
7258 if (typeof state_2 === "object")
7259 return state_2.value;
7260 }
7261 if (cache && isNestedFrozen(value))
7262 cache.add(value);
7263 return false;
7264 }
7265 function isNestedFrozen(value) {
7266 if (!Object.isFrozen(value))
7267 return false;
7268 for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
7269 var nestedValue = _c[_i];
7270 if (typeof nestedValue !== "object" || nestedValue === null)
7271 continue;
7272 if (!isNestedFrozen(nestedValue))
7273 return false;
7274 }
7275 return true;
7276 }
7277 function createSerializableStateInvariantMiddleware(options) {
7278 if (options === void 0) { options = {}; }
7279 if (false) // removed by dead control flow
7280 {}
7281 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;
7282 var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
7283 return function (storeAPI) { return function (next) { return function (action) {
7284 var result = next(action);
7285 var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
7286 if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
7287 measureUtils.measureTime(function () {
7288 var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
7289 if (foundActionNonSerializableValue) {
7290 var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
7291 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)");
7292 }
7293 });
7294 }
7295 if (!ignoreState) {
7296 measureUtils.measureTime(function () {
7297 var state = storeAPI.getState();
7298 var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
7299 if (foundStateNonSerializableValue) {
7300 var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
7301 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)");
7302 }
7303 });
7304 measureUtils.warnIfExceeded();
7305 }
7306 return result;
7307 }; }; };
7308 }
7309 // src/getDefaultMiddleware.ts
7310 function isBoolean(x) {
7311 return typeof x === "boolean";
7312 }
7313 function curryGetDefaultMiddleware() {
7314 return function curriedGetDefaultMiddleware(options) {
7315 return getDefaultMiddleware(options);
7316 };
7317 }
7318 function getDefaultMiddleware(options) {
7319 if (options === void 0) { options = {}; }
7320 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;
7321 var middlewareArray = new MiddlewareArray();
7322 if (thunk) {
7323 if (isBoolean(thunk)) {
7324 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"]);
7325 }
7326 else {
7327 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"].withExtraArgument(thunk.extraArgument));
7328 }
7329 }
7330 if (true) {
7331 if (immutableCheck) {
7332 var immutableOptions = {};
7333 if (!isBoolean(immutableCheck)) {
7334 immutableOptions = immutableCheck;
7335 }
7336 middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
7337 }
7338 if (serializableCheck) {
7339 var serializableOptions = {};
7340 if (!isBoolean(serializableCheck)) {
7341 serializableOptions = serializableCheck;
7342 }
7343 middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
7344 }
7345 if (actionCreatorCheck) {
7346 var actionCreatorOptions = {};
7347 if (!isBoolean(actionCreatorCheck)) {
7348 actionCreatorOptions = actionCreatorCheck;
7349 }
7350 middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
7351 }
7352 }
7353 return middlewareArray;
7354 }
7355 // src/configureStore.ts
7356 var IS_PRODUCTION = "development" === "production";
7357 function configureStore(options) {
7358 var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
7359 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;
7360 var rootReducer;
7361 if (typeof reducer === "function") {
7362 rootReducer = reducer;
7363 }
7364 else if (isPlainObject(reducer)) {
7365 rootReducer = (0,redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers)(reducer);
7366 }
7367 else {
7368 throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
7369 }
7370 var finalMiddleware = middleware;
7371 if (typeof finalMiddleware === "function") {
7372 finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
7373 if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
7374 throw new Error("when using a middleware builder function, an array of middleware must be returned");
7375 }
7376 }
7377 if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
7378 throw new Error("each middleware provided to configureStore must be a function");
7379 }
7380 var middlewareEnhancer = redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware.apply(void 0, finalMiddleware);
7381 var finalCompose = redux__WEBPACK_IMPORTED_MODULE_1__.compose;
7382 if (devTools) {
7383 finalCompose = composeWithDevTools(__spreadValues({
7384 trace: !IS_PRODUCTION
7385 }, typeof devTools === "object" && devTools));
7386 }
7387 var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
7388 var storeEnhancers = defaultEnhancers;
7389 if (Array.isArray(enhancers)) {
7390 storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
7391 }
7392 else if (typeof enhancers === "function") {
7393 storeEnhancers = enhancers(defaultEnhancers);
7394 }
7395 var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
7396 return (0,redux__WEBPACK_IMPORTED_MODULE_1__.createStore)(rootReducer, preloadedState, composedEnhancer);
7397 }
7398 // src/createReducer.ts
7399
7400 // src/mapBuilders.ts
7401 function executeReducerBuilderCallback(builderCallback) {
7402 var actionsMap = {};
7403 var actionMatchers = [];
7404 var defaultCaseReducer;
7405 var builder = {
7406 addCase: function (typeOrActionCreator, reducer) {
7407 if (true) {
7408 if (actionMatchers.length > 0) {
7409 throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
7410 }
7411 if (defaultCaseReducer) {
7412 throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
7413 }
7414 }
7415 var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
7416 if (!type) {
7417 throw new Error("`builder.addCase` cannot be called with an empty action type");
7418 }
7419 if (type in actionsMap) {
7420 throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");
7421 }
7422 actionsMap[type] = reducer;
7423 return builder;
7424 },
7425 addMatcher: function (matcher, reducer) {
7426 if (true) {
7427 if (defaultCaseReducer) {
7428 throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
7429 }
7430 }
7431 actionMatchers.push({ matcher: matcher, reducer: reducer });
7432 return builder;
7433 },
7434 addDefaultCase: function (reducer) {
7435 if (true) {
7436 if (defaultCaseReducer) {
7437 throw new Error("`builder.addDefaultCase` can only be called once");
7438 }
7439 }
7440 defaultCaseReducer = reducer;
7441 return builder;
7442 }
7443 };
7444 builderCallback(builder);
7445 return [actionsMap, actionMatchers, defaultCaseReducer];
7446 }
7447 // src/createReducer.ts
7448 function isStateFunction(x) {
7449 return typeof x === "function";
7450 }
7451 var hasWarnedAboutObjectNotation = false;
7452 function createReducer(initialState, mapOrBuilderCallback, actionMatchers, defaultCaseReducer) {
7453 if (actionMatchers === void 0) { actionMatchers = []; }
7454 if (true) {
7455 if (typeof mapOrBuilderCallback === "object") {
7456 if (!hasWarnedAboutObjectNotation) {
7457 hasWarnedAboutObjectNotation = true;
7458 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");
7459 }
7460 }
7461 }
7462 var _c = typeof mapOrBuilderCallback === "function" ? executeReducerBuilderCallback(mapOrBuilderCallback) : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer], actionsMap = _c[0], finalActionMatchers = _c[1], finalDefaultCaseReducer = _c[2];
7463 var getInitialState;
7464 if (isStateFunction(initialState)) {
7465 getInitialState = function () { return freezeDraftable(initialState()); };
7466 }
7467 else {
7468 var frozenInitialState_1 = freezeDraftable(initialState);
7469 getInitialState = function () { return frozenInitialState_1; };
7470 }
7471 function reducer(state, action) {
7472 if (state === void 0) { state = getInitialState(); }
7473 var caseReducers = __spreadArray([
7474 actionsMap[action.type]
7475 ], finalActionMatchers.filter(function (_c) {
7476 var matcher = _c.matcher;
7477 return matcher(action);
7478 }).map(function (_c) {
7479 var reducer2 = _c.reducer;
7480 return reducer2;
7481 }));
7482 if (caseReducers.filter(function (cr) { return !!cr; }).length === 0) {
7483 caseReducers = [finalDefaultCaseReducer];
7484 }
7485 return caseReducers.reduce(function (previousState, caseReducer) {
7486 if (caseReducer) {
7487 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(previousState)) {
7488 var draft = previousState;
7489 var result = caseReducer(draft, action);
7490 if (result === void 0) {
7491 return previousState;
7492 }
7493 return result;
7494 }
7495 else if (!(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(previousState)) {
7496 var result = caseReducer(previousState, action);
7497 if (result === void 0) {
7498 if (previousState === null) {
7499 return previousState;
7500 }
7501 throw Error("A case reducer on a non-draftable value must not return undefined");
7502 }
7503 return result;
7504 }
7505 else {
7506 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(previousState, function (draft) {
7507 return caseReducer(draft, action);
7508 });
7509 }
7510 }
7511 return previousState;
7512 }, state);
7513 }
7514 reducer.getInitialState = getInitialState;
7515 return reducer;
7516 }
7517 // src/createSlice.ts
7518 var hasWarnedAboutObjectNotation2 = false;
7519 function getType2(slice, actionKey) {
7520 return slice + "/" + actionKey;
7521 }
7522 function createSlice(options) {
7523 var name = options.name;
7524 if (!name) {
7525 throw new Error("`name` is a required option for createSlice");
7526 }
7527 if (typeof process !== "undefined" && "development" === "development") {
7528 if (options.initialState === void 0) {
7529 console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
7530 }
7531 }
7532 var initialState = typeof options.initialState == "function" ? options.initialState : freezeDraftable(options.initialState);
7533 var reducers = options.reducers || {};
7534 var reducerNames = Object.keys(reducers);
7535 var sliceCaseReducersByName = {};
7536 var sliceCaseReducersByType = {};
7537 var actionCreators = {};
7538 reducerNames.forEach(function (reducerName) {
7539 var maybeReducerWithPrepare = reducers[reducerName];
7540 var type = getType2(name, reducerName);
7541 var caseReducer;
7542 var prepareCallback;
7543 if ("reducer" in maybeReducerWithPrepare) {
7544 caseReducer = maybeReducerWithPrepare.reducer;
7545 prepareCallback = maybeReducerWithPrepare.prepare;
7546 }
7547 else {
7548 caseReducer = maybeReducerWithPrepare;
7549 }
7550 sliceCaseReducersByName[reducerName] = caseReducer;
7551 sliceCaseReducersByType[type] = caseReducer;
7552 actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type);
7553 });
7554 function buildReducer() {
7555 if (true) {
7556 if (typeof options.extraReducers === "object") {
7557 if (!hasWarnedAboutObjectNotation2) {
7558 hasWarnedAboutObjectNotation2 = true;
7559 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");
7560 }
7561 }
7562 }
7563 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;
7564 var finalCaseReducers = __spreadValues(__spreadValues({}, extraReducers), sliceCaseReducersByType);
7565 return createReducer(initialState, function (builder) {
7566 for (var key in finalCaseReducers) {
7567 builder.addCase(key, finalCaseReducers[key]);
7568 }
7569 for (var _i = 0, actionMatchers_1 = actionMatchers; _i < actionMatchers_1.length; _i++) {
7570 var m = actionMatchers_1[_i];
7571 builder.addMatcher(m.matcher, m.reducer);
7572 }
7573 if (defaultCaseReducer) {
7574 builder.addDefaultCase(defaultCaseReducer);
7575 }
7576 });
7577 }
7578 var _reducer;
7579 return {
7580 name: name,
7581 reducer: function (state, action) {
7582 if (!_reducer)
7583 _reducer = buildReducer();
7584 return _reducer(state, action);
7585 },
7586 actions: actionCreators,
7587 caseReducers: sliceCaseReducersByName,
7588 getInitialState: function () {
7589 if (!_reducer)
7590 _reducer = buildReducer();
7591 return _reducer.getInitialState();
7592 }
7593 };
7594 }
7595 // src/entities/entity_state.ts
7596 function getInitialEntityState() {
7597 return {
7598 ids: [],
7599 entities: {}
7600 };
7601 }
7602 function createInitialStateFactory() {
7603 function getInitialState(additionalState) {
7604 if (additionalState === void 0) { additionalState = {}; }
7605 return Object.assign(getInitialEntityState(), additionalState);
7606 }
7607 return { getInitialState: getInitialState };
7608 }
7609 // src/entities/state_selectors.ts
7610 function createSelectorsFactory() {
7611 function getSelectors(selectState) {
7612 var selectIds = function (state) { return state.ids; };
7613 var selectEntities = function (state) { return state.entities; };
7614 var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) { return ids.map(function (id) { return entities[id]; }); });
7615 var selectId = function (_, id) { return id; };
7616 var selectById = function (entities, id) { return entities[id]; };
7617 var selectTotal = createDraftSafeSelector(selectIds, function (ids) { return ids.length; });
7618 if (!selectState) {
7619 return {
7620 selectIds: selectIds,
7621 selectEntities: selectEntities,
7622 selectAll: selectAll,
7623 selectTotal: selectTotal,
7624 selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
7625 };
7626 }
7627 var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
7628 return {
7629 selectIds: createDraftSafeSelector(selectState, selectIds),
7630 selectEntities: selectGlobalizedEntities,
7631 selectAll: createDraftSafeSelector(selectState, selectAll),
7632 selectTotal: createDraftSafeSelector(selectState, selectTotal),
7633 selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
7634 };
7635 }
7636 return { getSelectors: getSelectors };
7637 }
7638 // src/entities/state_adapter.ts
7639
7640 function createSingleArgumentStateOperator(mutator) {
7641 var operator = createStateOperator(function (_, state) { return mutator(state); });
7642 return function operation(state) {
7643 return operator(state, void 0);
7644 };
7645 }
7646 function createStateOperator(mutator) {
7647 return function operation(state, arg) {
7648 function isPayloadActionArgument(arg2) {
7649 return isFSA(arg2);
7650 }
7651 var runMutator = function (draft) {
7652 if (isPayloadActionArgument(arg)) {
7653 mutator(arg.payload, draft);
7654 }
7655 else {
7656 mutator(arg, draft);
7657 }
7658 };
7659 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(state)) {
7660 runMutator(state);
7661 return state;
7662 }
7663 else {
7664 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(state, runMutator);
7665 }
7666 };
7667 }
7668 // src/entities/utils.ts
7669 function selectIdValue(entity, selectId) {
7670 var key = selectId(entity);
7671 if ( true && key === void 0) {
7672 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());
7673 }
7674 return key;
7675 }
7676 function ensureEntitiesArray(entities) {
7677 if (!Array.isArray(entities)) {
7678 entities = Object.values(entities);
7679 }
7680 return entities;
7681 }
7682 function splitAddedUpdatedEntities(newEntities, selectId, state) {
7683 newEntities = ensureEntitiesArray(newEntities);
7684 var added = [];
7685 var updated = [];
7686 for (var _i = 0, newEntities_1 = newEntities; _i < newEntities_1.length; _i++) {
7687 var entity = newEntities_1[_i];
7688 var id = selectIdValue(entity, selectId);
7689 if (id in state.entities) {
7690 updated.push({ id: id, changes: entity });
7691 }
7692 else {
7693 added.push(entity);
7694 }
7695 }
7696 return [added, updated];
7697 }
7698 // src/entities/unsorted_state_adapter.ts
7699 function createUnsortedStateAdapter(selectId) {
7700 function addOneMutably(entity, state) {
7701 var key = selectIdValue(entity, selectId);
7702 if (key in state.entities) {
7703 return;
7704 }
7705 state.ids.push(key);
7706 state.entities[key] = entity;
7707 }
7708 function addManyMutably(newEntities, state) {
7709 newEntities = ensureEntitiesArray(newEntities);
7710 for (var _i = 0, newEntities_2 = newEntities; _i < newEntities_2.length; _i++) {
7711 var entity = newEntities_2[_i];
7712 addOneMutably(entity, state);
7713 }
7714 }
7715 function setOneMutably(entity, state) {
7716 var key = selectIdValue(entity, selectId);
7717 if (!(key in state.entities)) {
7718 state.ids.push(key);
7719 }
7720 state.entities[key] = entity;
7721 }
7722 function setManyMutably(newEntities, state) {
7723 newEntities = ensureEntitiesArray(newEntities);
7724 for (var _i = 0, newEntities_3 = newEntities; _i < newEntities_3.length; _i++) {
7725 var entity = newEntities_3[_i];
7726 setOneMutably(entity, state);
7727 }
7728 }
7729 function setAllMutably(newEntities, state) {
7730 newEntities = ensureEntitiesArray(newEntities);
7731 state.ids = [];
7732 state.entities = {};
7733 addManyMutably(newEntities, state);
7734 }
7735 function removeOneMutably(key, state) {
7736 return removeManyMutably([key], state);
7737 }
7738 function removeManyMutably(keys, state) {
7739 var didMutate = false;
7740 keys.forEach(function (key) {
7741 if (key in state.entities) {
7742 delete state.entities[key];
7743 didMutate = true;
7744 }
7745 });
7746 if (didMutate) {
7747 state.ids = state.ids.filter(function (id) { return id in state.entities; });
7748 }
7749 }
7750 function removeAllMutably(state) {
7751 Object.assign(state, {
7752 ids: [],
7753 entities: {}
7754 });
7755 }
7756 function takeNewKey(keys, update, state) {
7757 var original2 = state.entities[update.id];
7758 var updated = Object.assign({}, original2, update.changes);
7759 var newKey = selectIdValue(updated, selectId);
7760 var hasNewKey = newKey !== update.id;
7761 if (hasNewKey) {
7762 keys[update.id] = newKey;
7763 delete state.entities[update.id];
7764 }
7765 state.entities[newKey] = updated;
7766 return hasNewKey;
7767 }
7768 function updateOneMutably(update, state) {
7769 return updateManyMutably([update], state);
7770 }
7771 function updateManyMutably(updates, state) {
7772 var newKeys = {};
7773 var updatesPerEntity = {};
7774 updates.forEach(function (update) {
7775 if (update.id in state.entities) {
7776 updatesPerEntity[update.id] = {
7777 id: update.id,
7778 changes: __spreadValues(__spreadValues({}, updatesPerEntity[update.id] ? updatesPerEntity[update.id].changes : null), update.changes)
7779 };
7780 }
7781 });
7782 updates = Object.values(updatesPerEntity);
7783 var didMutateEntities = updates.length > 0;
7784 if (didMutateEntities) {
7785 var didMutateIds = updates.filter(function (update) { return takeNewKey(newKeys, update, state); }).length > 0;
7786 if (didMutateIds) {
7787 state.ids = Object.keys(state.entities);
7788 }
7789 }
7790 }
7791 function upsertOneMutably(entity, state) {
7792 return upsertManyMutably([entity], state);
7793 }
7794 function upsertManyMutably(newEntities, state) {
7795 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7796 updateManyMutably(updated, state);
7797 addManyMutably(added, state);
7798 }
7799 return {
7800 removeAll: createSingleArgumentStateOperator(removeAllMutably),
7801 addOne: createStateOperator(addOneMutably),
7802 addMany: createStateOperator(addManyMutably),
7803 setOne: createStateOperator(setOneMutably),
7804 setMany: createStateOperator(setManyMutably),
7805 setAll: createStateOperator(setAllMutably),
7806 updateOne: createStateOperator(updateOneMutably),
7807 updateMany: createStateOperator(updateManyMutably),
7808 upsertOne: createStateOperator(upsertOneMutably),
7809 upsertMany: createStateOperator(upsertManyMutably),
7810 removeOne: createStateOperator(removeOneMutably),
7811 removeMany: createStateOperator(removeManyMutably)
7812 };
7813 }
7814 // src/entities/sorted_state_adapter.ts
7815 function createSortedStateAdapter(selectId, sort) {
7816 var _c = createUnsortedStateAdapter(selectId), removeOne = _c.removeOne, removeMany = _c.removeMany, removeAll = _c.removeAll;
7817 function addOneMutably(entity, state) {
7818 return addManyMutably([entity], state);
7819 }
7820 function addManyMutably(newEntities, state) {
7821 newEntities = ensureEntitiesArray(newEntities);
7822 var models = newEntities.filter(function (model) { return !(selectIdValue(model, selectId) in state.entities); });
7823 if (models.length !== 0) {
7824 merge(models, state);
7825 }
7826 }
7827 function setOneMutably(entity, state) {
7828 return setManyMutably([entity], state);
7829 }
7830 function setManyMutably(newEntities, state) {
7831 newEntities = ensureEntitiesArray(newEntities);
7832 if (newEntities.length !== 0) {
7833 merge(newEntities, state);
7834 }
7835 }
7836 function setAllMutably(newEntities, state) {
7837 newEntities = ensureEntitiesArray(newEntities);
7838 state.entities = {};
7839 state.ids = [];
7840 addManyMutably(newEntities, state);
7841 }
7842 function updateOneMutably(update, state) {
7843 return updateManyMutably([update], state);
7844 }
7845 function updateManyMutably(updates, state) {
7846 var appliedUpdates = false;
7847 for (var _i = 0, updates_1 = updates; _i < updates_1.length; _i++) {
7848 var update = updates_1[_i];
7849 var entity = state.entities[update.id];
7850 if (!entity) {
7851 continue;
7852 }
7853 appliedUpdates = true;
7854 Object.assign(entity, update.changes);
7855 var newId = selectId(entity);
7856 if (update.id !== newId) {
7857 delete state.entities[update.id];
7858 state.entities[newId] = entity;
7859 }
7860 }
7861 if (appliedUpdates) {
7862 resortEntities(state);
7863 }
7864 }
7865 function upsertOneMutably(entity, state) {
7866 return upsertManyMutably([entity], state);
7867 }
7868 function upsertManyMutably(newEntities, state) {
7869 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7870 updateManyMutably(updated, state);
7871 addManyMutably(added, state);
7872 }
7873 function areArraysEqual(a, b) {
7874 if (a.length !== b.length) {
7875 return false;
7876 }
7877 for (var i = 0; i < a.length && i < b.length; i++) {
7878 if (a[i] === b[i]) {
7879 continue;
7880 }
7881 return false;
7882 }
7883 return true;
7884 }
7885 function merge(models, state) {
7886 models.forEach(function (model) {
7887 state.entities[selectId(model)] = model;
7888 });
7889 resortEntities(state);
7890 }
7891 function resortEntities(state) {
7892 var allEntities = Object.values(state.entities);
7893 allEntities.sort(sort);
7894 var newSortedIds = allEntities.map(selectId);
7895 var ids = state.ids;
7896 if (!areArraysEqual(ids, newSortedIds)) {
7897 state.ids = newSortedIds;
7898 }
7899 }
7900 return {
7901 removeOne: removeOne,
7902 removeMany: removeMany,
7903 removeAll: removeAll,
7904 addOne: createStateOperator(addOneMutably),
7905 updateOne: createStateOperator(updateOneMutably),
7906 upsertOne: createStateOperator(upsertOneMutably),
7907 setOne: createStateOperator(setOneMutably),
7908 setMany: createStateOperator(setManyMutably),
7909 setAll: createStateOperator(setAllMutably),
7910 addMany: createStateOperator(addManyMutably),
7911 updateMany: createStateOperator(updateManyMutably),
7912 upsertMany: createStateOperator(upsertManyMutably)
7913 };
7914 }
7915 // src/entities/create_adapter.ts
7916 function createEntityAdapter(options) {
7917 if (options === void 0) { options = {}; }
7918 var _c = __spreadValues({
7919 sortComparer: false,
7920 selectId: function (instance) { return instance.id; }
7921 }, options), selectId = _c.selectId, sortComparer = _c.sortComparer;
7922 var stateFactory = createInitialStateFactory();
7923 var selectorsFactory = createSelectorsFactory();
7924 var stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
7925 return __spreadValues(__spreadValues(__spreadValues({
7926 selectId: selectId,
7927 sortComparer: sortComparer
7928 }, stateFactory), selectorsFactory), stateAdapter);
7929 }
7930 // src/nanoid.ts
7931 var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
7932 var nanoid = function (size) {
7933 if (size === void 0) { size = 21; }
7934 var id = "";
7935 var i = size;
7936 while (i--) {
7937 id += urlAlphabet[Math.random() * 64 | 0];
7938 }
7939 return id;
7940 };
7941 // src/createAsyncThunk.ts
7942 var commonProperties = [
7943 "name",
7944 "message",
7945 "stack",
7946 "code"
7947 ];
7948 var RejectWithValue = /** @class */ (function () {
7949 function RejectWithValue(payload, meta) {
7950 this.payload = payload;
7951 this.meta = meta;
7952 }
7953 return RejectWithValue;
7954 }());
7955 var FulfillWithMeta = /** @class */ (function () {
7956 function FulfillWithMeta(payload, meta) {
7957 this.payload = payload;
7958 this.meta = meta;
7959 }
7960 return FulfillWithMeta;
7961 }());
7962 var miniSerializeError = function (value) {
7963 if (typeof value === "object" && value !== null) {
7964 var simpleError = {};
7965 for (var _i = 0, commonProperties_1 = commonProperties; _i < commonProperties_1.length; _i++) {
7966 var property = commonProperties_1[_i];
7967 if (typeof value[property] === "string") {
7968 simpleError[property] = value[property];
7969 }
7970 }
7971 return simpleError;
7972 }
7973 return { message: String(value) };
7974 };
7975 var createAsyncThunk = (function () {
7976 function createAsyncThunk2(typePrefix, payloadCreator, options) {
7977 var fulfilled = createAction(typePrefix + "/fulfilled", function (payload, requestId, arg, meta) { return ({
7978 payload: payload,
7979 meta: __spreadProps(__spreadValues({}, meta || {}), {
7980 arg: arg,
7981 requestId: requestId,
7982 requestStatus: "fulfilled"
7983 })
7984 }); });
7985 var pending = createAction(typePrefix + "/pending", function (requestId, arg, meta) { return ({
7986 payload: void 0,
7987 meta: __spreadProps(__spreadValues({}, meta || {}), {
7988 arg: arg,
7989 requestId: requestId,
7990 requestStatus: "pending"
7991 })
7992 }); });
7993 var rejected = createAction(typePrefix + "/rejected", function (error, requestId, arg, payload, meta) { return ({
7994 payload: payload,
7995 error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
7996 meta: __spreadProps(__spreadValues({}, meta || {}), {
7997 arg: arg,
7998 requestId: requestId,
7999 rejectedWithValue: !!payload,
8000 requestStatus: "rejected",
8001 aborted: (error == null ? void 0 : error.name) === "AbortError",
8002 condition: (error == null ? void 0 : error.name) === "ConditionError"
8003 })
8004 }); });
8005 var displayedWarning = false;
8006 var AC = typeof AbortController !== "undefined" ? AbortController : /** @class */ (function () {
8007 function class_1() {
8008 this.signal = {
8009 aborted: false,
8010 addEventListener: function () {
8011 },
8012 dispatchEvent: function () {
8013 return false;
8014 },
8015 onabort: function () {
8016 },
8017 removeEventListener: function () {
8018 },
8019 reason: void 0,
8020 throwIfAborted: function () {
8021 }
8022 };
8023 }
8024 class_1.prototype.abort = function () {
8025 if (true) {
8026 if (!displayedWarning) {
8027 displayedWarning = true;
8028 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'.");
8029 }
8030 }
8031 };
8032 return class_1;
8033 }());
8034 function actionCreator(arg) {
8035 return function (dispatch, getState, extra) {
8036 var requestId = (options == null ? void 0 : options.idGenerator) ? options.idGenerator(arg) : nanoid();
8037 var abortController = new AC();
8038 var abortReason;
8039 var started = false;
8040 function abort(reason) {
8041 abortReason = reason;
8042 abortController.abort();
8043 }
8044 var promise2 = function () {
8045 return __async(this, null, function () {
8046 var _a, _b, finalAction, conditionResult, abortedPromise, err_1, skipDispatch;
8047 return __generator(this, function (_c) {
8048 switch (_c.label) {
8049 case 0:
8050 _c.trys.push([0, 4, , 5]);
8051 conditionResult = (_a = options == null ? void 0 : options.condition) == null ? void 0 : _a.call(options, arg, { getState: getState, extra: extra });
8052 if (!isThenable(conditionResult)) return [3 /*break*/, 2];
8053 return [4 /*yield*/, conditionResult];
8054 case 1:
8055 conditionResult = _c.sent();
8056 _c.label = 2;
8057 case 2:
8058 if (conditionResult === false || abortController.signal.aborted) {
8059 throw {
8060 name: "ConditionError",
8061 message: "Aborted due to condition callback returning false."
8062 };
8063 }
8064 started = true;
8065 abortedPromise = new Promise(function (_, reject) { return abortController.signal.addEventListener("abort", function () { return reject({
8066 name: "AbortError",
8067 message: abortReason || "Aborted"
8068 }); }); });
8069 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 })));
8070 return [4 /*yield*/, Promise.race([
8071 abortedPromise,
8072 Promise.resolve(payloadCreator(arg, {
8073 dispatch: dispatch,
8074 getState: getState,
8075 extra: extra,
8076 requestId: requestId,
8077 signal: abortController.signal,
8078 abort: abort,
8079 rejectWithValue: function (value, meta) {
8080 return new RejectWithValue(value, meta);
8081 },
8082 fulfillWithValue: function (value, meta) {
8083 return new FulfillWithMeta(value, meta);
8084 }
8085 })).then(function (result) {
8086 if (result instanceof RejectWithValue) {
8087 throw result;
8088 }
8089 if (result instanceof FulfillWithMeta) {
8090 return fulfilled(result.payload, requestId, arg, result.meta);
8091 }
8092 return fulfilled(result, requestId, arg);
8093 })
8094 ])];
8095 case 3:
8096 finalAction = _c.sent();
8097 return [3 /*break*/, 5];
8098 case 4:
8099 err_1 = _c.sent();
8100 finalAction = err_1 instanceof RejectWithValue ? rejected(null, requestId, arg, err_1.payload, err_1.meta) : rejected(err_1, requestId, arg);
8101 return [3 /*break*/, 5];
8102 case 5:
8103 skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
8104 if (!skipDispatch) {
8105 dispatch(finalAction);
8106 }
8107 return [2 /*return*/, finalAction];
8108 }
8109 });
8110 });
8111 }();
8112 return Object.assign(promise2, {
8113 abort: abort,
8114 requestId: requestId,
8115 arg: arg,
8116 unwrap: function () {
8117 return promise2.then(unwrapResult);
8118 }
8119 });
8120 };
8121 }
8122 return Object.assign(actionCreator, {
8123 pending: pending,
8124 rejected: rejected,
8125 fulfilled: fulfilled,
8126 typePrefix: typePrefix
8127 });
8128 }
8129 createAsyncThunk2.withTypes = function () { return createAsyncThunk2; };
8130 return createAsyncThunk2;
8131 })();
8132 function unwrapResult(action) {
8133 if (action.meta && action.meta.rejectedWithValue) {
8134 throw action.payload;
8135 }
8136 if (action.error) {
8137 throw action.error;
8138 }
8139 return action.payload;
8140 }
8141 function isThenable(value) {
8142 return value !== null && typeof value === "object" && typeof value.then === "function";
8143 }
8144 // src/matchers.ts
8145 var matches = function (matcher, action) {
8146 if (hasMatchFunction(matcher)) {
8147 return matcher.match(action);
8148 }
8149 else {
8150 return matcher(action);
8151 }
8152 };
8153 function isAnyOf() {
8154 var matchers = [];
8155 for (var _i = 0; _i < arguments.length; _i++) {
8156 matchers[_i] = arguments[_i];
8157 }
8158 return function (action) {
8159 return matchers.some(function (matcher) { return matches(matcher, action); });
8160 };
8161 }
8162 function isAllOf() {
8163 var matchers = [];
8164 for (var _i = 0; _i < arguments.length; _i++) {
8165 matchers[_i] = arguments[_i];
8166 }
8167 return function (action) {
8168 return matchers.every(function (matcher) { return matches(matcher, action); });
8169 };
8170 }
8171 function hasExpectedRequestMetadata(action, validStatus) {
8172 if (!action || !action.meta)
8173 return false;
8174 var hasValidRequestId = typeof action.meta.requestId === "string";
8175 var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
8176 return hasValidRequestId && hasValidRequestStatus;
8177 }
8178 function isAsyncThunkArray(a) {
8179 return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
8180 }
8181 function isPending() {
8182 var asyncThunks = [];
8183 for (var _i = 0; _i < arguments.length; _i++) {
8184 asyncThunks[_i] = arguments[_i];
8185 }
8186 if (asyncThunks.length === 0) {
8187 return function (action) { return hasExpectedRequestMetadata(action, ["pending"]); };
8188 }
8189 if (!isAsyncThunkArray(asyncThunks)) {
8190 return isPending()(asyncThunks[0]);
8191 }
8192 return function (action) {
8193 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.pending; });
8194 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8195 return combinedMatcher(action);
8196 };
8197 }
8198 function isRejected() {
8199 var asyncThunks = [];
8200 for (var _i = 0; _i < arguments.length; _i++) {
8201 asyncThunks[_i] = arguments[_i];
8202 }
8203 if (asyncThunks.length === 0) {
8204 return function (action) { return hasExpectedRequestMetadata(action, ["rejected"]); };
8205 }
8206 if (!isAsyncThunkArray(asyncThunks)) {
8207 return isRejected()(asyncThunks[0]);
8208 }
8209 return function (action) {
8210 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.rejected; });
8211 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8212 return combinedMatcher(action);
8213 };
8214 }
8215 function isRejectedWithValue() {
8216 var asyncThunks = [];
8217 for (var _i = 0; _i < arguments.length; _i++) {
8218 asyncThunks[_i] = arguments[_i];
8219 }
8220 var hasFlag = function (action) {
8221 return action && action.meta && action.meta.rejectedWithValue;
8222 };
8223 if (asyncThunks.length === 0) {
8224 return function (action) {
8225 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
8226 return combinedMatcher(action);
8227 };
8228 }
8229 if (!isAsyncThunkArray(asyncThunks)) {
8230 return isRejectedWithValue()(asyncThunks[0]);
8231 }
8232 return function (action) {
8233 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
8234 return combinedMatcher(action);
8235 };
8236 }
8237 function isFulfilled() {
8238 var asyncThunks = [];
8239 for (var _i = 0; _i < arguments.length; _i++) {
8240 asyncThunks[_i] = arguments[_i];
8241 }
8242 if (asyncThunks.length === 0) {
8243 return function (action) { return hasExpectedRequestMetadata(action, ["fulfilled"]); };
8244 }
8245 if (!isAsyncThunkArray(asyncThunks)) {
8246 return isFulfilled()(asyncThunks[0]);
8247 }
8248 return function (action) {
8249 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.fulfilled; });
8250 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8251 return combinedMatcher(action);
8252 };
8253 }
8254 function isAsyncThunkAction() {
8255 var asyncThunks = [];
8256 for (var _i = 0; _i < arguments.length; _i++) {
8257 asyncThunks[_i] = arguments[_i];
8258 }
8259 if (asyncThunks.length === 0) {
8260 return function (action) { return hasExpectedRequestMetadata(action, ["pending", "fulfilled", "rejected"]); };
8261 }
8262 if (!isAsyncThunkArray(asyncThunks)) {
8263 return isAsyncThunkAction()(asyncThunks[0]);
8264 }
8265 return function (action) {
8266 var matchers = [];
8267 for (var _i = 0, asyncThunks_1 = asyncThunks; _i < asyncThunks_1.length; _i++) {
8268 var asyncThunk = asyncThunks_1[_i];
8269 matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
8270 }
8271 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8272 return combinedMatcher(action);
8273 };
8274 }
8275 // src/listenerMiddleware/utils.ts
8276 var assertFunction = function (func, expected) {
8277 if (typeof func !== "function") {
8278 throw new TypeError(expected + " is not a function");
8279 }
8280 };
8281 var noop = function () {
8282 };
8283 var catchRejection = function (promise2, onError) {
8284 if (onError === void 0) { onError = noop; }
8285 promise2.catch(onError);
8286 return promise2;
8287 };
8288 var addAbortSignalListener = function (abortSignal, callback) {
8289 abortSignal.addEventListener("abort", callback, { once: true });
8290 return function () { return abortSignal.removeEventListener("abort", callback); };
8291 };
8292 var abortControllerWithReason = function (abortController, reason) {
8293 var signal = abortController.signal;
8294 if (signal.aborted) {
8295 return;
8296 }
8297 if (!("reason" in signal)) {
8298 Object.defineProperty(signal, "reason", {
8299 enumerable: true,
8300 value: reason,
8301 configurable: true,
8302 writable: true
8303 });
8304 }
8305 ;
8306 abortController.abort(reason);
8307 };
8308 // src/listenerMiddleware/exceptions.ts
8309 var task = "task";
8310 var listener = "listener";
8311 var completed = "completed";
8312 var cancelled = "cancelled";
8313 var taskCancelled = "task-" + cancelled;
8314 var taskCompleted = "task-" + completed;
8315 var listenerCancelled = listener + "-" + cancelled;
8316 var listenerCompleted = listener + "-" + completed;
8317 var TaskAbortError = /** @class */ (function () {
8318 function TaskAbortError(code) {
8319 this.code = code;
8320 this.name = "TaskAbortError";
8321 this.message = task + " " + cancelled + " (reason: " + code + ")";
8322 }
8323 return TaskAbortError;
8324 }());
8325 // src/listenerMiddleware/task.ts
8326 var validateActive = function (signal) {
8327 if (signal.aborted) {
8328 throw new TaskAbortError(signal.reason);
8329 }
8330 };
8331 function raceWithSignal(signal, promise2) {
8332 var cleanup = noop;
8333 return new Promise(function (resolve, reject) {
8334 var notifyRejection = function () { return reject(new TaskAbortError(signal.reason)); };
8335 if (signal.aborted) {
8336 notifyRejection();
8337 return;
8338 }
8339 cleanup = addAbortSignalListener(signal, notifyRejection);
8340 promise2.finally(function () { return cleanup(); }).then(resolve, reject);
8341 }).finally(function () {
8342 cleanup = noop;
8343 });
8344 }
8345 var runTask = function (task2, cleanUp) { return __async(void 0, null, function () {
8346 var value, error_1;
8347 return __generator(this, function (_c) {
8348 switch (_c.label) {
8349 case 0:
8350 _c.trys.push([0, 3, 4, 5]);
8351 return [4 /*yield*/, Promise.resolve()];
8352 case 1:
8353 _c.sent();
8354 return [4 /*yield*/, task2()];
8355 case 2:
8356 value = _c.sent();
8357 return [2 /*return*/, {
8358 status: "ok",
8359 value: value
8360 }];
8361 case 3:
8362 error_1 = _c.sent();
8363 return [2 /*return*/, {
8364 status: error_1 instanceof TaskAbortError ? "cancelled" : "rejected",
8365 error: error_1
8366 }];
8367 case 4:
8368 cleanUp == null ? void 0 : cleanUp();
8369 return [7 /*endfinally*/];
8370 case 5: return [2 /*return*/];
8371 }
8372 });
8373 }); };
8374 var createPause = function (signal) {
8375 return function (promise2) {
8376 return catchRejection(raceWithSignal(signal, promise2).then(function (output) {
8377 validateActive(signal);
8378 return output;
8379 }));
8380 };
8381 };
8382 var createDelay = function (signal) {
8383 var pause = createPause(signal);
8384 return function (timeoutMs) {
8385 return pause(new Promise(function (resolve) { return setTimeout(resolve, timeoutMs); }));
8386 };
8387 };
8388 // src/listenerMiddleware/index.ts
8389 var assign = Object.assign;
8390 var INTERNAL_NIL_TOKEN = {};
8391 var alm = "listenerMiddleware";
8392 var createFork = function (parentAbortSignal, parentBlockingPromises) {
8393 var linkControllers = function (controller) { return addAbortSignalListener(parentAbortSignal, function () { return abortControllerWithReason(controller, parentAbortSignal.reason); }); };
8394 return function (taskExecutor, opts) {
8395 assertFunction(taskExecutor, "taskExecutor");
8396 var childAbortController = new AbortController();
8397 linkControllers(childAbortController);
8398 var result = runTask(function () { return __async(void 0, null, function () {
8399 var result2;
8400 return __generator(this, function (_c) {
8401 switch (_c.label) {
8402 case 0:
8403 validateActive(parentAbortSignal);
8404 validateActive(childAbortController.signal);
8405 return [4 /*yield*/, taskExecutor({
8406 pause: createPause(childAbortController.signal),
8407 delay: createDelay(childAbortController.signal),
8408 signal: childAbortController.signal
8409 })];
8410 case 1:
8411 result2 = _c.sent();
8412 validateActive(childAbortController.signal);
8413 return [2 /*return*/, result2];
8414 }
8415 });
8416 }); }, function () { return abortControllerWithReason(childAbortController, taskCompleted); });
8417 if (opts == null ? void 0 : opts.autoJoin) {
8418 parentBlockingPromises.push(result);
8419 }
8420 return {
8421 result: createPause(parentAbortSignal)(result),
8422 cancel: function () {
8423 abortControllerWithReason(childAbortController, taskCancelled);
8424 }
8425 };
8426 };
8427 };
8428 var createTakePattern = function (startListening, signal) {
8429 var take = function (predicate, timeout) { return __async(void 0, null, function () {
8430 var unsubscribe, tuplePromise, promises, output;
8431 return __generator(this, function (_c) {
8432 switch (_c.label) {
8433 case 0:
8434 validateActive(signal);
8435 unsubscribe = function () {
8436 };
8437 tuplePromise = new Promise(function (resolve, reject) {
8438 var stopListening = startListening({
8439 predicate: predicate,
8440 effect: function (action, listenerApi) {
8441 listenerApi.unsubscribe();
8442 resolve([
8443 action,
8444 listenerApi.getState(),
8445 listenerApi.getOriginalState()
8446 ]);
8447 }
8448 });
8449 unsubscribe = function () {
8450 stopListening();
8451 reject();
8452 };
8453 });
8454 promises = [
8455 tuplePromise
8456 ];
8457 if (timeout != null) {
8458 promises.push(new Promise(function (resolve) { return setTimeout(resolve, timeout, null); }));
8459 }
8460 _c.label = 1;
8461 case 1:
8462 _c.trys.push([1, , 3, 4]);
8463 return [4 /*yield*/, raceWithSignal(signal, Promise.race(promises))];
8464 case 2:
8465 output = _c.sent();
8466 validateActive(signal);
8467 return [2 /*return*/, output];
8468 case 3:
8469 unsubscribe();
8470 return [7 /*endfinally*/];
8471 case 4: return [2 /*return*/];
8472 }
8473 });
8474 }); };
8475 return function (predicate, timeout) { return catchRejection(take(predicate, timeout)); };
8476 };
8477 var getListenerEntryPropsFrom = function (options) {
8478 var type = options.type, actionCreator = options.actionCreator, matcher = options.matcher, predicate = options.predicate, effect = options.effect;
8479 if (type) {
8480 predicate = createAction(type).match;
8481 }
8482 else if (actionCreator) {
8483 type = actionCreator.type;
8484 predicate = actionCreator.match;
8485 }
8486 else if (matcher) {
8487 predicate = matcher;
8488 }
8489 else if (predicate) {
8490 }
8491 else {
8492 throw new Error("Creating or removing a listener requires one of the known fields for matching an action");
8493 }
8494 assertFunction(effect, "options.listener");
8495 return { predicate: predicate, type: type, effect: effect };
8496 };
8497 var createListenerEntry = function (options) {
8498 var _c = getListenerEntryPropsFrom(options), type = _c.type, predicate = _c.predicate, effect = _c.effect;
8499 var id = nanoid();
8500 var entry = {
8501 id: id,
8502 effect: effect,
8503 type: type,
8504 predicate: predicate,
8505 pending: new Set(),
8506 unsubscribe: function () {
8507 throw new Error("Unsubscribe not initialized");
8508 }
8509 };
8510 return entry;
8511 };
8512 var cancelActiveListeners = function (entry) {
8513 entry.pending.forEach(function (controller) {
8514 abortControllerWithReason(controller, listenerCancelled);
8515 });
8516 };
8517 var createClearListenerMiddleware = function (listenerMap) {
8518 return function () {
8519 listenerMap.forEach(cancelActiveListeners);
8520 listenerMap.clear();
8521 };
8522 };
8523 var safelyNotifyError = function (errorHandler, errorToNotify, errorInfo) {
8524 try {
8525 errorHandler(errorToNotify, errorInfo);
8526 }
8527 catch (errorHandlerError) {
8528 setTimeout(function () {
8529 throw errorHandlerError;
8530 }, 0);
8531 }
8532 };
8533 var addListener = createAction(alm + "/add");
8534 var clearAllListeners = createAction(alm + "/removeAll");
8535 var removeListener = createAction(alm + "/remove");
8536 var defaultErrorHandler = function () {
8537 var args = [];
8538 for (var _i = 0; _i < arguments.length; _i++) {
8539 args[_i] = arguments[_i];
8540 }
8541 console.error.apply(console, __spreadArray([alm + "/error"], args));
8542 };
8543 function createListenerMiddleware(middlewareOptions) {
8544 var _this = this;
8545 if (middlewareOptions === void 0) { middlewareOptions = {}; }
8546 var listenerMap = new Map();
8547 var extra = middlewareOptions.extra, _c = middlewareOptions.onError, onError = _c === void 0 ? defaultErrorHandler : _c;
8548 assertFunction(onError, "onError");
8549 var insertEntry = function (entry) {
8550 entry.unsubscribe = function () { return listenerMap.delete(entry.id); };
8551 listenerMap.set(entry.id, entry);
8552 return function (cancelOptions) {
8553 entry.unsubscribe();
8554 if (cancelOptions == null ? void 0 : cancelOptions.cancelActive) {
8555 cancelActiveListeners(entry);
8556 }
8557 };
8558 };
8559 var findListenerEntry = function (comparator) {
8560 for (var _i = 0, _c = Array.from(listenerMap.values()); _i < _c.length; _i++) {
8561 var entry = _c[_i];
8562 if (comparator(entry)) {
8563 return entry;
8564 }
8565 }
8566 return void 0;
8567 };
8568 var startListening = function (options) {
8569 var entry = findListenerEntry(function (existingEntry) { return existingEntry.effect === options.effect; });
8570 if (!entry) {
8571 entry = createListenerEntry(options);
8572 }
8573 return insertEntry(entry);
8574 };
8575 var stopListening = function (options) {
8576 var _c = getListenerEntryPropsFrom(options), type = _c.type, effect = _c.effect, predicate = _c.predicate;
8577 var entry = findListenerEntry(function (entry2) {
8578 var matchPredicateOrType = typeof type === "string" ? entry2.type === type : entry2.predicate === predicate;
8579 return matchPredicateOrType && entry2.effect === effect;
8580 });
8581 if (entry) {
8582 entry.unsubscribe();
8583 if (options.cancelActive) {
8584 cancelActiveListeners(entry);
8585 }
8586 }
8587 return !!entry;
8588 };
8589 var notifyListener = function (entry, action, api, getOriginalState) { return __async(_this, null, function () {
8590 var internalTaskController, take, autoJoinPromises, listenerError_1;
8591 return __generator(this, function (_c) {
8592 switch (_c.label) {
8593 case 0:
8594 internalTaskController = new AbortController();
8595 take = createTakePattern(startListening, internalTaskController.signal);
8596 autoJoinPromises = [];
8597 _c.label = 1;
8598 case 1:
8599 _c.trys.push([1, 3, 4, 6]);
8600 entry.pending.add(internalTaskController);
8601 return [4 /*yield*/, Promise.resolve(entry.effect(action, assign({}, api, {
8602 getOriginalState: getOriginalState,
8603 condition: function (predicate, timeout) { return take(predicate, timeout).then(Boolean); },
8604 take: take,
8605 delay: createDelay(internalTaskController.signal),
8606 pause: createPause(internalTaskController.signal),
8607 extra: extra,
8608 signal: internalTaskController.signal,
8609 fork: createFork(internalTaskController.signal, autoJoinPromises),
8610 unsubscribe: entry.unsubscribe,
8611 subscribe: function () {
8612 listenerMap.set(entry.id, entry);
8613 },
8614 cancelActiveListeners: function () {
8615 entry.pending.forEach(function (controller, _, set) {
8616 if (controller !== internalTaskController) {
8617 abortControllerWithReason(controller, listenerCancelled);
8618 set.delete(controller);
8619 }
8620 });
8621 }
8622 })))];
8623 case 2:
8624 _c.sent();
8625 return [3 /*break*/, 6];
8626 case 3:
8627 listenerError_1 = _c.sent();
8628 if (!(listenerError_1 instanceof TaskAbortError)) {
8629 safelyNotifyError(onError, listenerError_1, {
8630 raisedBy: "effect"
8631 });
8632 }
8633 return [3 /*break*/, 6];
8634 case 4: return [4 /*yield*/, Promise.allSettled(autoJoinPromises)];
8635 case 5:
8636 _c.sent();
8637 abortControllerWithReason(internalTaskController, listenerCompleted);
8638 entry.pending.delete(internalTaskController);
8639 return [7 /*endfinally*/];
8640 case 6: return [2 /*return*/];
8641 }
8642 });
8643 }); };
8644 var clearListenerMiddleware = createClearListenerMiddleware(listenerMap);
8645 var middleware = function (api) { return function (next) { return function (action) {
8646 if (!isAction(action)) {
8647 return next(action);
8648 }
8649 if (addListener.match(action)) {
8650 return startListening(action.payload);
8651 }
8652 if (clearAllListeners.match(action)) {
8653 clearListenerMiddleware();
8654 return;
8655 }
8656 if (removeListener.match(action)) {
8657 return stopListening(action.payload);
8658 }
8659 var originalState = api.getState();
8660 var getOriginalState = function () {
8661 if (originalState === INTERNAL_NIL_TOKEN) {
8662 throw new Error(alm + ": getOriginalState can only be called synchronously");
8663 }
8664 return originalState;
8665 };
8666 var result;
8667 try {
8668 result = next(action);
8669 if (listenerMap.size > 0) {
8670 var currentState = api.getState();
8671 var listenerEntries = Array.from(listenerMap.values());
8672 for (var _i = 0, listenerEntries_1 = listenerEntries; _i < listenerEntries_1.length; _i++) {
8673 var entry = listenerEntries_1[_i];
8674 var runListener = false;
8675 try {
8676 runListener = entry.predicate(action, currentState, originalState);
8677 }
8678 catch (predicateError) {
8679 runListener = false;
8680 safelyNotifyError(onError, predicateError, {
8681 raisedBy: "predicate"
8682 });
8683 }
8684 if (!runListener) {
8685 continue;
8686 }
8687 notifyListener(entry, action, api, getOriginalState);
8688 }
8689 }
8690 }
8691 finally {
8692 originalState = INTERNAL_NIL_TOKEN;
8693 }
8694 return result;
8695 }; }; };
8696 return {
8697 middleware: middleware,
8698 startListening: startListening,
8699 stopListening: stopListening,
8700 clearListeners: clearListenerMiddleware
8701 };
8702 }
8703 // src/autoBatchEnhancer.ts
8704 var SHOULD_AUTOBATCH = "RTK_autoBatch";
8705 var prepareAutoBatched = function () { return function (payload) {
8706 var _c;
8707 return ({
8708 payload: payload,
8709 meta: (_c = {}, _c[SHOULD_AUTOBATCH] = true, _c)
8710 });
8711 }; };
8712 var promise;
8713 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 () {
8714 throw err;
8715 }, 0); }); };
8716 var createQueueWithTimer = function (timeout) {
8717 return function (notify) {
8718 setTimeout(notify, timeout);
8719 };
8720 };
8721 var rAF = typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10);
8722 var autoBatchEnhancer = function (options) {
8723 if (options === void 0) { options = { type: "raf" }; }
8724 return function (next) { return function () {
8725 var args = [];
8726 for (var _i = 0; _i < arguments.length; _i++) {
8727 args[_i] = arguments[_i];
8728 }
8729 var store = next.apply(void 0, args);
8730 var notifying = true;
8731 var shouldNotifyAtEndOfTick = false;
8732 var notificationQueued = false;
8733 var listeners = new Set();
8734 var queueCallback = options.type === "tick" ? queueMicrotaskShim : options.type === "raf" ? rAF : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
8735 var notifyListeners = function () {
8736 notificationQueued = false;
8737 if (shouldNotifyAtEndOfTick) {
8738 shouldNotifyAtEndOfTick = false;
8739 listeners.forEach(function (l) { return l(); });
8740 }
8741 };
8742 return Object.assign({}, store, {
8743 subscribe: function (listener2) {
8744 var wrappedListener = function () { return notifying && listener2(); };
8745 var unsubscribe = store.subscribe(wrappedListener);
8746 listeners.add(listener2);
8747 return function () {
8748 unsubscribe();
8749 listeners.delete(listener2);
8750 };
8751 },
8752 dispatch: function (action) {
8753 var _a;
8754 try {
8755 notifying = !((_a = action == null ? void 0 : action.meta) == null ? void 0 : _a[SHOULD_AUTOBATCH]);
8756 shouldNotifyAtEndOfTick = !notifying;
8757 if (shouldNotifyAtEndOfTick) {
8758 if (!notificationQueued) {
8759 notificationQueued = true;
8760 queueCallback(notifyListeners);
8761 }
8762 }
8763 return store.dispatch(action);
8764 }
8765 finally {
8766 notifying = true;
8767 }
8768 }
8769 });
8770 }; };
8771 };
8772 // src/index.ts
8773 (0,immer__WEBPACK_IMPORTED_MODULE_0__.enableES5)();
8774
8775 //# sourceMappingURL=redux-toolkit.esm.js.map
8776
8777 /***/ }),
8778
8779 /***/ "../node_modules/immer/dist/immer.esm.mjs":
8780 /*!************************************************!*\
8781 !*** ../node_modules/immer/dist/immer.esm.mjs ***!
8782 \************************************************/
8783 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8784
8785 "use strict";
8786 __webpack_require__.r(__webpack_exports__);
8787 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8788 /* harmony export */ Immer: () => (/* binding */ un),
8789 /* harmony export */ applyPatches: () => (/* binding */ pn),
8790 /* harmony export */ castDraft: () => (/* binding */ K),
8791 /* harmony export */ castImmutable: () => (/* binding */ $),
8792 /* harmony export */ createDraft: () => (/* binding */ ln),
8793 /* harmony export */ current: () => (/* binding */ R),
8794 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
8795 /* harmony export */ enableAllPlugins: () => (/* binding */ J),
8796 /* harmony export */ enableES5: () => (/* binding */ F),
8797 /* harmony export */ enableMapSet: () => (/* binding */ C),
8798 /* harmony export */ enablePatches: () => (/* binding */ T),
8799 /* harmony export */ finishDraft: () => (/* binding */ dn),
8800 /* harmony export */ freeze: () => (/* binding */ d),
8801 /* harmony export */ immerable: () => (/* binding */ L),
8802 /* harmony export */ isDraft: () => (/* binding */ r),
8803 /* harmony export */ isDraftable: () => (/* binding */ t),
8804 /* harmony export */ nothing: () => (/* binding */ H),
8805 /* harmony export */ original: () => (/* binding */ e),
8806 /* harmony export */ produce: () => (/* binding */ fn),
8807 /* harmony export */ produceWithPatches: () => (/* binding */ cn),
8808 /* harmony export */ setAutoFreeze: () => (/* binding */ sn),
8809 /* harmony export */ setUseProxies: () => (/* binding */ vn)
8810 /* harmony export */ });
8811 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
8812 }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);
8813 //# sourceMappingURL=immer.esm.js.map
8814
8815
8816 /***/ }),
8817
8818 /***/ "../node_modules/mixpanel-browser/dist/mixpanel.module.js":
8819 /*!****************************************************************!*\
8820 !*** ../node_modules/mixpanel-browser/dist/mixpanel.module.js ***!
8821 \****************************************************************/
8822 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8823
8824 "use strict";
8825 __webpack_require__.r(__webpack_exports__);
8826 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8827 /* harmony export */ "default": () => (/* binding */ mixpanel)
8828 /* harmony export */ });
8829 // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
8830 var win;
8831 if (typeof(window) === 'undefined') {
8832 var loc = {
8833 hostname: ''
8834 };
8835 win = {
8836 crypto: {randomUUID: function() {throw Error('unsupported');}},
8837 navigator: { userAgent: '', onLine: true },
8838 document: {
8839 createElement: function() { return {}; },
8840 location: loc,
8841 referrer: ''
8842 },
8843 screen: { width: 0, height: 0 },
8844 location: loc,
8845 addEventListener: function() {},
8846 removeEventListener: function() {}
8847 };
8848 } else {
8849 win = window;
8850 }
8851
8852 function _array_like_to_array(arr, len) {
8853 if (len == null || len > arr.length) len = arr.length;
8854 for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8855 return arr2;
8856 }
8857 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8858 try {
8859 var info = gen[key](arg);
8860 var value = info.value;
8861 } catch (error) {
8862 reject(error);
8863 return;
8864 }
8865 if (info.done) {
8866 resolve(value);
8867 } else {
8868 Promise.resolve(value).then(_next, _throw);
8869 }
8870 }
8871 function _async_to_generator(fn) {
8872 return function() {
8873 var self = this, args = arguments;
8874 return new Promise(function(resolve, reject) {
8875 var gen = fn.apply(self, args);
8876 function _next(value) {
8877 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8878 }
8879 function _throw(err) {
8880 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8881 }
8882 _next(undefined);
8883 });
8884 };
8885 }
8886 function _construct(Parent, args, Class) {
8887 if (_is_native_reflect_construct()) {
8888 _construct = Reflect.construct;
8889 } else {
8890 _construct = function construct(Parent, args, Class) {
8891 var a = [
8892 null
8893 ];
8894 a.push.apply(a, args);
8895 var Constructor = Function.bind.apply(Parent, a);
8896 var instance = new Constructor();
8897 if (Class) _set_prototype_of(instance, Class.prototype);
8898 return instance;
8899 };
8900 }
8901 return _construct.apply(null, arguments);
8902 }
8903 function _defineProperties(target, props) {
8904 for(var i = 0; i < props.length; i++){
8905 var descriptor = props[i];
8906 descriptor.enumerable = descriptor.enumerable || false;
8907 descriptor.configurable = true;
8908 if ("value" in descriptor) descriptor.writable = true;
8909 Object.defineProperty(target, descriptor.key, descriptor);
8910 }
8911 }
8912 function _create_class(Constructor, protoProps, staticProps) {
8913 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
8914 return Constructor;
8915 }
8916 function _extends() {
8917 _extends = Object.assign || function(target) {
8918 for(var i = 1; i < arguments.length; i++){
8919 var source = arguments[i];
8920 for(var key in source){
8921 if (Object.prototype.hasOwnProperty.call(source, key)) {
8922 target[key] = source[key];
8923 }
8924 }
8925 }
8926 return target;
8927 };
8928 return _extends.apply(this, arguments);
8929 }
8930 function _get_prototype_of(o) {
8931 _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
8932 return o.__proto__ || Object.getPrototypeOf(o);
8933 };
8934 return _get_prototype_of(o);
8935 }
8936 function _inherits(subClass, superClass) {
8937 if (typeof superClass !== "function" && superClass !== null) {
8938 throw new TypeError("Super expression must either be null or a function");
8939 }
8940 subClass.prototype = Object.create(superClass && superClass.prototype, {
8941 constructor: {
8942 value: subClass,
8943 writable: true,
8944 configurable: true
8945 }
8946 });
8947 if (superClass) _set_prototype_of(subClass, superClass);
8948 }
8949 function _instanceof(left, right) {
8950 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
8951 return !!right[Symbol.hasInstance](left);
8952 } else {
8953 return left instanceof right;
8954 }
8955 }
8956 function _is_native_function(fn) {
8957 return Function.toString.call(fn).indexOf("[native code]") !== -1;
8958 }
8959 function _object_without_properties_loose(source, excluded) {
8960 if (source == null) return {};
8961 var target = {};
8962 var sourceKeys = Object.keys(source);
8963 var key, i;
8964 for(i = 0; i < sourceKeys.length; i++){
8965 key = sourceKeys[i];
8966 if (excluded.indexOf(key) >= 0) continue;
8967 target[key] = source[key];
8968 }
8969 return target;
8970 }
8971 function _set_prototype_of(o, p) {
8972 _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
8973 o.__proto__ = p;
8974 return o;
8975 };
8976 return _set_prototype_of(o, p);
8977 }
8978 function _type_of(obj) {
8979 "@swc/helpers - typeof";
8980 return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
8981 }
8982 function _unsupported_iterable_to_array(o, minLen) {
8983 if (!o) return;
8984 if (typeof o === "string") return _array_like_to_array(o, minLen);
8985 var n = Object.prototype.toString.call(o).slice(8, -1);
8986 if (n === "Object" && o.constructor) n = o.constructor.name;
8987 if (n === "Map" || n === "Set") return Array.from(n);
8988 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
8989 }
8990 function _wrap_native_super(Class) {
8991 var _cache = typeof Map === "function" ? new Map() : undefined;
8992 _wrap_native_super = function wrapNativeSuper(Class) {
8993 if (Class === null || !_is_native_function(Class)) return Class;
8994 if (typeof Class !== "function") {
8995 throw new TypeError("Super expression must either be null or a function");
8996 }
8997 if (typeof _cache !== "undefined") {
8998 if (_cache.has(Class)) return _cache.get(Class);
8999 _cache.set(Class, Wrapper);
9000 }
9001 function Wrapper() {
9002 return _construct(Class, arguments, _get_prototype_of(this).constructor);
9003 }
9004 Wrapper.prototype = Object.create(Class.prototype, {
9005 constructor: {
9006 value: Wrapper,
9007 enumerable: false,
9008 writable: true,
9009 configurable: true
9010 }
9011 });
9012 return _set_prototype_of(Wrapper, Class);
9013 };
9014 return _wrap_native_super(Class);
9015 }
9016 function _is_native_reflect_construct() {
9017 try {
9018 var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
9019 } catch (_) {}
9020 return (_is_native_reflect_construct = function() {
9021 return !!result;
9022 })();
9023 }
9024 function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
9025 var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
9026 if (it) return (it = it.call(o)).next.bind(it);
9027 if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike) {
9028 if (it) o = it;
9029 var i = 0;
9030 return function() {
9031 if (i >= o.length) {
9032 return {
9033 done: true
9034 };
9035 }
9036 return {
9037 done: false,
9038 value: o[i++]
9039 };
9040 };
9041 }
9042 throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9043 }
9044 function _ts_generator(thisArg, body) {
9045 var f, y, t, g, _ = {
9046 label: 0,
9047 sent: function() {
9048 if (t[0] & 1) throw t[1];
9049 return t[1];
9050 },
9051 trys: [],
9052 ops: []
9053 };
9054 return g = {
9055 next: verb(0),
9056 "throw": verb(1),
9057 "return": verb(2)
9058 }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
9059 return this;
9060 }), g;
9061 function verb(n) {
9062 return function(v) {
9063 return step([
9064 n,
9065 v
9066 ]);
9067 };
9068 }
9069 function step(op) {
9070 if (f) throw new TypeError("Generator is already executing.");
9071 while(_)try {
9072 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;
9073 if (y = 0, t) op = [
9074 op[0] & 2,
9075 t.value
9076 ];
9077 switch(op[0]){
9078 case 0:
9079 case 1:
9080 t = op;
9081 break;
9082 case 4:
9083 _.label++;
9084 return {
9085 value: op[1],
9086 done: false
9087 };
9088 case 5:
9089 _.label++;
9090 y = op[1];
9091 op = [
9092 0
9093 ];
9094 continue;
9095 case 7:
9096 op = _.ops.pop();
9097 _.trys.pop();
9098 continue;
9099 default:
9100 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
9101 _ = 0;
9102 continue;
9103 }
9104 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
9105 _.label = op[1];
9106 break;
9107 }
9108 if (op[0] === 6 && _.label < t[1]) {
9109 _.label = t[1];
9110 t = op;
9111 break;
9112 }
9113 if (t && _.label < t[2]) {
9114 _.label = t[2];
9115 _.ops.push(op);
9116 break;
9117 }
9118 if (t[2]) _.ops.pop();
9119 _.trys.pop();
9120 continue;
9121 }
9122 op = body.call(thisArg, _);
9123 } catch (e) {
9124 op = [
9125 6,
9126 e
9127 ];
9128 y = 0;
9129 } finally{
9130 f = t = 0;
9131 }
9132 if (op[0] & 5) throw op[1];
9133 return {
9134 value: op[0] ? op[1] : void 0,
9135 done: true
9136 };
9137 }
9138 }
9139 function _ts_values(o) {
9140 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
9141 if (m) return m.call(o);
9142 if (o && typeof o.length === "number") return {
9143 next: function() {
9144 if (o && i >= o.length) o = void 0;
9145 return {
9146 value: o && o[i++],
9147 done: !o
9148 };
9149 }
9150 };
9151 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
9152 }
9153 var __defProp = Object.defineProperty;
9154 var __defNormalProp = function(obj, key, value) {
9155 return key in obj ? __defProp(obj, key, {
9156 enumerable: true,
9157 configurable: true,
9158 writable: true,
9159 value: value
9160 }) : obj[key] = value;
9161 };
9162 var __publicField = function(obj, key, value) {
9163 return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
9164 };
9165 var _a;
9166 var __defProp$1 = Object.defineProperty;
9167 var __defNormalProp$1 = function(obj, key, value) {
9168 return key in obj ? __defProp$1(obj, key, {
9169 enumerable: true,
9170 configurable: true,
9171 writable: true,
9172 value: value
9173 }) : obj[key] = value;
9174 };
9175 var __publicField$1 = function(obj, key, value) {
9176 return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
9177 };
9178 var NodeType$3 = /* @__PURE__ */ function(NodeType2) {
9179 NodeType2[NodeType2["Document"] = 0] = "Document";
9180 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
9181 NodeType2[NodeType2["Element"] = 2] = "Element";
9182 NodeType2[NodeType2["Text"] = 3] = "Text";
9183 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
9184 NodeType2[NodeType2["Comment"] = 5] = "Comment";
9185 return NodeType2;
9186 }(NodeType$3 || {});
9187 var testableAccessors$1 = {
9188 Node: [
9189 "childNodes",
9190 "parentNode",
9191 "parentElement",
9192 "textContent"
9193 ],
9194 ShadowRoot: [
9195 "host",
9196 "styleSheets"
9197 ],
9198 Element: [
9199 "shadowRoot",
9200 "querySelector",
9201 "querySelectorAll"
9202 ],
9203 MutationObserver: []
9204 };
9205 var testableMethods$1 = {
9206 Node: [
9207 "contains",
9208 "getRootNode"
9209 ],
9210 ShadowRoot: [
9211 "getSelection"
9212 ],
9213 Element: [],
9214 MutationObserver: [
9215 "constructor"
9216 ]
9217 };
9218 var untaintedBasePrototype$1 = {};
9219 var isAngularZonePresent$1 = function() {
9220 return !!globalThis.Zone;
9221 };
9222 function getUntaintedPrototype$1(key) {
9223 if (untaintedBasePrototype$1[key]) return untaintedBasePrototype$1[key];
9224 var defaultObj = globalThis[key];
9225 var defaultPrototype = defaultObj.prototype;
9226 var accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
9227 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
9228 accessorNames.every(function(accessor) {
9229 var _a2, _b;
9230 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
9231 }));
9232 var methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
9233 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
9234 function(method) {
9235 var _a2;
9236 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
9237 }));
9238 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent$1()) {
9239 untaintedBasePrototype$1[key] = defaultObj.prototype;
9240 return defaultObj.prototype;
9241 }
9242 try {
9243 var iframeEl = document.createElement("iframe");
9244 document.body.appendChild(iframeEl);
9245 var win = iframeEl.contentWindow;
9246 if (!win) return defaultObj.prototype;
9247 var untaintedObject = win[key].prototype;
9248 document.body.removeChild(iframeEl);
9249 if (!untaintedObject) return defaultPrototype;
9250 return untaintedBasePrototype$1[key] = untaintedObject;
9251 } catch (e) {
9252 return defaultPrototype;
9253 }
9254 }
9255 var untaintedAccessorCache$1 = {};
9256 function getUntaintedAccessor$1(key, instance, accessor) {
9257 var _a2;
9258 var cacheKey = key + "." + String(accessor);
9259 if (untaintedAccessorCache$1[cacheKey]) return untaintedAccessorCache$1[cacheKey].call(instance);
9260 var untaintedPrototype = getUntaintedPrototype$1(key);
9261 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
9262 if (!untaintedAccessor) return instance[accessor];
9263 untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
9264 return untaintedAccessor.call(instance);
9265 }
9266 var untaintedMethodCache$1 = {};
9267 function getUntaintedMethod$1(key, instance, method) {
9268 var cacheKey = key + "." + String(method);
9269 if (untaintedMethodCache$1[cacheKey]) return untaintedMethodCache$1[cacheKey].bind(instance);
9270 var untaintedPrototype = getUntaintedPrototype$1(key);
9271 var untaintedMethod = untaintedPrototype[method];
9272 if (typeof untaintedMethod !== "function") return instance[method];
9273 untaintedMethodCache$1[cacheKey] = untaintedMethod;
9274 return untaintedMethod.bind(instance);
9275 }
9276 function childNodes$1(n2) {
9277 return getUntaintedAccessor$1("Node", n2, "childNodes");
9278 }
9279 function parentNode$1(n2) {
9280 return getUntaintedAccessor$1("Node", n2, "parentNode");
9281 }
9282 function parentElement$1(n2) {
9283 return getUntaintedAccessor$1("Node", n2, "parentElement");
9284 }
9285 function textContent$1(n2) {
9286 return getUntaintedAccessor$1("Node", n2, "textContent");
9287 }
9288 function contains$1(n2, other) {
9289 return getUntaintedMethod$1("Node", n2, "contains")(other);
9290 }
9291 function getRootNode$1(n2) {
9292 return getUntaintedMethod$1("Node", n2, "getRootNode")();
9293 }
9294 function host$1(n2) {
9295 if (!n2 || !("host" in n2)) return null;
9296 return getUntaintedAccessor$1("ShadowRoot", n2, "host");
9297 }
9298 function styleSheets$1(n2) {
9299 return n2.styleSheets;
9300 }
9301 function shadowRoot$1(n2) {
9302 if (!n2 || !("shadowRoot" in n2)) return null;
9303 return getUntaintedAccessor$1("Element", n2, "shadowRoot");
9304 }
9305 function querySelector$1(n2, selectors) {
9306 return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
9307 }
9308 function querySelectorAll$1(n2, selectors) {
9309 return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
9310 }
9311 function mutationObserverCtor$1() {
9312 return getUntaintedPrototype$1("MutationObserver").constructor;
9313 }
9314 function patch$1(source, name, replacement) {
9315 try {
9316 if (!(name in source)) {
9317 return function() {};
9318 }
9319 var original = source[name];
9320 var wrapped = replacement(original);
9321 if (typeof wrapped === "function") {
9322 wrapped.prototype = wrapped.prototype || {};
9323 Object.defineProperties(wrapped, {
9324 __rrweb_original__: {
9325 enumerable: false,
9326 value: original
9327 }
9328 });
9329 }
9330 source[name] = wrapped;
9331 return function() {
9332 source[name] = original;
9333 };
9334 } catch (e) {
9335 return function() {};
9336 }
9337 }
9338 var index$1 = {
9339 childNodes: childNodes$1,
9340 parentNode: parentNode$1,
9341 parentElement: parentElement$1,
9342 textContent: textContent$1,
9343 contains: contains$1,
9344 getRootNode: getRootNode$1,
9345 host: host$1,
9346 styleSheets: styleSheets$1,
9347 shadowRoot: shadowRoot$1,
9348 querySelector: querySelector$1,
9349 querySelectorAll: querySelectorAll$1,
9350 mutationObserver: mutationObserverCtor$1,
9351 patch: patch$1
9352 };
9353 function isElement(n2) {
9354 return n2.nodeType === n2.ELEMENT_NODE;
9355 }
9356 function isShadowRoot(n2) {
9357 var hostEl = // anchor and textarea elements also have a `host` property
9358 // but only shadow roots have a `mode` property
9359 n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null;
9360 return Boolean(hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2);
9361 }
9362 function isNativeShadowDom(shadowRoot2) {
9363 return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
9364 }
9365 function fixBrowserCompatibilityIssuesInCSS(cssText) {
9366 if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
9367 cssText = cssText.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;");
9368 }
9369 return cssText;
9370 }
9371 function escapeImportStatement(rule2) {
9372 var cssText = rule2.cssText;
9373 if (cssText.split('"').length < 3) return cssText;
9374 var statement = [
9375 "@import",
9376 "url(" + JSON.stringify(rule2.href) + ")"
9377 ];
9378 if (rule2.layerName === "") {
9379 statement.push("layer");
9380 } else if (rule2.layerName) {
9381 statement.push("layer(" + rule2.layerName + ")");
9382 }
9383 if (rule2.supportsText) {
9384 statement.push("supports(" + rule2.supportsText + ")");
9385 }
9386 if (rule2.media.length) {
9387 statement.push(rule2.media.mediaText);
9388 }
9389 return statement.join(" ") + ";";
9390 }
9391 function stringifyStylesheet(s2) {
9392 try {
9393 var rules2 = s2.rules || s2.cssRules;
9394 if (!rules2) {
9395 return null;
9396 }
9397 var sheetHref = s2.href;
9398 if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
9399 sheetHref = s2.ownerNode.ownerDocument.location.href;
9400 }
9401 var stringifiedRules = Array.from(rules2, function(rule2) {
9402 return stringifyRule(rule2, sheetHref);
9403 }).join("");
9404 return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
9405 } catch (error) {
9406 return null;
9407 }
9408 }
9409 function stringifyRule(rule2, sheetHref) {
9410 if (isCSSImportRule(rule2)) {
9411 var importStringified;
9412 try {
9413 importStringified = // we can access the imported stylesheet rules directly
9414 stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
9415 escapeImportStatement(rule2);
9416 } catch (error) {
9417 importStringified = rule2.cssText;
9418 }
9419 if (rule2.styleSheet.href) {
9420 return absolutifyURLs(importStringified, rule2.styleSheet.href);
9421 }
9422 return importStringified;
9423 } else {
9424 var ruleStringified = rule2.cssText;
9425 if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
9426 ruleStringified = fixSafariColons(ruleStringified);
9427 }
9428 if (sheetHref) {
9429 return absolutifyURLs(ruleStringified, sheetHref);
9430 }
9431 return ruleStringified;
9432 }
9433 }
9434 function fixSafariColons(cssStringified) {
9435 var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
9436 return cssStringified.replace(regex, "$1\\$2");
9437 }
9438 function isCSSImportRule(rule2) {
9439 return "styleSheet" in rule2;
9440 }
9441 function isCSSStyleRule(rule2) {
9442 return "selectorText" in rule2;
9443 }
9444 var Mirror = /*#__PURE__*/ function() {
9445 function Mirror() {
9446 __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
9447 __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
9448 }
9449 var _proto = Mirror.prototype;
9450 _proto.getId = function getId(n2) {
9451 var _a2;
9452 if (!n2) return -1;
9453 var id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id;
9454 return id != null ? id : -1;
9455 };
9456 _proto.getNode = function getNode(id) {
9457 return this.idNodeMap.get(id) || null;
9458 };
9459 _proto.getIds = function getIds() {
9460 return Array.from(this.idNodeMap.keys());
9461 };
9462 _proto.getMeta = function getMeta(n2) {
9463 return this.nodeMetaMap.get(n2) || null;
9464 };
9465 // removes the node from idNodeMap
9466 // doesn't remove the node from nodeMetaMap
9467 _proto.removeNodeFromMap = function removeNodeFromMap(n2) {
9468 var _this = this;
9469 var id = this.getId(n2);
9470 this.idNodeMap.delete(id);
9471 if (n2.childNodes) {
9472 n2.childNodes.forEach(function(childNode) {
9473 return _this.removeNodeFromMap(childNode);
9474 });
9475 }
9476 };
9477 _proto.has = function has(id) {
9478 return this.idNodeMap.has(id);
9479 };
9480 _proto.hasNode = function hasNode(node2) {
9481 return this.nodeMetaMap.has(node2);
9482 };
9483 _proto.add = function add(n2, meta) {
9484 var id = meta.id;
9485 this.idNodeMap.set(id, n2);
9486 this.nodeMetaMap.set(n2, meta);
9487 };
9488 _proto.replace = function replace(id, n2) {
9489 var oldNode = this.getNode(id);
9490 if (oldNode) {
9491 var meta = this.nodeMetaMap.get(oldNode);
9492 if (meta) this.nodeMetaMap.set(n2, meta);
9493 }
9494 this.idNodeMap.set(id, n2);
9495 };
9496 _proto.reset = function reset() {
9497 this.idNodeMap = /* @__PURE__ */ new Map();
9498 this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
9499 };
9500 return Mirror;
9501 }();
9502 function createMirror$2() {
9503 return new Mirror();
9504 }
9505 function maskInputValue(param) {
9506 var element = param.element, maskInputOptions = param.maskInputOptions, tagName = param.tagName, type = param.type, value = param.value, maskInputFn = param.maskInputFn;
9507 var text = value || "";
9508 var actualType = type && toLowerCase(type);
9509 if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
9510 if (maskInputFn) {
9511 text = maskInputFn(text, element);
9512 } else {
9513 text = "*".repeat(text.length);
9514 }
9515 }
9516 return text;
9517 }
9518 function toLowerCase(str) {
9519 return str.toLowerCase();
9520 }
9521 var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
9522 function is2DCanvasBlank(canvas) {
9523 var ctx = canvas.getContext("2d");
9524 if (!ctx) return true;
9525 var chunkSize = 50;
9526 for(var x2 = 0; x2 < canvas.width; x2 += chunkSize){
9527 for(var y = 0; y < canvas.height; y += chunkSize){
9528 var getImageData = ctx.getImageData;
9529 var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
9530 var pixelBuffer = new Uint32Array(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
9531 originalGetImageData.call(ctx, x2, y, Math.min(chunkSize, canvas.width - x2), Math.min(chunkSize, canvas.height - y)).data.buffer);
9532 if (pixelBuffer.some(function(pixel) {
9533 return pixel !== 0;
9534 })) return false;
9535 }
9536 }
9537 return true;
9538 }
9539 function getInputType(element) {
9540 var type = element.type;
9541 return element.hasAttribute("data-rr-is-password") ? "password" : type ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
9542 toLowerCase(type) : null;
9543 }
9544 function extractFileExtension(path, baseURL) {
9545 var url;
9546 try {
9547 url = new URL(path, baseURL != null ? baseURL : window.location.href);
9548 } catch (err) {
9549 return null;
9550 }
9551 var regex = /\.([0-9a-z]+)(?:$)/i;
9552 var match = url.pathname.match(regex);
9553 var _ref;
9554 return (_ref = match == null ? void 0 : match[1]) != null ? _ref : null;
9555 }
9556 function extractOrigin(url) {
9557 var origin = "";
9558 if (url.indexOf("//") > -1) {
9559 origin = url.split("/").slice(0, 3).join("/");
9560 } else {
9561 origin = url.split("/")[0];
9562 }
9563 origin = origin.split("?")[0];
9564 return origin;
9565 }
9566 var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
9567 var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
9568 var URL_WWW_MATCH = /^www\..*/i;
9569 var DATA_URI = /^(data:)([^,]*),(.*)/i;
9570 function absolutifyURLs(cssText, href) {
9571 return (cssText || "").replace(URL_IN_CSS_REF, function(origin, quote1, path1, quote2, path2, path3) {
9572 var filePath = path1 || path2 || path3;
9573 var maybeQuote = quote1 || quote2 || "";
9574 if (!filePath) {
9575 return origin;
9576 }
9577 if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
9578 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9579 }
9580 if (DATA_URI.test(filePath)) {
9581 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9582 }
9583 if (filePath[0] === "/") {
9584 return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
9585 }
9586 var stack = href.split("/");
9587 var parts = filePath.split("/");
9588 stack.pop();
9589 for(var _iterator = _create_for_of_iterator_helper_loose(parts), _step; !(_step = _iterator()).done;){
9590 var part = _step.value;
9591 if (part === ".") {
9592 continue;
9593 } else if (part === "..") {
9594 stack.pop();
9595 } else {
9596 stack.push(part);
9597 }
9598 }
9599 return "url(" + maybeQuote + stack.join("/") + maybeQuote + ")";
9600 });
9601 }
9602 function normalizeCssString(cssText, _testNoPxNorm) {
9603 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9604 if (_testNoPxNorm) {
9605 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
9606 } else {
9607 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
9608 }
9609 }
9610 function splitCssText(cssText, style, _testNoPxNorm) {
9611 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9612 var childNodes2 = Array.from(style.childNodes);
9613 var splits = [];
9614 var iterCount = 0;
9615 if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
9616 var cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
9617 var normFactor = cssTextNorm.length / cssText.length;
9618 for(var i2 = 1; i2 < childNodes2.length; i2++){
9619 if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
9620 var textContentNorm = normalizeCssString(childNodes2[i2].textContent, _testNoPxNorm);
9621 var jLimit = 100;
9622 var j = 3;
9623 for(; j < textContentNorm.length; j++){
9624 if (// keep consuming css identifiers (to get a decent chunk more quickly)
9625 textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
9626 textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1) {
9627 continue;
9628 }
9629 break;
9630 }
9631 for(; j < textContentNorm.length; j++){
9632 var startSubstring = textContentNorm.substring(0, j);
9633 var cssNormSplits = cssTextNorm.split(startSubstring);
9634 var splitNorm = -1;
9635 if (cssNormSplits.length === 2) {
9636 splitNorm = cssNormSplits[0].length;
9637 } else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
9638 splitNorm = cssTextNorm.indexOf(startSubstring, 1);
9639 } else if (cssNormSplits.length === 1) {
9640 startSubstring = startSubstring.substring(0, startSubstring.length - 1);
9641 cssNormSplits = cssTextNorm.split(startSubstring);
9642 if (cssNormSplits.length <= 1) {
9643 splits.push(cssText);
9644 return splits;
9645 }
9646 j = jLimit + 1;
9647 } else if (j === textContentNorm.length - 1) {
9648 splitNorm = cssTextNorm.indexOf(startSubstring);
9649 }
9650 if (cssNormSplits.length >= 2 && j > jLimit) {
9651 var prevTextContent = childNodes2[i2 - 1].textContent;
9652 if (prevTextContent && typeof prevTextContent === "string") {
9653 var prevMinLength = normalizeCssString(prevTextContent).length;
9654 splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
9655 }
9656 if (splitNorm === -1) {
9657 splitNorm = cssNormSplits[0].length;
9658 }
9659 }
9660 if (splitNorm !== -1) {
9661 var k = Math.floor(splitNorm / normFactor);
9662 for(; k > 0 && k < cssText.length;){
9663 iterCount += 1;
9664 if (iterCount > 50 * childNodes2.length) {
9665 splits.push(cssText);
9666 return splits;
9667 }
9668 var normPart = normalizeCssString(cssText.substring(0, k), _testNoPxNorm);
9669 if (normPart.length === splitNorm) {
9670 splits.push(cssText.substring(0, k));
9671 cssText = cssText.substring(k);
9672 cssTextNorm = cssTextNorm.substring(splitNorm);
9673 break;
9674 } else if (normPart.length < splitNorm) {
9675 k += Math.max(1, Math.floor((splitNorm - normPart.length) / normFactor));
9676 } else {
9677 k -= Math.max(1, Math.floor((normPart.length - splitNorm) * normFactor));
9678 }
9679 }
9680 break;
9681 }
9682 }
9683 }
9684 }
9685 }
9686 splits.push(cssText);
9687 return splits;
9688 }
9689 function markCssSplits(cssText, style) {
9690 return splitCssText(cssText, style).join("/* rr_split */");
9691 }
9692 var _id = 1;
9693 var tagNameRegex = new RegExp("[^a-z0-9-_:]");
9694 var IGNORED_NODE = -2;
9695 function genId() {
9696 return _id++;
9697 }
9698 function getValidTagName$1(element) {
9699 if (_instanceof(element, HTMLFormElement)) {
9700 return "form";
9701 }
9702 var processedTagName = toLowerCase(element.tagName);
9703 if (tagNameRegex.test(processedTagName)) {
9704 return "div";
9705 }
9706 return processedTagName;
9707 }
9708 var canvasService;
9709 var canvasCtx;
9710 var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
9711 var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
9712 function getAbsoluteSrcsetString(doc, attributeValue) {
9713 if (attributeValue.trim() === "") {
9714 return attributeValue;
9715 }
9716 var pos = 0;
9717 function collectCharacters(regEx) {
9718 var chars2;
9719 var match = regEx.exec(attributeValue.substring(pos));
9720 if (match) {
9721 chars2 = match[0];
9722 pos += chars2.length;
9723 return chars2;
9724 }
9725 return "";
9726 }
9727 var output = [];
9728 while(true){
9729 collectCharacters(SRCSET_COMMAS_OR_SPACES);
9730 if (pos >= attributeValue.length) {
9731 break;
9732 }
9733 var url = collectCharacters(SRCSET_NOT_SPACES);
9734 if (url.slice(-1) === ",") {
9735 url = absoluteToDoc(doc, url.substring(0, url.length - 1));
9736 output.push(url);
9737 } else {
9738 var descriptorsStr = "";
9739 url = absoluteToDoc(doc, url);
9740 var inParens = false;
9741 while(true){
9742 var c2 = attributeValue.charAt(pos);
9743 if (c2 === "") {
9744 output.push((url + descriptorsStr).trim());
9745 break;
9746 } else if (!inParens) {
9747 if (c2 === ",") {
9748 pos += 1;
9749 output.push((url + descriptorsStr).trim());
9750 break;
9751 } else if (c2 === "(") {
9752 inParens = true;
9753 }
9754 } else {
9755 if (c2 === ")") {
9756 inParens = false;
9757 }
9758 }
9759 descriptorsStr += c2;
9760 pos += 1;
9761 }
9762 }
9763 }
9764 return output.join(", ");
9765 }
9766 var cachedDocument = /* @__PURE__ */ new WeakMap();
9767 function absoluteToDoc(doc, attributeValue) {
9768 if (!attributeValue || attributeValue.trim() === "") {
9769 return attributeValue;
9770 }
9771 return getHref(doc, attributeValue);
9772 }
9773 function isSVGElement(el) {
9774 return Boolean(el.tagName === "svg" || el.ownerSVGElement);
9775 }
9776 function getHref(doc, customHref) {
9777 var a2 = cachedDocument.get(doc);
9778 if (!a2) {
9779 a2 = doc.createElement("a");
9780 cachedDocument.set(doc, a2);
9781 }
9782 if (!customHref) {
9783 customHref = "";
9784 } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
9785 return customHref;
9786 }
9787 a2.setAttribute("href", customHref);
9788 return a2.href;
9789 }
9790 function transformAttribute(doc, tagName, name, value) {
9791 if (!value) {
9792 return value;
9793 }
9794 if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
9795 return absoluteToDoc(doc, value);
9796 } else if (name === "xlink:href" && value[0] !== "#") {
9797 return absoluteToDoc(doc, value);
9798 } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
9799 return absoluteToDoc(doc, value);
9800 } else if (name === "srcset") {
9801 return getAbsoluteSrcsetString(doc, value);
9802 } else if (name === "style") {
9803 return absolutifyURLs(value, getHref(doc));
9804 } else if (tagName === "object" && name === "data") {
9805 return absoluteToDoc(doc, value);
9806 }
9807 return value;
9808 }
9809 function ignoreAttribute(tagName, name, _value) {
9810 return (tagName === "video" || tagName === "audio") && name === "autoplay";
9811 }
9812 function _isBlockedElement(element, blockClass, blockSelector) {
9813 try {
9814 if (typeof blockClass === "string") {
9815 if (element.classList.contains(blockClass)) {
9816 return true;
9817 }
9818 } else {
9819 for(var eIndex = element.classList.length; eIndex--;){
9820 var className = element.classList[eIndex];
9821 if (blockClass.test(className)) {
9822 return true;
9823 }
9824 }
9825 }
9826 if (blockSelector) {
9827 return element.matches(blockSelector);
9828 }
9829 } catch (e2) {}
9830 return false;
9831 }
9832 function classMatchesRegex(node2, regex, checkAncestors) {
9833 if (!node2) return false;
9834 if (node2.nodeType !== node2.ELEMENT_NODE) {
9835 if (!checkAncestors) return false;
9836 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9837 }
9838 for(var eIndex = node2.classList.length; eIndex--;){
9839 var className = node2.classList[eIndex];
9840 if (regex.test(className)) {
9841 return true;
9842 }
9843 }
9844 if (!checkAncestors) return false;
9845 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9846 }
9847 function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
9848 var el;
9849 if (isElement(node2)) {
9850 el = node2;
9851 if (!index$1.childNodes(el).length) {
9852 return false;
9853 }
9854 } else if (index$1.parentElement(node2) === null) {
9855 return false;
9856 } else {
9857 el = index$1.parentElement(node2);
9858 }
9859 try {
9860 if (typeof maskTextClass === "string") {
9861 if (checkAncestors) {
9862 if (el.closest("." + maskTextClass)) return true;
9863 } else {
9864 if (el.classList.contains(maskTextClass)) return true;
9865 }
9866 } else {
9867 if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
9868 }
9869 if (maskTextSelector) {
9870 if (checkAncestors) {
9871 if (el.closest(maskTextSelector)) return true;
9872 } else {
9873 if (el.matches(maskTextSelector)) return true;
9874 }
9875 }
9876 } catch (e2) {}
9877 return false;
9878 }
9879 function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
9880 var win = iframeEl.contentWindow;
9881 if (!win) {
9882 return;
9883 }
9884 var fired = false;
9885 var readyState;
9886 try {
9887 readyState = win.document.readyState;
9888 } catch (error) {
9889 return;
9890 }
9891 if (readyState !== "complete") {
9892 var timer = setTimeout(function() {
9893 if (!fired) {
9894 listener();
9895 fired = true;
9896 }
9897 }, iframeLoadTimeout);
9898 iframeEl.addEventListener("load", function() {
9899 clearTimeout(timer);
9900 fired = true;
9901 listener();
9902 });
9903 return;
9904 }
9905 var blankUrl = "about:blank";
9906 if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
9907 setTimeout(listener, 0);
9908 return iframeEl.addEventListener("load", listener);
9909 }
9910 iframeEl.addEventListener("load", listener);
9911 }
9912 function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
9913 var fired = false;
9914 var styleSheetLoaded;
9915 try {
9916 styleSheetLoaded = link.sheet;
9917 } catch (error) {
9918 return;
9919 }
9920 if (styleSheetLoaded) return;
9921 var timer = setTimeout(function() {
9922 if (!fired) {
9923 listener();
9924 fired = true;
9925 }
9926 }, styleSheetLoadTimeout);
9927 link.addEventListener("load", function() {
9928 clearTimeout(timer);
9929 fired = true;
9930 listener();
9931 });
9932 }
9933 function serializeNode(n2, options) {
9934 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;
9935 var rootId = getRootId(doc, mirror2);
9936 switch(n2.nodeType){
9937 case n2.DOCUMENT_NODE:
9938 if (n2.compatMode !== "CSS1Compat") {
9939 return {
9940 type: NodeType$3.Document,
9941 childNodes: [],
9942 compatMode: n2.compatMode
9943 };
9944 } else {
9945 return {
9946 type: NodeType$3.Document,
9947 childNodes: []
9948 };
9949 }
9950 case n2.DOCUMENT_TYPE_NODE:
9951 return {
9952 type: NodeType$3.DocumentType,
9953 name: n2.name,
9954 publicId: n2.publicId,
9955 systemId: n2.systemId,
9956 rootId: rootId
9957 };
9958 case n2.ELEMENT_NODE:
9959 return serializeElementNode(n2, {
9960 doc: doc,
9961 blockClass: blockClass,
9962 blockSelector: blockSelector,
9963 inlineStylesheet: inlineStylesheet,
9964 maskInputOptions: maskInputOptions,
9965 maskInputFn: maskInputFn,
9966 dataURLOptions: dataURLOptions,
9967 inlineImages: inlineImages,
9968 recordCanvas: recordCanvas,
9969 keepIframeSrcFn: keepIframeSrcFn,
9970 newlyAddedElement: newlyAddedElement,
9971 rootId: rootId
9972 });
9973 case n2.TEXT_NODE:
9974 return serializeTextNode(n2, {
9975 doc: doc,
9976 needsMask: needsMask,
9977 maskTextFn: maskTextFn,
9978 rootId: rootId,
9979 cssCaptured: cssCaptured
9980 });
9981 case n2.CDATA_SECTION_NODE:
9982 return {
9983 type: NodeType$3.CDATA,
9984 textContent: "",
9985 rootId: rootId
9986 };
9987 case n2.COMMENT_NODE:
9988 return {
9989 type: NodeType$3.Comment,
9990 textContent: index$1.textContent(n2) || "",
9991 rootId: rootId
9992 };
9993 default:
9994 return false;
9995 }
9996 }
9997 function getRootId(doc, mirror2) {
9998 if (!mirror2.hasNode(doc)) return void 0;
9999 var docId = mirror2.getId(doc);
10000 return docId === 1 ? void 0 : docId;
10001 }
10002 function serializeTextNode(n2, options) {
10003 var needsMask = options.needsMask, maskTextFn = options.maskTextFn, rootId = options.rootId, cssCaptured = options.cssCaptured;
10004 var parent = index$1.parentNode(n2);
10005 var parentTagName = parent && parent.tagName;
10006 var textContent2 = "";
10007 var isStyle = parentTagName === "STYLE" ? true : void 0;
10008 var isScript = parentTagName === "SCRIPT" ? true : void 0;
10009 if (isScript) {
10010 textContent2 = "SCRIPT_PLACEHOLDER";
10011 } else if (!cssCaptured) {
10012 textContent2 = index$1.textContent(n2);
10013 if (isStyle && textContent2) {
10014 textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
10015 }
10016 }
10017 if (!isStyle && !isScript && textContent2 && needsMask) {
10018 textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
10019 }
10020 return {
10021 type: NodeType$3.Text,
10022 textContent: textContent2 || "",
10023 rootId: rootId
10024 };
10025 }
10026 function serializeElementNode(n2, options) {
10027 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;
10028 var needBlock = _isBlockedElement(n2, blockClass, blockSelector);
10029 var tagName = getValidTagName$1(n2);
10030 var attributes = {};
10031 var len = n2.attributes.length;
10032 for(var i2 = 0; i2 < len; i2++){
10033 var attr = n2.attributes[i2];
10034 if (!ignoreAttribute(tagName, attr.name, attr.value)) {
10035 attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
10036 }
10037 }
10038 if (tagName === "link" && inlineStylesheet) {
10039 var stylesheet = Array.from(doc.styleSheets).find(function(s2) {
10040 return s2.href === n2.href;
10041 });
10042 var cssText = null;
10043 if (stylesheet) {
10044 cssText = stringifyStylesheet(stylesheet);
10045 }
10046 if (cssText) {
10047 delete attributes.rel;
10048 delete attributes.href;
10049 attributes._cssText = cssText;
10050 }
10051 }
10052 if (tagName === "style" && n2.sheet) {
10053 var cssText1 = stringifyStylesheet(n2.sheet);
10054 if (cssText1) {
10055 if (n2.childNodes.length > 1) {
10056 cssText1 = markCssSplits(cssText1, n2);
10057 }
10058 attributes._cssText = cssText1;
10059 }
10060 }
10061 if (tagName === "input" || tagName === "textarea" || tagName === "select") {
10062 var value = n2.value;
10063 var checked = n2.checked;
10064 if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
10065 attributes.value = maskInputValue({
10066 element: n2,
10067 type: getInputType(n2),
10068 tagName: tagName,
10069 value: value,
10070 maskInputOptions: maskInputOptions,
10071 maskInputFn: maskInputFn
10072 });
10073 } else if (checked) {
10074 attributes.checked = checked;
10075 }
10076 }
10077 if (tagName === "option") {
10078 if (n2.selected && !maskInputOptions["select"]) {
10079 attributes.selected = true;
10080 } else {
10081 delete attributes.selected;
10082 }
10083 }
10084 if (tagName === "dialog" && n2.open) {
10085 attributes.rr_open_mode = n2.matches("dialog:modal") ? "modal" : "non-modal";
10086 }
10087 if (tagName === "canvas" && recordCanvas) {
10088 if (n2.__context === "2d") {
10089 if (!is2DCanvasBlank(n2)) {
10090 attributes.rr_dataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10091 }
10092 } else if (!("__context" in n2)) {
10093 var canvasDataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10094 var blankCanvas = doc.createElement("canvas");
10095 blankCanvas.width = n2.width;
10096 blankCanvas.height = n2.height;
10097 var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10098 if (canvasDataURL !== blankCanvasDataURL) {
10099 attributes.rr_dataURL = canvasDataURL;
10100 }
10101 }
10102 }
10103 if (tagName === "img" && inlineImages) {
10104 if (!canvasService) {
10105 canvasService = doc.createElement("canvas");
10106 canvasCtx = canvasService.getContext("2d");
10107 }
10108 var image = n2;
10109 var imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
10110 var priorCrossOrigin = image.crossOrigin;
10111 var recordInlineImage = function() {
10112 image.removeEventListener("load", recordInlineImage);
10113 try {
10114 canvasService.width = image.naturalWidth;
10115 canvasService.height = image.naturalHeight;
10116 canvasCtx.drawImage(image, 0, 0);
10117 attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10118 } catch (err) {
10119 if (image.crossOrigin !== "anonymous") {
10120 image.crossOrigin = "anonymous";
10121 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
10122 else image.addEventListener("load", recordInlineImage);
10123 return;
10124 } else {
10125 console.warn("Cannot inline img src=" + imageSrc + "! Error: " + err);
10126 }
10127 }
10128 if (image.crossOrigin === "anonymous") {
10129 priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
10130 }
10131 };
10132 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
10133 else image.addEventListener("load", recordInlineImage);
10134 }
10135 if (tagName === "audio" || tagName === "video") {
10136 var mediaAttributes = attributes;
10137 mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
10138 mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
10139 mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
10140 mediaAttributes.rr_mediaMuted = n2.muted;
10141 mediaAttributes.rr_mediaLoop = n2.loop;
10142 mediaAttributes.rr_mediaVolume = n2.volume;
10143 }
10144 if (!newlyAddedElement) {
10145 if (n2.scrollLeft) {
10146 attributes.rr_scrollLeft = n2.scrollLeft;
10147 }
10148 if (n2.scrollTop) {
10149 attributes.rr_scrollTop = n2.scrollTop;
10150 }
10151 }
10152 if (needBlock) {
10153 var _n2_getBoundingClientRect = n2.getBoundingClientRect(), width = _n2_getBoundingClientRect.width, height = _n2_getBoundingClientRect.height;
10154 attributes = {
10155 class: attributes.class,
10156 rr_width: "" + width + "px",
10157 rr_height: "" + height + "px"
10158 };
10159 }
10160 if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
10161 if (!n2.contentDocument) {
10162 attributes.rr_src = attributes.src;
10163 }
10164 delete attributes.src;
10165 }
10166 var isCustomElement;
10167 try {
10168 if (customElements.get(tagName)) isCustomElement = true;
10169 } catch (e2) {}
10170 return {
10171 type: NodeType$3.Element,
10172 tagName: tagName,
10173 attributes: attributes,
10174 childNodes: [],
10175 isSVG: isSVGElement(n2) || void 0,
10176 needBlock: needBlock,
10177 rootId: rootId,
10178 isCustom: isCustomElement
10179 };
10180 }
10181 function lowerIfExists(maybeAttr) {
10182 if (maybeAttr === void 0 || maybeAttr === null) {
10183 return "";
10184 } else {
10185 return maybeAttr.toLowerCase();
10186 }
10187 }
10188 function slimDOMExcluded(sn, slimDOMOptions) {
10189 if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
10190 return true;
10191 } else if (sn.type === NodeType$3.Element) {
10192 if (slimDOMOptions.script && // script tag
10193 (sn.tagName === "script" || // (module)preload link
10194 sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
10195 sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
10196 return true;
10197 } 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"))) {
10198 return true;
10199 } else if (sn.tagName === "meta") {
10200 if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
10201 return true;
10202 } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
10203 lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
10204 return true;
10205 } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
10206 return true;
10207 } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
10208 return true;
10209 } 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:/))) {
10210 return true;
10211 } 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")) {
10212 return true;
10213 }
10214 }
10215 }
10216 return false;
10217 }
10218 function serializeNodeWithId(n2, options) {
10219 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() {
10220 return false;
10221 } : _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;
10222 var needsMask = options.needsMask;
10223 var _options_preserveWhiteSpace = options.preserveWhiteSpace, preserveWhiteSpace = _options_preserveWhiteSpace === void 0 ? true : _options_preserveWhiteSpace;
10224 if (!needsMask) {
10225 var checkAncestors = needsMask === void 0;
10226 needsMask = needMaskingText(n2, maskTextClass, maskTextSelector, checkAncestors);
10227 }
10228 var _serializedNode = serializeNode(n2, {
10229 doc: doc,
10230 mirror: mirror2,
10231 blockClass: blockClass,
10232 blockSelector: blockSelector,
10233 needsMask: needsMask,
10234 inlineStylesheet: inlineStylesheet,
10235 maskInputOptions: maskInputOptions,
10236 maskTextFn: maskTextFn,
10237 maskInputFn: maskInputFn,
10238 dataURLOptions: dataURLOptions,
10239 inlineImages: inlineImages,
10240 recordCanvas: recordCanvas,
10241 keepIframeSrcFn: keepIframeSrcFn,
10242 newlyAddedElement: newlyAddedElement,
10243 cssCaptured: cssCaptured
10244 });
10245 if (!_serializedNode) {
10246 console.warn(n2, "not serialized");
10247 return null;
10248 }
10249 var id;
10250 if (mirror2.hasNode(n2)) {
10251 id = mirror2.getId(n2);
10252 } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
10253 id = IGNORED_NODE;
10254 } else {
10255 id = genId();
10256 }
10257 var serializedNode = Object.assign(_serializedNode, {
10258 id: id
10259 });
10260 mirror2.add(n2, serializedNode);
10261 if (id === IGNORED_NODE) {
10262 return null;
10263 }
10264 if (onSerialize) {
10265 onSerialize(n2);
10266 }
10267 var recordChild = !skipChild;
10268 if (serializedNode.type === NodeType$3.Element) {
10269 recordChild = recordChild && !serializedNode.needBlock;
10270 delete serializedNode.needBlock;
10271 var shadowRootEl = index$1.shadowRoot(n2);
10272 if (shadowRootEl && isNativeShadowDom(shadowRootEl)) serializedNode.isShadowHost = true;
10273 }
10274 if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
10275 if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
10276 preserveWhiteSpace = false;
10277 }
10278 var bypassOptions = {
10279 doc: doc,
10280 mirror: mirror2,
10281 blockClass: blockClass,
10282 blockSelector: blockSelector,
10283 needsMask: needsMask,
10284 maskTextClass: maskTextClass,
10285 maskTextSelector: maskTextSelector,
10286 skipChild: skipChild,
10287 inlineStylesheet: inlineStylesheet,
10288 maskInputOptions: maskInputOptions,
10289 maskTextFn: maskTextFn,
10290 maskInputFn: maskInputFn,
10291 slimDOMOptions: slimDOMOptions,
10292 dataURLOptions: dataURLOptions,
10293 inlineImages: inlineImages,
10294 recordCanvas: recordCanvas,
10295 preserveWhiteSpace: preserveWhiteSpace,
10296 onSerialize: onSerialize,
10297 onIframeLoad: onIframeLoad,
10298 iframeLoadTimeout: iframeLoadTimeout,
10299 onStylesheetLoad: onStylesheetLoad,
10300 stylesheetLoadTimeout: stylesheetLoadTimeout,
10301 keepIframeSrcFn: keepIframeSrcFn,
10302 cssCaptured: false
10303 };
10304 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
10305 else {
10306 if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
10307 bypassOptions.cssCaptured = true;
10308 }
10309 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(n2))), _step; !(_step = _iterator()).done;){
10310 var childN = _step.value;
10311 var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
10312 if (serializedChildNode) {
10313 serializedNode.childNodes.push(serializedChildNode);
10314 }
10315 }
10316 }
10317 var shadowRootEl1 = null;
10318 if (isElement(n2) && (shadowRootEl1 = index$1.shadowRoot(n2))) {
10319 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(shadowRootEl1))), _step1; !(_step1 = _iterator1()).done;){
10320 var childN1 = _step1.value;
10321 var serializedChildNode1 = serializeNodeWithId(childN1, bypassOptions);
10322 if (serializedChildNode1) {
10323 isNativeShadowDom(shadowRootEl1) && (serializedChildNode1.isShadow = true);
10324 serializedNode.childNodes.push(serializedChildNode1);
10325 }
10326 }
10327 }
10328 }
10329 var parent = index$1.parentNode(n2);
10330 if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
10331 serializedNode.isShadow = true;
10332 }
10333 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
10334 onceIframeLoaded(n2, function() {
10335 var iframeDoc = n2.contentDocument;
10336 if (iframeDoc && onIframeLoad) {
10337 var serializedIframeNode = serializeNodeWithId(iframeDoc, {
10338 doc: iframeDoc,
10339 mirror: mirror2,
10340 blockClass: blockClass,
10341 blockSelector: blockSelector,
10342 needsMask: needsMask,
10343 maskTextClass: maskTextClass,
10344 maskTextSelector: maskTextSelector,
10345 skipChild: false,
10346 inlineStylesheet: inlineStylesheet,
10347 maskInputOptions: maskInputOptions,
10348 maskTextFn: maskTextFn,
10349 maskInputFn: maskInputFn,
10350 slimDOMOptions: slimDOMOptions,
10351 dataURLOptions: dataURLOptions,
10352 inlineImages: inlineImages,
10353 recordCanvas: recordCanvas,
10354 preserveWhiteSpace: preserveWhiteSpace,
10355 onSerialize: onSerialize,
10356 onIframeLoad: onIframeLoad,
10357 iframeLoadTimeout: iframeLoadTimeout,
10358 onStylesheetLoad: onStylesheetLoad,
10359 stylesheetLoadTimeout: stylesheetLoadTimeout,
10360 keepIframeSrcFn: keepIframeSrcFn
10361 });
10362 if (serializedIframeNode) {
10363 onIframeLoad(n2, serializedIframeNode);
10364 }
10365 }
10366 }, iframeLoadTimeout);
10367 }
10368 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")) {
10369 onceStylesheetLoaded(n2, function() {
10370 if (onStylesheetLoad) {
10371 var serializedLinkNode = serializeNodeWithId(n2, {
10372 doc: doc,
10373 mirror: mirror2,
10374 blockClass: blockClass,
10375 blockSelector: blockSelector,
10376 needsMask: needsMask,
10377 maskTextClass: maskTextClass,
10378 maskTextSelector: maskTextSelector,
10379 skipChild: false,
10380 inlineStylesheet: inlineStylesheet,
10381 maskInputOptions: maskInputOptions,
10382 maskTextFn: maskTextFn,
10383 maskInputFn: maskInputFn,
10384 slimDOMOptions: slimDOMOptions,
10385 dataURLOptions: dataURLOptions,
10386 inlineImages: inlineImages,
10387 recordCanvas: recordCanvas,
10388 preserveWhiteSpace: preserveWhiteSpace,
10389 onSerialize: onSerialize,
10390 onIframeLoad: onIframeLoad,
10391 iframeLoadTimeout: iframeLoadTimeout,
10392 onStylesheetLoad: onStylesheetLoad,
10393 stylesheetLoadTimeout: stylesheetLoadTimeout,
10394 keepIframeSrcFn: keepIframeSrcFn
10395 });
10396 if (serializedLinkNode) {
10397 onStylesheetLoad(n2, serializedLinkNode);
10398 }
10399 }
10400 }, stylesheetLoadTimeout);
10401 }
10402 return serializedNode;
10403 }
10404 function snapshot(n2, options) {
10405 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() {
10406 return false;
10407 } : _ref_keepIframeSrcFn;
10408 var maskInputOptions = maskAllInputs === true ? {
10409 color: true,
10410 date: true,
10411 "datetime-local": true,
10412 email: true,
10413 month: true,
10414 number: true,
10415 range: true,
10416 search: true,
10417 tel: true,
10418 text: true,
10419 time: true,
10420 url: true,
10421 week: true,
10422 textarea: true,
10423 select: true,
10424 password: true,
10425 hidden: true
10426 } : maskAllInputs === false ? {
10427 password: true
10428 } : maskAllInputs;
10429 var slimDOMOptions = slimDOM === true || slimDOM === "all" ? // if true: set of sensible options that should not throw away any information
10430 {
10431 script: true,
10432 comment: true,
10433 headFavicon: true,
10434 headWhitespace: true,
10435 headMetaDescKeywords: slimDOM === "all",
10436 // destructive
10437 headMetaSocial: true,
10438 headMetaRobots: true,
10439 headMetaHttpEquiv: true,
10440 headMetaAuthorship: true,
10441 headMetaVerification: true
10442 } : slimDOM === false ? {} : slimDOM;
10443 return serializeNodeWithId(n2, {
10444 doc: n2,
10445 mirror: mirror2,
10446 blockClass: blockClass,
10447 blockSelector: blockSelector,
10448 maskTextClass: maskTextClass,
10449 maskTextSelector: maskTextSelector,
10450 skipChild: false,
10451 inlineStylesheet: inlineStylesheet,
10452 maskInputOptions: maskInputOptions,
10453 maskTextFn: maskTextFn,
10454 maskInputFn: maskInputFn,
10455 slimDOMOptions: slimDOMOptions,
10456 dataURLOptions: dataURLOptions,
10457 inlineImages: inlineImages,
10458 recordCanvas: recordCanvas,
10459 preserveWhiteSpace: preserveWhiteSpace,
10460 onSerialize: onSerialize,
10461 onIframeLoad: onIframeLoad,
10462 iframeLoadTimeout: iframeLoadTimeout,
10463 onStylesheetLoad: onStylesheetLoad,
10464 stylesheetLoadTimeout: stylesheetLoadTimeout,
10465 keepIframeSrcFn: keepIframeSrcFn,
10466 newlyAddedElement: false
10467 });
10468 }
10469 function getDefaultExportFromCjs$1(x2) {
10470 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
10471 }
10472 function getAugmentedNamespace$1(n2) {
10473 if (n2.__esModule) return n2;
10474 var f2 = n2.default;
10475 if (typeof f2 == "function") {
10476 var a2 = function a22() {
10477 if (_instanceof(this, a22)) {
10478 return Reflect.construct(f2, arguments, this.constructor);
10479 }
10480 return f2.apply(this, arguments);
10481 };
10482 a2.prototype = f2.prototype;
10483 } else a2 = {};
10484 Object.defineProperty(a2, "__esModule", {
10485 value: true
10486 });
10487 Object.keys(n2).forEach(function(k) {
10488 var d = Object.getOwnPropertyDescriptor(n2, k);
10489 Object.defineProperty(a2, k, d.get ? d : {
10490 enumerable: true,
10491 get: function get() {
10492 return n2[k];
10493 }
10494 });
10495 });
10496 return a2;
10497 }
10498 var picocolors_browser$1 = {
10499 exports: {}
10500 };
10501 var x$1 = String;
10502 var create$1 = function create$1() {
10503 return {
10504 isColorSupported: false,
10505 reset: x$1,
10506 bold: x$1,
10507 dim: x$1,
10508 italic: x$1,
10509 underline: x$1,
10510 inverse: x$1,
10511 hidden: x$1,
10512 strikethrough: x$1,
10513 black: x$1,
10514 red: x$1,
10515 green: x$1,
10516 yellow: x$1,
10517 blue: x$1,
10518 magenta: x$1,
10519 cyan: x$1,
10520 white: x$1,
10521 gray: x$1,
10522 bgBlack: x$1,
10523 bgRed: x$1,
10524 bgGreen: x$1,
10525 bgYellow: x$1,
10526 bgBlue: x$1,
10527 bgMagenta: x$1,
10528 bgCyan: x$1,
10529 bgWhite: x$1
10530 };
10531 };
10532 picocolors_browser$1.exports = create$1();
10533 picocolors_browser$1.exports.createColors = create$1;
10534 var picocolors_browserExports$1 = picocolors_browser$1.exports;
10535 var __viteBrowserExternal$2 = {};
10536 var __viteBrowserExternal$1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10537 __proto__: null,
10538 default: __viteBrowserExternal$2
10539 }, Symbol.toStringTag, {
10540 value: "Module"
10541 }));
10542 var require$$2$1 = /* @__PURE__ */ getAugmentedNamespace$1(__viteBrowserExternal$1$1);
10543 var pico$1 = picocolors_browserExports$1;
10544 var terminalHighlight$1$1 = require$$2$1;
10545 var CssSyntaxError$3$1 = /*#__PURE__*/ function(Error1) {
10546 _inherits(CssSyntaxError, Error1);
10547 function CssSyntaxError(message, line, column, source, file, plugin22) {
10548 var _this;
10549 _this = Error1.call(this, message) || this;
10550 _this.name = "CssSyntaxError";
10551 _this.reason = message;
10552 if (file) {
10553 _this.file = file;
10554 }
10555 if (source) {
10556 _this.source = source;
10557 }
10558 if (plugin22) {
10559 _this.plugin = plugin22;
10560 }
10561 if (typeof line !== "undefined" && typeof column !== "undefined") {
10562 if (typeof line === "number") {
10563 _this.line = line;
10564 _this.column = column;
10565 } else {
10566 _this.line = line.line;
10567 _this.column = line.column;
10568 _this.endLine = column.line;
10569 _this.endColumn = column.column;
10570 }
10571 }
10572 _this.setMessage();
10573 if (Error.captureStackTrace) {
10574 Error.captureStackTrace(_this, CssSyntaxError);
10575 }
10576 return _this;
10577 }
10578 var _proto = CssSyntaxError.prototype;
10579 _proto.setMessage = function setMessage() {
10580 this.message = this.plugin ? this.plugin + ": " : "";
10581 this.message += this.file ? this.file : "<css input>";
10582 if (typeof this.line !== "undefined") {
10583 this.message += ":" + this.line + ":" + this.column;
10584 }
10585 this.message += ": " + this.reason;
10586 };
10587 _proto.showSourceCode = function showSourceCode(color) {
10588 var _this = this;
10589 if (!this.source) return "";
10590 var css = this.source;
10591 if (color == null) color = pico$1.isColorSupported;
10592 if (terminalHighlight$1$1) {
10593 if (color) css = terminalHighlight$1$1(css);
10594 }
10595 var lines = css.split(/\r?\n/);
10596 var start = Math.max(this.line - 3, 0);
10597 var end = Math.min(this.line + 2, lines.length);
10598 var maxWidth = String(end).length;
10599 var mark, aside;
10600 if (color) {
10601 var _pico$1_createColors = pico$1.createColors(true), bold = _pico$1_createColors.bold, gray = _pico$1_createColors.gray, red = _pico$1_createColors.red;
10602 mark = function(text) {
10603 return bold(red(text));
10604 };
10605 aside = function(text) {
10606 return gray(text);
10607 };
10608 } else {
10609 mark = aside = function(str) {
10610 return str;
10611 };
10612 }
10613 return lines.slice(start, end).map(function(line, index2) {
10614 var number = start + 1 + index2;
10615 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
10616 if (number === _this.line) {
10617 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
10618 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
10619 }
10620 return " " + aside(gutter) + line;
10621 }).join("\n");
10622 };
10623 _proto.toString = function toString() {
10624 var code = this.showSourceCode();
10625 if (code) {
10626 code = "\n\n" + code + "\n";
10627 }
10628 return this.name + ": " + this.message + code;
10629 };
10630 return CssSyntaxError;
10631 }(_wrap_native_super(Error));
10632 var cssSyntaxError$1 = CssSyntaxError$3$1;
10633 CssSyntaxError$3$1.default = CssSyntaxError$3$1;
10634 var symbols$1 = {};
10635 symbols$1.isClean = Symbol("isClean");
10636 symbols$1.my = Symbol("my");
10637 var DEFAULT_RAW$1 = {
10638 after: "\n",
10639 beforeClose: "\n",
10640 beforeComment: "\n",
10641 beforeDecl: "\n",
10642 beforeOpen: " ",
10643 beforeRule: "\n",
10644 colon: ": ",
10645 commentLeft: " ",
10646 commentRight: " ",
10647 emptyBody: "",
10648 indent: " ",
10649 semicolon: false
10650 };
10651 function capitalize$1(str) {
10652 return str[0].toUpperCase() + str.slice(1);
10653 }
10654 var Stringifier$2$1 = /*#__PURE__*/ function() {
10655 function Stringifier(builder) {
10656 this.builder = builder;
10657 }
10658 var _proto = Stringifier.prototype;
10659 _proto.atrule = function atrule(node2, semicolon) {
10660 var name = "@" + node2.name;
10661 var params = node2.params ? this.rawValue(node2, "params") : "";
10662 if (typeof node2.raws.afterName !== "undefined") {
10663 name += node2.raws.afterName;
10664 } else if (params) {
10665 name += " ";
10666 }
10667 if (node2.nodes) {
10668 this.block(node2, name + params);
10669 } else {
10670 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
10671 this.builder(name + params + end, node2);
10672 }
10673 };
10674 _proto.beforeAfter = function beforeAfter(node2, detect) {
10675 var value;
10676 if (node2.type === "decl") {
10677 value = this.raw(node2, null, "beforeDecl");
10678 } else if (node2.type === "comment") {
10679 value = this.raw(node2, null, "beforeComment");
10680 } else if (detect === "before") {
10681 value = this.raw(node2, null, "beforeRule");
10682 } else {
10683 value = this.raw(node2, null, "beforeClose");
10684 }
10685 var buf = node2.parent;
10686 var depth = 0;
10687 while(buf && buf.type !== "root"){
10688 depth += 1;
10689 buf = buf.parent;
10690 }
10691 if (value.includes("\n")) {
10692 var indent = this.raw(node2, null, "indent");
10693 if (indent.length) {
10694 for(var step = 0; step < depth; step++)value += indent;
10695 }
10696 }
10697 return value;
10698 };
10699 _proto.block = function block(node2, start) {
10700 var between = this.raw(node2, "between", "beforeOpen");
10701 this.builder(start + between + "{", node2, "start");
10702 var after;
10703 if (node2.nodes && node2.nodes.length) {
10704 this.body(node2);
10705 after = this.raw(node2, "after");
10706 } else {
10707 after = this.raw(node2, "after", "emptyBody");
10708 }
10709 if (after) this.builder(after);
10710 this.builder("}", node2, "end");
10711 };
10712 _proto.body = function body(node2) {
10713 var last = node2.nodes.length - 1;
10714 while(last > 0){
10715 if (node2.nodes[last].type !== "comment") break;
10716 last -= 1;
10717 }
10718 var semicolon = this.raw(node2, "semicolon");
10719 for(var i2 = 0; i2 < node2.nodes.length; i2++){
10720 var child = node2.nodes[i2];
10721 var before = this.raw(child, "before");
10722 if (before) this.builder(before);
10723 this.stringify(child, last !== i2 || semicolon);
10724 }
10725 };
10726 _proto.comment = function comment(node2) {
10727 var left = this.raw(node2, "left", "commentLeft");
10728 var right = this.raw(node2, "right", "commentRight");
10729 this.builder("/*" + left + node2.text + right + "*/", node2);
10730 };
10731 _proto.decl = function decl(node2, semicolon) {
10732 var between = this.raw(node2, "between", "colon");
10733 var string = node2.prop + between + this.rawValue(node2, "value");
10734 if (node2.important) {
10735 string += node2.raws.important || " !important";
10736 }
10737 if (semicolon) string += ";";
10738 this.builder(string, node2);
10739 };
10740 _proto.document = function document1(node2) {
10741 this.body(node2);
10742 };
10743 _proto.raw = function raw(node2, own, detect) {
10744 var value;
10745 if (!detect) detect = own;
10746 if (own) {
10747 value = node2.raws[own];
10748 if (typeof value !== "undefined") return value;
10749 }
10750 var parent = node2.parent;
10751 if (detect === "before") {
10752 if (!parent || parent.type === "root" && parent.first === node2) {
10753 return "";
10754 }
10755 if (parent && parent.type === "document") {
10756 return "";
10757 }
10758 }
10759 if (!parent) return DEFAULT_RAW$1[detect];
10760 var root2 = node2.root();
10761 if (!root2.rawCache) root2.rawCache = {};
10762 if (typeof root2.rawCache[detect] !== "undefined") {
10763 return root2.rawCache[detect];
10764 }
10765 if (detect === "before" || detect === "after") {
10766 return this.beforeAfter(node2, detect);
10767 } else {
10768 var method = "raw" + capitalize$1(detect);
10769 if (this[method]) {
10770 value = this[method](root2, node2);
10771 } else {
10772 root2.walk(function(i2) {
10773 value = i2.raws[own];
10774 if (typeof value !== "undefined") return false;
10775 });
10776 }
10777 }
10778 if (typeof value === "undefined") value = DEFAULT_RAW$1[detect];
10779 root2.rawCache[detect] = value;
10780 return value;
10781 };
10782 _proto.rawBeforeClose = function rawBeforeClose(root2) {
10783 var value;
10784 root2.walk(function(i2) {
10785 if (i2.nodes && i2.nodes.length > 0) {
10786 if (typeof i2.raws.after !== "undefined") {
10787 value = i2.raws.after;
10788 if (value.includes("\n")) {
10789 value = value.replace(/[^\n]+$/, "");
10790 }
10791 return false;
10792 }
10793 }
10794 });
10795 if (value) value = value.replace(/\S/g, "");
10796 return value;
10797 };
10798 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
10799 var value;
10800 root2.walkComments(function(i2) {
10801 if (typeof i2.raws.before !== "undefined") {
10802 value = i2.raws.before;
10803 if (value.includes("\n")) {
10804 value = value.replace(/[^\n]+$/, "");
10805 }
10806 return false;
10807 }
10808 });
10809 if (typeof value === "undefined") {
10810 value = this.raw(node2, null, "beforeDecl");
10811 } else if (value) {
10812 value = value.replace(/\S/g, "");
10813 }
10814 return value;
10815 };
10816 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
10817 var value;
10818 root2.walkDecls(function(i2) {
10819 if (typeof i2.raws.before !== "undefined") {
10820 value = i2.raws.before;
10821 if (value.includes("\n")) {
10822 value = value.replace(/[^\n]+$/, "");
10823 }
10824 return false;
10825 }
10826 });
10827 if (typeof value === "undefined") {
10828 value = this.raw(node2, null, "beforeRule");
10829 } else if (value) {
10830 value = value.replace(/\S/g, "");
10831 }
10832 return value;
10833 };
10834 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
10835 var value;
10836 root2.walk(function(i2) {
10837 if (i2.type !== "decl") {
10838 value = i2.raws.between;
10839 if (typeof value !== "undefined") return false;
10840 }
10841 });
10842 return value;
10843 };
10844 _proto.rawBeforeRule = function rawBeforeRule(root2) {
10845 var value;
10846 root2.walk(function(i2) {
10847 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
10848 if (typeof i2.raws.before !== "undefined") {
10849 value = i2.raws.before;
10850 if (value.includes("\n")) {
10851 value = value.replace(/[^\n]+$/, "");
10852 }
10853 return false;
10854 }
10855 }
10856 });
10857 if (value) value = value.replace(/\S/g, "");
10858 return value;
10859 };
10860 _proto.rawColon = function rawColon(root2) {
10861 var value;
10862 root2.walkDecls(function(i2) {
10863 if (typeof i2.raws.between !== "undefined") {
10864 value = i2.raws.between.replace(/[^\s:]/g, "");
10865 return false;
10866 }
10867 });
10868 return value;
10869 };
10870 _proto.rawEmptyBody = function rawEmptyBody(root2) {
10871 var value;
10872 root2.walk(function(i2) {
10873 if (i2.nodes && i2.nodes.length === 0) {
10874 value = i2.raws.after;
10875 if (typeof value !== "undefined") return false;
10876 }
10877 });
10878 return value;
10879 };
10880 _proto.rawIndent = function rawIndent(root2) {
10881 if (root2.raws.indent) return root2.raws.indent;
10882 var value;
10883 root2.walk(function(i2) {
10884 var p = i2.parent;
10885 if (p && p !== root2 && p.parent && p.parent === root2) {
10886 if (typeof i2.raws.before !== "undefined") {
10887 var parts = i2.raws.before.split("\n");
10888 value = parts[parts.length - 1];
10889 value = value.replace(/\S/g, "");
10890 return false;
10891 }
10892 }
10893 });
10894 return value;
10895 };
10896 _proto.rawSemicolon = function rawSemicolon(root2) {
10897 var value;
10898 root2.walk(function(i2) {
10899 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
10900 value = i2.raws.semicolon;
10901 if (typeof value !== "undefined") return false;
10902 }
10903 });
10904 return value;
10905 };
10906 _proto.rawValue = function rawValue(node2, prop) {
10907 var value = node2[prop];
10908 var raw = node2.raws[prop];
10909 if (raw && raw.value === value) {
10910 return raw.raw;
10911 }
10912 return value;
10913 };
10914 _proto.root = function root(node2) {
10915 this.body(node2);
10916 if (node2.raws.after) this.builder(node2.raws.after);
10917 };
10918 _proto.rule = function rule(node2) {
10919 this.block(node2, this.rawValue(node2, "selector"));
10920 if (node2.raws.ownSemicolon) {
10921 this.builder(node2.raws.ownSemicolon, node2, "end");
10922 }
10923 };
10924 _proto.stringify = function stringify(node2, semicolon) {
10925 if (!this[node2.type]) {
10926 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
10927 }
10928 this[node2.type](node2, semicolon);
10929 };
10930 return Stringifier;
10931 }();
10932 var stringifier$1 = Stringifier$2$1;
10933 Stringifier$2$1.default = Stringifier$2$1;
10934 var Stringifier$1$1 = stringifier$1;
10935 function stringify$4$1(node2, builder) {
10936 var str = new Stringifier$1$1(builder);
10937 str.stringify(node2);
10938 }
10939 var stringify_1$1 = stringify$4$1;
10940 stringify$4$1.default = stringify$4$1;
10941 var isClean$2$1 = symbols$1.isClean, my$2$1 = symbols$1.my;
10942 var CssSyntaxError$2$1 = cssSyntaxError$1;
10943 var Stringifier2$1 = stringifier$1;
10944 var stringify$3$1 = stringify_1$1;
10945 function cloneNode$1(obj, parent) {
10946 var cloned = new obj.constructor();
10947 for(var i2 in obj){
10948 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
10949 continue;
10950 }
10951 if (i2 === "proxyCache") continue;
10952 var value = obj[i2];
10953 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
10954 if (i2 === "parent" && type === "object") {
10955 if (parent) cloned[i2] = parent;
10956 } else if (i2 === "source") {
10957 cloned[i2] = value;
10958 } else if (Array.isArray(value)) {
10959 cloned[i2] = value.map(function(j) {
10960 return cloneNode$1(j, cloned);
10961 });
10962 } else {
10963 if (type === "object" && value !== null) value = cloneNode$1(value);
10964 cloned[i2] = value;
10965 }
10966 }
10967 return cloned;
10968 }
10969 var Node$4$1 = /*#__PURE__*/ function() {
10970 function Node2(defaults) {
10971 if (defaults === void 0) defaults = {};
10972 this.raws = {};
10973 this[isClean$2$1] = false;
10974 this[my$2$1] = true;
10975 for(var name in defaults){
10976 if (name === "nodes") {
10977 this.nodes = [];
10978 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
10979 var node2 = _step.value;
10980 if (typeof node2.clone === "function") {
10981 this.append(node2.clone());
10982 } else {
10983 this.append(node2);
10984 }
10985 }
10986 } else {
10987 this[name] = defaults[name];
10988 }
10989 }
10990 }
10991 var _proto = Node2.prototype;
10992 _proto.addToError = function addToError(error) {
10993 error.postcssNode = this;
10994 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
10995 var s2 = this.source;
10996 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
10997 }
10998 return error;
10999 };
11000 _proto.after = function after(add) {
11001 this.parent.insertAfter(this, add);
11002 return this;
11003 };
11004 _proto.assign = function assign(overrides) {
11005 if (overrides === void 0) overrides = {};
11006 for(var name in overrides){
11007 this[name] = overrides[name];
11008 }
11009 return this;
11010 };
11011 _proto.before = function before(add) {
11012 this.parent.insertBefore(this, add);
11013 return this;
11014 };
11015 _proto.cleanRaws = function cleanRaws(keepBetween) {
11016 delete this.raws.before;
11017 delete this.raws.after;
11018 if (!keepBetween) delete this.raws.between;
11019 };
11020 _proto.clone = function clone(overrides) {
11021 if (overrides === void 0) overrides = {};
11022 var cloned = cloneNode$1(this);
11023 for(var name in overrides){
11024 cloned[name] = overrides[name];
11025 }
11026 return cloned;
11027 };
11028 _proto.cloneAfter = function cloneAfter(overrides) {
11029 if (overrides === void 0) overrides = {};
11030 var cloned = this.clone(overrides);
11031 this.parent.insertAfter(this, cloned);
11032 return cloned;
11033 };
11034 _proto.cloneBefore = function cloneBefore(overrides) {
11035 if (overrides === void 0) overrides = {};
11036 var cloned = this.clone(overrides);
11037 this.parent.insertBefore(this, cloned);
11038 return cloned;
11039 };
11040 _proto.error = function error(message, opts) {
11041 if (opts === void 0) opts = {};
11042 if (this.source) {
11043 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
11044 return this.source.input.error(message, {
11045 column: start.column,
11046 line: start.line
11047 }, {
11048 column: end.column,
11049 line: end.line
11050 }, opts);
11051 }
11052 return new CssSyntaxError$2$1(message);
11053 };
11054 _proto.getProxyProcessor = function getProxyProcessor() {
11055 return {
11056 get: function get(node2, prop) {
11057 if (prop === "proxyOf") {
11058 return node2;
11059 } else if (prop === "root") {
11060 return function() {
11061 return node2.root().toProxy();
11062 };
11063 } else {
11064 return node2[prop];
11065 }
11066 },
11067 set: function set(node2, prop, value) {
11068 if (node2[prop] === value) return true;
11069 node2[prop] = value;
11070 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
11071 node2.markDirty();
11072 }
11073 return true;
11074 }
11075 };
11076 };
11077 _proto.markDirty = function markDirty() {
11078 if (this[isClean$2$1]) {
11079 this[isClean$2$1] = false;
11080 var next = this;
11081 while(next = next.parent){
11082 next[isClean$2$1] = false;
11083 }
11084 }
11085 };
11086 _proto.next = function next() {
11087 if (!this.parent) return void 0;
11088 var index2 = this.parent.index(this);
11089 return this.parent.nodes[index2 + 1];
11090 };
11091 _proto.positionBy = function positionBy(opts, stringRepresentation) {
11092 var pos = this.source.start;
11093 if (opts.index) {
11094 pos = this.positionInside(opts.index, stringRepresentation);
11095 } else if (opts.word) {
11096 stringRepresentation = this.toString();
11097 var index2 = stringRepresentation.indexOf(opts.word);
11098 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
11099 }
11100 return pos;
11101 };
11102 _proto.positionInside = function positionInside(index2, stringRepresentation) {
11103 var string = stringRepresentation || this.toString();
11104 var column = this.source.start.column;
11105 var line = this.source.start.line;
11106 for(var i2 = 0; i2 < index2; i2++){
11107 if (string[i2] === "\n") {
11108 column = 1;
11109 line += 1;
11110 } else {
11111 column += 1;
11112 }
11113 }
11114 return {
11115 column: column,
11116 line: line
11117 };
11118 };
11119 _proto.prev = function prev() {
11120 if (!this.parent) return void 0;
11121 var index2 = this.parent.index(this);
11122 return this.parent.nodes[index2 - 1];
11123 };
11124 _proto.rangeBy = function rangeBy(opts) {
11125 var start = {
11126 column: this.source.start.column,
11127 line: this.source.start.line
11128 };
11129 var end = this.source.end ? {
11130 column: this.source.end.column + 1,
11131 line: this.source.end.line
11132 } : {
11133 column: start.column + 1,
11134 line: start.line
11135 };
11136 if (opts.word) {
11137 var stringRepresentation = this.toString();
11138 var index2 = stringRepresentation.indexOf(opts.word);
11139 if (index2 !== -1) {
11140 start = this.positionInside(index2, stringRepresentation);
11141 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
11142 }
11143 } else {
11144 if (opts.start) {
11145 start = {
11146 column: opts.start.column,
11147 line: opts.start.line
11148 };
11149 } else if (opts.index) {
11150 start = this.positionInside(opts.index);
11151 }
11152 if (opts.end) {
11153 end = {
11154 column: opts.end.column,
11155 line: opts.end.line
11156 };
11157 } else if (typeof opts.endIndex === "number") {
11158 end = this.positionInside(opts.endIndex);
11159 } else if (opts.index) {
11160 end = this.positionInside(opts.index + 1);
11161 }
11162 }
11163 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
11164 end = {
11165 column: start.column + 1,
11166 line: start.line
11167 };
11168 }
11169 return {
11170 end: end,
11171 start: start
11172 };
11173 };
11174 _proto.raw = function raw(prop, defaultType) {
11175 var str = new Stringifier2$1();
11176 return str.raw(this, prop, defaultType);
11177 };
11178 _proto.remove = function remove() {
11179 if (this.parent) {
11180 this.parent.removeChild(this);
11181 }
11182 this.parent = void 0;
11183 return this;
11184 };
11185 _proto.replaceWith = function replaceWith() {
11186 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
11187 nodes[_key] = arguments[_key];
11188 }
11189 if (this.parent) {
11190 var bookmark = this;
11191 var foundSelf = false;
11192 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11193 var node2 = _step.value;
11194 if (node2 === this) {
11195 foundSelf = true;
11196 } else if (foundSelf) {
11197 this.parent.insertAfter(bookmark, node2);
11198 bookmark = node2;
11199 } else {
11200 this.parent.insertBefore(bookmark, node2);
11201 }
11202 }
11203 if (!foundSelf) {
11204 this.remove();
11205 }
11206 }
11207 return this;
11208 };
11209 _proto.root = function root() {
11210 var result2 = this;
11211 while(result2.parent && result2.parent.type !== "document"){
11212 result2 = result2.parent;
11213 }
11214 return result2;
11215 };
11216 _proto.toJSON = function toJSON(_, inputs) {
11217 var fixed = {};
11218 var emitInputs = inputs == null;
11219 inputs = inputs || /* @__PURE__ */ new Map();
11220 var inputsNextIndex = 0;
11221 for(var name in this){
11222 if (!Object.prototype.hasOwnProperty.call(this, name)) {
11223 continue;
11224 }
11225 if (name === "parent" || name === "proxyCache") continue;
11226 var value = this[name];
11227 if (Array.isArray(value)) {
11228 fixed[name] = value.map(function(i2) {
11229 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
11230 return i2.toJSON(null, inputs);
11231 } else {
11232 return i2;
11233 }
11234 });
11235 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
11236 fixed[name] = value.toJSON(null, inputs);
11237 } else if (name === "source") {
11238 var inputId = inputs.get(value.input);
11239 if (inputId == null) {
11240 inputId = inputsNextIndex;
11241 inputs.set(value.input, inputsNextIndex);
11242 inputsNextIndex++;
11243 }
11244 fixed[name] = {
11245 end: value.end,
11246 inputId: inputId,
11247 start: value.start
11248 };
11249 } else {
11250 fixed[name] = value;
11251 }
11252 }
11253 if (emitInputs) {
11254 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
11255 return input2.toJSON();
11256 });
11257 }
11258 return fixed;
11259 };
11260 _proto.toProxy = function toProxy() {
11261 if (!this.proxyCache) {
11262 this.proxyCache = new Proxy(this, this.getProxyProcessor());
11263 }
11264 return this.proxyCache;
11265 };
11266 _proto.toString = function toString(stringifier2) {
11267 if (stringifier2 === void 0) stringifier2 = stringify$3$1;
11268 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
11269 var result2 = "";
11270 stringifier2(this, function(i2) {
11271 result2 += i2;
11272 });
11273 return result2;
11274 };
11275 _proto.warn = function warn(result2, text, opts) {
11276 var data = {
11277 node: this
11278 };
11279 for(var i2 in opts)data[i2] = opts[i2];
11280 return result2.warn(text, data);
11281 };
11282 _create_class(Node2, [
11283 {
11284 key: "proxyOf",
11285 get: function get() {
11286 return this;
11287 }
11288 }
11289 ]);
11290 return Node2;
11291 }();
11292 var node$1 = Node$4$1;
11293 Node$4$1.default = Node$4$1;
11294 var Node$3$1 = node$1;
11295 var Declaration$4$1 = /*#__PURE__*/ function(Node$3$1) {
11296 _inherits(Declaration, Node$3$1);
11297 function Declaration(defaults) {
11298 var _this;
11299 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
11300 defaults = _extends({}, defaults, {
11301 value: String(defaults.value)
11302 });
11303 }
11304 _this = Node$3$1.call(this, defaults) || this;
11305 _this.type = "decl";
11306 return _this;
11307 }
11308 _create_class(Declaration, [
11309 {
11310 key: "variable",
11311 get: function get() {
11312 return this.prop.startsWith("--") || this.prop[0] === "$";
11313 }
11314 }
11315 ]);
11316 return Declaration;
11317 }(Node$3$1);
11318 var declaration$1 = Declaration$4$1;
11319 Declaration$4$1.default = Declaration$4$1;
11320 var urlAlphabet$1 = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
11321 var nanoid$1$1 = function(size) {
11322 if (size === void 0) size = 21;
11323 var id = "";
11324 var i2 = size;
11325 while(i2--){
11326 id += urlAlphabet$1[Math.random() * 64 | 0];
11327 }
11328 return id;
11329 };
11330 var nonSecure$1 = {
11331 nanoid: nanoid$1$1};
11332 var SourceMapConsumer$2$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$2$1 = require$$2$1.SourceMapGenerator;
11333 var existsSync$1 = require$$2$1.existsSync, readFileSync$1 = require$$2$1.readFileSync;
11334 var dirname$1$1 = require$$2$1.dirname, join$1 = require$$2$1.join;
11335 function fromBase64$1(str) {
11336 if (Buffer) {
11337 return Buffer.from(str, "base64").toString();
11338 } else {
11339 return window.atob(str);
11340 }
11341 }
11342 var PreviousMap$2$1 = /*#__PURE__*/ function() {
11343 function PreviousMap(css, opts) {
11344 if (opts.map === false) return;
11345 this.loadAnnotation(css);
11346 this.inline = this.startWith(this.annotation, "data:");
11347 var prev = opts.map ? opts.map.prev : void 0;
11348 var text = this.loadMap(opts.from, prev);
11349 if (!this.mapFile && opts.from) {
11350 this.mapFile = opts.from;
11351 }
11352 if (this.mapFile) this.root = dirname$1$1(this.mapFile);
11353 if (text) this.text = text;
11354 }
11355 var _proto = PreviousMap.prototype;
11356 _proto.consumer = function consumer() {
11357 if (!this.consumerCache) {
11358 this.consumerCache = new SourceMapConsumer$2$1(this.text);
11359 }
11360 return this.consumerCache;
11361 };
11362 _proto.decodeInline = function decodeInline(text) {
11363 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
11364 var baseUri = /^data:application\/json;base64,/;
11365 var charsetUri = /^data:application\/json;charset=utf-?8,/;
11366 var uri = /^data:application\/json,/;
11367 if (charsetUri.test(text) || uri.test(text)) {
11368 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
11369 }
11370 if (baseCharsetUri.test(text) || baseUri.test(text)) {
11371 return fromBase64$1(text.substr(RegExp.lastMatch.length));
11372 }
11373 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
11374 throw new Error("Unsupported source map encoding " + encoding);
11375 };
11376 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
11377 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
11378 };
11379 _proto.isMap = function isMap(map) {
11380 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
11381 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
11382 };
11383 _proto.loadAnnotation = function loadAnnotation(css) {
11384 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
11385 if (!comments) return;
11386 var start = css.lastIndexOf(comments.pop());
11387 var end = css.indexOf("*/", start);
11388 if (start > -1 && end > -1) {
11389 this.annotation = this.getAnnotationURL(css.substring(start, end));
11390 }
11391 };
11392 _proto.loadFile = function loadFile(path) {
11393 this.root = dirname$1$1(path);
11394 if (existsSync$1(path)) {
11395 this.mapFile = path;
11396 return readFileSync$1(path, "utf-8").toString().trim();
11397 }
11398 };
11399 _proto.loadMap = function loadMap(file, prev) {
11400 if (prev === false) return false;
11401 if (prev) {
11402 if (typeof prev === "string") {
11403 return prev;
11404 } else if (typeof prev === "function") {
11405 var prevPath = prev(file);
11406 if (prevPath) {
11407 var map = this.loadFile(prevPath);
11408 if (!map) {
11409 throw new Error("Unable to load previous source map: " + prevPath.toString());
11410 }
11411 return map;
11412 }
11413 } else if (_instanceof(prev, SourceMapConsumer$2$1)) {
11414 return SourceMapGenerator$2$1.fromSourceMap(prev).toString();
11415 } else if (_instanceof(prev, SourceMapGenerator$2$1)) {
11416 return prev.toString();
11417 } else if (this.isMap(prev)) {
11418 return JSON.stringify(prev);
11419 } else {
11420 throw new Error("Unsupported previous source map format: " + prev.toString());
11421 }
11422 } else if (this.inline) {
11423 return this.decodeInline(this.annotation);
11424 } else if (this.annotation) {
11425 var map1 = this.annotation;
11426 if (file) map1 = join$1(dirname$1$1(file), map1);
11427 return this.loadFile(map1);
11428 }
11429 };
11430 _proto.startWith = function startWith(string, start) {
11431 if (!string) return false;
11432 return string.substr(0, start.length) === start;
11433 };
11434 _proto.withContent = function withContent() {
11435 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
11436 };
11437 return PreviousMap;
11438 }();
11439 var previousMap$1 = PreviousMap$2$1;
11440 PreviousMap$2$1.default = PreviousMap$2$1;
11441 var SourceMapConsumer$1$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$1$1 = require$$2$1.SourceMapGenerator;
11442 var fileURLToPath$1 = require$$2$1.fileURLToPath, pathToFileURL$1$1 = require$$2$1.pathToFileURL;
11443 var isAbsolute$1 = require$$2$1.isAbsolute, resolve$1$1 = require$$2$1.resolve;
11444 var nanoid$2 = nonSecure$1.nanoid;
11445 var terminalHighlight$2 = require$$2$1;
11446 var CssSyntaxError$1$1 = cssSyntaxError$1;
11447 var PreviousMap$1$1 = previousMap$1;
11448 var fromOffsetCache$1 = Symbol("fromOffsetCache");
11449 var sourceMapAvailable$1$1 = Boolean(SourceMapConsumer$1$1 && SourceMapGenerator$1$1);
11450 var pathAvailable$1$1 = Boolean(resolve$1$1 && isAbsolute$1);
11451 var Input$4$1 = /*#__PURE__*/ function() {
11452 function Input(css, opts) {
11453 if (opts === void 0) opts = {};
11454 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
11455 throw new Error("PostCSS received " + css + " instead of CSS string");
11456 }
11457 this.css = css.toString();
11458 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
11459 this.hasBOM = true;
11460 this.css = this.css.slice(1);
11461 } else {
11462 this.hasBOM = false;
11463 }
11464 if (opts.from) {
11465 if (!pathAvailable$1$1 || /^\w+:\/\//.test(opts.from) || isAbsolute$1(opts.from)) {
11466 this.file = opts.from;
11467 } else {
11468 this.file = resolve$1$1(opts.from);
11469 }
11470 }
11471 if (pathAvailable$1$1 && sourceMapAvailable$1$1) {
11472 var map = new PreviousMap$1$1(this.css, opts);
11473 if (map.text) {
11474 this.map = map;
11475 var file = map.consumer().file;
11476 if (!this.file && file) this.file = this.mapResolve(file);
11477 }
11478 }
11479 if (!this.file) {
11480 this.id = "<input css " + nanoid$2(6) + ">";
11481 }
11482 if (this.map) this.map.file = this.from;
11483 }
11484 var _proto = Input.prototype;
11485 _proto.error = function error(message, line, column, opts) {
11486 if (opts === void 0) opts = {};
11487 var result2, endLine, endColumn;
11488 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
11489 var start = line;
11490 var end = column;
11491 if (typeof start.offset === "number") {
11492 var pos = this.fromOffset(start.offset);
11493 line = pos.line;
11494 column = pos.col;
11495 } else {
11496 line = start.line;
11497 column = start.column;
11498 }
11499 if (typeof end.offset === "number") {
11500 var pos1 = this.fromOffset(end.offset);
11501 endLine = pos1.line;
11502 endColumn = pos1.col;
11503 } else {
11504 endLine = end.line;
11505 endColumn = end.column;
11506 }
11507 } else if (!column) {
11508 var pos2 = this.fromOffset(line);
11509 line = pos2.line;
11510 column = pos2.col;
11511 }
11512 var origin = this.origin(line, column, endLine, endColumn);
11513 if (origin) {
11514 result2 = new CssSyntaxError$1$1(message, origin.endLine === void 0 ? origin.line : {
11515 column: origin.column,
11516 line: origin.line
11517 }, origin.endLine === void 0 ? origin.column : {
11518 column: origin.endColumn,
11519 line: origin.endLine
11520 }, origin.source, origin.file, opts.plugin);
11521 } else {
11522 result2 = new CssSyntaxError$1$1(message, endLine === void 0 ? line : {
11523 column: column,
11524 line: line
11525 }, endLine === void 0 ? column : {
11526 column: endColumn,
11527 line: endLine
11528 }, this.css, this.file, opts.plugin);
11529 }
11530 result2.input = {
11531 column: column,
11532 endColumn: endColumn,
11533 endLine: endLine,
11534 line: line,
11535 source: this.css
11536 };
11537 if (this.file) {
11538 if (pathToFileURL$1$1) {
11539 result2.input.url = pathToFileURL$1$1(this.file).toString();
11540 }
11541 result2.input.file = this.file;
11542 }
11543 return result2;
11544 };
11545 _proto.fromOffset = function fromOffset(offset) {
11546 var lastLine, lineToIndex;
11547 if (!this[fromOffsetCache$1]) {
11548 var lines = this.css.split("\n");
11549 lineToIndex = new Array(lines.length);
11550 var prevIndex = 0;
11551 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
11552 lineToIndex[i2] = prevIndex;
11553 prevIndex += lines[i2].length + 1;
11554 }
11555 this[fromOffsetCache$1] = lineToIndex;
11556 } else {
11557 lineToIndex = this[fromOffsetCache$1];
11558 }
11559 lastLine = lineToIndex[lineToIndex.length - 1];
11560 var min = 0;
11561 if (offset >= lastLine) {
11562 min = lineToIndex.length - 1;
11563 } else {
11564 var max = lineToIndex.length - 2;
11565 var mid;
11566 while(min < max){
11567 mid = min + (max - min >> 1);
11568 if (offset < lineToIndex[mid]) {
11569 max = mid - 1;
11570 } else if (offset >= lineToIndex[mid + 1]) {
11571 min = mid + 1;
11572 } else {
11573 min = mid;
11574 break;
11575 }
11576 }
11577 }
11578 return {
11579 col: offset - lineToIndex[min] + 1,
11580 line: min + 1
11581 };
11582 };
11583 _proto.mapResolve = function mapResolve(file) {
11584 if (/^\w+:\/\//.test(file)) {
11585 return file;
11586 }
11587 return resolve$1$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
11588 };
11589 _proto.origin = function origin(line, column, endLine, endColumn) {
11590 if (!this.map) return false;
11591 var consumer = this.map.consumer();
11592 var from = consumer.originalPositionFor({
11593 column: column,
11594 line: line
11595 });
11596 if (!from.source) return false;
11597 var to;
11598 if (typeof endLine === "number") {
11599 to = consumer.originalPositionFor({
11600 column: endColumn,
11601 line: endLine
11602 });
11603 }
11604 var fromUrl;
11605 if (isAbsolute$1(from.source)) {
11606 fromUrl = pathToFileURL$1$1(from.source);
11607 } else {
11608 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1$1(this.map.mapFile));
11609 }
11610 var result2 = {
11611 column: from.column,
11612 endColumn: to && to.column,
11613 endLine: to && to.line,
11614 line: from.line,
11615 url: fromUrl.toString()
11616 };
11617 if (fromUrl.protocol === "file:") {
11618 if (fileURLToPath$1) {
11619 result2.file = fileURLToPath$1(fromUrl);
11620 } else {
11621 throw new Error("file: protocol is not available in this PostCSS build");
11622 }
11623 }
11624 var source = consumer.sourceContentFor(from.source);
11625 if (source) result2.source = source;
11626 return result2;
11627 };
11628 _proto.toJSON = function toJSON() {
11629 var json = {};
11630 for(var _i = 0, _iter = [
11631 "hasBOM",
11632 "css",
11633 "file",
11634 "id"
11635 ]; _i < _iter.length; _i++){
11636 var name = _iter[_i];
11637 if (this[name] != null) {
11638 json[name] = this[name];
11639 }
11640 }
11641 if (this.map) {
11642 json.map = _extends({}, this.map);
11643 if (json.map.consumerCache) {
11644 json.map.consumerCache = void 0;
11645 }
11646 }
11647 return json;
11648 };
11649 _create_class(Input, [
11650 {
11651 key: "from",
11652 get: function get() {
11653 return this.file || this.id;
11654 }
11655 }
11656 ]);
11657 return Input;
11658 }();
11659 var input$1 = Input$4$1;
11660 Input$4$1.default = Input$4$1;
11661 if (terminalHighlight$2 && terminalHighlight$2.registerInput) {
11662 terminalHighlight$2.registerInput(Input$4$1);
11663 }
11664 var SourceMapConsumer$3 = require$$2$1.SourceMapConsumer, SourceMapGenerator$3 = require$$2$1.SourceMapGenerator;
11665 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;
11666 var pathToFileURL$2 = require$$2$1.pathToFileURL;
11667 var Input$3$1 = input$1;
11668 var sourceMapAvailable$2 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$3);
11669 var pathAvailable$2 = Boolean(dirname$2 && resolve$2 && relative$1 && sep$1);
11670 var MapGenerator$2$1 = /*#__PURE__*/ function() {
11671 function MapGenerator(stringify2, root2, opts, cssString) {
11672 this.stringify = stringify2;
11673 this.mapOpts = opts.map || {};
11674 this.root = root2;
11675 this.opts = opts;
11676 this.css = cssString;
11677 this.originalCSS = cssString;
11678 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
11679 this.memoizedFileURLs = /* @__PURE__ */ new Map();
11680 this.memoizedPaths = /* @__PURE__ */ new Map();
11681 this.memoizedURLs = /* @__PURE__ */ new Map();
11682 }
11683 var _proto = MapGenerator.prototype;
11684 _proto.addAnnotation = function addAnnotation() {
11685 var content;
11686 if (this.isInline()) {
11687 content = "data:application/json;base64," + this.toBase64(this.map.toString());
11688 } else if (typeof this.mapOpts.annotation === "string") {
11689 content = this.mapOpts.annotation;
11690 } else if (typeof this.mapOpts.annotation === "function") {
11691 content = this.mapOpts.annotation(this.opts.to, this.root);
11692 } else {
11693 content = this.outputFile() + ".map";
11694 }
11695 var eol = "\n";
11696 if (this.css.includes("\r\n")) eol = "\r\n";
11697 this.css += eol + "/*# sourceMappingURL=" + content + " */";
11698 };
11699 _proto.applyPrevMaps = function applyPrevMaps() {
11700 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
11701 var prev = _step.value;
11702 var from = this.toUrl(this.path(prev.file));
11703 var root2 = prev.root || dirname$2(prev.file);
11704 var map = void 0;
11705 if (this.mapOpts.sourcesContent === false) {
11706 map = new SourceMapConsumer$3(prev.text);
11707 if (map.sourcesContent) {
11708 map.sourcesContent = null;
11709 }
11710 } else {
11711 map = prev.consumer();
11712 }
11713 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
11714 }
11715 };
11716 _proto.clearAnnotation = function clearAnnotation() {
11717 if (this.mapOpts.annotation === false) return;
11718 if (this.root) {
11719 var node2;
11720 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
11721 node2 = this.root.nodes[i2];
11722 if (node2.type !== "comment") continue;
11723 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
11724 this.root.removeChild(i2);
11725 }
11726 }
11727 } else if (this.css) {
11728 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
11729 }
11730 };
11731 _proto.generate = function generate() {
11732 this.clearAnnotation();
11733 if (pathAvailable$2 && sourceMapAvailable$2 && this.isMap()) {
11734 return this.generateMap();
11735 } else {
11736 var result2 = "";
11737 this.stringify(this.root, function(i2) {
11738 result2 += i2;
11739 });
11740 return [
11741 result2
11742 ];
11743 }
11744 };
11745 _proto.generateMap = function generateMap() {
11746 if (this.root) {
11747 this.generateString();
11748 } else if (this.previous().length === 1) {
11749 var prev = this.previous()[0].consumer();
11750 prev.file = this.outputFile();
11751 this.map = SourceMapGenerator$3.fromSourceMap(prev, {
11752 ignoreInvalidMapping: true
11753 });
11754 } else {
11755 this.map = new SourceMapGenerator$3({
11756 file: this.outputFile(),
11757 ignoreInvalidMapping: true
11758 });
11759 this.map.addMapping({
11760 generated: {
11761 column: 0,
11762 line: 1
11763 },
11764 original: {
11765 column: 0,
11766 line: 1
11767 },
11768 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
11769 });
11770 }
11771 if (this.isSourcesContent()) this.setSourcesContent();
11772 if (this.root && this.previous().length > 0) this.applyPrevMaps();
11773 if (this.isAnnotation()) this.addAnnotation();
11774 if (this.isInline()) {
11775 return [
11776 this.css
11777 ];
11778 } else {
11779 return [
11780 this.css,
11781 this.map
11782 ];
11783 }
11784 };
11785 _proto.generateString = function generateString() {
11786 var _this = this;
11787 this.css = "";
11788 this.map = new SourceMapGenerator$3({
11789 file: this.outputFile(),
11790 ignoreInvalidMapping: true
11791 });
11792 var line = 1;
11793 var column = 1;
11794 var noSource = "<no source>";
11795 var mapping = {
11796 generated: {
11797 column: 0,
11798 line: 0
11799 },
11800 original: {
11801 column: 0,
11802 line: 0
11803 },
11804 source: ""
11805 };
11806 var lines, last;
11807 this.stringify(this.root, function(str, node2, type) {
11808 _this.css += str;
11809 if (node2 && type !== "end") {
11810 mapping.generated.line = line;
11811 mapping.generated.column = column - 1;
11812 if (node2.source && node2.source.start) {
11813 mapping.source = _this.sourcePath(node2);
11814 mapping.original.line = node2.source.start.line;
11815 mapping.original.column = node2.source.start.column - 1;
11816 _this.map.addMapping(mapping);
11817 } else {
11818 mapping.source = noSource;
11819 mapping.original.line = 1;
11820 mapping.original.column = 0;
11821 _this.map.addMapping(mapping);
11822 }
11823 }
11824 lines = str.match(/\n/g);
11825 if (lines) {
11826 line += lines.length;
11827 last = str.lastIndexOf("\n");
11828 column = str.length - last;
11829 } else {
11830 column += str.length;
11831 }
11832 if (node2 && type !== "start") {
11833 var p = node2.parent || {
11834 raws: {}
11835 };
11836 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
11837 if (!childless || node2 !== p.last || p.raws.semicolon) {
11838 if (node2.source && node2.source.end) {
11839 mapping.source = _this.sourcePath(node2);
11840 mapping.original.line = node2.source.end.line;
11841 mapping.original.column = node2.source.end.column - 1;
11842 mapping.generated.line = line;
11843 mapping.generated.column = column - 2;
11844 _this.map.addMapping(mapping);
11845 } else {
11846 mapping.source = noSource;
11847 mapping.original.line = 1;
11848 mapping.original.column = 0;
11849 mapping.generated.line = line;
11850 mapping.generated.column = column - 1;
11851 _this.map.addMapping(mapping);
11852 }
11853 }
11854 }
11855 });
11856 };
11857 _proto.isAnnotation = function isAnnotation() {
11858 if (this.isInline()) {
11859 return true;
11860 }
11861 if (typeof this.mapOpts.annotation !== "undefined") {
11862 return this.mapOpts.annotation;
11863 }
11864 if (this.previous().length) {
11865 return this.previous().some(function(i2) {
11866 return i2.annotation;
11867 });
11868 }
11869 return true;
11870 };
11871 _proto.isInline = function isInline() {
11872 if (typeof this.mapOpts.inline !== "undefined") {
11873 return this.mapOpts.inline;
11874 }
11875 var annotation = this.mapOpts.annotation;
11876 if (typeof annotation !== "undefined" && annotation !== true) {
11877 return false;
11878 }
11879 if (this.previous().length) {
11880 return this.previous().some(function(i2) {
11881 return i2.inline;
11882 });
11883 }
11884 return true;
11885 };
11886 _proto.isMap = function isMap() {
11887 if (typeof this.opts.map !== "undefined") {
11888 return !!this.opts.map;
11889 }
11890 return this.previous().length > 0;
11891 };
11892 _proto.isSourcesContent = function isSourcesContent() {
11893 if (typeof this.mapOpts.sourcesContent !== "undefined") {
11894 return this.mapOpts.sourcesContent;
11895 }
11896 if (this.previous().length) {
11897 return this.previous().some(function(i2) {
11898 return i2.withContent();
11899 });
11900 }
11901 return true;
11902 };
11903 _proto.outputFile = function outputFile() {
11904 if (this.opts.to) {
11905 return this.path(this.opts.to);
11906 } else if (this.opts.from) {
11907 return this.path(this.opts.from);
11908 } else {
11909 return "to.css";
11910 }
11911 };
11912 _proto.path = function path(file) {
11913 if (this.mapOpts.absolute) return file;
11914 if (file.charCodeAt(0) === 60) return file;
11915 if (/^\w+:\/\//.test(file)) return file;
11916 var cached = this.memoizedPaths.get(file);
11917 if (cached) return cached;
11918 var from = this.opts.to ? dirname$2(this.opts.to) : ".";
11919 if (typeof this.mapOpts.annotation === "string") {
11920 from = dirname$2(resolve$2(from, this.mapOpts.annotation));
11921 }
11922 var path = relative$1(from, file);
11923 this.memoizedPaths.set(file, path);
11924 return path;
11925 };
11926 _proto.previous = function previous() {
11927 var _this = this;
11928 if (!this.previousMaps) {
11929 this.previousMaps = [];
11930 if (this.root) {
11931 this.root.walk(function(node2) {
11932 if (node2.source && node2.source.input.map) {
11933 var map = node2.source.input.map;
11934 if (!_this.previousMaps.includes(map)) {
11935 _this.previousMaps.push(map);
11936 }
11937 }
11938 });
11939 } else {
11940 var input2 = new Input$3$1(this.originalCSS, this.opts);
11941 if (input2.map) this.previousMaps.push(input2.map);
11942 }
11943 }
11944 return this.previousMaps;
11945 };
11946 _proto.setSourcesContent = function setSourcesContent() {
11947 var _this = this;
11948 var already = {};
11949 if (this.root) {
11950 this.root.walk(function(node2) {
11951 if (node2.source) {
11952 var from = node2.source.input.from;
11953 if (from && !already[from]) {
11954 already[from] = true;
11955 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
11956 _this.map.setSourceContent(fromUrl, node2.source.input.css);
11957 }
11958 }
11959 });
11960 } else if (this.css) {
11961 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
11962 this.map.setSourceContent(from, this.css);
11963 }
11964 };
11965 _proto.sourcePath = function sourcePath(node2) {
11966 if (this.mapOpts.from) {
11967 return this.toUrl(this.mapOpts.from);
11968 } else if (this.usesFileUrls) {
11969 return this.toFileUrl(node2.source.input.from);
11970 } else {
11971 return this.toUrl(this.path(node2.source.input.from));
11972 }
11973 };
11974 _proto.toBase64 = function toBase64(str) {
11975 if (Buffer) {
11976 return Buffer.from(str).toString("base64");
11977 } else {
11978 return window.btoa(unescape(encodeURIComponent(str)));
11979 }
11980 };
11981 _proto.toFileUrl = function toFileUrl(path) {
11982 var cached = this.memoizedFileURLs.get(path);
11983 if (cached) return cached;
11984 if (pathToFileURL$2) {
11985 var fileURL = pathToFileURL$2(path).toString();
11986 this.memoizedFileURLs.set(path, fileURL);
11987 return fileURL;
11988 } else {
11989 throw new Error("`map.absolute` option is not available in this PostCSS build");
11990 }
11991 };
11992 _proto.toUrl = function toUrl(path) {
11993 var cached = this.memoizedURLs.get(path);
11994 if (cached) return cached;
11995 if (sep$1 === "\\") {
11996 path = path.replace(/\\/g, "/");
11997 }
11998 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
11999 this.memoizedURLs.set(path, url);
12000 return url;
12001 };
12002 return MapGenerator;
12003 }();
12004 var mapGenerator$1 = MapGenerator$2$1;
12005 var Node$2$1 = node$1;
12006 var Comment$4$1 = /*#__PURE__*/ function(Node$2$1) {
12007 _inherits(Comment, Node$2$1);
12008 function Comment(defaults) {
12009 var _this;
12010 _this = Node$2$1.call(this, defaults) || this;
12011 _this.type = "comment";
12012 return _this;
12013 }
12014 return Comment;
12015 }(Node$2$1);
12016 var comment$1 = Comment$4$1;
12017 Comment$4$1.default = Comment$4$1;
12018 var isClean$1$1 = symbols$1.isClean, my$1$1 = symbols$1.my;
12019 var Declaration$3$1 = declaration$1;
12020 var Comment$3$1 = comment$1;
12021 var Node$1$1 = node$1;
12022 var parse$4$1, Rule$4$1, AtRule$4$1, Root$6$1;
12023 function cleanSource$1(nodes) {
12024 return nodes.map(function(i2) {
12025 if (i2.nodes) i2.nodes = cleanSource$1(i2.nodes);
12026 delete i2.source;
12027 return i2;
12028 });
12029 }
12030 function markDirtyUp$1(node2) {
12031 node2[isClean$1$1] = false;
12032 if (node2.proxyOf.nodes) {
12033 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
12034 var i2 = _step.value;
12035 markDirtyUp$1(i2);
12036 }
12037 }
12038 }
12039 var Container$7$1 = /*#__PURE__*/ function(Node$1$1) {
12040 _inherits(Container, Node$1$1);
12041 function Container() {
12042 return Node$1$1.apply(this, arguments) || this;
12043 }
12044 var _proto = Container.prototype;
12045 _proto.append = function append() {
12046 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12047 children[_key] = arguments[_key];
12048 }
12049 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
12050 var child = _step.value;
12051 var nodes = this.normalize(child, this.last);
12052 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12053 var node2 = _step1.value;
12054 this.proxyOf.nodes.push(node2);
12055 }
12056 }
12057 this.markDirty();
12058 return this;
12059 };
12060 _proto.cleanRaws = function cleanRaws(keepBetween) {
12061 Node$1$1.prototype.cleanRaws.call(this, keepBetween);
12062 if (this.nodes) {
12063 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
12064 var node2 = _step.value;
12065 node2.cleanRaws(keepBetween);
12066 }
12067 }
12068 };
12069 _proto.each = function each(callback) {
12070 if (!this.proxyOf.nodes) return void 0;
12071 var iterator = this.getIterator();
12072 var index2, result2;
12073 while(this.indexes[iterator] < this.proxyOf.nodes.length){
12074 index2 = this.indexes[iterator];
12075 result2 = callback(this.proxyOf.nodes[index2], index2);
12076 if (result2 === false) break;
12077 this.indexes[iterator] += 1;
12078 }
12079 delete this.indexes[iterator];
12080 return result2;
12081 };
12082 _proto.every = function every(condition) {
12083 return this.nodes.every(condition);
12084 };
12085 _proto.getIterator = function getIterator() {
12086 if (!this.lastEach) this.lastEach = 0;
12087 if (!this.indexes) this.indexes = {};
12088 this.lastEach += 1;
12089 var iterator = this.lastEach;
12090 this.indexes[iterator] = 0;
12091 return iterator;
12092 };
12093 _proto.getProxyProcessor = function getProxyProcessor() {
12094 return {
12095 get: function get(node2, prop) {
12096 if (prop === "proxyOf") {
12097 return node2;
12098 } else if (!node2[prop]) {
12099 return node2[prop];
12100 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
12101 return function() {
12102 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
12103 args[_key] = arguments[_key];
12104 }
12105 var _node2;
12106 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
12107 if (typeof i2 === "function") {
12108 return function(child, index2) {
12109 return i2(child.toProxy(), index2);
12110 };
12111 } else {
12112 return i2;
12113 }
12114 })));
12115 };
12116 } else if (prop === "every" || prop === "some") {
12117 return function(cb) {
12118 return node2[prop](function(child) {
12119 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
12120 other[_key - 1] = arguments[_key];
12121 }
12122 return cb.apply(void 0, [].concat([
12123 child.toProxy()
12124 ], other));
12125 });
12126 };
12127 } else if (prop === "root") {
12128 return function() {
12129 return node2.root().toProxy();
12130 };
12131 } else if (prop === "nodes") {
12132 return node2.nodes.map(function(i2) {
12133 return i2.toProxy();
12134 });
12135 } else if (prop === "first" || prop === "last") {
12136 return node2[prop].toProxy();
12137 } else {
12138 return node2[prop];
12139 }
12140 },
12141 set: function set(node2, prop, value) {
12142 if (node2[prop] === value) return true;
12143 node2[prop] = value;
12144 if (prop === "name" || prop === "params" || prop === "selector") {
12145 node2.markDirty();
12146 }
12147 return true;
12148 }
12149 };
12150 };
12151 _proto.index = function index(child) {
12152 if (typeof child === "number") return child;
12153 if (child.proxyOf) child = child.proxyOf;
12154 return this.proxyOf.nodes.indexOf(child);
12155 };
12156 _proto.insertAfter = function insertAfter(exist, add) {
12157 var existIndex = this.index(exist);
12158 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
12159 existIndex = this.index(exist);
12160 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12161 var node2 = _step.value;
12162 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
12163 }
12164 var index2;
12165 for(var id in this.indexes){
12166 index2 = this.indexes[id];
12167 if (existIndex < index2) {
12168 this.indexes[id] = index2 + nodes.length;
12169 }
12170 }
12171 this.markDirty();
12172 return this;
12173 };
12174 _proto.insertBefore = function insertBefore(exist, add) {
12175 var existIndex = this.index(exist);
12176 var type = existIndex === 0 ? "prepend" : false;
12177 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
12178 existIndex = this.index(exist);
12179 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12180 var node2 = _step.value;
12181 this.proxyOf.nodes.splice(existIndex, 0, node2);
12182 }
12183 var index2;
12184 for(var id in this.indexes){
12185 index2 = this.indexes[id];
12186 if (existIndex <= index2) {
12187 this.indexes[id] = index2 + nodes.length;
12188 }
12189 }
12190 this.markDirty();
12191 return this;
12192 };
12193 _proto.normalize = function normalize(nodes, sample) {
12194 var _this = this;
12195 if (typeof nodes === "string") {
12196 nodes = cleanSource$1(parse$4$1(nodes).nodes);
12197 } else if (typeof nodes === "undefined") {
12198 nodes = [];
12199 } else if (Array.isArray(nodes)) {
12200 nodes = nodes.slice(0);
12201 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12202 var i2 = _step.value;
12203 if (i2.parent) i2.parent.removeChild(i2, "ignore");
12204 }
12205 } else if (nodes.type === "root" && this.type !== "document") {
12206 nodes = nodes.nodes.slice(0);
12207 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12208 var i21 = _step1.value;
12209 if (i21.parent) i21.parent.removeChild(i21, "ignore");
12210 }
12211 } else if (nodes.type) {
12212 nodes = [
12213 nodes
12214 ];
12215 } else if (nodes.prop) {
12216 if (typeof nodes.value === "undefined") {
12217 throw new Error("Value field is missed in node creation");
12218 } else if (typeof nodes.value !== "string") {
12219 nodes.value = String(nodes.value);
12220 }
12221 nodes = [
12222 new Declaration$3$1(nodes)
12223 ];
12224 } else if (nodes.selector) {
12225 nodes = [
12226 new Rule$4$1(nodes)
12227 ];
12228 } else if (nodes.name) {
12229 nodes = [
12230 new AtRule$4$1(nodes)
12231 ];
12232 } else if (nodes.text) {
12233 nodes = [
12234 new Comment$3$1(nodes)
12235 ];
12236 } else {
12237 throw new Error("Unknown node type in node creation");
12238 }
12239 var processed = nodes.map(function(i2) {
12240 if (!i2[my$1$1]) Container.rebuild(i2);
12241 i2 = i2.proxyOf;
12242 if (i2.parent) i2.parent.removeChild(i2);
12243 if (i2[isClean$1$1]) markDirtyUp$1(i2);
12244 if (typeof i2.raws.before === "undefined") {
12245 if (sample && typeof sample.raws.before !== "undefined") {
12246 i2.raws.before = sample.raws.before.replace(/\S/g, "");
12247 }
12248 }
12249 i2.parent = _this.proxyOf;
12250 return i2;
12251 });
12252 return processed;
12253 };
12254 _proto.prepend = function prepend() {
12255 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12256 children[_key] = arguments[_key];
12257 }
12258 children = children.reverse();
12259 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
12260 var child = _step.value;
12261 var nodes = this.normalize(child, this.first, "prepend").reverse();
12262 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12263 var node2 = _step1.value;
12264 this.proxyOf.nodes.unshift(node2);
12265 }
12266 for(var id in this.indexes){
12267 this.indexes[id] = this.indexes[id] + nodes.length;
12268 }
12269 }
12270 this.markDirty();
12271 return this;
12272 };
12273 _proto.push = function push(child) {
12274 child.parent = this;
12275 this.proxyOf.nodes.push(child);
12276 return this;
12277 };
12278 _proto.removeAll = function removeAll() {
12279 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
12280 var node2 = _step.value;
12281 node2.parent = void 0;
12282 }
12283 this.proxyOf.nodes = [];
12284 this.markDirty();
12285 return this;
12286 };
12287 _proto.removeChild = function removeChild(child) {
12288 child = this.index(child);
12289 this.proxyOf.nodes[child].parent = void 0;
12290 this.proxyOf.nodes.splice(child, 1);
12291 var index2;
12292 for(var id in this.indexes){
12293 index2 = this.indexes[id];
12294 if (index2 >= child) {
12295 this.indexes[id] = index2 - 1;
12296 }
12297 }
12298 this.markDirty();
12299 return this;
12300 };
12301 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
12302 if (!callback) {
12303 callback = opts;
12304 opts = {};
12305 }
12306 this.walkDecls(function(decl) {
12307 if (opts.props && !opts.props.includes(decl.prop)) return;
12308 if (opts.fast && !decl.value.includes(opts.fast)) return;
12309 decl.value = decl.value.replace(pattern, callback);
12310 });
12311 this.markDirty();
12312 return this;
12313 };
12314 _proto.some = function some(condition) {
12315 return this.nodes.some(condition);
12316 };
12317 _proto.walk = function walk(callback) {
12318 return this.each(function(child, i2) {
12319 var result2;
12320 try {
12321 result2 = callback(child, i2);
12322 } catch (e2) {
12323 throw child.addToError(e2);
12324 }
12325 if (result2 !== false && child.walk) {
12326 result2 = child.walk(callback);
12327 }
12328 return result2;
12329 });
12330 };
12331 _proto.walkAtRules = function walkAtRules(name, callback) {
12332 if (!callback) {
12333 callback = name;
12334 return this.walk(function(child, i2) {
12335 if (child.type === "atrule") {
12336 return callback(child, i2);
12337 }
12338 });
12339 }
12340 if (_instanceof(name, RegExp)) {
12341 return this.walk(function(child, i2) {
12342 if (child.type === "atrule" && name.test(child.name)) {
12343 return callback(child, i2);
12344 }
12345 });
12346 }
12347 return this.walk(function(child, i2) {
12348 if (child.type === "atrule" && child.name === name) {
12349 return callback(child, i2);
12350 }
12351 });
12352 };
12353 _proto.walkComments = function walkComments(callback) {
12354 return this.walk(function(child, i2) {
12355 if (child.type === "comment") {
12356 return callback(child, i2);
12357 }
12358 });
12359 };
12360 _proto.walkDecls = function walkDecls(prop, callback) {
12361 if (!callback) {
12362 callback = prop;
12363 return this.walk(function(child, i2) {
12364 if (child.type === "decl") {
12365 return callback(child, i2);
12366 }
12367 });
12368 }
12369 if (_instanceof(prop, RegExp)) {
12370 return this.walk(function(child, i2) {
12371 if (child.type === "decl" && prop.test(child.prop)) {
12372 return callback(child, i2);
12373 }
12374 });
12375 }
12376 return this.walk(function(child, i2) {
12377 if (child.type === "decl" && child.prop === prop) {
12378 return callback(child, i2);
12379 }
12380 });
12381 };
12382 _proto.walkRules = function walkRules(selector, callback) {
12383 if (!callback) {
12384 callback = selector;
12385 return this.walk(function(child, i2) {
12386 if (child.type === "rule") {
12387 return callback(child, i2);
12388 }
12389 });
12390 }
12391 if (_instanceof(selector, RegExp)) {
12392 return this.walk(function(child, i2) {
12393 if (child.type === "rule" && selector.test(child.selector)) {
12394 return callback(child, i2);
12395 }
12396 });
12397 }
12398 return this.walk(function(child, i2) {
12399 if (child.type === "rule" && child.selector === selector) {
12400 return callback(child, i2);
12401 }
12402 });
12403 };
12404 _create_class(Container, [
12405 {
12406 key: "first",
12407 get: function get() {
12408 if (!this.proxyOf.nodes) return void 0;
12409 return this.proxyOf.nodes[0];
12410 }
12411 },
12412 {
12413 key: "last",
12414 get: function get() {
12415 if (!this.proxyOf.nodes) return void 0;
12416 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
12417 }
12418 }
12419 ]);
12420 return Container;
12421 }(Node$1$1);
12422 Container$7$1.registerParse = function(dependant) {
12423 parse$4$1 = dependant;
12424 };
12425 Container$7$1.registerRule = function(dependant) {
12426 Rule$4$1 = dependant;
12427 };
12428 Container$7$1.registerAtRule = function(dependant) {
12429 AtRule$4$1 = dependant;
12430 };
12431 Container$7$1.registerRoot = function(dependant) {
12432 Root$6$1 = dependant;
12433 };
12434 var container$1 = Container$7$1;
12435 Container$7$1.default = Container$7$1;
12436 Container$7$1.rebuild = function(node2) {
12437 if (node2.type === "atrule") {
12438 Object.setPrototypeOf(node2, AtRule$4$1.prototype);
12439 } else if (node2.type === "rule") {
12440 Object.setPrototypeOf(node2, Rule$4$1.prototype);
12441 } else if (node2.type === "decl") {
12442 Object.setPrototypeOf(node2, Declaration$3$1.prototype);
12443 } else if (node2.type === "comment") {
12444 Object.setPrototypeOf(node2, Comment$3$1.prototype);
12445 } else if (node2.type === "root") {
12446 Object.setPrototypeOf(node2, Root$6$1.prototype);
12447 }
12448 node2[my$1$1] = true;
12449 if (node2.nodes) {
12450 node2.nodes.forEach(function(child) {
12451 Container$7$1.rebuild(child);
12452 });
12453 }
12454 };
12455 var Container$6$1 = container$1;
12456 var LazyResult$4$1, Processor$3$1;
12457 var Document$3$1 = /*#__PURE__*/ function(Container$6$1) {
12458 _inherits(Document2, Container$6$1);
12459 function Document2(defaults) {
12460 var _this;
12461 _this = Container$6$1.call(this, _extends({
12462 type: "document"
12463 }, defaults)) || this;
12464 if (!_this.nodes) {
12465 _this.nodes = [];
12466 }
12467 return _this;
12468 }
12469 var _proto = Document2.prototype;
12470 _proto.toResult = function toResult(opts) {
12471 if (opts === void 0) opts = {};
12472 var lazy = new LazyResult$4$1(new Processor$3$1(), this, opts);
12473 return lazy.stringify();
12474 };
12475 return Document2;
12476 }(Container$6$1);
12477 Document$3$1.registerLazyResult = function(dependant) {
12478 LazyResult$4$1 = dependant;
12479 };
12480 Document$3$1.registerProcessor = function(dependant) {
12481 Processor$3$1 = dependant;
12482 };
12483 var document$1$1 = Document$3$1;
12484 Document$3$1.default = Document$3$1;
12485 var printed$1 = {};
12486 var warnOnce$2$1 = function warnOnce(message) {
12487 if (printed$1[message]) return;
12488 printed$1[message] = true;
12489 if (typeof console !== "undefined" && console.warn) {
12490 console.warn(message);
12491 }
12492 };
12493 var Warning$2$1 = /*#__PURE__*/ function() {
12494 function Warning(text, opts) {
12495 if (opts === void 0) opts = {};
12496 this.type = "warning";
12497 this.text = text;
12498 if (opts.node && opts.node.source) {
12499 var range = opts.node.rangeBy(opts);
12500 this.line = range.start.line;
12501 this.column = range.start.column;
12502 this.endLine = range.end.line;
12503 this.endColumn = range.end.column;
12504 }
12505 for(var opt in opts)this[opt] = opts[opt];
12506 }
12507 var _proto = Warning.prototype;
12508 _proto.toString = function toString() {
12509 if (this.node) {
12510 return this.node.error(this.text, {
12511 index: this.index,
12512 plugin: this.plugin,
12513 word: this.word
12514 }).message;
12515 }
12516 if (this.plugin) {
12517 return this.plugin + ": " + this.text;
12518 }
12519 return this.text;
12520 };
12521 return Warning;
12522 }();
12523 var warning$1 = Warning$2$1;
12524 Warning$2$1.default = Warning$2$1;
12525 var Warning$1$1 = warning$1;
12526 var Result$3$1 = /*#__PURE__*/ function() {
12527 function Result(processor2, root2, opts) {
12528 this.processor = processor2;
12529 this.messages = [];
12530 this.root = root2;
12531 this.opts = opts;
12532 this.css = void 0;
12533 this.map = void 0;
12534 }
12535 var _proto = Result.prototype;
12536 _proto.toString = function toString() {
12537 return this.css;
12538 };
12539 _proto.warn = function warn(text, opts) {
12540 if (opts === void 0) opts = {};
12541 if (!opts.plugin) {
12542 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
12543 opts.plugin = this.lastPlugin.postcssPlugin;
12544 }
12545 }
12546 var warning2 = new Warning$1$1(text, opts);
12547 this.messages.push(warning2);
12548 return warning2;
12549 };
12550 _proto.warnings = function warnings() {
12551 return this.messages.filter(function(i2) {
12552 return i2.type === "warning";
12553 });
12554 };
12555 _create_class(Result, [
12556 {
12557 key: "content",
12558 get: function get() {
12559 return this.css;
12560 }
12561 }
12562 ]);
12563 return Result;
12564 }();
12565 var result$1 = Result$3$1;
12566 Result$3$1.default = Result$3$1;
12567 var SINGLE_QUOTE$1 = "'".charCodeAt(0);
12568 var DOUBLE_QUOTE$1 = '"'.charCodeAt(0);
12569 var BACKSLASH$1 = "\\".charCodeAt(0);
12570 var SLASH$1 = "/".charCodeAt(0);
12571 var NEWLINE$1 = "\n".charCodeAt(0);
12572 var SPACE$1 = " ".charCodeAt(0);
12573 var FEED$1 = "\f".charCodeAt(0);
12574 var TAB$1 = " ".charCodeAt(0);
12575 var CR$1 = "\r".charCodeAt(0);
12576 var OPEN_SQUARE$1 = "[".charCodeAt(0);
12577 var CLOSE_SQUARE$1 = "]".charCodeAt(0);
12578 var OPEN_PARENTHESES$1 = "(".charCodeAt(0);
12579 var CLOSE_PARENTHESES$1 = ")".charCodeAt(0);
12580 var OPEN_CURLY$1 = "{".charCodeAt(0);
12581 var CLOSE_CURLY$1 = "}".charCodeAt(0);
12582 var SEMICOLON$1 = ";".charCodeAt(0);
12583 var ASTERISK$1 = "*".charCodeAt(0);
12584 var COLON$1 = ":".charCodeAt(0);
12585 var AT$1 = "@".charCodeAt(0);
12586 var RE_AT_END$1 = /[\t\n\f\r "#'()/;[\\\]{}]/g;
12587 var RE_WORD_END$1 = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
12588 var RE_BAD_BRACKET$1 = /.[\r\n"'(/\\]/;
12589 var RE_HEX_ESCAPE$1 = /[\da-f]/i;
12590 var tokenize$1 = function tokenizer(input2, options) {
12591 if (options === void 0) options = {};
12592 var css = input2.css.valueOf();
12593 var ignore = options.ignoreErrors;
12594 var code, next, quote, content, escape;
12595 var escaped, escapePos, prev, n2, currentToken;
12596 var length = css.length;
12597 var pos = 0;
12598 var buffer = [];
12599 var returned = [];
12600 function position() {
12601 return pos;
12602 }
12603 function unclosed(what) {
12604 throw input2.error("Unclosed " + what, pos);
12605 }
12606 function endOfFile() {
12607 return returned.length === 0 && pos >= length;
12608 }
12609 function nextToken(opts) {
12610 if (returned.length) return returned.pop();
12611 if (pos >= length) return;
12612 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
12613 code = css.charCodeAt(pos);
12614 switch(code){
12615 case NEWLINE$1:
12616 case SPACE$1:
12617 case TAB$1:
12618 case CR$1:
12619 case FEED$1:
12620 {
12621 next = pos;
12622 do {
12623 next += 1;
12624 code = css.charCodeAt(next);
12625 }while (code === SPACE$1 || code === NEWLINE$1 || code === TAB$1 || code === CR$1 || code === FEED$1);
12626 currentToken = [
12627 "space",
12628 css.slice(pos, next)
12629 ];
12630 pos = next - 1;
12631 break;
12632 }
12633 case OPEN_SQUARE$1:
12634 case CLOSE_SQUARE$1:
12635 case OPEN_CURLY$1:
12636 case CLOSE_CURLY$1:
12637 case COLON$1:
12638 case SEMICOLON$1:
12639 case CLOSE_PARENTHESES$1:
12640 {
12641 var controlChar = String.fromCharCode(code);
12642 currentToken = [
12643 controlChar,
12644 controlChar,
12645 pos
12646 ];
12647 break;
12648 }
12649 case OPEN_PARENTHESES$1:
12650 {
12651 prev = buffer.length ? buffer.pop()[1] : "";
12652 n2 = css.charCodeAt(pos + 1);
12653 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) {
12654 next = pos;
12655 do {
12656 escaped = false;
12657 next = css.indexOf(")", next + 1);
12658 if (next === -1) {
12659 if (ignore || ignoreUnclosed) {
12660 next = pos;
12661 break;
12662 } else {
12663 unclosed("bracket");
12664 }
12665 }
12666 escapePos = next;
12667 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12668 escapePos -= 1;
12669 escaped = !escaped;
12670 }
12671 }while (escaped);
12672 currentToken = [
12673 "brackets",
12674 css.slice(pos, next + 1),
12675 pos,
12676 next
12677 ];
12678 pos = next;
12679 } else {
12680 next = css.indexOf(")", pos + 1);
12681 content = css.slice(pos, next + 1);
12682 if (next === -1 || RE_BAD_BRACKET$1.test(content)) {
12683 currentToken = [
12684 "(",
12685 "(",
12686 pos
12687 ];
12688 } else {
12689 currentToken = [
12690 "brackets",
12691 content,
12692 pos,
12693 next
12694 ];
12695 pos = next;
12696 }
12697 }
12698 break;
12699 }
12700 case SINGLE_QUOTE$1:
12701 case DOUBLE_QUOTE$1:
12702 {
12703 quote = code === SINGLE_QUOTE$1 ? "'" : '"';
12704 next = pos;
12705 do {
12706 escaped = false;
12707 next = css.indexOf(quote, next + 1);
12708 if (next === -1) {
12709 if (ignore || ignoreUnclosed) {
12710 next = pos + 1;
12711 break;
12712 } else {
12713 unclosed("string");
12714 }
12715 }
12716 escapePos = next;
12717 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12718 escapePos -= 1;
12719 escaped = !escaped;
12720 }
12721 }while (escaped);
12722 currentToken = [
12723 "string",
12724 css.slice(pos, next + 1),
12725 pos,
12726 next
12727 ];
12728 pos = next;
12729 break;
12730 }
12731 case AT$1:
12732 {
12733 RE_AT_END$1.lastIndex = pos + 1;
12734 RE_AT_END$1.test(css);
12735 if (RE_AT_END$1.lastIndex === 0) {
12736 next = css.length - 1;
12737 } else {
12738 next = RE_AT_END$1.lastIndex - 2;
12739 }
12740 currentToken = [
12741 "at-word",
12742 css.slice(pos, next + 1),
12743 pos,
12744 next
12745 ];
12746 pos = next;
12747 break;
12748 }
12749 case BACKSLASH$1:
12750 {
12751 next = pos;
12752 escape = true;
12753 while(css.charCodeAt(next + 1) === BACKSLASH$1){
12754 next += 1;
12755 escape = !escape;
12756 }
12757 code = css.charCodeAt(next + 1);
12758 if (escape && code !== SLASH$1 && code !== SPACE$1 && code !== NEWLINE$1 && code !== TAB$1 && code !== CR$1 && code !== FEED$1) {
12759 next += 1;
12760 if (RE_HEX_ESCAPE$1.test(css.charAt(next))) {
12761 while(RE_HEX_ESCAPE$1.test(css.charAt(next + 1))){
12762 next += 1;
12763 }
12764 if (css.charCodeAt(next + 1) === SPACE$1) {
12765 next += 1;
12766 }
12767 }
12768 }
12769 currentToken = [
12770 "word",
12771 css.slice(pos, next + 1),
12772 pos,
12773 next
12774 ];
12775 pos = next;
12776 break;
12777 }
12778 default:
12779 {
12780 if (code === SLASH$1 && css.charCodeAt(pos + 1) === ASTERISK$1) {
12781 next = css.indexOf("*/", pos + 2) + 1;
12782 if (next === 0) {
12783 if (ignore || ignoreUnclosed) {
12784 next = css.length;
12785 } else {
12786 unclosed("comment");
12787 }
12788 }
12789 currentToken = [
12790 "comment",
12791 css.slice(pos, next + 1),
12792 pos,
12793 next
12794 ];
12795 pos = next;
12796 } else {
12797 RE_WORD_END$1.lastIndex = pos + 1;
12798 RE_WORD_END$1.test(css);
12799 if (RE_WORD_END$1.lastIndex === 0) {
12800 next = css.length - 1;
12801 } else {
12802 next = RE_WORD_END$1.lastIndex - 2;
12803 }
12804 currentToken = [
12805 "word",
12806 css.slice(pos, next + 1),
12807 pos,
12808 next
12809 ];
12810 buffer.push(currentToken);
12811 pos = next;
12812 }
12813 break;
12814 }
12815 }
12816 pos++;
12817 return currentToken;
12818 }
12819 function back(token) {
12820 returned.push(token);
12821 }
12822 return {
12823 back: back,
12824 endOfFile: endOfFile,
12825 nextToken: nextToken,
12826 position: position
12827 };
12828 };
12829 var Container$5$1 = container$1;
12830 var AtRule$3$1 = /*#__PURE__*/ function(Container$5$1) {
12831 _inherits(AtRule, Container$5$1);
12832 function AtRule(defaults) {
12833 var _this;
12834 _this = Container$5$1.call(this, defaults) || this;
12835 _this.type = "atrule";
12836 return _this;
12837 }
12838 var _proto = AtRule.prototype;
12839 _proto.append = function append() {
12840 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12841 children[_key] = arguments[_key];
12842 }
12843 var _Container$5$1_prototype_append;
12844 if (!this.proxyOf.nodes) this.nodes = [];
12845 return (_Container$5$1_prototype_append = Container$5$1.prototype.append).call.apply(_Container$5$1_prototype_append, [].concat([
12846 this
12847 ], children));
12848 };
12849 _proto.prepend = function prepend() {
12850 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12851 children[_key] = arguments[_key];
12852 }
12853 var _Container$5$1_prototype_prepend;
12854 if (!this.proxyOf.nodes) this.nodes = [];
12855 return (_Container$5$1_prototype_prepend = Container$5$1.prototype.prepend).call.apply(_Container$5$1_prototype_prepend, [].concat([
12856 this
12857 ], children));
12858 };
12859 return AtRule;
12860 }(Container$5$1);
12861 var atRule$1 = AtRule$3$1;
12862 AtRule$3$1.default = AtRule$3$1;
12863 Container$5$1.registerAtRule(AtRule$3$1);
12864 var Container$4$1 = container$1;
12865 var LazyResult$3$1, Processor$2$1;
12866 var Root$5$1 = /*#__PURE__*/ function(Container$4$1) {
12867 _inherits(Root, Container$4$1);
12868 function Root(defaults) {
12869 var _this;
12870 _this = Container$4$1.call(this, defaults) || this;
12871 _this.type = "root";
12872 if (!_this.nodes) _this.nodes = [];
12873 return _this;
12874 }
12875 var _proto = Root.prototype;
12876 _proto.normalize = function normalize(child, sample, type) {
12877 var nodes = Container$4$1.prototype.normalize.call(this, child);
12878 if (sample) {
12879 if (type === "prepend") {
12880 if (this.nodes.length > 1) {
12881 sample.raws.before = this.nodes[1].raws.before;
12882 } else {
12883 delete sample.raws.before;
12884 }
12885 } else if (this.first !== sample) {
12886 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12887 var node2 = _step.value;
12888 node2.raws.before = sample.raws.before;
12889 }
12890 }
12891 }
12892 return nodes;
12893 };
12894 _proto.removeChild = function removeChild(child, ignore) {
12895 var index2 = this.index(child);
12896 if (!ignore && index2 === 0 && this.nodes.length > 1) {
12897 this.nodes[1].raws.before = this.nodes[index2].raws.before;
12898 }
12899 return Container$4$1.prototype.removeChild.call(this, child);
12900 };
12901 _proto.toResult = function toResult(opts) {
12902 if (opts === void 0) opts = {};
12903 var lazy = new LazyResult$3$1(new Processor$2$1(), this, opts);
12904 return lazy.stringify();
12905 };
12906 return Root;
12907 }(Container$4$1);
12908 Root$5$1.registerLazyResult = function(dependant) {
12909 LazyResult$3$1 = dependant;
12910 };
12911 Root$5$1.registerProcessor = function(dependant) {
12912 Processor$2$1 = dependant;
12913 };
12914 var root$1 = Root$5$1;
12915 Root$5$1.default = Root$5$1;
12916 Container$4$1.registerRoot(Root$5$1);
12917 var list$2$1 = {
12918 comma: function comma(string) {
12919 return list$2$1.split(string, [
12920 ","
12921 ], true);
12922 },
12923 space: function space(string) {
12924 var spaces = [
12925 " ",
12926 "\n",
12927 " "
12928 ];
12929 return list$2$1.split(string, spaces);
12930 },
12931 split: function split(string, separators, last) {
12932 var array = [];
12933 var current = "";
12934 var split = false;
12935 var func = 0;
12936 var inQuote = false;
12937 var prevQuote = "";
12938 var escape = false;
12939 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
12940 var letter = _step.value;
12941 if (escape) {
12942 escape = false;
12943 } else if (letter === "\\") {
12944 escape = true;
12945 } else if (inQuote) {
12946 if (letter === prevQuote) {
12947 inQuote = false;
12948 }
12949 } else if (letter === '"' || letter === "'") {
12950 inQuote = true;
12951 prevQuote = letter;
12952 } else if (letter === "(") {
12953 func += 1;
12954 } else if (letter === ")") {
12955 if (func > 0) func -= 1;
12956 } else if (func === 0) {
12957 if (separators.includes(letter)) split = true;
12958 }
12959 if (split) {
12960 if (current !== "") array.push(current.trim());
12961 current = "";
12962 split = false;
12963 } else {
12964 current += letter;
12965 }
12966 }
12967 if (last || current !== "") array.push(current.trim());
12968 return array;
12969 }
12970 };
12971 var list_1$1 = list$2$1;
12972 list$2$1.default = list$2$1;
12973 var Container$3$1 = container$1;
12974 var list$1$1 = list_1$1;
12975 var Rule$3$1 = /*#__PURE__*/ function(Container$3$1) {
12976 _inherits(Rule, Container$3$1);
12977 function Rule(defaults) {
12978 var _this;
12979 _this = Container$3$1.call(this, defaults) || this;
12980 _this.type = "rule";
12981 if (!_this.nodes) _this.nodes = [];
12982 return _this;
12983 }
12984 _create_class(Rule, [
12985 {
12986 key: "selectors",
12987 get: function get() {
12988 return list$1$1.comma(this.selector);
12989 },
12990 set: function set(values) {
12991 var match = this.selector ? this.selector.match(/,\s*/) : null;
12992 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
12993 this.selector = values.join(sep2);
12994 }
12995 }
12996 ]);
12997 return Rule;
12998 }(Container$3$1);
12999 var rule$1 = Rule$3$1;
13000 Rule$3$1.default = Rule$3$1;
13001 Container$3$1.registerRule(Rule$3$1);
13002 var Declaration$2$1 = declaration$1;
13003 var tokenizer2$1 = tokenize$1;
13004 var Comment$2$1 = comment$1;
13005 var AtRule$2$1 = atRule$1;
13006 var Root$4$1 = root$1;
13007 var Rule$2$1 = rule$1;
13008 var SAFE_COMMENT_NEIGHBOR$1 = {
13009 empty: true,
13010 space: true
13011 };
13012 function findLastWithPosition$1(tokens) {
13013 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
13014 var token = tokens[i2];
13015 var pos = token[3] || token[2];
13016 if (pos) return pos;
13017 }
13018 }
13019 var Parser$1$1 = /*#__PURE__*/ function() {
13020 function Parser(input2) {
13021 this.input = input2;
13022 this.root = new Root$4$1();
13023 this.current = this.root;
13024 this.spaces = "";
13025 this.semicolon = false;
13026 this.createTokenizer();
13027 this.root.source = {
13028 input: input2,
13029 start: {
13030 column: 1,
13031 line: 1,
13032 offset: 0
13033 }
13034 };
13035 }
13036 var _proto = Parser.prototype;
13037 _proto.atrule = function atrule(token) {
13038 var node2 = new AtRule$2$1();
13039 node2.name = token[1].slice(1);
13040 if (node2.name === "") {
13041 this.unnamedAtrule(node2, token);
13042 }
13043 this.init(node2, token[2]);
13044 var type;
13045 var prev;
13046 var shift;
13047 var last = false;
13048 var open = false;
13049 var params = [];
13050 var brackets = [];
13051 while(!this.tokenizer.endOfFile()){
13052 token = this.tokenizer.nextToken();
13053 type = token[0];
13054 if (type === "(" || type === "[") {
13055 brackets.push(type === "(" ? ")" : "]");
13056 } else if (type === "{" && brackets.length > 0) {
13057 brackets.push("}");
13058 } else if (type === brackets[brackets.length - 1]) {
13059 brackets.pop();
13060 }
13061 if (brackets.length === 0) {
13062 if (type === ";") {
13063 node2.source.end = this.getPosition(token[2]);
13064 node2.source.end.offset++;
13065 this.semicolon = true;
13066 break;
13067 } else if (type === "{") {
13068 open = true;
13069 break;
13070 } else if (type === "}") {
13071 if (params.length > 0) {
13072 shift = params.length - 1;
13073 prev = params[shift];
13074 while(prev && prev[0] === "space"){
13075 prev = params[--shift];
13076 }
13077 if (prev) {
13078 node2.source.end = this.getPosition(prev[3] || prev[2]);
13079 node2.source.end.offset++;
13080 }
13081 }
13082 this.end(token);
13083 break;
13084 } else {
13085 params.push(token);
13086 }
13087 } else {
13088 params.push(token);
13089 }
13090 if (this.tokenizer.endOfFile()) {
13091 last = true;
13092 break;
13093 }
13094 }
13095 node2.raws.between = this.spacesAndCommentsFromEnd(params);
13096 if (params.length) {
13097 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
13098 this.raw(node2, "params", params);
13099 if (last) {
13100 token = params[params.length - 1];
13101 node2.source.end = this.getPosition(token[3] || token[2]);
13102 node2.source.end.offset++;
13103 this.spaces = node2.raws.between;
13104 node2.raws.between = "";
13105 }
13106 } else {
13107 node2.raws.afterName = "";
13108 node2.params = "";
13109 }
13110 if (open) {
13111 node2.nodes = [];
13112 this.current = node2;
13113 }
13114 };
13115 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
13116 var colon = this.colon(tokens);
13117 if (colon === false) return;
13118 var founded = 0;
13119 var token;
13120 for(var j = colon - 1; j >= 0; j--){
13121 token = tokens[j];
13122 if (token[0] !== "space") {
13123 founded += 1;
13124 if (founded === 2) break;
13125 }
13126 }
13127 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
13128 };
13129 _proto.colon = function colon(tokens) {
13130 var brackets = 0;
13131 var token, type, prev;
13132 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
13133 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
13134 token = element;
13135 type = token[0];
13136 if (type === "(") {
13137 brackets += 1;
13138 }
13139 if (type === ")") {
13140 brackets -= 1;
13141 }
13142 if (brackets === 0 && type === ":") {
13143 if (!prev) {
13144 this.doubleColon(token);
13145 } else if (prev[0] === "word" && prev[1] === "progid") {
13146 continue;
13147 } else {
13148 return i2;
13149 }
13150 }
13151 prev = token;
13152 }
13153 return false;
13154 };
13155 _proto.comment = function comment(token) {
13156 var node2 = new Comment$2$1();
13157 this.init(node2, token[2]);
13158 node2.source.end = this.getPosition(token[3] || token[2]);
13159 node2.source.end.offset++;
13160 var text = token[1].slice(2, -2);
13161 if (/^\s*$/.test(text)) {
13162 node2.text = "";
13163 node2.raws.left = text;
13164 node2.raws.right = "";
13165 } else {
13166 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
13167 node2.text = match[2];
13168 node2.raws.left = match[1];
13169 node2.raws.right = match[3];
13170 }
13171 };
13172 _proto.createTokenizer = function createTokenizer() {
13173 this.tokenizer = tokenizer2$1(this.input);
13174 };
13175 _proto.decl = function decl(tokens, customProperty) {
13176 var node2 = new Declaration$2$1();
13177 this.init(node2, tokens[0][2]);
13178 var last = tokens[tokens.length - 1];
13179 if (last[0] === ";") {
13180 this.semicolon = true;
13181 tokens.pop();
13182 }
13183 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition$1(tokens));
13184 node2.source.end.offset++;
13185 while(tokens[0][0] !== "word"){
13186 if (tokens.length === 1) this.unknownWord(tokens);
13187 node2.raws.before += tokens.shift()[1];
13188 }
13189 node2.source.start = this.getPosition(tokens[0][2]);
13190 node2.prop = "";
13191 while(tokens.length){
13192 var type = tokens[0][0];
13193 if (type === ":" || type === "space" || type === "comment") {
13194 break;
13195 }
13196 node2.prop += tokens.shift()[1];
13197 }
13198 node2.raws.between = "";
13199 var token;
13200 while(tokens.length){
13201 token = tokens.shift();
13202 if (token[0] === ":") {
13203 node2.raws.between += token[1];
13204 break;
13205 } else {
13206 if (token[0] === "word" && /\w/.test(token[1])) {
13207 this.unknownWord([
13208 token
13209 ]);
13210 }
13211 node2.raws.between += token[1];
13212 }
13213 }
13214 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
13215 node2.raws.before += node2.prop[0];
13216 node2.prop = node2.prop.slice(1);
13217 }
13218 var firstSpaces = [];
13219 var next;
13220 while(tokens.length){
13221 next = tokens[0][0];
13222 if (next !== "space" && next !== "comment") break;
13223 firstSpaces.push(tokens.shift());
13224 }
13225 this.precheckMissedSemicolon(tokens);
13226 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
13227 token = tokens[i2];
13228 if (token[1].toLowerCase() === "!important") {
13229 node2.important = true;
13230 var string = this.stringFrom(tokens, i2);
13231 string = this.spacesFromEnd(tokens) + string;
13232 if (string !== " !important") node2.raws.important = string;
13233 break;
13234 } else if (token[1].toLowerCase() === "important") {
13235 var cache = tokens.slice(0);
13236 var str = "";
13237 for(var j = i2; j > 0; j--){
13238 var type1 = cache[j][0];
13239 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
13240 break;
13241 }
13242 str = cache.pop()[1] + str;
13243 }
13244 if (str.trim().indexOf("!") === 0) {
13245 node2.important = true;
13246 node2.raws.important = str;
13247 tokens = cache;
13248 }
13249 }
13250 if (token[0] !== "space" && token[0] !== "comment") {
13251 break;
13252 }
13253 }
13254 var hasWord = tokens.some(function(i2) {
13255 return i2[0] !== "space" && i2[0] !== "comment";
13256 });
13257 if (hasWord) {
13258 node2.raws.between += firstSpaces.map(function(i2) {
13259 return i2[1];
13260 }).join("");
13261 firstSpaces = [];
13262 }
13263 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
13264 if (node2.value.includes(":") && !customProperty) {
13265 this.checkMissedSemicolon(tokens);
13266 }
13267 };
13268 _proto.doubleColon = function doubleColon(token) {
13269 throw this.input.error("Double colon", {
13270 offset: token[2]
13271 }, {
13272 offset: token[2] + token[1].length
13273 });
13274 };
13275 _proto.emptyRule = function emptyRule(token) {
13276 var node2 = new Rule$2$1();
13277 this.init(node2, token[2]);
13278 node2.selector = "";
13279 node2.raws.between = "";
13280 this.current = node2;
13281 };
13282 _proto.end = function end(token) {
13283 if (this.current.nodes && this.current.nodes.length) {
13284 this.current.raws.semicolon = this.semicolon;
13285 }
13286 this.semicolon = false;
13287 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
13288 this.spaces = "";
13289 if (this.current.parent) {
13290 this.current.source.end = this.getPosition(token[2]);
13291 this.current.source.end.offset++;
13292 this.current = this.current.parent;
13293 } else {
13294 this.unexpectedClose(token);
13295 }
13296 };
13297 _proto.endFile = function endFile() {
13298 if (this.current.parent) this.unclosedBlock();
13299 if (this.current.nodes && this.current.nodes.length) {
13300 this.current.raws.semicolon = this.semicolon;
13301 }
13302 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
13303 this.root.source.end = this.getPosition(this.tokenizer.position());
13304 };
13305 _proto.freeSemicolon = function freeSemicolon(token) {
13306 this.spaces += token[1];
13307 if (this.current.nodes) {
13308 var prev = this.current.nodes[this.current.nodes.length - 1];
13309 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
13310 prev.raws.ownSemicolon = this.spaces;
13311 this.spaces = "";
13312 }
13313 }
13314 };
13315 // Helpers
13316 _proto.getPosition = function getPosition(offset) {
13317 var pos = this.input.fromOffset(offset);
13318 return {
13319 column: pos.col,
13320 line: pos.line,
13321 offset: offset
13322 };
13323 };
13324 _proto.init = function init(node2, offset) {
13325 this.current.push(node2);
13326 node2.source = {
13327 input: this.input,
13328 start: this.getPosition(offset)
13329 };
13330 node2.raws.before = this.spaces;
13331 this.spaces = "";
13332 if (node2.type !== "comment") this.semicolon = false;
13333 };
13334 _proto.other = function other(start) {
13335 var end = false;
13336 var type = null;
13337 var colon = false;
13338 var bracket = null;
13339 var brackets = [];
13340 var customProperty = start[1].startsWith("--");
13341 var tokens = [];
13342 var token = start;
13343 while(token){
13344 type = token[0];
13345 tokens.push(token);
13346 if (type === "(" || type === "[") {
13347 if (!bracket) bracket = token;
13348 brackets.push(type === "(" ? ")" : "]");
13349 } else if (customProperty && colon && type === "{") {
13350 if (!bracket) bracket = token;
13351 brackets.push("}");
13352 } else if (brackets.length === 0) {
13353 if (type === ";") {
13354 if (colon) {
13355 this.decl(tokens, customProperty);
13356 return;
13357 } else {
13358 break;
13359 }
13360 } else if (type === "{") {
13361 this.rule(tokens);
13362 return;
13363 } else if (type === "}") {
13364 this.tokenizer.back(tokens.pop());
13365 end = true;
13366 break;
13367 } else if (type === ":") {
13368 colon = true;
13369 }
13370 } else if (type === brackets[brackets.length - 1]) {
13371 brackets.pop();
13372 if (brackets.length === 0) bracket = null;
13373 }
13374 token = this.tokenizer.nextToken();
13375 }
13376 if (this.tokenizer.endOfFile()) end = true;
13377 if (brackets.length > 0) this.unclosedBracket(bracket);
13378 if (end && colon) {
13379 if (!customProperty) {
13380 while(tokens.length){
13381 token = tokens[tokens.length - 1][0];
13382 if (token !== "space" && token !== "comment") break;
13383 this.tokenizer.back(tokens.pop());
13384 }
13385 }
13386 this.decl(tokens, customProperty);
13387 } else {
13388 this.unknownWord(tokens);
13389 }
13390 };
13391 _proto.parse = function parse() {
13392 var token;
13393 while(!this.tokenizer.endOfFile()){
13394 token = this.tokenizer.nextToken();
13395 switch(token[0]){
13396 case "space":
13397 this.spaces += token[1];
13398 break;
13399 case ";":
13400 this.freeSemicolon(token);
13401 break;
13402 case "}":
13403 this.end(token);
13404 break;
13405 case "comment":
13406 this.comment(token);
13407 break;
13408 case "at-word":
13409 this.atrule(token);
13410 break;
13411 case "{":
13412 this.emptyRule(token);
13413 break;
13414 default:
13415 this.other(token);
13416 break;
13417 }
13418 }
13419 this.endFile();
13420 };
13421 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
13422 _proto.raw = function raw(node2, prop, tokens, customProperty) {
13423 var token, type;
13424 var length = tokens.length;
13425 var value = "";
13426 var clean = true;
13427 var next, prev;
13428 for(var i2 = 0; i2 < length; i2 += 1){
13429 token = tokens[i2];
13430 type = token[0];
13431 if (type === "space" && i2 === length - 1 && !customProperty) {
13432 clean = false;
13433 } else if (type === "comment") {
13434 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
13435 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
13436 if (!SAFE_COMMENT_NEIGHBOR$1[prev] && !SAFE_COMMENT_NEIGHBOR$1[next]) {
13437 if (value.slice(-1) === ",") {
13438 clean = false;
13439 } else {
13440 value += token[1];
13441 }
13442 } else {
13443 clean = false;
13444 }
13445 } else {
13446 value += token[1];
13447 }
13448 }
13449 if (!clean) {
13450 var raw = tokens.reduce(function(all, i2) {
13451 return all + i2[1];
13452 }, "");
13453 node2.raws[prop] = {
13454 raw: raw,
13455 value: value
13456 };
13457 }
13458 node2[prop] = value;
13459 };
13460 _proto.rule = function rule(tokens) {
13461 tokens.pop();
13462 var node2 = new Rule$2$1();
13463 this.init(node2, tokens[0][2]);
13464 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
13465 this.raw(node2, "selector", tokens);
13466 this.current = node2;
13467 };
13468 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
13469 var lastTokenType;
13470 var spaces = "";
13471 while(tokens.length){
13472 lastTokenType = tokens[tokens.length - 1][0];
13473 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
13474 spaces = tokens.pop()[1] + spaces;
13475 }
13476 return spaces;
13477 };
13478 // Errors
13479 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
13480 var next;
13481 var spaces = "";
13482 while(tokens.length){
13483 next = tokens[0][0];
13484 if (next !== "space" && next !== "comment") break;
13485 spaces += tokens.shift()[1];
13486 }
13487 return spaces;
13488 };
13489 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
13490 var lastTokenType;
13491 var spaces = "";
13492 while(tokens.length){
13493 lastTokenType = tokens[tokens.length - 1][0];
13494 if (lastTokenType !== "space") break;
13495 spaces = tokens.pop()[1] + spaces;
13496 }
13497 return spaces;
13498 };
13499 _proto.stringFrom = function stringFrom(tokens, from) {
13500 var result2 = "";
13501 for(var i2 = from; i2 < tokens.length; i2++){
13502 result2 += tokens[i2][1];
13503 }
13504 tokens.splice(from, tokens.length - from);
13505 return result2;
13506 };
13507 _proto.unclosedBlock = function unclosedBlock() {
13508 var pos = this.current.source.start;
13509 throw this.input.error("Unclosed block", pos.line, pos.column);
13510 };
13511 _proto.unclosedBracket = function unclosedBracket(bracket) {
13512 throw this.input.error("Unclosed bracket", {
13513 offset: bracket[2]
13514 }, {
13515 offset: bracket[2] + 1
13516 });
13517 };
13518 _proto.unexpectedClose = function unexpectedClose(token) {
13519 throw this.input.error("Unexpected }", {
13520 offset: token[2]
13521 }, {
13522 offset: token[2] + 1
13523 });
13524 };
13525 _proto.unknownWord = function unknownWord(tokens) {
13526 throw this.input.error("Unknown word", {
13527 offset: tokens[0][2]
13528 }, {
13529 offset: tokens[0][2] + tokens[0][1].length
13530 });
13531 };
13532 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
13533 throw this.input.error("At-rule without name", {
13534 offset: token[2]
13535 }, {
13536 offset: token[2] + token[1].length
13537 });
13538 };
13539 return Parser;
13540 }();
13541 var parser$1 = Parser$1$1;
13542 var Container$2$1 = container$1;
13543 var Parser2$1 = parser$1;
13544 var Input$2$1 = input$1;
13545 function parse$3$1(css, opts) {
13546 var input2 = new Input$2$1(css, opts);
13547 var parser2 = new Parser2$1(input2);
13548 try {
13549 parser2.parse();
13550 } catch (e2) {
13551 if (true) {
13552 if (e2.name === "CssSyntaxError" && opts && opts.from) {
13553 if (/\.scss$/i.test(opts.from)) {
13554 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
13555 } else if (/\.sass/i.test(opts.from)) {
13556 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
13557 } else if (/\.less$/i.test(opts.from)) {
13558 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
13559 }
13560 }
13561 }
13562 throw e2;
13563 }
13564 return parser2.root;
13565 }
13566 var parse_1$1 = parse$3$1;
13567 parse$3$1.default = parse$3$1;
13568 Container$2$1.registerParse(parse$3$1);
13569 var isClean$3 = symbols$1.isClean, my$3 = symbols$1.my;
13570 var MapGenerator$1$1 = mapGenerator$1;
13571 var stringify$2$1 = stringify_1$1;
13572 var Container$1$1 = container$1;
13573 var Document$2$1 = document$1$1;
13574 var warnOnce$1$1 = warnOnce$2$1;
13575 var Result$2$1 = result$1;
13576 var parse$2$1 = parse_1$1;
13577 var Root$3$1 = root$1;
13578 var TYPE_TO_CLASS_NAME$1 = {
13579 atrule: "AtRule",
13580 comment: "Comment",
13581 decl: "Declaration",
13582 document: "Document",
13583 root: "Root",
13584 rule: "Rule"
13585 };
13586 var PLUGIN_PROPS$1 = {
13587 AtRule: true,
13588 AtRuleExit: true,
13589 Comment: true,
13590 CommentExit: true,
13591 Declaration: true,
13592 DeclarationExit: true,
13593 Document: true,
13594 DocumentExit: true,
13595 Once: true,
13596 OnceExit: true,
13597 postcssPlugin: true,
13598 prepare: true,
13599 Root: true,
13600 RootExit: true,
13601 Rule: true,
13602 RuleExit: true
13603 };
13604 var NOT_VISITORS$1 = {
13605 Once: true,
13606 postcssPlugin: true,
13607 prepare: true
13608 };
13609 var CHILDREN$1 = 0;
13610 function isPromise$1(obj) {
13611 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
13612 }
13613 function getEvents$1(node2) {
13614 var key = false;
13615 var type = TYPE_TO_CLASS_NAME$1[node2.type];
13616 if (node2.type === "decl") {
13617 key = node2.prop.toLowerCase();
13618 } else if (node2.type === "atrule") {
13619 key = node2.name.toLowerCase();
13620 }
13621 if (key && node2.append) {
13622 return [
13623 type,
13624 type + "-" + key,
13625 CHILDREN$1,
13626 type + "Exit",
13627 type + "Exit-" + key
13628 ];
13629 } else if (key) {
13630 return [
13631 type,
13632 type + "-" + key,
13633 type + "Exit",
13634 type + "Exit-" + key
13635 ];
13636 } else if (node2.append) {
13637 return [
13638 type,
13639 CHILDREN$1,
13640 type + "Exit"
13641 ];
13642 } else {
13643 return [
13644 type,
13645 type + "Exit"
13646 ];
13647 }
13648 }
13649 function toStack$1(node2) {
13650 var events;
13651 if (node2.type === "document") {
13652 events = [
13653 "Document",
13654 CHILDREN$1,
13655 "DocumentExit"
13656 ];
13657 } else if (node2.type === "root") {
13658 events = [
13659 "Root",
13660 CHILDREN$1,
13661 "RootExit"
13662 ];
13663 } else {
13664 events = getEvents$1(node2);
13665 }
13666 return {
13667 eventIndex: 0,
13668 events: events,
13669 iterator: 0,
13670 node: node2,
13671 visitorIndex: 0,
13672 visitors: []
13673 };
13674 }
13675 function cleanMarks$1(node2) {
13676 node2[isClean$3] = false;
13677 if (node2.nodes) node2.nodes.forEach(function(i2) {
13678 return cleanMarks$1(i2);
13679 });
13680 return node2;
13681 }
13682 var postcss$2$1 = {};
13683 var LazyResult$2$1 = /*#__PURE__*/ function() {
13684 function LazyResult(processor2, css, opts) {
13685 var _this = this;
13686 this.stringified = false;
13687 this.processed = false;
13688 var root2;
13689 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
13690 root2 = cleanMarks$1(css);
13691 } else if (_instanceof(css, LazyResult) || _instanceof(css, Result$2$1)) {
13692 root2 = cleanMarks$1(css.root);
13693 if (css.map) {
13694 if (typeof opts.map === "undefined") opts.map = {};
13695 if (!opts.map.inline) opts.map.inline = false;
13696 opts.map.prev = css.map;
13697 }
13698 } else {
13699 var parser2 = parse$2$1;
13700 if (opts.syntax) parser2 = opts.syntax.parse;
13701 if (opts.parser) parser2 = opts.parser;
13702 if (parser2.parse) parser2 = parser2.parse;
13703 try {
13704 root2 = parser2(css, opts);
13705 } catch (error) {
13706 this.processed = true;
13707 this.error = error;
13708 }
13709 if (root2 && !root2[my$3]) {
13710 Container$1$1.rebuild(root2);
13711 }
13712 }
13713 this.result = new Result$2$1(processor2, root2, opts);
13714 this.helpers = _extends({}, postcss$2$1, {
13715 postcss: postcss$2$1,
13716 result: this.result
13717 });
13718 this.plugins = this.processor.plugins.map(function(plugin22) {
13719 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
13720 return _extends({}, plugin22, plugin22.prepare(_this.result));
13721 } else {
13722 return plugin22;
13723 }
13724 });
13725 }
13726 var _proto = LazyResult.prototype;
13727 _proto.async = function async() {
13728 if (this.error) return Promise.reject(this.error);
13729 if (this.processed) return Promise.resolve(this.result);
13730 if (!this.processing) {
13731 this.processing = this.runAsync();
13732 }
13733 return this.processing;
13734 };
13735 _proto.catch = function _catch(onRejected) {
13736 return this.async().catch(onRejected);
13737 };
13738 _proto.finally = function _finally(onFinally) {
13739 return this.async().then(onFinally, onFinally);
13740 };
13741 _proto.getAsyncError = function getAsyncError() {
13742 throw new Error("Use process(css).then(cb) to work with async plugins");
13743 };
13744 _proto.handleError = function handleError(error, node2) {
13745 var plugin22 = this.result.lastPlugin;
13746 try {
13747 if (node2) node2.addToError(error);
13748 this.error = error;
13749 if (error.name === "CssSyntaxError" && !error.plugin) {
13750 error.plugin = plugin22.postcssPlugin;
13751 error.setMessage();
13752 } else if (plugin22.postcssVersion) {
13753 if (true) {
13754 var pluginName = plugin22.postcssPlugin;
13755 var pluginVer = plugin22.postcssVersion;
13756 var runtimeVer = this.result.processor.version;
13757 var a2 = pluginVer.split(".");
13758 var b = runtimeVer.split(".");
13759 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
13760 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.");
13761 }
13762 }
13763 }
13764 } catch (err) {
13765 if (console && console.error) console.error(err);
13766 }
13767 return error;
13768 };
13769 _proto.prepareVisitors = function prepareVisitors() {
13770 var _this = this;
13771 this.listeners = {};
13772 var add = function(plugin22, type, cb) {
13773 if (!_this.listeners[type]) _this.listeners[type] = [];
13774 _this.listeners[type].push([
13775 plugin22,
13776 cb
13777 ]);
13778 };
13779 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13780 var plugin22 = _step.value;
13781 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
13782 for(var event in plugin22){
13783 if (!PLUGIN_PROPS$1[event] && /^[A-Z]/.test(event)) {
13784 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
13785 }
13786 if (!NOT_VISITORS$1[event]) {
13787 if (_type_of(plugin22[event]) === "object") {
13788 for(var filter in plugin22[event]){
13789 if (filter === "*") {
13790 add(plugin22, event, plugin22[event][filter]);
13791 } else {
13792 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
13793 }
13794 }
13795 } else if (typeof plugin22[event] === "function") {
13796 add(plugin22, event, plugin22[event]);
13797 }
13798 }
13799 }
13800 }
13801 }
13802 this.hasListener = Object.keys(this.listeners).length > 0;
13803 };
13804 _proto.runAsync = function runAsync() {
13805 var _this = this;
13806 return _async_to_generator(function() {
13807 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
13808 return _ts_generator(this, function(_state) {
13809 switch(_state.label){
13810 case 0:
13811 _this.plugin = 0;
13812 i2 = 0;
13813 _state.label = 1;
13814 case 1:
13815 if (!(i2 < _this.plugins.length)) return [
13816 3,
13817 6
13818 ];
13819 plugin22 = _this.plugins[i2];
13820 promise = _this.runOnRoot(plugin22);
13821 if (!isPromise$1(promise)) return [
13822 3,
13823 5
13824 ];
13825 _state.label = 2;
13826 case 2:
13827 _state.trys.push([
13828 2,
13829 4,
13830 ,
13831 5
13832 ]);
13833 return [
13834 4,
13835 promise
13836 ];
13837 case 3:
13838 _state.sent();
13839 return [
13840 3,
13841 5
13842 ];
13843 case 4:
13844 error = _state.sent();
13845 throw _this.handleError(error);
13846 case 5:
13847 i2++;
13848 return [
13849 3,
13850 1
13851 ];
13852 case 6:
13853 _this.prepareVisitors();
13854 if (!_this.hasListener) return [
13855 3,
13856 18
13857 ];
13858 root2 = _this.result.root;
13859 _state.label = 7;
13860 case 7:
13861 if (!!root2[isClean$3]) return [
13862 3,
13863 14
13864 ];
13865 root2[isClean$3] = true;
13866 stack = [
13867 toStack$1(root2)
13868 ];
13869 _state.label = 8;
13870 case 8:
13871 if (!(stack.length > 0)) return [
13872 3,
13873 13
13874 ];
13875 promise1 = _this.visitTick(stack);
13876 if (!isPromise$1(promise1)) return [
13877 3,
13878 12
13879 ];
13880 _state.label = 9;
13881 case 9:
13882 _state.trys.push([
13883 9,
13884 11,
13885 ,
13886 12
13887 ]);
13888 return [
13889 4,
13890 promise1
13891 ];
13892 case 10:
13893 _state.sent();
13894 return [
13895 3,
13896 12
13897 ];
13898 case 11:
13899 e2 = _state.sent();
13900 node2 = stack[stack.length - 1].node;
13901 throw _this.handleError(e2, node2);
13902 case 12:
13903 return [
13904 3,
13905 8
13906 ];
13907 case 13:
13908 return [
13909 3,
13910 7
13911 ];
13912 case 14:
13913 if (!_this.listeners.OnceExit) return [
13914 3,
13915 18
13916 ];
13917 _loop = function() {
13918 var _step_value, plugin22, visitor, roots, e2;
13919 return _ts_generator(this, function(_state) {
13920 switch(_state.label){
13921 case 0:
13922 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13923 _this.result.lastPlugin = plugin22;
13924 _state.label = 1;
13925 case 1:
13926 _state.trys.push([
13927 1,
13928 6,
13929 ,
13930 7
13931 ]);
13932 if (!(root2.type === "document")) return [
13933 3,
13934 3
13935 ];
13936 roots = root2.nodes.map(function(subRoot) {
13937 return visitor(subRoot, _this.helpers);
13938 });
13939 return [
13940 4,
13941 Promise.all(roots)
13942 ];
13943 case 2:
13944 _state.sent();
13945 return [
13946 3,
13947 5
13948 ];
13949 case 3:
13950 return [
13951 4,
13952 visitor(root2, _this.helpers)
13953 ];
13954 case 4:
13955 _state.sent();
13956 _state.label = 5;
13957 case 5:
13958 return [
13959 3,
13960 7
13961 ];
13962 case 6:
13963 e2 = _state.sent();
13964 throw _this.handleError(e2);
13965 case 7:
13966 return [
13967 2
13968 ];
13969 }
13970 });
13971 };
13972 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
13973 _state.label = 15;
13974 case 15:
13975 if (!!(_step = _iterator()).done) return [
13976 3,
13977 18
13978 ];
13979 return [
13980 5,
13981 _ts_values(_loop())
13982 ];
13983 case 16:
13984 _state.sent();
13985 _state.label = 17;
13986 case 17:
13987 return [
13988 3,
13989 15
13990 ];
13991 case 18:
13992 _this.processed = true;
13993 return [
13994 2,
13995 _this.stringify()
13996 ];
13997 }
13998 });
13999 })();
14000 };
14001 _proto.runOnRoot = function runOnRoot(plugin22) {
14002 var _this = this;
14003 this.result.lastPlugin = plugin22;
14004 try {
14005 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
14006 if (this.result.root.type === "document") {
14007 var roots = this.result.root.nodes.map(function(root2) {
14008 return plugin22.Once(root2, _this.helpers);
14009 });
14010 if (isPromise$1(roots[0])) {
14011 return Promise.all(roots);
14012 }
14013 return roots;
14014 }
14015 return plugin22.Once(this.result.root, this.helpers);
14016 } else if (typeof plugin22 === "function") {
14017 return plugin22(this.result.root, this.result);
14018 }
14019 } catch (error) {
14020 throw this.handleError(error);
14021 }
14022 };
14023 _proto.stringify = function stringify() {
14024 if (this.error) throw this.error;
14025 if (this.stringified) return this.result;
14026 this.stringified = true;
14027 this.sync();
14028 var opts = this.result.opts;
14029 var str = stringify$2$1;
14030 if (opts.syntax) str = opts.syntax.stringify;
14031 if (opts.stringifier) str = opts.stringifier;
14032 if (str.stringify) str = str.stringify;
14033 var map = new MapGenerator$1$1(str, this.result.root, this.result.opts);
14034 var data = map.generate();
14035 this.result.css = data[0];
14036 this.result.map = data[1];
14037 return this.result;
14038 };
14039 _proto.sync = function sync() {
14040 if (this.error) throw this.error;
14041 if (this.processed) return this.result;
14042 this.processed = true;
14043 if (this.processing) {
14044 throw this.getAsyncError();
14045 }
14046 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
14047 var plugin22 = _step.value;
14048 var promise = this.runOnRoot(plugin22);
14049 if (isPromise$1(promise)) {
14050 throw this.getAsyncError();
14051 }
14052 }
14053 this.prepareVisitors();
14054 if (this.hasListener) {
14055 var root2 = this.result.root;
14056 while(!root2[isClean$3]){
14057 root2[isClean$3] = true;
14058 this.walkSync(root2);
14059 }
14060 if (this.listeners.OnceExit) {
14061 if (root2.type === "document") {
14062 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
14063 var subRoot = _step1.value;
14064 this.visitSync(this.listeners.OnceExit, subRoot);
14065 }
14066 } else {
14067 this.visitSync(this.listeners.OnceExit, root2);
14068 }
14069 }
14070 }
14071 return this.result;
14072 };
14073 _proto.then = function then(onFulfilled, onRejected) {
14074 if (true) {
14075 if (!("from" in this.opts)) {
14076 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.");
14077 }
14078 }
14079 return this.async().then(onFulfilled, onRejected);
14080 };
14081 _proto.toString = function toString() {
14082 return this.css;
14083 };
14084 _proto.visitSync = function visitSync(visitors, node2) {
14085 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
14086 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
14087 this.result.lastPlugin = plugin22;
14088 var promise = void 0;
14089 try {
14090 promise = visitor(node2, this.helpers);
14091 } catch (e2) {
14092 throw this.handleError(e2, node2.proxyOf);
14093 }
14094 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
14095 return true;
14096 }
14097 if (isPromise$1(promise)) {
14098 throw this.getAsyncError();
14099 }
14100 }
14101 };
14102 _proto.visitTick = function visitTick(stack) {
14103 var visit2 = stack[stack.length - 1];
14104 var node2 = visit2.node, visitors = visit2.visitors;
14105 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
14106 stack.pop();
14107 return;
14108 }
14109 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
14110 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
14111 visit2.visitorIndex += 1;
14112 if (visit2.visitorIndex === visitors.length) {
14113 visit2.visitors = [];
14114 visit2.visitorIndex = 0;
14115 }
14116 this.result.lastPlugin = plugin22;
14117 try {
14118 return visitor(node2.toProxy(), this.helpers);
14119 } catch (e2) {
14120 throw this.handleError(e2, node2);
14121 }
14122 }
14123 if (visit2.iterator !== 0) {
14124 var iterator = visit2.iterator;
14125 var child;
14126 while(child = node2.nodes[node2.indexes[iterator]]){
14127 node2.indexes[iterator] += 1;
14128 if (!child[isClean$3]) {
14129 child[isClean$3] = true;
14130 stack.push(toStack$1(child));
14131 return;
14132 }
14133 }
14134 visit2.iterator = 0;
14135 delete node2.indexes[iterator];
14136 }
14137 var events = visit2.events;
14138 while(visit2.eventIndex < events.length){
14139 var event = events[visit2.eventIndex];
14140 visit2.eventIndex += 1;
14141 if (event === CHILDREN$1) {
14142 if (node2.nodes && node2.nodes.length) {
14143 node2[isClean$3] = true;
14144 visit2.iterator = node2.getIterator();
14145 }
14146 return;
14147 } else if (this.listeners[event]) {
14148 visit2.visitors = this.listeners[event];
14149 return;
14150 }
14151 }
14152 stack.pop();
14153 };
14154 _proto.walkSync = function walkSync(node2) {
14155 var _this = this;
14156 node2[isClean$3] = true;
14157 var events = getEvents$1(node2);
14158 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
14159 var event = _step.value;
14160 if (event === CHILDREN$1) {
14161 if (node2.nodes) {
14162 node2.each(function(child) {
14163 if (!child[isClean$3]) _this.walkSync(child);
14164 });
14165 }
14166 } else {
14167 var visitors = this.listeners[event];
14168 if (visitors) {
14169 if (this.visitSync(visitors, node2.toProxy())) return;
14170 }
14171 }
14172 }
14173 };
14174 _proto.warnings = function warnings() {
14175 return this.sync().warnings();
14176 };
14177 _create_class(LazyResult, [
14178 {
14179 key: "content",
14180 get: function get() {
14181 return this.stringify().content;
14182 }
14183 },
14184 {
14185 key: "css",
14186 get: function get() {
14187 return this.stringify().css;
14188 }
14189 },
14190 {
14191 key: "map",
14192 get: function get() {
14193 return this.stringify().map;
14194 }
14195 },
14196 {
14197 key: "messages",
14198 get: function get() {
14199 return this.sync().messages;
14200 }
14201 },
14202 {
14203 key: "opts",
14204 get: function get() {
14205 return this.result.opts;
14206 }
14207 },
14208 {
14209 key: "processor",
14210 get: function get() {
14211 return this.result.processor;
14212 }
14213 },
14214 {
14215 key: "root",
14216 get: function get() {
14217 return this.sync().root;
14218 }
14219 },
14220 {
14221 key: Symbol.toStringTag,
14222 get: function get() {
14223 return "LazyResult";
14224 }
14225 }
14226 ]);
14227 return LazyResult;
14228 }();
14229 LazyResult$2$1.registerPostcss = function(dependant) {
14230 postcss$2$1 = dependant;
14231 };
14232 var lazyResult$1 = LazyResult$2$1;
14233 LazyResult$2$1.default = LazyResult$2$1;
14234 Root$3$1.registerLazyResult(LazyResult$2$1);
14235 Document$2$1.registerLazyResult(LazyResult$2$1);
14236 var MapGenerator2$1 = mapGenerator$1;
14237 var stringify$1$1 = stringify_1$1;
14238 var warnOnce2$1 = warnOnce$2$1;
14239 var parse$1$1 = parse_1$1;
14240 var Result$1$1 = result$1;
14241 var NoWorkResult$1$1 = /*#__PURE__*/ function() {
14242 function NoWorkResult(processor2, css, opts) {
14243 css = css.toString();
14244 this.stringified = false;
14245 this._processor = processor2;
14246 this._css = css;
14247 this._opts = opts;
14248 this._map = void 0;
14249 var root2;
14250 var str = stringify$1$1;
14251 this.result = new Result$1$1(this._processor, root2, this._opts);
14252 this.result.css = css;
14253 var self = this;
14254 Object.defineProperty(this.result, "root", {
14255 get: function get() {
14256 return self.root;
14257 }
14258 });
14259 var map = new MapGenerator2$1(str, root2, this._opts, css);
14260 if (map.isMap()) {
14261 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
14262 if (generatedCSS) {
14263 this.result.css = generatedCSS;
14264 }
14265 if (generatedMap) {
14266 this.result.map = generatedMap;
14267 }
14268 } else {
14269 map.clearAnnotation();
14270 this.result.css = map.css;
14271 }
14272 }
14273 var _proto = NoWorkResult.prototype;
14274 _proto.async = function async() {
14275 if (this.error) return Promise.reject(this.error);
14276 return Promise.resolve(this.result);
14277 };
14278 _proto.catch = function _catch(onRejected) {
14279 return this.async().catch(onRejected);
14280 };
14281 _proto.finally = function _finally(onFinally) {
14282 return this.async().then(onFinally, onFinally);
14283 };
14284 _proto.sync = function sync() {
14285 if (this.error) throw this.error;
14286 return this.result;
14287 };
14288 _proto.then = function then(onFulfilled, onRejected) {
14289 if (true) {
14290 if (!("from" in this._opts)) {
14291 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.");
14292 }
14293 }
14294 return this.async().then(onFulfilled, onRejected);
14295 };
14296 _proto.toString = function toString() {
14297 return this._css;
14298 };
14299 _proto.warnings = function warnings() {
14300 return [];
14301 };
14302 _create_class(NoWorkResult, [
14303 {
14304 key: "content",
14305 get: function get() {
14306 return this.result.css;
14307 }
14308 },
14309 {
14310 key: "css",
14311 get: function get() {
14312 return this.result.css;
14313 }
14314 },
14315 {
14316 key: "map",
14317 get: function get() {
14318 return this.result.map;
14319 }
14320 },
14321 {
14322 key: "messages",
14323 get: function get() {
14324 return [];
14325 }
14326 },
14327 {
14328 key: "opts",
14329 get: function get() {
14330 return this.result.opts;
14331 }
14332 },
14333 {
14334 key: "processor",
14335 get: function get() {
14336 return this.result.processor;
14337 }
14338 },
14339 {
14340 key: "root",
14341 get: function get() {
14342 if (this._root) {
14343 return this._root;
14344 }
14345 var root2;
14346 var parser2 = parse$1$1;
14347 try {
14348 root2 = parser2(this._css, this._opts);
14349 } catch (error) {
14350 this.error = error;
14351 }
14352 if (this.error) {
14353 throw this.error;
14354 } else {
14355 this._root = root2;
14356 return root2;
14357 }
14358 }
14359 },
14360 {
14361 key: Symbol.toStringTag,
14362 get: function get() {
14363 return "NoWorkResult";
14364 }
14365 }
14366 ]);
14367 return NoWorkResult;
14368 }();
14369 var noWorkResult$1 = NoWorkResult$1$1;
14370 NoWorkResult$1$1.default = NoWorkResult$1$1;
14371 var NoWorkResult2$1 = noWorkResult$1;
14372 var LazyResult$1$1 = lazyResult$1;
14373 var Document$1$1 = document$1$1;
14374 var Root$2$1 = root$1;
14375 var Processor$1$1 = /*#__PURE__*/ function() {
14376 function Processor(plugins) {
14377 if (plugins === void 0) plugins = [];
14378 this.version = "8.4.38";
14379 this.plugins = this.normalize(plugins);
14380 }
14381 var _proto = Processor.prototype;
14382 _proto.normalize = function normalize(plugins) {
14383 var normalized = [];
14384 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
14385 var i2 = _step.value;
14386 if (i2.postcss === true) {
14387 i2 = i2();
14388 } else if (i2.postcss) {
14389 i2 = i2.postcss;
14390 }
14391 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
14392 normalized = normalized.concat(i2.plugins);
14393 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
14394 normalized.push(i2);
14395 } else if (typeof i2 === "function") {
14396 normalized.push(i2);
14397 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
14398 if (true) {
14399 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.");
14400 }
14401 } else {
14402 throw new Error(i2 + " is not a PostCSS plugin");
14403 }
14404 }
14405 return normalized;
14406 };
14407 _proto.process = function process1(css, opts) {
14408 if (opts === void 0) opts = {};
14409 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
14410 return new NoWorkResult2$1(this, css, opts);
14411 } else {
14412 return new LazyResult$1$1(this, css, opts);
14413 }
14414 };
14415 _proto.use = function use(plugin22) {
14416 this.plugins = this.plugins.concat(this.normalize([
14417 plugin22
14418 ]));
14419 return this;
14420 };
14421 return Processor;
14422 }();
14423 var processor$1 = Processor$1$1;
14424 Processor$1$1.default = Processor$1$1;
14425 Root$2$1.registerProcessor(Processor$1$1);
14426 Document$1$1.registerProcessor(Processor$1$1);
14427 var Declaration$1$1 = declaration$1;
14428 var PreviousMap2$1 = previousMap$1;
14429 var Comment$1$1 = comment$1;
14430 var AtRule$1$1 = atRule$1;
14431 var Input$1$1 = input$1;
14432 var Root$1$1 = root$1;
14433 var Rule$1$1 = rule$1;
14434 function fromJSON$1$1(json, inputs) {
14435 if (Array.isArray(json)) return json.map(function(n2) {
14436 return fromJSON$1$1(n2);
14437 });
14438 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
14439 "inputs"
14440 ]);
14441 if (ownInputs) {
14442 inputs = [];
14443 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
14444 var input2 = _step.value;
14445 var inputHydrated = _extends({}, input2, {
14446 __proto__: Input$1$1.prototype
14447 });
14448 if (inputHydrated.map) {
14449 inputHydrated.map = _extends({}, inputHydrated.map, {
14450 __proto__: PreviousMap2$1.prototype
14451 });
14452 }
14453 inputs.push(inputHydrated);
14454 }
14455 }
14456 if (defaults.nodes) {
14457 defaults.nodes = json.nodes.map(function(n2) {
14458 return fromJSON$1$1(n2, inputs);
14459 });
14460 }
14461 if (defaults.source) {
14462 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
14463 "inputId"
14464 ]);
14465 defaults.source = source;
14466 if (inputId != null) {
14467 defaults.source.input = inputs[inputId];
14468 }
14469 }
14470 if (defaults.type === "root") {
14471 return new Root$1$1(defaults);
14472 } else if (defaults.type === "decl") {
14473 return new Declaration$1$1(defaults);
14474 } else if (defaults.type === "rule") {
14475 return new Rule$1$1(defaults);
14476 } else if (defaults.type === "comment") {
14477 return new Comment$1$1(defaults);
14478 } else if (defaults.type === "atrule") {
14479 return new AtRule$1$1(defaults);
14480 } else {
14481 throw new Error("Unknown node type: " + json.type);
14482 }
14483 }
14484 var fromJSON_1$1 = fromJSON$1$1;
14485 fromJSON$1$1.default = fromJSON$1$1;
14486 var CssSyntaxError2$1 = cssSyntaxError$1;
14487 var Declaration2$1 = declaration$1;
14488 var LazyResult2$1 = lazyResult$1;
14489 var Container2$1 = container$1;
14490 var Processor2$1 = processor$1;
14491 var stringify$5 = stringify_1$1;
14492 var fromJSON$2 = fromJSON_1$1;
14493 var Document22 = document$1$1;
14494 var Warning2$1 = warning$1;
14495 var Comment2$1 = comment$1;
14496 var AtRule2$1 = atRule$1;
14497 var Result2$1 = result$1;
14498 var Input2$1 = input$1;
14499 var parse$5 = parse_1$1;
14500 var list$3 = list_1$1;
14501 var Rule2$1 = rule$1;
14502 var Root2$1 = root$1;
14503 var Node2$1 = node$1;
14504 function postcss$3() {
14505 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
14506 plugins[_key] = arguments[_key];
14507 }
14508 if (plugins.length === 1 && Array.isArray(plugins[0])) {
14509 plugins = plugins[0];
14510 }
14511 return new Processor2$1(plugins);
14512 }
14513 postcss$3.plugin = function plugin(name, initializer) {
14514 var warningPrinted = false;
14515 function creator() {
14516 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
14517 args[_key] = arguments[_key];
14518 }
14519 if (console && console.warn && !warningPrinted) {
14520 warningPrinted = true;
14521 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
14522 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
14523 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
14524 }
14525 }
14526 var transformer = initializer.apply(void 0, [].concat(args));
14527 transformer.postcssPlugin = name;
14528 transformer.postcssVersion = new Processor2$1().version;
14529 return transformer;
14530 }
14531 var cache;
14532 Object.defineProperty(creator, "postcss", {
14533 get: function get() {
14534 if (!cache) cache = creator();
14535 return cache;
14536 }
14537 });
14538 creator.process = function(css, processOpts, pluginOpts) {
14539 return postcss$3([
14540 creator(pluginOpts)
14541 ]).process(css, processOpts);
14542 };
14543 return creator;
14544 };
14545 postcss$3.stringify = stringify$5;
14546 postcss$3.parse = parse$5;
14547 postcss$3.fromJSON = fromJSON$2;
14548 postcss$3.list = list$3;
14549 postcss$3.comment = function(defaults) {
14550 return new Comment2$1(defaults);
14551 };
14552 postcss$3.atRule = function(defaults) {
14553 return new AtRule2$1(defaults);
14554 };
14555 postcss$3.decl = function(defaults) {
14556 return new Declaration2$1(defaults);
14557 };
14558 postcss$3.rule = function(defaults) {
14559 return new Rule2$1(defaults);
14560 };
14561 postcss$3.root = function(defaults) {
14562 return new Root2$1(defaults);
14563 };
14564 postcss$3.document = function(defaults) {
14565 return new Document22(defaults);
14566 };
14567 postcss$3.CssSyntaxError = CssSyntaxError2$1;
14568 postcss$3.Declaration = Declaration2$1;
14569 postcss$3.Container = Container2$1;
14570 postcss$3.Processor = Processor2$1;
14571 postcss$3.Document = Document22;
14572 postcss$3.Comment = Comment2$1;
14573 postcss$3.Warning = Warning2$1;
14574 postcss$3.AtRule = AtRule2$1;
14575 postcss$3.Result = Result2$1;
14576 postcss$3.Input = Input2$1;
14577 postcss$3.Rule = Rule2$1;
14578 postcss$3.Root = Root2$1;
14579 postcss$3.Node = Node2$1;
14580 LazyResult2$1.registerPostcss(postcss$3);
14581 var postcss_1$1 = postcss$3;
14582 postcss$3.default = postcss$3;
14583 var postcss$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(postcss_1$1);
14584 postcss$1$1.stringify;
14585 postcss$1$1.fromJSON;
14586 postcss$1$1.plugin;
14587 postcss$1$1.parse;
14588 postcss$1$1.list;
14589 postcss$1$1.document;
14590 postcss$1$1.comment;
14591 postcss$1$1.atRule;
14592 postcss$1$1.rule;
14593 postcss$1$1.decl;
14594 postcss$1$1.root;
14595 postcss$1$1.CssSyntaxError;
14596 postcss$1$1.Declaration;
14597 postcss$1$1.Container;
14598 postcss$1$1.Processor;
14599 postcss$1$1.Document;
14600 postcss$1$1.Comment;
14601 postcss$1$1.Warning;
14602 postcss$1$1.AtRule;
14603 postcss$1$1.Result;
14604 postcss$1$1.Input;
14605 postcss$1$1.Rule;
14606 postcss$1$1.Root;
14607 postcss$1$1.Node;
14608 var __defProp2 = Object.defineProperty;
14609 var __defNormalProp2 = function(obj, key, value) {
14610 return key in obj ? __defProp2(obj, key, {
14611 enumerable: true,
14612 configurable: true,
14613 writable: true,
14614 value: value
14615 }) : obj[key] = value;
14616 };
14617 var __publicField2 = function(obj, key, value) {
14618 return __defNormalProp2(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
14619 };
14620 function getDefaultExportFromCjs(x2) {
14621 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
14622 }
14623 function getAugmentedNamespace(n2) {
14624 if (n2.__esModule) return n2;
14625 var f2 = n2.default;
14626 if (typeof f2 == "function") {
14627 var a2 = function a22() {
14628 if (_instanceof(this, a22)) {
14629 return Reflect.construct(f2, arguments, this.constructor);
14630 }
14631 return f2.apply(this, arguments);
14632 };
14633 a2.prototype = f2.prototype;
14634 } else a2 = {};
14635 Object.defineProperty(a2, "__esModule", {
14636 value: true
14637 });
14638 Object.keys(n2).forEach(function(k) {
14639 var d = Object.getOwnPropertyDescriptor(n2, k);
14640 Object.defineProperty(a2, k, d.get ? d : {
14641 enumerable: true,
14642 get: function get() {
14643 return n2[k];
14644 }
14645 });
14646 });
14647 return a2;
14648 }
14649 var picocolors_browser = {
14650 exports: {}
14651 };
14652 var x = String;
14653 var create = function create() {
14654 return {
14655 isColorSupported: false,
14656 reset: x,
14657 bold: x,
14658 dim: x,
14659 italic: x,
14660 underline: x,
14661 inverse: x,
14662 hidden: x,
14663 strikethrough: x,
14664 black: x,
14665 red: x,
14666 green: x,
14667 yellow: x,
14668 blue: x,
14669 magenta: x,
14670 cyan: x,
14671 white: x,
14672 gray: x,
14673 bgBlack: x,
14674 bgRed: x,
14675 bgGreen: x,
14676 bgYellow: x,
14677 bgBlue: x,
14678 bgMagenta: x,
14679 bgCyan: x,
14680 bgWhite: x
14681 };
14682 };
14683 picocolors_browser.exports = create();
14684 picocolors_browser.exports.createColors = create;
14685 var picocolors_browserExports = picocolors_browser.exports;
14686 var __viteBrowserExternal = {};
14687 var __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
14688 __proto__: null,
14689 default: __viteBrowserExternal
14690 }, Symbol.toStringTag, {
14691 value: "Module"
14692 }));
14693 var require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
14694 var pico = picocolors_browserExports;
14695 var terminalHighlight$1 = require$$2;
14696 var CssSyntaxError$3 = /*#__PURE__*/ function(Error1) {
14697 _inherits(CssSyntaxError2, Error1);
14698 function CssSyntaxError2(message, line, column, source, file, plugin22) {
14699 var _this;
14700 _this = Error1.call(this, message) || this;
14701 _this.name = "CssSyntaxError";
14702 _this.reason = message;
14703 if (file) {
14704 _this.file = file;
14705 }
14706 if (source) {
14707 _this.source = source;
14708 }
14709 if (plugin22) {
14710 _this.plugin = plugin22;
14711 }
14712 if (typeof line !== "undefined" && typeof column !== "undefined") {
14713 if (typeof line === "number") {
14714 _this.line = line;
14715 _this.column = column;
14716 } else {
14717 _this.line = line.line;
14718 _this.column = line.column;
14719 _this.endLine = column.line;
14720 _this.endColumn = column.column;
14721 }
14722 }
14723 _this.setMessage();
14724 if (Error.captureStackTrace) {
14725 Error.captureStackTrace(_this, CssSyntaxError2);
14726 }
14727 return _this;
14728 }
14729 var _proto = CssSyntaxError2.prototype;
14730 _proto.setMessage = function setMessage() {
14731 this.message = this.plugin ? this.plugin + ": " : "";
14732 this.message += this.file ? this.file : "<css input>";
14733 if (typeof this.line !== "undefined") {
14734 this.message += ":" + this.line + ":" + this.column;
14735 }
14736 this.message += ": " + this.reason;
14737 };
14738 _proto.showSourceCode = function showSourceCode(color) {
14739 var _this = this;
14740 if (!this.source) return "";
14741 var css = this.source;
14742 if (color == null) color = pico.isColorSupported;
14743 if (terminalHighlight$1) {
14744 if (color) css = terminalHighlight$1(css);
14745 }
14746 var lines = css.split(/\r?\n/);
14747 var start = Math.max(this.line - 3, 0);
14748 var end = Math.min(this.line + 2, lines.length);
14749 var maxWidth = String(end).length;
14750 var mark, aside;
14751 if (color) {
14752 var _pico_createColors = pico.createColors(true), bold = _pico_createColors.bold, gray = _pico_createColors.gray, red = _pico_createColors.red;
14753 mark = function(text) {
14754 return bold(red(text));
14755 };
14756 aside = function(text) {
14757 return gray(text);
14758 };
14759 } else {
14760 mark = aside = function(str) {
14761 return str;
14762 };
14763 }
14764 return lines.slice(start, end).map(function(line, index2) {
14765 var number = start + 1 + index2;
14766 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
14767 if (number === _this.line) {
14768 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
14769 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
14770 }
14771 return " " + aside(gutter) + line;
14772 }).join("\n");
14773 };
14774 _proto.toString = function toString() {
14775 var code = this.showSourceCode();
14776 if (code) {
14777 code = "\n\n" + code + "\n";
14778 }
14779 return this.name + ": " + this.message + code;
14780 };
14781 return CssSyntaxError2;
14782 }(_wrap_native_super(Error));
14783 var cssSyntaxError = CssSyntaxError$3;
14784 CssSyntaxError$3.default = CssSyntaxError$3;
14785 var symbols = {};
14786 symbols.isClean = Symbol("isClean");
14787 symbols.my = Symbol("my");
14788 var DEFAULT_RAW = {
14789 after: "\n",
14790 beforeClose: "\n",
14791 beforeComment: "\n",
14792 beforeDecl: "\n",
14793 beforeOpen: " ",
14794 beforeRule: "\n",
14795 colon: ": ",
14796 commentLeft: " ",
14797 commentRight: " ",
14798 emptyBody: "",
14799 indent: " ",
14800 semicolon: false
14801 };
14802 function capitalize(str) {
14803 return str[0].toUpperCase() + str.slice(1);
14804 }
14805 var Stringifier$2 = /*#__PURE__*/ function() {
14806 function Stringifier2(builder) {
14807 this.builder = builder;
14808 }
14809 var _proto = Stringifier2.prototype;
14810 _proto.atrule = function atrule(node2, semicolon) {
14811 var name = "@" + node2.name;
14812 var params = node2.params ? this.rawValue(node2, "params") : "";
14813 if (typeof node2.raws.afterName !== "undefined") {
14814 name += node2.raws.afterName;
14815 } else if (params) {
14816 name += " ";
14817 }
14818 if (node2.nodes) {
14819 this.block(node2, name + params);
14820 } else {
14821 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
14822 this.builder(name + params + end, node2);
14823 }
14824 };
14825 _proto.beforeAfter = function beforeAfter(node2, detect) {
14826 var value;
14827 if (node2.type === "decl") {
14828 value = this.raw(node2, null, "beforeDecl");
14829 } else if (node2.type === "comment") {
14830 value = this.raw(node2, null, "beforeComment");
14831 } else if (detect === "before") {
14832 value = this.raw(node2, null, "beforeRule");
14833 } else {
14834 value = this.raw(node2, null, "beforeClose");
14835 }
14836 var buf = node2.parent;
14837 var depth = 0;
14838 while(buf && buf.type !== "root"){
14839 depth += 1;
14840 buf = buf.parent;
14841 }
14842 if (value.includes("\n")) {
14843 var indent = this.raw(node2, null, "indent");
14844 if (indent.length) {
14845 for(var step = 0; step < depth; step++)value += indent;
14846 }
14847 }
14848 return value;
14849 };
14850 _proto.block = function block(node2, start) {
14851 var between = this.raw(node2, "between", "beforeOpen");
14852 this.builder(start + between + "{", node2, "start");
14853 var after;
14854 if (node2.nodes && node2.nodes.length) {
14855 this.body(node2);
14856 after = this.raw(node2, "after");
14857 } else {
14858 after = this.raw(node2, "after", "emptyBody");
14859 }
14860 if (after) this.builder(after);
14861 this.builder("}", node2, "end");
14862 };
14863 _proto.body = function body(node2) {
14864 var last = node2.nodes.length - 1;
14865 while(last > 0){
14866 if (node2.nodes[last].type !== "comment") break;
14867 last -= 1;
14868 }
14869 var semicolon = this.raw(node2, "semicolon");
14870 for(var i2 = 0; i2 < node2.nodes.length; i2++){
14871 var child = node2.nodes[i2];
14872 var before = this.raw(child, "before");
14873 if (before) this.builder(before);
14874 this.stringify(child, last !== i2 || semicolon);
14875 }
14876 };
14877 _proto.comment = function comment(node2) {
14878 var left = this.raw(node2, "left", "commentLeft");
14879 var right = this.raw(node2, "right", "commentRight");
14880 this.builder("/*" + left + node2.text + right + "*/", node2);
14881 };
14882 _proto.decl = function decl(node2, semicolon) {
14883 var between = this.raw(node2, "between", "colon");
14884 var string = node2.prop + between + this.rawValue(node2, "value");
14885 if (node2.important) {
14886 string += node2.raws.important || " !important";
14887 }
14888 if (semicolon) string += ";";
14889 this.builder(string, node2);
14890 };
14891 _proto.document = function document1(node2) {
14892 this.body(node2);
14893 };
14894 _proto.raw = function raw(node2, own, detect) {
14895 var value;
14896 if (!detect) detect = own;
14897 if (own) {
14898 value = node2.raws[own];
14899 if (typeof value !== "undefined") return value;
14900 }
14901 var parent = node2.parent;
14902 if (detect === "before") {
14903 if (!parent || parent.type === "root" && parent.first === node2) {
14904 return "";
14905 }
14906 if (parent && parent.type === "document") {
14907 return "";
14908 }
14909 }
14910 if (!parent) return DEFAULT_RAW[detect];
14911 var root2 = node2.root();
14912 if (!root2.rawCache) root2.rawCache = {};
14913 if (typeof root2.rawCache[detect] !== "undefined") {
14914 return root2.rawCache[detect];
14915 }
14916 if (detect === "before" || detect === "after") {
14917 return this.beforeAfter(node2, detect);
14918 } else {
14919 var method = "raw" + capitalize(detect);
14920 if (this[method]) {
14921 value = this[method](root2, node2);
14922 } else {
14923 root2.walk(function(i2) {
14924 value = i2.raws[own];
14925 if (typeof value !== "undefined") return false;
14926 });
14927 }
14928 }
14929 if (typeof value === "undefined") value = DEFAULT_RAW[detect];
14930 root2.rawCache[detect] = value;
14931 return value;
14932 };
14933 _proto.rawBeforeClose = function rawBeforeClose(root2) {
14934 var value;
14935 root2.walk(function(i2) {
14936 if (i2.nodes && i2.nodes.length > 0) {
14937 if (typeof i2.raws.after !== "undefined") {
14938 value = i2.raws.after;
14939 if (value.includes("\n")) {
14940 value = value.replace(/[^\n]+$/, "");
14941 }
14942 return false;
14943 }
14944 }
14945 });
14946 if (value) value = value.replace(/\S/g, "");
14947 return value;
14948 };
14949 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
14950 var value;
14951 root2.walkComments(function(i2) {
14952 if (typeof i2.raws.before !== "undefined") {
14953 value = i2.raws.before;
14954 if (value.includes("\n")) {
14955 value = value.replace(/[^\n]+$/, "");
14956 }
14957 return false;
14958 }
14959 });
14960 if (typeof value === "undefined") {
14961 value = this.raw(node2, null, "beforeDecl");
14962 } else if (value) {
14963 value = value.replace(/\S/g, "");
14964 }
14965 return value;
14966 };
14967 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
14968 var value;
14969 root2.walkDecls(function(i2) {
14970 if (typeof i2.raws.before !== "undefined") {
14971 value = i2.raws.before;
14972 if (value.includes("\n")) {
14973 value = value.replace(/[^\n]+$/, "");
14974 }
14975 return false;
14976 }
14977 });
14978 if (typeof value === "undefined") {
14979 value = this.raw(node2, null, "beforeRule");
14980 } else if (value) {
14981 value = value.replace(/\S/g, "");
14982 }
14983 return value;
14984 };
14985 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
14986 var value;
14987 root2.walk(function(i2) {
14988 if (i2.type !== "decl") {
14989 value = i2.raws.between;
14990 if (typeof value !== "undefined") return false;
14991 }
14992 });
14993 return value;
14994 };
14995 _proto.rawBeforeRule = function rawBeforeRule(root2) {
14996 var value;
14997 root2.walk(function(i2) {
14998 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
14999 if (typeof i2.raws.before !== "undefined") {
15000 value = i2.raws.before;
15001 if (value.includes("\n")) {
15002 value = value.replace(/[^\n]+$/, "");
15003 }
15004 return false;
15005 }
15006 }
15007 });
15008 if (value) value = value.replace(/\S/g, "");
15009 return value;
15010 };
15011 _proto.rawColon = function rawColon(root2) {
15012 var value;
15013 root2.walkDecls(function(i2) {
15014 if (typeof i2.raws.between !== "undefined") {
15015 value = i2.raws.between.replace(/[^\s:]/g, "");
15016 return false;
15017 }
15018 });
15019 return value;
15020 };
15021 _proto.rawEmptyBody = function rawEmptyBody(root2) {
15022 var value;
15023 root2.walk(function(i2) {
15024 if (i2.nodes && i2.nodes.length === 0) {
15025 value = i2.raws.after;
15026 if (typeof value !== "undefined") return false;
15027 }
15028 });
15029 return value;
15030 };
15031 _proto.rawIndent = function rawIndent(root2) {
15032 if (root2.raws.indent) return root2.raws.indent;
15033 var value;
15034 root2.walk(function(i2) {
15035 var p = i2.parent;
15036 if (p && p !== root2 && p.parent && p.parent === root2) {
15037 if (typeof i2.raws.before !== "undefined") {
15038 var parts = i2.raws.before.split("\n");
15039 value = parts[parts.length - 1];
15040 value = value.replace(/\S/g, "");
15041 return false;
15042 }
15043 }
15044 });
15045 return value;
15046 };
15047 _proto.rawSemicolon = function rawSemicolon(root2) {
15048 var value;
15049 root2.walk(function(i2) {
15050 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
15051 value = i2.raws.semicolon;
15052 if (typeof value !== "undefined") return false;
15053 }
15054 });
15055 return value;
15056 };
15057 _proto.rawValue = function rawValue(node2, prop) {
15058 var value = node2[prop];
15059 var raw = node2.raws[prop];
15060 if (raw && raw.value === value) {
15061 return raw.raw;
15062 }
15063 return value;
15064 };
15065 _proto.root = function root(node2) {
15066 this.body(node2);
15067 if (node2.raws.after) this.builder(node2.raws.after);
15068 };
15069 _proto.rule = function rule(node2) {
15070 this.block(node2, this.rawValue(node2, "selector"));
15071 if (node2.raws.ownSemicolon) {
15072 this.builder(node2.raws.ownSemicolon, node2, "end");
15073 }
15074 };
15075 _proto.stringify = function stringify(node2, semicolon) {
15076 if (!this[node2.type]) {
15077 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
15078 }
15079 this[node2.type](node2, semicolon);
15080 };
15081 return Stringifier2;
15082 }();
15083 var stringifier = Stringifier$2;
15084 Stringifier$2.default = Stringifier$2;
15085 var Stringifier$1 = stringifier;
15086 function stringify$4(node2, builder) {
15087 var str = new Stringifier$1(builder);
15088 str.stringify(node2);
15089 }
15090 var stringify_1 = stringify$4;
15091 stringify$4.default = stringify$4;
15092 var isClean$2 = symbols.isClean, my$2 = symbols.my;
15093 var CssSyntaxError$2 = cssSyntaxError;
15094 var Stringifier22 = stringifier;
15095 var stringify$3 = stringify_1;
15096 function cloneNode(obj, parent) {
15097 var cloned = new obj.constructor();
15098 for(var i2 in obj){
15099 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
15100 continue;
15101 }
15102 if (i2 === "proxyCache") continue;
15103 var value = obj[i2];
15104 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
15105 if (i2 === "parent" && type === "object") {
15106 if (parent) cloned[i2] = parent;
15107 } else if (i2 === "source") {
15108 cloned[i2] = value;
15109 } else if (Array.isArray(value)) {
15110 cloned[i2] = value.map(function(j) {
15111 return cloneNode(j, cloned);
15112 });
15113 } else {
15114 if (type === "object" && value !== null) value = cloneNode(value);
15115 cloned[i2] = value;
15116 }
15117 }
15118 return cloned;
15119 }
15120 var Node$4 = /*#__PURE__*/ function() {
15121 function Node3(defaults) {
15122 if (defaults === void 0) defaults = {};
15123 this.raws = {};
15124 this[isClean$2] = false;
15125 this[my$2] = true;
15126 for(var name in defaults){
15127 if (name === "nodes") {
15128 this.nodes = [];
15129 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
15130 var node2 = _step.value;
15131 if (typeof node2.clone === "function") {
15132 this.append(node2.clone());
15133 } else {
15134 this.append(node2);
15135 }
15136 }
15137 } else {
15138 this[name] = defaults[name];
15139 }
15140 }
15141 }
15142 var _proto = Node3.prototype;
15143 _proto.addToError = function addToError(error) {
15144 error.postcssNode = this;
15145 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
15146 var s2 = this.source;
15147 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
15148 }
15149 return error;
15150 };
15151 _proto.after = function after(add) {
15152 this.parent.insertAfter(this, add);
15153 return this;
15154 };
15155 _proto.assign = function assign(overrides) {
15156 if (overrides === void 0) overrides = {};
15157 for(var name in overrides){
15158 this[name] = overrides[name];
15159 }
15160 return this;
15161 };
15162 _proto.before = function before(add) {
15163 this.parent.insertBefore(this, add);
15164 return this;
15165 };
15166 _proto.cleanRaws = function cleanRaws(keepBetween) {
15167 delete this.raws.before;
15168 delete this.raws.after;
15169 if (!keepBetween) delete this.raws.between;
15170 };
15171 _proto.clone = function clone(overrides) {
15172 if (overrides === void 0) overrides = {};
15173 var cloned = cloneNode(this);
15174 for(var name in overrides){
15175 cloned[name] = overrides[name];
15176 }
15177 return cloned;
15178 };
15179 _proto.cloneAfter = function cloneAfter(overrides) {
15180 if (overrides === void 0) overrides = {};
15181 var cloned = this.clone(overrides);
15182 this.parent.insertAfter(this, cloned);
15183 return cloned;
15184 };
15185 _proto.cloneBefore = function cloneBefore(overrides) {
15186 if (overrides === void 0) overrides = {};
15187 var cloned = this.clone(overrides);
15188 this.parent.insertBefore(this, cloned);
15189 return cloned;
15190 };
15191 _proto.error = function error(message, opts) {
15192 if (opts === void 0) opts = {};
15193 if (this.source) {
15194 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
15195 return this.source.input.error(message, {
15196 column: start.column,
15197 line: start.line
15198 }, {
15199 column: end.column,
15200 line: end.line
15201 }, opts);
15202 }
15203 return new CssSyntaxError$2(message);
15204 };
15205 _proto.getProxyProcessor = function getProxyProcessor() {
15206 return {
15207 get: function get(node2, prop) {
15208 if (prop === "proxyOf") {
15209 return node2;
15210 } else if (prop === "root") {
15211 return function() {
15212 return node2.root().toProxy();
15213 };
15214 } else {
15215 return node2[prop];
15216 }
15217 },
15218 set: function set(node2, prop, value) {
15219 if (node2[prop] === value) return true;
15220 node2[prop] = value;
15221 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
15222 node2.markDirty();
15223 }
15224 return true;
15225 }
15226 };
15227 };
15228 _proto.markDirty = function markDirty() {
15229 if (this[isClean$2]) {
15230 this[isClean$2] = false;
15231 var next = this;
15232 while(next = next.parent){
15233 next[isClean$2] = false;
15234 }
15235 }
15236 };
15237 _proto.next = function next() {
15238 if (!this.parent) return void 0;
15239 var index2 = this.parent.index(this);
15240 return this.parent.nodes[index2 + 1];
15241 };
15242 _proto.positionBy = function positionBy(opts, stringRepresentation) {
15243 var pos = this.source.start;
15244 if (opts.index) {
15245 pos = this.positionInside(opts.index, stringRepresentation);
15246 } else if (opts.word) {
15247 stringRepresentation = this.toString();
15248 var index2 = stringRepresentation.indexOf(opts.word);
15249 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
15250 }
15251 return pos;
15252 };
15253 _proto.positionInside = function positionInside(index2, stringRepresentation) {
15254 var string = stringRepresentation || this.toString();
15255 var column = this.source.start.column;
15256 var line = this.source.start.line;
15257 for(var i2 = 0; i2 < index2; i2++){
15258 if (string[i2] === "\n") {
15259 column = 1;
15260 line += 1;
15261 } else {
15262 column += 1;
15263 }
15264 }
15265 return {
15266 column: column,
15267 line: line
15268 };
15269 };
15270 _proto.prev = function prev() {
15271 if (!this.parent) return void 0;
15272 var index2 = this.parent.index(this);
15273 return this.parent.nodes[index2 - 1];
15274 };
15275 _proto.rangeBy = function rangeBy(opts) {
15276 var start = {
15277 column: this.source.start.column,
15278 line: this.source.start.line
15279 };
15280 var end = this.source.end ? {
15281 column: this.source.end.column + 1,
15282 line: this.source.end.line
15283 } : {
15284 column: start.column + 1,
15285 line: start.line
15286 };
15287 if (opts.word) {
15288 var stringRepresentation = this.toString();
15289 var index2 = stringRepresentation.indexOf(opts.word);
15290 if (index2 !== -1) {
15291 start = this.positionInside(index2, stringRepresentation);
15292 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
15293 }
15294 } else {
15295 if (opts.start) {
15296 start = {
15297 column: opts.start.column,
15298 line: opts.start.line
15299 };
15300 } else if (opts.index) {
15301 start = this.positionInside(opts.index);
15302 }
15303 if (opts.end) {
15304 end = {
15305 column: opts.end.column,
15306 line: opts.end.line
15307 };
15308 } else if (typeof opts.endIndex === "number") {
15309 end = this.positionInside(opts.endIndex);
15310 } else if (opts.index) {
15311 end = this.positionInside(opts.index + 1);
15312 }
15313 }
15314 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
15315 end = {
15316 column: start.column + 1,
15317 line: start.line
15318 };
15319 }
15320 return {
15321 end: end,
15322 start: start
15323 };
15324 };
15325 _proto.raw = function raw(prop, defaultType) {
15326 var str = new Stringifier22();
15327 return str.raw(this, prop, defaultType);
15328 };
15329 _proto.remove = function remove() {
15330 if (this.parent) {
15331 this.parent.removeChild(this);
15332 }
15333 this.parent = void 0;
15334 return this;
15335 };
15336 _proto.replaceWith = function replaceWith() {
15337 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
15338 nodes[_key] = arguments[_key];
15339 }
15340 if (this.parent) {
15341 var bookmark = this;
15342 var foundSelf = false;
15343 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15344 var node2 = _step.value;
15345 if (node2 === this) {
15346 foundSelf = true;
15347 } else if (foundSelf) {
15348 this.parent.insertAfter(bookmark, node2);
15349 bookmark = node2;
15350 } else {
15351 this.parent.insertBefore(bookmark, node2);
15352 }
15353 }
15354 if (!foundSelf) {
15355 this.remove();
15356 }
15357 }
15358 return this;
15359 };
15360 _proto.root = function root() {
15361 var result2 = this;
15362 while(result2.parent && result2.parent.type !== "document"){
15363 result2 = result2.parent;
15364 }
15365 return result2;
15366 };
15367 _proto.toJSON = function toJSON(_, inputs) {
15368 var fixed = {};
15369 var emitInputs = inputs == null;
15370 inputs = inputs || /* @__PURE__ */ new Map();
15371 var inputsNextIndex = 0;
15372 for(var name in this){
15373 if (!Object.prototype.hasOwnProperty.call(this, name)) {
15374 continue;
15375 }
15376 if (name === "parent" || name === "proxyCache") continue;
15377 var value = this[name];
15378 if (Array.isArray(value)) {
15379 fixed[name] = value.map(function(i2) {
15380 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
15381 return i2.toJSON(null, inputs);
15382 } else {
15383 return i2;
15384 }
15385 });
15386 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
15387 fixed[name] = value.toJSON(null, inputs);
15388 } else if (name === "source") {
15389 var inputId = inputs.get(value.input);
15390 if (inputId == null) {
15391 inputId = inputsNextIndex;
15392 inputs.set(value.input, inputsNextIndex);
15393 inputsNextIndex++;
15394 }
15395 fixed[name] = {
15396 end: value.end,
15397 inputId: inputId,
15398 start: value.start
15399 };
15400 } else {
15401 fixed[name] = value;
15402 }
15403 }
15404 if (emitInputs) {
15405 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
15406 return input2.toJSON();
15407 });
15408 }
15409 return fixed;
15410 };
15411 _proto.toProxy = function toProxy() {
15412 if (!this.proxyCache) {
15413 this.proxyCache = new Proxy(this, this.getProxyProcessor());
15414 }
15415 return this.proxyCache;
15416 };
15417 _proto.toString = function toString(stringifier2) {
15418 if (stringifier2 === void 0) stringifier2 = stringify$3;
15419 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
15420 var result2 = "";
15421 stringifier2(this, function(i2) {
15422 result2 += i2;
15423 });
15424 return result2;
15425 };
15426 _proto.warn = function warn(result2, text, opts) {
15427 var data = {
15428 node: this
15429 };
15430 for(var i2 in opts)data[i2] = opts[i2];
15431 return result2.warn(text, data);
15432 };
15433 _create_class(Node3, [
15434 {
15435 key: "proxyOf",
15436 get: function get() {
15437 return this;
15438 }
15439 }
15440 ]);
15441 return Node3;
15442 }();
15443 var node = Node$4;
15444 Node$4.default = Node$4;
15445 var Node$3 = node;
15446 var Declaration$4 = /*#__PURE__*/ function(Node$3) {
15447 _inherits(Declaration2, Node$3);
15448 function Declaration2(defaults) {
15449 var _this;
15450 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
15451 defaults = _extends({}, defaults, {
15452 value: String(defaults.value)
15453 });
15454 }
15455 _this = Node$3.call(this, defaults) || this;
15456 _this.type = "decl";
15457 return _this;
15458 }
15459 _create_class(Declaration2, [
15460 {
15461 key: "variable",
15462 get: function get() {
15463 return this.prop.startsWith("--") || this.prop[0] === "$";
15464 }
15465 }
15466 ]);
15467 return Declaration2;
15468 }(Node$3);
15469 var declaration = Declaration$4;
15470 Declaration$4.default = Declaration$4;
15471 var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
15472 var nanoid$1 = function(size) {
15473 if (size === void 0) size = 21;
15474 var id = "";
15475 var i2 = size;
15476 while(i2--){
15477 id += urlAlphabet[Math.random() * 64 | 0];
15478 }
15479 return id;
15480 };
15481 var nonSecure = {
15482 nanoid: nanoid$1};
15483 var SourceMapConsumer$2 = require$$2.SourceMapConsumer, SourceMapGenerator$2 = require$$2.SourceMapGenerator;
15484 var existsSync = require$$2.existsSync, readFileSync = require$$2.readFileSync;
15485 var dirname$1 = require$$2.dirname, join = require$$2.join;
15486 function fromBase64(str) {
15487 if (Buffer) {
15488 return Buffer.from(str, "base64").toString();
15489 } else {
15490 return window.atob(str);
15491 }
15492 }
15493 var PreviousMap$2 = /*#__PURE__*/ function() {
15494 function PreviousMap2(css, opts) {
15495 if (opts.map === false) return;
15496 this.loadAnnotation(css);
15497 this.inline = this.startWith(this.annotation, "data:");
15498 var prev = opts.map ? opts.map.prev : void 0;
15499 var text = this.loadMap(opts.from, prev);
15500 if (!this.mapFile && opts.from) {
15501 this.mapFile = opts.from;
15502 }
15503 if (this.mapFile) this.root = dirname$1(this.mapFile);
15504 if (text) this.text = text;
15505 }
15506 var _proto = PreviousMap2.prototype;
15507 _proto.consumer = function consumer() {
15508 if (!this.consumerCache) {
15509 this.consumerCache = new SourceMapConsumer$2(this.text);
15510 }
15511 return this.consumerCache;
15512 };
15513 _proto.decodeInline = function decodeInline(text) {
15514 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
15515 var baseUri = /^data:application\/json;base64,/;
15516 var charsetUri = /^data:application\/json;charset=utf-?8,/;
15517 var uri = /^data:application\/json,/;
15518 if (charsetUri.test(text) || uri.test(text)) {
15519 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
15520 }
15521 if (baseCharsetUri.test(text) || baseUri.test(text)) {
15522 return fromBase64(text.substr(RegExp.lastMatch.length));
15523 }
15524 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
15525 throw new Error("Unsupported source map encoding " + encoding);
15526 };
15527 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
15528 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
15529 };
15530 _proto.isMap = function isMap(map) {
15531 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
15532 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
15533 };
15534 _proto.loadAnnotation = function loadAnnotation(css) {
15535 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
15536 if (!comments) return;
15537 var start = css.lastIndexOf(comments.pop());
15538 var end = css.indexOf("*/", start);
15539 if (start > -1 && end > -1) {
15540 this.annotation = this.getAnnotationURL(css.substring(start, end));
15541 }
15542 };
15543 _proto.loadFile = function loadFile(path) {
15544 this.root = dirname$1(path);
15545 if (existsSync(path)) {
15546 this.mapFile = path;
15547 return readFileSync(path, "utf-8").toString().trim();
15548 }
15549 };
15550 _proto.loadMap = function loadMap(file, prev) {
15551 if (prev === false) return false;
15552 if (prev) {
15553 if (typeof prev === "string") {
15554 return prev;
15555 } else if (typeof prev === "function") {
15556 var prevPath = prev(file);
15557 if (prevPath) {
15558 var map = this.loadFile(prevPath);
15559 if (!map) {
15560 throw new Error("Unable to load previous source map: " + prevPath.toString());
15561 }
15562 return map;
15563 }
15564 } else if (_instanceof(prev, SourceMapConsumer$2)) {
15565 return SourceMapGenerator$2.fromSourceMap(prev).toString();
15566 } else if (_instanceof(prev, SourceMapGenerator$2)) {
15567 return prev.toString();
15568 } else if (this.isMap(prev)) {
15569 return JSON.stringify(prev);
15570 } else {
15571 throw new Error("Unsupported previous source map format: " + prev.toString());
15572 }
15573 } else if (this.inline) {
15574 return this.decodeInline(this.annotation);
15575 } else if (this.annotation) {
15576 var map1 = this.annotation;
15577 if (file) map1 = join(dirname$1(file), map1);
15578 return this.loadFile(map1);
15579 }
15580 };
15581 _proto.startWith = function startWith(string, start) {
15582 if (!string) return false;
15583 return string.substr(0, start.length) === start;
15584 };
15585 _proto.withContent = function withContent() {
15586 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
15587 };
15588 return PreviousMap2;
15589 }();
15590 var previousMap = PreviousMap$2;
15591 PreviousMap$2.default = PreviousMap$2;
15592 var SourceMapConsumer$1 = require$$2.SourceMapConsumer, SourceMapGenerator$1 = require$$2.SourceMapGenerator;
15593 var fileURLToPath = require$$2.fileURLToPath, pathToFileURL$1 = require$$2.pathToFileURL;
15594 var isAbsolute = require$$2.isAbsolute, resolve$1 = require$$2.resolve;
15595 var nanoid = nonSecure.nanoid;
15596 var terminalHighlight = require$$2;
15597 var CssSyntaxError$1 = cssSyntaxError;
15598 var PreviousMap$1 = previousMap;
15599 var fromOffsetCache = Symbol("fromOffsetCache");
15600 var sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
15601 var pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
15602 var Input$4 = /*#__PURE__*/ function() {
15603 function Input2(css, opts) {
15604 if (opts === void 0) opts = {};
15605 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
15606 throw new Error("PostCSS received " + css + " instead of CSS string");
15607 }
15608 this.css = css.toString();
15609 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
15610 this.hasBOM = true;
15611 this.css = this.css.slice(1);
15612 } else {
15613 this.hasBOM = false;
15614 }
15615 if (opts.from) {
15616 if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
15617 this.file = opts.from;
15618 } else {
15619 this.file = resolve$1(opts.from);
15620 }
15621 }
15622 if (pathAvailable$1 && sourceMapAvailable$1) {
15623 var map = new PreviousMap$1(this.css, opts);
15624 if (map.text) {
15625 this.map = map;
15626 var file = map.consumer().file;
15627 if (!this.file && file) this.file = this.mapResolve(file);
15628 }
15629 }
15630 if (!this.file) {
15631 this.id = "<input css " + nanoid(6) + ">";
15632 }
15633 if (this.map) this.map.file = this.from;
15634 }
15635 var _proto = Input2.prototype;
15636 _proto.error = function error(message, line, column, opts) {
15637 if (opts === void 0) opts = {};
15638 var result2, endLine, endColumn;
15639 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
15640 var start = line;
15641 var end = column;
15642 if (typeof start.offset === "number") {
15643 var pos = this.fromOffset(start.offset);
15644 line = pos.line;
15645 column = pos.col;
15646 } else {
15647 line = start.line;
15648 column = start.column;
15649 }
15650 if (typeof end.offset === "number") {
15651 var pos1 = this.fromOffset(end.offset);
15652 endLine = pos1.line;
15653 endColumn = pos1.col;
15654 } else {
15655 endLine = end.line;
15656 endColumn = end.column;
15657 }
15658 } else if (!column) {
15659 var pos2 = this.fromOffset(line);
15660 line = pos2.line;
15661 column = pos2.col;
15662 }
15663 var origin = this.origin(line, column, endLine, endColumn);
15664 if (origin) {
15665 result2 = new CssSyntaxError$1(message, origin.endLine === void 0 ? origin.line : {
15666 column: origin.column,
15667 line: origin.line
15668 }, origin.endLine === void 0 ? origin.column : {
15669 column: origin.endColumn,
15670 line: origin.endLine
15671 }, origin.source, origin.file, opts.plugin);
15672 } else {
15673 result2 = new CssSyntaxError$1(message, endLine === void 0 ? line : {
15674 column: column,
15675 line: line
15676 }, endLine === void 0 ? column : {
15677 column: endColumn,
15678 line: endLine
15679 }, this.css, this.file, opts.plugin);
15680 }
15681 result2.input = {
15682 column: column,
15683 endColumn: endColumn,
15684 endLine: endLine,
15685 line: line,
15686 source: this.css
15687 };
15688 if (this.file) {
15689 if (pathToFileURL$1) {
15690 result2.input.url = pathToFileURL$1(this.file).toString();
15691 }
15692 result2.input.file = this.file;
15693 }
15694 return result2;
15695 };
15696 _proto.fromOffset = function fromOffset(offset) {
15697 var lastLine, lineToIndex;
15698 if (!this[fromOffsetCache]) {
15699 var lines = this.css.split("\n");
15700 lineToIndex = new Array(lines.length);
15701 var prevIndex = 0;
15702 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
15703 lineToIndex[i2] = prevIndex;
15704 prevIndex += lines[i2].length + 1;
15705 }
15706 this[fromOffsetCache] = lineToIndex;
15707 } else {
15708 lineToIndex = this[fromOffsetCache];
15709 }
15710 lastLine = lineToIndex[lineToIndex.length - 1];
15711 var min = 0;
15712 if (offset >= lastLine) {
15713 min = lineToIndex.length - 1;
15714 } else {
15715 var max = lineToIndex.length - 2;
15716 var mid;
15717 while(min < max){
15718 mid = min + (max - min >> 1);
15719 if (offset < lineToIndex[mid]) {
15720 max = mid - 1;
15721 } else if (offset >= lineToIndex[mid + 1]) {
15722 min = mid + 1;
15723 } else {
15724 min = mid;
15725 break;
15726 }
15727 }
15728 }
15729 return {
15730 col: offset - lineToIndex[min] + 1,
15731 line: min + 1
15732 };
15733 };
15734 _proto.mapResolve = function mapResolve(file) {
15735 if (/^\w+:\/\//.test(file)) {
15736 return file;
15737 }
15738 return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
15739 };
15740 _proto.origin = function origin(line, column, endLine, endColumn) {
15741 if (!this.map) return false;
15742 var consumer = this.map.consumer();
15743 var from = consumer.originalPositionFor({
15744 column: column,
15745 line: line
15746 });
15747 if (!from.source) return false;
15748 var to;
15749 if (typeof endLine === "number") {
15750 to = consumer.originalPositionFor({
15751 column: endColumn,
15752 line: endLine
15753 });
15754 }
15755 var fromUrl;
15756 if (isAbsolute(from.source)) {
15757 fromUrl = pathToFileURL$1(from.source);
15758 } else {
15759 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile));
15760 }
15761 var result2 = {
15762 column: from.column,
15763 endColumn: to && to.column,
15764 endLine: to && to.line,
15765 line: from.line,
15766 url: fromUrl.toString()
15767 };
15768 if (fromUrl.protocol === "file:") {
15769 if (fileURLToPath) {
15770 result2.file = fileURLToPath(fromUrl);
15771 } else {
15772 throw new Error("file: protocol is not available in this PostCSS build");
15773 }
15774 }
15775 var source = consumer.sourceContentFor(from.source);
15776 if (source) result2.source = source;
15777 return result2;
15778 };
15779 _proto.toJSON = function toJSON() {
15780 var json = {};
15781 for(var _i = 0, _iter = [
15782 "hasBOM",
15783 "css",
15784 "file",
15785 "id"
15786 ]; _i < _iter.length; _i++){
15787 var name = _iter[_i];
15788 if (this[name] != null) {
15789 json[name] = this[name];
15790 }
15791 }
15792 if (this.map) {
15793 json.map = _extends({}, this.map);
15794 if (json.map.consumerCache) {
15795 json.map.consumerCache = void 0;
15796 }
15797 }
15798 return json;
15799 };
15800 _create_class(Input2, [
15801 {
15802 key: "from",
15803 get: function get() {
15804 return this.file || this.id;
15805 }
15806 }
15807 ]);
15808 return Input2;
15809 }();
15810 var input = Input$4;
15811 Input$4.default = Input$4;
15812 if (terminalHighlight && terminalHighlight.registerInput) {
15813 terminalHighlight.registerInput(Input$4);
15814 }
15815 var SourceMapConsumer = require$$2.SourceMapConsumer, SourceMapGenerator = require$$2.SourceMapGenerator;
15816 var dirname = require$$2.dirname, relative = require$$2.relative, resolve$3 = require$$2.resolve, sep = require$$2.sep;
15817 var pathToFileURL = require$$2.pathToFileURL;
15818 var Input$3 = input;
15819 var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
15820 var pathAvailable = Boolean(dirname && resolve$3 && relative && sep);
15821 var MapGenerator$2 = /*#__PURE__*/ function() {
15822 function MapGenerator2(stringify2, root2, opts, cssString) {
15823 this.stringify = stringify2;
15824 this.mapOpts = opts.map || {};
15825 this.root = root2;
15826 this.opts = opts;
15827 this.css = cssString;
15828 this.originalCSS = cssString;
15829 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
15830 this.memoizedFileURLs = /* @__PURE__ */ new Map();
15831 this.memoizedPaths = /* @__PURE__ */ new Map();
15832 this.memoizedURLs = /* @__PURE__ */ new Map();
15833 }
15834 var _proto = MapGenerator2.prototype;
15835 _proto.addAnnotation = function addAnnotation() {
15836 var content;
15837 if (this.isInline()) {
15838 content = "data:application/json;base64," + this.toBase64(this.map.toString());
15839 } else if (typeof this.mapOpts.annotation === "string") {
15840 content = this.mapOpts.annotation;
15841 } else if (typeof this.mapOpts.annotation === "function") {
15842 content = this.mapOpts.annotation(this.opts.to, this.root);
15843 } else {
15844 content = this.outputFile() + ".map";
15845 }
15846 var eol = "\n";
15847 if (this.css.includes("\r\n")) eol = "\r\n";
15848 this.css += eol + "/*# sourceMappingURL=" + content + " */";
15849 };
15850 _proto.applyPrevMaps = function applyPrevMaps() {
15851 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
15852 var prev = _step.value;
15853 var from = this.toUrl(this.path(prev.file));
15854 var root2 = prev.root || dirname(prev.file);
15855 var map = void 0;
15856 if (this.mapOpts.sourcesContent === false) {
15857 map = new SourceMapConsumer(prev.text);
15858 if (map.sourcesContent) {
15859 map.sourcesContent = null;
15860 }
15861 } else {
15862 map = prev.consumer();
15863 }
15864 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
15865 }
15866 };
15867 _proto.clearAnnotation = function clearAnnotation() {
15868 if (this.mapOpts.annotation === false) return;
15869 if (this.root) {
15870 var node2;
15871 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
15872 node2 = this.root.nodes[i2];
15873 if (node2.type !== "comment") continue;
15874 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
15875 this.root.removeChild(i2);
15876 }
15877 }
15878 } else if (this.css) {
15879 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
15880 }
15881 };
15882 _proto.generate = function generate() {
15883 this.clearAnnotation();
15884 if (pathAvailable && sourceMapAvailable && this.isMap()) {
15885 return this.generateMap();
15886 } else {
15887 var result2 = "";
15888 this.stringify(this.root, function(i2) {
15889 result2 += i2;
15890 });
15891 return [
15892 result2
15893 ];
15894 }
15895 };
15896 _proto.generateMap = function generateMap() {
15897 if (this.root) {
15898 this.generateString();
15899 } else if (this.previous().length === 1) {
15900 var prev = this.previous()[0].consumer();
15901 prev.file = this.outputFile();
15902 this.map = SourceMapGenerator.fromSourceMap(prev, {
15903 ignoreInvalidMapping: true
15904 });
15905 } else {
15906 this.map = new SourceMapGenerator({
15907 file: this.outputFile(),
15908 ignoreInvalidMapping: true
15909 });
15910 this.map.addMapping({
15911 generated: {
15912 column: 0,
15913 line: 1
15914 },
15915 original: {
15916 column: 0,
15917 line: 1
15918 },
15919 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
15920 });
15921 }
15922 if (this.isSourcesContent()) this.setSourcesContent();
15923 if (this.root && this.previous().length > 0) this.applyPrevMaps();
15924 if (this.isAnnotation()) this.addAnnotation();
15925 if (this.isInline()) {
15926 return [
15927 this.css
15928 ];
15929 } else {
15930 return [
15931 this.css,
15932 this.map
15933 ];
15934 }
15935 };
15936 _proto.generateString = function generateString() {
15937 var _this = this;
15938 this.css = "";
15939 this.map = new SourceMapGenerator({
15940 file: this.outputFile(),
15941 ignoreInvalidMapping: true
15942 });
15943 var line = 1;
15944 var column = 1;
15945 var noSource = "<no source>";
15946 var mapping = {
15947 generated: {
15948 column: 0,
15949 line: 0
15950 },
15951 original: {
15952 column: 0,
15953 line: 0
15954 },
15955 source: ""
15956 };
15957 var lines, last;
15958 this.stringify(this.root, function(str, node2, type) {
15959 _this.css += str;
15960 if (node2 && type !== "end") {
15961 mapping.generated.line = line;
15962 mapping.generated.column = column - 1;
15963 if (node2.source && node2.source.start) {
15964 mapping.source = _this.sourcePath(node2);
15965 mapping.original.line = node2.source.start.line;
15966 mapping.original.column = node2.source.start.column - 1;
15967 _this.map.addMapping(mapping);
15968 } else {
15969 mapping.source = noSource;
15970 mapping.original.line = 1;
15971 mapping.original.column = 0;
15972 _this.map.addMapping(mapping);
15973 }
15974 }
15975 lines = str.match(/\n/g);
15976 if (lines) {
15977 line += lines.length;
15978 last = str.lastIndexOf("\n");
15979 column = str.length - last;
15980 } else {
15981 column += str.length;
15982 }
15983 if (node2 && type !== "start") {
15984 var p = node2.parent || {
15985 raws: {}
15986 };
15987 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
15988 if (!childless || node2 !== p.last || p.raws.semicolon) {
15989 if (node2.source && node2.source.end) {
15990 mapping.source = _this.sourcePath(node2);
15991 mapping.original.line = node2.source.end.line;
15992 mapping.original.column = node2.source.end.column - 1;
15993 mapping.generated.line = line;
15994 mapping.generated.column = column - 2;
15995 _this.map.addMapping(mapping);
15996 } else {
15997 mapping.source = noSource;
15998 mapping.original.line = 1;
15999 mapping.original.column = 0;
16000 mapping.generated.line = line;
16001 mapping.generated.column = column - 1;
16002 _this.map.addMapping(mapping);
16003 }
16004 }
16005 }
16006 });
16007 };
16008 _proto.isAnnotation = function isAnnotation() {
16009 if (this.isInline()) {
16010 return true;
16011 }
16012 if (typeof this.mapOpts.annotation !== "undefined") {
16013 return this.mapOpts.annotation;
16014 }
16015 if (this.previous().length) {
16016 return this.previous().some(function(i2) {
16017 return i2.annotation;
16018 });
16019 }
16020 return true;
16021 };
16022 _proto.isInline = function isInline() {
16023 if (typeof this.mapOpts.inline !== "undefined") {
16024 return this.mapOpts.inline;
16025 }
16026 var annotation = this.mapOpts.annotation;
16027 if (typeof annotation !== "undefined" && annotation !== true) {
16028 return false;
16029 }
16030 if (this.previous().length) {
16031 return this.previous().some(function(i2) {
16032 return i2.inline;
16033 });
16034 }
16035 return true;
16036 };
16037 _proto.isMap = function isMap() {
16038 if (typeof this.opts.map !== "undefined") {
16039 return !!this.opts.map;
16040 }
16041 return this.previous().length > 0;
16042 };
16043 _proto.isSourcesContent = function isSourcesContent() {
16044 if (typeof this.mapOpts.sourcesContent !== "undefined") {
16045 return this.mapOpts.sourcesContent;
16046 }
16047 if (this.previous().length) {
16048 return this.previous().some(function(i2) {
16049 return i2.withContent();
16050 });
16051 }
16052 return true;
16053 };
16054 _proto.outputFile = function outputFile() {
16055 if (this.opts.to) {
16056 return this.path(this.opts.to);
16057 } else if (this.opts.from) {
16058 return this.path(this.opts.from);
16059 } else {
16060 return "to.css";
16061 }
16062 };
16063 _proto.path = function path(file) {
16064 if (this.mapOpts.absolute) return file;
16065 if (file.charCodeAt(0) === 60) return file;
16066 if (/^\w+:\/\//.test(file)) return file;
16067 var cached = this.memoizedPaths.get(file);
16068 if (cached) return cached;
16069 var from = this.opts.to ? dirname(this.opts.to) : ".";
16070 if (typeof this.mapOpts.annotation === "string") {
16071 from = dirname(resolve$3(from, this.mapOpts.annotation));
16072 }
16073 var path = relative(from, file);
16074 this.memoizedPaths.set(file, path);
16075 return path;
16076 };
16077 _proto.previous = function previous() {
16078 var _this = this;
16079 if (!this.previousMaps) {
16080 this.previousMaps = [];
16081 if (this.root) {
16082 this.root.walk(function(node2) {
16083 if (node2.source && node2.source.input.map) {
16084 var map = node2.source.input.map;
16085 if (!_this.previousMaps.includes(map)) {
16086 _this.previousMaps.push(map);
16087 }
16088 }
16089 });
16090 } else {
16091 var input2 = new Input$3(this.originalCSS, this.opts);
16092 if (input2.map) this.previousMaps.push(input2.map);
16093 }
16094 }
16095 return this.previousMaps;
16096 };
16097 _proto.setSourcesContent = function setSourcesContent() {
16098 var _this = this;
16099 var already = {};
16100 if (this.root) {
16101 this.root.walk(function(node2) {
16102 if (node2.source) {
16103 var from = node2.source.input.from;
16104 if (from && !already[from]) {
16105 already[from] = true;
16106 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
16107 _this.map.setSourceContent(fromUrl, node2.source.input.css);
16108 }
16109 }
16110 });
16111 } else if (this.css) {
16112 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
16113 this.map.setSourceContent(from, this.css);
16114 }
16115 };
16116 _proto.sourcePath = function sourcePath(node2) {
16117 if (this.mapOpts.from) {
16118 return this.toUrl(this.mapOpts.from);
16119 } else if (this.usesFileUrls) {
16120 return this.toFileUrl(node2.source.input.from);
16121 } else {
16122 return this.toUrl(this.path(node2.source.input.from));
16123 }
16124 };
16125 _proto.toBase64 = function toBase64(str) {
16126 if (Buffer) {
16127 return Buffer.from(str).toString("base64");
16128 } else {
16129 return window.btoa(unescape(encodeURIComponent(str)));
16130 }
16131 };
16132 _proto.toFileUrl = function toFileUrl(path) {
16133 var cached = this.memoizedFileURLs.get(path);
16134 if (cached) return cached;
16135 if (pathToFileURL) {
16136 var fileURL = pathToFileURL(path).toString();
16137 this.memoizedFileURLs.set(path, fileURL);
16138 return fileURL;
16139 } else {
16140 throw new Error("`map.absolute` option is not available in this PostCSS build");
16141 }
16142 };
16143 _proto.toUrl = function toUrl(path) {
16144 var cached = this.memoizedURLs.get(path);
16145 if (cached) return cached;
16146 if (sep === "\\") {
16147 path = path.replace(/\\/g, "/");
16148 }
16149 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
16150 this.memoizedURLs.set(path, url);
16151 return url;
16152 };
16153 return MapGenerator2;
16154 }();
16155 var mapGenerator = MapGenerator$2;
16156 var Node$2 = node;
16157 var Comment$4 = /*#__PURE__*/ function(Node$2) {
16158 _inherits(Comment2, Node$2);
16159 function Comment2(defaults) {
16160 var _this;
16161 _this = Node$2.call(this, defaults) || this;
16162 _this.type = "comment";
16163 return _this;
16164 }
16165 return Comment2;
16166 }(Node$2);
16167 var comment = Comment$4;
16168 Comment$4.default = Comment$4;
16169 var isClean$1 = symbols.isClean, my$1 = symbols.my;
16170 var Declaration$3 = declaration;
16171 var Comment$3 = comment;
16172 var Node$1 = node;
16173 var parse$4, Rule$4, AtRule$4, Root$6;
16174 function cleanSource(nodes) {
16175 return nodes.map(function(i2) {
16176 if (i2.nodes) i2.nodes = cleanSource(i2.nodes);
16177 delete i2.source;
16178 return i2;
16179 });
16180 }
16181 function markDirtyUp(node2) {
16182 node2[isClean$1] = false;
16183 if (node2.proxyOf.nodes) {
16184 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
16185 var i2 = _step.value;
16186 markDirtyUp(i2);
16187 }
16188 }
16189 }
16190 var Container$7 = /*#__PURE__*/ function(Node$1) {
16191 _inherits(Container2, Node$1);
16192 function Container2() {
16193 return Node$1.apply(this, arguments) || this;
16194 }
16195 var _proto = Container2.prototype;
16196 _proto.append = function append() {
16197 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16198 children[_key] = arguments[_key];
16199 }
16200 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
16201 var child = _step.value;
16202 var nodes = this.normalize(child, this.last);
16203 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16204 var node2 = _step1.value;
16205 this.proxyOf.nodes.push(node2);
16206 }
16207 }
16208 this.markDirty();
16209 return this;
16210 };
16211 _proto.cleanRaws = function cleanRaws(keepBetween) {
16212 Node$1.prototype.cleanRaws.call(this, keepBetween);
16213 if (this.nodes) {
16214 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
16215 var node2 = _step.value;
16216 node2.cleanRaws(keepBetween);
16217 }
16218 }
16219 };
16220 _proto.each = function each(callback) {
16221 if (!this.proxyOf.nodes) return void 0;
16222 var iterator = this.getIterator();
16223 var index2, result2;
16224 while(this.indexes[iterator] < this.proxyOf.nodes.length){
16225 index2 = this.indexes[iterator];
16226 result2 = callback(this.proxyOf.nodes[index2], index2);
16227 if (result2 === false) break;
16228 this.indexes[iterator] += 1;
16229 }
16230 delete this.indexes[iterator];
16231 return result2;
16232 };
16233 _proto.every = function every(condition) {
16234 return this.nodes.every(condition);
16235 };
16236 _proto.getIterator = function getIterator() {
16237 if (!this.lastEach) this.lastEach = 0;
16238 if (!this.indexes) this.indexes = {};
16239 this.lastEach += 1;
16240 var iterator = this.lastEach;
16241 this.indexes[iterator] = 0;
16242 return iterator;
16243 };
16244 _proto.getProxyProcessor = function getProxyProcessor() {
16245 return {
16246 get: function get(node2, prop) {
16247 if (prop === "proxyOf") {
16248 return node2;
16249 } else if (!node2[prop]) {
16250 return node2[prop];
16251 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
16252 return function() {
16253 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
16254 args[_key] = arguments[_key];
16255 }
16256 var _node2;
16257 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
16258 if (typeof i2 === "function") {
16259 return function(child, index2) {
16260 return i2(child.toProxy(), index2);
16261 };
16262 } else {
16263 return i2;
16264 }
16265 })));
16266 };
16267 } else if (prop === "every" || prop === "some") {
16268 return function(cb) {
16269 return node2[prop](function(child) {
16270 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
16271 other[_key - 1] = arguments[_key];
16272 }
16273 return cb.apply(void 0, [].concat([
16274 child.toProxy()
16275 ], other));
16276 });
16277 };
16278 } else if (prop === "root") {
16279 return function() {
16280 return node2.root().toProxy();
16281 };
16282 } else if (prop === "nodes") {
16283 return node2.nodes.map(function(i2) {
16284 return i2.toProxy();
16285 });
16286 } else if (prop === "first" || prop === "last") {
16287 return node2[prop].toProxy();
16288 } else {
16289 return node2[prop];
16290 }
16291 },
16292 set: function set(node2, prop, value) {
16293 if (node2[prop] === value) return true;
16294 node2[prop] = value;
16295 if (prop === "name" || prop === "params" || prop === "selector") {
16296 node2.markDirty();
16297 }
16298 return true;
16299 }
16300 };
16301 };
16302 _proto.index = function index(child) {
16303 if (typeof child === "number") return child;
16304 if (child.proxyOf) child = child.proxyOf;
16305 return this.proxyOf.nodes.indexOf(child);
16306 };
16307 _proto.insertAfter = function insertAfter(exist, add) {
16308 var existIndex = this.index(exist);
16309 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
16310 existIndex = this.index(exist);
16311 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16312 var node2 = _step.value;
16313 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
16314 }
16315 var index2;
16316 for(var id in this.indexes){
16317 index2 = this.indexes[id];
16318 if (existIndex < index2) {
16319 this.indexes[id] = index2 + nodes.length;
16320 }
16321 }
16322 this.markDirty();
16323 return this;
16324 };
16325 _proto.insertBefore = function insertBefore(exist, add) {
16326 var existIndex = this.index(exist);
16327 var type = existIndex === 0 ? "prepend" : false;
16328 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
16329 existIndex = this.index(exist);
16330 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16331 var node2 = _step.value;
16332 this.proxyOf.nodes.splice(existIndex, 0, node2);
16333 }
16334 var index2;
16335 for(var id in this.indexes){
16336 index2 = this.indexes[id];
16337 if (existIndex <= index2) {
16338 this.indexes[id] = index2 + nodes.length;
16339 }
16340 }
16341 this.markDirty();
16342 return this;
16343 };
16344 _proto.normalize = function normalize(nodes, sample) {
16345 var _this = this;
16346 if (typeof nodes === "string") {
16347 nodes = cleanSource(parse$4(nodes).nodes);
16348 } else if (typeof nodes === "undefined") {
16349 nodes = [];
16350 } else if (Array.isArray(nodes)) {
16351 nodes = nodes.slice(0);
16352 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16353 var i2 = _step.value;
16354 if (i2.parent) i2.parent.removeChild(i2, "ignore");
16355 }
16356 } else if (nodes.type === "root" && this.type !== "document") {
16357 nodes = nodes.nodes.slice(0);
16358 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16359 var i21 = _step1.value;
16360 if (i21.parent) i21.parent.removeChild(i21, "ignore");
16361 }
16362 } else if (nodes.type) {
16363 nodes = [
16364 nodes
16365 ];
16366 } else if (nodes.prop) {
16367 if (typeof nodes.value === "undefined") {
16368 throw new Error("Value field is missed in node creation");
16369 } else if (typeof nodes.value !== "string") {
16370 nodes.value = String(nodes.value);
16371 }
16372 nodes = [
16373 new Declaration$3(nodes)
16374 ];
16375 } else if (nodes.selector) {
16376 nodes = [
16377 new Rule$4(nodes)
16378 ];
16379 } else if (nodes.name) {
16380 nodes = [
16381 new AtRule$4(nodes)
16382 ];
16383 } else if (nodes.text) {
16384 nodes = [
16385 new Comment$3(nodes)
16386 ];
16387 } else {
16388 throw new Error("Unknown node type in node creation");
16389 }
16390 var processed = nodes.map(function(i2) {
16391 if (!i2[my$1]) Container2.rebuild(i2);
16392 i2 = i2.proxyOf;
16393 if (i2.parent) i2.parent.removeChild(i2);
16394 if (i2[isClean$1]) markDirtyUp(i2);
16395 if (typeof i2.raws.before === "undefined") {
16396 if (sample && typeof sample.raws.before !== "undefined") {
16397 i2.raws.before = sample.raws.before.replace(/\S/g, "");
16398 }
16399 }
16400 i2.parent = _this.proxyOf;
16401 return i2;
16402 });
16403 return processed;
16404 };
16405 _proto.prepend = function prepend() {
16406 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16407 children[_key] = arguments[_key];
16408 }
16409 children = children.reverse();
16410 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
16411 var child = _step.value;
16412 var nodes = this.normalize(child, this.first, "prepend").reverse();
16413 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16414 var node2 = _step1.value;
16415 this.proxyOf.nodes.unshift(node2);
16416 }
16417 for(var id in this.indexes){
16418 this.indexes[id] = this.indexes[id] + nodes.length;
16419 }
16420 }
16421 this.markDirty();
16422 return this;
16423 };
16424 _proto.push = function push(child) {
16425 child.parent = this;
16426 this.proxyOf.nodes.push(child);
16427 return this;
16428 };
16429 _proto.removeAll = function removeAll() {
16430 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
16431 var node2 = _step.value;
16432 node2.parent = void 0;
16433 }
16434 this.proxyOf.nodes = [];
16435 this.markDirty();
16436 return this;
16437 };
16438 _proto.removeChild = function removeChild(child) {
16439 child = this.index(child);
16440 this.proxyOf.nodes[child].parent = void 0;
16441 this.proxyOf.nodes.splice(child, 1);
16442 var index2;
16443 for(var id in this.indexes){
16444 index2 = this.indexes[id];
16445 if (index2 >= child) {
16446 this.indexes[id] = index2 - 1;
16447 }
16448 }
16449 this.markDirty();
16450 return this;
16451 };
16452 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
16453 if (!callback) {
16454 callback = opts;
16455 opts = {};
16456 }
16457 this.walkDecls(function(decl) {
16458 if (opts.props && !opts.props.includes(decl.prop)) return;
16459 if (opts.fast && !decl.value.includes(opts.fast)) return;
16460 decl.value = decl.value.replace(pattern, callback);
16461 });
16462 this.markDirty();
16463 return this;
16464 };
16465 _proto.some = function some(condition) {
16466 return this.nodes.some(condition);
16467 };
16468 _proto.walk = function walk(callback) {
16469 return this.each(function(child, i2) {
16470 var result2;
16471 try {
16472 result2 = callback(child, i2);
16473 } catch (e2) {
16474 throw child.addToError(e2);
16475 }
16476 if (result2 !== false && child.walk) {
16477 result2 = child.walk(callback);
16478 }
16479 return result2;
16480 });
16481 };
16482 _proto.walkAtRules = function walkAtRules(name, callback) {
16483 if (!callback) {
16484 callback = name;
16485 return this.walk(function(child, i2) {
16486 if (child.type === "atrule") {
16487 return callback(child, i2);
16488 }
16489 });
16490 }
16491 if (_instanceof(name, RegExp)) {
16492 return this.walk(function(child, i2) {
16493 if (child.type === "atrule" && name.test(child.name)) {
16494 return callback(child, i2);
16495 }
16496 });
16497 }
16498 return this.walk(function(child, i2) {
16499 if (child.type === "atrule" && child.name === name) {
16500 return callback(child, i2);
16501 }
16502 });
16503 };
16504 _proto.walkComments = function walkComments(callback) {
16505 return this.walk(function(child, i2) {
16506 if (child.type === "comment") {
16507 return callback(child, i2);
16508 }
16509 });
16510 };
16511 _proto.walkDecls = function walkDecls(prop, callback) {
16512 if (!callback) {
16513 callback = prop;
16514 return this.walk(function(child, i2) {
16515 if (child.type === "decl") {
16516 return callback(child, i2);
16517 }
16518 });
16519 }
16520 if (_instanceof(prop, RegExp)) {
16521 return this.walk(function(child, i2) {
16522 if (child.type === "decl" && prop.test(child.prop)) {
16523 return callback(child, i2);
16524 }
16525 });
16526 }
16527 return this.walk(function(child, i2) {
16528 if (child.type === "decl" && child.prop === prop) {
16529 return callback(child, i2);
16530 }
16531 });
16532 };
16533 _proto.walkRules = function walkRules(selector, callback) {
16534 if (!callback) {
16535 callback = selector;
16536 return this.walk(function(child, i2) {
16537 if (child.type === "rule") {
16538 return callback(child, i2);
16539 }
16540 });
16541 }
16542 if (_instanceof(selector, RegExp)) {
16543 return this.walk(function(child, i2) {
16544 if (child.type === "rule" && selector.test(child.selector)) {
16545 return callback(child, i2);
16546 }
16547 });
16548 }
16549 return this.walk(function(child, i2) {
16550 if (child.type === "rule" && child.selector === selector) {
16551 return callback(child, i2);
16552 }
16553 });
16554 };
16555 _create_class(Container2, [
16556 {
16557 key: "first",
16558 get: function get() {
16559 if (!this.proxyOf.nodes) return void 0;
16560 return this.proxyOf.nodes[0];
16561 }
16562 },
16563 {
16564 key: "last",
16565 get: function get() {
16566 if (!this.proxyOf.nodes) return void 0;
16567 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
16568 }
16569 }
16570 ]);
16571 return Container2;
16572 }(Node$1);
16573 Container$7.registerParse = function(dependant) {
16574 parse$4 = dependant;
16575 };
16576 Container$7.registerRule = function(dependant) {
16577 Rule$4 = dependant;
16578 };
16579 Container$7.registerAtRule = function(dependant) {
16580 AtRule$4 = dependant;
16581 };
16582 Container$7.registerRoot = function(dependant) {
16583 Root$6 = dependant;
16584 };
16585 var container = Container$7;
16586 Container$7.default = Container$7;
16587 Container$7.rebuild = function(node2) {
16588 if (node2.type === "atrule") {
16589 Object.setPrototypeOf(node2, AtRule$4.prototype);
16590 } else if (node2.type === "rule") {
16591 Object.setPrototypeOf(node2, Rule$4.prototype);
16592 } else if (node2.type === "decl") {
16593 Object.setPrototypeOf(node2, Declaration$3.prototype);
16594 } else if (node2.type === "comment") {
16595 Object.setPrototypeOf(node2, Comment$3.prototype);
16596 } else if (node2.type === "root") {
16597 Object.setPrototypeOf(node2, Root$6.prototype);
16598 }
16599 node2[my$1] = true;
16600 if (node2.nodes) {
16601 node2.nodes.forEach(function(child) {
16602 Container$7.rebuild(child);
16603 });
16604 }
16605 };
16606 var Container$6 = container;
16607 var LazyResult$4, Processor$3;
16608 var Document$3 = /*#__PURE__*/ function(Container$6) {
16609 _inherits(Document23, Container$6);
16610 function Document23(defaults) {
16611 var _this;
16612 _this = Container$6.call(this, _extends({
16613 type: "document"
16614 }, defaults)) || this;
16615 if (!_this.nodes) {
16616 _this.nodes = [];
16617 }
16618 return _this;
16619 }
16620 var _proto = Document23.prototype;
16621 _proto.toResult = function toResult(opts) {
16622 if (opts === void 0) opts = {};
16623 var lazy = new LazyResult$4(new Processor$3(), this, opts);
16624 return lazy.stringify();
16625 };
16626 return Document23;
16627 }(Container$6);
16628 Document$3.registerLazyResult = function(dependant) {
16629 LazyResult$4 = dependant;
16630 };
16631 Document$3.registerProcessor = function(dependant) {
16632 Processor$3 = dependant;
16633 };
16634 var document$1$2 = Document$3;
16635 Document$3.default = Document$3;
16636 var printed = {};
16637 var warnOnce$2 = function warnOnce2(message) {
16638 if (printed[message]) return;
16639 printed[message] = true;
16640 if (typeof console !== "undefined" && console.warn) {
16641 console.warn(message);
16642 }
16643 };
16644 var Warning$2 = /*#__PURE__*/ function() {
16645 function Warning2(text, opts) {
16646 if (opts === void 0) opts = {};
16647 this.type = "warning";
16648 this.text = text;
16649 if (opts.node && opts.node.source) {
16650 var range = opts.node.rangeBy(opts);
16651 this.line = range.start.line;
16652 this.column = range.start.column;
16653 this.endLine = range.end.line;
16654 this.endColumn = range.end.column;
16655 }
16656 for(var opt in opts)this[opt] = opts[opt];
16657 }
16658 var _proto = Warning2.prototype;
16659 _proto.toString = function toString() {
16660 if (this.node) {
16661 return this.node.error(this.text, {
16662 index: this.index,
16663 plugin: this.plugin,
16664 word: this.word
16665 }).message;
16666 }
16667 if (this.plugin) {
16668 return this.plugin + ": " + this.text;
16669 }
16670 return this.text;
16671 };
16672 return Warning2;
16673 }();
16674 var warning = Warning$2;
16675 Warning$2.default = Warning$2;
16676 var Warning$1 = warning;
16677 var Result$3 = /*#__PURE__*/ function() {
16678 function Result2(processor2, root2, opts) {
16679 this.processor = processor2;
16680 this.messages = [];
16681 this.root = root2;
16682 this.opts = opts;
16683 this.css = void 0;
16684 this.map = void 0;
16685 }
16686 var _proto = Result2.prototype;
16687 _proto.toString = function toString() {
16688 return this.css;
16689 };
16690 _proto.warn = function warn(text, opts) {
16691 if (opts === void 0) opts = {};
16692 if (!opts.plugin) {
16693 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
16694 opts.plugin = this.lastPlugin.postcssPlugin;
16695 }
16696 }
16697 var warning2 = new Warning$1(text, opts);
16698 this.messages.push(warning2);
16699 return warning2;
16700 };
16701 _proto.warnings = function warnings() {
16702 return this.messages.filter(function(i2) {
16703 return i2.type === "warning";
16704 });
16705 };
16706 _create_class(Result2, [
16707 {
16708 key: "content",
16709 get: function get() {
16710 return this.css;
16711 }
16712 }
16713 ]);
16714 return Result2;
16715 }();
16716 var result = Result$3;
16717 Result$3.default = Result$3;
16718 var SINGLE_QUOTE = "'".charCodeAt(0);
16719 var DOUBLE_QUOTE = '"'.charCodeAt(0);
16720 var BACKSLASH = "\\".charCodeAt(0);
16721 var SLASH = "/".charCodeAt(0);
16722 var NEWLINE = "\n".charCodeAt(0);
16723 var SPACE = " ".charCodeAt(0);
16724 var FEED = "\f".charCodeAt(0);
16725 var TAB = " ".charCodeAt(0);
16726 var CR = "\r".charCodeAt(0);
16727 var OPEN_SQUARE = "[".charCodeAt(0);
16728 var CLOSE_SQUARE = "]".charCodeAt(0);
16729 var OPEN_PARENTHESES = "(".charCodeAt(0);
16730 var CLOSE_PARENTHESES = ")".charCodeAt(0);
16731 var OPEN_CURLY = "{".charCodeAt(0);
16732 var CLOSE_CURLY = "}".charCodeAt(0);
16733 var SEMICOLON = ";".charCodeAt(0);
16734 var ASTERISK = "*".charCodeAt(0);
16735 var COLON = ":".charCodeAt(0);
16736 var AT = "@".charCodeAt(0);
16737 var RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
16738 var RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
16739 var RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
16740 var RE_HEX_ESCAPE = /[\da-f]/i;
16741 var tokenize = function tokenizer2(input2, options) {
16742 if (options === void 0) options = {};
16743 var css = input2.css.valueOf();
16744 var ignore = options.ignoreErrors;
16745 var code, next, quote, content, escape;
16746 var escaped, escapePos, prev, n2, currentToken;
16747 var length = css.length;
16748 var pos = 0;
16749 var buffer = [];
16750 var returned = [];
16751 function position() {
16752 return pos;
16753 }
16754 function unclosed(what) {
16755 throw input2.error("Unclosed " + what, pos);
16756 }
16757 function endOfFile() {
16758 return returned.length === 0 && pos >= length;
16759 }
16760 function nextToken(opts) {
16761 if (returned.length) return returned.pop();
16762 if (pos >= length) return;
16763 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
16764 code = css.charCodeAt(pos);
16765 switch(code){
16766 case NEWLINE:
16767 case SPACE:
16768 case TAB:
16769 case CR:
16770 case FEED:
16771 {
16772 next = pos;
16773 do {
16774 next += 1;
16775 code = css.charCodeAt(next);
16776 }while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED);
16777 currentToken = [
16778 "space",
16779 css.slice(pos, next)
16780 ];
16781 pos = next - 1;
16782 break;
16783 }
16784 case OPEN_SQUARE:
16785 case CLOSE_SQUARE:
16786 case OPEN_CURLY:
16787 case CLOSE_CURLY:
16788 case COLON:
16789 case SEMICOLON:
16790 case CLOSE_PARENTHESES:
16791 {
16792 var controlChar = String.fromCharCode(code);
16793 currentToken = [
16794 controlChar,
16795 controlChar,
16796 pos
16797 ];
16798 break;
16799 }
16800 case OPEN_PARENTHESES:
16801 {
16802 prev = buffer.length ? buffer.pop()[1] : "";
16803 n2 = css.charCodeAt(pos + 1);
16804 if (prev === "url" && n2 !== SINGLE_QUOTE && n2 !== DOUBLE_QUOTE && n2 !== SPACE && n2 !== NEWLINE && n2 !== TAB && n2 !== FEED && n2 !== CR) {
16805 next = pos;
16806 do {
16807 escaped = false;
16808 next = css.indexOf(")", next + 1);
16809 if (next === -1) {
16810 if (ignore || ignoreUnclosed) {
16811 next = pos;
16812 break;
16813 } else {
16814 unclosed("bracket");
16815 }
16816 }
16817 escapePos = next;
16818 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16819 escapePos -= 1;
16820 escaped = !escaped;
16821 }
16822 }while (escaped);
16823 currentToken = [
16824 "brackets",
16825 css.slice(pos, next + 1),
16826 pos,
16827 next
16828 ];
16829 pos = next;
16830 } else {
16831 next = css.indexOf(")", pos + 1);
16832 content = css.slice(pos, next + 1);
16833 if (next === -1 || RE_BAD_BRACKET.test(content)) {
16834 currentToken = [
16835 "(",
16836 "(",
16837 pos
16838 ];
16839 } else {
16840 currentToken = [
16841 "brackets",
16842 content,
16843 pos,
16844 next
16845 ];
16846 pos = next;
16847 }
16848 }
16849 break;
16850 }
16851 case SINGLE_QUOTE:
16852 case DOUBLE_QUOTE:
16853 {
16854 quote = code === SINGLE_QUOTE ? "'" : '"';
16855 next = pos;
16856 do {
16857 escaped = false;
16858 next = css.indexOf(quote, next + 1);
16859 if (next === -1) {
16860 if (ignore || ignoreUnclosed) {
16861 next = pos + 1;
16862 break;
16863 } else {
16864 unclosed("string");
16865 }
16866 }
16867 escapePos = next;
16868 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16869 escapePos -= 1;
16870 escaped = !escaped;
16871 }
16872 }while (escaped);
16873 currentToken = [
16874 "string",
16875 css.slice(pos, next + 1),
16876 pos,
16877 next
16878 ];
16879 pos = next;
16880 break;
16881 }
16882 case AT:
16883 {
16884 RE_AT_END.lastIndex = pos + 1;
16885 RE_AT_END.test(css);
16886 if (RE_AT_END.lastIndex === 0) {
16887 next = css.length - 1;
16888 } else {
16889 next = RE_AT_END.lastIndex - 2;
16890 }
16891 currentToken = [
16892 "at-word",
16893 css.slice(pos, next + 1),
16894 pos,
16895 next
16896 ];
16897 pos = next;
16898 break;
16899 }
16900 case BACKSLASH:
16901 {
16902 next = pos;
16903 escape = true;
16904 while(css.charCodeAt(next + 1) === BACKSLASH){
16905 next += 1;
16906 escape = !escape;
16907 }
16908 code = css.charCodeAt(next + 1);
16909 if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
16910 next += 1;
16911 if (RE_HEX_ESCAPE.test(css.charAt(next))) {
16912 while(RE_HEX_ESCAPE.test(css.charAt(next + 1))){
16913 next += 1;
16914 }
16915 if (css.charCodeAt(next + 1) === SPACE) {
16916 next += 1;
16917 }
16918 }
16919 }
16920 currentToken = [
16921 "word",
16922 css.slice(pos, next + 1),
16923 pos,
16924 next
16925 ];
16926 pos = next;
16927 break;
16928 }
16929 default:
16930 {
16931 if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
16932 next = css.indexOf("*/", pos + 2) + 1;
16933 if (next === 0) {
16934 if (ignore || ignoreUnclosed) {
16935 next = css.length;
16936 } else {
16937 unclosed("comment");
16938 }
16939 }
16940 currentToken = [
16941 "comment",
16942 css.slice(pos, next + 1),
16943 pos,
16944 next
16945 ];
16946 pos = next;
16947 } else {
16948 RE_WORD_END.lastIndex = pos + 1;
16949 RE_WORD_END.test(css);
16950 if (RE_WORD_END.lastIndex === 0) {
16951 next = css.length - 1;
16952 } else {
16953 next = RE_WORD_END.lastIndex - 2;
16954 }
16955 currentToken = [
16956 "word",
16957 css.slice(pos, next + 1),
16958 pos,
16959 next
16960 ];
16961 buffer.push(currentToken);
16962 pos = next;
16963 }
16964 break;
16965 }
16966 }
16967 pos++;
16968 return currentToken;
16969 }
16970 function back(token) {
16971 returned.push(token);
16972 }
16973 return {
16974 back: back,
16975 endOfFile: endOfFile,
16976 nextToken: nextToken,
16977 position: position
16978 };
16979 };
16980 var Container$5 = container;
16981 var AtRule$3 = /*#__PURE__*/ function(Container$5) {
16982 _inherits(AtRule2, Container$5);
16983 function AtRule2(defaults) {
16984 var _this;
16985 _this = Container$5.call(this, defaults) || this;
16986 _this.type = "atrule";
16987 return _this;
16988 }
16989 var _proto = AtRule2.prototype;
16990 _proto.append = function append() {
16991 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16992 children[_key] = arguments[_key];
16993 }
16994 var _Container$5_prototype_append;
16995 if (!this.proxyOf.nodes) this.nodes = [];
16996 return (_Container$5_prototype_append = Container$5.prototype.append).call.apply(_Container$5_prototype_append, [].concat([
16997 this
16998 ], children));
16999 };
17000 _proto.prepend = function prepend() {
17001 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
17002 children[_key] = arguments[_key];
17003 }
17004 var _Container$5_prototype_prepend;
17005 if (!this.proxyOf.nodes) this.nodes = [];
17006 return (_Container$5_prototype_prepend = Container$5.prototype.prepend).call.apply(_Container$5_prototype_prepend, [].concat([
17007 this
17008 ], children));
17009 };
17010 return AtRule2;
17011 }(Container$5);
17012 var atRule = AtRule$3;
17013 AtRule$3.default = AtRule$3;
17014 Container$5.registerAtRule(AtRule$3);
17015 var Container$4 = container;
17016 var LazyResult$3, Processor$2;
17017 var Root$5 = /*#__PURE__*/ function(Container$4) {
17018 _inherits(Root2, Container$4);
17019 function Root2(defaults) {
17020 var _this;
17021 _this = Container$4.call(this, defaults) || this;
17022 _this.type = "root";
17023 if (!_this.nodes) _this.nodes = [];
17024 return _this;
17025 }
17026 var _proto = Root2.prototype;
17027 _proto.normalize = function normalize(child, sample, type) {
17028 var nodes = Container$4.prototype.normalize.call(this, child);
17029 if (sample) {
17030 if (type === "prepend") {
17031 if (this.nodes.length > 1) {
17032 sample.raws.before = this.nodes[1].raws.before;
17033 } else {
17034 delete sample.raws.before;
17035 }
17036 } else if (this.first !== sample) {
17037 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
17038 var node2 = _step.value;
17039 node2.raws.before = sample.raws.before;
17040 }
17041 }
17042 }
17043 return nodes;
17044 };
17045 _proto.removeChild = function removeChild(child, ignore) {
17046 var index2 = this.index(child);
17047 if (!ignore && index2 === 0 && this.nodes.length > 1) {
17048 this.nodes[1].raws.before = this.nodes[index2].raws.before;
17049 }
17050 return Container$4.prototype.removeChild.call(this, child);
17051 };
17052 _proto.toResult = function toResult(opts) {
17053 if (opts === void 0) opts = {};
17054 var lazy = new LazyResult$3(new Processor$2(), this, opts);
17055 return lazy.stringify();
17056 };
17057 return Root2;
17058 }(Container$4);
17059 Root$5.registerLazyResult = function(dependant) {
17060 LazyResult$3 = dependant;
17061 };
17062 Root$5.registerProcessor = function(dependant) {
17063 Processor$2 = dependant;
17064 };
17065 var root = Root$5;
17066 Root$5.default = Root$5;
17067 Container$4.registerRoot(Root$5);
17068 var list$2 = {
17069 comma: function comma(string) {
17070 return list$2.split(string, [
17071 ","
17072 ], true);
17073 },
17074 space: function space(string) {
17075 var spaces = [
17076 " ",
17077 "\n",
17078 " "
17079 ];
17080 return list$2.split(string, spaces);
17081 },
17082 split: function split(string, separators, last) {
17083 var array = [];
17084 var current = "";
17085 var split = false;
17086 var func = 0;
17087 var inQuote = false;
17088 var prevQuote = "";
17089 var escape = false;
17090 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
17091 var letter = _step.value;
17092 if (escape) {
17093 escape = false;
17094 } else if (letter === "\\") {
17095 escape = true;
17096 } else if (inQuote) {
17097 if (letter === prevQuote) {
17098 inQuote = false;
17099 }
17100 } else if (letter === '"' || letter === "'") {
17101 inQuote = true;
17102 prevQuote = letter;
17103 } else if (letter === "(") {
17104 func += 1;
17105 } else if (letter === ")") {
17106 if (func > 0) func -= 1;
17107 } else if (func === 0) {
17108 if (separators.includes(letter)) split = true;
17109 }
17110 if (split) {
17111 if (current !== "") array.push(current.trim());
17112 current = "";
17113 split = false;
17114 } else {
17115 current += letter;
17116 }
17117 }
17118 if (last || current !== "") array.push(current.trim());
17119 return array;
17120 }
17121 };
17122 var list_1 = list$2;
17123 list$2.default = list$2;
17124 var Container$3 = container;
17125 var list$1 = list_1;
17126 var Rule$3 = /*#__PURE__*/ function(Container$3) {
17127 _inherits(Rule2, Container$3);
17128 function Rule2(defaults) {
17129 var _this;
17130 _this = Container$3.call(this, defaults) || this;
17131 _this.type = "rule";
17132 if (!_this.nodes) _this.nodes = [];
17133 return _this;
17134 }
17135 _create_class(Rule2, [
17136 {
17137 key: "selectors",
17138 get: function get() {
17139 return list$1.comma(this.selector);
17140 },
17141 set: function set(values) {
17142 var match = this.selector ? this.selector.match(/,\s*/) : null;
17143 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
17144 this.selector = values.join(sep2);
17145 }
17146 }
17147 ]);
17148 return Rule2;
17149 }(Container$3);
17150 var rule = Rule$3;
17151 Rule$3.default = Rule$3;
17152 Container$3.registerRule(Rule$3);
17153 var Declaration$2 = declaration;
17154 var tokenizer22 = tokenize;
17155 var Comment$2 = comment;
17156 var AtRule$2 = atRule;
17157 var Root$4 = root;
17158 var Rule$2 = rule;
17159 var SAFE_COMMENT_NEIGHBOR = {
17160 empty: true,
17161 space: true
17162 };
17163 function findLastWithPosition(tokens) {
17164 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
17165 var token = tokens[i2];
17166 var pos = token[3] || token[2];
17167 if (pos) return pos;
17168 }
17169 }
17170 var Parser$1 = /*#__PURE__*/ function() {
17171 function Parser2(input2) {
17172 this.input = input2;
17173 this.root = new Root$4();
17174 this.current = this.root;
17175 this.spaces = "";
17176 this.semicolon = false;
17177 this.createTokenizer();
17178 this.root.source = {
17179 input: input2,
17180 start: {
17181 column: 1,
17182 line: 1,
17183 offset: 0
17184 }
17185 };
17186 }
17187 var _proto = Parser2.prototype;
17188 _proto.atrule = function atrule(token) {
17189 var node2 = new AtRule$2();
17190 node2.name = token[1].slice(1);
17191 if (node2.name === "") {
17192 this.unnamedAtrule(node2, token);
17193 }
17194 this.init(node2, token[2]);
17195 var type;
17196 var prev;
17197 var shift;
17198 var last = false;
17199 var open = false;
17200 var params = [];
17201 var brackets = [];
17202 while(!this.tokenizer.endOfFile()){
17203 token = this.tokenizer.nextToken();
17204 type = token[0];
17205 if (type === "(" || type === "[") {
17206 brackets.push(type === "(" ? ")" : "]");
17207 } else if (type === "{" && brackets.length > 0) {
17208 brackets.push("}");
17209 } else if (type === brackets[brackets.length - 1]) {
17210 brackets.pop();
17211 }
17212 if (brackets.length === 0) {
17213 if (type === ";") {
17214 node2.source.end = this.getPosition(token[2]);
17215 node2.source.end.offset++;
17216 this.semicolon = true;
17217 break;
17218 } else if (type === "{") {
17219 open = true;
17220 break;
17221 } else if (type === "}") {
17222 if (params.length > 0) {
17223 shift = params.length - 1;
17224 prev = params[shift];
17225 while(prev && prev[0] === "space"){
17226 prev = params[--shift];
17227 }
17228 if (prev) {
17229 node2.source.end = this.getPosition(prev[3] || prev[2]);
17230 node2.source.end.offset++;
17231 }
17232 }
17233 this.end(token);
17234 break;
17235 } else {
17236 params.push(token);
17237 }
17238 } else {
17239 params.push(token);
17240 }
17241 if (this.tokenizer.endOfFile()) {
17242 last = true;
17243 break;
17244 }
17245 }
17246 node2.raws.between = this.spacesAndCommentsFromEnd(params);
17247 if (params.length) {
17248 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
17249 this.raw(node2, "params", params);
17250 if (last) {
17251 token = params[params.length - 1];
17252 node2.source.end = this.getPosition(token[3] || token[2]);
17253 node2.source.end.offset++;
17254 this.spaces = node2.raws.between;
17255 node2.raws.between = "";
17256 }
17257 } else {
17258 node2.raws.afterName = "";
17259 node2.params = "";
17260 }
17261 if (open) {
17262 node2.nodes = [];
17263 this.current = node2;
17264 }
17265 };
17266 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
17267 var colon = this.colon(tokens);
17268 if (colon === false) return;
17269 var founded = 0;
17270 var token;
17271 for(var j = colon - 1; j >= 0; j--){
17272 token = tokens[j];
17273 if (token[0] !== "space") {
17274 founded += 1;
17275 if (founded === 2) break;
17276 }
17277 }
17278 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
17279 };
17280 _proto.colon = function colon(tokens) {
17281 var brackets = 0;
17282 var token, type, prev;
17283 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
17284 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
17285 token = element;
17286 type = token[0];
17287 if (type === "(") {
17288 brackets += 1;
17289 }
17290 if (type === ")") {
17291 brackets -= 1;
17292 }
17293 if (brackets === 0 && type === ":") {
17294 if (!prev) {
17295 this.doubleColon(token);
17296 } else if (prev[0] === "word" && prev[1] === "progid") {
17297 continue;
17298 } else {
17299 return i2;
17300 }
17301 }
17302 prev = token;
17303 }
17304 return false;
17305 };
17306 _proto.comment = function comment(token) {
17307 var node2 = new Comment$2();
17308 this.init(node2, token[2]);
17309 node2.source.end = this.getPosition(token[3] || token[2]);
17310 node2.source.end.offset++;
17311 var text = token[1].slice(2, -2);
17312 if (/^\s*$/.test(text)) {
17313 node2.text = "";
17314 node2.raws.left = text;
17315 node2.raws.right = "";
17316 } else {
17317 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
17318 node2.text = match[2];
17319 node2.raws.left = match[1];
17320 node2.raws.right = match[3];
17321 }
17322 };
17323 _proto.createTokenizer = function createTokenizer() {
17324 this.tokenizer = tokenizer22(this.input);
17325 };
17326 _proto.decl = function decl(tokens, customProperty) {
17327 var node2 = new Declaration$2();
17328 this.init(node2, tokens[0][2]);
17329 var last = tokens[tokens.length - 1];
17330 if (last[0] === ";") {
17331 this.semicolon = true;
17332 tokens.pop();
17333 }
17334 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition(tokens));
17335 node2.source.end.offset++;
17336 while(tokens[0][0] !== "word"){
17337 if (tokens.length === 1) this.unknownWord(tokens);
17338 node2.raws.before += tokens.shift()[1];
17339 }
17340 node2.source.start = this.getPosition(tokens[0][2]);
17341 node2.prop = "";
17342 while(tokens.length){
17343 var type = tokens[0][0];
17344 if (type === ":" || type === "space" || type === "comment") {
17345 break;
17346 }
17347 node2.prop += tokens.shift()[1];
17348 }
17349 node2.raws.between = "";
17350 var token;
17351 while(tokens.length){
17352 token = tokens.shift();
17353 if (token[0] === ":") {
17354 node2.raws.between += token[1];
17355 break;
17356 } else {
17357 if (token[0] === "word" && /\w/.test(token[1])) {
17358 this.unknownWord([
17359 token
17360 ]);
17361 }
17362 node2.raws.between += token[1];
17363 }
17364 }
17365 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
17366 node2.raws.before += node2.prop[0];
17367 node2.prop = node2.prop.slice(1);
17368 }
17369 var firstSpaces = [];
17370 var next;
17371 while(tokens.length){
17372 next = tokens[0][0];
17373 if (next !== "space" && next !== "comment") break;
17374 firstSpaces.push(tokens.shift());
17375 }
17376 this.precheckMissedSemicolon(tokens);
17377 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
17378 token = tokens[i2];
17379 if (token[1].toLowerCase() === "!important") {
17380 node2.important = true;
17381 var string = this.stringFrom(tokens, i2);
17382 string = this.spacesFromEnd(tokens) + string;
17383 if (string !== " !important") node2.raws.important = string;
17384 break;
17385 } else if (token[1].toLowerCase() === "important") {
17386 var cache = tokens.slice(0);
17387 var str = "";
17388 for(var j = i2; j > 0; j--){
17389 var type1 = cache[j][0];
17390 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
17391 break;
17392 }
17393 str = cache.pop()[1] + str;
17394 }
17395 if (str.trim().indexOf("!") === 0) {
17396 node2.important = true;
17397 node2.raws.important = str;
17398 tokens = cache;
17399 }
17400 }
17401 if (token[0] !== "space" && token[0] !== "comment") {
17402 break;
17403 }
17404 }
17405 var hasWord = tokens.some(function(i2) {
17406 return i2[0] !== "space" && i2[0] !== "comment";
17407 });
17408 if (hasWord) {
17409 node2.raws.between += firstSpaces.map(function(i2) {
17410 return i2[1];
17411 }).join("");
17412 firstSpaces = [];
17413 }
17414 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
17415 if (node2.value.includes(":") && !customProperty) {
17416 this.checkMissedSemicolon(tokens);
17417 }
17418 };
17419 _proto.doubleColon = function doubleColon(token) {
17420 throw this.input.error("Double colon", {
17421 offset: token[2]
17422 }, {
17423 offset: token[2] + token[1].length
17424 });
17425 };
17426 _proto.emptyRule = function emptyRule(token) {
17427 var node2 = new Rule$2();
17428 this.init(node2, token[2]);
17429 node2.selector = "";
17430 node2.raws.between = "";
17431 this.current = node2;
17432 };
17433 _proto.end = function end(token) {
17434 if (this.current.nodes && this.current.nodes.length) {
17435 this.current.raws.semicolon = this.semicolon;
17436 }
17437 this.semicolon = false;
17438 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
17439 this.spaces = "";
17440 if (this.current.parent) {
17441 this.current.source.end = this.getPosition(token[2]);
17442 this.current.source.end.offset++;
17443 this.current = this.current.parent;
17444 } else {
17445 this.unexpectedClose(token);
17446 }
17447 };
17448 _proto.endFile = function endFile() {
17449 if (this.current.parent) this.unclosedBlock();
17450 if (this.current.nodes && this.current.nodes.length) {
17451 this.current.raws.semicolon = this.semicolon;
17452 }
17453 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
17454 this.root.source.end = this.getPosition(this.tokenizer.position());
17455 };
17456 _proto.freeSemicolon = function freeSemicolon(token) {
17457 this.spaces += token[1];
17458 if (this.current.nodes) {
17459 var prev = this.current.nodes[this.current.nodes.length - 1];
17460 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
17461 prev.raws.ownSemicolon = this.spaces;
17462 this.spaces = "";
17463 }
17464 }
17465 };
17466 // Helpers
17467 _proto.getPosition = function getPosition(offset) {
17468 var pos = this.input.fromOffset(offset);
17469 return {
17470 column: pos.col,
17471 line: pos.line,
17472 offset: offset
17473 };
17474 };
17475 _proto.init = function init(node2, offset) {
17476 this.current.push(node2);
17477 node2.source = {
17478 input: this.input,
17479 start: this.getPosition(offset)
17480 };
17481 node2.raws.before = this.spaces;
17482 this.spaces = "";
17483 if (node2.type !== "comment") this.semicolon = false;
17484 };
17485 _proto.other = function other(start) {
17486 var end = false;
17487 var type = null;
17488 var colon = false;
17489 var bracket = null;
17490 var brackets = [];
17491 var customProperty = start[1].startsWith("--");
17492 var tokens = [];
17493 var token = start;
17494 while(token){
17495 type = token[0];
17496 tokens.push(token);
17497 if (type === "(" || type === "[") {
17498 if (!bracket) bracket = token;
17499 brackets.push(type === "(" ? ")" : "]");
17500 } else if (customProperty && colon && type === "{") {
17501 if (!bracket) bracket = token;
17502 brackets.push("}");
17503 } else if (brackets.length === 0) {
17504 if (type === ";") {
17505 if (colon) {
17506 this.decl(tokens, customProperty);
17507 return;
17508 } else {
17509 break;
17510 }
17511 } else if (type === "{") {
17512 this.rule(tokens);
17513 return;
17514 } else if (type === "}") {
17515 this.tokenizer.back(tokens.pop());
17516 end = true;
17517 break;
17518 } else if (type === ":") {
17519 colon = true;
17520 }
17521 } else if (type === brackets[brackets.length - 1]) {
17522 brackets.pop();
17523 if (brackets.length === 0) bracket = null;
17524 }
17525 token = this.tokenizer.nextToken();
17526 }
17527 if (this.tokenizer.endOfFile()) end = true;
17528 if (brackets.length > 0) this.unclosedBracket(bracket);
17529 if (end && colon) {
17530 if (!customProperty) {
17531 while(tokens.length){
17532 token = tokens[tokens.length - 1][0];
17533 if (token !== "space" && token !== "comment") break;
17534 this.tokenizer.back(tokens.pop());
17535 }
17536 }
17537 this.decl(tokens, customProperty);
17538 } else {
17539 this.unknownWord(tokens);
17540 }
17541 };
17542 _proto.parse = function parse() {
17543 var token;
17544 while(!this.tokenizer.endOfFile()){
17545 token = this.tokenizer.nextToken();
17546 switch(token[0]){
17547 case "space":
17548 this.spaces += token[1];
17549 break;
17550 case ";":
17551 this.freeSemicolon(token);
17552 break;
17553 case "}":
17554 this.end(token);
17555 break;
17556 case "comment":
17557 this.comment(token);
17558 break;
17559 case "at-word":
17560 this.atrule(token);
17561 break;
17562 case "{":
17563 this.emptyRule(token);
17564 break;
17565 default:
17566 this.other(token);
17567 break;
17568 }
17569 }
17570 this.endFile();
17571 };
17572 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
17573 _proto.raw = function raw(node2, prop, tokens, customProperty) {
17574 var token, type;
17575 var length = tokens.length;
17576 var value = "";
17577 var clean = true;
17578 var next, prev;
17579 for(var i2 = 0; i2 < length; i2 += 1){
17580 token = tokens[i2];
17581 type = token[0];
17582 if (type === "space" && i2 === length - 1 && !customProperty) {
17583 clean = false;
17584 } else if (type === "comment") {
17585 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
17586 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
17587 if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
17588 if (value.slice(-1) === ",") {
17589 clean = false;
17590 } else {
17591 value += token[1];
17592 }
17593 } else {
17594 clean = false;
17595 }
17596 } else {
17597 value += token[1];
17598 }
17599 }
17600 if (!clean) {
17601 var raw = tokens.reduce(function(all, i2) {
17602 return all + i2[1];
17603 }, "");
17604 node2.raws[prop] = {
17605 raw: raw,
17606 value: value
17607 };
17608 }
17609 node2[prop] = value;
17610 };
17611 _proto.rule = function rule(tokens) {
17612 tokens.pop();
17613 var node2 = new Rule$2();
17614 this.init(node2, tokens[0][2]);
17615 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
17616 this.raw(node2, "selector", tokens);
17617 this.current = node2;
17618 };
17619 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
17620 var lastTokenType;
17621 var spaces = "";
17622 while(tokens.length){
17623 lastTokenType = tokens[tokens.length - 1][0];
17624 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
17625 spaces = tokens.pop()[1] + spaces;
17626 }
17627 return spaces;
17628 };
17629 // Errors
17630 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
17631 var next;
17632 var spaces = "";
17633 while(tokens.length){
17634 next = tokens[0][0];
17635 if (next !== "space" && next !== "comment") break;
17636 spaces += tokens.shift()[1];
17637 }
17638 return spaces;
17639 };
17640 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
17641 var lastTokenType;
17642 var spaces = "";
17643 while(tokens.length){
17644 lastTokenType = tokens[tokens.length - 1][0];
17645 if (lastTokenType !== "space") break;
17646 spaces = tokens.pop()[1] + spaces;
17647 }
17648 return spaces;
17649 };
17650 _proto.stringFrom = function stringFrom(tokens, from) {
17651 var result2 = "";
17652 for(var i2 = from; i2 < tokens.length; i2++){
17653 result2 += tokens[i2][1];
17654 }
17655 tokens.splice(from, tokens.length - from);
17656 return result2;
17657 };
17658 _proto.unclosedBlock = function unclosedBlock() {
17659 var pos = this.current.source.start;
17660 throw this.input.error("Unclosed block", pos.line, pos.column);
17661 };
17662 _proto.unclosedBracket = function unclosedBracket(bracket) {
17663 throw this.input.error("Unclosed bracket", {
17664 offset: bracket[2]
17665 }, {
17666 offset: bracket[2] + 1
17667 });
17668 };
17669 _proto.unexpectedClose = function unexpectedClose(token) {
17670 throw this.input.error("Unexpected }", {
17671 offset: token[2]
17672 }, {
17673 offset: token[2] + 1
17674 });
17675 };
17676 _proto.unknownWord = function unknownWord(tokens) {
17677 throw this.input.error("Unknown word", {
17678 offset: tokens[0][2]
17679 }, {
17680 offset: tokens[0][2] + tokens[0][1].length
17681 });
17682 };
17683 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
17684 throw this.input.error("At-rule without name", {
17685 offset: token[2]
17686 }, {
17687 offset: token[2] + token[1].length
17688 });
17689 };
17690 return Parser2;
17691 }();
17692 var parser = Parser$1;
17693 var Container$2 = container;
17694 var Parser22 = parser;
17695 var Input$2 = input;
17696 function parse$3(css, opts) {
17697 var input2 = new Input$2(css, opts);
17698 var parser2 = new Parser22(input2);
17699 try {
17700 parser2.parse();
17701 } catch (e2) {
17702 if (true) {
17703 if (e2.name === "CssSyntaxError" && opts && opts.from) {
17704 if (/\.scss$/i.test(opts.from)) {
17705 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
17706 } else if (/\.sass/i.test(opts.from)) {
17707 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
17708 } else if (/\.less$/i.test(opts.from)) {
17709 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
17710 }
17711 }
17712 }
17713 throw e2;
17714 }
17715 return parser2.root;
17716 }
17717 var parse_1 = parse$3;
17718 parse$3.default = parse$3;
17719 Container$2.registerParse(parse$3);
17720 var isClean = symbols.isClean, my = symbols.my;
17721 var MapGenerator$1 = mapGenerator;
17722 var stringify$2 = stringify_1;
17723 var Container$1 = container;
17724 var Document$2 = document$1$2;
17725 var warnOnce$1 = warnOnce$2;
17726 var Result$2 = result;
17727 var parse$2 = parse_1;
17728 var Root$3 = root;
17729 var TYPE_TO_CLASS_NAME = {
17730 atrule: "AtRule",
17731 comment: "Comment",
17732 decl: "Declaration",
17733 document: "Document",
17734 root: "Root",
17735 rule: "Rule"
17736 };
17737 var PLUGIN_PROPS = {
17738 AtRule: true,
17739 AtRuleExit: true,
17740 Comment: true,
17741 CommentExit: true,
17742 Declaration: true,
17743 DeclarationExit: true,
17744 Document: true,
17745 DocumentExit: true,
17746 Once: true,
17747 OnceExit: true,
17748 postcssPlugin: true,
17749 prepare: true,
17750 Root: true,
17751 RootExit: true,
17752 Rule: true,
17753 RuleExit: true
17754 };
17755 var NOT_VISITORS = {
17756 Once: true,
17757 postcssPlugin: true,
17758 prepare: true
17759 };
17760 var CHILDREN = 0;
17761 function isPromise(obj) {
17762 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
17763 }
17764 function getEvents(node2) {
17765 var key = false;
17766 var type = TYPE_TO_CLASS_NAME[node2.type];
17767 if (node2.type === "decl") {
17768 key = node2.prop.toLowerCase();
17769 } else if (node2.type === "atrule") {
17770 key = node2.name.toLowerCase();
17771 }
17772 if (key && node2.append) {
17773 return [
17774 type,
17775 type + "-" + key,
17776 CHILDREN,
17777 type + "Exit",
17778 type + "Exit-" + key
17779 ];
17780 } else if (key) {
17781 return [
17782 type,
17783 type + "-" + key,
17784 type + "Exit",
17785 type + "Exit-" + key
17786 ];
17787 } else if (node2.append) {
17788 return [
17789 type,
17790 CHILDREN,
17791 type + "Exit"
17792 ];
17793 } else {
17794 return [
17795 type,
17796 type + "Exit"
17797 ];
17798 }
17799 }
17800 function toStack(node2) {
17801 var events;
17802 if (node2.type === "document") {
17803 events = [
17804 "Document",
17805 CHILDREN,
17806 "DocumentExit"
17807 ];
17808 } else if (node2.type === "root") {
17809 events = [
17810 "Root",
17811 CHILDREN,
17812 "RootExit"
17813 ];
17814 } else {
17815 events = getEvents(node2);
17816 }
17817 return {
17818 eventIndex: 0,
17819 events: events,
17820 iterator: 0,
17821 node: node2,
17822 visitorIndex: 0,
17823 visitors: []
17824 };
17825 }
17826 function cleanMarks(node2) {
17827 node2[isClean] = false;
17828 if (node2.nodes) node2.nodes.forEach(function(i2) {
17829 return cleanMarks(i2);
17830 });
17831 return node2;
17832 }
17833 var postcss$2 = {};
17834 var LazyResult$2 = /*#__PURE__*/ function() {
17835 function LazyResult2(processor2, css, opts) {
17836 var _this = this;
17837 this.stringified = false;
17838 this.processed = false;
17839 var root2;
17840 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
17841 root2 = cleanMarks(css);
17842 } else if (_instanceof(css, LazyResult2) || _instanceof(css, Result$2)) {
17843 root2 = cleanMarks(css.root);
17844 if (css.map) {
17845 if (typeof opts.map === "undefined") opts.map = {};
17846 if (!opts.map.inline) opts.map.inline = false;
17847 opts.map.prev = css.map;
17848 }
17849 } else {
17850 var parser2 = parse$2;
17851 if (opts.syntax) parser2 = opts.syntax.parse;
17852 if (opts.parser) parser2 = opts.parser;
17853 if (parser2.parse) parser2 = parser2.parse;
17854 try {
17855 root2 = parser2(css, opts);
17856 } catch (error) {
17857 this.processed = true;
17858 this.error = error;
17859 }
17860 if (root2 && !root2[my]) {
17861 Container$1.rebuild(root2);
17862 }
17863 }
17864 this.result = new Result$2(processor2, root2, opts);
17865 this.helpers = _extends({}, postcss$2, {
17866 postcss: postcss$2,
17867 result: this.result
17868 });
17869 this.plugins = this.processor.plugins.map(function(plugin22) {
17870 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
17871 return _extends({}, plugin22, plugin22.prepare(_this.result));
17872 } else {
17873 return plugin22;
17874 }
17875 });
17876 }
17877 var _proto = LazyResult2.prototype;
17878 _proto.async = function async() {
17879 if (this.error) return Promise.reject(this.error);
17880 if (this.processed) return Promise.resolve(this.result);
17881 if (!this.processing) {
17882 this.processing = this.runAsync();
17883 }
17884 return this.processing;
17885 };
17886 _proto.catch = function _catch(onRejected) {
17887 return this.async().catch(onRejected);
17888 };
17889 _proto.finally = function _finally(onFinally) {
17890 return this.async().then(onFinally, onFinally);
17891 };
17892 _proto.getAsyncError = function getAsyncError() {
17893 throw new Error("Use process(css).then(cb) to work with async plugins");
17894 };
17895 _proto.handleError = function handleError(error, node2) {
17896 var plugin22 = this.result.lastPlugin;
17897 try {
17898 if (node2) node2.addToError(error);
17899 this.error = error;
17900 if (error.name === "CssSyntaxError" && !error.plugin) {
17901 error.plugin = plugin22.postcssPlugin;
17902 error.setMessage();
17903 } else if (plugin22.postcssVersion) {
17904 if (true) {
17905 var pluginName = plugin22.postcssPlugin;
17906 var pluginVer = plugin22.postcssVersion;
17907 var runtimeVer = this.result.processor.version;
17908 var a2 = pluginVer.split(".");
17909 var b = runtimeVer.split(".");
17910 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
17911 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.");
17912 }
17913 }
17914 }
17915 } catch (err) {
17916 if (console && console.error) console.error(err);
17917 }
17918 return error;
17919 };
17920 _proto.prepareVisitors = function prepareVisitors() {
17921 var _this = this;
17922 this.listeners = {};
17923 var add = function(plugin22, type, cb) {
17924 if (!_this.listeners[type]) _this.listeners[type] = [];
17925 _this.listeners[type].push([
17926 plugin22,
17927 cb
17928 ]);
17929 };
17930 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17931 var plugin22 = _step.value;
17932 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
17933 for(var event in plugin22){
17934 if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
17935 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
17936 }
17937 if (!NOT_VISITORS[event]) {
17938 if (_type_of(plugin22[event]) === "object") {
17939 for(var filter in plugin22[event]){
17940 if (filter === "*") {
17941 add(plugin22, event, plugin22[event][filter]);
17942 } else {
17943 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
17944 }
17945 }
17946 } else if (typeof plugin22[event] === "function") {
17947 add(plugin22, event, plugin22[event]);
17948 }
17949 }
17950 }
17951 }
17952 }
17953 this.hasListener = Object.keys(this.listeners).length > 0;
17954 };
17955 _proto.runAsync = function runAsync() {
17956 var _this = this;
17957 return _async_to_generator(function() {
17958 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
17959 return _ts_generator(this, function(_state) {
17960 switch(_state.label){
17961 case 0:
17962 _this.plugin = 0;
17963 i2 = 0;
17964 _state.label = 1;
17965 case 1:
17966 if (!(i2 < _this.plugins.length)) return [
17967 3,
17968 6
17969 ];
17970 plugin22 = _this.plugins[i2];
17971 promise = _this.runOnRoot(plugin22);
17972 if (!isPromise(promise)) return [
17973 3,
17974 5
17975 ];
17976 _state.label = 2;
17977 case 2:
17978 _state.trys.push([
17979 2,
17980 4,
17981 ,
17982 5
17983 ]);
17984 return [
17985 4,
17986 promise
17987 ];
17988 case 3:
17989 _state.sent();
17990 return [
17991 3,
17992 5
17993 ];
17994 case 4:
17995 error = _state.sent();
17996 throw _this.handleError(error);
17997 case 5:
17998 i2++;
17999 return [
18000 3,
18001 1
18002 ];
18003 case 6:
18004 _this.prepareVisitors();
18005 if (!_this.hasListener) return [
18006 3,
18007 18
18008 ];
18009 root2 = _this.result.root;
18010 _state.label = 7;
18011 case 7:
18012 if (!!root2[isClean]) return [
18013 3,
18014 14
18015 ];
18016 root2[isClean] = true;
18017 stack = [
18018 toStack(root2)
18019 ];
18020 _state.label = 8;
18021 case 8:
18022 if (!(stack.length > 0)) return [
18023 3,
18024 13
18025 ];
18026 promise1 = _this.visitTick(stack);
18027 if (!isPromise(promise1)) return [
18028 3,
18029 12
18030 ];
18031 _state.label = 9;
18032 case 9:
18033 _state.trys.push([
18034 9,
18035 11,
18036 ,
18037 12
18038 ]);
18039 return [
18040 4,
18041 promise1
18042 ];
18043 case 10:
18044 _state.sent();
18045 return [
18046 3,
18047 12
18048 ];
18049 case 11:
18050 e2 = _state.sent();
18051 node2 = stack[stack.length - 1].node;
18052 throw _this.handleError(e2, node2);
18053 case 12:
18054 return [
18055 3,
18056 8
18057 ];
18058 case 13:
18059 return [
18060 3,
18061 7
18062 ];
18063 case 14:
18064 if (!_this.listeners.OnceExit) return [
18065 3,
18066 18
18067 ];
18068 _loop = function() {
18069 var _step_value, plugin22, visitor, roots, e2;
18070 return _ts_generator(this, function(_state) {
18071 switch(_state.label){
18072 case 0:
18073 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
18074 _this.result.lastPlugin = plugin22;
18075 _state.label = 1;
18076 case 1:
18077 _state.trys.push([
18078 1,
18079 6,
18080 ,
18081 7
18082 ]);
18083 if (!(root2.type === "document")) return [
18084 3,
18085 3
18086 ];
18087 roots = root2.nodes.map(function(subRoot) {
18088 return visitor(subRoot, _this.helpers);
18089 });
18090 return [
18091 4,
18092 Promise.all(roots)
18093 ];
18094 case 2:
18095 _state.sent();
18096 return [
18097 3,
18098 5
18099 ];
18100 case 3:
18101 return [
18102 4,
18103 visitor(root2, _this.helpers)
18104 ];
18105 case 4:
18106 _state.sent();
18107 _state.label = 5;
18108 case 5:
18109 return [
18110 3,
18111 7
18112 ];
18113 case 6:
18114 e2 = _state.sent();
18115 throw _this.handleError(e2);
18116 case 7:
18117 return [
18118 2
18119 ];
18120 }
18121 });
18122 };
18123 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
18124 _state.label = 15;
18125 case 15:
18126 if (!!(_step = _iterator()).done) return [
18127 3,
18128 18
18129 ];
18130 return [
18131 5,
18132 _ts_values(_loop())
18133 ];
18134 case 16:
18135 _state.sent();
18136 _state.label = 17;
18137 case 17:
18138 return [
18139 3,
18140 15
18141 ];
18142 case 18:
18143 _this.processed = true;
18144 return [
18145 2,
18146 _this.stringify()
18147 ];
18148 }
18149 });
18150 })();
18151 };
18152 _proto.runOnRoot = function runOnRoot(plugin22) {
18153 var _this = this;
18154 this.result.lastPlugin = plugin22;
18155 try {
18156 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
18157 if (this.result.root.type === "document") {
18158 var roots = this.result.root.nodes.map(function(root2) {
18159 return plugin22.Once(root2, _this.helpers);
18160 });
18161 if (isPromise(roots[0])) {
18162 return Promise.all(roots);
18163 }
18164 return roots;
18165 }
18166 return plugin22.Once(this.result.root, this.helpers);
18167 } else if (typeof plugin22 === "function") {
18168 return plugin22(this.result.root, this.result);
18169 }
18170 } catch (error) {
18171 throw this.handleError(error);
18172 }
18173 };
18174 _proto.stringify = function stringify() {
18175 if (this.error) throw this.error;
18176 if (this.stringified) return this.result;
18177 this.stringified = true;
18178 this.sync();
18179 var opts = this.result.opts;
18180 var str = stringify$2;
18181 if (opts.syntax) str = opts.syntax.stringify;
18182 if (opts.stringifier) str = opts.stringifier;
18183 if (str.stringify) str = str.stringify;
18184 var map = new MapGenerator$1(str, this.result.root, this.result.opts);
18185 var data = map.generate();
18186 this.result.css = data[0];
18187 this.result.map = data[1];
18188 return this.result;
18189 };
18190 _proto.sync = function sync() {
18191 if (this.error) throw this.error;
18192 if (this.processed) return this.result;
18193 this.processed = true;
18194 if (this.processing) {
18195 throw this.getAsyncError();
18196 }
18197 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
18198 var plugin22 = _step.value;
18199 var promise = this.runOnRoot(plugin22);
18200 if (isPromise(promise)) {
18201 throw this.getAsyncError();
18202 }
18203 }
18204 this.prepareVisitors();
18205 if (this.hasListener) {
18206 var root2 = this.result.root;
18207 while(!root2[isClean]){
18208 root2[isClean] = true;
18209 this.walkSync(root2);
18210 }
18211 if (this.listeners.OnceExit) {
18212 if (root2.type === "document") {
18213 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
18214 var subRoot = _step1.value;
18215 this.visitSync(this.listeners.OnceExit, subRoot);
18216 }
18217 } else {
18218 this.visitSync(this.listeners.OnceExit, root2);
18219 }
18220 }
18221 }
18222 return this.result;
18223 };
18224 _proto.then = function then(onFulfilled, onRejected) {
18225 if (true) {
18226 if (!("from" in this.opts)) {
18227 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.");
18228 }
18229 }
18230 return this.async().then(onFulfilled, onRejected);
18231 };
18232 _proto.toString = function toString() {
18233 return this.css;
18234 };
18235 _proto.visitSync = function visitSync(visitors, node2) {
18236 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
18237 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
18238 this.result.lastPlugin = plugin22;
18239 var promise = void 0;
18240 try {
18241 promise = visitor(node2, this.helpers);
18242 } catch (e2) {
18243 throw this.handleError(e2, node2.proxyOf);
18244 }
18245 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
18246 return true;
18247 }
18248 if (isPromise(promise)) {
18249 throw this.getAsyncError();
18250 }
18251 }
18252 };
18253 _proto.visitTick = function visitTick(stack) {
18254 var visit2 = stack[stack.length - 1];
18255 var node2 = visit2.node, visitors = visit2.visitors;
18256 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
18257 stack.pop();
18258 return;
18259 }
18260 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
18261 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
18262 visit2.visitorIndex += 1;
18263 if (visit2.visitorIndex === visitors.length) {
18264 visit2.visitors = [];
18265 visit2.visitorIndex = 0;
18266 }
18267 this.result.lastPlugin = plugin22;
18268 try {
18269 return visitor(node2.toProxy(), this.helpers);
18270 } catch (e2) {
18271 throw this.handleError(e2, node2);
18272 }
18273 }
18274 if (visit2.iterator !== 0) {
18275 var iterator = visit2.iterator;
18276 var child;
18277 while(child = node2.nodes[node2.indexes[iterator]]){
18278 node2.indexes[iterator] += 1;
18279 if (!child[isClean]) {
18280 child[isClean] = true;
18281 stack.push(toStack(child));
18282 return;
18283 }
18284 }
18285 visit2.iterator = 0;
18286 delete node2.indexes[iterator];
18287 }
18288 var events = visit2.events;
18289 while(visit2.eventIndex < events.length){
18290 var event = events[visit2.eventIndex];
18291 visit2.eventIndex += 1;
18292 if (event === CHILDREN) {
18293 if (node2.nodes && node2.nodes.length) {
18294 node2[isClean] = true;
18295 visit2.iterator = node2.getIterator();
18296 }
18297 return;
18298 } else if (this.listeners[event]) {
18299 visit2.visitors = this.listeners[event];
18300 return;
18301 }
18302 }
18303 stack.pop();
18304 };
18305 _proto.walkSync = function walkSync(node2) {
18306 var _this = this;
18307 node2[isClean] = true;
18308 var events = getEvents(node2);
18309 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
18310 var event = _step.value;
18311 if (event === CHILDREN) {
18312 if (node2.nodes) {
18313 node2.each(function(child) {
18314 if (!child[isClean]) _this.walkSync(child);
18315 });
18316 }
18317 } else {
18318 var visitors = this.listeners[event];
18319 if (visitors) {
18320 if (this.visitSync(visitors, node2.toProxy())) return;
18321 }
18322 }
18323 }
18324 };
18325 _proto.warnings = function warnings() {
18326 return this.sync().warnings();
18327 };
18328 _create_class(LazyResult2, [
18329 {
18330 key: "content",
18331 get: function get() {
18332 return this.stringify().content;
18333 }
18334 },
18335 {
18336 key: "css",
18337 get: function get() {
18338 return this.stringify().css;
18339 }
18340 },
18341 {
18342 key: "map",
18343 get: function get() {
18344 return this.stringify().map;
18345 }
18346 },
18347 {
18348 key: "messages",
18349 get: function get() {
18350 return this.sync().messages;
18351 }
18352 },
18353 {
18354 key: "opts",
18355 get: function get() {
18356 return this.result.opts;
18357 }
18358 },
18359 {
18360 key: "processor",
18361 get: function get() {
18362 return this.result.processor;
18363 }
18364 },
18365 {
18366 key: "root",
18367 get: function get() {
18368 return this.sync().root;
18369 }
18370 },
18371 {
18372 key: Symbol.toStringTag,
18373 get: function get() {
18374 return "LazyResult";
18375 }
18376 }
18377 ]);
18378 return LazyResult2;
18379 }();
18380 LazyResult$2.registerPostcss = function(dependant) {
18381 postcss$2 = dependant;
18382 };
18383 var lazyResult = LazyResult$2;
18384 LazyResult$2.default = LazyResult$2;
18385 Root$3.registerLazyResult(LazyResult$2);
18386 Document$2.registerLazyResult(LazyResult$2);
18387 var MapGenerator22 = mapGenerator;
18388 var stringify$1 = stringify_1;
18389 var warnOnce22 = warnOnce$2;
18390 var parse$1 = parse_1;
18391 var Result$1 = result;
18392 var NoWorkResult$1 = /*#__PURE__*/ function() {
18393 function NoWorkResult2(processor2, css, opts) {
18394 css = css.toString();
18395 this.stringified = false;
18396 this._processor = processor2;
18397 this._css = css;
18398 this._opts = opts;
18399 this._map = void 0;
18400 var root2;
18401 var str = stringify$1;
18402 this.result = new Result$1(this._processor, root2, this._opts);
18403 this.result.css = css;
18404 var self = this;
18405 Object.defineProperty(this.result, "root", {
18406 get: function get() {
18407 return self.root;
18408 }
18409 });
18410 var map = new MapGenerator22(str, root2, this._opts, css);
18411 if (map.isMap()) {
18412 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
18413 if (generatedCSS) {
18414 this.result.css = generatedCSS;
18415 }
18416 if (generatedMap) {
18417 this.result.map = generatedMap;
18418 }
18419 } else {
18420 map.clearAnnotation();
18421 this.result.css = map.css;
18422 }
18423 }
18424 var _proto = NoWorkResult2.prototype;
18425 _proto.async = function async() {
18426 if (this.error) return Promise.reject(this.error);
18427 return Promise.resolve(this.result);
18428 };
18429 _proto.catch = function _catch(onRejected) {
18430 return this.async().catch(onRejected);
18431 };
18432 _proto.finally = function _finally(onFinally) {
18433 return this.async().then(onFinally, onFinally);
18434 };
18435 _proto.sync = function sync() {
18436 if (this.error) throw this.error;
18437 return this.result;
18438 };
18439 _proto.then = function then(onFulfilled, onRejected) {
18440 if (true) {
18441 if (!("from" in this._opts)) {
18442 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.");
18443 }
18444 }
18445 return this.async().then(onFulfilled, onRejected);
18446 };
18447 _proto.toString = function toString() {
18448 return this._css;
18449 };
18450 _proto.warnings = function warnings() {
18451 return [];
18452 };
18453 _create_class(NoWorkResult2, [
18454 {
18455 key: "content",
18456 get: function get() {
18457 return this.result.css;
18458 }
18459 },
18460 {
18461 key: "css",
18462 get: function get() {
18463 return this.result.css;
18464 }
18465 },
18466 {
18467 key: "map",
18468 get: function get() {
18469 return this.result.map;
18470 }
18471 },
18472 {
18473 key: "messages",
18474 get: function get() {
18475 return [];
18476 }
18477 },
18478 {
18479 key: "opts",
18480 get: function get() {
18481 return this.result.opts;
18482 }
18483 },
18484 {
18485 key: "processor",
18486 get: function get() {
18487 return this.result.processor;
18488 }
18489 },
18490 {
18491 key: "root",
18492 get: function get() {
18493 if (this._root) {
18494 return this._root;
18495 }
18496 var root2;
18497 var parser2 = parse$1;
18498 try {
18499 root2 = parser2(this._css, this._opts);
18500 } catch (error) {
18501 this.error = error;
18502 }
18503 if (this.error) {
18504 throw this.error;
18505 } else {
18506 this._root = root2;
18507 return root2;
18508 }
18509 }
18510 },
18511 {
18512 key: Symbol.toStringTag,
18513 get: function get() {
18514 return "NoWorkResult";
18515 }
18516 }
18517 ]);
18518 return NoWorkResult2;
18519 }();
18520 var noWorkResult = NoWorkResult$1;
18521 NoWorkResult$1.default = NoWorkResult$1;
18522 var NoWorkResult22 = noWorkResult;
18523 var LazyResult$1 = lazyResult;
18524 var Document$1 = document$1$2;
18525 var Root$2 = root;
18526 var Processor$1 = /*#__PURE__*/ function() {
18527 function Processor2(plugins) {
18528 if (plugins === void 0) plugins = [];
18529 this.version = "8.4.38";
18530 this.plugins = this.normalize(plugins);
18531 }
18532 var _proto = Processor2.prototype;
18533 _proto.normalize = function normalize(plugins) {
18534 var normalized = [];
18535 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
18536 var i2 = _step.value;
18537 if (i2.postcss === true) {
18538 i2 = i2();
18539 } else if (i2.postcss) {
18540 i2 = i2.postcss;
18541 }
18542 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
18543 normalized = normalized.concat(i2.plugins);
18544 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
18545 normalized.push(i2);
18546 } else if (typeof i2 === "function") {
18547 normalized.push(i2);
18548 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
18549 if (true) {
18550 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.");
18551 }
18552 } else {
18553 throw new Error(i2 + " is not a PostCSS plugin");
18554 }
18555 }
18556 return normalized;
18557 };
18558 _proto.process = function process1(css, opts) {
18559 if (opts === void 0) opts = {};
18560 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
18561 return new NoWorkResult22(this, css, opts);
18562 } else {
18563 return new LazyResult$1(this, css, opts);
18564 }
18565 };
18566 _proto.use = function use(plugin22) {
18567 this.plugins = this.plugins.concat(this.normalize([
18568 plugin22
18569 ]));
18570 return this;
18571 };
18572 return Processor2;
18573 }();
18574 var processor = Processor$1;
18575 Processor$1.default = Processor$1;
18576 Root$2.registerProcessor(Processor$1);
18577 Document$1.registerProcessor(Processor$1);
18578 var Declaration$1 = declaration;
18579 var PreviousMap22 = previousMap;
18580 var Comment$1 = comment;
18581 var AtRule$1 = atRule;
18582 var Input$1 = input;
18583 var Root$1 = root;
18584 var Rule$1 = rule;
18585 function fromJSON$1(json, inputs) {
18586 if (Array.isArray(json)) return json.map(function(n2) {
18587 return fromJSON$1(n2);
18588 });
18589 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
18590 "inputs"
18591 ]);
18592 if (ownInputs) {
18593 inputs = [];
18594 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
18595 var input2 = _step.value;
18596 var inputHydrated = _extends({}, input2, {
18597 __proto__: Input$1.prototype
18598 });
18599 if (inputHydrated.map) {
18600 inputHydrated.map = _extends({}, inputHydrated.map, {
18601 __proto__: PreviousMap22.prototype
18602 });
18603 }
18604 inputs.push(inputHydrated);
18605 }
18606 }
18607 if (defaults.nodes) {
18608 defaults.nodes = json.nodes.map(function(n2) {
18609 return fromJSON$1(n2, inputs);
18610 });
18611 }
18612 if (defaults.source) {
18613 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
18614 "inputId"
18615 ]);
18616 defaults.source = source;
18617 if (inputId != null) {
18618 defaults.source.input = inputs[inputId];
18619 }
18620 }
18621 if (defaults.type === "root") {
18622 return new Root$1(defaults);
18623 } else if (defaults.type === "decl") {
18624 return new Declaration$1(defaults);
18625 } else if (defaults.type === "rule") {
18626 return new Rule$1(defaults);
18627 } else if (defaults.type === "comment") {
18628 return new Comment$1(defaults);
18629 } else if (defaults.type === "atrule") {
18630 return new AtRule$1(defaults);
18631 } else {
18632 throw new Error("Unknown node type: " + json.type);
18633 }
18634 }
18635 var fromJSON_1 = fromJSON$1;
18636 fromJSON$1.default = fromJSON$1;
18637 var CssSyntaxError22 = cssSyntaxError;
18638 var Declaration22 = declaration;
18639 var LazyResult22 = lazyResult;
18640 var Container22 = container;
18641 var Processor22 = processor;
18642 var stringify = stringify_1;
18643 var fromJSON = fromJSON_1;
18644 var Document222 = document$1$2;
18645 var Warning22 = warning;
18646 var Comment22 = comment;
18647 var AtRule22 = atRule;
18648 var Result22 = result;
18649 var Input22 = input;
18650 var parse = parse_1;
18651 var list = list_1;
18652 var Rule22 = rule;
18653 var Root22 = root;
18654 var Node22 = node;
18655 function postcss() {
18656 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
18657 plugins[_key] = arguments[_key];
18658 }
18659 if (plugins.length === 1 && Array.isArray(plugins[0])) {
18660 plugins = plugins[0];
18661 }
18662 return new Processor22(plugins);
18663 }
18664 postcss.plugin = function plugin2(name, initializer) {
18665 var warningPrinted = false;
18666 function creator() {
18667 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18668 args[_key] = arguments[_key];
18669 }
18670 if (console && console.warn && !warningPrinted) {
18671 warningPrinted = true;
18672 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
18673 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
18674 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
18675 }
18676 }
18677 var transformer = initializer.apply(void 0, [].concat(args));
18678 transformer.postcssPlugin = name;
18679 transformer.postcssVersion = new Processor22().version;
18680 return transformer;
18681 }
18682 var cache;
18683 Object.defineProperty(creator, "postcss", {
18684 get: function get() {
18685 if (!cache) cache = creator();
18686 return cache;
18687 }
18688 });
18689 creator.process = function(css, processOpts, pluginOpts) {
18690 return postcss([
18691 creator(pluginOpts)
18692 ]).process(css, processOpts);
18693 };
18694 return creator;
18695 };
18696 postcss.stringify = stringify;
18697 postcss.parse = parse;
18698 postcss.fromJSON = fromJSON;
18699 postcss.list = list;
18700 postcss.comment = function(defaults) {
18701 return new Comment22(defaults);
18702 };
18703 postcss.atRule = function(defaults) {
18704 return new AtRule22(defaults);
18705 };
18706 postcss.decl = function(defaults) {
18707 return new Declaration22(defaults);
18708 };
18709 postcss.rule = function(defaults) {
18710 return new Rule22(defaults);
18711 };
18712 postcss.root = function(defaults) {
18713 return new Root22(defaults);
18714 };
18715 postcss.document = function(defaults) {
18716 return new Document222(defaults);
18717 };
18718 postcss.CssSyntaxError = CssSyntaxError22;
18719 postcss.Declaration = Declaration22;
18720 postcss.Container = Container22;
18721 postcss.Processor = Processor22;
18722 postcss.Document = Document222;
18723 postcss.Comment = Comment22;
18724 postcss.Warning = Warning22;
18725 postcss.AtRule = AtRule22;
18726 postcss.Result = Result22;
18727 postcss.Input = Input22;
18728 postcss.Rule = Rule22;
18729 postcss.Root = Root22;
18730 postcss.Node = Node22;
18731 LazyResult22.registerPostcss(postcss);
18732 var postcss_1 = postcss;
18733 postcss.default = postcss;
18734 var postcss$1 = /* @__PURE__ */ getDefaultExportFromCjs(postcss_1);
18735 postcss$1.stringify;
18736 postcss$1.fromJSON;
18737 postcss$1.plugin;
18738 postcss$1.parse;
18739 postcss$1.list;
18740 postcss$1.document;
18741 postcss$1.comment;
18742 postcss$1.atRule;
18743 postcss$1.rule;
18744 postcss$1.decl;
18745 postcss$1.root;
18746 postcss$1.CssSyntaxError;
18747 postcss$1.Declaration;
18748 postcss$1.Container;
18749 postcss$1.Processor;
18750 postcss$1.Document;
18751 postcss$1.Comment;
18752 postcss$1.Warning;
18753 postcss$1.AtRule;
18754 postcss$1.Result;
18755 postcss$1.Input;
18756 postcss$1.Rule;
18757 postcss$1.Root;
18758 postcss$1.Node;
18759 var BaseRRNode = /*#__PURE__*/ function() {
18760 function BaseRRNode() {
18761 for(var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++){
18762 _args[_key] = arguments[_key];
18763 }
18764 __publicField2(this, "parentElement", null);
18765 __publicField2(this, "parentNode", null);
18766 __publicField2(this, "ownerDocument");
18767 __publicField2(this, "firstChild", null);
18768 __publicField2(this, "lastChild", null);
18769 __publicField2(this, "previousSibling", null);
18770 __publicField2(this, "nextSibling", null);
18771 __publicField2(this, "ELEMENT_NODE", 1);
18772 __publicField2(this, "TEXT_NODE", 3);
18773 __publicField2(this, "nodeType");
18774 __publicField2(this, "nodeName");
18775 __publicField2(this, "RRNodeType");
18776 }
18777 var _proto = BaseRRNode.prototype;
18778 _proto.contains = function contains(node2) {
18779 if (!_instanceof(node2, BaseRRNode)) return false;
18780 else if (node2.ownerDocument !== this.ownerDocument) return false;
18781 else if (node2 === this) return true;
18782 while(node2.parentNode){
18783 if (node2.parentNode === this) return true;
18784 node2 = node2.parentNode;
18785 }
18786 return false;
18787 };
18788 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18789 _proto.appendChild = function appendChild(_newChild) {
18790 throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.");
18791 };
18792 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18793 _proto.insertBefore = function insertBefore(_newChild, _refChild) {
18794 throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.");
18795 };
18796 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18797 _proto.removeChild = function removeChild(_node) {
18798 throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.");
18799 };
18800 _proto.toString = function toString() {
18801 return "RRNode";
18802 };
18803 _create_class(BaseRRNode, [
18804 {
18805 key: "childNodes",
18806 get: function get() {
18807 var childNodes2 = [];
18808 var childIterator = this.firstChild;
18809 while(childIterator){
18810 childNodes2.push(childIterator);
18811 childIterator = childIterator.nextSibling;
18812 }
18813 return childNodes2;
18814 }
18815 }
18816 ]);
18817 return BaseRRNode;
18818 }();
18819 var testableAccessors = {
18820 Node: [
18821 "childNodes",
18822 "parentNode",
18823 "parentElement",
18824 "textContent"
18825 ],
18826 ShadowRoot: [
18827 "host",
18828 "styleSheets"
18829 ],
18830 Element: [
18831 "shadowRoot",
18832 "querySelector",
18833 "querySelectorAll"
18834 ],
18835 MutationObserver: []
18836 };
18837 var testableMethods = {
18838 Node: [
18839 "contains",
18840 "getRootNode"
18841 ],
18842 ShadowRoot: [
18843 "getSelection"
18844 ],
18845 Element: [],
18846 MutationObserver: [
18847 "constructor"
18848 ]
18849 };
18850 var untaintedBasePrototype = {};
18851 var isAngularZonePresent = function() {
18852 return !!globalThis.Zone;
18853 };
18854 function getUntaintedPrototype(key) {
18855 if (untaintedBasePrototype[key]) return untaintedBasePrototype[key];
18856 var defaultObj = globalThis[key];
18857 var defaultPrototype = defaultObj.prototype;
18858 var accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
18859 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
18860 accessorNames.every(function(accessor) {
18861 var _a2, _b;
18862 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
18863 }));
18864 var methodNames = key in testableMethods ? testableMethods[key] : void 0;
18865 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
18866 function(method) {
18867 var _a2;
18868 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
18869 }));
18870 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {
18871 untaintedBasePrototype[key] = defaultObj.prototype;
18872 return defaultObj.prototype;
18873 }
18874 try {
18875 var iframeEl = document.createElement("iframe");
18876 document.body.appendChild(iframeEl);
18877 var win = iframeEl.contentWindow;
18878 if (!win) return defaultObj.prototype;
18879 var untaintedObject = win[key].prototype;
18880 document.body.removeChild(iframeEl);
18881 if (!untaintedObject) return defaultPrototype;
18882 return untaintedBasePrototype[key] = untaintedObject;
18883 } catch (e) {
18884 return defaultPrototype;
18885 }
18886 }
18887 var untaintedAccessorCache = {};
18888 function getUntaintedAccessor(key, instance, accessor) {
18889 var _a2;
18890 var cacheKey = key + "." + String(accessor);
18891 if (untaintedAccessorCache[cacheKey]) return untaintedAccessorCache[cacheKey].call(instance);
18892 var untaintedPrototype = getUntaintedPrototype(key);
18893 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
18894 if (!untaintedAccessor) return instance[accessor];
18895 untaintedAccessorCache[cacheKey] = untaintedAccessor;
18896 return untaintedAccessor.call(instance);
18897 }
18898 var untaintedMethodCache = {};
18899 function getUntaintedMethod(key, instance, method) {
18900 var cacheKey = key + "." + String(method);
18901 if (untaintedMethodCache[cacheKey]) return untaintedMethodCache[cacheKey].bind(instance);
18902 var untaintedPrototype = getUntaintedPrototype(key);
18903 var untaintedMethod = untaintedPrototype[method];
18904 if (typeof untaintedMethod !== "function") return instance[method];
18905 untaintedMethodCache[cacheKey] = untaintedMethod;
18906 return untaintedMethod.bind(instance);
18907 }
18908 function childNodes(n2) {
18909 return getUntaintedAccessor("Node", n2, "childNodes");
18910 }
18911 function parentNode(n2) {
18912 return getUntaintedAccessor("Node", n2, "parentNode");
18913 }
18914 function parentElement(n2) {
18915 return getUntaintedAccessor("Node", n2, "parentElement");
18916 }
18917 function textContent(n2) {
18918 return getUntaintedAccessor("Node", n2, "textContent");
18919 }
18920 function contains(n2, other) {
18921 return getUntaintedMethod("Node", n2, "contains")(other);
18922 }
18923 function getRootNode(n2) {
18924 return getUntaintedMethod("Node", n2, "getRootNode")();
18925 }
18926 function host(n2) {
18927 if (!n2 || !("host" in n2)) return null;
18928 return getUntaintedAccessor("ShadowRoot", n2, "host");
18929 }
18930 function styleSheets(n2) {
18931 return n2.styleSheets;
18932 }
18933 function shadowRoot(n2) {
18934 if (!n2 || !("shadowRoot" in n2)) return null;
18935 return getUntaintedAccessor("Element", n2, "shadowRoot");
18936 }
18937 function querySelector(n2, selectors) {
18938 return getUntaintedAccessor("Element", n2, "querySelector")(selectors);
18939 }
18940 function querySelectorAll(n2, selectors) {
18941 return getUntaintedAccessor("Element", n2, "querySelectorAll")(selectors);
18942 }
18943 function mutationObserverCtor() {
18944 return getUntaintedPrototype("MutationObserver").constructor;
18945 }
18946 function patch(source, name, replacement) {
18947 try {
18948 if (!(name in source)) {
18949 return function() {};
18950 }
18951 var original = source[name];
18952 var wrapped = replacement(original);
18953 if (typeof wrapped === "function") {
18954 wrapped.prototype = wrapped.prototype || {};
18955 Object.defineProperties(wrapped, {
18956 __rrweb_original__: {
18957 enumerable: false,
18958 value: original
18959 }
18960 });
18961 }
18962 source[name] = wrapped;
18963 return function() {
18964 source[name] = original;
18965 };
18966 } catch (e) {
18967 return function() {};
18968 }
18969 }
18970 var index = {
18971 childNodes: childNodes,
18972 parentNode: parentNode,
18973 parentElement: parentElement,
18974 textContent: textContent,
18975 contains: contains,
18976 getRootNode: getRootNode,
18977 host: host,
18978 styleSheets: styleSheets,
18979 shadowRoot: shadowRoot,
18980 querySelector: querySelector,
18981 querySelectorAll: querySelectorAll,
18982 mutationObserver: mutationObserverCtor,
18983 patch: patch
18984 };
18985 function on(type, fn, target) {
18986 if (target === void 0) target = document;
18987 var options = {
18988 capture: true,
18989 passive: true
18990 };
18991 target.addEventListener(type, fn, options);
18992 return function() {
18993 return target.removeEventListener(type, fn, options);
18994 };
18995 }
18996 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.";
18997 var _mirror = {
18998 map: {},
18999 getId: function getId() {
19000 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19001 return -1;
19002 },
19003 getNode: function getNode() {
19004 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19005 return null;
19006 },
19007 removeNodeFromMap: function removeNodeFromMap() {
19008 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19009 },
19010 has: function has() {
19011 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19012 return false;
19013 },
19014 reset: function reset() {
19015 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19016 }
19017 };
19018 if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
19019 _mirror = new Proxy(_mirror, {
19020 get: function get(target, prop, receiver) {
19021 if (prop === "map") {
19022 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19023 }
19024 return Reflect.get(target, prop, receiver);
19025 }
19026 });
19027 }
19028 function throttle(func, wait, options) {
19029 if (options === void 0) options = {};
19030 var timeout = null;
19031 var previous = 0;
19032 return function() {
19033 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
19034 args[_key] = arguments[_key];
19035 }
19036 var now = Date.now();
19037 if (!previous && options.leading === false) {
19038 previous = now;
19039 }
19040 var remaining = wait - (now - previous);
19041 var context = this;
19042 if (remaining <= 0 || remaining > wait) {
19043 if (timeout) {
19044 clearTimeout(timeout);
19045 timeout = null;
19046 }
19047 previous = now;
19048 func.apply(context, args);
19049 } else if (!timeout && options.trailing !== false) {
19050 timeout = setTimeout(function() {
19051 previous = options.leading === false ? 0 : Date.now();
19052 timeout = null;
19053 func.apply(context, args);
19054 }, remaining);
19055 }
19056 };
19057 }
19058 function hookSetter(target, key, d, isRevoked, win) {
19059 if (win === void 0) win = window;
19060 var original = win.Object.getOwnPropertyDescriptor(target, key);
19061 win.Object.defineProperty(target, key, isRevoked ? d : {
19062 set: function set(value) {
19063 var _this = this;
19064 setTimeout(function() {
19065 d.set.call(_this, value);
19066 }, 0);
19067 if (original && original.set) {
19068 original.set.call(this, value);
19069 }
19070 }
19071 });
19072 return function() {
19073 return hookSetter(target, key, original || {}, true);
19074 };
19075 }
19076 var nowTimestamp = Date.now;
19077 if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
19078 nowTimestamp = function() {
19079 return /* @__PURE__ */ new Date().getTime();
19080 };
19081 }
19082 function getWindowScroll(win) {
19083 var _a2, _b, _c, _d;
19084 var doc = win.document;
19085 return {
19086 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,
19087 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
19088 };
19089 }
19090 function getWindowHeight() {
19091 return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
19092 }
19093 function getWindowWidth() {
19094 return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
19095 }
19096 function closestElementOfNode(node2) {
19097 if (!node2) {
19098 return null;
19099 }
19100 var el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index.parentElement(node2);
19101 return el;
19102 }
19103 function isBlocked(node2, blockClass, blockSelector, checkAncestors) {
19104 if (!node2) {
19105 return false;
19106 }
19107 var el = closestElementOfNode(node2);
19108 if (!el) {
19109 return false;
19110 }
19111 try {
19112 if (typeof blockClass === "string") {
19113 if (el.classList.contains(blockClass)) return true;
19114 if (checkAncestors && el.closest("." + blockClass) !== null) return true;
19115 } else {
19116 if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
19117 }
19118 } catch (e2) {}
19119 if (blockSelector) {
19120 if (el.matches(blockSelector)) return true;
19121 if (checkAncestors && el.closest(blockSelector) !== null) return true;
19122 }
19123 return false;
19124 }
19125 function isSerialized(n2, mirror2) {
19126 return mirror2.getId(n2) !== -1;
19127 }
19128 function isIgnored(n2, mirror2, slimDOMOptions) {
19129 if (n2.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
19130 return true;
19131 }
19132 return mirror2.getId(n2) === IGNORED_NODE;
19133 }
19134 function isAncestorRemoved(target, mirror2) {
19135 if (isShadowRoot(target)) {
19136 return false;
19137 }
19138 var id = mirror2.getId(target);
19139 if (!mirror2.has(id)) {
19140 return true;
19141 }
19142 var parent = index.parentNode(target);
19143 if (parent && parent.nodeType === target.DOCUMENT_NODE) {
19144 return false;
19145 }
19146 if (!parent) {
19147 return true;
19148 }
19149 return isAncestorRemoved(parent, mirror2);
19150 }
19151 function legacy_isTouchEvent(event) {
19152 return Boolean(event.changedTouches);
19153 }
19154 function polyfill$1(win) {
19155 if (win === void 0) win = window;
19156 if ("NodeList" in win && !win.NodeList.prototype.forEach) {
19157 win.NodeList.prototype.forEach = Array.prototype.forEach;
19158 }
19159 if ("DOMTokenList" in win && !win.DOMTokenList.prototype.forEach) {
19160 win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
19161 }
19162 }
19163 function isSerializedIframe(n2, mirror2) {
19164 return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
19165 }
19166 function isSerializedStylesheet(n2, mirror2) {
19167 return Boolean(n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2));
19168 }
19169 function hasShadowRoot(n2) {
19170 if (!n2) return false;
19171 if (_instanceof(n2, BaseRRNode) && "shadowRoot" in n2) {
19172 return Boolean(n2.shadowRoot);
19173 }
19174 return Boolean(index.shadowRoot(n2));
19175 }
19176 var StyleSheetMirror = /*#__PURE__*/ function() {
19177 function StyleSheetMirror() {
19178 __publicField(this, "id", 1);
19179 __publicField(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
19180 __publicField(this, "idStyleMap", /* @__PURE__ */ new Map());
19181 }
19182 var _proto = StyleSheetMirror.prototype;
19183 _proto.getId = function getId(stylesheet) {
19184 var _this_styleIDMap_get;
19185 return (_this_styleIDMap_get = this.styleIDMap.get(stylesheet)) != null ? _this_styleIDMap_get : -1;
19186 };
19187 _proto.has = function has(stylesheet) {
19188 return this.styleIDMap.has(stylesheet);
19189 };
19190 /**
19191 * @returns If the stylesheet is in the mirror, returns the id of the stylesheet. If not, return the new assigned id.
19192 */ _proto.add = function add(stylesheet, id) {
19193 if (this.has(stylesheet)) return this.getId(stylesheet);
19194 var newId;
19195 if (id === void 0) {
19196 newId = this.id++;
19197 } else newId = id;
19198 this.styleIDMap.set(stylesheet, newId);
19199 this.idStyleMap.set(newId, stylesheet);
19200 return newId;
19201 };
19202 _proto.getStyle = function getStyle(id) {
19203 return this.idStyleMap.get(id) || null;
19204 };
19205 _proto.reset = function reset() {
19206 this.styleIDMap = /* @__PURE__ */ new WeakMap();
19207 this.idStyleMap = /* @__PURE__ */ new Map();
19208 this.id = 1;
19209 };
19210 _proto.generateId = function generateId() {
19211 return this.id++;
19212 };
19213 return StyleSheetMirror;
19214 }();
19215 function getShadowHost(n2) {
19216 var _a2;
19217 var shadowHost = null;
19218 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));
19219 return shadowHost;
19220 }
19221 function getRootShadowHost(n2) {
19222 var rootShadowHost = n2;
19223 var shadowHost;
19224 while(shadowHost = getShadowHost(rootShadowHost))rootShadowHost = shadowHost;
19225 return rootShadowHost;
19226 }
19227 function shadowHostInDom(n2) {
19228 var doc = n2.ownerDocument;
19229 if (!doc) return false;
19230 var shadowHost = getRootShadowHost(n2);
19231 return index.contains(doc, shadowHost);
19232 }
19233 function inDom(n2) {
19234 var doc = n2.ownerDocument;
19235 if (!doc) return false;
19236 return index.contains(doc, n2) || shadowHostInDom(n2);
19237 }
19238 var EventType = /* @__PURE__ */ function(EventType2) {
19239 EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
19240 EventType2[EventType2["Load"] = 1] = "Load";
19241 EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
19242 EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
19243 EventType2[EventType2["Meta"] = 4] = "Meta";
19244 EventType2[EventType2["Custom"] = 5] = "Custom";
19245 EventType2[EventType2["Plugin"] = 6] = "Plugin";
19246 return EventType2;
19247 }(EventType || {});
19248 var IncrementalSource = /* @__PURE__ */ function(IncrementalSource2) {
19249 IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
19250 IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
19251 IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
19252 IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
19253 IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
19254 IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
19255 IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
19256 IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
19257 IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
19258 IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
19259 IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
19260 IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
19261 IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
19262 IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
19263 IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
19264 IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
19265 IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
19266 return IncrementalSource2;
19267 }(IncrementalSource || {});
19268 var MouseInteractions = /* @__PURE__ */ function(MouseInteractions2) {
19269 MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
19270 MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
19271 MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
19272 MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
19273 MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
19274 MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
19275 MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
19276 MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
19277 MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
19278 MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
19279 MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
19280 return MouseInteractions2;
19281 }(MouseInteractions || {});
19282 var PointerTypes = /* @__PURE__ */ function(PointerTypes2) {
19283 PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
19284 PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
19285 PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
19286 return PointerTypes2;
19287 }(PointerTypes || {});
19288 var CanvasContext = /* @__PURE__ */ function(CanvasContext2) {
19289 CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
19290 CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
19291 CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
19292 return CanvasContext2;
19293 }(CanvasContext || {});
19294 var MediaInteractions = /* @__PURE__ */ function(MediaInteractions2) {
19295 MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
19296 MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
19297 MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
19298 MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
19299 MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
19300 return MediaInteractions2;
19301 }(MediaInteractions || {});
19302 var NodeType = /* @__PURE__ */ function(NodeType2) {
19303 NodeType2[NodeType2["Document"] = 0] = "Document";
19304 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
19305 NodeType2[NodeType2["Element"] = 2] = "Element";
19306 NodeType2[NodeType2["Text"] = 3] = "Text";
19307 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
19308 NodeType2[NodeType2["Comment"] = 5] = "Comment";
19309 return NodeType2;
19310 }(NodeType || {});
19311 function isNodeInLinkedList(n2) {
19312 return "__ln" in n2;
19313 }
19314 var DoubleLinkedList = /*#__PURE__*/ function() {
19315 function DoubleLinkedList() {
19316 __publicField(this, "length", 0);
19317 __publicField(this, "head", null);
19318 __publicField(this, "tail", null);
19319 }
19320 var _proto = DoubleLinkedList.prototype;
19321 _proto.get = function get(position) {
19322 if (position >= this.length) {
19323 throw new Error("Position outside of list range");
19324 }
19325 var current = this.head;
19326 for(var index2 = 0; index2 < position; index2++){
19327 current = (current == null ? void 0 : current.next) || null;
19328 }
19329 return current;
19330 };
19331 _proto.addNode = function addNode(n2) {
19332 var node2 = {
19333 value: n2,
19334 previous: null,
19335 next: null
19336 };
19337 n2.__ln = node2;
19338 if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
19339 var current = n2.previousSibling.__ln.next;
19340 node2.next = current;
19341 node2.previous = n2.previousSibling.__ln;
19342 n2.previousSibling.__ln.next = node2;
19343 if (current) {
19344 current.previous = node2;
19345 }
19346 } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
19347 var current1 = n2.nextSibling.__ln.previous;
19348 node2.previous = current1;
19349 node2.next = n2.nextSibling.__ln;
19350 n2.nextSibling.__ln.previous = node2;
19351 if (current1) {
19352 current1.next = node2;
19353 }
19354 } else {
19355 if (this.head) {
19356 this.head.previous = node2;
19357 }
19358 node2.next = this.head;
19359 this.head = node2;
19360 }
19361 if (node2.next === null) {
19362 this.tail = node2;
19363 }
19364 this.length++;
19365 };
19366 _proto.removeNode = function removeNode(n2) {
19367 var current = n2.__ln;
19368 if (!this.head) {
19369 return;
19370 }
19371 if (!current.previous) {
19372 this.head = current.next;
19373 if (this.head) {
19374 this.head.previous = null;
19375 } else {
19376 this.tail = null;
19377 }
19378 } else {
19379 current.previous.next = current.next;
19380 if (current.next) {
19381 current.next.previous = current.previous;
19382 } else {
19383 this.tail = current.previous;
19384 }
19385 }
19386 if (n2.__ln) {
19387 delete n2.__ln;
19388 }
19389 this.length--;
19390 };
19391 return DoubleLinkedList;
19392 }();
19393 var moveKey = function(id, parentId) {
19394 return id + "@" + parentId;
19395 };
19396 var MutationBuffer = /*#__PURE__*/ function() {
19397 function MutationBuffer() {
19398 var _this = this;
19399 __publicField(this, "frozen", false);
19400 __publicField(this, "locked", false);
19401 __publicField(this, "texts", []);
19402 __publicField(this, "attributes", []);
19403 __publicField(this, "attributeMap", /* @__PURE__ */ new WeakMap());
19404 __publicField(this, "removes", []);
19405 __publicField(this, "mapRemoves", []);
19406 __publicField(this, "movedMap", {});
19407 /**
19408 * the browser MutationObserver emits multiple mutations after
19409 * a delay for performance reasons, making tracing added nodes hard
19410 * in our `processMutations` callback function.
19411 * For example, if we append an element el_1 into body, and then append
19412 * another element el_2 into el_1, these two mutations may be passed to the
19413 * callback function together when the two operations were done.
19414 * Generally we need to trace child nodes of newly added nodes, but in this
19415 * case if we count el_2 as el_1's child node in the first mutation record,
19416 * then we will count el_2 again in the second mutation record which was
19417 * duplicated.
19418 * To avoid of duplicate counting added nodes, we use a Set to store
19419 * added nodes and its child nodes during iterate mutation records. Then
19420 * collect added nodes from the Set which have no duplicate copy. But
19421 * this also causes newly added nodes will not be serialized with id ASAP,
19422 * which means all the id related calculation should be lazy too.
19423 */ __publicField(this, "addedSet", /* @__PURE__ */ new Set());
19424 __publicField(this, "movedSet", /* @__PURE__ */ new Set());
19425 __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
19426 __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
19427 __publicField(this, "mutationCb");
19428 __publicField(this, "blockClass");
19429 __publicField(this, "blockSelector");
19430 __publicField(this, "maskTextClass");
19431 __publicField(this, "maskTextSelector");
19432 __publicField(this, "inlineStylesheet");
19433 __publicField(this, "maskInputOptions");
19434 __publicField(this, "maskTextFn");
19435 __publicField(this, "maskInputFn");
19436 __publicField(this, "keepIframeSrcFn");
19437 __publicField(this, "recordCanvas");
19438 __publicField(this, "inlineImages");
19439 __publicField(this, "slimDOMOptions");
19440 __publicField(this, "dataURLOptions");
19441 __publicField(this, "doc");
19442 __publicField(this, "mirror");
19443 __publicField(this, "iframeManager");
19444 __publicField(this, "stylesheetManager");
19445 __publicField(this, "shadowDomManager");
19446 __publicField(this, "canvasManager");
19447 __publicField(this, "processedNodeManager");
19448 __publicField(this, "unattachedDoc");
19449 __publicField(this, "processMutations", function(mutations) {
19450 mutations.forEach(_this.processMutation);
19451 _this.emit();
19452 });
19453 __publicField(this, "emit", function() {
19454 if (_this.frozen || _this.locked) {
19455 return;
19456 }
19457 var adds = [];
19458 var addedIds = /* @__PURE__ */ new Set();
19459 var addList = new DoubleLinkedList();
19460 var getNextId = function(n2) {
19461 var ns = n2;
19462 var nextId = IGNORED_NODE;
19463 while(nextId === IGNORED_NODE){
19464 ns = ns && ns.nextSibling;
19465 nextId = ns && _this.mirror.getId(ns);
19466 }
19467 return nextId;
19468 };
19469 var pushAdd = function(n2) {
19470 var parent = index.parentNode(n2);
19471 if (!parent || !inDom(n2)) {
19472 return;
19473 }
19474 var cssCaptured = false;
19475 if (n2.nodeType === Node.TEXT_NODE) {
19476 var parentTag = parent.tagName;
19477 if (parentTag === "TEXTAREA") {
19478 return;
19479 } else if (parentTag === "STYLE" && _this.addedSet.has(parent)) {
19480 cssCaptured = true;
19481 }
19482 }
19483 var parentId = isShadowRoot(parent) ? _this.mirror.getId(getShadowHost(n2)) : _this.mirror.getId(parent);
19484 var nextId = getNextId(n2);
19485 if (parentId === -1 || nextId === -1) {
19486 return addList.addNode(n2);
19487 }
19488 var sn = serializeNodeWithId(n2, {
19489 doc: _this.doc,
19490 mirror: _this.mirror,
19491 blockClass: _this.blockClass,
19492 blockSelector: _this.blockSelector,
19493 maskTextClass: _this.maskTextClass,
19494 maskTextSelector: _this.maskTextSelector,
19495 skipChild: true,
19496 newlyAddedElement: true,
19497 inlineStylesheet: _this.inlineStylesheet,
19498 maskInputOptions: _this.maskInputOptions,
19499 maskTextFn: _this.maskTextFn,
19500 maskInputFn: _this.maskInputFn,
19501 slimDOMOptions: _this.slimDOMOptions,
19502 dataURLOptions: _this.dataURLOptions,
19503 recordCanvas: _this.recordCanvas,
19504 inlineImages: _this.inlineImages,
19505 onSerialize: function(currentN) {
19506 if (isSerializedIframe(currentN, _this.mirror)) {
19507 _this.iframeManager.addIframe(currentN);
19508 }
19509 if (isSerializedStylesheet(currentN, _this.mirror)) {
19510 _this.stylesheetManager.trackLinkElement(currentN);
19511 }
19512 if (hasShadowRoot(n2)) {
19513 _this.shadowDomManager.addShadowRoot(index.shadowRoot(n2), _this.doc);
19514 }
19515 },
19516 onIframeLoad: function(iframe, childSn) {
19517 _this.iframeManager.attachIframe(iframe, childSn);
19518 _this.shadowDomManager.observeAttachShadow(iframe);
19519 },
19520 onStylesheetLoad: function(link, childSn) {
19521 _this.stylesheetManager.attachLinkElement(link, childSn);
19522 },
19523 cssCaptured: cssCaptured
19524 });
19525 if (sn) {
19526 adds.push({
19527 parentId: parentId,
19528 nextId: nextId,
19529 node: sn
19530 });
19531 addedIds.add(sn.id);
19532 }
19533 };
19534 while(_this.mapRemoves.length){
19535 _this.mirror.removeNodeFromMap(_this.mapRemoves.shift());
19536 }
19537 for(var _iterator = _create_for_of_iterator_helper_loose(_this.movedSet), _step; !(_step = _iterator()).done;){
19538 var n2 = _step.value;
19539 if (isParentRemoved(_this.removesSubTreeCache, n2, _this.mirror) && !_this.movedSet.has(index.parentNode(n2))) {
19540 continue;
19541 }
19542 pushAdd(n2);
19543 }
19544 for(var _iterator1 = _create_for_of_iterator_helper_loose(_this.addedSet), _step1; !(_step1 = _iterator1()).done;){
19545 var n21 = _step1.value;
19546 if (!isAncestorInSet(_this.droppedSet, n21) && !isParentRemoved(_this.removesSubTreeCache, n21, _this.mirror)) {
19547 pushAdd(n21);
19548 } else if (isAncestorInSet(_this.movedSet, n21)) {
19549 pushAdd(n21);
19550 } else {
19551 _this.droppedSet.add(n21);
19552 }
19553 }
19554 var candidate = null;
19555 while(addList.length){
19556 var node2 = null;
19557 if (candidate) {
19558 var parentId = _this.mirror.getId(index.parentNode(candidate.value));
19559 var nextId = getNextId(candidate.value);
19560 if (parentId !== -1 && nextId !== -1) {
19561 node2 = candidate;
19562 }
19563 }
19564 if (!node2) {
19565 var tailNode = addList.tail;
19566 while(tailNode){
19567 var _node = tailNode;
19568 tailNode = tailNode.previous;
19569 if (_node) {
19570 var parentId1 = _this.mirror.getId(index.parentNode(_node.value));
19571 var nextId1 = getNextId(_node.value);
19572 if (nextId1 === -1) continue;
19573 else if (parentId1 !== -1) {
19574 node2 = _node;
19575 break;
19576 } else {
19577 var unhandledNode = _node.value;
19578 var parent = index.parentNode(unhandledNode);
19579 if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
19580 var shadowHost = index.host(parent);
19581 var parentId2 = _this.mirror.getId(shadowHost);
19582 if (parentId2 !== -1) {
19583 node2 = _node;
19584 break;
19585 }
19586 }
19587 }
19588 }
19589 }
19590 }
19591 if (!node2) {
19592 while(addList.head){
19593 addList.removeNode(addList.head.value);
19594 }
19595 break;
19596 }
19597 candidate = node2.previous;
19598 addList.removeNode(node2.value);
19599 pushAdd(node2.value);
19600 }
19601 var payload = {
19602 texts: _this.texts.map(function(text) {
19603 var n2 = text.node;
19604 var parent = index.parentNode(n2);
19605 if (parent && parent.tagName === "TEXTAREA") {
19606 _this.genTextAreaValueMutation(parent);
19607 }
19608 return {
19609 id: _this.mirror.getId(n2),
19610 value: text.value
19611 };
19612 }).filter(function(text) {
19613 return !addedIds.has(text.id);
19614 }).filter(function(text) {
19615 return _this.mirror.has(text.id);
19616 }),
19617 attributes: _this.attributes.map(function(attribute) {
19618 var attributes = attribute.attributes;
19619 if (typeof attributes.style === "string") {
19620 var diffAsStr = JSON.stringify(attribute.styleDiff);
19621 var unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
19622 if (diffAsStr.length < attributes.style.length) {
19623 if ((diffAsStr + unchangedAsStr).split("var(").length === attributes.style.split("var(").length) {
19624 attributes.style = attribute.styleDiff;
19625 }
19626 }
19627 }
19628 return {
19629 id: _this.mirror.getId(attribute.node),
19630 attributes: attributes
19631 };
19632 }).filter(function(attribute) {
19633 return !addedIds.has(attribute.id);
19634 }).filter(function(attribute) {
19635 return _this.mirror.has(attribute.id);
19636 }),
19637 removes: _this.removes,
19638 adds: adds
19639 };
19640 if (!payload.texts.length && !payload.attributes.length && !payload.removes.length && !payload.adds.length) {
19641 return;
19642 }
19643 _this.texts = [];
19644 _this.attributes = [];
19645 _this.attributeMap = /* @__PURE__ */ new WeakMap();
19646 _this.removes = [];
19647 _this.addedSet = /* @__PURE__ */ new Set();
19648 _this.movedSet = /* @__PURE__ */ new Set();
19649 _this.droppedSet = /* @__PURE__ */ new Set();
19650 _this.removesSubTreeCache = /* @__PURE__ */ new Set();
19651 _this.movedMap = {};
19652 _this.mutationCb(payload);
19653 });
19654 __publicField(this, "genTextAreaValueMutation", function(textarea) {
19655 var item = _this.attributeMap.get(textarea);
19656 if (!item) {
19657 item = {
19658 node: textarea,
19659 attributes: {},
19660 styleDiff: {},
19661 _unchangedStyles: {}
19662 };
19663 _this.attributes.push(item);
19664 _this.attributeMap.set(textarea, item);
19665 }
19666 var value = Array.from(index.childNodes(textarea), function(cn) {
19667 return index.textContent(cn) || "";
19668 }).join("");
19669 item.attributes.value = maskInputValue({
19670 element: textarea,
19671 maskInputOptions: _this.maskInputOptions,
19672 tagName: textarea.tagName,
19673 type: getInputType(textarea),
19674 value: value,
19675 maskInputFn: _this.maskInputFn
19676 });
19677 });
19678 __publicField(this, "processMutation", function(m) {
19679 if (isIgnored(m.target, _this.mirror, _this.slimDOMOptions)) {
19680 return;
19681 }
19682 switch(m.type){
19683 case "characterData":
19684 {
19685 var value = index.textContent(m.target);
19686 if (!isBlocked(m.target, _this.blockClass, _this.blockSelector, false) && value !== m.oldValue) {
19687 _this.texts.push({
19688 value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, true) && value ? _this.maskTextFn ? _this.maskTextFn(value, closestElementOfNode(m.target)) : value.replace(/[\S]/g, "*") : value,
19689 node: m.target
19690 });
19691 }
19692 break;
19693 }
19694 case "attributes":
19695 {
19696 var target = m.target;
19697 var attributeName = m.attributeName;
19698 var value1 = m.target.getAttribute(attributeName);
19699 if (attributeName === "value") {
19700 var type = getInputType(target);
19701 value1 = maskInputValue({
19702 element: target,
19703 maskInputOptions: _this.maskInputOptions,
19704 tagName: target.tagName,
19705 type: type,
19706 value: value1,
19707 maskInputFn: _this.maskInputFn
19708 });
19709 }
19710 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || value1 === m.oldValue) {
19711 return;
19712 }
19713 var item = _this.attributeMap.get(m.target);
19714 if (target.tagName === "IFRAME" && attributeName === "src" && !_this.keepIframeSrcFn(value1)) {
19715 if (!target.contentDocument) {
19716 attributeName = "rr_src";
19717 } else {
19718 return;
19719 }
19720 }
19721 if (!item) {
19722 item = {
19723 node: m.target,
19724 attributes: {},
19725 styleDiff: {},
19726 _unchangedStyles: {}
19727 };
19728 _this.attributes.push(item);
19729 _this.attributeMap.set(m.target, item);
19730 }
19731 if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
19732 target.setAttribute("data-rr-is-password", "true");
19733 }
19734 if (!ignoreAttribute(target.tagName, attributeName)) {
19735 item.attributes[attributeName] = transformAttribute(_this.doc, toLowerCase(target.tagName), toLowerCase(attributeName), value1);
19736 if (attributeName === "style") {
19737 if (!_this.unattachedDoc) {
19738 try {
19739 _this.unattachedDoc = document.implementation.createHTMLDocument();
19740 } catch (e2) {
19741 _this.unattachedDoc = _this.doc;
19742 }
19743 }
19744 var old = _this.unattachedDoc.createElement("span");
19745 if (m.oldValue) {
19746 old.setAttribute("style", m.oldValue);
19747 }
19748 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(target.style)), _step; !(_step = _iterator()).done;){
19749 var pname = _step.value;
19750 var newValue = target.style.getPropertyValue(pname);
19751 var newPriority = target.style.getPropertyPriority(pname);
19752 if (newValue !== old.style.getPropertyValue(pname) || newPriority !== old.style.getPropertyPriority(pname)) {
19753 if (newPriority === "") {
19754 item.styleDiff[pname] = newValue;
19755 } else {
19756 item.styleDiff[pname] = [
19757 newValue,
19758 newPriority
19759 ];
19760 }
19761 } else {
19762 item._unchangedStyles[pname] = [
19763 newValue,
19764 newPriority
19765 ];
19766 }
19767 }
19768 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(old.style)), _step1; !(_step1 = _iterator1()).done;){
19769 var pname1 = _step1.value;
19770 if (target.style.getPropertyValue(pname1) === "") {
19771 item.styleDiff[pname1] = false;
19772 }
19773 }
19774 } else if (attributeName === "open" && target.tagName === "DIALOG") {
19775 if (target.matches("dialog:modal")) {
19776 item.attributes["rr_open_mode"] = "modal";
19777 } else {
19778 item.attributes["rr_open_mode"] = "non-modal";
19779 }
19780 }
19781 }
19782 break;
19783 }
19784 case "childList":
19785 {
19786 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, true)) return;
19787 if (m.target.tagName === "TEXTAREA") {
19788 _this.genTextAreaValueMutation(m.target);
19789 return;
19790 }
19791 m.addedNodes.forEach(function(n2) {
19792 return _this.genAdds(n2, m.target);
19793 });
19794 m.removedNodes.forEach(function(n2) {
19795 var nodeId = _this.mirror.getId(n2);
19796 var parentId = isShadowRoot(m.target) ? _this.mirror.getId(index.host(m.target)) : _this.mirror.getId(m.target);
19797 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || isIgnored(n2, _this.mirror, _this.slimDOMOptions) || !isSerialized(n2, _this.mirror)) {
19798 return;
19799 }
19800 if (_this.addedSet.has(n2)) {
19801 deepDelete(_this.addedSet, n2);
19802 _this.droppedSet.add(n2);
19803 } else if (_this.addedSet.has(m.target) && nodeId === -1) ;
19804 else if (isAncestorRemoved(m.target, _this.mirror)) ;
19805 else if (_this.movedSet.has(n2) && _this.movedMap[moveKey(nodeId, parentId)]) {
19806 deepDelete(_this.movedSet, n2);
19807 } else {
19808 _this.removes.push({
19809 parentId: parentId,
19810 id: nodeId,
19811 isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
19812 });
19813 processRemoves(n2, _this.removesSubTreeCache);
19814 }
19815 _this.mapRemoves.push(n2);
19816 });
19817 break;
19818 }
19819 }
19820 });
19821 /**
19822 * Make sure you check if `n`'s parent is blocked before calling this function
19823 * */ __publicField(this, "genAdds", function(n2, target) {
19824 if (_this.processedNodeManager.inOtherBuffer(n2, _this)) return;
19825 if (_this.addedSet.has(n2) || _this.movedSet.has(n2)) return;
19826 if (_this.mirror.hasNode(n2)) {
19827 if (isIgnored(n2, _this.mirror, _this.slimDOMOptions)) {
19828 return;
19829 }
19830 _this.movedSet.add(n2);
19831 var targetId = null;
19832 if (target && _this.mirror.hasNode(target)) {
19833 targetId = _this.mirror.getId(target);
19834 }
19835 if (targetId && targetId !== -1) {
19836 _this.movedMap[moveKey(_this.mirror.getId(n2), targetId)] = true;
19837 }
19838 } else {
19839 _this.addedSet.add(n2);
19840 _this.droppedSet.delete(n2);
19841 }
19842 if (!isBlocked(n2, _this.blockClass, _this.blockSelector, false)) {
19843 index.childNodes(n2).forEach(function(childN) {
19844 return _this.genAdds(childN);
19845 });
19846 if (hasShadowRoot(n2)) {
19847 index.childNodes(index.shadowRoot(n2)).forEach(function(childN) {
19848 _this.processedNodeManager.add(childN, _this);
19849 _this.genAdds(childN, n2);
19850 });
19851 }
19852 }
19853 });
19854 }
19855 var _proto = MutationBuffer.prototype;
19856 _proto.init = function init(options) {
19857 var _this = this;
19858 [
19859 "mutationCb",
19860 "blockClass",
19861 "blockSelector",
19862 "maskTextClass",
19863 "maskTextSelector",
19864 "inlineStylesheet",
19865 "maskInputOptions",
19866 "maskTextFn",
19867 "maskInputFn",
19868 "keepIframeSrcFn",
19869 "recordCanvas",
19870 "inlineImages",
19871 "slimDOMOptions",
19872 "dataURLOptions",
19873 "doc",
19874 "mirror",
19875 "iframeManager",
19876 "stylesheetManager",
19877 "shadowDomManager",
19878 "canvasManager",
19879 "processedNodeManager"
19880 ].forEach(function(key) {
19881 _this[key] = options[key];
19882 });
19883 };
19884 _proto.freeze = function freeze() {
19885 this.frozen = true;
19886 this.canvasManager.freeze();
19887 };
19888 _proto.unfreeze = function unfreeze() {
19889 this.frozen = false;
19890 this.canvasManager.unfreeze();
19891 this.emit();
19892 };
19893 _proto.isFrozen = function isFrozen() {
19894 return this.frozen;
19895 };
19896 _proto.lock = function lock() {
19897 this.locked = true;
19898 this.canvasManager.lock();
19899 };
19900 _proto.unlock = function unlock() {
19901 this.locked = false;
19902 this.canvasManager.unlock();
19903 this.emit();
19904 };
19905 _proto.reset = function reset() {
19906 this.shadowDomManager.reset();
19907 this.canvasManager.reset();
19908 };
19909 return MutationBuffer;
19910 }();
19911 function deepDelete(addsSet, n2) {
19912 addsSet.delete(n2);
19913 index.childNodes(n2).forEach(function(childN) {
19914 return deepDelete(addsSet, childN);
19915 });
19916 }
19917 function processRemoves(n2, cache) {
19918 var queue = [
19919 n2
19920 ];
19921 while(queue.length){
19922 var next = queue.pop();
19923 if (cache.has(next)) continue;
19924 cache.add(next);
19925 index.childNodes(next).forEach(function(n22) {
19926 return queue.push(n22);
19927 });
19928 }
19929 return;
19930 }
19931 function isParentRemoved(removes, n2, mirror2) {
19932 if (removes.size === 0) return false;
19933 return _isParentRemoved(removes, n2);
19934 }
19935 function _isParentRemoved(removes, n2, _mirror2) {
19936 var node2 = index.parentNode(n2);
19937 if (!node2) return false;
19938 return removes.has(node2);
19939 }
19940 function isAncestorInSet(set, n2) {
19941 if (set.size === 0) return false;
19942 return _isAncestorInSet(set, n2);
19943 }
19944 function _isAncestorInSet(set, n2) {
19945 var parent = index.parentNode(n2);
19946 if (!parent) {
19947 return false;
19948 }
19949 if (set.has(parent)) {
19950 return true;
19951 }
19952 return _isAncestorInSet(set, parent);
19953 }
19954 var errorHandler;
19955 function registerErrorHandler(handler) {
19956 errorHandler = handler;
19957 }
19958 function unregisterErrorHandler() {
19959 errorHandler = void 0;
19960 }
19961 var callbackWrapper = function(cb) {
19962 if (!errorHandler) {
19963 return cb;
19964 }
19965 var rrwebWrapped = function() {
19966 for(var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++){
19967 rest[_key] = arguments[_key];
19968 }
19969 try {
19970 return cb.apply(void 0, [].concat(rest));
19971 } catch (error) {
19972 if (errorHandler && errorHandler(error) === true) {
19973 return;
19974 }
19975 throw error;
19976 }
19977 };
19978 return rrwebWrapped;
19979 };
19980 var mutationBuffers = [];
19981 function getEventTarget(event) {
19982 try {
19983 if ("composedPath" in event) {
19984 var path = event.composedPath();
19985 if (path.length) {
19986 return path[0];
19987 }
19988 } else if ("path" in event && event.path.length) {
19989 return event.path[0];
19990 }
19991 } catch (e) {}
19992 return event && event.target;
19993 }
19994 function initMutationObserver(options, rootEl) {
19995 var mutationBuffer = new MutationBuffer();
19996 mutationBuffers.push(mutationBuffer);
19997 mutationBuffer.init(options);
19998 var observer = new (mutationObserverCtor())(callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer)));
19999 observer.observe(rootEl, {
20000 attributes: true,
20001 attributeOldValue: true,
20002 characterData: true,
20003 characterDataOldValue: true,
20004 childList: true,
20005 subtree: true
20006 });
20007 return observer;
20008 }
20009 function initMoveObserver(param) {
20010 var mousemoveCb = param.mousemoveCb, sampling = param.sampling, doc = param.doc, mirror2 = param.mirror;
20011 if (sampling.mousemove === false) {
20012 return function() {};
20013 }
20014 var threshold = typeof sampling.mousemove === "number" ? sampling.mousemove : 50;
20015 var callbackThreshold = typeof sampling.mousemoveCallback === "number" ? sampling.mousemoveCallback : 500;
20016 var positions = [];
20017 var timeBaseline;
20018 var wrappedCb = throttle(callbackWrapper(function(source) {
20019 var totalOffset = Date.now() - timeBaseline;
20020 mousemoveCb(positions.map(function(p) {
20021 p.timeOffset -= totalOffset;
20022 return p;
20023 }), source);
20024 positions = [];
20025 timeBaseline = null;
20026 }), callbackThreshold);
20027 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
20028 var target = getEventTarget(evt);
20029 var _ref = legacy_isTouchEvent(evt) ? evt.changedTouches[0] : evt, clientX = _ref.clientX, clientY = _ref.clientY;
20030 if (!timeBaseline) {
20031 timeBaseline = nowTimestamp();
20032 }
20033 positions.push({
20034 x: clientX,
20035 y: clientY,
20036 id: mirror2.getId(target),
20037 timeOffset: nowTimestamp() - timeBaseline
20038 });
20039 wrappedCb(typeof DragEvent !== "undefined" && _instanceof(evt, DragEvent) ? IncrementalSource.Drag : _instanceof(evt, MouseEvent) ? IncrementalSource.MouseMove : IncrementalSource.TouchMove);
20040 }), threshold, {
20041 trailing: false
20042 }));
20043 var handlers = [
20044 on("mousemove", updatePosition, doc),
20045 on("touchmove", updatePosition, doc),
20046 on("drag", updatePosition, doc)
20047 ];
20048 return callbackWrapper(function() {
20049 handlers.forEach(function(h) {
20050 return h();
20051 });
20052 });
20053 }
20054 function initMouseInteractionObserver(param) {
20055 var mouseInteractionCb = param.mouseInteractionCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
20056 if (sampling.mouseInteraction === false) {
20057 return function() {};
20058 }
20059 var disableMap = sampling.mouseInteraction === true || sampling.mouseInteraction === void 0 ? {} : sampling.mouseInteraction;
20060 var handlers = [];
20061 var currentPointerType = null;
20062 var getHandler = function(eventKey) {
20063 return function(event) {
20064 var target = getEventTarget(event);
20065 if (isBlocked(target, blockClass, blockSelector, true)) {
20066 return;
20067 }
20068 var pointerType = null;
20069 var thisEventKey = eventKey;
20070 if ("pointerType" in event) {
20071 switch(event.pointerType){
20072 case "mouse":
20073 pointerType = PointerTypes.Mouse;
20074 break;
20075 case "touch":
20076 pointerType = PointerTypes.Touch;
20077 break;
20078 case "pen":
20079 pointerType = PointerTypes.Pen;
20080 break;
20081 }
20082 if (pointerType === PointerTypes.Touch) {
20083 if (MouseInteractions[eventKey] === MouseInteractions.MouseDown) {
20084 thisEventKey = "TouchStart";
20085 } else if (MouseInteractions[eventKey] === MouseInteractions.MouseUp) {
20086 thisEventKey = "TouchEnd";
20087 }
20088 } else if (pointerType === PointerTypes.Pen) ;
20089 } else if (legacy_isTouchEvent(event)) {
20090 pointerType = PointerTypes.Touch;
20091 }
20092 if (pointerType !== null) {
20093 currentPointerType = pointerType;
20094 if (thisEventKey.startsWith("Touch") && pointerType === PointerTypes.Touch || thisEventKey.startsWith("Mouse") && pointerType === PointerTypes.Mouse) {
20095 pointerType = null;
20096 }
20097 } else if (MouseInteractions[eventKey] === MouseInteractions.Click) {
20098 pointerType = currentPointerType;
20099 currentPointerType = null;
20100 }
20101 var e2 = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
20102 if (!e2) {
20103 return;
20104 }
20105 var id = mirror2.getId(target);
20106 var clientX = e2.clientX, clientY = e2.clientY;
20107 callbackWrapper(mouseInteractionCb)(_extends({
20108 type: MouseInteractions[thisEventKey],
20109 id: id,
20110 x: clientX,
20111 y: clientY
20112 }, pointerType !== null && {
20113 pointerType: pointerType
20114 }));
20115 };
20116 };
20117 Object.keys(MouseInteractions).filter(function(key) {
20118 return Number.isNaN(Number(key)) && !key.endsWith("_Departed") && disableMap[key] !== false;
20119 }).forEach(function(eventKey) {
20120 var eventName = toLowerCase(eventKey);
20121 var handler = getHandler(eventKey);
20122 if (window.PointerEvent) {
20123 switch(MouseInteractions[eventKey]){
20124 case MouseInteractions.MouseDown:
20125 case MouseInteractions.MouseUp:
20126 eventName = eventName.replace("mouse", "pointer");
20127 break;
20128 case MouseInteractions.TouchStart:
20129 case MouseInteractions.TouchEnd:
20130 return;
20131 }
20132 }
20133 handlers.push(on(eventName, handler, doc));
20134 });
20135 return callbackWrapper(function() {
20136 handlers.forEach(function(h) {
20137 return h();
20138 });
20139 });
20140 }
20141 function initScrollObserver(param) {
20142 var scrollCb = param.scrollCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
20143 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
20144 var target = getEventTarget(evt);
20145 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20146 return;
20147 }
20148 var id = mirror2.getId(target);
20149 if (target === doc && doc.defaultView) {
20150 var scrollLeftTop = getWindowScroll(doc.defaultView);
20151 scrollCb({
20152 id: id,
20153 x: scrollLeftTop.left,
20154 y: scrollLeftTop.top
20155 });
20156 } else {
20157 scrollCb({
20158 id: id,
20159 x: target.scrollLeft,
20160 y: target.scrollTop
20161 });
20162 }
20163 }), sampling.scroll || 100));
20164 return on("scroll", updatePosition, doc);
20165 }
20166 function initViewportResizeObserver(param, param1) {
20167 var viewportResizeCb = param.viewportResizeCb;
20168 var win = param1.win;
20169 var lastH = -1;
20170 var lastW = -1;
20171 var updateDimension = callbackWrapper(throttle(callbackWrapper(function() {
20172 var height = getWindowHeight();
20173 var width = getWindowWidth();
20174 if (lastH !== height || lastW !== width) {
20175 viewportResizeCb({
20176 width: Number(width),
20177 height: Number(height)
20178 });
20179 lastH = height;
20180 lastW = width;
20181 }
20182 }), 200));
20183 return on("resize", updateDimension, win);
20184 }
20185 var INPUT_TAGS = [
20186 "INPUT",
20187 "TEXTAREA",
20188 "SELECT"
20189 ];
20190 var lastInputValueMap = /* @__PURE__ */ new WeakMap();
20191 function initInputObserver(param) {
20192 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;
20193 function eventHandler(event) {
20194 var target = getEventTarget(event);
20195 var userTriggered = event.isTrusted;
20196 var tagName = target && target.tagName;
20197 if (target && tagName === "OPTION") {
20198 target = index.parentElement(target);
20199 }
20200 if (!target || !tagName || INPUT_TAGS.indexOf(tagName) < 0 || isBlocked(target, blockClass, blockSelector, true)) {
20201 return;
20202 }
20203 if (target.classList.contains(ignoreClass) || ignoreSelector && target.matches(ignoreSelector)) {
20204 return;
20205 }
20206 var text = target.value;
20207 var isChecked = false;
20208 var type = getInputType(target) || "";
20209 if (type === "radio" || type === "checkbox") {
20210 isChecked = target.checked;
20211 } else if (maskInputOptions[tagName.toLowerCase()] || maskInputOptions[type]) {
20212 text = maskInputValue({
20213 element: target,
20214 maskInputOptions: maskInputOptions,
20215 tagName: tagName,
20216 type: type,
20217 value: text,
20218 maskInputFn: maskInputFn
20219 });
20220 }
20221 cbWithDedup(target, userTriggeredOnInput ? {
20222 text: text,
20223 isChecked: isChecked,
20224 userTriggered: userTriggered
20225 } : {
20226 text: text,
20227 isChecked: isChecked
20228 });
20229 var name = target.name;
20230 if (type === "radio" && name && isChecked) {
20231 doc.querySelectorAll('input[type="radio"][name="' + name + '"]').forEach(function(el) {
20232 if (el !== target) {
20233 var text2 = el.value;
20234 cbWithDedup(el, userTriggeredOnInput ? {
20235 text: text2,
20236 isChecked: !isChecked,
20237 userTriggered: false
20238 } : {
20239 text: text2,
20240 isChecked: !isChecked
20241 });
20242 }
20243 });
20244 }
20245 }
20246 function cbWithDedup(target, v2) {
20247 var lastInputValue = lastInputValueMap.get(target);
20248 if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
20249 lastInputValueMap.set(target, v2);
20250 var id = mirror2.getId(target);
20251 callbackWrapper(inputCb)(_extends({}, v2, {
20252 id: id
20253 }));
20254 }
20255 }
20256 var events = sampling.input === "last" ? [
20257 "change"
20258 ] : [
20259 "input",
20260 "change"
20261 ];
20262 var handlers = events.map(function(eventName) {
20263 return on(eventName, callbackWrapper(eventHandler), doc);
20264 });
20265 var currentWindow = doc.defaultView;
20266 if (!currentWindow) {
20267 return function() {
20268 handlers.forEach(function(h) {
20269 return h();
20270 });
20271 };
20272 }
20273 var propertyDescriptor = currentWindow.Object.getOwnPropertyDescriptor(currentWindow.HTMLInputElement.prototype, "value");
20274 var hookProperties = [
20275 [
20276 currentWindow.HTMLInputElement.prototype,
20277 "value"
20278 ],
20279 [
20280 currentWindow.HTMLInputElement.prototype,
20281 "checked"
20282 ],
20283 [
20284 currentWindow.HTMLSelectElement.prototype,
20285 "value"
20286 ],
20287 [
20288 currentWindow.HTMLTextAreaElement.prototype,
20289 "value"
20290 ],
20291 // Some UI library use selectedIndex to set select value
20292 [
20293 currentWindow.HTMLSelectElement.prototype,
20294 "selectedIndex"
20295 ],
20296 [
20297 currentWindow.HTMLOptionElement.prototype,
20298 "selected"
20299 ]
20300 ];
20301 if (propertyDescriptor && propertyDescriptor.set) {
20302 var _handlers;
20303 (_handlers = handlers).push.apply(_handlers, [].concat(hookProperties.map(function(p) {
20304 return hookSetter(p[0], p[1], {
20305 set: function set() {
20306 callbackWrapper(eventHandler)({
20307 target: this,
20308 isTrusted: false
20309 });
20310 }
20311 }, false, currentWindow);
20312 })));
20313 }
20314 return callbackWrapper(function() {
20315 handlers.forEach(function(h) {
20316 return h();
20317 });
20318 });
20319 }
20320 function getNestedCSSRulePositions(rule2) {
20321 var positions = [];
20322 function recurse(childRule, pos) {
20323 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)) {
20324 var rules2 = Array.from(childRule.parentRule.cssRules);
20325 var index2 = rules2.indexOf(childRule);
20326 pos.unshift(index2);
20327 } else if (childRule.parentStyleSheet) {
20328 var rules21 = Array.from(childRule.parentStyleSheet.cssRules);
20329 var index21 = rules21.indexOf(childRule);
20330 pos.unshift(index21);
20331 }
20332 return pos;
20333 }
20334 return recurse(rule2, positions);
20335 }
20336 function getIdAndStyleId(sheet, mirror2, styleMirror) {
20337 var id, styleId;
20338 if (!sheet) return {};
20339 if (sheet.ownerNode) id = mirror2.getId(sheet.ownerNode);
20340 else styleId = styleMirror.getId(sheet);
20341 return {
20342 styleId: styleId,
20343 id: id
20344 };
20345 }
20346 function initStyleSheetObserver(param, param1) {
20347 var styleSheetRuleCb = param.styleSheetRuleCb, mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
20348 var win = param1.win;
20349 if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
20350 return function() {};
20351 }
20352 var insertRule = win.CSSStyleSheet.prototype.insertRule;
20353 win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
20354 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20355 var rule2 = argumentsList[0], index2 = argumentsList[1];
20356 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20357 if (id && id !== -1 || styleId && styleId !== -1) {
20358 styleSheetRuleCb({
20359 id: id,
20360 styleId: styleId,
20361 adds: [
20362 {
20363 rule: rule2,
20364 index: index2
20365 }
20366 ]
20367 });
20368 }
20369 return target.apply(thisArg, argumentsList);
20370 })
20371 });
20372 win.CSSStyleSheet.prototype.addRule = function(selector, styleBlock, index2) {
20373 if (index2 === void 0) index2 = this.cssRules.length;
20374 var rule2 = selector + " { " + styleBlock + " }";
20375 return win.CSSStyleSheet.prototype.insertRule.apply(this, [
20376 rule2,
20377 index2
20378 ]);
20379 };
20380 var deleteRule = win.CSSStyleSheet.prototype.deleteRule;
20381 win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
20382 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20383 var index2 = argumentsList[0];
20384 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20385 if (id && id !== -1 || styleId && styleId !== -1) {
20386 styleSheetRuleCb({
20387 id: id,
20388 styleId: styleId,
20389 removes: [
20390 {
20391 index: index2
20392 }
20393 ]
20394 });
20395 }
20396 return target.apply(thisArg, argumentsList);
20397 })
20398 });
20399 win.CSSStyleSheet.prototype.removeRule = function(index2) {
20400 return win.CSSStyleSheet.prototype.deleteRule.apply(this, [
20401 index2
20402 ]);
20403 };
20404 var replace;
20405 if (win.CSSStyleSheet.prototype.replace) {
20406 replace = win.CSSStyleSheet.prototype.replace;
20407 win.CSSStyleSheet.prototype.replace = new Proxy(replace, {
20408 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20409 var text = argumentsList[0];
20410 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20411 if (id && id !== -1 || styleId && styleId !== -1) {
20412 styleSheetRuleCb({
20413 id: id,
20414 styleId: styleId,
20415 replace: text
20416 });
20417 }
20418 return target.apply(thisArg, argumentsList);
20419 })
20420 });
20421 }
20422 var replaceSync;
20423 if (win.CSSStyleSheet.prototype.replaceSync) {
20424 replaceSync = win.CSSStyleSheet.prototype.replaceSync;
20425 win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {
20426 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20427 var text = argumentsList[0];
20428 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20429 if (id && id !== -1 || styleId && styleId !== -1) {
20430 styleSheetRuleCb({
20431 id: id,
20432 styleId: styleId,
20433 replaceSync: text
20434 });
20435 }
20436 return target.apply(thisArg, argumentsList);
20437 })
20438 });
20439 }
20440 var supportedNestedCSSRuleTypes = {};
20441 if (canMonkeyPatchNestedCSSRule("CSSGroupingRule")) {
20442 supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
20443 } else {
20444 if (canMonkeyPatchNestedCSSRule("CSSMediaRule")) {
20445 supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
20446 }
20447 if (canMonkeyPatchNestedCSSRule("CSSConditionRule")) {
20448 supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
20449 }
20450 if (canMonkeyPatchNestedCSSRule("CSSSupportsRule")) {
20451 supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
20452 }
20453 }
20454 var unmodifiedFunctions = {};
20455 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
20456 var typeKey = param[0], type = param[1];
20457 unmodifiedFunctions[typeKey] = {
20458 // eslint-disable-next-line @typescript-eslint/unbound-method
20459 insertRule: type.prototype.insertRule,
20460 // eslint-disable-next-line @typescript-eslint/unbound-method
20461 deleteRule: type.prototype.deleteRule
20462 };
20463 type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
20464 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20465 var rule2 = argumentsList[0], index2 = argumentsList[1];
20466 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20467 if (id && id !== -1 || styleId && styleId !== -1) {
20468 styleSheetRuleCb({
20469 id: id,
20470 styleId: styleId,
20471 adds: [
20472 {
20473 rule: rule2,
20474 index: [].concat(getNestedCSSRulePositions(thisArg), [
20475 index2 || 0
20476 ])
20477 }
20478 ]
20479 });
20480 }
20481 return target.apply(thisArg, argumentsList);
20482 })
20483 });
20484 type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
20485 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20486 var index2 = argumentsList[0];
20487 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20488 if (id && id !== -1 || styleId && styleId !== -1) {
20489 styleSheetRuleCb({
20490 id: id,
20491 styleId: styleId,
20492 removes: [
20493 {
20494 index: [].concat(getNestedCSSRulePositions(thisArg), [
20495 index2
20496 ])
20497 }
20498 ]
20499 });
20500 }
20501 return target.apply(thisArg, argumentsList);
20502 })
20503 });
20504 });
20505 return callbackWrapper(function() {
20506 win.CSSStyleSheet.prototype.insertRule = insertRule;
20507 win.CSSStyleSheet.prototype.deleteRule = deleteRule;
20508 replace && (win.CSSStyleSheet.prototype.replace = replace);
20509 replaceSync && (win.CSSStyleSheet.prototype.replaceSync = replaceSync);
20510 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
20511 var typeKey = param[0], type = param[1];
20512 type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
20513 type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
20514 });
20515 });
20516 }
20517 function initAdoptedStyleSheetObserver(param, host2) {
20518 var mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
20519 var _a2, _b, _c;
20520 var hostId = null;
20521 if (host2.nodeName === "#document") hostId = mirror2.getId(host2);
20522 else hostId = mirror2.getId(index.host(host2));
20523 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;
20524 var originalPropertyDescriptor = (patchTarget == null ? void 0 : patchTarget.prototype) ? Object.getOwnPropertyDescriptor(patchTarget == null ? void 0 : patchTarget.prototype, "adoptedStyleSheets") : void 0;
20525 if (hostId === null || hostId === -1 || !patchTarget || !originalPropertyDescriptor) return function() {};
20526 Object.defineProperty(host2, "adoptedStyleSheets", {
20527 configurable: originalPropertyDescriptor.configurable,
20528 enumerable: originalPropertyDescriptor.enumerable,
20529 get: function get() {
20530 var _a3;
20531 return (_a3 = originalPropertyDescriptor.get) == null ? void 0 : _a3.call(this);
20532 },
20533 set: function set(sheets) {
20534 var _a3;
20535 var result2 = (_a3 = originalPropertyDescriptor.set) == null ? void 0 : _a3.call(this, sheets);
20536 if (hostId !== null && hostId !== -1) {
20537 try {
20538 stylesheetManager.adoptStyleSheets(sheets, hostId);
20539 } catch (e2) {}
20540 }
20541 return result2;
20542 }
20543 });
20544 return callbackWrapper(function() {
20545 Object.defineProperty(host2, "adoptedStyleSheets", {
20546 configurable: originalPropertyDescriptor.configurable,
20547 enumerable: originalPropertyDescriptor.enumerable,
20548 // eslint-disable-next-line @typescript-eslint/unbound-method
20549 get: originalPropertyDescriptor.get,
20550 // eslint-disable-next-line @typescript-eslint/unbound-method
20551 set: originalPropertyDescriptor.set
20552 });
20553 });
20554 }
20555 function initStyleDeclarationObserver(param, param1) {
20556 var styleDeclarationCb = param.styleDeclarationCb, mirror2 = param.mirror, ignoreCSSAttributes = param.ignoreCSSAttributes, stylesheetManager = param.stylesheetManager;
20557 var win = param1.win;
20558 var setProperty = win.CSSStyleDeclaration.prototype.setProperty;
20559 win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
20560 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20561 var _a2;
20562 var property = argumentsList[0], value = argumentsList[1], priority = argumentsList[2];
20563 if (ignoreCSSAttributes.has(property)) {
20564 return setProperty.apply(thisArg, [
20565 property,
20566 value,
20567 priority
20568 ]);
20569 }
20570 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20571 if (id && id !== -1 || styleId && styleId !== -1) {
20572 styleDeclarationCb({
20573 id: id,
20574 styleId: styleId,
20575 set: {
20576 property: property,
20577 value: value,
20578 priority: priority
20579 },
20580 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20581 index: getNestedCSSRulePositions(thisArg.parentRule)
20582 });
20583 }
20584 return target.apply(thisArg, argumentsList);
20585 })
20586 });
20587 var removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
20588 win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
20589 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20590 var _a2;
20591 var property = argumentsList[0];
20592 if (ignoreCSSAttributes.has(property)) {
20593 return removeProperty.apply(thisArg, [
20594 property
20595 ]);
20596 }
20597 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20598 if (id && id !== -1 || styleId && styleId !== -1) {
20599 styleDeclarationCb({
20600 id: id,
20601 styleId: styleId,
20602 remove: {
20603 property: property
20604 },
20605 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20606 index: getNestedCSSRulePositions(thisArg.parentRule)
20607 });
20608 }
20609 return target.apply(thisArg, argumentsList);
20610 })
20611 });
20612 return callbackWrapper(function() {
20613 win.CSSStyleDeclaration.prototype.setProperty = setProperty;
20614 win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
20615 });
20616 }
20617 function initMediaInteractionObserver(param) {
20618 var mediaInteractionCb = param.mediaInteractionCb, blockClass = param.blockClass, blockSelector = param.blockSelector, mirror2 = param.mirror, sampling = param.sampling, doc = param.doc;
20619 var handler = callbackWrapper(function(type) {
20620 return throttle(callbackWrapper(function(event) {
20621 var target = getEventTarget(event);
20622 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20623 return;
20624 }
20625 var currentTime = target.currentTime, volume = target.volume, muted = target.muted, playbackRate = target.playbackRate, loop = target.loop;
20626 mediaInteractionCb({
20627 type: type,
20628 id: mirror2.getId(target),
20629 currentTime: currentTime,
20630 volume: volume,
20631 muted: muted,
20632 playbackRate: playbackRate,
20633 loop: loop
20634 });
20635 }), sampling.media || 500);
20636 });
20637 var handlers = [
20638 on("play", handler(MediaInteractions.Play), doc),
20639 on("pause", handler(MediaInteractions.Pause), doc),
20640 on("seeked", handler(MediaInteractions.Seeked), doc),
20641 on("volumechange", handler(MediaInteractions.VolumeChange), doc),
20642 on("ratechange", handler(MediaInteractions.RateChange), doc)
20643 ];
20644 return callbackWrapper(function() {
20645 handlers.forEach(function(h) {
20646 return h();
20647 });
20648 });
20649 }
20650 function initFontObserver(param) {
20651 var fontCb = param.fontCb, doc = param.doc;
20652 var win = doc.defaultView;
20653 if (!win) {
20654 return function() {};
20655 }
20656 var handlers = [];
20657 var fontMap = /* @__PURE__ */ new WeakMap();
20658 var originalFontFace = win.FontFace;
20659 win.FontFace = function FontFace2(family, source, descriptors) {
20660 var fontFace = new originalFontFace(family, source, descriptors);
20661 fontMap.set(fontFace, {
20662 family: family,
20663 buffer: typeof source !== "string",
20664 descriptors: descriptors,
20665 fontSource: typeof source === "string" ? source : JSON.stringify(Array.from(new Uint8Array(source)))
20666 });
20667 return fontFace;
20668 };
20669 var restoreHandler = patch(doc.fonts, "add", function(original) {
20670 return function(fontFace) {
20671 setTimeout(callbackWrapper(function() {
20672 var p = fontMap.get(fontFace);
20673 if (p) {
20674 fontCb(p);
20675 fontMap.delete(fontFace);
20676 }
20677 }), 0);
20678 return original.apply(this, [
20679 fontFace
20680 ]);
20681 };
20682 });
20683 handlers.push(function() {
20684 win.FontFace = originalFontFace;
20685 });
20686 handlers.push(restoreHandler);
20687 return callbackWrapper(function() {
20688 handlers.forEach(function(h) {
20689 return h();
20690 });
20691 });
20692 }
20693 function initSelectionObserver(param) {
20694 var doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, selectionCb = param.selectionCb;
20695 var collapsed = true;
20696 var updateSelection = callbackWrapper(function() {
20697 var selection = doc.getSelection();
20698 if (!selection || collapsed && (selection == null ? void 0 : selection.isCollapsed)) return;
20699 collapsed = selection.isCollapsed || false;
20700 var ranges = [];
20701 var count = selection.rangeCount || 0;
20702 for(var i2 = 0; i2 < count; i2++){
20703 var range = selection.getRangeAt(i2);
20704 var startContainer = range.startContainer, startOffset = range.startOffset, endContainer = range.endContainer, endOffset = range.endOffset;
20705 var blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
20706 if (blocked) continue;
20707 ranges.push({
20708 start: mirror2.getId(startContainer),
20709 startOffset: startOffset,
20710 end: mirror2.getId(endContainer),
20711 endOffset: endOffset
20712 });
20713 }
20714 selectionCb({
20715 ranges: ranges
20716 });
20717 });
20718 updateSelection();
20719 return on("selectionchange", updateSelection);
20720 }
20721 function initCustomElementObserver(param) {
20722 var doc = param.doc, customElementCb = param.customElementCb;
20723 var win = doc.defaultView;
20724 if (!win || !win.customElements) return function() {};
20725 var restoreHandler = patch(win.customElements, "define", function(original) {
20726 return function(name, constructor, options) {
20727 try {
20728 customElementCb({
20729 define: {
20730 name: name
20731 }
20732 });
20733 } catch (e2) {
20734 console.warn("Custom element callback failed for " + name);
20735 }
20736 return original.apply(this, [
20737 name,
20738 constructor,
20739 options
20740 ]);
20741 };
20742 });
20743 return restoreHandler;
20744 }
20745 function mergeHooks(o2, hooks) {
20746 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;
20747 o2.mutationCb = function() {
20748 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20749 p[_key] = arguments[_key];
20750 }
20751 if (hooks.mutation) {
20752 var _hooks;
20753 (_hooks = hooks).mutation.apply(_hooks, [].concat(p));
20754 }
20755 mutationCb.apply(void 0, [].concat(p));
20756 };
20757 o2.mousemoveCb = function() {
20758 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20759 p[_key] = arguments[_key];
20760 }
20761 if (hooks.mousemove) {
20762 var _hooks;
20763 (_hooks = hooks).mousemove.apply(_hooks, [].concat(p));
20764 }
20765 mousemoveCb.apply(void 0, [].concat(p));
20766 };
20767 o2.mouseInteractionCb = function() {
20768 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20769 p[_key] = arguments[_key];
20770 }
20771 if (hooks.mouseInteraction) {
20772 var _hooks;
20773 (_hooks = hooks).mouseInteraction.apply(_hooks, [].concat(p));
20774 }
20775 mouseInteractionCb.apply(void 0, [].concat(p));
20776 };
20777 o2.scrollCb = function() {
20778 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20779 p[_key] = arguments[_key];
20780 }
20781 if (hooks.scroll) {
20782 var _hooks;
20783 (_hooks = hooks).scroll.apply(_hooks, [].concat(p));
20784 }
20785 scrollCb.apply(void 0, [].concat(p));
20786 };
20787 o2.viewportResizeCb = function() {
20788 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20789 p[_key] = arguments[_key];
20790 }
20791 if (hooks.viewportResize) {
20792 var _hooks;
20793 (_hooks = hooks).viewportResize.apply(_hooks, [].concat(p));
20794 }
20795 viewportResizeCb.apply(void 0, [].concat(p));
20796 };
20797 o2.inputCb = function() {
20798 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20799 p[_key] = arguments[_key];
20800 }
20801 if (hooks.input) {
20802 var _hooks;
20803 (_hooks = hooks).input.apply(_hooks, [].concat(p));
20804 }
20805 inputCb.apply(void 0, [].concat(p));
20806 };
20807 o2.mediaInteractionCb = function() {
20808 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20809 p[_key] = arguments[_key];
20810 }
20811 if (hooks.mediaInteaction) {
20812 var _hooks;
20813 (_hooks = hooks).mediaInteaction.apply(_hooks, [].concat(p));
20814 }
20815 mediaInteractionCb.apply(void 0, [].concat(p));
20816 };
20817 o2.styleSheetRuleCb = function() {
20818 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20819 p[_key] = arguments[_key];
20820 }
20821 if (hooks.styleSheetRule) {
20822 var _hooks;
20823 (_hooks = hooks).styleSheetRule.apply(_hooks, [].concat(p));
20824 }
20825 styleSheetRuleCb.apply(void 0, [].concat(p));
20826 };
20827 o2.styleDeclarationCb = function() {
20828 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20829 p[_key] = arguments[_key];
20830 }
20831 if (hooks.styleDeclaration) {
20832 var _hooks;
20833 (_hooks = hooks).styleDeclaration.apply(_hooks, [].concat(p));
20834 }
20835 styleDeclarationCb.apply(void 0, [].concat(p));
20836 };
20837 o2.canvasMutationCb = function() {
20838 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20839 p[_key] = arguments[_key];
20840 }
20841 if (hooks.canvasMutation) {
20842 var _hooks;
20843 (_hooks = hooks).canvasMutation.apply(_hooks, [].concat(p));
20844 }
20845 canvasMutationCb.apply(void 0, [].concat(p));
20846 };
20847 o2.fontCb = function() {
20848 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20849 p[_key] = arguments[_key];
20850 }
20851 if (hooks.font) {
20852 var _hooks;
20853 (_hooks = hooks).font.apply(_hooks, [].concat(p));
20854 }
20855 fontCb.apply(void 0, [].concat(p));
20856 };
20857 o2.selectionCb = function() {
20858 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20859 p[_key] = arguments[_key];
20860 }
20861 if (hooks.selection) {
20862 var _hooks;
20863 (_hooks = hooks).selection.apply(_hooks, [].concat(p));
20864 }
20865 selectionCb.apply(void 0, [].concat(p));
20866 };
20867 o2.customElementCb = function() {
20868 for(var _len = arguments.length, c2 = new Array(_len), _key = 0; _key < _len; _key++){
20869 c2[_key] = arguments[_key];
20870 }
20871 if (hooks.customElement) {
20872 var _hooks;
20873 (_hooks = hooks).customElement.apply(_hooks, [].concat(c2));
20874 }
20875 customElementCb.apply(void 0, [].concat(c2));
20876 };
20877 }
20878 function initObservers(o2, hooks) {
20879 if (hooks === void 0) hooks = {};
20880 var currentWindow = o2.doc.defaultView;
20881 if (!currentWindow) {
20882 return function() {};
20883 }
20884 mergeHooks(o2, hooks);
20885 var mutationObserver;
20886 if (o2.recordDOM) {
20887 mutationObserver = initMutationObserver(o2, o2.doc);
20888 }
20889 var mousemoveHandler = initMoveObserver(o2);
20890 var mouseInteractionHandler = initMouseInteractionObserver(o2);
20891 var scrollHandler = initScrollObserver(o2);
20892 var viewportResizeHandler = initViewportResizeObserver(o2, {
20893 win: currentWindow
20894 });
20895 var inputHandler = initInputObserver(o2);
20896 var mediaInteractionHandler = initMediaInteractionObserver(o2);
20897 var styleSheetObserver = function() {};
20898 var adoptedStyleSheetObserver = function() {};
20899 var styleDeclarationObserver = function() {};
20900 var fontObserver = function() {};
20901 if (o2.recordDOM) {
20902 styleSheetObserver = initStyleSheetObserver(o2, {
20903 win: currentWindow
20904 });
20905 adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o2, o2.doc);
20906 styleDeclarationObserver = initStyleDeclarationObserver(o2, {
20907 win: currentWindow
20908 });
20909 if (o2.collectFonts) {
20910 fontObserver = initFontObserver(o2);
20911 }
20912 }
20913 var selectionObserver = initSelectionObserver(o2);
20914 var customElementObserver = initCustomElementObserver(o2);
20915 var pluginHandlers = [];
20916 for(var _iterator = _create_for_of_iterator_helper_loose(o2.plugins), _step; !(_step = _iterator()).done;){
20917 var plugin3 = _step.value;
20918 pluginHandlers.push(plugin3.observer(plugin3.callback, currentWindow, plugin3.options));
20919 }
20920 return callbackWrapper(function() {
20921 mutationBuffers.forEach(function(b) {
20922 return b.reset();
20923 });
20924 mutationObserver == null ? void 0 : mutationObserver.disconnect();
20925 mousemoveHandler();
20926 mouseInteractionHandler();
20927 scrollHandler();
20928 viewportResizeHandler();
20929 inputHandler();
20930 mediaInteractionHandler();
20931 styleSheetObserver();
20932 adoptedStyleSheetObserver();
20933 styleDeclarationObserver();
20934 fontObserver();
20935 selectionObserver();
20936 customElementObserver();
20937 pluginHandlers.forEach(function(h) {
20938 return h();
20939 });
20940 });
20941 }
20942 function hasNestedCSSRule(prop) {
20943 return typeof window[prop] !== "undefined";
20944 }
20945 function canMonkeyPatchNestedCSSRule(prop) {
20946 return Boolean(typeof window[prop] !== "undefined" && // Note: Generally, this check _shouldn't_ be necessary
20947 // However, in some scenarios (e.g. jsdom) this can sometimes fail, so we check for it here
20948 window[prop].prototype && "insertRule" in window[prop].prototype && "deleteRule" in window[prop].prototype);
20949 }
20950 var CrossOriginIframeMirror = /*#__PURE__*/ function() {
20951 function CrossOriginIframeMirror(generateIdFn) {
20952 __publicField(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
20953 __publicField(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
20954 this.generateIdFn = generateIdFn;
20955 }
20956 var _proto = CrossOriginIframeMirror.prototype;
20957 _proto.getId = function getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) {
20958 var idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe);
20959 var remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe);
20960 var id = idToRemoteIdMap.get(remoteId);
20961 if (!id) {
20962 id = this.generateIdFn();
20963 idToRemoteIdMap.set(remoteId, id);
20964 remoteIdToIdMap.set(id, remoteId);
20965 }
20966 return id;
20967 };
20968 _proto.getIds = function getIds(iframe, remoteId) {
20969 var _this = this;
20970 var idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);
20971 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20972 return remoteId.map(function(id) {
20973 return _this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap);
20974 });
20975 };
20976 _proto.getRemoteId = function getRemoteId(iframe, id, map) {
20977 var remoteIdToIdMap = map || this.getRemoteIdToIdMap(iframe);
20978 if (typeof id !== "number") return id;
20979 var remoteId = remoteIdToIdMap.get(id);
20980 if (!remoteId) return -1;
20981 return remoteId;
20982 };
20983 _proto.getRemoteIds = function getRemoteIds(iframe, ids) {
20984 var _this = this;
20985 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20986 return ids.map(function(id) {
20987 return _this.getRemoteId(iframe, id, remoteIdToIdMap);
20988 });
20989 };
20990 _proto.reset = function reset(iframe) {
20991 if (!iframe) {
20992 this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap();
20993 this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
20994 return;
20995 }
20996 this.iframeIdToRemoteIdMap.delete(iframe);
20997 this.iframeRemoteIdToIdMap.delete(iframe);
20998 };
20999 _proto.getIdToRemoteIdMap = function getIdToRemoteIdMap(iframe) {
21000 var idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe);
21001 if (!idToRemoteIdMap) {
21002 idToRemoteIdMap = /* @__PURE__ */ new Map();
21003 this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap);
21004 }
21005 return idToRemoteIdMap;
21006 };
21007 _proto.getRemoteIdToIdMap = function getRemoteIdToIdMap(iframe) {
21008 var remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe);
21009 if (!remoteIdToIdMap) {
21010 remoteIdToIdMap = /* @__PURE__ */ new Map();
21011 this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap);
21012 }
21013 return remoteIdToIdMap;
21014 };
21015 return CrossOriginIframeMirror;
21016 }();
21017 var IframeManager = /*#__PURE__*/ function() {
21018 function IframeManager(options) {
21019 __publicField(this, "iframes", /* @__PURE__ */ new WeakMap());
21020 __publicField(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
21021 __publicField(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
21022 __publicField(this, "crossOriginIframeStyleMirror");
21023 __publicField(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
21024 __publicField(this, "mirror");
21025 __publicField(this, "mutationCb");
21026 __publicField(this, "wrappedEmit");
21027 __publicField(this, "loadListener");
21028 __publicField(this, "stylesheetManager");
21029 __publicField(this, "recordCrossOriginIframes");
21030 this.mutationCb = options.mutationCb;
21031 this.wrappedEmit = options.wrappedEmit;
21032 this.stylesheetManager = options.stylesheetManager;
21033 this.recordCrossOriginIframes = options.recordCrossOriginIframes;
21034 this.crossOriginIframeStyleMirror = new CrossOriginIframeMirror(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror));
21035 this.mirror = options.mirror;
21036 if (this.recordCrossOriginIframes) {
21037 window.addEventListener("message", this.handleMessage.bind(this));
21038 }
21039 }
21040 var _proto = IframeManager.prototype;
21041 _proto.addIframe = function addIframe(iframeEl) {
21042 this.iframes.set(iframeEl, true);
21043 if (iframeEl.contentWindow) this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
21044 };
21045 _proto.addLoadListener = function addLoadListener(cb) {
21046 this.loadListener = cb;
21047 };
21048 _proto.attachIframe = function attachIframe(iframeEl, childSn) {
21049 var _a2, _b;
21050 this.mutationCb({
21051 adds: [
21052 {
21053 parentId: this.mirror.getId(iframeEl),
21054 nextId: null,
21055 node: childSn
21056 }
21057 ],
21058 removes: [],
21059 texts: [],
21060 attributes: [],
21061 isAttachIframe: true
21062 });
21063 if (this.recordCrossOriginIframes) (_a2 = iframeEl.contentWindow) == null ? void 0 : _a2.addEventListener("message", this.handleMessage.bind(this));
21064 (_b = this.loadListener) == null ? void 0 : _b.call(this, iframeEl);
21065 if (iframeEl.contentDocument && iframeEl.contentDocument.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0) this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
21066 };
21067 _proto.handleMessage = function handleMessage(message) {
21068 var crossOriginMessageEvent = message;
21069 if (crossOriginMessageEvent.data.type !== "rrweb" || // To filter out the rrweb messages which are forwarded by some sites.
21070 crossOriginMessageEvent.origin !== crossOriginMessageEvent.data.origin) return;
21071 var iframeSourceWindow = message.source;
21072 if (!iframeSourceWindow) return;
21073 var iframeEl = this.crossOriginIframeMap.get(message.source);
21074 if (!iframeEl) return;
21075 var transformedEvent = this.transformCrossOriginEvent(iframeEl, crossOriginMessageEvent.data.event);
21076 if (transformedEvent) this.wrappedEmit(transformedEvent, crossOriginMessageEvent.data.isCheckout);
21077 };
21078 _proto.transformCrossOriginEvent = function transformCrossOriginEvent(iframeEl, e2) {
21079 var _this = this;
21080 var _a2;
21081 switch(e2.type){
21082 case EventType.FullSnapshot:
21083 {
21084 this.crossOriginIframeMirror.reset(iframeEl);
21085 this.crossOriginIframeStyleMirror.reset(iframeEl);
21086 this.replaceIdOnNode(e2.data.node, iframeEl);
21087 var rootId = e2.data.node.id;
21088 this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
21089 this.patchRootIdOnNode(e2.data.node, rootId);
21090 return {
21091 timestamp: e2.timestamp,
21092 type: EventType.IncrementalSnapshot,
21093 data: {
21094 source: IncrementalSource.Mutation,
21095 adds: [
21096 {
21097 parentId: this.mirror.getId(iframeEl),
21098 nextId: null,
21099 node: e2.data.node
21100 }
21101 ],
21102 removes: [],
21103 texts: [],
21104 attributes: [],
21105 isAttachIframe: true
21106 }
21107 };
21108 }
21109 case EventType.Meta:
21110 case EventType.Load:
21111 case EventType.DomContentLoaded:
21112 {
21113 return false;
21114 }
21115 case EventType.Plugin:
21116 {
21117 return e2;
21118 }
21119 case EventType.Custom:
21120 {
21121 this.replaceIds(e2.data.payload, iframeEl, [
21122 "id",
21123 "parentId",
21124 "previousId",
21125 "nextId"
21126 ]);
21127 return e2;
21128 }
21129 case EventType.IncrementalSnapshot:
21130 {
21131 switch(e2.data.source){
21132 case IncrementalSource.Mutation:
21133 {
21134 e2.data.adds.forEach(function(n2) {
21135 _this.replaceIds(n2, iframeEl, [
21136 "parentId",
21137 "nextId",
21138 "previousId"
21139 ]);
21140 _this.replaceIdOnNode(n2.node, iframeEl);
21141 var rootId = _this.crossOriginIframeRootIdMap.get(iframeEl);
21142 rootId && _this.patchRootIdOnNode(n2.node, rootId);
21143 });
21144 e2.data.removes.forEach(function(n2) {
21145 _this.replaceIds(n2, iframeEl, [
21146 "parentId",
21147 "id"
21148 ]);
21149 });
21150 e2.data.attributes.forEach(function(n2) {
21151 _this.replaceIds(n2, iframeEl, [
21152 "id"
21153 ]);
21154 });
21155 e2.data.texts.forEach(function(n2) {
21156 _this.replaceIds(n2, iframeEl, [
21157 "id"
21158 ]);
21159 });
21160 return e2;
21161 }
21162 case IncrementalSource.Drag:
21163 case IncrementalSource.TouchMove:
21164 case IncrementalSource.MouseMove:
21165 {
21166 e2.data.positions.forEach(function(p) {
21167 _this.replaceIds(p, iframeEl, [
21168 "id"
21169 ]);
21170 });
21171 return e2;
21172 }
21173 case IncrementalSource.ViewportResize:
21174 {
21175 return false;
21176 }
21177 case IncrementalSource.MediaInteraction:
21178 case IncrementalSource.MouseInteraction:
21179 case IncrementalSource.Scroll:
21180 case IncrementalSource.CanvasMutation:
21181 case IncrementalSource.Input:
21182 {
21183 this.replaceIds(e2.data, iframeEl, [
21184 "id"
21185 ]);
21186 return e2;
21187 }
21188 case IncrementalSource.StyleSheetRule:
21189 case IncrementalSource.StyleDeclaration:
21190 {
21191 this.replaceIds(e2.data, iframeEl, [
21192 "id"
21193 ]);
21194 this.replaceStyleIds(e2.data, iframeEl, [
21195 "styleId"
21196 ]);
21197 return e2;
21198 }
21199 case IncrementalSource.Font:
21200 {
21201 return e2;
21202 }
21203 case IncrementalSource.Selection:
21204 {
21205 e2.data.ranges.forEach(function(range) {
21206 _this.replaceIds(range, iframeEl, [
21207 "start",
21208 "end"
21209 ]);
21210 });
21211 return e2;
21212 }
21213 case IncrementalSource.AdoptedStyleSheet:
21214 {
21215 this.replaceIds(e2.data, iframeEl, [
21216 "id"
21217 ]);
21218 this.replaceStyleIds(e2.data, iframeEl, [
21219 "styleIds"
21220 ]);
21221 (_a2 = e2.data.styles) == null ? void 0 : _a2.forEach(function(style) {
21222 _this.replaceStyleIds(style, iframeEl, [
21223 "styleId"
21224 ]);
21225 });
21226 return e2;
21227 }
21228 }
21229 }
21230 }
21231 return false;
21232 };
21233 _proto.replace = function replace(iframeMirror, obj, iframeEl, keys) {
21234 for(var _iterator = _create_for_of_iterator_helper_loose(keys), _step; !(_step = _iterator()).done;){
21235 var key = _step.value;
21236 if (!Array.isArray(obj[key]) && typeof obj[key] !== "number") continue;
21237 if (Array.isArray(obj[key])) {
21238 obj[key] = iframeMirror.getIds(iframeEl, obj[key]);
21239 } else {
21240 obj[key] = iframeMirror.getId(iframeEl, obj[key]);
21241 }
21242 }
21243 return obj;
21244 };
21245 _proto.replaceIds = function replaceIds(obj, iframeEl, keys) {
21246 return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);
21247 };
21248 _proto.replaceStyleIds = function replaceStyleIds(obj, iframeEl, keys) {
21249 return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
21250 };
21251 _proto.replaceIdOnNode = function replaceIdOnNode(node2, iframeEl) {
21252 var _this = this;
21253 this.replaceIds(node2, iframeEl, [
21254 "id",
21255 "rootId"
21256 ]);
21257 if ("childNodes" in node2) {
21258 node2.childNodes.forEach(function(child) {
21259 _this.replaceIdOnNode(child, iframeEl);
21260 });
21261 }
21262 };
21263 _proto.patchRootIdOnNode = function patchRootIdOnNode(node2, rootId) {
21264 var _this = this;
21265 if (node2.type !== NodeType.Document && !node2.rootId) node2.rootId = rootId;
21266 if ("childNodes" in node2) {
21267 node2.childNodes.forEach(function(child) {
21268 _this.patchRootIdOnNode(child, rootId);
21269 });
21270 }
21271 };
21272 return IframeManager;
21273 }();
21274 var ShadowDomManager = /*#__PURE__*/ function() {
21275 function ShadowDomManager(options) {
21276 __publicField(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
21277 __publicField(this, "mutationCb");
21278 __publicField(this, "scrollCb");
21279 __publicField(this, "bypassOptions");
21280 __publicField(this, "mirror");
21281 __publicField(this, "restoreHandlers", []);
21282 this.mutationCb = options.mutationCb;
21283 this.scrollCb = options.scrollCb;
21284 this.bypassOptions = options.bypassOptions;
21285 this.mirror = options.mirror;
21286 this.init();
21287 }
21288 var _proto = ShadowDomManager.prototype;
21289 _proto.init = function init() {
21290 this.reset();
21291 this.patchAttachShadow(Element, document);
21292 };
21293 _proto.addShadowRoot = function addShadowRoot(shadowRoot2, doc) {
21294 var _this = this;
21295 if (!isNativeShadowDom(shadowRoot2)) return;
21296 if (this.shadowDoms.has(shadowRoot2)) return;
21297 this.shadowDoms.add(shadowRoot2);
21298 var observer = initMutationObserver(_extends({}, this.bypassOptions, {
21299 doc: doc,
21300 mutationCb: this.mutationCb,
21301 mirror: this.mirror,
21302 shadowDomManager: this
21303 }), shadowRoot2);
21304 this.restoreHandlers.push(function() {
21305 return observer.disconnect();
21306 });
21307 this.restoreHandlers.push(initScrollObserver(_extends({}, this.bypassOptions, {
21308 scrollCb: this.scrollCb,
21309 // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813
21310 // scroll is not allowed to pass the boundary, so we need to listen the shadow document
21311 doc: shadowRoot2,
21312 mirror: this.mirror
21313 })));
21314 setTimeout(function() {
21315 if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0) _this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot2.adoptedStyleSheets, _this.mirror.getId(index.host(shadowRoot2)));
21316 _this.restoreHandlers.push(initAdoptedStyleSheetObserver({
21317 mirror: _this.mirror,
21318 stylesheetManager: _this.bypassOptions.stylesheetManager
21319 }, shadowRoot2));
21320 }, 0);
21321 };
21322 /**
21323 * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
21324 */ _proto.observeAttachShadow = function observeAttachShadow(iframeElement) {
21325 if (!iframeElement.contentWindow || !iframeElement.contentDocument) return;
21326 this.patchAttachShadow(iframeElement.contentWindow.Element, iframeElement.contentDocument);
21327 };
21328 /**
21329 * Patch 'attachShadow' to observe newly added shadow doms.
21330 */ _proto.patchAttachShadow = function patchAttachShadow(element, doc) {
21331 var manager = this;
21332 this.restoreHandlers.push(patch(element.prototype, "attachShadow", function(original) {
21333 return function(option) {
21334 var sRoot = original.call(this, option);
21335 var shadowRootEl = index.shadowRoot(this);
21336 if (shadowRootEl && inDom(this)) manager.addShadowRoot(shadowRootEl, doc);
21337 return sRoot;
21338 };
21339 }));
21340 };
21341 _proto.reset = function reset() {
21342 this.restoreHandlers.forEach(function(handler) {
21343 try {
21344 handler();
21345 } catch (e2) {}
21346 });
21347 this.restoreHandlers = [];
21348 this.shadowDoms = /* @__PURE__ */ new WeakSet();
21349 };
21350 return ShadowDomManager;
21351 }();
21352 var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
21353 var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
21354 for(var i$1 = 0; i$1 < chars.length; i$1++){
21355 lookup[chars.charCodeAt(i$1)] = i$1;
21356 }
21357 var encode = function encode(arraybuffer) {
21358 var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
21359 for(i2 = 0; i2 < len; i2 += 3){
21360 base64 += chars[bytes[i2] >> 2];
21361 base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
21362 base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
21363 base64 += chars[bytes[i2 + 2] & 63];
21364 }
21365 if (len % 3 === 2) {
21366 base64 = base64.substring(0, base64.length - 1) + "=";
21367 } else if (len % 3 === 1) {
21368 base64 = base64.substring(0, base64.length - 2) + "==";
21369 }
21370 return base64;
21371 };
21372 var canvasVarMap = /* @__PURE__ */ new Map();
21373 function variableListFor$1(ctx, ctor) {
21374 var contextMap = canvasVarMap.get(ctx);
21375 if (!contextMap) {
21376 contextMap = /* @__PURE__ */ new Map();
21377 canvasVarMap.set(ctx, contextMap);
21378 }
21379 if (!contextMap.has(ctor)) {
21380 contextMap.set(ctor, []);
21381 }
21382 return contextMap.get(ctor);
21383 }
21384 var saveWebGLVar = function(value, win, ctx) {
21385 if (!value || !(isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object")) return;
21386 var name = value.constructor.name;
21387 var list2 = variableListFor$1(ctx, name);
21388 var index2 = list2.indexOf(value);
21389 if (index2 === -1) {
21390 index2 = list2.length;
21391 list2.push(value);
21392 }
21393 return index2;
21394 };
21395 function serializeArg(value, win, ctx) {
21396 if (_instanceof(value, Array)) {
21397 return value.map(function(arg) {
21398 return serializeArg(arg, win, ctx);
21399 });
21400 } else if (value === null) {
21401 return value;
21402 } 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)) {
21403 var name = value.constructor.name;
21404 return {
21405 rr_type: name,
21406 args: [
21407 Object.values(value)
21408 ]
21409 };
21410 } else if (// SharedArrayBuffer disabled on most browsers due to spectre.
21411 // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer
21412 // value instanceof SharedArrayBuffer ||
21413 _instanceof(value, ArrayBuffer)) {
21414 var name1 = value.constructor.name;
21415 var base64 = encode(value);
21416 return {
21417 rr_type: name1,
21418 base64: base64
21419 };
21420 } else if (_instanceof(value, DataView)) {
21421 var name2 = value.constructor.name;
21422 return {
21423 rr_type: name2,
21424 args: [
21425 serializeArg(value.buffer, win, ctx),
21426 value.byteOffset,
21427 value.byteLength
21428 ]
21429 };
21430 } else if (_instanceof(value, HTMLImageElement)) {
21431 var name3 = value.constructor.name;
21432 var src = value.src;
21433 return {
21434 rr_type: name3,
21435 src: src
21436 };
21437 } else if (_instanceof(value, HTMLCanvasElement)) {
21438 var name4 = "HTMLImageElement";
21439 var src1 = value.toDataURL();
21440 return {
21441 rr_type: name4,
21442 src: src1
21443 };
21444 } else if (_instanceof(value, ImageData)) {
21445 var name5 = value.constructor.name;
21446 return {
21447 rr_type: name5,
21448 args: [
21449 serializeArg(value.data, win, ctx),
21450 value.width,
21451 value.height
21452 ]
21453 };
21454 } else if (isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
21455 var name6 = value.constructor.name;
21456 var index2 = saveWebGLVar(value, win, ctx);
21457 return {
21458 rr_type: name6,
21459 index: index2
21460 };
21461 }
21462 return value;
21463 }
21464 var serializeArgs = function(args, win, ctx) {
21465 return args.map(function(arg) {
21466 return serializeArg(arg, win, ctx);
21467 });
21468 };
21469 var isInstanceOfWebGLObject = function(value, win) {
21470 var webGLConstructorNames = [
21471 "WebGLActiveInfo",
21472 "WebGLBuffer",
21473 "WebGLFramebuffer",
21474 "WebGLProgram",
21475 "WebGLRenderbuffer",
21476 "WebGLShader",
21477 "WebGLShaderPrecisionFormat",
21478 "WebGLTexture",
21479 "WebGLUniformLocation",
21480 "WebGLVertexArrayObject",
21481 // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.
21482 "WebGLVertexArrayObjectOES"
21483 ];
21484 var supportedWebGLConstructorNames = webGLConstructorNames.filter(function(name) {
21485 return typeof win[name] === "function";
21486 });
21487 return Boolean(supportedWebGLConstructorNames.find(function(name) {
21488 return _instanceof(value, win[name]);
21489 }));
21490 };
21491 function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
21492 var _loop = function() {
21493 var prop = _step.value;
21494 try {
21495 if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
21496 return "continue";
21497 }
21498 var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
21499 return function() {
21500 var _this = this;
21501 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21502 args[_key] = arguments[_key];
21503 }
21504 if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
21505 setTimeout(function() {
21506 var recordArgs = serializeArgs(args, win, _this);
21507 cb(_this.canvas, {
21508 type: CanvasContext["2D"],
21509 property: prop,
21510 args: recordArgs
21511 });
21512 }, 0);
21513 }
21514 return original.apply(this, args);
21515 };
21516 });
21517 handlers.push(restoreHandler);
21518 } catch (e) {
21519 var hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
21520 set: function set(v2) {
21521 cb(this.canvas, {
21522 type: CanvasContext["2D"],
21523 property: prop,
21524 args: [
21525 v2
21526 ],
21527 setter: true
21528 });
21529 }
21530 });
21531 handlers.push(hookHandler);
21532 }
21533 };
21534 var handlers = [];
21535 var props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
21536 for(var _iterator = _create_for_of_iterator_helper_loose(props2D), _step; !(_step = _iterator()).done;)_loop();
21537 return function() {
21538 handlers.forEach(function(h) {
21539 return h();
21540 });
21541 };
21542 }
21543 function getNormalizedContextName(contextType) {
21544 return contextType === "experimental-webgl" ? "webgl" : contextType;
21545 }
21546 function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
21547 var handlers = [];
21548 try {
21549 var restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
21550 return function(contextType) {
21551 for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
21552 args[_key - 1] = arguments[_key];
21553 }
21554 if (!isBlocked(this, blockClass, blockSelector, true)) {
21555 var ctxName = getNormalizedContextName(contextType);
21556 if (!("__context" in this)) this.__context = ctxName;
21557 if (setPreserveDrawingBufferToTrue && [
21558 "webgl",
21559 "webgl2"
21560 ].includes(ctxName)) {
21561 if (args[0] && _type_of(args[0]) === "object") {
21562 var contextAttributes = args[0];
21563 if (!contextAttributes.preserveDrawingBuffer) {
21564 contextAttributes.preserveDrawingBuffer = true;
21565 }
21566 } else {
21567 args.splice(0, 1, {
21568 preserveDrawingBuffer: true
21569 });
21570 }
21571 }
21572 }
21573 return original.apply(this, [].concat([
21574 contextType
21575 ], args));
21576 };
21577 });
21578 handlers.push(restoreHandler);
21579 } catch (e) {
21580 console.error("failed to patch HTMLCanvasElement.prototype.getContext");
21581 }
21582 return function() {
21583 handlers.forEach(function(h) {
21584 return h();
21585 });
21586 };
21587 }
21588 function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
21589 var _loop = function() {
21590 var prop = _step.value;
21591 if (//prop.startsWith('get') || // e.g. getProgramParameter, but too risky
21592 [
21593 "isContextLost",
21594 "canvas",
21595 "drawingBufferWidth",
21596 "drawingBufferHeight"
21597 ].includes(prop)) {
21598 return "continue";
21599 }
21600 try {
21601 if (typeof prototype[prop] !== "function") {
21602 return "continue";
21603 }
21604 var restoreHandler = patch(prototype, prop, function(original) {
21605 return function() {
21606 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21607 args[_key] = arguments[_key];
21608 }
21609 var result2 = original.apply(this, args);
21610 saveWebGLVar(result2, win, this);
21611 if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
21612 var recordArgs = serializeArgs(args, win, this);
21613 var mutation = {
21614 type: type,
21615 property: prop,
21616 args: recordArgs
21617 };
21618 cb(this.canvas, mutation);
21619 }
21620 return result2;
21621 };
21622 });
21623 handlers.push(restoreHandler);
21624 } catch (e) {
21625 var hookHandler = hookSetter(prototype, prop, {
21626 set: function set(v2) {
21627 cb(this.canvas, {
21628 type: type,
21629 property: prop,
21630 args: [
21631 v2
21632 ],
21633 setter: true
21634 });
21635 }
21636 });
21637 handlers.push(hookHandler);
21638 }
21639 };
21640 var handlers = [];
21641 var props = Object.getOwnPropertyNames(prototype);
21642 for(var _iterator = _create_for_of_iterator_helper_loose(props), _step; !(_step = _iterator()).done;)_loop();
21643 return handlers;
21644 }
21645 function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
21646 var _handlers;
21647 var handlers = [];
21648 (_handlers = handlers).push.apply(_handlers, [].concat(patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, blockSelector, win)));
21649 if (typeof win.WebGL2RenderingContext !== "undefined") {
21650 var _handlers1;
21651 (_handlers1 = handlers).push.apply(_handlers1, [].concat(patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, blockSelector, win)));
21652 }
21653 return function() {
21654 handlers.forEach(function(h) {
21655 return h();
21656 });
21657 };
21658 }
21659 var encodedJs = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=";
21660 var decodeBase64 = function(base64) {
21661 return Uint8Array.from(atob(base64), function(c2) {
21662 return c2.charCodeAt(0);
21663 });
21664 };
21665 var blob = typeof window !== "undefined" && window.Blob && new Blob([
21666 decodeBase64(encodedJs)
21667 ], {
21668 type: "text/javascript;charset=utf-8"
21669 });
21670 function WorkerWrapper(options) {
21671 var objURL;
21672 try {
21673 objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
21674 if (!objURL) throw "";
21675 var worker = new Worker(objURL, {
21676 name: options == null ? void 0 : options.name
21677 });
21678 worker.addEventListener("error", function() {
21679 (window.URL || window.webkitURL).revokeObjectURL(objURL);
21680 });
21681 return worker;
21682 } catch (e2) {
21683 return new Worker("data:text/javascript;base64," + encodedJs, {
21684 name: options == null ? void 0 : options.name
21685 });
21686 } finally{
21687 objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
21688 }
21689 }
21690 var CanvasManager = /*#__PURE__*/ function() {
21691 function CanvasManager(options) {
21692 var _this = this;
21693 __publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
21694 __publicField(this, "rafStamps", {
21695 latestId: 0,
21696 invokeId: null
21697 });
21698 __publicField(this, "mirror");
21699 __publicField(this, "mutationCb");
21700 __publicField(this, "resetObservers");
21701 __publicField(this, "frozen", false);
21702 __publicField(this, "locked", false);
21703 __publicField(this, "processMutation", function(target, mutation) {
21704 var newFrame = _this.rafStamps.invokeId && _this.rafStamps.latestId !== _this.rafStamps.invokeId;
21705 if (newFrame || !_this.rafStamps.invokeId) _this.rafStamps.invokeId = _this.rafStamps.latestId;
21706 if (!_this.pendingCanvasMutations.has(target)) {
21707 _this.pendingCanvasMutations.set(target, []);
21708 }
21709 _this.pendingCanvasMutations.get(target).push(mutation);
21710 });
21711 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;
21712 this.mutationCb = options.mutationCb;
21713 this.mirror = options.mirror;
21714 if (recordCanvas && sampling === "all") this.initCanvasMutationObserver(win, blockClass, blockSelector);
21715 if (recordCanvas && typeof sampling === "number") this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
21716 dataURLOptions: dataURLOptions
21717 });
21718 }
21719 var _proto = CanvasManager.prototype;
21720 _proto.reset = function reset() {
21721 this.pendingCanvasMutations.clear();
21722 this.resetObservers && this.resetObservers();
21723 };
21724 _proto.freeze = function freeze() {
21725 this.frozen = true;
21726 };
21727 _proto.unfreeze = function unfreeze() {
21728 this.frozen = false;
21729 };
21730 _proto.lock = function lock() {
21731 this.locked = true;
21732 };
21733 _proto.unlock = function unlock() {
21734 this.locked = false;
21735 };
21736 _proto.initCanvasFPSObserver = function initCanvasFPSObserver(fps, win, blockClass, blockSelector, options) {
21737 var _this = this;
21738 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, true);
21739 var snapshotInProgressMap = /* @__PURE__ */ new Map();
21740 var worker = new WorkerWrapper();
21741 worker.onmessage = function(e2) {
21742 var id = e2.data.id;
21743 snapshotInProgressMap.set(id, false);
21744 if (!("base64" in e2.data)) return;
21745 var _e2_data = e2.data, base64 = _e2_data.base64, type = _e2_data.type, width = _e2_data.width, height = _e2_data.height;
21746 _this.mutationCb({
21747 id: id,
21748 type: CanvasContext["2D"],
21749 commands: [
21750 {
21751 property: "clearRect",
21752 // wipe canvas
21753 args: [
21754 0,
21755 0,
21756 width,
21757 height
21758 ]
21759 },
21760 {
21761 property: "drawImage",
21762 // draws (semi-transparent) image
21763 args: [
21764 {
21765 rr_type: "ImageBitmap",
21766 args: [
21767 {
21768 rr_type: "Blob",
21769 data: [
21770 {
21771 rr_type: "ArrayBuffer",
21772 base64: base64
21773 }
21774 ],
21775 type: type
21776 }
21777 ]
21778 },
21779 0,
21780 0
21781 ]
21782 }
21783 ]
21784 });
21785 };
21786 var timeBetweenSnapshots = 1e3 / fps;
21787 var lastSnapshotTime = 0;
21788 var rafId;
21789 var getCanvas = function() {
21790 var matchedCanvas = [];
21791 win.document.querySelectorAll("canvas").forEach(function(canvas) {
21792 if (!isBlocked(canvas, blockClass, blockSelector, true)) {
21793 matchedCanvas.push(canvas);
21794 }
21795 });
21796 return matchedCanvas;
21797 };
21798 var takeCanvasSnapshots = function(timestamp) {
21799 if (lastSnapshotTime && timestamp - lastSnapshotTime < timeBetweenSnapshots) {
21800 rafId = requestAnimationFrame(takeCanvasSnapshots);
21801 return;
21802 }
21803 lastSnapshotTime = timestamp;
21804 var _this1 = _this;
21805 getCanvas().forEach(/*#__PURE__*/ _async_to_generator(function(canvas) {
21806 var _a2, id, context, bitmap;
21807 return _ts_generator(this, function(_state) {
21808 switch(_state.label){
21809 case 0:
21810 id = _this1.mirror.getId(canvas);
21811 if (snapshotInProgressMap.get(id)) return [
21812 2
21813 ];
21814 if (canvas.width === 0 || canvas.height === 0) return [
21815 2
21816 ];
21817 snapshotInProgressMap.set(id, true);
21818 if ([
21819 "webgl",
21820 "webgl2"
21821 ].includes(canvas.__context)) {
21822 context = canvas.getContext(canvas.__context);
21823 if (((_a2 = context == null ? void 0 : context.getContextAttributes()) == null ? void 0 : _a2.preserveDrawingBuffer) === false) {
21824 context.clear(context.COLOR_BUFFER_BIT);
21825 }
21826 }
21827 return [
21828 4,
21829 createImageBitmap(canvas)
21830 ];
21831 case 1:
21832 bitmap = _state.sent();
21833 worker.postMessage({
21834 id: id,
21835 bitmap: bitmap,
21836 width: canvas.width,
21837 height: canvas.height,
21838 dataURLOptions: options.dataURLOptions
21839 }, [
21840 bitmap
21841 ]);
21842 return [
21843 2
21844 ];
21845 }
21846 });
21847 }));
21848 rafId = requestAnimationFrame(takeCanvasSnapshots);
21849 };
21850 rafId = requestAnimationFrame(takeCanvasSnapshots);
21851 this.resetObservers = function() {
21852 canvasContextReset();
21853 cancelAnimationFrame(rafId);
21854 };
21855 };
21856 _proto.initCanvasMutationObserver = function initCanvasMutationObserver(win, blockClass, blockSelector) {
21857 this.startRAFTimestamping();
21858 this.startPendingCanvasMutationFlusher();
21859 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, false);
21860 var canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21861 var canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21862 this.resetObservers = function() {
21863 canvasContextReset();
21864 canvas2DReset();
21865 canvasWebGL1and2Reset();
21866 };
21867 };
21868 _proto.startPendingCanvasMutationFlusher = function startPendingCanvasMutationFlusher() {
21869 var _this = this;
21870 requestAnimationFrame(function() {
21871 return _this.flushPendingCanvasMutations();
21872 });
21873 };
21874 _proto.startRAFTimestamping = function startRAFTimestamping() {
21875 var _this = this;
21876 var setLatestRAFTimestamp = function(timestamp) {
21877 _this.rafStamps.latestId = timestamp;
21878 requestAnimationFrame(setLatestRAFTimestamp);
21879 };
21880 requestAnimationFrame(setLatestRAFTimestamp);
21881 };
21882 _proto.flushPendingCanvasMutations = function flushPendingCanvasMutations() {
21883 var _this = this;
21884 this.pendingCanvasMutations.forEach(function(_values, canvas) {
21885 var id = _this.mirror.getId(canvas);
21886 _this.flushPendingCanvasMutationFor(canvas, id);
21887 });
21888 requestAnimationFrame(function() {
21889 return _this.flushPendingCanvasMutations();
21890 });
21891 };
21892 _proto.flushPendingCanvasMutationFor = function flushPendingCanvasMutationFor(canvas, id) {
21893 if (this.frozen || this.locked) {
21894 return;
21895 }
21896 var valuesWithType = this.pendingCanvasMutations.get(canvas);
21897 if (!valuesWithType || id === -1) return;
21898 var values = valuesWithType.map(function(value) {
21899 value.type; var rest = _object_without_properties_loose(value, [
21900 "type"
21901 ]);
21902 return rest;
21903 });
21904 var type = valuesWithType[0].type;
21905 this.mutationCb({
21906 id: id,
21907 type: type,
21908 commands: values
21909 });
21910 this.pendingCanvasMutations.delete(canvas);
21911 };
21912 return CanvasManager;
21913 }();
21914 var StylesheetManager = /*#__PURE__*/ function() {
21915 function StylesheetManager(options) {
21916 __publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
21917 __publicField(this, "mutationCb");
21918 __publicField(this, "adoptedStyleSheetCb");
21919 __publicField(this, "styleMirror", new StyleSheetMirror());
21920 this.mutationCb = options.mutationCb;
21921 this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
21922 }
21923 var _proto = StylesheetManager.prototype;
21924 _proto.attachLinkElement = function attachLinkElement(linkEl, childSn) {
21925 if ("_cssText" in childSn.attributes) this.mutationCb({
21926 adds: [],
21927 removes: [],
21928 texts: [],
21929 attributes: [
21930 {
21931 id: childSn.id,
21932 attributes: childSn.attributes
21933 }
21934 ]
21935 });
21936 this.trackLinkElement(linkEl);
21937 };
21938 _proto.trackLinkElement = function trackLinkElement(linkEl) {
21939 if (this.trackedLinkElements.has(linkEl)) return;
21940 this.trackedLinkElements.add(linkEl);
21941 this.trackStylesheetInLinkElement(linkEl);
21942 };
21943 _proto.adoptStyleSheets = function adoptStyleSheets(sheets, hostId) {
21944 var _this, _loop = function() {
21945 var sheet = _step.value;
21946 var styleId = void 0;
21947 if (!_this.styleMirror.has(sheet)) {
21948 styleId = _this.styleMirror.add(sheet);
21949 styles.push({
21950 styleId: styleId,
21951 rules: Array.from(sheet.rules || CSSRule, function(r2, index2) {
21952 return {
21953 rule: stringifyRule(r2, sheet.href),
21954 index: index2
21955 };
21956 })
21957 });
21958 } else styleId = _this.styleMirror.getId(sheet);
21959 adoptedStyleSheetData.styleIds.push(styleId);
21960 };
21961 if (sheets.length === 0) return;
21962 var adoptedStyleSheetData = {
21963 id: hostId,
21964 styleIds: []
21965 };
21966 var styles = [];
21967 for(var _iterator = _create_for_of_iterator_helper_loose(sheets), _step; !(_step = _iterator()).done;)_this = this, _loop();
21968 if (styles.length > 0) adoptedStyleSheetData.styles = styles;
21969 this.adoptedStyleSheetCb(adoptedStyleSheetData);
21970 };
21971 _proto.reset = function reset() {
21972 this.styleMirror.reset();
21973 this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
21974 };
21975 // TODO: take snapshot on stylesheet reload by applying event listener
21976 _proto.trackStylesheetInLinkElement = function trackStylesheetInLinkElement(_linkEl) {};
21977 return StylesheetManager;
21978 }();
21979 var ProcessedNodeManager = /*#__PURE__*/ function() {
21980 function ProcessedNodeManager() {
21981 __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap());
21982 __publicField(this, "active", false);
21983 }
21984 var _proto = ProcessedNodeManager.prototype;
21985 _proto.inOtherBuffer = function inOtherBuffer(node2, thisBuffer) {
21986 var buffers = this.nodeMap.get(node2);
21987 return buffers && Array.from(buffers).some(function(buffer) {
21988 return buffer !== thisBuffer;
21989 });
21990 };
21991 _proto.add = function add(node2, buffer) {
21992 var _this = this;
21993 if (!this.active) {
21994 this.active = true;
21995 requestAnimationFrame(function() {
21996 _this.nodeMap = /* @__PURE__ */ new WeakMap();
21997 _this.active = false;
21998 });
21999 }
22000 this.nodeMap.set(node2, (this.nodeMap.get(node2) || /* @__PURE__ */ new Set()).add(buffer));
22001 };
22002 _proto.destroy = function destroy() {};
22003 return ProcessedNodeManager;
22004 }();
22005 var wrappedEmit;
22006 var takeFullSnapshot$1;
22007 var canvasManager;
22008 var recording = false;
22009 try {
22010 if (Array.from([
22011 1
22012 ], function(x2) {
22013 return x2 * 2;
22014 })[0] !== 2) {
22015 var cleanFrame = document.createElement("iframe");
22016 document.body.appendChild(cleanFrame);
22017 Array.from = ((_a = cleanFrame.contentWindow) == null ? void 0 : _a.Array.from) || Array.from;
22018 document.body.removeChild(cleanFrame);
22019 }
22020 } catch (err) {
22021 console.debug("Unable to override Array.from", err);
22022 }
22023 var mirror = createMirror$2();
22024 function record(options) {
22025 if (options === void 0) options = {};
22026 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() {
22027 return false;
22028 } : _options_keepIframeSrcFn, _options_ignoreCSSAttributes = options.ignoreCSSAttributes, ignoreCSSAttributes = _options_ignoreCSSAttributes === void 0 ? /* @__PURE__ */ new Set([]) : _options_ignoreCSSAttributes, errorHandler2 = options.errorHandler;
22029 registerErrorHandler(errorHandler2);
22030 var inEmittingFrame = recordCrossOriginIframes ? window.parent === window : true;
22031 var passEmitsToParent = false;
22032 if (!inEmittingFrame) {
22033 try {
22034 if (window.parent.document) {
22035 passEmitsToParent = false;
22036 }
22037 } catch (e2) {
22038 passEmitsToParent = true;
22039 }
22040 }
22041 if (inEmittingFrame && !emit) {
22042 throw new Error("emit function is required");
22043 }
22044 if (!inEmittingFrame && !passEmitsToParent) {
22045 return function() {};
22046 }
22047 if (mousemoveWait !== void 0 && sampling.mousemove === void 0) {
22048 sampling.mousemove = mousemoveWait;
22049 }
22050 mirror.reset();
22051 var maskInputOptions = maskAllInputs === true ? {
22052 color: true,
22053 date: true,
22054 "datetime-local": true,
22055 email: true,
22056 month: true,
22057 number: true,
22058 range: true,
22059 search: true,
22060 tel: true,
22061 text: true,
22062 time: true,
22063 url: true,
22064 week: true,
22065 textarea: true,
22066 select: true,
22067 password: true,
22068 hidden: true
22069 } : _maskInputOptions !== void 0 ? _maskInputOptions : {
22070 password: true
22071 };
22072 var slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
22073 script: true,
22074 comment: true,
22075 headFavicon: true,
22076 headWhitespace: true,
22077 headMetaSocial: true,
22078 headMetaRobots: true,
22079 headMetaHttpEquiv: true,
22080 headMetaVerification: true,
22081 // the following are off for slimDOMOptions === true,
22082 // as they destroy some (hidden) info:
22083 headMetaAuthorship: _slimDOMOptions === "all",
22084 headMetaDescKeywords: _slimDOMOptions === "all",
22085 headTitleMutations: _slimDOMOptions === "all"
22086 } : _slimDOMOptions ? _slimDOMOptions : {};
22087 polyfill$1();
22088 var lastFullSnapshotEvent;
22089 var incrementalSnapshotCount = 0;
22090 var eventProcessor = function(e2) {
22091 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
22092 var plugin3 = _step.value;
22093 if (plugin3.eventProcessor) {
22094 e2 = plugin3.eventProcessor(e2);
22095 }
22096 }
22097 if (packFn && // Disable packing events which will be emitted to parent frames.
22098 !passEmitsToParent) {
22099 e2 = packFn(e2);
22100 }
22101 return e2;
22102 };
22103 wrappedEmit = function(r2, isCheckout) {
22104 var _a2;
22105 var e2 = r2;
22106 e2.timestamp = nowTimestamp();
22107 if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
22108 mutationBuffers.forEach(function(buf) {
22109 return buf.unfreeze();
22110 });
22111 }
22112 if (inEmittingFrame) {
22113 emit == null ? void 0 : emit(eventProcessor(e2), isCheckout);
22114 } else if (passEmitsToParent) {
22115 var message = {
22116 type: "rrweb",
22117 event: eventProcessor(e2),
22118 origin: window.location.origin,
22119 isCheckout: isCheckout
22120 };
22121 window.parent.postMessage(message, "*");
22122 }
22123 if (e2.type === EventType.FullSnapshot) {
22124 lastFullSnapshotEvent = e2;
22125 incrementalSnapshotCount = 0;
22126 } else if (e2.type === EventType.IncrementalSnapshot) {
22127 if (e2.data.source === IncrementalSource.Mutation && e2.data.isAttachIframe) {
22128 return;
22129 }
22130 incrementalSnapshotCount++;
22131 var exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
22132 var exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
22133 if (exceedCount || exceedTime) {
22134 takeFullSnapshot$1(true);
22135 }
22136 }
22137 };
22138 var wrappedMutationEmit = function(m) {
22139 wrappedEmit({
22140 type: EventType.IncrementalSnapshot,
22141 data: _extends({
22142 source: IncrementalSource.Mutation
22143 }, m)
22144 });
22145 };
22146 var wrappedScrollEmit = function(p) {
22147 return wrappedEmit({
22148 type: EventType.IncrementalSnapshot,
22149 data: _extends({
22150 source: IncrementalSource.Scroll
22151 }, p)
22152 });
22153 };
22154 var wrappedCanvasMutationEmit = function(p) {
22155 return wrappedEmit({
22156 type: EventType.IncrementalSnapshot,
22157 data: _extends({
22158 source: IncrementalSource.CanvasMutation
22159 }, p)
22160 });
22161 };
22162 var wrappedAdoptedStyleSheetEmit = function(a2) {
22163 return wrappedEmit({
22164 type: EventType.IncrementalSnapshot,
22165 data: _extends({
22166 source: IncrementalSource.AdoptedStyleSheet
22167 }, a2)
22168 });
22169 };
22170 var stylesheetManager = new StylesheetManager({
22171 mutationCb: wrappedMutationEmit,
22172 adoptedStyleSheetCb: wrappedAdoptedStyleSheetEmit
22173 });
22174 var iframeManager = new IframeManager({
22175 mirror: mirror,
22176 mutationCb: wrappedMutationEmit,
22177 stylesheetManager: stylesheetManager,
22178 recordCrossOriginIframes: recordCrossOriginIframes,
22179 wrappedEmit: wrappedEmit
22180 });
22181 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
22182 var plugin3 = _step.value;
22183 if (plugin3.getMirror) plugin3.getMirror({
22184 nodeMirror: mirror,
22185 crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,
22186 crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror
22187 });
22188 }
22189 var processedNodeManager = new ProcessedNodeManager();
22190 canvasManager = new CanvasManager({
22191 recordCanvas: recordCanvas,
22192 mutationCb: wrappedCanvasMutationEmit,
22193 win: window,
22194 blockClass: blockClass,
22195 blockSelector: blockSelector,
22196 mirror: mirror,
22197 sampling: sampling.canvas,
22198 dataURLOptions: dataURLOptions
22199 });
22200 var shadowDomManager = new ShadowDomManager({
22201 mutationCb: wrappedMutationEmit,
22202 scrollCb: wrappedScrollEmit,
22203 bypassOptions: {
22204 blockClass: blockClass,
22205 blockSelector: blockSelector,
22206 maskTextClass: maskTextClass,
22207 maskTextSelector: maskTextSelector,
22208 inlineStylesheet: inlineStylesheet,
22209 maskInputOptions: maskInputOptions,
22210 dataURLOptions: dataURLOptions,
22211 maskTextFn: maskTextFn,
22212 maskInputFn: maskInputFn,
22213 recordCanvas: recordCanvas,
22214 inlineImages: inlineImages,
22215 sampling: sampling,
22216 slimDOMOptions: slimDOMOptions,
22217 iframeManager: iframeManager,
22218 stylesheetManager: stylesheetManager,
22219 canvasManager: canvasManager,
22220 keepIframeSrcFn: keepIframeSrcFn,
22221 processedNodeManager: processedNodeManager
22222 },
22223 mirror: mirror
22224 });
22225 takeFullSnapshot$1 = function(isCheckout) {
22226 if (isCheckout === void 0) isCheckout = false;
22227 if (!recordDOM) {
22228 return;
22229 }
22230 wrappedEmit({
22231 type: EventType.Meta,
22232 data: {
22233 href: window.location.href,
22234 width: getWindowWidth(),
22235 height: getWindowHeight()
22236 }
22237 }, isCheckout);
22238 stylesheetManager.reset();
22239 shadowDomManager.init();
22240 mutationBuffers.forEach(function(buf) {
22241 return buf.lock();
22242 });
22243 var node2 = snapshot(document, {
22244 mirror: mirror,
22245 blockClass: blockClass,
22246 blockSelector: blockSelector,
22247 maskTextClass: maskTextClass,
22248 maskTextSelector: maskTextSelector,
22249 inlineStylesheet: inlineStylesheet,
22250 maskAllInputs: maskInputOptions,
22251 maskTextFn: maskTextFn,
22252 maskInputFn: maskInputFn,
22253 slimDOM: slimDOMOptions,
22254 dataURLOptions: dataURLOptions,
22255 recordCanvas: recordCanvas,
22256 inlineImages: inlineImages,
22257 onSerialize: function(n2) {
22258 if (isSerializedIframe(n2, mirror)) {
22259 iframeManager.addIframe(n2);
22260 }
22261 if (isSerializedStylesheet(n2, mirror)) {
22262 stylesheetManager.trackLinkElement(n2);
22263 }
22264 if (hasShadowRoot(n2)) {
22265 shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
22266 }
22267 },
22268 onIframeLoad: function(iframe, childSn) {
22269 iframeManager.attachIframe(iframe, childSn);
22270 shadowDomManager.observeAttachShadow(iframe);
22271 },
22272 onStylesheetLoad: function(linkEl, childSn) {
22273 stylesheetManager.attachLinkElement(linkEl, childSn);
22274 },
22275 keepIframeSrcFn: keepIframeSrcFn
22276 });
22277 if (!node2) {
22278 return console.warn("Failed to snapshot the document");
22279 }
22280 wrappedEmit({
22281 type: EventType.FullSnapshot,
22282 data: {
22283 node: node2,
22284 initialOffset: getWindowScroll(window)
22285 }
22286 }, isCheckout);
22287 mutationBuffers.forEach(function(buf) {
22288 return buf.unlock();
22289 });
22290 if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0) stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.getId(document));
22291 };
22292 try {
22293 var handlers = [];
22294 var observe = function(doc) {
22295 var _a2;
22296 return callbackWrapper(initObservers)({
22297 mutationCb: wrappedMutationEmit,
22298 mousemoveCb: function(positions, source) {
22299 return wrappedEmit({
22300 type: EventType.IncrementalSnapshot,
22301 data: {
22302 source: source,
22303 positions: positions
22304 }
22305 });
22306 },
22307 mouseInteractionCb: function(d) {
22308 return wrappedEmit({
22309 type: EventType.IncrementalSnapshot,
22310 data: _extends({
22311 source: IncrementalSource.MouseInteraction
22312 }, d)
22313 });
22314 },
22315 scrollCb: wrappedScrollEmit,
22316 viewportResizeCb: function(d) {
22317 return wrappedEmit({
22318 type: EventType.IncrementalSnapshot,
22319 data: _extends({
22320 source: IncrementalSource.ViewportResize
22321 }, d)
22322 });
22323 },
22324 inputCb: function(v2) {
22325 return wrappedEmit({
22326 type: EventType.IncrementalSnapshot,
22327 data: _extends({
22328 source: IncrementalSource.Input
22329 }, v2)
22330 });
22331 },
22332 mediaInteractionCb: function(p) {
22333 return wrappedEmit({
22334 type: EventType.IncrementalSnapshot,
22335 data: _extends({
22336 source: IncrementalSource.MediaInteraction
22337 }, p)
22338 });
22339 },
22340 styleSheetRuleCb: function(r2) {
22341 return wrappedEmit({
22342 type: EventType.IncrementalSnapshot,
22343 data: _extends({
22344 source: IncrementalSource.StyleSheetRule
22345 }, r2)
22346 });
22347 },
22348 styleDeclarationCb: function(r2) {
22349 return wrappedEmit({
22350 type: EventType.IncrementalSnapshot,
22351 data: _extends({
22352 source: IncrementalSource.StyleDeclaration
22353 }, r2)
22354 });
22355 },
22356 canvasMutationCb: wrappedCanvasMutationEmit,
22357 fontCb: function(p) {
22358 return wrappedEmit({
22359 type: EventType.IncrementalSnapshot,
22360 data: _extends({
22361 source: IncrementalSource.Font
22362 }, p)
22363 });
22364 },
22365 selectionCb: function(p) {
22366 wrappedEmit({
22367 type: EventType.IncrementalSnapshot,
22368 data: _extends({
22369 source: IncrementalSource.Selection
22370 }, p)
22371 });
22372 },
22373 customElementCb: function(c2) {
22374 wrappedEmit({
22375 type: EventType.IncrementalSnapshot,
22376 data: _extends({
22377 source: IncrementalSource.CustomElement
22378 }, c2)
22379 });
22380 },
22381 blockClass: blockClass,
22382 ignoreClass: ignoreClass,
22383 ignoreSelector: ignoreSelector,
22384 maskTextClass: maskTextClass,
22385 maskTextSelector: maskTextSelector,
22386 maskInputOptions: maskInputOptions,
22387 inlineStylesheet: inlineStylesheet,
22388 sampling: sampling,
22389 recordDOM: recordDOM,
22390 recordCanvas: recordCanvas,
22391 inlineImages: inlineImages,
22392 userTriggeredOnInput: userTriggeredOnInput,
22393 collectFonts: collectFonts,
22394 doc: doc,
22395 maskInputFn: maskInputFn,
22396 maskTextFn: maskTextFn,
22397 keepIframeSrcFn: keepIframeSrcFn,
22398 blockSelector: blockSelector,
22399 slimDOMOptions: slimDOMOptions,
22400 dataURLOptions: dataURLOptions,
22401 mirror: mirror,
22402 iframeManager: iframeManager,
22403 stylesheetManager: stylesheetManager,
22404 shadowDomManager: shadowDomManager,
22405 processedNodeManager: processedNodeManager,
22406 canvasManager: canvasManager,
22407 ignoreCSSAttributes: ignoreCSSAttributes,
22408 plugins: ((_a2 = plugins == null ? void 0 : plugins.filter(function(p) {
22409 return p.observer;
22410 })) == null ? void 0 : _a2.map(function(p) {
22411 return {
22412 observer: p.observer,
22413 options: p.options,
22414 callback: function(payload) {
22415 return wrappedEmit({
22416 type: EventType.Plugin,
22417 data: {
22418 plugin: p.name,
22419 payload: payload
22420 }
22421 });
22422 }
22423 };
22424 })) || []
22425 }, hooks);
22426 };
22427 iframeManager.addLoadListener(function(iframeEl) {
22428 try {
22429 handlers.push(observe(iframeEl.contentDocument));
22430 } catch (error) {
22431 console.warn(error);
22432 }
22433 });
22434 var init = function() {
22435 takeFullSnapshot$1();
22436 handlers.push(observe(document));
22437 recording = true;
22438 };
22439 if (document.readyState === "interactive" || document.readyState === "complete") {
22440 init();
22441 } else {
22442 handlers.push(on("DOMContentLoaded", function() {
22443 wrappedEmit({
22444 type: EventType.DomContentLoaded,
22445 data: {}
22446 });
22447 if (recordAfter === "DOMContentLoaded") init();
22448 }));
22449 handlers.push(on("load", function() {
22450 wrappedEmit({
22451 type: EventType.Load,
22452 data: {}
22453 });
22454 if (recordAfter === "load") init();
22455 }, window));
22456 }
22457 return function() {
22458 handlers.forEach(function(handler) {
22459 try {
22460 handler();
22461 } catch (error) {
22462 var msg = String(error).toLowerCase();
22463 if (!msg.includes("cross-origin")) {
22464 console.warn(error);
22465 }
22466 }
22467 });
22468 processedNodeManager.destroy();
22469 recording = false;
22470 unregisterErrorHandler();
22471 };
22472 } catch (error) {
22473 console.warn(error);
22474 }
22475 }
22476 record.addCustomEvent = function(tag, payload) {
22477 if (!recording) {
22478 throw new Error("please add custom event after start recording");
22479 }
22480 wrappedEmit({
22481 type: EventType.Custom,
22482 data: {
22483 tag: tag,
22484 payload: payload
22485 }
22486 });
22487 };
22488 record.freezePage = function() {
22489 mutationBuffers.forEach(function(buf) {
22490 return buf.freeze();
22491 });
22492 };
22493 record.takeFullSnapshot = function(isCheckout) {
22494 if (!recording) {
22495 throw new Error("please take full snapshot after start recording");
22496 }
22497 takeFullSnapshot$1(isCheckout);
22498 };
22499 record.mirror = mirror;
22500 var n;
22501 !function(t2) {
22502 t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
22503 }(n || (n = {}));
22504 record.addCustomEvent;
22505 record.freezePage;
22506 record.takeFullSnapshot;
22507
22508 var setImmediate = win['setImmediate'];
22509 var builtInProp, cycle, schedulingQueue,
22510 ToString = Object.prototype.toString,
22511 timer = (typeof setImmediate !== 'undefined') ?
22512 function timer(fn) { return setImmediate(fn); } :
22513 setTimeout;
22514
22515 // dammit, IE8.
22516 try {
22517 Object.defineProperty({},'x',{});
22518 builtInProp = function builtInProp(obj,name,val,config) {
22519 return Object.defineProperty(obj,name,{
22520 value: val,
22521 writable: true,
22522 configurable: config !== false
22523 });
22524 };
22525 }
22526 catch (err) {
22527 builtInProp = function builtInProp(obj,name,val) {
22528 obj[name] = val;
22529 return obj;
22530 };
22531 }
22532
22533 // Note: using a queue instead of array for efficiency
22534 schedulingQueue = (function Queue() {
22535 var first, last, item;
22536
22537 function Item(fn,self) {
22538 this.fn = fn;
22539 this.self = self;
22540 this.next = void 0;
22541 }
22542
22543 return {
22544 add: function add(fn,self) {
22545 item = new Item(fn,self);
22546 if (last) {
22547 last.next = item;
22548 }
22549 else {
22550 first = item;
22551 }
22552 last = item;
22553 item = void 0;
22554 },
22555 drain: function drain() {
22556 var f = first;
22557 first = last = cycle = void 0;
22558
22559 while (f) {
22560 f.fn.call(f.self);
22561 f = f.next;
22562 }
22563 }
22564 };
22565 })();
22566
22567 function schedule(fn,self) {
22568 schedulingQueue.add(fn,self);
22569 if (!cycle) {
22570 cycle = timer(schedulingQueue.drain);
22571 }
22572 }
22573
22574 // promise duck typing
22575 function isThenable(o) {
22576 var _then, oType = typeof o;
22577
22578 if (o !== null && (oType === 'object' || oType === 'function')) {
22579 _then = o.then;
22580 }
22581 return typeof _then === 'function' ? _then : false;
22582 }
22583
22584 function notify() {
22585 for (var i=0; i<this.chain.length; i++) {
22586 notifyIsolated(
22587 this,
22588 (this.state === 1) ? this.chain[i].success : this.chain[i].failure,
22589 this.chain[i]
22590 );
22591 }
22592 this.chain.length = 0;
22593 }
22594
22595 // NOTE: This is a separate function to isolate
22596 // the `try..catch` so that other code can be
22597 // optimized better
22598 function notifyIsolated(self,cb,chain) {
22599 var ret, _then;
22600 try {
22601 if (cb === false) {
22602 chain.reject(self.msg);
22603 }
22604 else {
22605 if (cb === true) {
22606 ret = self.msg;
22607 }
22608 else {
22609 ret = cb.call(void 0,self.msg);
22610 }
22611
22612 if (ret === chain.promise) {
22613 chain.reject(TypeError('Promise-chain cycle'));
22614 }
22615 // eslint-disable-next-line no-cond-assign
22616 else if (_then = isThenable(ret)) {
22617 _then.call(ret,chain.resolve,chain.reject);
22618 }
22619 else {
22620 chain.resolve(ret);
22621 }
22622 }
22623 }
22624 catch (err) {
22625 chain.reject(err);
22626 }
22627 }
22628
22629 function resolve(msg) {
22630 var _then, self = this;
22631
22632 // already triggered?
22633 if (self.triggered) { return; }
22634
22635 self.triggered = true;
22636
22637 // unwrap
22638 if (self.def) {
22639 self = self.def;
22640 }
22641
22642 try {
22643 // eslint-disable-next-line no-cond-assign
22644 if (_then = isThenable(msg)) {
22645 schedule(function(){
22646 var defWrapper = new MakeDefWrapper(self);
22647 try {
22648 _then.call(msg,
22649 function $resolve$(){ resolve.apply(defWrapper,arguments); },
22650 function $reject$(){ reject.apply(defWrapper,arguments); }
22651 );
22652 }
22653 catch (err) {
22654 reject.call(defWrapper,err);
22655 }
22656 });
22657 }
22658 else {
22659 self.msg = msg;
22660 self.state = 1;
22661 if (self.chain.length > 0) {
22662 schedule(notify,self);
22663 }
22664 }
22665 }
22666 catch (err) {
22667 reject.call(new MakeDefWrapper(self),err);
22668 }
22669 }
22670
22671 function reject(msg) {
22672 var self = this;
22673
22674 // already triggered?
22675 if (self.triggered) { return; }
22676
22677 self.triggered = true;
22678
22679 // unwrap
22680 if (self.def) {
22681 self = self.def;
22682 }
22683
22684 self.msg = msg;
22685 self.state = 2;
22686 if (self.chain.length > 0) {
22687 schedule(notify,self);
22688 }
22689 }
22690
22691 function iteratePromises(Constructor,arr,resolver,rejecter) {
22692 for (var idx=0; idx<arr.length; idx++) {
22693 (function IIFE(idx){
22694 Constructor.resolve(arr[idx])
22695 .then(
22696 function $resolver$(msg){
22697 resolver(idx,msg);
22698 },
22699 rejecter
22700 );
22701 })(idx);
22702 }
22703 }
22704
22705 function MakeDefWrapper(self) {
22706 this.def = self;
22707 this.triggered = false;
22708 }
22709
22710 function MakeDef(self) {
22711 this.promise = self;
22712 this.state = 0;
22713 this.triggered = false;
22714 this.chain = [];
22715 this.msg = void 0;
22716 }
22717
22718 function NpoPromise(executor) {
22719 if (typeof executor !== 'function') {
22720 throw TypeError('Not a function');
22721 }
22722
22723 if (this['__NPO__'] !== 0) {
22724 throw TypeError('Not a promise');
22725 }
22726
22727 // instance shadowing the inherited "brand"
22728 // to signal an already "initialized" promise
22729 this['__NPO__'] = 1;
22730
22731 var def = new MakeDef(this);
22732
22733 this['then'] = function then(success,failure) {
22734 var o = {
22735 success: typeof success === 'function' ? success : true,
22736 failure: typeof failure === 'function' ? failure : false
22737 };
22738 // Note: `then(..)` itself can be borrowed to be used against
22739 // a different promise constructor for making the chained promise,
22740 // by substituting a different `this` binding.
22741 o.promise = new this.constructor(function extractChain(resolve,reject) {
22742 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22743 throw TypeError('Not a function');
22744 }
22745
22746 o.resolve = resolve;
22747 o.reject = reject;
22748 });
22749 def.chain.push(o);
22750
22751 if (def.state !== 0) {
22752 schedule(notify,def);
22753 }
22754
22755 return o.promise;
22756 };
22757 this['catch'] = function $catch$(failure) {
22758 return this.then(void 0,failure);
22759 };
22760
22761 try {
22762 executor.call(
22763 void 0,
22764 function publicResolve(msg){
22765 resolve.call(def,msg);
22766 },
22767 function publicReject(msg) {
22768 reject.call(def,msg);
22769 }
22770 );
22771 }
22772 catch (err) {
22773 reject.call(def,err);
22774 }
22775 }
22776
22777 var PromisePrototype = builtInProp({},'constructor',NpoPromise,
22778 /*configurable=*/false
22779 );
22780
22781 // Note: Android 4 cannot use `Object.defineProperty(..)` here
22782 NpoPromise.prototype = PromisePrototype;
22783
22784 // built-in "brand" to signal an "uninitialized" promise
22785 builtInProp(PromisePrototype,'__NPO__',0,
22786 /*configurable=*/false
22787 );
22788
22789 builtInProp(NpoPromise,'resolve',function Promise$resolve(msg) {
22790 var Constructor = this;
22791
22792 // spec mandated checks
22793 // note: best "isPromise" check that's practical for now
22794 if (msg && typeof msg === 'object' && msg['__NPO__'] === 1) {
22795 return msg;
22796 }
22797
22798 return new Constructor(function executor(resolve,reject){
22799 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22800 throw TypeError('Not a function');
22801 }
22802
22803 resolve(msg);
22804 });
22805 });
22806
22807 builtInProp(NpoPromise,'reject',function Promise$reject(msg) {
22808 return new this(function executor(resolve,reject){
22809 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22810 throw TypeError('Not a function');
22811 }
22812
22813 reject(msg);
22814 });
22815 });
22816
22817 builtInProp(NpoPromise,'all',function Promise$all(arr) {
22818 var Constructor = this;
22819
22820 // spec mandated checks
22821 if (ToString.call(arr) !== '[object Array]') {
22822 return Constructor.reject(TypeError('Not an array'));
22823 }
22824 if (arr.length === 0) {
22825 return Constructor.resolve([]);
22826 }
22827
22828 return new Constructor(function executor(resolve,reject){
22829 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22830 throw TypeError('Not a function');
22831 }
22832
22833 var len = arr.length, msgs = Array(len), count = 0;
22834
22835 iteratePromises(Constructor,arr,function resolver(idx,msg) {
22836 msgs[idx] = msg;
22837 if (++count === len) {
22838 resolve(msgs);
22839 }
22840 },reject);
22841 });
22842 });
22843
22844 builtInProp(NpoPromise,'race',function Promise$race(arr) {
22845 var Constructor = this;
22846
22847 // spec mandated checks
22848 if (ToString.call(arr) !== '[object Array]') {
22849 return Constructor.reject(TypeError('Not an array'));
22850 }
22851
22852 return new Constructor(function executor(resolve,reject){
22853 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22854 throw TypeError('Not a function');
22855 }
22856
22857 iteratePromises(Constructor,arr,function resolver(idx,msg){
22858 resolve(msg);
22859 },reject);
22860 });
22861 });
22862
22863 var PromisePolyfill;
22864 if (typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]') !== -1) {
22865 PromisePolyfill = Promise;
22866 } else {
22867 PromisePolyfill = NpoPromise;
22868 }
22869
22870 var Config = {
22871 DEBUG: false,
22872 LIB_VERSION: '2.71.1'
22873 };
22874
22875 /* eslint camelcase: "off", eqeqeq: "off" */
22876
22877 // Maximum allowed session recording length
22878 var MAX_RECORDING_MS = 24 * 60 * 60 * 1000; // 24 hours
22879 // Maximum allowed value for minimum session recording length
22880 var MAX_VALUE_FOR_MIN_RECORDING_MS = 8 * 1000; // 8 seconds
22881
22882 /*
22883 * Saved references to long variable names, so that closure compiler can
22884 * minimize file size.
22885 */
22886
22887 var ArrayProto = Array.prototype,
22888 FuncProto = Function.prototype,
22889 ObjProto = Object.prototype,
22890 slice = ArrayProto.slice,
22891 toString = ObjProto.toString,
22892 hasOwnProperty = ObjProto.hasOwnProperty,
22893 windowConsole = win.console,
22894 navigator = win.navigator,
22895 document$1 = win.document,
22896 windowOpera = win.opera,
22897 screen = win.screen,
22898 userAgent = navigator.userAgent;
22899
22900 var nativeBind = FuncProto.bind,
22901 nativeForEach = ArrayProto.forEach,
22902 nativeIndexOf = ArrayProto.indexOf,
22903 nativeMap = ArrayProto.map,
22904 nativeIsArray = Array.isArray,
22905 breaker = {};
22906
22907 var _ = {
22908 trim: function(str) {
22909 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
22910 return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
22911 }
22912 };
22913
22914 // Console override
22915 var console$1 = {
22916 /** @type {function(...*)} */
22917 log: function() {
22918 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22919 try {
22920 windowConsole.log.apply(windowConsole, arguments);
22921 } catch (err) {
22922 _.each(arguments, function(arg) {
22923 windowConsole.log(arg);
22924 });
22925 }
22926 }
22927 },
22928 /** @type {function(...*)} */
22929 warn: function() {
22930 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22931 var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
22932 try {
22933 windowConsole.warn.apply(windowConsole, args);
22934 } catch (err) {
22935 _.each(args, function(arg) {
22936 windowConsole.warn(arg);
22937 });
22938 }
22939 }
22940 },
22941 /** @type {function(...*)} */
22942 error: function() {
22943 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22944 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22945 try {
22946 windowConsole.error.apply(windowConsole, args);
22947 } catch (err) {
22948 _.each(args, function(arg) {
22949 windowConsole.error(arg);
22950 });
22951 }
22952 }
22953 },
22954 /** @type {function(...*)} */
22955 critical: function() {
22956 if (!_.isUndefined(windowConsole) && windowConsole) {
22957 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22958 try {
22959 windowConsole.error.apply(windowConsole, args);
22960 } catch (err) {
22961 _.each(args, function(arg) {
22962 windowConsole.error(arg);
22963 });
22964 }
22965 }
22966 }
22967 };
22968
22969 var log_func_with_prefix = function(func, prefix) {
22970 return function() {
22971 arguments[0] = '[' + prefix + '] ' + arguments[0];
22972 return func.apply(console$1, arguments);
22973 };
22974 };
22975 var console_with_prefix = function(prefix) {
22976 return {
22977 log: log_func_with_prefix(console$1.log, prefix),
22978 error: log_func_with_prefix(console$1.error, prefix),
22979 critical: log_func_with_prefix(console$1.critical, prefix)
22980 };
22981 };
22982
22983
22984 var safewrap = function(f) {
22985 return function() {
22986 try {
22987 return f.apply(this, arguments);
22988 } catch (e) {
22989 console$1.critical('Implementation error. Please turn on debug and contact support@mixpanel.com.');
22990 if (Config.DEBUG){
22991 console$1.critical(e);
22992 }
22993 }
22994 };
22995 };
22996
22997 var safewrapClass = function(klass) {
22998 var proto = klass.prototype;
22999 for (var func in proto) {
23000 if (typeof(proto[func]) === 'function') {
23001 proto[func] = safewrap(proto[func]);
23002 }
23003 }
23004 };
23005
23006
23007 // UNDERSCORE
23008 // Embed part of the Underscore Library
23009 _.bind = function(func, context) {
23010 var args, bound;
23011 if (nativeBind && func.bind === nativeBind) {
23012 return nativeBind.apply(func, slice.call(arguments, 1));
23013 }
23014 if (!_.isFunction(func)) {
23015 throw new TypeError();
23016 }
23017 args = slice.call(arguments, 2);
23018 bound = function() {
23019 if (!(this instanceof bound)) {
23020 return func.apply(context, args.concat(slice.call(arguments)));
23021 }
23022 var ctor = {};
23023 ctor.prototype = func.prototype;
23024 var self = new ctor();
23025 ctor.prototype = null;
23026 var result = func.apply(self, args.concat(slice.call(arguments)));
23027 if (Object(result) === result) {
23028 return result;
23029 }
23030 return self;
23031 };
23032 return bound;
23033 };
23034
23035 /**
23036 * @param {*=} obj
23037 * @param {function(...*)=} iterator
23038 * @param {Object=} context
23039 */
23040 _.each = function(obj, iterator, context) {
23041 if (obj === null || obj === undefined) {
23042 return;
23043 }
23044 if (nativeForEach && obj.forEach === nativeForEach) {
23045 obj.forEach(iterator, context);
23046 } else if (obj.length === +obj.length) {
23047 for (var i = 0, l = obj.length; i < l; i++) {
23048 if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
23049 return;
23050 }
23051 }
23052 } else {
23053 for (var key in obj) {
23054 if (hasOwnProperty.call(obj, key)) {
23055 if (iterator.call(context, obj[key], key, obj) === breaker) {
23056 return;
23057 }
23058 }
23059 }
23060 }
23061 };
23062
23063 _.extend = function(obj) {
23064 _.each(slice.call(arguments, 1), function(source) {
23065 for (var prop in source) {
23066 if (source[prop] !== void 0) {
23067 obj[prop] = source[prop];
23068 }
23069 }
23070 });
23071 return obj;
23072 };
23073
23074 _.isArray = nativeIsArray || function(obj) {
23075 return toString.call(obj) === '[object Array]';
23076 };
23077
23078 // from a comment on http://dbj.org/dbj/?p=286
23079 // fails on only one very rare and deliberate custom object:
23080 // var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
23081 _.isFunction = function(f) {
23082 try {
23083 return /^\s*\bfunction\b/.test(f);
23084 } catch (x) {
23085 return false;
23086 }
23087 };
23088
23089 _.isArguments = function(obj) {
23090 return !!(obj && hasOwnProperty.call(obj, 'callee'));
23091 };
23092
23093 _.toArray = function(iterable) {
23094 if (!iterable) {
23095 return [];
23096 }
23097 if (iterable.toArray) {
23098 return iterable.toArray();
23099 }
23100 if (_.isArray(iterable)) {
23101 return slice.call(iterable);
23102 }
23103 if (_.isArguments(iterable)) {
23104 return slice.call(iterable);
23105 }
23106 return _.values(iterable);
23107 };
23108
23109 _.map = function(arr, callback, context) {
23110 if (nativeMap && arr.map === nativeMap) {
23111 return arr.map(callback, context);
23112 } else {
23113 var results = [];
23114 _.each(arr, function(item) {
23115 results.push(callback.call(context, item));
23116 });
23117 return results;
23118 }
23119 };
23120
23121 _.keys = function(obj) {
23122 var results = [];
23123 if (obj === null) {
23124 return results;
23125 }
23126 _.each(obj, function(value, key) {
23127 results[results.length] = key;
23128 });
23129 return results;
23130 };
23131
23132 _.values = function(obj) {
23133 var results = [];
23134 if (obj === null) {
23135 return results;
23136 }
23137 _.each(obj, function(value) {
23138 results[results.length] = value;
23139 });
23140 return results;
23141 };
23142
23143 _.include = function(obj, target) {
23144 var found = false;
23145 if (obj === null) {
23146 return found;
23147 }
23148 if (nativeIndexOf && obj.indexOf === nativeIndexOf) {
23149 return obj.indexOf(target) != -1;
23150 }
23151 _.each(obj, function(value) {
23152 if (found || (found = (value === target))) {
23153 return breaker;
23154 }
23155 });
23156 return found;
23157 };
23158
23159 _.includes = function(str, needle) {
23160 return str.indexOf(needle) !== -1;
23161 };
23162
23163 // Underscore Addons
23164 _.inherit = function(subclass, superclass) {
23165 subclass.prototype = new superclass();
23166 subclass.prototype.constructor = subclass;
23167 subclass.superclass = superclass.prototype;
23168 return subclass;
23169 };
23170
23171 _.isObject = function(obj) {
23172 return (obj === Object(obj) && !_.isArray(obj));
23173 };
23174
23175 _.isEmptyObject = function(obj) {
23176 if (_.isObject(obj)) {
23177 for (var key in obj) {
23178 if (hasOwnProperty.call(obj, key)) {
23179 return false;
23180 }
23181 }
23182 return true;
23183 }
23184 return false;
23185 };
23186
23187 _.isUndefined = function(obj) {
23188 return obj === void 0;
23189 };
23190
23191 _.isString = function(obj) {
23192 return toString.call(obj) == '[object String]';
23193 };
23194
23195 _.isDate = function(obj) {
23196 return toString.call(obj) == '[object Date]';
23197 };
23198
23199 _.isNumber = function(obj) {
23200 return toString.call(obj) == '[object Number]';
23201 };
23202
23203 _.isElement = function(obj) {
23204 return !!(obj && obj.nodeType === 1);
23205 };
23206
23207 _.encodeDates = function(obj) {
23208 _.each(obj, function(v, k) {
23209 if (_.isDate(v)) {
23210 obj[k] = _.formatDate(v);
23211 } else if (_.isObject(v)) {
23212 obj[k] = _.encodeDates(v); // recurse
23213 }
23214 });
23215 return obj;
23216 };
23217
23218 _.timestamp = function() {
23219 Date.now = Date.now || function() {
23220 return +new Date;
23221 };
23222 return Date.now();
23223 };
23224
23225 _.formatDate = function(d) {
23226 // YYYY-MM-DDTHH:MM:SS in UTC
23227 function pad(n) {
23228 return n < 10 ? '0' + n : n;
23229 }
23230 return d.getUTCFullYear() + '-' +
23231 pad(d.getUTCMonth() + 1) + '-' +
23232 pad(d.getUTCDate()) + 'T' +
23233 pad(d.getUTCHours()) + ':' +
23234 pad(d.getUTCMinutes()) + ':' +
23235 pad(d.getUTCSeconds());
23236 };
23237
23238 _.strip_empty_properties = function(p) {
23239 var ret = {};
23240 _.each(p, function(v, k) {
23241 if (_.isString(v) && v.length > 0) {
23242 ret[k] = v;
23243 }
23244 });
23245 return ret;
23246 };
23247
23248 /*
23249 * this function returns a copy of object after truncating it. If
23250 * passed an Array or Object it will iterate through obj and
23251 * truncate all the values recursively.
23252 */
23253 _.truncate = function(obj, length) {
23254 var ret;
23255
23256 if (typeof(obj) === 'string') {
23257 ret = obj.slice(0, length);
23258 } else if (_.isArray(obj)) {
23259 ret = [];
23260 _.each(obj, function(val) {
23261 ret.push(_.truncate(val, length));
23262 });
23263 } else if (_.isObject(obj)) {
23264 ret = {};
23265 _.each(obj, function(val, key) {
23266 ret[key] = _.truncate(val, length);
23267 });
23268 } else {
23269 ret = obj;
23270 }
23271
23272 return ret;
23273 };
23274
23275 _.JSONEncode = (function() {
23276 return function(mixed_val) {
23277 var value = mixed_val;
23278 var quote = function(string) {
23279 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
23280 var meta = { // table of character substitutions
23281 '\b': '\\b',
23282 '\t': '\\t',
23283 '\n': '\\n',
23284 '\f': '\\f',
23285 '\r': '\\r',
23286 '"': '\\"',
23287 '\\': '\\\\'
23288 };
23289
23290 escapable.lastIndex = 0;
23291 return escapable.test(string) ?
23292 '"' + string.replace(escapable, function(a) {
23293 var c = meta[a];
23294 return typeof c === 'string' ? c :
23295 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
23296 }) + '"' :
23297 '"' + string + '"';
23298 };
23299
23300 var str = function(key, holder) {
23301 var gap = '';
23302 var indent = ' ';
23303 var i = 0; // The loop counter.
23304 var k = ''; // The member key.
23305 var v = ''; // The member value.
23306 var length = 0;
23307 var mind = gap;
23308 var partial = [];
23309 var value = holder[key];
23310
23311 // If the value has a toJSON method, call it to obtain a replacement value.
23312 if (value && typeof value === 'object' &&
23313 typeof value.toJSON === 'function') {
23314 value = value.toJSON(key);
23315 }
23316
23317 // What happens next depends on the value's type.
23318 switch (typeof value) {
23319 case 'string':
23320 return quote(value);
23321
23322 case 'number':
23323 // JSON numbers must be finite. Encode non-finite numbers as null.
23324 return isFinite(value) ? String(value) : 'null';
23325
23326 case 'boolean':
23327 case 'null':
23328 // If the value is a boolean or null, convert it to a string. Note:
23329 // typeof null does not produce 'null'. The case is included here in
23330 // the remote chance that this gets fixed someday.
23331
23332 return String(value);
23333
23334 case 'object':
23335 // If the type is 'object', we might be dealing with an object or an array or
23336 // null.
23337 // Due to a specification blunder in ECMAScript, typeof null is 'object',
23338 // so watch out for that case.
23339 if (!value) {
23340 return 'null';
23341 }
23342
23343 // Make an array to hold the partial results of stringifying this object value.
23344 gap += indent;
23345 partial = [];
23346
23347 // Is the value an array?
23348 if (toString.apply(value) === '[object Array]') {
23349 // The value is an array. Stringify every element. Use null as a placeholder
23350 // for non-JSON values.
23351
23352 length = value.length;
23353 for (i = 0; i < length; i += 1) {
23354 partial[i] = str(i, value) || 'null';
23355 }
23356
23357 // Join all of the elements together, separated with commas, and wrap them in
23358 // brackets.
23359 v = partial.length === 0 ? '[]' :
23360 gap ? '[\n' + gap +
23361 partial.join(',\n' + gap) + '\n' +
23362 mind + ']' :
23363 '[' + partial.join(',') + ']';
23364 gap = mind;
23365 return v;
23366 }
23367
23368 // Iterate through all of the keys in the object.
23369 for (k in value) {
23370 if (hasOwnProperty.call(value, k)) {
23371 v = str(k, value);
23372 if (v) {
23373 partial.push(quote(k) + (gap ? ': ' : ':') + v);
23374 }
23375 }
23376 }
23377
23378 // Join all of the member texts together, separated with commas,
23379 // and wrap them in braces.
23380 v = partial.length === 0 ? '{}' :
23381 gap ? '{' + partial.join(',') + '' +
23382 mind + '}' : '{' + partial.join(',') + '}';
23383 gap = mind;
23384 return v;
23385 }
23386 };
23387
23388 // Make a fake root object containing our value under the key of ''.
23389 // Return the result of stringifying the value.
23390 return str('', {
23391 '': value
23392 });
23393 };
23394 })();
23395
23396 /**
23397 * From https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
23398 * Slightly modified to throw a real Error rather than a POJO
23399 */
23400 _.JSONDecode = (function() {
23401 var at, // The index of the current character
23402 ch, // The current character
23403 escapee = {
23404 '"': '"',
23405 '\\': '\\',
23406 '/': '/',
23407 'b': '\b',
23408 'f': '\f',
23409 'n': '\n',
23410 'r': '\r',
23411 't': '\t'
23412 },
23413 text,
23414 error = function(m) {
23415 var e = new SyntaxError(m);
23416 e.at = at;
23417 e.text = text;
23418 throw e;
23419 },
23420 next = function(c) {
23421 // If a c parameter is provided, verify that it matches the current character.
23422 if (c && c !== ch) {
23423 error('Expected \'' + c + '\' instead of \'' + ch + '\'');
23424 }
23425 // Get the next character. When there are no more characters,
23426 // return the empty string.
23427 ch = text.charAt(at);
23428 at += 1;
23429 return ch;
23430 },
23431 number = function() {
23432 // Parse a number value.
23433 var number,
23434 string = '';
23435
23436 if (ch === '-') {
23437 string = '-';
23438 next('-');
23439 }
23440 while (ch >= '0' && ch <= '9') {
23441 string += ch;
23442 next();
23443 }
23444 if (ch === '.') {
23445 string += '.';
23446 while (next() && ch >= '0' && ch <= '9') {
23447 string += ch;
23448 }
23449 }
23450 if (ch === 'e' || ch === 'E') {
23451 string += ch;
23452 next();
23453 if (ch === '-' || ch === '+') {
23454 string += ch;
23455 next();
23456 }
23457 while (ch >= '0' && ch <= '9') {
23458 string += ch;
23459 next();
23460 }
23461 }
23462 number = +string;
23463 if (!isFinite(number)) {
23464 error('Bad number');
23465 } else {
23466 return number;
23467 }
23468 },
23469
23470 string = function() {
23471 // Parse a string value.
23472 var hex,
23473 i,
23474 string = '',
23475 uffff;
23476 // When parsing for string values, we must look for " and \ characters.
23477 if (ch === '"') {
23478 while (next()) {
23479 if (ch === '"') {
23480 next();
23481 return string;
23482 }
23483 if (ch === '\\') {
23484 next();
23485 if (ch === 'u') {
23486 uffff = 0;
23487 for (i = 0; i < 4; i += 1) {
23488 hex = parseInt(next(), 16);
23489 if (!isFinite(hex)) {
23490 break;
23491 }
23492 uffff = uffff * 16 + hex;
23493 }
23494 string += String.fromCharCode(uffff);
23495 } else if (typeof escapee[ch] === 'string') {
23496 string += escapee[ch];
23497 } else {
23498 break;
23499 }
23500 } else {
23501 string += ch;
23502 }
23503 }
23504 }
23505 error('Bad string');
23506 },
23507 white = function() {
23508 // Skip whitespace.
23509 while (ch && ch <= ' ') {
23510 next();
23511 }
23512 },
23513 word = function() {
23514 // true, false, or null.
23515 switch (ch) {
23516 case 't':
23517 next('t');
23518 next('r');
23519 next('u');
23520 next('e');
23521 return true;
23522 case 'f':
23523 next('f');
23524 next('a');
23525 next('l');
23526 next('s');
23527 next('e');
23528 return false;
23529 case 'n':
23530 next('n');
23531 next('u');
23532 next('l');
23533 next('l');
23534 return null;
23535 }
23536 error('Unexpected "' + ch + '"');
23537 },
23538 value, // Placeholder for the value function.
23539 array = function() {
23540 // Parse an array value.
23541 var array = [];
23542
23543 if (ch === '[') {
23544 next('[');
23545 white();
23546 if (ch === ']') {
23547 next(']');
23548 return array; // empty array
23549 }
23550 while (ch) {
23551 array.push(value());
23552 white();
23553 if (ch === ']') {
23554 next(']');
23555 return array;
23556 }
23557 next(',');
23558 white();
23559 }
23560 }
23561 error('Bad array');
23562 },
23563 object = function() {
23564 // Parse an object value.
23565 var key,
23566 object = {};
23567
23568 if (ch === '{') {
23569 next('{');
23570 white();
23571 if (ch === '}') {
23572 next('}');
23573 return object; // empty object
23574 }
23575 while (ch) {
23576 key = string();
23577 white();
23578 next(':');
23579 if (Object.hasOwnProperty.call(object, key)) {
23580 error('Duplicate key "' + key + '"');
23581 }
23582 object[key] = value();
23583 white();
23584 if (ch === '}') {
23585 next('}');
23586 return object;
23587 }
23588 next(',');
23589 white();
23590 }
23591 }
23592 error('Bad object');
23593 };
23594
23595 value = function() {
23596 // Parse a JSON value. It could be an object, an array, a string,
23597 // a number, or a word.
23598 white();
23599 switch (ch) {
23600 case '{':
23601 return object();
23602 case '[':
23603 return array();
23604 case '"':
23605 return string();
23606 case '-':
23607 return number();
23608 default:
23609 return ch >= '0' && ch <= '9' ? number() : word();
23610 }
23611 };
23612
23613 // Return the json_parse function. It will have access to all of the
23614 // above functions and variables.
23615 return function(source) {
23616 var result;
23617
23618 text = source;
23619 at = 0;
23620 ch = ' ';
23621 result = value();
23622 white();
23623 if (ch) {
23624 error('Syntax error');
23625 }
23626
23627 return result;
23628 };
23629 })();
23630
23631 _.base64Encode = function(data) {
23632 var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
23633 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
23634 ac = 0,
23635 enc = '',
23636 tmp_arr = [];
23637
23638 if (!data) {
23639 return data;
23640 }
23641
23642 data = _.utf8Encode(data);
23643
23644 do { // pack three octets into four hexets
23645 o1 = data.charCodeAt(i++);
23646 o2 = data.charCodeAt(i++);
23647 o3 = data.charCodeAt(i++);
23648
23649 bits = o1 << 16 | o2 << 8 | o3;
23650
23651 h1 = bits >> 18 & 0x3f;
23652 h2 = bits >> 12 & 0x3f;
23653 h3 = bits >> 6 & 0x3f;
23654 h4 = bits & 0x3f;
23655
23656 // use hexets to index into b64, and append result to encoded string
23657 tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
23658 } while (i < data.length);
23659
23660 enc = tmp_arr.join('');
23661
23662 switch (data.length % 3) {
23663 case 1:
23664 enc = enc.slice(0, -2) + '==';
23665 break;
23666 case 2:
23667 enc = enc.slice(0, -1) + '=';
23668 break;
23669 }
23670
23671 return enc;
23672 };
23673
23674 _.utf8Encode = function(string) {
23675 string = (string + '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
23676
23677 var utftext = '',
23678 start,
23679 end;
23680 var stringl = 0,
23681 n;
23682
23683 start = end = 0;
23684 stringl = string.length;
23685
23686 for (n = 0; n < stringl; n++) {
23687 var c1 = string.charCodeAt(n);
23688 var enc = null;
23689
23690 if (c1 < 128) {
23691 end++;
23692 } else if ((c1 > 127) && (c1 < 2048)) {
23693 enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128);
23694 } else {
23695 enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128);
23696 }
23697 if (enc !== null) {
23698 if (end > start) {
23699 utftext += string.substring(start, end);
23700 }
23701 utftext += enc;
23702 start = end = n + 1;
23703 }
23704 }
23705
23706 if (end > start) {
23707 utftext += string.substring(start, string.length);
23708 }
23709
23710 return utftext;
23711 };
23712
23713 _.UUID = function() {
23714 try {
23715 // use native Crypto API when available
23716 return win['crypto']['randomUUID']();
23717 } catch (err) {
23718 // fall back to generating our own UUID
23719 // based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
23720 var uuid = new Array(36);
23721 for (var i = 0; i < 36; i++) {
23722 uuid[i] = Math.floor(Math.random() * 16);
23723 }
23724 uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
23725 uuid[19] = uuid[19] &= -5; // set bit 6 of clock-seq-and-reserved to zero
23726 uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
23727 uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
23728
23729 return _.map(uuid, function(x) {
23730 return x.toString(16);
23731 }).join('');
23732 }
23733 };
23734
23735 // _.isBlockedUA()
23736 // This is to block various web spiders from executing our JS and
23737 // sending false tracking data
23738 var BLOCKED_UA_STRS = [
23739 'ahrefsbot',
23740 'ahrefssiteaudit',
23741 'amazonbot',
23742 'baiduspider',
23743 'bingbot',
23744 'bingpreview',
23745 'chrome-lighthouse',
23746 'facebookexternal',
23747 'petalbot',
23748 'pinterest',
23749 'screaming frog',
23750 'yahoo! slurp',
23751 'yandex',
23752
23753 // a whole bunch of goog-specific crawlers
23754 // https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
23755 'adsbot-google',
23756 'apis-google',
23757 'duplexweb-google',
23758 'feedfetcher-google',
23759 'google favicon',
23760 'google web preview',
23761 'google-read-aloud',
23762 'googlebot',
23763 'googleweblight',
23764 'mediapartners-google',
23765 'storebot-google'
23766 ];
23767 _.isBlockedUA = function(ua) {
23768 var i;
23769 ua = ua.toLowerCase();
23770 for (i = 0; i < BLOCKED_UA_STRS.length; i++) {
23771 if (ua.indexOf(BLOCKED_UA_STRS[i]) !== -1) {
23772 return true;
23773 }
23774 }
23775 return false;
23776 };
23777
23778 /**
23779 * @param {Object=} formdata
23780 * @param {string=} arg_separator
23781 */
23782 _.HTTPBuildQuery = function(formdata, arg_separator) {
23783 var use_val, use_key, tmp_arr = [];
23784
23785 if (_.isUndefined(arg_separator)) {
23786 arg_separator = '&';
23787 }
23788
23789 _.each(formdata, function(val, key) {
23790 use_val = encodeURIComponent(val.toString());
23791 use_key = encodeURIComponent(key);
23792 tmp_arr[tmp_arr.length] = use_key + '=' + use_val;
23793 });
23794
23795 return tmp_arr.join(arg_separator);
23796 };
23797
23798 _.getQueryParam = function(url, param) {
23799 // Expects a raw URL
23800
23801 param = param.replace(/[[]/g, '\\[').replace(/[\]]/g, '\\]');
23802 var regexS = '[\\?&]' + param + '=([^&#]*)',
23803 regex = new RegExp(regexS),
23804 results = regex.exec(url);
23805 if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
23806 return '';
23807 } else {
23808 var result = results[1];
23809 try {
23810 result = decodeURIComponent(result);
23811 } catch(err) {
23812 console$1.error('Skipping decoding for malformed query param: ' + result);
23813 }
23814 return result.replace(/\+/g, ' ');
23815 }
23816 };
23817
23818
23819 // _.cookie
23820 // Methods partially borrowed from quirksmode.org/js/cookies.html
23821 _.cookie = {
23822 get: function(name) {
23823 var nameEQ = name + '=';
23824 var ca = document$1.cookie.split(';');
23825 for (var i = 0; i < ca.length; i++) {
23826 var c = ca[i];
23827 while (c.charAt(0) == ' ') {
23828 c = c.substring(1, c.length);
23829 }
23830 if (c.indexOf(nameEQ) === 0) {
23831 return decodeURIComponent(c.substring(nameEQ.length, c.length));
23832 }
23833 }
23834 return null;
23835 },
23836
23837 parse: function(name) {
23838 var cookie;
23839 try {
23840 cookie = _.JSONDecode(_.cookie.get(name)) || {};
23841 } catch (err) {
23842 // noop
23843 }
23844 return cookie;
23845 },
23846
23847 set_seconds: function(name, value, seconds, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23848 var cdomain = '',
23849 expires = '',
23850 secure = '';
23851
23852 if (domain_override) {
23853 cdomain = '; domain=' + domain_override;
23854 } else if (is_cross_subdomain) {
23855 var domain = extract_domain(document$1.location.hostname);
23856 cdomain = domain ? '; domain=.' + domain : '';
23857 }
23858
23859 if (seconds) {
23860 var date = new Date();
23861 date.setTime(date.getTime() + (seconds * 1000));
23862 expires = '; expires=' + date.toGMTString();
23863 }
23864
23865 if (is_cross_site) {
23866 is_secure = true;
23867 secure = '; SameSite=None';
23868 }
23869 if (is_secure) {
23870 secure += '; secure';
23871 }
23872
23873 document$1.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23874 },
23875
23876 set: function(name, value, days, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23877 var cdomain = '', expires = '', secure = '';
23878
23879 if (domain_override) {
23880 cdomain = '; domain=' + domain_override;
23881 } else if (is_cross_subdomain) {
23882 var domain = extract_domain(document$1.location.hostname);
23883 cdomain = domain ? '; domain=.' + domain : '';
23884 }
23885
23886 if (days) {
23887 var date = new Date();
23888 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
23889 expires = '; expires=' + date.toGMTString();
23890 }
23891
23892 if (is_cross_site) {
23893 is_secure = true;
23894 secure = '; SameSite=None';
23895 }
23896 if (is_secure) {
23897 secure += '; secure';
23898 }
23899
23900 var new_cookie_val = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23901 document$1.cookie = new_cookie_val;
23902 return new_cookie_val;
23903 },
23904
23905 remove: function(name, is_cross_subdomain, domain_override) {
23906 _.cookie.set(name, '', -1, is_cross_subdomain, false, false, domain_override);
23907 }
23908 };
23909
23910 var _testStorageSupported = function (storage) {
23911 var supported = true;
23912 try {
23913 var key = '__mplss_' + cheap_guid(8),
23914 val = 'xyz';
23915 storage.setItem(key, val);
23916 if (storage.getItem(key) !== val) {
23917 supported = false;
23918 }
23919 storage.removeItem(key);
23920 } catch (err) {
23921 supported = false;
23922 }
23923 return supported;
23924 };
23925
23926 var _localStorageSupported = null;
23927 var localStorageSupported = function(storage, forceCheck) {
23928 if (_localStorageSupported !== null && !forceCheck) {
23929 return _localStorageSupported;
23930 }
23931 return _localStorageSupported = _testStorageSupported(storage || win.localStorage);
23932 };
23933
23934 var _sessionStorageSupported = null;
23935 var sessionStorageSupported = function(storage, forceCheck) {
23936 if (_sessionStorageSupported !== null && !forceCheck) {
23937 return _sessionStorageSupported;
23938 }
23939 return _sessionStorageSupported = _testStorageSupported(storage || win.sessionStorage);
23940 };
23941
23942 function _storageWrapper(storage, name, is_supported_fn) {
23943 var log_error = function(msg) {
23944 console$1.error(name + ' error: ' + msg);
23945 };
23946
23947 return {
23948 is_supported: function(forceCheck) {
23949 var supported = is_supported_fn(storage, forceCheck);
23950 if (!supported) {
23951 console$1.error(name + ' unsupported');
23952 }
23953 return supported;
23954 },
23955 error: log_error,
23956 get: function(key) {
23957 try {
23958 return storage.getItem(key);
23959 } catch (err) {
23960 log_error(err);
23961 }
23962 return null;
23963 },
23964 parse: function(key) {
23965 try {
23966 return _.JSONDecode(storage.getItem(key)) || {};
23967 } catch (err) {
23968 // noop
23969 }
23970 return null;
23971 },
23972 set: function(key, value) {
23973 try {
23974 storage.setItem(key, value);
23975 } catch (err) {
23976 log_error(err);
23977 }
23978 },
23979 remove: function(key) {
23980 try {
23981 storage.removeItem(key);
23982 } catch (err) {
23983 log_error(err);
23984 }
23985 }
23986 };
23987 }
23988
23989 _.localStorage = _storageWrapper(win.localStorage, 'localStorage', localStorageSupported);
23990 _.sessionStorage = _storageWrapper(win.sessionStorage, 'sessionStorage', sessionStorageSupported);
23991
23992 _.register_event = (function() {
23993 // written by Dean Edwards, 2005
23994 // with input from Tino Zijdel - crisp@xs4all.nl
23995 // with input from Carl Sverre - mail@carlsverre.com
23996 // with input from Mixpanel
23997 // http://dean.edwards.name/weblog/2005/10/add-event/
23998 // https://gist.github.com/1930440
23999
24000 /**
24001 * @param {Object} element
24002 * @param {string} type
24003 * @param {function(...*)} handler
24004 * @param {boolean=} oldSchool
24005 * @param {boolean=} useCapture
24006 */
24007 var register_event = function(element, type, handler, oldSchool, useCapture) {
24008 if (!element) {
24009 console$1.error('No valid element provided to register_event');
24010 return;
24011 }
24012
24013 if (element.addEventListener && !oldSchool) {
24014 element.addEventListener(type, handler, !!useCapture);
24015 } else {
24016 var ontype = 'on' + type;
24017 var old_handler = element[ontype]; // can be undefined
24018 element[ontype] = makeHandler(element, handler, old_handler);
24019 }
24020 };
24021
24022 function makeHandler(element, new_handler, old_handlers) {
24023 var handler = function(event) {
24024 event = event || fixEvent(win.event);
24025
24026 // this basically happens in firefox whenever another script
24027 // overwrites the onload callback and doesn't pass the event
24028 // object to previously defined callbacks. All the browsers
24029 // that don't define window.event implement addEventListener
24030 // so the dom_loaded handler will still be fired as usual.
24031 if (!event) {
24032 return undefined;
24033 }
24034
24035 var ret = true;
24036 var old_result, new_result;
24037
24038 if (_.isFunction(old_handlers)) {
24039 old_result = old_handlers(event);
24040 }
24041 new_result = new_handler.call(element, event);
24042
24043 if ((false === old_result) || (false === new_result)) {
24044 ret = false;
24045 }
24046
24047 return ret;
24048 };
24049
24050 return handler;
24051 }
24052
24053 function fixEvent(event) {
24054 if (event) {
24055 event.preventDefault = fixEvent.preventDefault;
24056 event.stopPropagation = fixEvent.stopPropagation;
24057 }
24058 return event;
24059 }
24060 fixEvent.preventDefault = function() {
24061 this.returnValue = false;
24062 };
24063 fixEvent.stopPropagation = function() {
24064 this.cancelBubble = true;
24065 };
24066
24067 return register_event;
24068 })();
24069
24070
24071 var TOKEN_MATCH_REGEX = new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');
24072
24073 _.dom_query = (function() {
24074 /* document.getElementsBySelector(selector)
24075 - returns an array of element objects from the current document
24076 matching the CSS selector. Selectors can contain element names,
24077 class names and ids and can be nested. For example:
24078
24079 elements = document.getElementsBySelector('div#main p a.external')
24080
24081 Will return an array of all 'a' elements with 'external' in their
24082 class attribute that are contained inside 'p' elements that are
24083 contained inside the 'div' element which has id="main"
24084
24085 New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
24086 See http://www.w3.org/TR/css3-selectors/#attribute-selectors
24087
24088 Version 0.4 - Simon Willison, March 25th 2003
24089 -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
24090 -- Opera 7 fails
24091
24092 Version 0.5 - Carl Sverre, Jan 7th 2013
24093 -- Now uses jQuery-esque `hasClass` for testing class name
24094 equality. This fixes a bug related to '-' characters being
24095 considered not part of a 'word' in regex.
24096 */
24097
24098 function getAllChildren(e) {
24099 // Returns all children of element. Workaround required for IE5/Windows. Ugh.
24100 return e.all ? e.all : e.getElementsByTagName('*');
24101 }
24102
24103 var bad_whitespace = /[\t\r\n]/g;
24104
24105 function hasClass(elem, selector) {
24106 var className = ' ' + selector + ' ';
24107 return ((' ' + elem.className + ' ').replace(bad_whitespace, ' ').indexOf(className) >= 0);
24108 }
24109
24110 function getElementsBySelector(selector) {
24111 // Attempt to fail gracefully in lesser browsers
24112 if (!document$1.getElementsByTagName) {
24113 return [];
24114 }
24115 // Split selector in to tokens
24116 var tokens = selector.split(' ');
24117 var token, bits, tagName, found, foundCount, i, j, k, elements, currentContextIndex;
24118 var currentContext = [document$1];
24119 for (i = 0; i < tokens.length; i++) {
24120 token = tokens[i].replace(/^\s+/, '').replace(/\s+$/, '');
24121 if (token.indexOf('#') > -1) {
24122 // Token is an ID selector
24123 bits = token.split('#');
24124 tagName = bits[0];
24125 var id = bits[1];
24126 var element = document$1.getElementById(id);
24127 if (!element || (tagName && element.nodeName.toLowerCase() != tagName)) {
24128 // element not found or tag with that ID not found, return false
24129 return [];
24130 }
24131 // Set currentContext to contain just this element
24132 currentContext = [element];
24133 continue; // Skip to next token
24134 }
24135 if (token.indexOf('.') > -1) {
24136 // Token contains a class selector
24137 bits = token.split('.');
24138 tagName = bits[0];
24139 var className = bits[1];
24140 if (!tagName) {
24141 tagName = '*';
24142 }
24143 // Get elements matching tag, filter them for class selector
24144 found = [];
24145 foundCount = 0;
24146 for (j = 0; j < currentContext.length; j++) {
24147 if (tagName == '*') {
24148 elements = getAllChildren(currentContext[j]);
24149 } else {
24150 elements = currentContext[j].getElementsByTagName(tagName);
24151 }
24152 for (k = 0; k < elements.length; k++) {
24153 found[foundCount++] = elements[k];
24154 }
24155 }
24156 currentContext = [];
24157 currentContextIndex = 0;
24158 for (j = 0; j < found.length; j++) {
24159 if (found[j].className &&
24160 _.isString(found[j].className) && // some SVG elements have classNames which are not strings
24161 hasClass(found[j], className)
24162 ) {
24163 currentContext[currentContextIndex++] = found[j];
24164 }
24165 }
24166 continue; // Skip to next token
24167 }
24168 // Code to deal with attribute selectors
24169 var token_match = token.match(TOKEN_MATCH_REGEX);
24170 if (token_match) {
24171 tagName = token_match[1];
24172 var attrName = token_match[2];
24173 var attrOperator = token_match[3];
24174 var attrValue = token_match[4];
24175 if (!tagName) {
24176 tagName = '*';
24177 }
24178 // Grab all of the tagName elements within current context
24179 found = [];
24180 foundCount = 0;
24181 for (j = 0; j < currentContext.length; j++) {
24182 if (tagName == '*') {
24183 elements = getAllChildren(currentContext[j]);
24184 } else {
24185 elements = currentContext[j].getElementsByTagName(tagName);
24186 }
24187 for (k = 0; k < elements.length; k++) {
24188 found[foundCount++] = elements[k];
24189 }
24190 }
24191 currentContext = [];
24192 currentContextIndex = 0;
24193 var checkFunction; // This function will be used to filter the elements
24194 switch (attrOperator) {
24195 case '=': // Equality
24196 checkFunction = function(e) {
24197 return (e.getAttribute(attrName) == attrValue);
24198 };
24199 break;
24200 case '~': // Match one of space seperated words
24201 checkFunction = function(e) {
24202 return (e.getAttribute(attrName).match(new RegExp('\\b' + attrValue + '\\b')));
24203 };
24204 break;
24205 case '|': // Match start with value followed by optional hyphen
24206 checkFunction = function(e) {
24207 return (e.getAttribute(attrName).match(new RegExp('^' + attrValue + '-?')));
24208 };
24209 break;
24210 case '^': // Match starts with value
24211 checkFunction = function(e) {
24212 return (e.getAttribute(attrName).indexOf(attrValue) === 0);
24213 };
24214 break;
24215 case '$': // Match ends with value - fails with "Warning" in Opera 7
24216 checkFunction = function(e) {
24217 return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length);
24218 };
24219 break;
24220 case '*': // Match ends with value
24221 checkFunction = function(e) {
24222 return (e.getAttribute(attrName).indexOf(attrValue) > -1);
24223 };
24224 break;
24225 default:
24226 // Just test for existence of attribute
24227 checkFunction = function(e) {
24228 return e.getAttribute(attrName);
24229 };
24230 }
24231 currentContext = [];
24232 currentContextIndex = 0;
24233 for (j = 0; j < found.length; j++) {
24234 if (checkFunction(found[j])) {
24235 currentContext[currentContextIndex++] = found[j];
24236 }
24237 }
24238 // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
24239 continue; // Skip to next token
24240 }
24241 // If we get here, token is JUST an element (not a class or ID selector)
24242 tagName = token;
24243 found = [];
24244 foundCount = 0;
24245 for (j = 0; j < currentContext.length; j++) {
24246 elements = currentContext[j].getElementsByTagName(tagName);
24247 for (k = 0; k < elements.length; k++) {
24248 found[foundCount++] = elements[k];
24249 }
24250 }
24251 currentContext = found;
24252 }
24253 return currentContext;
24254 }
24255
24256 return function(query) {
24257 if (_.isElement(query)) {
24258 return [query];
24259 } else if (_.isObject(query) && !_.isUndefined(query.length)) {
24260 return query;
24261 } else {
24262 return getElementsBySelector.call(this, query);
24263 }
24264 };
24265 })();
24266
24267 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'];
24268 var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'sccid', 'ttclid', 'twclid', 'wbraid'];
24269
24270 _.info = {
24271 campaignParams: function(default_value) {
24272 var kw = '',
24273 params = {};
24274 _.each(CAMPAIGN_KEYWORDS, function(kwkey) {
24275 kw = _.getQueryParam(document$1.URL, kwkey);
24276 if (kw.length) {
24277 params[kwkey] = kw;
24278 } else if (default_value !== undefined) {
24279 params[kwkey] = default_value;
24280 }
24281 });
24282
24283 return params;
24284 },
24285
24286 clickParams: function() {
24287 var id = '',
24288 params = {};
24289 _.each(CLICK_IDS, function(idkey) {
24290 id = _.getQueryParam(document$1.URL, idkey);
24291 if (id.length) {
24292 params[idkey] = id;
24293 }
24294 });
24295
24296 return params;
24297 },
24298
24299 marketingParams: function() {
24300 return _.extend(_.info.campaignParams(), _.info.clickParams());
24301 },
24302
24303 searchEngine: function(referrer) {
24304 if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
24305 return 'google';
24306 } else if (referrer.search('https?://(.*)bing.com') === 0) {
24307 return 'bing';
24308 } else if (referrer.search('https?://(.*)yahoo.com') === 0) {
24309 return 'yahoo';
24310 } else if (referrer.search('https?://(.*)duckduckgo.com') === 0) {
24311 return 'duckduckgo';
24312 } else {
24313 return null;
24314 }
24315 },
24316
24317 searchInfo: function(referrer) {
24318 var search = _.info.searchEngine(referrer),
24319 param = (search != 'yahoo') ? 'q' : 'p',
24320 ret = {};
24321
24322 if (search !== null) {
24323 ret['$search_engine'] = search;
24324
24325 var keyword = _.getQueryParam(referrer, param);
24326 if (keyword.length) {
24327 ret['mp_keyword'] = keyword;
24328 }
24329 }
24330
24331 return ret;
24332 },
24333
24334 /**
24335 * This function detects which browser is running this script.
24336 * The order of the checks are important since many user agents
24337 * include key words used in later checks.
24338 */
24339 browser: function(user_agent, vendor, opera) {
24340 vendor = vendor || ''; // vendor is undefined for at least IE9
24341 if (opera || _.includes(user_agent, ' OPR/')) {
24342 if (_.includes(user_agent, 'Mini')) {
24343 return 'Opera Mini';
24344 }
24345 return 'Opera';
24346 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
24347 return 'BlackBerry';
24348 } else if (_.includes(user_agent, 'IEMobile') || _.includes(user_agent, 'WPDesktop')) {
24349 return 'Internet Explorer Mobile';
24350 } else if (_.includes(user_agent, 'SamsungBrowser/')) {
24351 // https://developer.samsung.com/internet/user-agent-string-format
24352 return 'Samsung Internet';
24353 } else if (_.includes(user_agent, 'Edge') || _.includes(user_agent, 'Edg/')) {
24354 return 'Microsoft Edge';
24355 } else if (_.includes(user_agent, 'FBIOS')) {
24356 return 'Facebook Mobile';
24357 } else if (_.includes(user_agent, 'Whale/')) {
24358 // https://user-agents.net/browsers/whale-browser
24359 return 'Whale Browser';
24360 } else if (_.includes(user_agent, 'Chrome')) {
24361 return 'Chrome';
24362 } else if (_.includes(user_agent, 'CriOS')) {
24363 return 'Chrome iOS';
24364 } else if (_.includes(user_agent, 'UCWEB') || _.includes(user_agent, 'UCBrowser')) {
24365 return 'UC Browser';
24366 } else if (_.includes(user_agent, 'FxiOS')) {
24367 return 'Firefox iOS';
24368 } else if (_.includes(vendor, 'Apple')) {
24369 if (_.includes(user_agent, 'Mobile')) {
24370 return 'Mobile Safari';
24371 }
24372 return 'Safari';
24373 } else if (_.includes(user_agent, 'Android')) {
24374 return 'Android Mobile';
24375 } else if (_.includes(user_agent, 'Konqueror')) {
24376 return 'Konqueror';
24377 } else if (_.includes(user_agent, 'Firefox')) {
24378 return 'Firefox';
24379 } else if (_.includes(user_agent, 'MSIE') || _.includes(user_agent, 'Trident/')) {
24380 return 'Internet Explorer';
24381 } else if (_.includes(user_agent, 'Gecko')) {
24382 return 'Mozilla';
24383 } else {
24384 return '';
24385 }
24386 },
24387
24388 /**
24389 * This function detects which browser version is running this script,
24390 * parsing major and minor version (e.g., 42.1). User agent strings from:
24391 * http://www.useragentstring.com/pages/useragentstring.php
24392 */
24393 browserVersion: function(userAgent, vendor, opera) {
24394 var browser = _.info.browser(userAgent, vendor, opera);
24395 var versionRegexs = {
24396 'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/,
24397 'Microsoft Edge': /Edge?\/(\d+(\.\d+)?)/,
24398 'Chrome': /Chrome\/(\d+(\.\d+)?)/,
24399 'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/,
24400 'UC Browser' : /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,
24401 'Safari': /Version\/(\d+(\.\d+)?)/,
24402 'Mobile Safari': /Version\/(\d+(\.\d+)?)/,
24403 'Opera': /(Opera|OPR)\/(\d+(\.\d+)?)/,
24404 'Firefox': /Firefox\/(\d+(\.\d+)?)/,
24405 'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/,
24406 'Konqueror': /Konqueror:(\d+(\.\d+)?)/,
24407 'BlackBerry': /BlackBerry (\d+(\.\d+)?)/,
24408 'Android Mobile': /android\s(\d+(\.\d+)?)/,
24409 'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
24410 'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
24411 'Mozilla': /rv:(\d+(\.\d+)?)/,
24412 'Whale Browser': /Whale\/(\d+(\.\d+)?)/
24413 };
24414 var regex = versionRegexs[browser];
24415 if (regex === undefined) {
24416 return null;
24417 }
24418 var matches = userAgent.match(regex);
24419 if (!matches) {
24420 return null;
24421 }
24422 return parseFloat(matches[matches.length - 2]);
24423 },
24424
24425 os: function() {
24426 var a = userAgent;
24427 if (/Windows/i.test(a)) {
24428 if (/Phone/.test(a) || /WPDesktop/.test(a)) {
24429 return 'Windows Phone';
24430 }
24431 return 'Windows';
24432 } else if (/(iPhone|iPad|iPod)/.test(a)) {
24433 return 'iOS';
24434 } else if (/Android/.test(a)) {
24435 return 'Android';
24436 } else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {
24437 return 'BlackBerry';
24438 } else if (/Mac/i.test(a)) {
24439 return 'Mac OS X';
24440 } else if (/Linux/.test(a)) {
24441 return 'Linux';
24442 } else if (/CrOS/.test(a)) {
24443 return 'Chrome OS';
24444 } else {
24445 return '';
24446 }
24447 },
24448
24449 device: function(user_agent) {
24450 if (/Windows Phone/i.test(user_agent) || /WPDesktop/.test(user_agent)) {
24451 return 'Windows Phone';
24452 } else if (/iPad/.test(user_agent)) {
24453 return 'iPad';
24454 } else if (/iPod/.test(user_agent)) {
24455 return 'iPod Touch';
24456 } else if (/iPhone/.test(user_agent)) {
24457 return 'iPhone';
24458 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
24459 return 'BlackBerry';
24460 } else if (/Android/.test(user_agent)) {
24461 return 'Android';
24462 } else {
24463 return '';
24464 }
24465 },
24466
24467 referringDomain: function(referrer) {
24468 var split = referrer.split('/');
24469 if (split.length >= 3) {
24470 return split[2];
24471 }
24472 return '';
24473 },
24474
24475 currentUrl: function() {
24476 return win.location.href;
24477 },
24478
24479 properties: function(extra_props) {
24480 if (typeof extra_props !== 'object') {
24481 extra_props = {};
24482 }
24483 return _.extend(_.strip_empty_properties({
24484 '$os': _.info.os(),
24485 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
24486 '$referrer': document$1.referrer,
24487 '$referring_domain': _.info.referringDomain(document$1.referrer),
24488 '$device': _.info.device(userAgent)
24489 }), {
24490 '$current_url': _.info.currentUrl(),
24491 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera),
24492 '$screen_height': screen.height,
24493 '$screen_width': screen.width,
24494 'mp_lib': 'web',
24495 '$lib_version': Config.LIB_VERSION,
24496 '$insert_id': cheap_guid(),
24497 'time': _.timestamp() / 1000 // epoch time in seconds
24498 }, _.strip_empty_properties(extra_props));
24499 },
24500
24501 people_properties: function() {
24502 return _.extend(_.strip_empty_properties({
24503 '$os': _.info.os(),
24504 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera)
24505 }), {
24506 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera)
24507 });
24508 },
24509
24510 mpPageViewProperties: function() {
24511 return _.strip_empty_properties({
24512 'current_page_title': document$1.title,
24513 'current_domain': win.location.hostname,
24514 'current_url_path': win.location.pathname,
24515 'current_url_protocol': win.location.protocol,
24516 'current_url_search': win.location.search
24517 });
24518 }
24519 };
24520
24521 /**
24522 * Returns a throttled function that will only run at most every `waitMs` and returns a promise that resolves with the next invocation.
24523 * Throttled calls will build up a batch of args and invoke the callback with all args since the last invocation.
24524 */
24525 var batchedThrottle = function (fn, waitMs) {
24526 var timeoutPromise = null;
24527 var throttledItems = [];
24528 return function (item) {
24529 var self = this;
24530 throttledItems.push(item);
24531
24532 if (!timeoutPromise) {
24533 timeoutPromise = new PromisePolyfill(function (resolve) {
24534 setTimeout(function () {
24535 var returnValue = fn.apply(self, [throttledItems]);
24536 timeoutPromise = null;
24537 throttledItems = [];
24538 resolve(returnValue);
24539 }, waitMs);
24540 });
24541 }
24542 return timeoutPromise;
24543 };
24544 };
24545
24546 var cheap_guid = function(maxlen) {
24547 var guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
24548 return maxlen ? guid.substring(0, maxlen) : guid;
24549 };
24550
24551 /**
24552 * Generates a W3C traceparent header for easy interop with distributed tracing systems i.e Open Telemetry
24553 * https://www.w3.org/TR/trace-context/#traceparent-header
24554 */
24555 var generateTraceparent = function() {
24556 var traceID = _.UUID().replace(/-/g, '');
24557 var parentID = _.UUID().replace(/-/g, '').substring(0, 16);
24558
24559 // Sampled trace
24560 var traceFlags = '01';
24561
24562 return '00-' + traceID + '-' + parentID + '-' + traceFlags;
24563 };
24564
24565 // naive way to extract domain name (example.com) from full hostname (my.sub.example.com)
24566 var SIMPLE_DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]*\.[a-z]+$/i;
24567 // this next one attempts to account for some ccSLDs, e.g. extracting oxford.ac.uk from www.oxford.ac.uk
24568 var DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;
24569 /**
24570 * Attempts to extract main domain name from full hostname, using a few blunt heuristics. For
24571 * common TLDs like .com/.org that always have a simple SLD.TLD structure (example.com), we
24572 * simply extract the last two .-separated parts of the hostname (SIMPLE_DOMAIN_MATCH_REGEX).
24573 * For others, we attempt to account for short ccSLD+TLD combos (.ac.uk) with the legacy
24574 * DOMAIN_MATCH_REGEX (kept to maintain backwards compatibility with existing Mixpanel
24575 * integrations). The only _reliable_ way to extract domain from hostname is with an up-to-date
24576 * list like at https://publicsuffix.org/ so for cases that this helper fails at, the SDK
24577 * offers the 'cookie_domain' config option to set it explicitly.
24578 * @example
24579 * extract_domain('my.sub.example.com')
24580 * // 'example.com'
24581 */
24582 var extract_domain = function(hostname) {
24583 var domain_regex = DOMAIN_MATCH_REGEX;
24584 var parts = hostname.split('.');
24585 var tld = parts[parts.length - 1];
24586 if (tld.length > 4 || tld === 'com' || tld === 'org') {
24587 domain_regex = SIMPLE_DOMAIN_MATCH_REGEX;
24588 }
24589 var matches = hostname.match(domain_regex);
24590 return matches ? matches[0] : '';
24591 };
24592
24593 /**
24594 * Check whether we have network connection. default to true for browsers that don't support navigator.onLine (IE)
24595 * @returns {boolean}
24596 */
24597 var isOnline = function() {
24598 var onLine = win.navigator['onLine'];
24599 return _.isUndefined(onLine) || onLine;
24600 };
24601
24602 var NOOP_FUNC = function () {};
24603
24604 var JSONStringify = null, JSONParse = null;
24605 if (typeof JSON !== 'undefined') {
24606 JSONStringify = JSON.stringify;
24607 JSONParse = JSON.parse;
24608 }
24609 JSONStringify = JSONStringify || _.JSONEncode;
24610 JSONParse = JSONParse || _.JSONDecode;
24611
24612 // UNMINIFIED EXPORTS (for closure compiler)
24613 _['info'] = _.info;
24614 _['info']['browser'] = _.info.browser;
24615 _['info']['browserVersion'] = _.info.browserVersion;
24616 _['info']['device'] = _.info.device;
24617 _['info']['properties'] = _.info.properties;
24618 _['isBlockedUA'] = _.isBlockedUA;
24619 _['isEmptyObject'] = _.isEmptyObject;
24620 _['isObject'] = _.isObject;
24621 _['JSONDecode'] = _.JSONDecode;
24622 _['JSONEncode'] = _.JSONEncode;
24623 _['toArray'] = _.toArray;
24624 _['NPO'] = NpoPromise;
24625
24626 var MIXPANEL_DB_NAME = 'mixpanelBrowserDb';
24627
24628 var RECORDING_EVENTS_STORE_NAME = 'mixpanelRecordingEvents';
24629 var RECORDING_REGISTRY_STORE_NAME = 'mixpanelRecordingRegistry';
24630
24631 // note: increment the version number when adding new object stores
24632 var DB_VERSION = 1;
24633 var OBJECT_STORES = [RECORDING_EVENTS_STORE_NAME, RECORDING_REGISTRY_STORE_NAME];
24634
24635 /**
24636 * @type {import('./wrapper').StorageWrapper}
24637 */
24638 var IDBStorageWrapper = function (storeName) {
24639 /**
24640 * @type {Promise<IDBDatabase>|null}
24641 */
24642 this.dbPromise = null;
24643 this.storeName = storeName;
24644 };
24645
24646 IDBStorageWrapper.prototype._openDb = function () {
24647 return new PromisePolyfill(function (resolve, reject) {
24648 var openRequest = win.indexedDB.open(MIXPANEL_DB_NAME, DB_VERSION);
24649 openRequest['onerror'] = function () {
24650 reject(openRequest.error);
24651 };
24652
24653 openRequest['onsuccess'] = function () {
24654 resolve(openRequest.result);
24655 };
24656
24657 openRequest['onupgradeneeded'] = function (ev) {
24658 var db = ev.target.result;
24659
24660 OBJECT_STORES.forEach(function (storeName) {
24661 db.createObjectStore(storeName);
24662 });
24663 };
24664 });
24665 };
24666
24667 IDBStorageWrapper.prototype.init = function () {
24668 if (!win.indexedDB) {
24669 return PromisePolyfill.reject('indexedDB is not supported in this browser');
24670 }
24671
24672 if (!this.dbPromise) {
24673 this.dbPromise = this._openDb();
24674 }
24675
24676 return this.dbPromise
24677 .then(function (dbOrError) {
24678 if (dbOrError instanceof win['IDBDatabase']) {
24679 return PromisePolyfill.resolve();
24680 } else {
24681 return PromisePolyfill.reject(dbOrError);
24682 }
24683 });
24684 };
24685
24686 IDBStorageWrapper.prototype.isInitialized = function () {
24687 return !!this.dbPromise;
24688 };
24689
24690 /**
24691 * @param {IDBTransactionMode} mode
24692 * @param {function(IDBObjectStore): void} storeCb
24693 */
24694 IDBStorageWrapper.prototype.makeTransaction = function (mode, storeCb) {
24695 var storeName = this.storeName;
24696 var doTransaction = function (db) {
24697 return new PromisePolyfill(function (resolve, reject) {
24698 var transaction = db.transaction(storeName, mode);
24699 transaction.oncomplete = function () {
24700 resolve(transaction);
24701 };
24702 transaction.onabort = transaction.onerror = function () {
24703 reject(transaction.error);
24704 };
24705
24706 storeCb(transaction.objectStore(storeName));
24707 });
24708 };
24709
24710 return this.dbPromise
24711 .then(doTransaction)
24712 .catch(function (err) {
24713 if (err && err['name'] === 'InvalidStateError') {
24714 // try reopening the DB if the connection is closed
24715 this.dbPromise = this._openDb();
24716 return this.dbPromise.then(doTransaction);
24717 } else {
24718 return PromisePolyfill.reject(err);
24719 }
24720 }.bind(this));
24721 };
24722
24723 IDBStorageWrapper.prototype.setItem = function (key, value) {
24724 return this.makeTransaction('readwrite', function (objectStore) {
24725 objectStore.put(value, key);
24726 });
24727 };
24728
24729 IDBStorageWrapper.prototype.getItem = function (key) {
24730 var req;
24731 return this.makeTransaction('readonly', function (objectStore) {
24732 req = objectStore.get(key);
24733 }).then(function () {
24734 return req.result;
24735 });
24736 };
24737
24738 IDBStorageWrapper.prototype.removeItem = function (key) {
24739 return this.makeTransaction('readwrite', function (objectStore) {
24740 objectStore.delete(key);
24741 });
24742 };
24743
24744 IDBStorageWrapper.prototype.getAll = function () {
24745 var req;
24746 return this.makeTransaction('readonly', function (objectStore) {
24747 req = objectStore.getAll();
24748 }).then(function () {
24749 return req.result;
24750 });
24751 };
24752
24753 /**
24754 * GDPR utils
24755 *
24756 * The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
24757 * and privacy for all individuals within the European Union. It addresses the export of personal
24758 * data outside the EU. The GDPR aims primarily to give control back to citizens and residents
24759 * over their personal data and to simplify the regulatory environment for international business
24760 * by unifying the regulation within the EU.
24761 *
24762 * This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
24763 * These functions are used internally by the SDK and are not intended to be publicly exposed.
24764 */
24765
24766
24767 /**
24768 * A function used to track a Mixpanel event (e.g. MixpanelLib.track)
24769 * @callback trackFunction
24770 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
24771 * @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.
24772 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
24773 */
24774
24775 /** Public **/
24776
24777 var GDPR_DEFAULT_PERSISTENCE_PREFIX = '__mp_opt_in_out_';
24778
24779 /**
24780 * Opt the user in to data tracking and cookies/localstorage for the given token
24781 * @param {string} token - Mixpanel project tracking token
24782 * @param {Object} [options]
24783 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24784 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24785 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24786 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24787 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24788 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24789 * @param {string} [options.cookieDomain] - custom cookie domain
24790 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24791 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24792 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24793 */
24794 function optIn(token, options) {
24795 _optInOut(true, token, options);
24796 }
24797
24798 /**
24799 * Opt the user out of data tracking and cookies/localstorage for the given token
24800 * @param {string} token - Mixpanel project tracking token
24801 * @param {Object} [options]
24802 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24803 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24804 * @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires
24805 * @param {string} [options.cookieDomain] - custom cookie domain
24806 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24807 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not
24808 * @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not
24809 */
24810 function optOut(token, options) {
24811 _optInOut(false, token, options);
24812 }
24813
24814 /**
24815 * Check whether the user has opted in to data tracking and cookies/localstorage for the given token
24816 * @param {string} token - Mixpanel project tracking token
24817 * @param {Object} [options]
24818 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24819 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24820 * @returns {boolean} whether the user has opted in to the given opt type
24821 */
24822 function hasOptedIn(token, options) {
24823 return _getStorageValue(token, options) === '1';
24824 }
24825
24826 /**
24827 * Check whether the user has opted out of data tracking and cookies/localstorage for the given token
24828 * @param {string} token - Mixpanel project tracking token
24829 * @param {Object} [options]
24830 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24831 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24832 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24833 * @returns {boolean} whether the user has opted out of the given opt type
24834 */
24835 function hasOptedOut(token, options) {
24836 if (_hasDoNotTrackFlagOn(options)) {
24837 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"');
24838 return true;
24839 }
24840 var optedOut = _getStorageValue(token, options) === '0';
24841 if (optedOut) {
24842 console$1.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
24843 }
24844 return optedOut;
24845 }
24846
24847 /**
24848 * Wrap a MixpanelLib method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24849 * If the user has opted out, return early instead of executing the method.
24850 * If a callback argument was provided, execute it passing the 0 error code.
24851 * @param {function} method - wrapped method to be executed if the user has not opted out
24852 * @returns {*} the result of executing method OR undefined if the user has opted out
24853 */
24854 function addOptOutCheckMixpanelLib(method) {
24855 return _addOptOutCheck(method, function(name) {
24856 return this.get_config(name);
24857 });
24858 }
24859
24860 /**
24861 * Wrap a MixpanelPeople method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24862 * If the user has opted out, return early instead of executing the method.
24863 * If a callback argument was provided, execute it passing the 0 error code.
24864 * @param {function} method - wrapped method to be executed if the user has not opted out
24865 * @returns {*} the result of executing method OR undefined if the user has opted out
24866 */
24867 function addOptOutCheckMixpanelPeople(method) {
24868 return _addOptOutCheck(method, function(name) {
24869 return this._get_config(name);
24870 });
24871 }
24872
24873 /**
24874 * Wrap a MixpanelGroup method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24875 * If the user has opted out, return early instead of executing the method.
24876 * If a callback argument was provided, execute it passing the 0 error code.
24877 * @param {function} method - wrapped method to be executed if the user has not opted out
24878 * @returns {*} the result of executing method OR undefined if the user has opted out
24879 */
24880 function addOptOutCheckMixpanelGroup(method) {
24881 return _addOptOutCheck(method, function(name) {
24882 return this._get_config(name);
24883 });
24884 }
24885
24886 /**
24887 * Clear the user's opt in/out status of data tracking and cookies/localstorage for the given token
24888 * @param {string} token - Mixpanel project tracking token
24889 * @param {Object} [options]
24890 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24891 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24892 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24893 * @param {string} [options.cookieDomain] - custom cookie domain
24894 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24895 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24896 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24897 */
24898 function clearOptInOut(token, options) {
24899 options = options || {};
24900 _getStorage(options).remove(
24901 _getStorageKey(token, options), !!options.crossSubdomainCookie, options.cookieDomain
24902 );
24903 }
24904
24905 /** Private **/
24906
24907 /**
24908 * Get storage util
24909 * @param {Object} [options]
24910 * @param {string} [options.persistenceType]
24911 * @returns {object} either _.cookie or _.localstorage
24912 */
24913 function _getStorage(options) {
24914 options = options || {};
24915 return options.persistenceType === 'localStorage' ? _.localStorage : _.cookie;
24916 }
24917
24918 /**
24919 * Get the name of the cookie that is used for the given opt type (tracking, cookie, etc.)
24920 * @param {string} token - Mixpanel project tracking token
24921 * @param {Object} [options]
24922 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24923 * @returns {string} the name of the cookie for the given opt type
24924 */
24925 function _getStorageKey(token, options) {
24926 options = options || {};
24927 return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
24928 }
24929
24930 /**
24931 * Get the value of the cookie that is used for the given opt type (tracking, cookie, etc.)
24932 * @param {string} token - Mixpanel project tracking token
24933 * @param {Object} [options]
24934 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24935 * @returns {string} the value of the cookie for the given opt type
24936 */
24937 function _getStorageValue(token, options) {
24938 return _getStorage(options).get(_getStorageKey(token, options));
24939 }
24940
24941 /**
24942 * Check whether the user has set the DNT/doNotTrack setting to true in their browser
24943 * @param {Object} [options]
24944 * @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests
24945 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24946 * @returns {boolean} whether the DNT setting is true
24947 */
24948 function _hasDoNotTrackFlagOn(options) {
24949 if (options && options.ignoreDnt) {
24950 return false;
24951 }
24952 var win$1 = (options && options.window) || win;
24953 var nav = win$1['navigator'] || {};
24954 var hasDntOn = false;
24955
24956 _.each([
24957 nav['doNotTrack'], // standard
24958 nav['msDoNotTrack'],
24959 win$1['doNotTrack']
24960 ], function(dntValue) {
24961 if (_.includes([true, 1, '1', 'yes'], dntValue)) {
24962 hasDntOn = true;
24963 }
24964 });
24965
24966 return hasDntOn;
24967 }
24968
24969 /**
24970 * Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type
24971 * @param {boolean} optValue - whether to opt the user in or out for the given opt type
24972 * @param {string} token - Mixpanel project tracking token
24973 * @param {Object} [options]
24974 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24975 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24976 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24977 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24978 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24979 * @param {string} [options.cookieDomain] - custom cookie domain
24980 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24981 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24982 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24983 */
24984 function _optInOut(optValue, token, options) {
24985 if (!_.isString(token) || !token.length) {
24986 console$1.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token');
24987 return;
24988 }
24989
24990 options = options || {};
24991
24992 _getStorage(options).set(
24993 _getStorageKey(token, options),
24994 optValue ? 1 : 0,
24995 _.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
24996 !!options.crossSubdomainCookie,
24997 !!options.secureCookie,
24998 !!options.crossSiteCookie,
24999 options.cookieDomain
25000 );
25001
25002 if (options.track && optValue) { // only track event if opting in (optValue=true)
25003 options.track(options.trackEventName || '$opt_in', options.trackProperties, {
25004 'send_immediately': true
25005 });
25006 }
25007 }
25008
25009 /**
25010 * Wrap a method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
25011 * If the user has opted out, return early instead of executing the method.
25012 * If a callback argument was provided, execute it passing the 0 error code.
25013 * @param {function} method - wrapped method to be executed if the user has not opted out
25014 * @param {function} getConfigValue - getter function for the Mixpanel API token and other options to be used with opt-out check
25015 * @returns {*} the result of executing method OR undefined if the user has opted out
25016 */
25017 function _addOptOutCheck(method, getConfigValue) {
25018 return function() {
25019 var optedOut = false;
25020
25021 try {
25022 var token = getConfigValue.call(this, 'token');
25023 var ignoreDnt = getConfigValue.call(this, 'ignore_dnt');
25024 var persistenceType = getConfigValue.call(this, 'opt_out_tracking_persistence_type');
25025 var persistencePrefix = getConfigValue.call(this, 'opt_out_tracking_cookie_prefix');
25026 var win = getConfigValue.call(this, 'window'); // used to override window during browser tests
25027
25028 if (token) { // if there was an issue getting the token, continue method execution as normal
25029 optedOut = hasOptedOut(token, {
25030 ignoreDnt: ignoreDnt,
25031 persistenceType: persistenceType,
25032 persistencePrefix: persistencePrefix,
25033 window: win
25034 });
25035 }
25036 } catch(err) {
25037 console$1.error('Unexpected error when checking tracking opt-out status: ' + err);
25038 }
25039
25040 if (!optedOut) {
25041 return method.apply(this, arguments);
25042 }
25043
25044 var callback = arguments[arguments.length - 1];
25045 if (typeof(callback) === 'function') {
25046 callback(0);
25047 }
25048
25049 return;
25050 };
25051 }
25052
25053 var logger$6 = console_with_prefix('lock');
25054
25055 /**
25056 * SharedLock: a mutex built on HTML5 localStorage, to ensure that only one browser
25057 * window/tab at a time will be able to access shared resources.
25058 *
25059 * Based on the Alur and Taubenfeld fast lock
25060 * (http://www.cs.rochester.edu/research/synchronization/pseudocode/fastlock.html)
25061 * with an added timeout to ensure there will be eventual progress in the event
25062 * that a window is closed in the middle of the callback.
25063 *
25064 * Implementation based on the original version by David Wolever (https://github.com/wolever)
25065 * at https://gist.github.com/wolever/5fd7573d1ef6166e8f8c4af286a69432.
25066 *
25067 * @example
25068 * const myLock = new SharedLock('some-key');
25069 * myLock.withLock(function() {
25070 * console.log('I hold the mutex!');
25071 * });
25072 *
25073 * @constructor
25074 */
25075 var SharedLock = function(key, options) {
25076 options = options || {};
25077
25078 this.storageKey = key;
25079 this.storage = options.storage || win.localStorage;
25080 this.pollIntervalMS = options.pollIntervalMS || 100;
25081 this.timeoutMS = options.timeoutMS || 2000;
25082
25083 // dependency-inject promise implementation for testing purposes
25084 this.promiseImpl = options.promiseImpl || PromisePolyfill;
25085 };
25086
25087 // pass in a specific pid to test contention scenarios; otherwise
25088 // it is chosen randomly for each acquisition attempt
25089 SharedLock.prototype.withLock = function(lockedCB, pid) {
25090 var Promise = this.promiseImpl;
25091 return new Promise(_.bind(function (resolve, reject) {
25092 var i = pid || (new Date().getTime() + '|' + Math.random());
25093 var startTime = new Date().getTime();
25094 var key = this.storageKey;
25095 var pollIntervalMS = this.pollIntervalMS;
25096 var timeoutMS = this.timeoutMS;
25097 var storage = this.storage;
25098
25099 var keyX = key + ':X';
25100 var keyY = key + ':Y';
25101 var keyZ = key + ':Z';
25102
25103 var delay = function(cb) {
25104 if (new Date().getTime() - startTime > timeoutMS) {
25105 logger$6.error('Timeout waiting for mutex on ' + key + '; clearing lock. [' + i + ']');
25106 storage.removeItem(keyZ);
25107 storage.removeItem(keyY);
25108 loop();
25109 return;
25110 }
25111 setTimeout(function() {
25112 try {
25113 cb();
25114 } catch(err) {
25115 reject(err);
25116 }
25117 }, pollIntervalMS * (Math.random() + 0.1));
25118 };
25119
25120 var waitFor = function(predicate, cb) {
25121 if (predicate()) {
25122 cb();
25123 } else {
25124 delay(function() {
25125 waitFor(predicate, cb);
25126 });
25127 }
25128 };
25129
25130 var getSetY = function() {
25131 var valY = storage.getItem(keyY);
25132 if (valY && valY !== i) { // if Y == i then this process already has the lock (useful for test cases)
25133 return false;
25134 } else {
25135 storage.setItem(keyY, i);
25136 if (storage.getItem(keyY) === i) {
25137 return true;
25138 } else {
25139 if (!localStorageSupported(storage, true)) {
25140 reject(new Error('localStorage support dropped while acquiring lock'));
25141 }
25142 return false;
25143 }
25144 }
25145 };
25146
25147 var loop = function() {
25148 storage.setItem(keyX, i);
25149
25150 waitFor(getSetY, function() {
25151 if (storage.getItem(keyX) === i) {
25152 criticalSection();
25153 return;
25154 }
25155
25156 delay(function() {
25157 if (storage.getItem(keyY) !== i) {
25158 loop();
25159 return;
25160 }
25161 waitFor(function() {
25162 return !storage.getItem(keyZ);
25163 }, criticalSection);
25164 });
25165 });
25166 };
25167
25168 var criticalSection = function() {
25169 storage.setItem(keyZ, '1');
25170 var removeLock = function () {
25171 storage.removeItem(keyZ);
25172 if (storage.getItem(keyY) === i) {
25173 storage.removeItem(keyY);
25174 }
25175 if (storage.getItem(keyX) === i) {
25176 storage.removeItem(keyX);
25177 }
25178 };
25179
25180 lockedCB()
25181 .then(function (ret) {
25182 removeLock();
25183 resolve(ret);
25184 })
25185 .catch(function (err) {
25186 removeLock();
25187 reject(err);
25188 });
25189 };
25190
25191 try {
25192 if (localStorageSupported(storage, true)) {
25193 loop();
25194 } else {
25195 throw new Error('localStorage support check failed');
25196 }
25197 } catch(err) {
25198 reject(err);
25199 }
25200 }, this));
25201 };
25202
25203 /**
25204 * @type {import('./wrapper').StorageWrapper}
25205 */
25206 var LocalStorageWrapper = function (storageOverride) {
25207 this.storage = storageOverride || win.localStorage;
25208 };
25209
25210 LocalStorageWrapper.prototype.init = function () {
25211 return PromisePolyfill.resolve();
25212 };
25213
25214 LocalStorageWrapper.prototype.isInitialized = function () {
25215 return true;
25216 };
25217
25218 LocalStorageWrapper.prototype.setItem = function (key, value) {
25219 return new PromisePolyfill(_.bind(function (resolve, reject) {
25220 try {
25221 this.storage.setItem(key, JSONStringify(value));
25222 } catch (e) {
25223 reject(e);
25224 }
25225 resolve();
25226 }, this));
25227 };
25228
25229 LocalStorageWrapper.prototype.getItem = function (key) {
25230 return new PromisePolyfill(_.bind(function (resolve, reject) {
25231 var item;
25232 try {
25233 item = JSONParse(this.storage.getItem(key));
25234 } catch (e) {
25235 reject(e);
25236 }
25237 resolve(item);
25238 }, this));
25239 };
25240
25241 LocalStorageWrapper.prototype.removeItem = function (key) {
25242 return new PromisePolyfill(_.bind(function (resolve, reject) {
25243 try {
25244 this.storage.removeItem(key);
25245 } catch (e) {
25246 reject(e);
25247 }
25248 resolve();
25249 }, this));
25250 };
25251
25252 var logger$5 = console_with_prefix('batch');
25253
25254 /**
25255 * RequestQueue: queue for batching API requests with localStorage backup for retries.
25256 * Maintains an in-memory queue which represents the source of truth for the current
25257 * page, but also writes all items out to a copy in the browser's localStorage, which
25258 * can be read on subsequent pageloads and retried. For batchability, all the request
25259 * items in the queue should be of the same type (events, people updates, group updates)
25260 * so they can be sent in a single request to the same API endpoint.
25261 *
25262 * LocalStorage keying and locking: In order for reloads and subsequent pageloads of
25263 * the same site to access the same persisted data, they must share the same localStorage
25264 * key (for instance based on project token and queue type). Therefore access to the
25265 * localStorage entry is guarded by an asynchronous mutex (SharedLock) to prevent
25266 * simultaneously open windows/tabs from overwriting each other's data (which would lead
25267 * to data loss in some situations).
25268 * @constructor
25269 */
25270 var RequestQueue = function (storageKey, options) {
25271 options = options || {};
25272 this.storageKey = storageKey;
25273 this.usePersistence = options.usePersistence;
25274 if (this.usePersistence) {
25275 this.queueStorage = options.queueStorage || new LocalStorageWrapper();
25276 this.lock = new SharedLock(storageKey, {
25277 storage: options.sharedLockStorage || win.localStorage,
25278 timeoutMS: options.sharedLockTimeoutMS,
25279 });
25280 }
25281 this.reportError = options.errorReporter || _.bind(logger$5.error, logger$5);
25282
25283 this.pid = options.pid || null; // pass pid to test out storage lock contention scenarios
25284
25285 this.memQueue = [];
25286 this.initialized = false;
25287
25288 if (options.enqueueThrottleMs) {
25289 this.enqueuePersisted = batchedThrottle(_.bind(this._enqueuePersisted, this), options.enqueueThrottleMs);
25290 } else {
25291 this.enqueuePersisted = _.bind(function (queueEntry) {
25292 return this._enqueuePersisted([queueEntry]);
25293 }, this);
25294 }
25295 };
25296
25297 RequestQueue.prototype.ensureInit = function () {
25298 if (this.initialized || !this.usePersistence) {
25299 return PromisePolyfill.resolve();
25300 }
25301
25302 return this.queueStorage
25303 .init()
25304 .then(_.bind(function () {
25305 this.initialized = true;
25306 }, this))
25307 .catch(_.bind(function (err) {
25308 this.reportError('Error initializing queue persistence. Disabling persistence', err);
25309 this.initialized = true;
25310 this.usePersistence = false;
25311 }, this));
25312 };
25313
25314 /**
25315 * Add one item to queues (memory and localStorage). The queued entry includes
25316 * the given item along with an auto-generated ID and a "flush-after" timestamp.
25317 * It is expected that the item will be sent over the network and dequeued
25318 * before the flush-after time; if this doesn't happen it is considered orphaned
25319 * (e.g., the original tab where it was enqueued got closed before it could be
25320 * sent) and the item can be sent by any tab that finds it in localStorage.
25321 *
25322 * The final callback param is called with a param indicating success or
25323 * failure of the enqueue operation; it is asynchronous because the localStorage
25324 * lock is asynchronous.
25325 */
25326 RequestQueue.prototype.enqueue = function (item, flushInterval) {
25327 var queueEntry = {
25328 'id': cheap_guid(),
25329 'flushAfter': new Date().getTime() + flushInterval * 2,
25330 'payload': item
25331 };
25332
25333 if (!this.usePersistence) {
25334 this.memQueue.push(queueEntry);
25335 return PromisePolyfill.resolve(true);
25336 } else {
25337 return this.enqueuePersisted(queueEntry);
25338 }
25339 };
25340
25341 RequestQueue.prototype._enqueuePersisted = function (queueEntries) {
25342 var enqueueItem = _.bind(function () {
25343 return this.ensureInit()
25344 .then(_.bind(function () {
25345 return this.readFromStorage();
25346 }, this))
25347 .then(_.bind(function (storedQueue) {
25348 return this.saveToStorage(storedQueue.concat(queueEntries));
25349 }, this))
25350 .then(_.bind(function (succeeded) {
25351 // only add to in-memory queue when storage succeeds
25352 if (succeeded) {
25353 this.memQueue = this.memQueue.concat(queueEntries);
25354 }
25355
25356 return succeeded;
25357 }, this))
25358 .catch(_.bind(function (err) {
25359 this.reportError('Error enqueueing items', err, queueEntries);
25360 return false;
25361 }, this));
25362 }, this);
25363
25364 return this.lock
25365 .withLock(enqueueItem, this.pid)
25366 .catch(_.bind(function (err) {
25367 this.reportError('Error acquiring storage lock', err);
25368 return false;
25369 }, this));
25370 };
25371
25372 /**
25373 * Read out the given number of queue entries. If this.memQueue
25374 * has fewer than batchSize items, then look for "orphaned" items
25375 * in the persisted queue (items where the 'flushAfter' time has
25376 * already passed).
25377 */
25378 RequestQueue.prototype.fillBatch = function (batchSize) {
25379 var batch = this.memQueue.slice(0, batchSize);
25380 if (this.usePersistence && batch.length < batchSize) {
25381 // don't need lock just to read events; localStorage is thread-safe
25382 // and the worst that could happen is a duplicate send of some
25383 // orphaned events, which will be deduplicated on the server side
25384 return this.ensureInit()
25385 .then(_.bind(function () {
25386 return this.readFromStorage();
25387 }, this))
25388 .then(_.bind(function (storedQueue) {
25389 if (storedQueue.length) {
25390 // item IDs already in batch; don't duplicate out of storage
25391 var idsInBatch = {}; // poor man's Set
25392 _.each(batch, function (item) {
25393 idsInBatch[item['id']] = true;
25394 });
25395
25396 for (var i = 0; i < storedQueue.length; i++) {
25397 var item = storedQueue[i];
25398 if (new Date().getTime() > item['flushAfter'] && !idsInBatch[item['id']]) {
25399 item.orphaned = true;
25400 batch.push(item);
25401 if (batch.length >= batchSize) {
25402 break;
25403 }
25404 }
25405 }
25406 }
25407
25408 return batch;
25409 }, this));
25410 } else {
25411 return PromisePolyfill.resolve(batch);
25412 }
25413 };
25414
25415 /**
25416 * Remove items with matching 'id' from array (immutably)
25417 * also remove any item without a valid id (e.g., malformed
25418 * storage entries).
25419 */
25420 var filterOutIDsAndInvalid = function (items, idSet) {
25421 var filteredItems = [];
25422 _.each(items, function (item) {
25423 if (item['id'] && !idSet[item['id']]) {
25424 filteredItems.push(item);
25425 }
25426 });
25427 return filteredItems;
25428 };
25429
25430 /**
25431 * Remove items with matching IDs from both in-memory queue
25432 * and persisted queue
25433 */
25434 RequestQueue.prototype.removeItemsByID = function (ids) {
25435 var idSet = {}; // poor man's Set
25436 _.each(ids, function (id) {
25437 idSet[id] = true;
25438 });
25439
25440 this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
25441 if (!this.usePersistence) {
25442 return PromisePolyfill.resolve(true);
25443 } else {
25444 var removeFromStorage = _.bind(function () {
25445 return this.ensureInit()
25446 .then(_.bind(function () {
25447 return this.readFromStorage();
25448 }, this))
25449 .then(_.bind(function (storedQueue) {
25450 storedQueue = filterOutIDsAndInvalid(storedQueue, idSet);
25451 return this.saveToStorage(storedQueue);
25452 }, this))
25453 .then(_.bind(function () {
25454 return this.readFromStorage();
25455 }, this))
25456 .then(_.bind(function (storedQueue) {
25457 // an extra check: did storage report success but somehow
25458 // the items are still there?
25459 for (var i = 0; i < storedQueue.length; i++) {
25460 var item = storedQueue[i];
25461 if (item['id'] && !!idSet[item['id']]) {
25462 throw new Error('Item not removed from storage');
25463 }
25464 }
25465 return true;
25466 }, this))
25467 .catch(_.bind(function (err) {
25468 this.reportError('Error removing items', err, ids);
25469 return false;
25470 }, this));
25471 }, this);
25472
25473 return this.lock
25474 .withLock(removeFromStorage, this.pid)
25475 .catch(_.bind(function (err) {
25476 this.reportError('Error acquiring storage lock', err);
25477 if (!localStorageSupported(this.lock.storage, true)) {
25478 // Looks like localStorage writes have stopped working sometime after
25479 // initialization (probably full), and so nobody can acquire locks
25480 // anymore. Consider it temporarily safe to remove items without the
25481 // lock, since nobody's writing successfully anyway.
25482 return removeFromStorage()
25483 .then(_.bind(function (success) {
25484 if (!success) {
25485 // OK, we couldn't even write out the smaller queue. Try clearing it
25486 // entirely.
25487 return this.queueStorage.removeItem(this.storageKey).then(function () {
25488 return success;
25489 });
25490 }
25491 return success;
25492 }, this))
25493 .catch(_.bind(function (err) {
25494 this.reportError('Error clearing queue', err);
25495 return false;
25496 }, this));
25497 } else {
25498 return false;
25499 }
25500 }, this));
25501 }
25502 };
25503
25504 // internal helper for RequestQueue.updatePayloads
25505 var updatePayloads = function (existingItems, itemsToUpdate) {
25506 var newItems = [];
25507 _.each(existingItems, function (item) {
25508 var id = item['id'];
25509 if (id in itemsToUpdate) {
25510 var newPayload = itemsToUpdate[id];
25511 if (newPayload !== null) {
25512 item['payload'] = newPayload;
25513 newItems.push(item);
25514 }
25515 } else {
25516 // no update
25517 newItems.push(item);
25518 }
25519 });
25520 return newItems;
25521 };
25522
25523 /**
25524 * Update payloads of given items in both in-memory queue and
25525 * persisted queue. Items set to null are removed from queues.
25526 */
25527 RequestQueue.prototype.updatePayloads = function (itemsToUpdate) {
25528 this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
25529 if (!this.usePersistence) {
25530 return PromisePolyfill.resolve(true);
25531 } else {
25532 return this.lock
25533 .withLock(_.bind(function lockAcquired() {
25534 return this.ensureInit()
25535 .then(_.bind(function () {
25536 return this.readFromStorage();
25537 }, this))
25538 .then(_.bind(function (storedQueue) {
25539 storedQueue = updatePayloads(storedQueue, itemsToUpdate);
25540 return this.saveToStorage(storedQueue);
25541 }, this))
25542 .catch(_.bind(function (err) {
25543 this.reportError('Error updating items', itemsToUpdate, err);
25544 return false;
25545 }, this));
25546 }, this), this.pid)
25547 .catch(_.bind(function (err) {
25548 this.reportError('Error acquiring storage lock', err);
25549 return false;
25550 }, this));
25551 }
25552 };
25553
25554 /**
25555 * Read and parse items array from localStorage entry, handling
25556 * malformed/missing data if necessary.
25557 */
25558 RequestQueue.prototype.readFromStorage = function () {
25559 return this.ensureInit()
25560 .then(_.bind(function () {
25561 return this.queueStorage.getItem(this.storageKey);
25562 }, this))
25563 .then(_.bind(function (storageEntry) {
25564 if (storageEntry) {
25565 if (!_.isArray(storageEntry)) {
25566 this.reportError('Invalid storage entry:', storageEntry);
25567 storageEntry = null;
25568 }
25569 }
25570 return storageEntry || [];
25571 }, this))
25572 .catch(_.bind(function (err) {
25573 this.reportError('Error retrieving queue', err);
25574 return [];
25575 }, this));
25576 };
25577
25578 /**
25579 * Serialize the given items array to localStorage.
25580 */
25581 RequestQueue.prototype.saveToStorage = function (queue) {
25582 return this.ensureInit()
25583 .then(_.bind(function () {
25584 return this.queueStorage.setItem(this.storageKey, queue);
25585 }, this))
25586 .then(function () {
25587 return true;
25588 })
25589 .catch(_.bind(function (err) {
25590 this.reportError('Error saving queue', err);
25591 return false;
25592 }, this));
25593 };
25594
25595 /**
25596 * Clear out queues (memory and localStorage).
25597 */
25598 RequestQueue.prototype.clear = function () {
25599 this.memQueue = [];
25600
25601 if (this.usePersistence) {
25602 return this.ensureInit()
25603 .then(_.bind(function () {
25604 return this.queueStorage.removeItem(this.storageKey);
25605 }, this));
25606 } else {
25607 return PromisePolyfill.resolve();
25608 }
25609 };
25610
25611 // maximum interval between request retries after exponential backoff
25612 var MAX_RETRY_INTERVAL_MS = 10 * 60 * 1000; // 10 minutes
25613
25614 var logger$4 = console_with_prefix('batch');
25615
25616 /**
25617 * RequestBatcher: manages the queueing, flushing, retry etc of requests of one
25618 * type (events, people, groups).
25619 * Uses RequestQueue to manage the backing store.
25620 * @constructor
25621 */
25622 var RequestBatcher = function(storageKey, options) {
25623 this.errorReporter = options.errorReporter;
25624 this.queue = new RequestQueue(storageKey, {
25625 errorReporter: _.bind(this.reportError, this),
25626 queueStorage: options.queueStorage,
25627 sharedLockStorage: options.sharedLockStorage,
25628 sharedLockTimeoutMS: options.sharedLockTimeoutMS,
25629 usePersistence: options.usePersistence,
25630 enqueueThrottleMs: options.enqueueThrottleMs
25631 });
25632
25633 this.libConfig = options.libConfig;
25634 this.sendRequest = options.sendRequestFunc;
25635 this.beforeSendHook = options.beforeSendHook;
25636 this.stopAllBatching = options.stopAllBatchingFunc;
25637
25638 // seed variable batch size + flush interval with configured values
25639 this.batchSize = this.libConfig['batch_size'];
25640 this.flushInterval = this.libConfig['batch_flush_interval_ms'];
25641
25642 this.stopped = !this.libConfig['batch_autostart'];
25643 this.consecutiveRemovalFailures = 0;
25644
25645 // extra client-side dedupe
25646 this.itemIdsSentSuccessfully = {};
25647
25648 // Make the flush occur at the interval specified by flushIntervalMs, default behavior will attempt consecutive flushes
25649 // as long as the queue is not empty. This is useful for high-frequency events like Session Replay where we might end up
25650 // in a request loop and get ratelimited by the server.
25651 this.flushOnlyOnInterval = options.flushOnlyOnInterval || false;
25652
25653 this._flushPromise = null;
25654 };
25655
25656 /**
25657 * Add one item to queue.
25658 */
25659 RequestBatcher.prototype.enqueue = function(item) {
25660 return this.queue.enqueue(item, this.flushInterval);
25661 };
25662
25663 /**
25664 * Start flushing batches at the configured time interval. Must call
25665 * this method upon SDK init in order to send anything over the network.
25666 */
25667 RequestBatcher.prototype.start = function() {
25668 this.stopped = false;
25669 this.consecutiveRemovalFailures = 0;
25670 return this.flush();
25671 };
25672
25673 /**
25674 * Stop flushing batches. Can be restarted by calling start().
25675 */
25676 RequestBatcher.prototype.stop = function() {
25677 this.stopped = true;
25678 if (this.timeoutID) {
25679 clearTimeout(this.timeoutID);
25680 this.timeoutID = null;
25681 }
25682 };
25683
25684 /**
25685 * Clear out queue.
25686 */
25687 RequestBatcher.prototype.clear = function() {
25688 return this.queue.clear();
25689 };
25690
25691 /**
25692 * Restore batch size configuration to whatever is set in the main SDK.
25693 */
25694 RequestBatcher.prototype.resetBatchSize = function() {
25695 this.batchSize = this.libConfig['batch_size'];
25696 };
25697
25698 /**
25699 * Restore flush interval time configuration to whatever is set in the main SDK.
25700 */
25701 RequestBatcher.prototype.resetFlush = function() {
25702 this.scheduleFlush(this.libConfig['batch_flush_interval_ms']);
25703 };
25704
25705 /**
25706 * Schedule the next flush in the given number of milliseconds.
25707 */
25708 RequestBatcher.prototype.scheduleFlush = function(flushMS) {
25709 this.flushInterval = flushMS;
25710 if (!this.stopped) { // don't schedule anymore if batching has been stopped
25711 this.timeoutID = setTimeout(_.bind(function() {
25712 if (!this.stopped) {
25713 this._flushPromise = this.flush();
25714 }
25715 }, this), this.flushInterval);
25716 }
25717 };
25718
25719 /**
25720 * Send a request using the sendRequest callback, but promisified.
25721 * TODO: sendRequest should be promisified in the first place.
25722 */
25723 RequestBatcher.prototype.sendRequestPromise = function(data, options) {
25724 return new PromisePolyfill(_.bind(function(resolve) {
25725 this.sendRequest(data, options, resolve);
25726 }, this));
25727 };
25728
25729
25730 /**
25731 * Flush one batch to network. Depending on success/failure modes, it will either
25732 * remove the batch from the queue or leave it in for retry, and schedule the next
25733 * flush. In cases of most network or API failures, it will back off exponentially
25734 * when retrying.
25735 * @param {Object} [options]
25736 * @param {boolean} [options.sendBeacon] - whether to send batch with
25737 * navigator.sendBeacon (only useful for sending batches before page unloads, as
25738 * sendBeacon offers no callbacks or status indications)
25739 */
25740 RequestBatcher.prototype.flush = function(options) {
25741 if (this.requestInProgress) {
25742 logger$4.log('Flush: Request already in progress');
25743 return PromisePolyfill.resolve();
25744 }
25745
25746 this.requestInProgress = true;
25747
25748 options = options || {};
25749 var timeoutMS = this.libConfig['batch_request_timeout_ms'];
25750 var startTime = new Date().getTime();
25751 var currentBatchSize = this.batchSize;
25752
25753 return this.queue.fillBatch(currentBatchSize)
25754 .then(_.bind(function(batch) {
25755
25756 // if there's more items in the queue than the batch size, attempt
25757 // to flush again after the current batch is done.
25758 var attemptSecondaryFlush = batch.length === currentBatchSize;
25759 var dataForRequest = [];
25760 var transformedItems = {};
25761 _.each(batch, function(item) {
25762 var payload = item['payload'];
25763 if (this.beforeSendHook && !item.orphaned) {
25764 payload = this.beforeSendHook(payload);
25765 }
25766 if (payload) {
25767 // mp_sent_by_lib_version prop captures which lib version actually
25768 // sends each event (regardless of which version originally queued
25769 // it for sending)
25770 if (payload['event'] && payload['properties']) {
25771 payload['properties'] = _.extend(
25772 {},
25773 payload['properties'],
25774 {'mp_sent_by_lib_version': Config.LIB_VERSION}
25775 );
25776 }
25777 var addPayload = true;
25778 var itemId = item['id'];
25779 if (itemId) {
25780 if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
25781 this.reportError('[dupe] item ID sent too many times, not sending', {
25782 item: item,
25783 batchSize: batch.length,
25784 timesSent: this.itemIdsSentSuccessfully[itemId]
25785 });
25786 addPayload = false;
25787 }
25788 } else {
25789 this.reportError('[dupe] found item with no ID', {item: item});
25790 }
25791
25792 if (addPayload) {
25793 dataForRequest.push(payload);
25794 }
25795 }
25796 transformedItems[item['id']] = payload;
25797 }, this);
25798
25799 if (dataForRequest.length < 1) {
25800 this.requestInProgress = false;
25801 this.resetFlush();
25802 return PromisePolyfill.resolve(); // nothing to do
25803 }
25804
25805 var removeItemsFromQueue = _.bind(function () {
25806 return this.queue
25807 .removeItemsByID(
25808 _.map(batch, function (item) {
25809 return item['id'];
25810 })
25811 )
25812 .then(_.bind(function (succeeded) {
25813 // client-side dedupe
25814 _.each(batch, _.bind(function(item) {
25815 var itemId = item['id'];
25816 if (itemId) {
25817 this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
25818 this.itemIdsSentSuccessfully[itemId]++;
25819 if (this.itemIdsSentSuccessfully[itemId] > 5) {
25820 this.reportError('[dupe] item ID sent too many times', {
25821 item: item,
25822 batchSize: batch.length,
25823 timesSent: this.itemIdsSentSuccessfully[itemId]
25824 });
25825 }
25826 } else {
25827 this.reportError('[dupe] found item with no ID while removing', {item: item});
25828 }
25829 }, this));
25830
25831 if (succeeded) {
25832 this.consecutiveRemovalFailures = 0;
25833 if (this.flushOnlyOnInterval && !attemptSecondaryFlush) {
25834 this.resetFlush(); // schedule next batch with a delay
25835 return PromisePolyfill.resolve();
25836 } else {
25837 return this.flush(); // handle next batch if the queue isn't empty
25838 }
25839 } else {
25840 if (++this.consecutiveRemovalFailures > 5) {
25841 this.reportError('Too many queue failures; disabling batching system.');
25842 this.stopAllBatching();
25843 } else {
25844 this.resetFlush();
25845 }
25846 return PromisePolyfill.resolve();
25847 }
25848 }, this));
25849 }, this);
25850
25851 var batchSendCallback = _.bind(function(res) {
25852 this.requestInProgress = false;
25853
25854 try {
25855
25856 // handle API response in a try-catch to make sure we can reset the
25857 // flush operation if something goes wrong
25858
25859 if (options.unloading) {
25860 // update persisted data to include hook transformations
25861 return this.queue.updatePayloads(transformedItems);
25862 } else if (
25863 _.isObject(res) &&
25864 res.error === 'timeout' &&
25865 new Date().getTime() - startTime >= timeoutMS
25866 ) {
25867 this.reportError('Network timeout; retrying');
25868 return this.flush();
25869 } else if (
25870 _.isObject(res) &&
25871 (
25872 res.httpStatusCode >= 500
25873 || res.httpStatusCode === 429
25874 || (res.httpStatusCode <= 0 && !isOnline())
25875 || res.error === 'timeout'
25876 )
25877 ) {
25878 // network or API error, or 429 Too Many Requests, retry
25879 var retryMS = this.flushInterval * 2;
25880 if (res.retryAfter) {
25881 retryMS = (parseInt(res.retryAfter, 10) * 1000) || retryMS;
25882 }
25883 retryMS = Math.min(MAX_RETRY_INTERVAL_MS, retryMS);
25884 this.reportError('Error; retry in ' + retryMS + ' ms');
25885 this.scheduleFlush(retryMS);
25886 return PromisePolyfill.resolve();
25887 } else if (_.isObject(res) && res.httpStatusCode === 413) {
25888 // 413 Payload Too Large
25889 if (batch.length > 1) {
25890 var halvedBatchSize = Math.max(1, Math.floor(currentBatchSize / 2));
25891 this.batchSize = Math.min(this.batchSize, halvedBatchSize, batch.length - 1);
25892 this.reportError('413 response; reducing batch size to ' + this.batchSize);
25893 this.resetFlush();
25894 return PromisePolyfill.resolve();
25895 } else {
25896 this.reportError('Single-event request too large; dropping', batch);
25897 this.resetBatchSize();
25898 return removeItemsFromQueue();
25899 }
25900 } else {
25901 // successful network request+response; remove each item in batch from queue
25902 // (even if it was e.g. a 400, in which case retrying won't help)
25903 return removeItemsFromQueue();
25904 }
25905 } catch(err) {
25906 this.reportError('Error handling API response', err);
25907 this.resetFlush();
25908 }
25909 }, this);
25910 var requestOptions = {
25911 method: 'POST',
25912 verbose: true,
25913 ignore_json_errors: true, // eslint-disable-line camelcase
25914 timeout_ms: timeoutMS // eslint-disable-line camelcase
25915 };
25916 if (options.unloading) {
25917 requestOptions.transport = 'sendBeacon';
25918 }
25919 logger$4.log('MIXPANEL REQUEST:', dataForRequest);
25920 return this.sendRequestPromise(dataForRequest, requestOptions).then(batchSendCallback);
25921 }, this))
25922 .catch(_.bind(function(err) {
25923 this.reportError('Error flushing request queue', err);
25924 this.resetFlush();
25925 }, this));
25926 };
25927
25928 /**
25929 * Log error to global logger and optional user-defined logger.
25930 */
25931 RequestBatcher.prototype.reportError = function(msg, err) {
25932 logger$4.error.apply(logger$4.error, arguments);
25933 if (this.errorReporter) {
25934 try {
25935 if (!(err instanceof Error)) {
25936 err = new Error(msg);
25937 }
25938 this.errorReporter(msg, err);
25939 } catch(err) {
25940 logger$4.error(err);
25941 }
25942 }
25943 };
25944
25945 /**
25946 * @param {import('./session-recording').SerializedRecording} serializedRecording
25947 * @returns {boolean}
25948 */
25949 var isRecordingExpired = function(serializedRecording) {
25950 var now = Date.now();
25951 return !serializedRecording || now > serializedRecording['maxExpires'] || now > serializedRecording['idleExpires'];
25952 };
25953
25954 var RECORD_ENQUEUE_THROTTLE_MS = 250;
25955
25956 var logger$3 = console_with_prefix('recorder');
25957 var CompressionStream = win['CompressionStream'];
25958
25959 var RECORDER_BATCHER_LIB_CONFIG = {
25960 'batch_size': 1000,
25961 'batch_flush_interval_ms': 10 * 1000,
25962 'batch_request_timeout_ms': 90 * 1000,
25963 'batch_autostart': true
25964 };
25965
25966 var ACTIVE_SOURCES = new Set([
25967 IncrementalSource.MouseMove,
25968 IncrementalSource.MouseInteraction,
25969 IncrementalSource.Scroll,
25970 IncrementalSource.ViewportResize,
25971 IncrementalSource.Input,
25972 IncrementalSource.TouchMove,
25973 IncrementalSource.MediaInteraction,
25974 IncrementalSource.Drag,
25975 IncrementalSource.Selection,
25976 ]);
25977
25978 function isUserEvent(ev) {
25979 return ev.type === EventType.IncrementalSnapshot && ACTIVE_SOURCES.has(ev.data.source);
25980 }
25981
25982 /**
25983 * @typedef {Object} SerializedRecording
25984 * @property {number} idleExpires
25985 * @property {number} maxExpires
25986 * @property {number} replayStartTime
25987 * @property {number} seqNo
25988 * @property {string} batchStartUrl
25989 * @property {string} replayId
25990 * @property {string} tabId
25991 * @property {string} replayStartUrl
25992 */
25993
25994 /**
25995 * @typedef {Object} SessionRecordingOptions
25996 * @property {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
25997 * @property {String} [options.replayId] - unique uuid for a single replay
25998 * @property {Function} [options.onIdleTimeout] - callback when a recording reaches idle timeout
25999 * @property {Function} [options.onMaxLengthReached] - callback when a recording reaches its maximum length
26000 * @property {Function} [options.rrwebRecord] - rrweb's `record` function
26001 * @property {Function} [options.onBatchSent] - callback when a batch of events is sent to the server
26002 * @property {Storage} [options.sharedLockStorage] - optional storage for shared lock, used for test dependency injection
26003 * optional properties for deserialization:
26004 * @property {number} idleExpires
26005 * @property {number} maxExpires
26006 * @property {number} replayStartTime
26007 * @property {number} seqNo
26008 * @property {string} batchStartUrl
26009 * @property {string} replayStartUrl
26010 */
26011
26012 /**
26013 * @typedef {Object} UserIdInfo
26014 * @property {string} distinct_id
26015 * @property {string} user_id
26016 * @property {string} device_id
26017 */
26018
26019
26020 /**
26021 * This class encapsulates a single session recording and its lifecycle.
26022 * @param {SessionRecordingOptions} options
26023 */
26024 var SessionRecording = function(options) {
26025 this._mixpanel = options.mixpanelInstance;
26026 this._onIdleTimeout = options.onIdleTimeout || NOOP_FUNC;
26027 this._onMaxLengthReached = options.onMaxLengthReached || NOOP_FUNC;
26028 this._onBatchSent = options.onBatchSent || NOOP_FUNC;
26029 this._rrwebRecord = options.rrwebRecord || null;
26030
26031 // internal rrweb stopRecording function
26032 this._stopRecording = null;
26033 this.replayId = options.replayId;
26034
26035 this.batchStartUrl = options.batchStartUrl || null;
26036 this.replayStartUrl = options.replayStartUrl || null;
26037 this.idleExpires = options.idleExpires || null;
26038 this.maxExpires = options.maxExpires || null;
26039 this.replayStartTime = options.replayStartTime || null;
26040 this.seqNo = options.seqNo || 0;
26041
26042 this.idleTimeoutId = null;
26043 this.maxTimeoutId = null;
26044
26045 this.recordMaxMs = MAX_RECORDING_MS;
26046 this.recordMinMs = 0;
26047
26048 // disable persistence if localStorage is not supported
26049 // request-queue will automatically disable persistence if indexedDB fails to initialize
26050 var usePersistence = localStorageSupported(options.sharedLockStorage, true) && !this.getConfig('disable_persistence');
26051
26052 // each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
26053 this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
26054 this.queueStorage = new IDBStorageWrapper(RECORDING_EVENTS_STORE_NAME);
26055 this.batcher = new RequestBatcher(this.batcherKey, {
26056 errorReporter: this.reportError.bind(this),
26057 flushOnlyOnInterval: true,
26058 libConfig: RECORDER_BATCHER_LIB_CONFIG,
26059 sendRequestFunc: this.flushEventsWithOptOut.bind(this),
26060 queueStorage: this.queueStorage,
26061 sharedLockStorage: options.sharedLockStorage,
26062 usePersistence: usePersistence,
26063 stopAllBatchingFunc: this.stopRecording.bind(this),
26064
26065 // increased throttle and shared lock timeout because recording events are very high frequency.
26066 // this will minimize the amount of lock contention between enqueued events.
26067 // for session recordings there is a lock for each tab anyway, so there's no risk of deadlock between tabs.
26068 enqueueThrottleMs: RECORD_ENQUEUE_THROTTLE_MS,
26069 sharedLockTimeoutMS: 10 * 1000,
26070 });
26071 };
26072
26073 /**
26074 * @returns {UserIdInfo}
26075 */
26076 SessionRecording.prototype.getUserIdInfo = function () {
26077 if (this.finalFlushUserIdInfo) {
26078 return this.finalFlushUserIdInfo;
26079 }
26080
26081 var userIdInfo = {
26082 'distinct_id': String(this._mixpanel.get_distinct_id()),
26083 };
26084
26085 // send ID management props if they exist
26086 var deviceId = this._mixpanel.get_property('$device_id');
26087 if (deviceId) {
26088 userIdInfo['$device_id'] = deviceId;
26089 }
26090 var userId = this._mixpanel.get_property('$user_id');
26091 if (userId) {
26092 userIdInfo['$user_id'] = userId;
26093 }
26094 return userIdInfo;
26095 };
26096
26097 SessionRecording.prototype.unloadPersistedData = function () {
26098 this.batcher.stop();
26099 return this.batcher.flush()
26100 .then(function () {
26101 return this.queueStorage.removeItem(this.batcherKey);
26102 }.bind(this));
26103 };
26104
26105 SessionRecording.prototype.getConfig = function(configVar) {
26106 return this._mixpanel.get_config(configVar);
26107 };
26108
26109 // Alias for getConfig, used by the common addOptOutCheckMixpanelLib function which
26110 // reaches into this class instance and expects the snake case version of the function.
26111 // eslint-disable-next-line camelcase
26112 SessionRecording.prototype.get_config = function(configVar) {
26113 return this.getConfig(configVar);
26114 };
26115
26116 SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
26117 if (this._rrwebRecord === null) {
26118 this.reportError('rrweb record function not provided. ');
26119 return;
26120 }
26121
26122 if (this._stopRecording !== null) {
26123 logger$3.log('Recording already in progress, skipping startRecording.');
26124 return;
26125 }
26126
26127 this.recordMaxMs = this.getConfig('record_max_ms');
26128 if (this.recordMaxMs > MAX_RECORDING_MS) {
26129 this.recordMaxMs = MAX_RECORDING_MS;
26130 logger$3.critical('record_max_ms cannot be greater than ' + MAX_RECORDING_MS + 'ms. Capping value.');
26131 }
26132
26133 if (!this.maxExpires) {
26134 this.maxExpires = new Date().getTime() + this.recordMaxMs;
26135 }
26136
26137 this.recordMinMs = this.getConfig('record_min_ms');
26138 if (this.recordMinMs > MAX_VALUE_FOR_MIN_RECORDING_MS) {
26139 this.recordMinMs = MAX_VALUE_FOR_MIN_RECORDING_MS;
26140 logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
26141 }
26142
26143 if (!this.replayStartTime) {
26144 this.replayStartTime = new Date().getTime();
26145 this.batchStartUrl = _.info.currentUrl();
26146 this.replayStartUrl = _.info.currentUrl();
26147 }
26148
26149 if (shouldStopBatcher || this.recordMinMs > 0) {
26150 // the primary case for shouldStopBatcher is when we're starting recording after a reset
26151 // and don't want to send anything over the network until there's
26152 // actual user activity
26153 // this also applies if the minimum recording length has not been hit yet
26154 // so that we don't send data until we know the recording will be long enough
26155 this.batcher.stop();
26156 } else {
26157 this.batcher.start();
26158 }
26159
26160 var resetIdleTimeout = function () {
26161 clearTimeout(this.idleTimeoutId);
26162 var idleTimeoutMs = this.getConfig('record_idle_timeout_ms');
26163 this.idleTimeoutId = setTimeout(this._onIdleTimeout, idleTimeoutMs);
26164 this.idleExpires = new Date().getTime() + idleTimeoutMs;
26165 }.bind(this);
26166 resetIdleTimeout();
26167
26168 var blockSelector = this.getConfig('record_block_selector');
26169 if (blockSelector === '' || blockSelector === null) {
26170 blockSelector = undefined;
26171 }
26172
26173 try {
26174 this._stopRecording = this._rrwebRecord({
26175 'emit': function (ev) {
26176 if (this.idleExpires && this.idleExpires < ev.timestamp) {
26177 this._onIdleTimeout();
26178 return;
26179 }
26180 if (isUserEvent(ev)) {
26181 if (this.batcher.stopped && new Date().getTime() - this.replayStartTime >= this.recordMinMs) {
26182 // start flushing again after user activity
26183 this.batcher.start();
26184 }
26185 resetIdleTimeout();
26186 }
26187 // promise only used to await during tests
26188 this.__enqueuePromise = this.batcher.enqueue(ev);
26189 }.bind(this),
26190 'blockClass': this.getConfig('record_block_class'),
26191 'blockSelector': blockSelector,
26192 'collectFonts': this.getConfig('record_collect_fonts'),
26193 'dataURLOptions': { // canvas image options (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL)
26194 'type': 'image/webp',
26195 'quality': 0.6
26196 },
26197 'maskAllInputs': true,
26198 'maskTextClass': this.getConfig('record_mask_text_class'),
26199 'maskTextSelector': this.getConfig('record_mask_text_selector'),
26200 'recordCanvas': this.getConfig('record_canvas'),
26201 'sampling': {
26202 'canvas': 15
26203 }
26204 });
26205 } catch (err) {
26206 this.reportError('Unexpected error when starting rrweb recording.', err);
26207 }
26208
26209 if (typeof this._stopRecording !== 'function') {
26210 this.reportError('rrweb failed to start, skipping this recording.');
26211 this._stopRecording = null;
26212 this.stopRecording(); // stop batcher looping and any timeouts
26213 return;
26214 }
26215
26216 var maxTimeoutMs = this.maxExpires - new Date().getTime();
26217 this.maxTimeoutId = setTimeout(this._onMaxLengthReached.bind(this), maxTimeoutMs);
26218 };
26219
26220 SessionRecording.prototype.stopRecording = function (skipFlush) {
26221 // store the user ID info in case this is getting called in mixpanel.reset()
26222 this.finalFlushUserIdInfo = this.getUserIdInfo();
26223
26224 if (!this.isRrwebStopped()) {
26225 try {
26226 this._stopRecording();
26227 } catch (err) {
26228 this.reportError('Error with rrweb stopRecording', err);
26229 }
26230 this._stopRecording = null;
26231 }
26232
26233 var flushPromise;
26234 if (this.batcher.stopped) {
26235 // never got user activity to flush after reset, so just clear the batcher
26236 flushPromise = this.batcher.clear();
26237 } else if (!skipFlush) {
26238 // flush any remaining events from running batcher
26239 flushPromise = this.batcher.flush();
26240 }
26241 this.batcher.stop();
26242
26243 clearTimeout(this.idleTimeoutId);
26244 clearTimeout(this.maxTimeoutId);
26245 return flushPromise;
26246 };
26247
26248 SessionRecording.prototype.isRrwebStopped = function () {
26249 return this._stopRecording === null;
26250 };
26251
26252
26253 /**
26254 * Flushes the current batch of events to the server, but passes an opt-out callback to make sure
26255 * we stop recording and dump any queued events if the user has opted out.
26256 */
26257 SessionRecording.prototype.flushEventsWithOptOut = function (data, options, cb) {
26258 var onOptOut = function (code) {
26259 // addOptOutCheckMixpanelLib invokes this function with code=0 when the user has opted out
26260 if (code === 0) {
26261 this.stopRecording();
26262 cb({error: 'Tracking has been opted out, stopping recording.'});
26263 }
26264 }.bind(this);
26265
26266 this._flushEvents(data, options, cb, onOptOut);
26267 };
26268
26269 /**
26270 * @returns {SerializedRecording}
26271 */
26272 SessionRecording.prototype.serialize = function () {
26273 // don't break if mixpanel instance was destroyed at some point
26274 var tabId;
26275 try {
26276 tabId = this._mixpanel.get_tab_id();
26277 } catch (e) {
26278 this.reportError('Error getting tab ID for serialization ', e);
26279 tabId = null;
26280 }
26281
26282 return {
26283 'replayId': this.replayId,
26284 'seqNo': this.seqNo,
26285 'replayStartTime': this.replayStartTime,
26286 'batchStartUrl': this.batchStartUrl,
26287 'replayStartUrl': this.replayStartUrl,
26288 'idleExpires': this.idleExpires,
26289 'maxExpires': this.maxExpires,
26290 'tabId': tabId,
26291 };
26292 };
26293
26294
26295 /**
26296 * @static
26297 * @param {SerializedRecording} serializedRecording
26298 * @param {SessionRecordingOptions} options
26299 * @returns {SessionRecording}
26300 */
26301 SessionRecording.deserialize = function (serializedRecording, options) {
26302 var recording = new SessionRecording(_.extend({}, options, {
26303 replayId: serializedRecording['replayId'],
26304 batchStartUrl: serializedRecording['batchStartUrl'],
26305 replayStartUrl: serializedRecording['replayStartUrl'],
26306 idleExpires: serializedRecording['idleExpires'],
26307 maxExpires: serializedRecording['maxExpires'],
26308 replayStartTime: serializedRecording['replayStartTime'],
26309 seqNo: serializedRecording['seqNo'],
26310 sharedLockStorage: options.sharedLockStorage,
26311 }));
26312
26313 return recording;
26314 };
26315
26316 SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, reqBody, callback) {
26317 var onSuccess = function (response, responseBody) {
26318 // Update batch specific props only if the request was successful to guarantee ordering.
26319 // RequestBatcher will always flush the next batch after the previous one succeeds.
26320 // extra check to see if the replay ID has changed so that we don't increment the seqNo on the wrong replay
26321 if (response.status === 200 && this.replayId === currentReplayId) {
26322 this.seqNo++;
26323 this.batchStartUrl = _.info.currentUrl();
26324 }
26325
26326 this._onBatchSent();
26327 callback({
26328 status: 0,
26329 httpStatusCode: response.status,
26330 responseBody: responseBody,
26331 retryAfter: response.headers.get('Retry-After')
26332 });
26333 }.bind(this);
26334 var apiHost = (this._mixpanel.get_api_host && this._mixpanel.get_api_host('record')) || this.getConfig('api_host');
26335 win['fetch'](apiHost + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
26336 'method': 'POST',
26337 'headers': {
26338 'Authorization': 'Basic ' + btoa(this.getConfig('token') + ':'),
26339 'Content-Type': 'application/octet-stream'
26340 },
26341 'body': reqBody,
26342 }).then(function (response) {
26343 response.json().then(function (responseBody) {
26344 onSuccess(response, responseBody);
26345 }).catch(function (error) {
26346 callback({error: error});
26347 });
26348 }).catch(function (error) {
26349 callback({error: error, httpStatusCode: 0});
26350 });
26351 };
26352
26353 SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (data, options, callback) {
26354 var numEvents = data.length;
26355
26356 if (numEvents > 0) {
26357 var replayId = this.replayId;
26358
26359 // each rrweb event has a timestamp - leverage those to get time properties
26360 var batchStartTime = Infinity;
26361 var batchEndTime = -Infinity;
26362 var hasFullSnapshot = false;
26363 for (var i = 0; i < numEvents; i++) {
26364 batchStartTime = Math.min(batchStartTime, data[i].timestamp);
26365 batchEndTime = Math.max(batchEndTime, data[i].timestamp);
26366 if (data[i].type === EventType.FullSnapshot) {
26367 hasFullSnapshot = true;
26368 }
26369 }
26370
26371 if (this.seqNo === 0) {
26372 if (!hasFullSnapshot) {
26373 callback({error: 'First batch does not contain a full snapshot. Aborting recording.'});
26374 this.stopRecording(true);
26375 return;
26376 }
26377 this.replayStartTime = batchStartTime;
26378 } else if (!this.replayStartTime) {
26379 this.reportError('Replay start time not set but seqNo is not 0. Using current batch start time as a fallback.');
26380 this.replayStartTime = batchStartTime;
26381 }
26382
26383 var replayLengthMs = batchEndTime - this.replayStartTime;
26384
26385 var reqParams = {
26386 '$current_url': this.batchStartUrl,
26387 '$lib_version': Config.LIB_VERSION,
26388 'batch_start_time': batchStartTime / 1000,
26389 'mp_lib': 'web',
26390 'replay_id': replayId,
26391 'replay_length_ms': replayLengthMs,
26392 'replay_start_time': this.replayStartTime / 1000,
26393 'replay_start_url': this.replayStartUrl,
26394 'seq': this.seqNo
26395 };
26396 var eventsJson = JSON.stringify(data);
26397 Object.assign(reqParams, this.getUserIdInfo());
26398
26399 if (CompressionStream) {
26400 var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
26401 var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
26402 new Response(gzipStream)
26403 .blob()
26404 .then(function(compressedBlob) {
26405 reqParams['format'] = 'gzip';
26406 this._sendRequest(replayId, reqParams, compressedBlob, callback);
26407 }.bind(this));
26408 } else {
26409 reqParams['format'] = 'body';
26410 this._sendRequest(replayId, reqParams, eventsJson, callback);
26411 }
26412 }
26413 });
26414
26415
26416 SessionRecording.prototype.reportError = function(msg, err) {
26417 logger$3.error.apply(logger$3.error, arguments);
26418 try {
26419 if (!err && !(msg instanceof Error)) {
26420 msg = new Error(msg);
26421 }
26422 this.getConfig('error_reporter')(msg, err);
26423 } catch(err) {
26424 logger$3.error(err);
26425 }
26426 };
26427
26428 /**
26429 * Module for handling the storage and retrieval of recording metadata as well as any active recordings.
26430 * Makes sure that only one tab can be recording at a time.
26431 */
26432 var RecordingRegistry = function (options) {
26433 /** @type {IDBStorageWrapper} */
26434 this.idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
26435 this.errorReporter = options.errorReporter;
26436 this.mixpanelInstance = options.mixpanelInstance;
26437 this.sharedLockStorage = options.sharedLockStorage;
26438 };
26439
26440 RecordingRegistry.prototype.isPersistenceEnabled = function() {
26441 return !this.mixpanelInstance.get_config('disable_persistence');
26442 };
26443
26444 RecordingRegistry.prototype.handleError = function (err) {
26445 this.errorReporter('IndexedDB error: ', err);
26446 };
26447
26448 /**
26449 * @param {import('./session-recording').SerializedRecording} serializedRecording
26450 */
26451 RecordingRegistry.prototype.setActiveRecording = function (serializedRecording) {
26452 if (!this.isPersistenceEnabled()) {
26453 return PromisePolyfill.resolve();
26454 }
26455
26456 var tabId = serializedRecording['tabId'];
26457 if (!tabId) {
26458 console.warn('No tab ID is set, cannot persist recording metadata.');
26459 return PromisePolyfill.resolve();
26460 }
26461
26462 return this.idb.init()
26463 .then(function () {
26464 return this.idb.setItem(tabId, serializedRecording);
26465 }.bind(this))
26466 .catch(this.handleError.bind(this));
26467 };
26468
26469 /**
26470 * @returns {Promise<import('./session-recording').SerializedRecording>}
26471 */
26472 RecordingRegistry.prototype.getActiveRecording = function () {
26473 if (!this.isPersistenceEnabled()) {
26474 return PromisePolyfill.resolve(null);
26475 }
26476
26477 return this.idb.init()
26478 .then(function () {
26479 return this.idb.getItem(this.mixpanelInstance.get_tab_id());
26480 }.bind(this))
26481 .then(function (serializedRecording) {
26482 return isRecordingExpired(serializedRecording) ? null : serializedRecording;
26483 }.bind(this))
26484 .catch(this.handleError.bind(this));
26485 };
26486
26487 RecordingRegistry.prototype.clearActiveRecording = function () {
26488 if (this.isPersistenceEnabled()) {
26489 // mark recording as expired instead of deleting it in case the page unloads mid-flush and doesn't make it to ingestion.
26490 // this will ensure the next pageload will flush the remaining events, but not try to continue the recording.
26491 return this.markActiveRecordingExpired();
26492 } else {
26493 return this.deleteActiveRecording();
26494 }
26495 };
26496
26497 RecordingRegistry.prototype.markActiveRecordingExpired = function () {
26498 return this.getActiveRecording()
26499 .then(function (serializedRecording) {
26500 if (serializedRecording) {
26501 serializedRecording['maxExpires'] = 0;
26502 return this.setActiveRecording(serializedRecording);
26503 }
26504 }.bind(this))
26505 .catch(this.handleError.bind(this));
26506 };
26507
26508 RecordingRegistry.prototype.deleteActiveRecording = function () {
26509 // avoid initializing IDB if this registry instance hasn't already written a recording
26510 if (this.idb.isInitialized()) {
26511 return this.idb.removeItem(this.mixpanelInstance.get_tab_id())
26512 .catch(this.handleError.bind(this));
26513 } else {
26514 return PromisePolyfill.resolve();
26515 }
26516 };
26517
26518 /**
26519 * Flush any inactive recordings from the registry to minimize data loss.
26520 * The main idea here is that we can flush remaining rrweb events on the next page load if a tab is closed mid-batch.
26521 */
26522 RecordingRegistry.prototype.flushInactiveRecordings = function () {
26523 if (!this.isPersistenceEnabled()) {
26524 return PromisePolyfill.resolve([]);
26525 }
26526
26527 return this.idb.init()
26528 .then(function() {
26529 return this.idb.getAll();
26530 }.bind(this))
26531 .then(function (serializedRecordings) {
26532 // clean up any expired recordings from the registry, non-expired ones may be active in other tabs
26533 var unloadPromises = serializedRecordings
26534 .filter(function (serializedRecording) {
26535 return isRecordingExpired(serializedRecording);
26536 })
26537 .map(function (serializedRecording) {
26538 var sessionRecording = SessionRecording.deserialize(serializedRecording, {
26539 mixpanelInstance: this.mixpanelInstance,
26540 sharedLockStorage: this.sharedLockStorage
26541 });
26542 return sessionRecording.unloadPersistedData()
26543 .then(function () {
26544 // expired recording was successfully flushed, we can clean it up from the registry
26545 return this.idb.removeItem(serializedRecording['tabId']);
26546 }.bind(this))
26547 .catch(this.handleError.bind(this));
26548 }.bind(this));
26549
26550 return PromisePolyfill.all(unloadPromises);
26551 }.bind(this))
26552 .catch(this.handleError.bind(this));
26553 };
26554
26555 var logger$2 = console_with_prefix('recorder');
26556
26557 /**
26558 * Recorder API: bundles rrweb and and exposes methods to start and stop recordings.
26559 * @param {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
26560 */
26561 var MixpanelRecorder = function(mixpanelInstance, rrwebRecord, sharedLockStorage) {
26562 this.mixpanelInstance = mixpanelInstance;
26563 this.rrwebRecord = rrwebRecord || record;
26564 this.sharedLockStorage = sharedLockStorage;
26565
26566 /**
26567 * @member {import('./registry').RecordingRegistry}
26568 */
26569 this.recordingRegistry = new RecordingRegistry({
26570 mixpanelInstance: this.mixpanelInstance,
26571 errorReporter: logger$2.error,
26572 sharedLockStorage: sharedLockStorage
26573 });
26574 this._flushInactivePromise = this.recordingRegistry.flushInactiveRecordings();
26575
26576 this.activeRecording = null;
26577 this.stopRecordingInProgress = false;
26578 };
26579
26580 MixpanelRecorder.prototype.startRecording = function(options) {
26581 options = options || {};
26582 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26583 logger$2.log('Recording already in progress, skipping startRecording.');
26584 return;
26585 }
26586
26587 var onIdleTimeout = function () {
26588 logger$2.log('Idle timeout reached, restarting recording.');
26589 this.resetRecording();
26590 }.bind(this);
26591
26592 var onMaxLengthReached = function () {
26593 logger$2.log('Max recording length reached, stopping recording.');
26594 this.resetRecording();
26595 }.bind(this);
26596
26597 var onBatchSent = function () {
26598 this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26599 this['__flushPromise'] = this.activeRecording.batcher._flushPromise;
26600 }.bind(this);
26601
26602 /**
26603 * @type {import('./session-recording').SessionRecordingOptions}
26604 */
26605 var sessionRecordingOptions = {
26606 mixpanelInstance: this.mixpanelInstance,
26607 onBatchSent: onBatchSent,
26608 onIdleTimeout: onIdleTimeout,
26609 onMaxLengthReached: onMaxLengthReached,
26610 replayId: _.UUID(),
26611 rrwebRecord: this.rrwebRecord,
26612 sharedLockStorage: this.sharedLockStorage
26613 };
26614
26615 if (options.activeSerializedRecording) {
26616 this.activeRecording = SessionRecording.deserialize(options.activeSerializedRecording, sessionRecordingOptions);
26617 } else {
26618 this.activeRecording = new SessionRecording(sessionRecordingOptions);
26619 }
26620
26621 this.activeRecording.startRecording(options.shouldStopBatcher);
26622 return this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26623 };
26624
26625 MixpanelRecorder.prototype.stopRecording = function() {
26626 // Prevents activeSerializedRecording from being reused when stopping the recording.
26627 this.stopRecordingInProgress = true;
26628 return this._stopCurrentRecording(false, true).then(function() {
26629 return this.recordingRegistry.clearActiveRecording();
26630 }.bind(this)).then(function() {
26631 this.stopRecordingInProgress = false;
26632 }.bind(this));
26633 };
26634
26635 MixpanelRecorder.prototype.pauseRecording = function() {
26636 return this._stopCurrentRecording(false);
26637 };
26638
26639 MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush, disableActiveRecording) {
26640 if (this.activeRecording) {
26641 var stopRecordingPromise = this.activeRecording.stopRecording(skipFlush);
26642 if (disableActiveRecording) {
26643 this.activeRecording = null;
26644 }
26645 return stopRecordingPromise;
26646 }
26647 return PromisePolyfill.resolve();
26648 };
26649
26650 MixpanelRecorder.prototype.resumeRecording = function (startNewIfInactive) {
26651 if (this.activeRecording && this.activeRecording.isRrwebStopped()) {
26652 this.activeRecording.startRecording(false);
26653 return PromisePolyfill.resolve(null);
26654 }
26655
26656 return this.recordingRegistry.getActiveRecording()
26657 .then(function (activeSerializedRecording) {
26658 if (activeSerializedRecording && !this.stopRecordingInProgress) {
26659 return this.startRecording({activeSerializedRecording: activeSerializedRecording});
26660 } else if (startNewIfInactive) {
26661 return this.startRecording({shouldStopBatcher: false});
26662 } else {
26663 logger$2.log('No resumable recording found.');
26664 return null;
26665 }
26666 }.bind(this));
26667 };
26668
26669
26670 MixpanelRecorder.prototype.resetRecording = function () {
26671 this.stopRecording();
26672 this.startRecording({shouldStopBatcher: true});
26673 };
26674
26675 MixpanelRecorder.prototype.getActiveReplayId = function () {
26676 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26677 return this.activeRecording.replayId;
26678 } else {
26679 return null;
26680 }
26681 };
26682
26683 // getter so that older mixpanel-core versions can still retrieve the replay ID
26684 // when pulling the latest recorder bundle from the CDN
26685 Object.defineProperty(MixpanelRecorder.prototype, 'replayId', {
26686 get: function () {
26687 return this.getActiveReplayId();
26688 }
26689 });
26690
26691 win['__mp_recorder'] = MixpanelRecorder;
26692
26693 // stateless utils
26694 // mostly from https://github.com/mixpanel/mixpanel-js/blob/989ada50f518edab47b9c4fd9535f9fbd5ec5fc0/src/autotrack-utils.js
26695
26696
26697 var EV_CHANGE = 'change';
26698 var EV_CLICK = 'click';
26699 var EV_HASHCHANGE = 'hashchange';
26700 var EV_INPUT = 'input';
26701 var EV_LOAD = 'load';
26702 var EV_MP_LOCATION_CHANGE = 'mp_locationchange';
26703 var EV_POPSTATE = 'popstate';
26704 // TODO scrollend isn't available in Safari: document or polyfill?
26705 var EV_SCROLLEND = 'scrollend';
26706 var EV_SCROLL = 'scroll';
26707 var EV_SELECT = 'select';
26708 var EV_SUBMIT = 'submit';
26709 var EV_TOGGLE = 'toggle';
26710 var EV_VISIBILITYCHANGE = 'visibilitychange';
26711
26712 var CLICK_EVENT_PROPS = [
26713 'clientX', 'clientY',
26714 'offsetX', 'offsetY',
26715 'pageX', 'pageY',
26716 'screenX', 'screenY',
26717 'x', 'y'
26718 ];
26719 var OPT_IN_CLASSES = ['mp-include'];
26720 var OPT_OUT_CLASSES = ['mp-no-track'];
26721 var SENSITIVE_DATA_CLASSES = OPT_OUT_CLASSES.concat(['mp-sensitive']);
26722 var TRACKED_ATTRS = [
26723 'aria-label', 'aria-labelledby', 'aria-describedby',
26724 'href', 'name', 'role', 'title', 'type'
26725 ];
26726
26727 var INTERACTIVE_ARIA_ROLES = {
26728 'button': true,
26729 'checkbox': true,
26730 'combobox': true,
26731 'grid': true,
26732 'link': true,
26733 'listbox': true,
26734 'menu': true,
26735 'menubar': true,
26736 'menuitem': true,
26737 'menuitemcheckbox': true,
26738 'menuitemradio': true,
26739 'navigation': true,
26740 'option': true,
26741 'radio': true,
26742 'radiogroup': true,
26743 'searchbox': true,
26744 'slider': true,
26745 'spinbutton': true,
26746 'switch': true,
26747 'tab': true,
26748 'tablist': true,
26749 'textbox': true,
26750 'tree': true,
26751 'treegrid': true,
26752 'treeitem': true
26753 };
26754
26755 var ALWAYS_NON_INTERACTIVE_TAGS = {
26756 // Document metadata
26757 'base': true,
26758 'head': true,
26759 'html': true,
26760 'link': true,
26761 'meta': true,
26762 'script': true,
26763 'style': true,
26764 'title': true,
26765 // Text formatting
26766 'br': true,
26767 'hr': true,
26768 'wbr': true,
26769 // Other
26770 'noscript': true,
26771 'picture': true,
26772 'source': true,
26773 'template': true,
26774 'track': true
26775 };
26776
26777 // Common container tags that need additional checks
26778 var TEXT_CONTAINER_TAGS = {
26779 'article': true,
26780 'div': true,
26781 'h1': true,
26782 'h2': true,
26783 'h3': true,
26784 'h4': true,
26785 'h5': true,
26786 'h6': true,
26787 'p': true,
26788 'section': true,
26789 'span': true
26790 };
26791
26792 var EVENT_HANDLER_ATTRIBUTES = [
26793 'onclick', 'onmousedown', 'onmouseup', 'onpointerdown', 'onpointerup', 'ontouchend', 'ontouchstart'
26794 ];
26795
26796 var MAX_DEPTH = 5;
26797
26798 var logger$1 = console_with_prefix('autocapture');
26799
26800
26801 function getClasses(el) {
26802 var classes = {};
26803 var classList = getClassName(el).split(' ');
26804 for (var i = 0; i < classList.length; i++) {
26805 var cls = classList[i];
26806 if (cls) {
26807 classes[cls] = true;
26808 }
26809 }
26810 return classes;
26811 }
26812
26813 /*
26814 * Get the className of an element, accounting for edge cases where element.className is an object
26815 * @param {Element} el - element to get the className of
26816 * @returns {string} the element's class
26817 */
26818 function getClassName(el) {
26819 switch(typeof el.className) {
26820 case 'string':
26821 return el.className;
26822 case 'object': // handle cases where className might be SVGAnimatedString or some other type
26823 return el.className.baseVal || el.getAttribute('class') || '';
26824 default: // future proof
26825 return '';
26826 }
26827 }
26828
26829 function getPreviousElementSibling(el) {
26830 if (el.previousElementSibling) {
26831 return el.previousElementSibling;
26832 } else {
26833 do {
26834 el = el.previousSibling;
26835 } while (el && !isElementNode(el));
26836 return el;
26837 }
26838 }
26839
26840 function getPropertiesFromElement(el, ev, blockAttrsSet, extraAttrs, allowElementCallback, allowSelectors) {
26841 var props = {
26842 '$classes': getClassName(el).split(' '),
26843 '$tag_name': el.tagName.toLowerCase()
26844 };
26845 var elId = el.id;
26846 if (elId) {
26847 props['$id'] = elId;
26848 }
26849
26850 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors)) {
26851 _.each(TRACKED_ATTRS.concat(extraAttrs), function(attr) {
26852 if (el.hasAttribute(attr) && !blockAttrsSet[attr]) {
26853 var attrVal = el.getAttribute(attr);
26854 if (shouldTrackValue(attrVal)) {
26855 props['$attr-' + attr] = attrVal;
26856 }
26857 }
26858 });
26859 }
26860
26861 var nthChild = 1;
26862 var nthOfType = 1;
26863 var currentElem = el;
26864 while (currentElem = getPreviousElementSibling(currentElem)) { // eslint-disable-line no-cond-assign
26865 nthChild++;
26866 if (currentElem.tagName === el.tagName) {
26867 nthOfType++;
26868 }
26869 }
26870 props['$nth_child'] = nthChild;
26871 props['$nth_of_type'] = nthOfType;
26872
26873 return props;
26874 }
26875
26876 function getPropsForDOMEvent(ev, config) {
26877 var allowElementCallback = config.allowElementCallback;
26878 var allowSelectors = config.allowSelectors || [];
26879 var blockAttrs = config.blockAttrs || [];
26880 var blockElementCallback = config.blockElementCallback;
26881 var blockSelectors = config.blockSelectors || [];
26882 var captureTextContent = config.captureTextContent || false;
26883 var captureExtraAttrs = config.captureExtraAttrs || [];
26884 var capturedForHeatMap = config.capturedForHeatMap || false;
26885
26886 // convert array to set every time, as the config may have changed
26887 var blockAttrsSet = {};
26888 _.each(blockAttrs, function(attr) {
26889 blockAttrsSet[attr] = true;
26890 });
26891
26892 var props = null;
26893
26894 var target = typeof ev.target === 'undefined' ? ev.srcElement : ev.target;
26895 if (isTextNode(target)) { // defeat Safari bug (see: http://www.quirksmode.org/js/events_properties.html)
26896 target = target.parentNode;
26897 }
26898
26899 if (
26900 shouldTrackDomEvent(target, ev) &&
26901 isElementAllowed(target, ev, allowElementCallback, allowSelectors) &&
26902 !isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26903 ) {
26904 var targetElementList = [target];
26905 var curEl = target;
26906 while (curEl.parentNode && !isTag(curEl, 'body')) {
26907 targetElementList.push(curEl.parentNode);
26908 curEl = curEl.parentNode;
26909 }
26910
26911 var elementsJson = [];
26912 var href, explicitNoTrack = false;
26913 _.each(targetElementList, function(el) {
26914 var shouldTrackDetails = shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors);
26915
26916 // if the element or a parent element is an anchor tag
26917 // include the href as a property
26918 if (!blockAttrsSet['href'] && el.tagName.toLowerCase() === 'a') {
26919 href = el.getAttribute('href');
26920 href = shouldTrackDetails && shouldTrackValue(href) && href;
26921 }
26922
26923 if (isElementBlocked(el, ev, blockElementCallback, blockSelectors)) {
26924 explicitNoTrack = true;
26925 }
26926
26927 elementsJson.push(getPropertiesFromElement(el, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors));
26928 }, this);
26929
26930 if (!explicitNoTrack) {
26931 var docElement = document$1['documentElement'];
26932 props = {
26933 '$event_type': ev.type,
26934 '$host': win.location.host,
26935 '$pathname': win.location.pathname,
26936 '$elements': elementsJson,
26937 '$el_attr__href': href,
26938 '$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
26939 '$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0),
26940 '$pageHeight': document$1['body']['offsetHeight'] || 0,
26941 '$pageWidth': document$1['body']['offsetWidth'] || 0,
26942 };
26943 _.each(captureExtraAttrs, function(attr) {
26944 if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
26945 var attrVal = target.getAttribute(attr);
26946 if (shouldTrackValue(attrVal)) {
26947 props['$el_attr__' + attr] = attrVal;
26948 }
26949 }
26950 });
26951
26952 if (captureTextContent) {
26953 elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26954 if (elementText && elementText.length) {
26955 props['$el_text'] = elementText;
26956 }
26957 }
26958
26959 if (ev.type === EV_CLICK) {
26960 _.each(CLICK_EVENT_PROPS, function(prop) {
26961 if (prop in ev) {
26962 props['$' + prop] = ev[prop];
26963 }
26964 });
26965 if (capturedForHeatMap) {
26966 props['$captured_for_heatmap'] = true;
26967 }
26968 target = guessRealClickTarget(ev);
26969 }
26970 // prioritize text content from "real" click target if different from original target
26971 if (captureTextContent) {
26972 var elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26973 if (elementText && elementText.length) {
26974 props['$el_text'] = elementText;
26975 }
26976 }
26977
26978 if (target) {
26979 // target may have been recalculated; check allowlists and blocklists again
26980 if (
26981 !isElementAllowed(target, ev, allowElementCallback, allowSelectors) ||
26982 isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26983 ) {
26984 return null;
26985 }
26986
26987 var targetProps = getPropertiesFromElement(target, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors);
26988 props['$target'] = targetProps;
26989 // pull up more props onto main event props
26990 props['$el_classes'] = targetProps['$classes'];
26991 _.extend(props, _.strip_empty_properties({
26992 '$el_id': targetProps['$id'],
26993 '$el_tag_name': targetProps['$tag_name']
26994 }));
26995 }
26996 }
26997 }
26998
26999 return props;
27000 }
27001
27002
27003 /**
27004 * Get the direct text content of an element, protecting against sensitive data collection.
27005 * Concats textContent of each of the element's text node children; this avoids potential
27006 * collection of sensitive data that could happen if we used element.textContent and the
27007 * element had sensitive child elements, since element.textContent includes child content.
27008 * Scrubs values that look like they could be sensitive (i.e. cc or ssn number).
27009 * @param {Element} el - element to get the text of
27010 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
27011 * @returns {string} the element's direct text content
27012 */
27013 function getSafeText(el, ev, allowElementCallback, allowSelectors) {
27014 var elText = '';
27015
27016 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) && el.childNodes && el.childNodes.length) {
27017 _.each(el.childNodes, function(child) {
27018 if (isTextNode(child) && child.textContent) {
27019 elText += _.trim(child.textContent)
27020 // scrub potentially sensitive values
27021 .split(/(\s+)/).filter(shouldTrackValue).join('')
27022 // normalize whitespace
27023 .replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ')
27024 // truncate
27025 .substring(0, 255);
27026 }
27027 });
27028 }
27029
27030 return _.trim(elText);
27031 }
27032
27033 function guessRealClickTarget(ev) {
27034 var target = ev.target;
27035 var composedPath = ev['composedPath']();
27036 for (var i = 0; i < composedPath.length; i++) {
27037 var node = composedPath[i];
27038 if (
27039 isTag(node, 'a') ||
27040 isTag(node, 'button') ||
27041 isTag(node, 'input') ||
27042 isTag(node, 'select') ||
27043 (node.getAttribute && node.getAttribute('role') === 'button')
27044 ) {
27045 target = node;
27046 break;
27047 }
27048 if (node === target) {
27049 break;
27050 }
27051 }
27052 return target;
27053 }
27054
27055 function isElementAllowed(el, ev, allowElementCallback, allowSelectors) {
27056 if (allowElementCallback) {
27057 try {
27058 if (!allowElementCallback(el, ev)) {
27059 return false;
27060 }
27061 } catch (err) {
27062 logger$1.critical('Error while checking element in allowElementCallback', err);
27063 return false;
27064 }
27065 }
27066
27067 if (!allowSelectors.length) {
27068 // no allowlist; all elements are fair game
27069 return true;
27070 }
27071
27072 for (var i = 0; i < allowSelectors.length; i++) {
27073 var sel = allowSelectors[i];
27074 try {
27075 if (el['matches'](sel)) {
27076 return true;
27077 }
27078 } catch (err) {
27079 logger$1.critical('Error while checking selector: ' + sel, err);
27080 }
27081 }
27082 return false;
27083 }
27084
27085 function isElementBlocked(el, ev, blockElementCallback, blockSelectors) {
27086 var i;
27087
27088 if (blockElementCallback) {
27089 try {
27090 if (blockElementCallback(el, ev)) {
27091 return true;
27092 }
27093 } catch (err) {
27094 logger$1.critical('Error while checking element in blockElementCallback', err);
27095 return true;
27096 }
27097 }
27098
27099 if (blockSelectors && blockSelectors.length) {
27100 // programmatically prevent tracking of elements that match CSS selectors
27101 for (i = 0; i < blockSelectors.length; i++) {
27102 var sel = blockSelectors[i];
27103 try {
27104 if (el['matches'](sel)) {
27105 return true;
27106 }
27107 } catch (err) {
27108 logger$1.critical('Error while checking selector: ' + sel, err);
27109 }
27110 }
27111 }
27112
27113 // allow users to programmatically prevent tracking of elements by adding default classes such as 'mp-no-track'
27114 var classes = getClasses(el);
27115 for (i = 0; i < OPT_OUT_CLASSES.length; i++) {
27116 if (classes[OPT_OUT_CLASSES[i]]) {
27117 return true;
27118 }
27119 }
27120
27121 return false;
27122 }
27123
27124 /*
27125 * Check whether a DOM node has nodeType Node.ELEMENT_NODE
27126 * @param {Node} node - node to check
27127 * @returns {boolean} whether node is of the correct nodeType
27128 */
27129 function isElementNode(node) {
27130 return node && node.nodeType === 1; // Node.ELEMENT_NODE - use integer constant for browser portability
27131 }
27132
27133 /*
27134 * Check whether an element is of a given tag type.
27135 * Due to potential reference discrepancies (such as the webcomponents.js polyfill),
27136 * we want to match tagNames instead of specific references because something like
27137 * element === document.body won't always work because element might not be a native
27138 * element.
27139 * @param {Element} el - element to check
27140 * @param {string} tag - tag name (e.g., "div")
27141 * @returns {boolean} whether el is of the given tag type
27142 */
27143 function isTag(el, tag) {
27144 return el && el.tagName && el.tagName.toLowerCase() === tag.toLowerCase();
27145 }
27146
27147 /*
27148 * Check whether a DOM node is a TEXT_NODE
27149 * @param {Node} node - node to check
27150 * @returns {boolean} whether node is of type Node.TEXT_NODE
27151 */
27152 function isTextNode(node) {
27153 return node && node.nodeType === 3; // Node.TEXT_NODE - use integer constant for browser portability
27154 }
27155
27156 function minDOMApisSupported() {
27157 try {
27158 var testEl = document$1.createElement('div');
27159 return !!testEl['matches'];
27160 } catch (err) {
27161 return false;
27162 }
27163 }
27164
27165 function weakSetSupported() {
27166 return typeof WeakSet !== 'undefined';
27167 }
27168
27169 /*
27170 * Check whether a DOM event should be "tracked" or if it may contain sensitive data
27171 * using a variety of heuristics.
27172 * @param {Element} el - element to check
27173 * @param {Event} ev - event to check
27174 * @returns {boolean} whether the event should be tracked
27175 */
27176 function shouldTrackDomEvent(el, ev) {
27177 if (!el || isTag(el, 'html') || !isElementNode(el)) {
27178 return false;
27179 }
27180 var tag = el.tagName.toLowerCase();
27181 switch (tag) {
27182 case 'form':
27183 return ev.type === EV_SUBMIT;
27184 case 'input':
27185 if (['button', 'submit'].indexOf(el.getAttribute('type')) === -1) {
27186 return ev.type === EV_CHANGE;
27187 } else {
27188 return ev.type === EV_CLICK;
27189 }
27190 case 'select':
27191 case 'textarea':
27192 return ev.type === EV_CHANGE;
27193 default:
27194 return ev.type === EV_CLICK;
27195 }
27196 }
27197
27198 /*
27199 * Check whether a DOM element should be "tracked" or if it may contain sensitive data
27200 * using a variety of heuristics.
27201 * @param {Element} el - element to check
27202 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
27203 * @returns {boolean} whether the element should be tracked
27204 */
27205 function shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) {
27206 var i;
27207
27208 if (!isElementAllowed(el, ev, allowElementCallback, allowSelectors)) {
27209 return false;
27210 }
27211
27212 for (var curEl = el; curEl.parentNode && !isTag(curEl, 'body'); curEl = curEl.parentNode) {
27213 var classes = getClasses(curEl);
27214 for (i = 0; i < SENSITIVE_DATA_CLASSES.length; i++) {
27215 if (classes[SENSITIVE_DATA_CLASSES[i]]) {
27216 return false;
27217 }
27218 }
27219 }
27220
27221 var elClasses = getClasses(el);
27222 for (i = 0; i < OPT_IN_CLASSES.length; i++) {
27223 if (elClasses[OPT_IN_CLASSES[i]]) {
27224 return true;
27225 }
27226 }
27227
27228 // don't send data from inputs or similar elements since there will always be
27229 // a risk of clientside javascript placing sensitive data in attributes
27230 if (
27231 isTag(el, 'input') ||
27232 isTag(el, 'select') ||
27233 isTag(el, 'textarea') ||
27234 el.getAttribute('contenteditable') === 'true'
27235 ) {
27236 return false;
27237 }
27238
27239 // don't include hidden or password fields
27240 var type = el.type || '';
27241 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"]
27242 switch(type.toLowerCase()) {
27243 case 'hidden':
27244 return false;
27245 case 'password':
27246 return false;
27247 }
27248 }
27249
27250 // filter out data from fields that look like sensitive fields
27251 var name = el.name || el.id || '';
27252 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"]
27253 var sensitiveNameRegex = /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i;
27254 if (sensitiveNameRegex.test(name.replace(/[^a-zA-Z0-9]/g, ''))) {
27255 return false;
27256 }
27257 }
27258
27259 return true;
27260 }
27261
27262
27263 /*
27264 * Check whether a string value should be "tracked" or if it may contain sensitive data
27265 * using a variety of heuristics.
27266 * @param {string} value - string value to check
27267 * @returns {boolean} whether the element should be tracked
27268 */
27269 function shouldTrackValue(value) {
27270 if (value === null || _.isUndefined(value)) {
27271 return false;
27272 }
27273
27274 if (typeof value === 'string') {
27275 value = _.trim(value);
27276
27277 // check to see if input value looks like a credit card number
27278 // see: https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch04s20.html
27279 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}))$/;
27280 if (ccRegex.test((value || '').replace(/[- ]/g, ''))) {
27281 return false;
27282 }
27283
27284 // check to see if input value looks like a social security number
27285 var ssnRegex = /(^\d{3}-?\d{2}-?\d{4}$)/;
27286 if (ssnRegex.test(value)) {
27287 return false;
27288 }
27289 }
27290
27291 return true;
27292 }
27293
27294 /**
27295 * Creates a cross-browser compatible scroll end function with appropriate event listener.
27296 * For browsers that support scrollend, returns the original function with scrollend event.
27297 * For browsers without scrollend support, returns a debounced function that triggers
27298 * 100ms after the last scroll event to simulate scrollend behavior.
27299 * @param {Function} originalFunction - The function to call when scrolling ends
27300 * @returns {Object} Object containing listener function and eventType string
27301 * @returns {Function} returns.listener - The wrapped function to use as event listener
27302 * @returns {string} returns.eventType - The event type to listen for ('scrollend' or 'scroll')
27303 */
27304 function getPolyfillScrollEndFunction(originalFunction) {
27305 var supportsScrollEnd = 'onscrollend' in win;
27306 var polyfillFunction = safewrap(originalFunction);
27307 var polyfillEvent = EV_SCROLLEND;
27308 if (!supportsScrollEnd) {
27309 // Polyfill for browsers without scrollend support: wait 100ms after the last scroll event
27310 // https://developer.chrome.com/blog/scrollend-a-new-javascript-event
27311 var scrollTimer = null;
27312 var scrollDelayMs = 100;
27313
27314 polyfillFunction = safewrap(function() {
27315 clearTimeout(scrollTimer);
27316 scrollTimer = setTimeout(originalFunction, scrollDelayMs);
27317 });
27318
27319 polyfillEvent = EV_SCROLL;
27320 }
27321
27322 return {
27323 listener: polyfillFunction,
27324 eventType: polyfillEvent
27325 };
27326 }
27327
27328 function hasInlineEventHandlers(element) {
27329 for (var i = 0; i < EVENT_HANDLER_ATTRIBUTES.length; i++) {
27330 if (element.hasAttribute(EVENT_HANDLER_ATTRIBUTES[i])) {
27331 return true;
27332 }
27333 }
27334 return false;
27335 }
27336
27337 function hasInteractiveAriaRole(element) {
27338 var role = element.getAttribute('role');
27339 if (!role) return false;
27340
27341 // Handle invalid markup where multiple roles might be specified
27342 // Only the first token is recognized per ARIA spec
27343 var primaryRole = role.trim().split(/\s+/)[0].toLowerCase();
27344
27345 return INTERACTIVE_ARIA_ROLES[primaryRole];
27346 }
27347
27348 function hasAnyInteractivityIndicators(element) {
27349 var tagName = element.tagName.toLowerCase();
27350
27351 // Check for interactive HTML elements
27352 if (tagName === 'button' ||
27353 tagName === 'input' ||
27354 tagName === 'select' ||
27355 tagName === 'textarea' ||
27356 tagName === 'details' ||
27357 tagName === 'dialog') {
27358 return true;
27359 }
27360
27361 if (element.isContentEditable) {
27362 return true;
27363 }
27364
27365 if (element.onclick || element.onmousedown || element.onmouseup || element.ontouchstart || element.ontouchend) {
27366 return true;
27367 }
27368
27369 if (hasInlineEventHandlers(element)) {
27370 return true;
27371 }
27372
27373 if (hasInteractiveAriaRole(element)) {
27374 return true;
27375 }
27376
27377 if (tagName === 'a' && element.hasAttribute('href')) {
27378 return true;
27379 }
27380
27381 if (element.hasAttribute('tabindex')) {
27382 return true;
27383 }
27384
27385 return false;
27386 }
27387
27388
27389 function isDefinitelyNonInteractive(element) {
27390 if (!element || !element.tagName) {
27391 return true;
27392 }
27393
27394 var tagName = element.tagName.toLowerCase();
27395
27396 // These tags are definitely non-interactive
27397 if (ALWAYS_NON_INTERACTIVE_TAGS[tagName]) {
27398 return true;
27399 }
27400
27401 // For all other elements, we can only be certain they're non-interactive if they lack ALL indicators of interactivity
27402 // Check for any signs of interactivity
27403 if (hasAnyInteractivityIndicators(element)) {
27404 return false;
27405 }
27406
27407 // Check parent chain for interactive context
27408 var parent = element.parentElement;
27409 var depth = 0;
27410
27411 while (parent && depth < MAX_DEPTH) {
27412 if (hasAnyInteractivityIndicators(parent)) {
27413 return false; // Element is inside an interactive parent
27414 }
27415
27416 if (parent.getRootNode && parent.getRootNode() !== document$1) {
27417 var root = parent.getRootNode();
27418 if (root.host && hasAnyInteractivityIndicators(root.host)) {
27419 return false; // Inside an interactive shadow host
27420 }
27421 }
27422
27423 parent = parent.parentElement;
27424 depth++;
27425 }
27426
27427 // Pure text containers without any interactive context
27428 if (TEXT_CONTAINER_TAGS[tagName]) {
27429 // These are non-interactive ONLY if they have no interactive indicators (already checked as part of hasAnyInteractivityIndicators)
27430 return true;
27431 }
27432
27433 // Default: we can't be certain it's non-interactive
27434 return false;
27435 }
27436
27437 /** @const */ var DEFAULT_RAGE_CLICK_THRESHOLD_PX = 30;
27438 /** @const */ var DEFAULT_RAGE_CLICK_TIMEOUT_MS = 1000;
27439 /** @const */ var DEFAULT_RAGE_CLICK_CLICK_COUNT = 4;
27440
27441 function RageClickTracker() {
27442 this.clicks = [];
27443 }
27444
27445 RageClickTracker.prototype.isRageClick = function(x, y, options) {
27446 options = options || {};
27447 var thresholdPx = options['threshold_px'] || DEFAULT_RAGE_CLICK_THRESHOLD_PX;
27448 var timeoutMs = options['timeout_ms'] || DEFAULT_RAGE_CLICK_TIMEOUT_MS;
27449 var clickCount = options['click_count'] || DEFAULT_RAGE_CLICK_CLICK_COUNT;
27450 var timestamp = Date.now();
27451
27452 var lastClick = this.clicks[this.clicks.length - 1];
27453 if (
27454 lastClick &&
27455 timestamp - lastClick.timestamp < timeoutMs &&
27456 Math.sqrt(Math.pow(x - lastClick.x, 2) + Math.pow(y - lastClick.y, 2)) < thresholdPx
27457 ) {
27458 this.clicks.push({ x: x, y: y, timestamp: timestamp });
27459 if (this.clicks.length >= clickCount) {
27460 this.clicks = [];
27461 return true;
27462 }
27463 } else {
27464 this.clicks = [{ x: x, y: y, timestamp: timestamp }];
27465 }
27466 return false;
27467 };
27468
27469 function ShadowDOMObserver(changeCallback, observerConfig) {
27470 this.changeCallback = changeCallback || function() {};
27471 this.observerConfig = observerConfig;
27472
27473 this.observedShadowRoots = null;
27474 this.shadowObservers = [];
27475 }
27476
27477 ShadowDOMObserver.prototype.getEventTarget = function(event) {
27478 if (!this.observedShadowRoots) {
27479 return;
27480 }
27481 var path = this.getComposedPath(event);
27482 if (path && path.length) {
27483 return path[0];
27484 }
27485
27486 return event['target'] || event['srcElement'];
27487 };
27488
27489
27490 ShadowDOMObserver.prototype.getComposedPath = function(event) {
27491 if ('composedPath' in event) {
27492 return event['composedPath']();
27493 }
27494
27495 return [];
27496 };
27497 ShadowDOMObserver.prototype.observeFromEvent = function(event) {
27498 if (!this.observedShadowRoots) {
27499 return;
27500 }
27501
27502 var path = this.getComposedPath(event);
27503
27504 // Check each element in path for shadow roots
27505 for (var i = 0; i < path.length; i++) {
27506 var element = path[i];
27507
27508 if (element && element.shadowRoot) {
27509 this.observeShadowRoot(element.shadowRoot);
27510 }
27511 }
27512 };
27513
27514
27515 ShadowDOMObserver.prototype.observeShadowRoot = function(shadowRoot) {
27516 if (!this.observedShadowRoots || this.observedShadowRoots.has(shadowRoot)) {
27517 return;
27518 }
27519
27520 var self = this;
27521
27522 try {
27523 this.observedShadowRoots.add(shadowRoot);
27524
27525 var observer = new window.MutationObserver(function() {
27526 self.changeCallback();
27527 });
27528
27529 observer.observe(shadowRoot, this.observerConfig);
27530 this.shadowObservers.push(observer);
27531 } catch (e) {
27532 logger$1.critical('Error while observing shadow root', e);
27533 }
27534 };
27535
27536
27537 ShadowDOMObserver.prototype.start = function() {
27538 if (this.observedShadowRoots) {
27539 return;
27540 }
27541
27542 if (!weakSetSupported()) {
27543 logger$1.critical('Shadow DOM observation unavailable: WeakSet not supported');
27544 return;
27545 }
27546
27547 this.observedShadowRoots = new WeakSet();
27548 };
27549
27550 ShadowDOMObserver.prototype.stop = function() {
27551 if (!this.observedShadowRoots) {
27552 return;
27553 }
27554
27555 for (var i = 0; i < this.shadowObservers.length; i++) {
27556 try {
27557 this.shadowObservers[i].disconnect();
27558 } catch (e) {
27559 logger$1.critical('Error while disconnecting shadow DOM observer', e);
27560 }
27561 }
27562 this.shadowObservers = [];
27563 this.observedShadowRoots = null;
27564 };
27565
27566 /** @const */ var DEFAULT_DEAD_CLICK_TIMEOUT_MS = 500;
27567 /** @const */ var INTERACTION_EVENTS = [EV_CHANGE, EV_INPUT, EV_SUBMIT, EV_SELECT, EV_TOGGLE];
27568 /** @const */ var LAYOUT_EVENTS = [EV_SCROLLEND];
27569 /** @const */ var NAVIGATION_EVENTS = [EV_HASHCHANGE];
27570 /** @const */ var MUTATION_OBSERVER_CONFIG = {
27571 characterData: true,
27572 childList: true,
27573 subtree: true,
27574 attributes: true,
27575 attributeFilter: ['style', 'class', 'hidden', 'checked', 'selected', 'value', 'display', 'visibility']
27576 };
27577
27578
27579 function DeadClickTracker(onDeadClickCallback) {
27580 this.eventListeners = [];
27581 this.mutationObserver = null;
27582 this.shadowDOMObserver = null;
27583
27584 this.isTracking = false;
27585 this.lastChangeEventTimestamp = 0;
27586 this.pendingClicks = [];
27587 this.onDeadClickCallback = onDeadClickCallback;
27588 this.processingActive = false;
27589 this.processingTimeout = null;
27590 }
27591
27592
27593 DeadClickTracker.prototype.addClick = function(event) {
27594 var element = this.shadowDOMObserver && this.shadowDOMObserver.getEventTarget(event);
27595
27596 if (!element) {
27597 element = event['target'] || event['srcElement'];
27598 }
27599
27600 if (!element || isDefinitelyNonInteractive(element)) {
27601 return false;
27602 }
27603
27604 if (this.shadowDOMObserver) {
27605 this.shadowDOMObserver.observeFromEvent(event);
27606 }
27607 this.pendingClicks.push({
27608 element: element,
27609 event: event,
27610 timestamp: Date.now()
27611 });
27612 return true;
27613 };
27614
27615 DeadClickTracker.prototype.trackClick = function(event, config) {
27616 if (!this.isTracking) {
27617 return false;
27618 }
27619
27620 var added = this.addClick(event);
27621 if (added) {
27622 this.triggerProcessing(config);
27623 }
27624 return added;
27625 };
27626
27627 DeadClickTracker.prototype.getDeadClicks = function(config) {
27628 if (this.pendingClicks.length === 0) {
27629 return [];
27630 }
27631
27632 var timeoutMs = config['timeout_ms'];
27633 var now = Date.now();
27634 var clicksToEvaluate = this.pendingClicks.slice(); // Copy array
27635 this.pendingClicks = []; // Clear original
27636
27637 var deadClicks = [];
27638
27639 for (var i = 0; i < clicksToEvaluate.length; i++) {
27640 var click = clicksToEvaluate[i];
27641
27642 if (now - click.timestamp >= timeoutMs) {
27643 // Click has exceeded timeout, check if it's dead by looking for changes after this specific click
27644 if (!this.hasChangesAfter(click.timestamp)) {
27645 deadClicks.push(click);
27646 }
27647 } else {
27648 // Still pending - add back
27649 this.pendingClicks.push(click);
27650 }
27651 }
27652
27653 return deadClicks;
27654 };
27655
27656 DeadClickTracker.prototype.hasChangesAfter = function(timestamp) {
27657 // 100ms tolerance for race condition between when we record the click and the change event
27658 return this.lastChangeEventTimestamp >= (timestamp - 100);
27659 };
27660
27661 DeadClickTracker.prototype.recordChangeEvent = function() {
27662 this.lastChangeEventTimestamp = Date.now();
27663 };
27664
27665 DeadClickTracker.prototype.triggerProcessing = function(config) {
27666 // Prevent multiple concurrent processing chains
27667 if (this.processingActive) {
27668 return;
27669 }
27670 this.processingActive = true;
27671 this.processRecursively(config);
27672 };
27673
27674 DeadClickTracker.prototype.processRecursively = function(config) {
27675 if (!this.isTracking || !this.onDeadClickCallback) {
27676 this.processingActive = false;
27677 return;
27678 }
27679
27680 var timeoutMs = config['timeout_ms'];
27681 var self = this;
27682
27683 this.processingTimeout = setTimeout(function() {
27684 if (!self.processingActive) {
27685 return;
27686 }
27687
27688 var deadClicks = self.getDeadClicks(config);
27689
27690 for (var i = 0; i < deadClicks.length; i++) {
27691 self.onDeadClickCallback(deadClicks[i].event);
27692 }
27693
27694 if (self.pendingClicks.length > 0) {
27695 self.processRecursively(config);
27696 } else {
27697 self.processingActive = false;
27698 }
27699 }, timeoutMs);
27700 };
27701
27702 DeadClickTracker.prototype.startTracking = function() {
27703 if (this.isTracking) {
27704 return;
27705 }
27706
27707 this.isTracking = true;
27708
27709 var self = this;
27710
27711 INTERACTION_EVENTS.forEach(function(event) {
27712 var handler = function() {
27713 self.recordChangeEvent();
27714 };
27715 document.addEventListener(event, handler, { capture: true, passive: true });
27716 self.eventListeners.push({ target: document, event: event, handler: handler, options: { capture: true, passive: true } });
27717 });
27718 NAVIGATION_EVENTS.forEach(function(event) {
27719 var handler = function() {
27720 self.recordChangeEvent();
27721 };
27722 window.addEventListener(event, handler);
27723 self.eventListeners.push({ target: window, event: event, handler: handler });
27724 });
27725 LAYOUT_EVENTS.forEach(function(event) {
27726 var handler = function() {
27727 self.recordChangeEvent();
27728 };
27729 window.addEventListener(event, handler, { passive: true });
27730 self.eventListeners.push({ target: window, event: event, handler: handler, options: { passive: true } });
27731 });
27732 var selectionHandler = function() {
27733 self.recordChangeEvent();
27734 };
27735 document.addEventListener('selectionchange', selectionHandler);
27736 self.eventListeners.push({ target: document, event: 'selectionchange', handler: selectionHandler });
27737
27738 // Set up MutationObserver
27739 if (window.MutationObserver) {
27740 try {
27741 this.mutationObserver = new window.MutationObserver(function() {
27742 self.recordChangeEvent();
27743 });
27744
27745 this.mutationObserver.observe(document.body || document.documentElement, MUTATION_OBSERVER_CONFIG);
27746 } catch (e) {
27747 logger$1.critical('Error while setting up mutation observer', e);
27748 }
27749 }
27750
27751 // Set up Shadow DOM observer
27752 if (window.customElements) {
27753 try {
27754 this.shadowDOMObserver = new ShadowDOMObserver(
27755 function() {
27756 self.recordChangeEvent();
27757 },
27758 MUTATION_OBSERVER_CONFIG
27759 );
27760 this.shadowDOMObserver.start();
27761 } catch (e) {
27762 logger$1.critical('Error while setting up shadow DOM observer', e);
27763 this.shadowDOMObserver = null;
27764 }
27765 }
27766 };
27767
27768 DeadClickTracker.prototype.stopTracking = function() {
27769 if (!this.isTracking) {
27770 return;
27771 }
27772
27773 this.isTracking = false;
27774 this.pendingClicks = [];
27775 this.lastChangeEventTimestamp = 0;
27776 this.processingActive = false;
27777
27778 if (this.processingTimeout) {
27779 clearTimeout(this.processingTimeout);
27780 this.processingTimeout = null;
27781 }
27782
27783 // Remove all event listeners
27784 for (var i = 0; i < this.eventListeners.length; i++) {
27785 var listener = this.eventListeners[i];
27786 try {
27787 listener.target.removeEventListener(listener.event, listener.handler, listener.options);
27788 } catch (e) {
27789 logger$1.critical('Error while removing event listener', e);
27790 }
27791 }
27792 this.eventListeners = [];
27793
27794 if (this.mutationObserver) {
27795 try {
27796 this.mutationObserver.disconnect();
27797 } catch (e) {
27798 logger$1.critical('Error while disconnecting mutation observer', e);
27799 }
27800 this.mutationObserver = null;
27801 }
27802
27803 if (this.shadowDOMObserver) {
27804 try {
27805 this.shadowDOMObserver.stop();
27806 } catch (e) {
27807 logger$1.critical('Error while stopping shadow DOM observer', e);
27808 }
27809 this.shadowDOMObserver = null;
27810 }
27811 };
27812
27813 var AUTOCAPTURE_CONFIG_KEY = 'autocapture';
27814 var LEGACY_PAGEVIEW_CONFIG_KEY = 'track_pageview';
27815
27816 var PAGEVIEW_OPTION_FULL_URL = 'full-url';
27817 var PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING = 'url-with-path-and-query-string';
27818 var PAGEVIEW_OPTION_URL_WITH_PATH = 'url-with-path';
27819
27820 var CONFIG_ALLOW_ELEMENT_CALLBACK = 'allow_element_callback';
27821 var CONFIG_ALLOW_SELECTORS = 'allow_selectors';
27822 var CONFIG_ALLOW_URL_REGEXES = 'allow_url_regexes';
27823 var CONFIG_BLOCK_ATTRS = 'block_attrs';
27824 var CONFIG_BLOCK_ELEMENT_CALLBACK = 'block_element_callback';
27825 var CONFIG_BLOCK_SELECTORS = 'block_selectors';
27826 var CONFIG_BLOCK_URL_REGEXES = 'block_url_regexes';
27827 var CONFIG_CAPTURE_EXTRA_ATTRS = 'capture_extra_attrs';
27828 var CONFIG_CAPTURE_TEXT_CONTENT = 'capture_text_content';
27829 var CONFIG_SCROLL_CAPTURE_ALL = 'scroll_capture_all';
27830 var CONFIG_SCROLL_CHECKPOINTS = 'scroll_depth_percent_checkpoints';
27831 var CONFIG_TRACK_CLICK = 'click';
27832 var CONFIG_TRACK_DEAD_CLICK = 'dead_click';
27833 var CONFIG_TRACK_INPUT = 'input';
27834 var CONFIG_TRACK_PAGEVIEW = 'pageview';
27835 var CONFIG_TRACK_RAGE_CLICK = 'rage_click';
27836 var CONFIG_TRACK_SCROLL = 'scroll';
27837 var CONFIG_TRACK_PAGE_LEAVE = 'page_leave';
27838 var CONFIG_TRACK_SUBMIT = 'submit';
27839
27840 var CONFIG_DEFAULTS$1 = {};
27841 CONFIG_DEFAULTS$1[CONFIG_ALLOW_SELECTORS] = [];
27842 CONFIG_DEFAULTS$1[CONFIG_ALLOW_URL_REGEXES] = [];
27843 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ATTRS] = [];
27844 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ELEMENT_CALLBACK] = null;
27845 CONFIG_DEFAULTS$1[CONFIG_BLOCK_SELECTORS] = [];
27846 CONFIG_DEFAULTS$1[CONFIG_BLOCK_URL_REGEXES] = [];
27847 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_EXTRA_ATTRS] = [];
27848 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_TEXT_CONTENT] = false;
27849 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CAPTURE_ALL] = false;
27850 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CHECKPOINTS] = [25, 50, 75, 100];
27851 CONFIG_DEFAULTS$1[CONFIG_TRACK_CLICK] = true;
27852 CONFIG_DEFAULTS$1[CONFIG_TRACK_DEAD_CLICK] = true;
27853 CONFIG_DEFAULTS$1[CONFIG_TRACK_INPUT] = true;
27854 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGEVIEW] = PAGEVIEW_OPTION_FULL_URL;
27855 CONFIG_DEFAULTS$1[CONFIG_TRACK_RAGE_CLICK] = true;
27856 CONFIG_DEFAULTS$1[CONFIG_TRACK_SCROLL] = true;
27857 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGE_LEAVE] = false;
27858 CONFIG_DEFAULTS$1[CONFIG_TRACK_SUBMIT] = true;
27859
27860 var DEFAULT_PROPS = {
27861 '$mp_autocapture': true
27862 };
27863
27864 var MP_EV_CLICK = '$mp_click';
27865 var MP_EV_DEAD_CLICK = '$mp_dead_click';
27866 var MP_EV_INPUT = '$mp_input_change';
27867 var MP_EV_RAGE_CLICK = '$mp_rage_click';
27868 var MP_EV_SCROLL = '$mp_scroll';
27869 var MP_EV_SUBMIT = '$mp_submit';
27870 var MP_EV_PAGE_LEAVE = '$mp_page_leave';
27871
27872 /**
27873 * Autocapture: manages automatic event tracking
27874 * @constructor
27875 */
27876 var Autocapture = function(mp) {
27877 this.mp = mp;
27878 this.maxScrollViewDepth = 0;
27879 this.hasTrackedScrollSession = false;
27880 this.previousScrollHeight = 0;
27881 };
27882
27883 Autocapture.prototype.init = function() {
27884 if (!minDOMApisSupported()) {
27885 logger$1.critical('Autocapture unavailable: missing required DOM APIs');
27886 return;
27887 }
27888 this.initPageListeners();
27889 this.initPageviewTracking();
27890 this.initClickTracking();
27891 this.initDeadClickTracking();
27892 this.initInputTracking();
27893 this.initScrollTracking();
27894 this.initSubmitTracking();
27895 this.initRageClickTracking();
27896 this.initPageLeaveTracking();
27897 };
27898
27899 Autocapture.prototype.getFullConfig = function() {
27900 var autocaptureConfig = this.mp.get_config(AUTOCAPTURE_CONFIG_KEY);
27901 if (!autocaptureConfig) {
27902 // Autocapture is completely off
27903 return {};
27904 } else if (_.isObject(autocaptureConfig)) {
27905 return _.extend({}, CONFIG_DEFAULTS$1, autocaptureConfig);
27906 } else {
27907 // Autocapture config is non-object truthy value, return default
27908 return CONFIG_DEFAULTS$1;
27909 }
27910 };
27911
27912 Autocapture.prototype.getConfig = function(key) {
27913 return this.getFullConfig()[key];
27914 };
27915
27916 Autocapture.prototype.currentUrlBlocked = function() {
27917 var i;
27918 var currentUrl = _.info.currentUrl();
27919
27920 var allowUrlRegexes = this.getConfig(CONFIG_ALLOW_URL_REGEXES) || [];
27921 if (allowUrlRegexes.length) {
27922 // we're using an allowlist, only track if current URL matches
27923 var allowed = false;
27924 for (i = 0; i < allowUrlRegexes.length; i++) {
27925 var allowRegex = allowUrlRegexes[i];
27926 try {
27927 if (currentUrl.match(allowRegex)) {
27928 allowed = true;
27929 break;
27930 }
27931 } catch (err) {
27932 logger$1.critical('Error while checking block URL regex: ' + allowRegex, err);
27933 return true;
27934 }
27935 }
27936 if (!allowed) {
27937 // wasn't allowed by any regex
27938 return true;
27939 }
27940 }
27941
27942 var blockUrlRegexes = this.getConfig(CONFIG_BLOCK_URL_REGEXES) || [];
27943 if (!blockUrlRegexes || !blockUrlRegexes.length) {
27944 return false;
27945 }
27946
27947 for (i = 0; i < blockUrlRegexes.length; i++) {
27948 try {
27949 if (currentUrl.match(blockUrlRegexes[i])) {
27950 return true;
27951 }
27952 } catch (err) {
27953 logger$1.critical('Error while checking block URL regex: ' + blockUrlRegexes[i], err);
27954 return true;
27955 }
27956 }
27957 return false;
27958 };
27959
27960 Autocapture.prototype.pageviewTrackingConfig = function() {
27961 // supports both autocapture config and old track_pageview config
27962 if (this.mp.get_config(AUTOCAPTURE_CONFIG_KEY)) {
27963 return this.getConfig(CONFIG_TRACK_PAGEVIEW);
27964 } else {
27965 return this.mp.get_config(LEGACY_PAGEVIEW_CONFIG_KEY);
27966 }
27967 };
27968
27969 // helper for event handlers
27970 Autocapture.prototype.trackDomEvent = function(ev, mpEventName) {
27971 if (this.currentUrlBlocked()) {
27972 return;
27973 }
27974
27975 var isCapturedForHeatMap = this.mp.is_recording_heatmap_data() && (
27976 (mpEventName === MP_EV_CLICK && !this.getConfig(CONFIG_TRACK_CLICK)) ||
27977 (mpEventName === MP_EV_RAGE_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK)) ||
27978 (mpEventName === MP_EV_DEAD_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK))
27979 );
27980
27981 var props = getPropsForDOMEvent(ev, {
27982 allowElementCallback: this.getConfig(CONFIG_ALLOW_ELEMENT_CALLBACK),
27983 allowSelectors: this.getConfig(CONFIG_ALLOW_SELECTORS),
27984 blockAttrs: this.getConfig(CONFIG_BLOCK_ATTRS),
27985 blockElementCallback: this.getConfig(CONFIG_BLOCK_ELEMENT_CALLBACK),
27986 blockSelectors: this.getConfig(CONFIG_BLOCK_SELECTORS),
27987 captureExtraAttrs: this.getConfig(CONFIG_CAPTURE_EXTRA_ATTRS),
27988 captureTextContent: this.getConfig(CONFIG_CAPTURE_TEXT_CONTENT),
27989 capturedForHeatMap: isCapturedForHeatMap,
27990 });
27991 if (props) {
27992 _.extend(props, DEFAULT_PROPS);
27993 this.mp.track(mpEventName, props);
27994 }
27995 };
27996
27997 Autocapture.prototype.initPageListeners = function() {
27998 win.removeEventListener(EV_POPSTATE, this.listenerPopstate);
27999 win.removeEventListener(EV_HASHCHANGE, this.listenerHashchange);
28000
28001 if (!this.pageviewTrackingConfig() && !this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
28002 // These are all the configs that use these listeners
28003 return;
28004 }
28005
28006 this.listenerPopstate = function() {
28007 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28008 };
28009 this.listenerHashchange = function() {
28010 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28011 };
28012
28013 win.addEventListener(EV_POPSTATE, this.listenerPopstate);
28014 win.addEventListener(EV_HASHCHANGE, this.listenerHashchange);
28015 var nativePushState = win.history.pushState;
28016 if (typeof nativePushState === 'function') {
28017 win.history.pushState = function(state, unused, url) {
28018 nativePushState.call(win.history, state, unused, url);
28019 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28020 };
28021 }
28022 var nativeReplaceState = win.history.replaceState;
28023 if (typeof nativeReplaceState === 'function') {
28024 win.history.replaceState = function(state, unused, url) {
28025 nativeReplaceState.call(win.history, state, unused, url);
28026 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28027 };
28028 }
28029 };
28030
28031 Autocapture.prototype._getClickTrackingConfig = function(configKey) {
28032 var config = this.getConfig(configKey);
28033
28034 if (!config) {
28035 return null; // click tracking disabled
28036 }
28037
28038 if (config === true) {
28039 return {}; // use defaults
28040 }
28041
28042 if (typeof config === 'object') {
28043 return config; // use custom configuration
28044 }
28045
28046 return {}; // fallback to defaults for any other truthy value
28047 };
28048
28049 Autocapture.prototype._trackPageLeave = function(ev, currentUrl, currentScrollHeight) {
28050 if (this.hasTrackedScrollSession) {
28051 // User has navigated away already ending their impression.
28052 return;
28053 }
28054
28055 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.is_recording_heatmap_data()) {
28056 return;
28057 }
28058
28059 this.hasTrackedScrollSession = true;
28060 var viewportHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28061 var scrollPercentage = Math.round(Math.max(this.maxScrollViewDepth - viewportHeight, 0) / (currentScrollHeight - viewportHeight) * 100);
28062 var foldLinePercentage = Math.round((viewportHeight / currentScrollHeight) * 100);
28063 if (currentScrollHeight <= viewportHeight) {
28064 // If the content fits within the viewport, consider it fully scrolled
28065 scrollPercentage = 100;
28066 foldLinePercentage = 100;
28067 }
28068
28069 var props = _.extend({
28070 '$max_scroll_view_depth': this.maxScrollViewDepth,
28071 '$max_scroll_percentage': scrollPercentage,
28072 '$fold_line_percentage': foldLinePercentage,
28073 '$scroll_height': currentScrollHeight,
28074 '$event_type': ev.type,
28075 '$current_url': currentUrl || _.info.currentUrl(),
28076 '$viewportHeight': viewportHeight, // This is the fold line
28077 '$viewportWidth': Math.max(document$1.documentElement.clientWidth, win.innerWidth || 0),
28078 '$captured_for_heatmap': this.mp.is_recording_heatmap_data()
28079 }, DEFAULT_PROPS);
28080
28081 // Send with beacon transport to ensure event is sent before unload
28082 this.mp.track(MP_EV_PAGE_LEAVE, props, {transport: 'sendBeacon'});
28083 };
28084
28085 Autocapture.prototype._initScrollDepthTracking = function() {
28086 win.removeEventListener(EV_SCROLL, this.listenerScrollDepth);
28087 win.removeEventListener(EV_SCROLLEND, this.listenerScrollDepth);
28088
28089 if (!this.mp.get_config('record_heatmap_data')) {
28090 return;
28091 }
28092
28093 logger$1.log('Initializing scroll depth tracking');
28094
28095 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28096
28097 var updateScrollDepth = function() {
28098 if (this.currentUrlBlocked()) {
28099 return;
28100 }
28101 var scrollViewHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0) + win.scrollY;
28102 if (scrollViewHeight > this.maxScrollViewDepth) {
28103 this.maxScrollViewDepth = scrollViewHeight;
28104 }
28105 this.previousScrollHeight = document$1.body.scrollHeight;
28106 }.bind(this);
28107
28108 var scrollEndPolyfill = getPolyfillScrollEndFunction(updateScrollDepth);
28109 this.listenerScrollDepth = scrollEndPolyfill.listener;
28110 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScrollDepth);
28111 };
28112
28113 Autocapture.prototype.initClickTracking = function() {
28114 win.removeEventListener(EV_CLICK, this.listenerClick);
28115
28116 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.get_config('record_heatmap_data')) {
28117 return;
28118 }
28119 logger$1.log('Initializing click tracking');
28120
28121 this.listenerClick = function(ev) {
28122 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.is_recording_heatmap_data()) {
28123 return;
28124 }
28125 this.trackDomEvent(ev, MP_EV_CLICK);
28126 }.bind(this);
28127 win.addEventListener(EV_CLICK, this.listenerClick);
28128 };
28129
28130 Autocapture.prototype.initDeadClickTracking = function() {
28131 var deadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
28132
28133 if (!deadClickConfig && !this.mp.get_config('record_heatmap_data')) {
28134 this.stopDeadClickTracking();
28135 return;
28136 }
28137
28138 logger$1.log('Initializing dead click tracking');
28139 if (!this._deadClickTracker) {
28140 this._deadClickTracker = new DeadClickTracker(function(deadClickEvent) {
28141 this.trackDomEvent(deadClickEvent, MP_EV_DEAD_CLICK);
28142 }.bind(this));
28143 this._deadClickTracker.startTracking();
28144 }
28145
28146 if (!this.listenerDeadClick) {
28147 this.listenerDeadClick = function(ev) {
28148 var currentDeadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
28149 if (!currentDeadClickConfig && !this.mp.is_recording_heatmap_data()) {
28150 return;
28151 }
28152 if (this.currentUrlBlocked()) {
28153 return;
28154 }
28155 // Normalize config to ensure timeout_ms is always set
28156 var normalizedConfig = currentDeadClickConfig || {};
28157 if (!normalizedConfig['timeout_ms']) {
28158 normalizedConfig['timeout_ms'] = DEFAULT_DEAD_CLICK_TIMEOUT_MS;
28159 }
28160 this._deadClickTracker.trackClick(ev, normalizedConfig);
28161 }.bind(this);
28162 win.addEventListener(EV_CLICK, this.listenerDeadClick);
28163 }
28164 };
28165
28166 Autocapture.prototype.initInputTracking = function() {
28167 win.removeEventListener(EV_CHANGE, this.listenerChange);
28168
28169 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
28170 return;
28171 }
28172 logger$1.log('Initializing input tracking');
28173
28174 this.listenerChange = function(ev) {
28175 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
28176 return;
28177 }
28178 this.trackDomEvent(ev, MP_EV_INPUT);
28179 }.bind(this);
28180 win.addEventListener(EV_CHANGE, this.listenerChange);
28181 };
28182
28183 Autocapture.prototype.initPageviewTracking = function() {
28184 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
28185
28186 if (!this.pageviewTrackingConfig()) {
28187 return;
28188 }
28189 logger$1.log('Initializing pageview tracking');
28190
28191 var previousTrackedUrl = '';
28192 var tracked = false;
28193 if (!this.currentUrlBlocked()) {
28194 tracked = this.mp.track_pageview(DEFAULT_PROPS);
28195 }
28196 if (tracked) {
28197 previousTrackedUrl = _.info.currentUrl();
28198 }
28199
28200 this.listenerLocationchange = safewrap(function() {
28201 if (this.currentUrlBlocked()) {
28202 return;
28203 }
28204
28205 var currentUrl = _.info.currentUrl();
28206 var shouldTrack = false;
28207 var didPathChange = currentUrl.split('#')[0].split('?')[0] !== previousTrackedUrl.split('#')[0].split('?')[0];
28208 var trackPageviewOption = this.pageviewTrackingConfig();
28209 if (trackPageviewOption === PAGEVIEW_OPTION_FULL_URL) {
28210 shouldTrack = currentUrl !== previousTrackedUrl;
28211 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING) {
28212 shouldTrack = currentUrl.split('#')[0] !== previousTrackedUrl.split('#')[0];
28213 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH) {
28214 shouldTrack = didPathChange;
28215 }
28216
28217 if (shouldTrack) {
28218 var tracked = this.mp.track_pageview(DEFAULT_PROPS);
28219 if (tracked) {
28220 previousTrackedUrl = currentUrl;
28221 }
28222 if (didPathChange) {
28223 this.lastScrollCheckpoint = 0;
28224 logger$1.log('Path change: re-initializing scroll depth checkpoints');
28225 }
28226 }
28227 }.bind(this));
28228 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
28229 };
28230
28231 Autocapture.prototype.initRageClickTracking = function() {
28232 win.removeEventListener(EV_CLICK, this.listenerRageClick);
28233
28234 var rageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
28235 if (!rageClickConfig && !this.mp.get_config('record_heatmap_data')) {
28236 return;
28237 }
28238
28239 logger$1.log('Initializing rage click tracking');
28240 if (!this._rageClickTracker) {
28241 this._rageClickTracker = new RageClickTracker();
28242 }
28243
28244 this.listenerRageClick = function(ev) {
28245 var currentRageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
28246 if (!currentRageClickConfig && !this.mp.is_recording_heatmap_data()) {
28247 return;
28248 }
28249
28250 if (this.currentUrlBlocked()) {
28251 return;
28252 }
28253
28254 if (this._rageClickTracker.isRageClick(ev['pageX'], ev['pageY'], currentRageClickConfig)) {
28255 this.trackDomEvent(ev, MP_EV_RAGE_CLICK);
28256 }
28257 }.bind(this);
28258 win.addEventListener(EV_CLICK, this.listenerRageClick);
28259 };
28260
28261 Autocapture.prototype.initScrollTracking = function() {
28262 win.removeEventListener(EV_SCROLLEND, this.listenerScroll);
28263 win.removeEventListener(EV_SCROLL, this.listenerScroll);
28264
28265
28266 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
28267 return;
28268 }
28269 logger$1.log('Initializing scroll tracking');
28270 this.lastScrollCheckpoint = 0;
28271
28272 var scrollTrackFunction = function() {
28273 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
28274 return;
28275 }
28276 if (this.currentUrlBlocked()) {
28277 return;
28278 }
28279
28280 var shouldTrack = this.getConfig(CONFIG_SCROLL_CAPTURE_ALL);
28281 var scrollCheckpoints = (this.getConfig(CONFIG_SCROLL_CHECKPOINTS) || [])
28282 .slice()
28283 .sort(function(a, b) { return a - b; });
28284
28285 var scrollTop = win.scrollY;
28286 var props = _.extend({'$scroll_top': scrollTop}, DEFAULT_PROPS);
28287 try {
28288 var scrollHeight = document$1.body.scrollHeight;
28289 var scrollPercentage = Math.round((scrollTop / (scrollHeight - win.innerHeight)) * 100);
28290 props['$scroll_height'] = scrollHeight;
28291 props['$scroll_percentage'] = scrollPercentage;
28292 if (scrollPercentage > this.lastScrollCheckpoint) {
28293 for (var i = 0; i < scrollCheckpoints.length; i++) {
28294 var checkpoint = scrollCheckpoints[i];
28295 if (
28296 scrollPercentage >= checkpoint &&
28297 this.lastScrollCheckpoint < checkpoint
28298 ) {
28299 props['$scroll_checkpoint'] = checkpoint;
28300 this.lastScrollCheckpoint = checkpoint;
28301 shouldTrack = true;
28302 }
28303 }
28304 }
28305 } catch (err) {
28306 logger$1.critical('Error while calculating scroll percentage', err);
28307 }
28308 if (shouldTrack) {
28309 this.mp.track(MP_EV_SCROLL, props);
28310 }
28311 }.bind(this);
28312
28313 var scrollEndPolyfill = getPolyfillScrollEndFunction(scrollTrackFunction);
28314 this.listenerScroll = scrollEndPolyfill.listener;
28315 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScroll);
28316 };
28317
28318 Autocapture.prototype.initSubmitTracking = function() {
28319 win.removeEventListener(EV_SUBMIT, this.listenerSubmit);
28320
28321 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
28322 return;
28323 }
28324 logger$1.log('Initializing submit tracking');
28325
28326 this.listenerSubmit = function(ev) {
28327 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
28328 return;
28329 }
28330 this.trackDomEvent(ev, MP_EV_SUBMIT);
28331 }.bind(this);
28332 win.addEventListener(EV_SUBMIT, this.listenerSubmit);
28333 };
28334
28335 Autocapture.prototype.initPageLeaveTracking = function() {
28336 // Capture page_leave both when the user navigates away from the page (visibilitychange) as well
28337 // as when they navigate to a different page within the SPA (popstate/pushstate/hashchange).
28338 document$1.removeEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
28339 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
28340 win.removeEventListener(EV_LOAD, this.listenerPageLoad);
28341
28342 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
28343 return;
28344 }
28345
28346 logger$1.log('Initializing page visibility tracking.');
28347 this._initScrollDepthTracking();
28348 var previousTrackedUrl = _.info.currentUrl();
28349
28350 // Initialize previousScrollHeight on `load` which handles async loading
28351 // https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
28352 this.listenerPageLoad = function() {
28353 this.previousScrollHeight = document$1.body.scrollHeight;
28354 }.bind(this);
28355 win.addEventListener(EV_LOAD, this.listenerPageLoad);
28356
28357 // Track page navigation events similar to how initPageviewTracking does it
28358 this.listenerPageLeaveLocationchange = safewrap(function(ev) {
28359 if (this.currentUrlBlocked()) {
28360 return;
28361 }
28362
28363 var currentUrl = _.info.currentUrl();
28364 // Track all URL changes including query string or fragment changes as separate scroll sessions
28365 var shouldTrack = currentUrl !== previousTrackedUrl;
28366
28367 if (shouldTrack) {
28368 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
28369 previousTrackedUrl = currentUrl;
28370 // Fragment navigation should call scroll(end) and trigger listener, don't add window.scrollY here.
28371 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28372 this.previousScrollHeight = document$1.body.scrollHeight;
28373 this.hasTrackedScrollSession = false;
28374 }
28375 }.bind(this));
28376 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
28377
28378 this.listenerPageLeaveVisibilitychange = function(ev) {
28379 if (document$1.hidden) {
28380 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
28381 }
28382 }.bind(this);
28383 document$1.addEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
28384 };
28385
28386 Autocapture.prototype.stopDeadClickTracking = function() {
28387 if (this.listenerDeadClick) {
28388 win.removeEventListener(EV_CLICK, this.listenerDeadClick);
28389 this.listenerDeadClick = null;
28390 }
28391
28392 if (this._deadClickTracker) {
28393 this._deadClickTracker.stopTracking();
28394 this._deadClickTracker = null;
28395 }
28396 };
28397
28398 // TODO integrate error_reporter from mixpanel instance
28399 safewrapClass(Autocapture);
28400
28401 var logger = console_with_prefix('flags');
28402
28403 var FLAGS_CONFIG_KEY = 'flags';
28404
28405 var CONFIG_CONTEXT = 'context';
28406 var CONFIG_DEFAULTS = {};
28407 CONFIG_DEFAULTS[CONFIG_CONTEXT] = {};
28408
28409 /**
28410 * FeatureFlagManager: support for Mixpanel's feature flagging product
28411 * @constructor
28412 */
28413 var FeatureFlagManager = function(initOptions) {
28414 this.fetch = win['fetch'];
28415 this.getFullApiRoute = initOptions.getFullApiRoute;
28416 this.getMpConfig = initOptions.getConfigFunc;
28417 this.setMpConfig = initOptions.setConfigFunc;
28418 this.getMpProperty = initOptions.getPropertyFunc;
28419 this.track = initOptions.trackingFunc;
28420 };
28421
28422 FeatureFlagManager.prototype.init = function() {
28423 if (!this.minApisSupported()) {
28424 logger.critical('Feature Flags unavailable: missing minimum required APIs');
28425 return;
28426 }
28427
28428 this.flags = null;
28429 this.fetchFlags();
28430
28431 this.trackedFeatures = new Set();
28432 };
28433
28434 FeatureFlagManager.prototype.getFullConfig = function() {
28435 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
28436 if (!ffConfig) {
28437 // flags are completely off
28438 return {};
28439 } else if (_.isObject(ffConfig)) {
28440 return _.extend({}, CONFIG_DEFAULTS, ffConfig);
28441 } else {
28442 // config is non-object truthy value, return default
28443 return CONFIG_DEFAULTS;
28444 }
28445 };
28446
28447 FeatureFlagManager.prototype.getConfig = function(key) {
28448 return this.getFullConfig()[key];
28449 };
28450
28451 FeatureFlagManager.prototype.isSystemEnabled = function() {
28452 return !!this.getMpConfig(FLAGS_CONFIG_KEY);
28453 };
28454
28455 FeatureFlagManager.prototype.updateContext = function(newContext, options) {
28456 if (!this.isSystemEnabled()) {
28457 logger.critical('Feature Flags not enabled, cannot update context');
28458 return Promise.resolve();
28459 }
28460
28461 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
28462 if (!_.isObject(ffConfig)) {
28463 ffConfig = {};
28464 }
28465 var oldContext = (options && options['replace']) ? {} : this.getConfig(CONFIG_CONTEXT);
28466 ffConfig[CONFIG_CONTEXT] = _.extend({}, oldContext, newContext);
28467
28468 this.setMpConfig(FLAGS_CONFIG_KEY, ffConfig);
28469 return this.fetchFlags();
28470 };
28471
28472 FeatureFlagManager.prototype.areFlagsReady = function() {
28473 if (!this.isSystemEnabled()) {
28474 logger.error('Feature Flags not enabled');
28475 }
28476 return !!this.flags;
28477 };
28478
28479 FeatureFlagManager.prototype.fetchFlags = function() {
28480 if (!this.isSystemEnabled()) {
28481 return Promise.resolve();
28482 }
28483
28484 var distinctId = this.getMpProperty('distinct_id');
28485 var deviceId = this.getMpProperty('$device_id');
28486 var traceparent = generateTraceparent();
28487 logger.log('Fetching flags for distinct ID: ' + distinctId);
28488
28489 var context = _.extend({'distinct_id': distinctId, 'device_id': deviceId}, this.getConfig(CONFIG_CONTEXT));
28490 var searchParams = new URLSearchParams();
28491 searchParams.set('context', JSON.stringify(context));
28492 searchParams.set('token', this.getMpConfig('token'));
28493 searchParams.set('mp_lib', 'web');
28494 searchParams.set('$lib_version', Config.LIB_VERSION);
28495 var url = this.getFullApiRoute() + '?' + searchParams.toString();
28496
28497 this._fetchInProgressStartTime = Date.now();
28498 this.fetchPromise = this.fetch.call(win, url, {
28499 'method': 'GET',
28500 'headers': {
28501 'Authorization': 'Basic ' + btoa(this.getMpConfig('token') + ':'),
28502 'traceparent': traceparent
28503 }
28504 }).then(function(response) {
28505 this.markFetchComplete();
28506 return response.json().then(function(responseBody) {
28507 var responseFlags = responseBody['flags'];
28508 if (!responseFlags) {
28509 throw new Error('No flags in API response');
28510 }
28511 var flags = new Map();
28512 _.each(responseFlags, function(data, key) {
28513 flags.set(key, {
28514 'key': data['variant_key'],
28515 'value': data['variant_value'],
28516 'experiment_id': data['experiment_id'],
28517 'is_experiment_active': data['is_experiment_active'],
28518 'is_qa_tester': data['is_qa_tester']
28519 });
28520 });
28521 this.flags = flags;
28522 this._traceparent = traceparent;
28523 }.bind(this)).catch(function(error) {
28524 this.markFetchComplete();
28525 logger.error(error);
28526 }.bind(this));
28527 }.bind(this)).catch(function(error) {
28528 this.markFetchComplete();
28529 logger.error(error);
28530 }.bind(this));
28531
28532 return this.fetchPromise;
28533 };
28534
28535 FeatureFlagManager.prototype.markFetchComplete = function() {
28536 if (!this._fetchInProgressStartTime) {
28537 logger.error('Fetch in progress started time not set, cannot mark fetch complete');
28538 return;
28539 }
28540 this._fetchStartTime = this._fetchInProgressStartTime;
28541 this._fetchCompleteTime = Date.now();
28542 this._fetchLatency = this._fetchCompleteTime - this._fetchStartTime;
28543 this._fetchInProgressStartTime = null;
28544 };
28545
28546 FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
28547 if (!this.fetchPromise) {
28548 return new Promise(function(resolve) {
28549 logger.critical('Feature Flags not initialized');
28550 resolve(fallback);
28551 });
28552 }
28553
28554 return this.fetchPromise.then(function() {
28555 return this.getVariantSync(featureName, fallback);
28556 }.bind(this)).catch(function(error) {
28557 logger.error(error);
28558 return fallback;
28559 });
28560 };
28561
28562 FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
28563 if (!this.areFlagsReady()) {
28564 logger.log('Flags not loaded yet');
28565 return fallback;
28566 }
28567 var feature = this.flags.get(featureName);
28568 if (!feature) {
28569 logger.log('No flag found: "' + featureName + '"');
28570 return fallback;
28571 }
28572 this.trackFeatureCheck(featureName, feature);
28573 return feature;
28574 };
28575
28576 FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
28577 return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
28578 return feature['value'];
28579 }).catch(function(error) {
28580 logger.error(error);
28581 return fallbackValue;
28582 });
28583 };
28584
28585 // TODO remove deprecated method
28586 FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
28587 logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
28588 return this.getVariantValue(featureName, fallbackValue);
28589 };
28590
28591 FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
28592 return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
28593 };
28594
28595 FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
28596 return this.getVariantValue(featureName).then(function() {
28597 return this.isEnabledSync(featureName, fallbackValue);
28598 }.bind(this)).catch(function(error) {
28599 logger.error(error);
28600 return fallbackValue;
28601 });
28602 };
28603
28604 FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
28605 fallbackValue = fallbackValue || false;
28606 var val = this.getVariantValueSync(featureName, fallbackValue);
28607 if (val !== true && val !== false) {
28608 logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
28609 val = fallbackValue;
28610 }
28611 return val;
28612 };
28613
28614 FeatureFlagManager.prototype.trackFeatureCheck = function(featureName, feature) {
28615 if (this.trackedFeatures.has(featureName)) {
28616 return;
28617 }
28618 this.trackedFeatures.add(featureName);
28619
28620 var trackingProperties = {
28621 'Experiment name': featureName,
28622 'Variant name': feature['key'],
28623 '$experiment_type': 'feature_flag',
28624 'Variant fetch start time': new Date(this._fetchStartTime).toISOString(),
28625 'Variant fetch complete time': new Date(this._fetchCompleteTime).toISOString(),
28626 'Variant fetch latency (ms)': this._fetchLatency,
28627 'Variant fetch traceparent': this._traceparent,
28628 };
28629
28630 if (feature['experiment_id'] !== 'undefined') {
28631 trackingProperties['$experiment_id'] = feature['experiment_id'];
28632 }
28633 if (feature['is_experiment_active'] !== 'undefined') {
28634 trackingProperties['$is_experiment_active'] = feature['is_experiment_active'];
28635 }
28636 if (feature['is_qa_tester'] !== 'undefined') {
28637 trackingProperties['$is_qa_tester'] = feature['is_qa_tester'];
28638 }
28639
28640 this.track('$experiment_started', trackingProperties);
28641 };
28642
28643 FeatureFlagManager.prototype.minApisSupported = function() {
28644 return !!this.fetch &&
28645 typeof Promise !== 'undefined' &&
28646 typeof Map !== 'undefined' &&
28647 typeof Set !== 'undefined';
28648 };
28649
28650 safewrapClass(FeatureFlagManager);
28651
28652 FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
28653 FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
28654 FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
28655 FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
28656 FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
28657 FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
28658 FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
28659 FeatureFlagManager.prototype['update_context'] = FeatureFlagManager.prototype.updateContext;
28660
28661 // Deprecated method
28662 FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
28663
28664 /* eslint camelcase: "off" */
28665
28666
28667 /**
28668 * DomTracker Object
28669 * @constructor
28670 */
28671 var DomTracker = function() {};
28672
28673
28674 // interface
28675 DomTracker.prototype.create_properties = function() {};
28676 DomTracker.prototype.event_handler = function() {};
28677 DomTracker.prototype.after_track_handler = function() {};
28678
28679 DomTracker.prototype.init = function(mixpanel_instance) {
28680 this.mp = mixpanel_instance;
28681 return this;
28682 };
28683
28684 /**
28685 * @param {Object|string} query
28686 * @param {string} event_name
28687 * @param {Object=} properties
28688 * @param {function=} user_callback
28689 */
28690 DomTracker.prototype.track = function(query, event_name, properties, user_callback) {
28691 var that = this;
28692 var elements = _.dom_query(query);
28693
28694 if (elements.length === 0) {
28695 console$1.error('The DOM query (' + query + ') returned 0 elements');
28696 return;
28697 }
28698
28699 _.each(elements, function(element) {
28700 _.register_event(element, this.override_event, function(e) {
28701 var options = {};
28702 var props = that.create_properties(properties, this);
28703 var timeout = that.mp.get_config('track_links_timeout');
28704
28705 that.event_handler(e, this, options);
28706
28707 // in case the mixpanel servers don't get back to us in time
28708 window.setTimeout(that.track_callback(user_callback, props, options, true), timeout);
28709
28710 // fire the tracking event
28711 that.mp.track(event_name, props, that.track_callback(user_callback, props, options));
28712 });
28713 }, this);
28714
28715 return true;
28716 };
28717
28718 /**
28719 * @param {function} user_callback
28720 * @param {Object} props
28721 * @param {boolean=} timeout_occured
28722 */
28723 DomTracker.prototype.track_callback = function(user_callback, props, options, timeout_occured) {
28724 timeout_occured = timeout_occured || false;
28725 var that = this;
28726
28727 return function() {
28728 // options is referenced from both callbacks, so we can have
28729 // a 'lock' of sorts to ensure only one fires
28730 if (options.callback_fired) { return; }
28731 options.callback_fired = true;
28732
28733 if (user_callback && user_callback(timeout_occured, props) === false) {
28734 // user can prevent the default functionality by
28735 // returning false from their callback
28736 return;
28737 }
28738
28739 that.after_track_handler(props, options, timeout_occured);
28740 };
28741 };
28742
28743 DomTracker.prototype.create_properties = function(properties, element) {
28744 var props;
28745
28746 if (typeof(properties) === 'function') {
28747 props = properties(element);
28748 } else {
28749 props = _.extend({}, properties);
28750 }
28751
28752 return props;
28753 };
28754
28755 /**
28756 * LinkTracker Object
28757 * @constructor
28758 * @extends DomTracker
28759 */
28760 var LinkTracker = function() {
28761 this.override_event = 'click';
28762 };
28763 _.inherit(LinkTracker, DomTracker);
28764
28765 LinkTracker.prototype.create_properties = function(properties, element) {
28766 var props = LinkTracker.superclass.create_properties.apply(this, arguments);
28767
28768 if (element.href) { props['url'] = element.href; }
28769
28770 return props;
28771 };
28772
28773 LinkTracker.prototype.event_handler = function(evt, element, options) {
28774 options.new_tab = (
28775 evt.which === 2 ||
28776 evt.metaKey ||
28777 evt.ctrlKey ||
28778 element.target === '_blank'
28779 );
28780 options.href = element.href;
28781
28782 if (!options.new_tab) {
28783 evt.preventDefault();
28784 }
28785 };
28786
28787 LinkTracker.prototype.after_track_handler = function(props, options) {
28788 if (options.new_tab) { return; }
28789
28790 setTimeout(function() {
28791 window.location = options.href;
28792 }, 0);
28793 };
28794
28795 /**
28796 * FormTracker Object
28797 * @constructor
28798 * @extends DomTracker
28799 */
28800 var FormTracker = function() {
28801 this.override_event = 'submit';
28802 };
28803 _.inherit(FormTracker, DomTracker);
28804
28805 FormTracker.prototype.event_handler = function(evt, element, options) {
28806 options.element = element;
28807 evt.preventDefault();
28808 };
28809
28810 FormTracker.prototype.after_track_handler = function(props, options) {
28811 setTimeout(function() {
28812 options.element.submit();
28813 }, 0);
28814 };
28815
28816 /* eslint camelcase: "off" */
28817
28818
28819 /** @const */ var SET_ACTION = '$set';
28820 /** @const */ var SET_ONCE_ACTION = '$set_once';
28821 /** @const */ var UNSET_ACTION = '$unset';
28822 /** @const */ var ADD_ACTION = '$add';
28823 /** @const */ var APPEND_ACTION = '$append';
28824 /** @const */ var UNION_ACTION = '$union';
28825 /** @const */ var REMOVE_ACTION = '$remove';
28826 /** @const */ var DELETE_ACTION = '$delete';
28827
28828 // Common internal methods for mixpanel.people and mixpanel.group APIs.
28829 // These methods shouldn't involve network I/O.
28830 var apiActions = {
28831 set_action: function(prop, to) {
28832 var data = {};
28833 var $set = {};
28834 if (_.isObject(prop)) {
28835 _.each(prop, function(v, k) {
28836 if (!this._is_reserved_property(k)) {
28837 $set[k] = v;
28838 }
28839 }, this);
28840 } else {
28841 $set[prop] = to;
28842 }
28843
28844 data[SET_ACTION] = $set;
28845 return data;
28846 },
28847
28848 unset_action: function(prop) {
28849 var data = {};
28850 var $unset = [];
28851 if (!_.isArray(prop)) {
28852 prop = [prop];
28853 }
28854
28855 _.each(prop, function(k) {
28856 if (!this._is_reserved_property(k)) {
28857 $unset.push(k);
28858 }
28859 }, this);
28860
28861 data[UNSET_ACTION] = $unset;
28862 return data;
28863 },
28864
28865 set_once_action: function(prop, to) {
28866 var data = {};
28867 var $set_once = {};
28868 if (_.isObject(prop)) {
28869 _.each(prop, function(v, k) {
28870 if (!this._is_reserved_property(k)) {
28871 $set_once[k] = v;
28872 }
28873 }, this);
28874 } else {
28875 $set_once[prop] = to;
28876 }
28877 data[SET_ONCE_ACTION] = $set_once;
28878 return data;
28879 },
28880
28881 union_action: function(list_name, values) {
28882 var data = {};
28883 var $union = {};
28884 if (_.isObject(list_name)) {
28885 _.each(list_name, function(v, k) {
28886 if (!this._is_reserved_property(k)) {
28887 $union[k] = _.isArray(v) ? v : [v];
28888 }
28889 }, this);
28890 } else {
28891 $union[list_name] = _.isArray(values) ? values : [values];
28892 }
28893 data[UNION_ACTION] = $union;
28894 return data;
28895 },
28896
28897 append_action: function(list_name, value) {
28898 var data = {};
28899 var $append = {};
28900 if (_.isObject(list_name)) {
28901 _.each(list_name, function(v, k) {
28902 if (!this._is_reserved_property(k)) {
28903 $append[k] = v;
28904 }
28905 }, this);
28906 } else {
28907 $append[list_name] = value;
28908 }
28909 data[APPEND_ACTION] = $append;
28910 return data;
28911 },
28912
28913 remove_action: function(list_name, value) {
28914 var data = {};
28915 var $remove = {};
28916 if (_.isObject(list_name)) {
28917 _.each(list_name, function(v, k) {
28918 if (!this._is_reserved_property(k)) {
28919 $remove[k] = v;
28920 }
28921 }, this);
28922 } else {
28923 $remove[list_name] = value;
28924 }
28925 data[REMOVE_ACTION] = $remove;
28926 return data;
28927 },
28928
28929 delete_action: function() {
28930 var data = {};
28931 data[DELETE_ACTION] = '';
28932 return data;
28933 }
28934 };
28935
28936 /* eslint camelcase: "off" */
28937
28938 /**
28939 * Mixpanel Group Object
28940 * @constructor
28941 */
28942 var MixpanelGroup = function() {};
28943
28944 _.extend(MixpanelGroup.prototype, apiActions);
28945
28946 MixpanelGroup.prototype._init = function(mixpanel_instance, group_key, group_id) {
28947 this._mixpanel = mixpanel_instance;
28948 this._group_key = group_key;
28949 this._group_id = group_id;
28950 };
28951
28952 /**
28953 * Set properties on a group.
28954 *
28955 * ### Usage:
28956 *
28957 * mixpanel.get_group('company', 'mixpanel').set('Location', '405 Howard');
28958 *
28959 * // or set multiple properties at once
28960 * mixpanel.get_group('company', 'mixpanel').set({
28961 * 'Location': '405 Howard',
28962 * 'Founded' : 2009,
28963 * });
28964 * // properties can be strings, integers, dates, or lists
28965 *
28966 * @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.
28967 * @param {*} [to] A value to set on the given property name
28968 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28969 */
28970 MixpanelGroup.prototype.set = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28971 var data = this.set_action(prop, to);
28972 if (_.isObject(prop)) {
28973 callback = to;
28974 }
28975 return this._send_request(data, callback);
28976 });
28977
28978 /**
28979 * Set properties on a group, only if they do not yet exist.
28980 * This will not overwrite previous group property values, unlike
28981 * group.set().
28982 *
28983 * ### Usage:
28984 *
28985 * mixpanel.get_group('company', 'mixpanel').set_once('Location', '405 Howard');
28986 *
28987 * // or set multiple properties at once
28988 * mixpanel.get_group('company', 'mixpanel').set_once({
28989 * 'Location': '405 Howard',
28990 * 'Founded' : 2009,
28991 * });
28992 * // properties can be strings, integers, lists or dates
28993 *
28994 * @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.
28995 * @param {*} [to] A value to set on the given property name
28996 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28997 */
28998 MixpanelGroup.prototype.set_once = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28999 var data = this.set_once_action(prop, to);
29000 if (_.isObject(prop)) {
29001 callback = to;
29002 }
29003 return this._send_request(data, callback);
29004 });
29005
29006 /**
29007 * Unset properties on a group permanently.
29008 *
29009 * ### Usage:
29010 *
29011 * mixpanel.get_group('company', 'mixpanel').unset('Founded');
29012 *
29013 * @param {String} prop The name of the property.
29014 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29015 */
29016 MixpanelGroup.prototype.unset = addOptOutCheckMixpanelGroup(function(prop, callback) {
29017 var data = this.unset_action(prop);
29018 return this._send_request(data, callback);
29019 });
29020
29021 /**
29022 * Merge a given list with a list-valued group property, excluding duplicate values.
29023 *
29024 * ### Usage:
29025 *
29026 * // merge a value to a list, creating it if needed
29027 * mixpanel.get_group('company', 'mixpanel').union('Location', ['San Francisco', 'London']);
29028 *
29029 * @param {String} list_name Name of the property.
29030 * @param {Array} values Values to merge with the given property
29031 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29032 */
29033 MixpanelGroup.prototype.union = addOptOutCheckMixpanelGroup(function(list_name, values, callback) {
29034 if (_.isObject(list_name)) {
29035 callback = values;
29036 }
29037 var data = this.union_action(list_name, values);
29038 return this._send_request(data, callback);
29039 });
29040
29041 /**
29042 * Permanently delete a group.
29043 *
29044 * ### Usage:
29045 *
29046 * mixpanel.get_group('company', 'mixpanel').delete();
29047 *
29048 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29049 */
29050 MixpanelGroup.prototype['delete'] = addOptOutCheckMixpanelGroup(function(callback) {
29051 // bracket notation above prevents a minification error related to reserved words
29052 var data = this.delete_action();
29053 return this._send_request(data, callback);
29054 });
29055
29056 /**
29057 * Remove a property from a group. The value will be ignored if doesn't exist.
29058 *
29059 * ### Usage:
29060 *
29061 * mixpanel.get_group('company', 'mixpanel').remove('Location', 'London');
29062 *
29063 * @param {String} list_name Name of the property.
29064 * @param {Object} value Value to remove from the given group property
29065 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29066 */
29067 MixpanelGroup.prototype.remove = addOptOutCheckMixpanelGroup(function(list_name, value, callback) {
29068 var data = this.remove_action(list_name, value);
29069 return this._send_request(data, callback);
29070 });
29071
29072 MixpanelGroup.prototype._send_request = function(data, callback) {
29073 data['$group_key'] = this._group_key;
29074 data['$group_id'] = this._group_id;
29075 data['$token'] = this._get_config('token');
29076
29077 var date_encoded_data = _.encodeDates(data);
29078 return this._mixpanel._track_or_batch({
29079 type: 'groups',
29080 data: date_encoded_data,
29081 endpoint: this._mixpanel.get_api_host('groups') + '/' + this._get_config('api_routes')['groups'],
29082 batcher: this._mixpanel.request_batchers.groups
29083 }, callback);
29084 };
29085
29086 MixpanelGroup.prototype._is_reserved_property = function(prop) {
29087 return prop === '$group_key' || prop === '$group_id';
29088 };
29089
29090 MixpanelGroup.prototype._get_config = function(conf) {
29091 return this._mixpanel.get_config(conf);
29092 };
29093
29094 MixpanelGroup.prototype.toString = function() {
29095 return this._mixpanel.toString() + '.group.' + this._group_key + '.' + this._group_id;
29096 };
29097
29098 // MixpanelGroup Exports
29099 MixpanelGroup.prototype['remove'] = MixpanelGroup.prototype.remove;
29100 MixpanelGroup.prototype['set'] = MixpanelGroup.prototype.set;
29101 MixpanelGroup.prototype['set_once'] = MixpanelGroup.prototype.set_once;
29102 MixpanelGroup.prototype['union'] = MixpanelGroup.prototype.union;
29103 MixpanelGroup.prototype['unset'] = MixpanelGroup.prototype.unset;
29104 MixpanelGroup.prototype['toString'] = MixpanelGroup.prototype.toString;
29105
29106 /* eslint camelcase: "off" */
29107
29108 /**
29109 * Mixpanel People Object
29110 * @constructor
29111 */
29112 var MixpanelPeople = function() {};
29113
29114 _.extend(MixpanelPeople.prototype, apiActions);
29115
29116 MixpanelPeople.prototype._init = function(mixpanel_instance) {
29117 this._mixpanel = mixpanel_instance;
29118 };
29119
29120 /*
29121 * Set properties on a user record.
29122 *
29123 * ### Usage:
29124 *
29125 * mixpanel.people.set('gender', 'm');
29126 *
29127 * // or set multiple properties at once
29128 * mixpanel.people.set({
29129 * 'Company': 'Acme',
29130 * 'Plan': 'Premium',
29131 * 'Upgrade date': new Date()
29132 * });
29133 * // properties can be strings, integers, dates, or lists
29134 *
29135 * @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.
29136 * @param {*} [to] A value to set on the given property name
29137 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29138 */
29139 MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
29140 var data = this.set_action(prop, to);
29141 if (_.isObject(prop)) {
29142 callback = to;
29143 }
29144 // make sure that the referrer info has been updated and saved
29145 if (this._get_config('save_referrer')) {
29146 this._mixpanel['persistence'].update_referrer_info(document.referrer);
29147 }
29148
29149 // update $set object with default people properties
29150 data[SET_ACTION] = _.extend(
29151 {},
29152 _.info.people_properties(),
29153 data[SET_ACTION]
29154 );
29155 return this._send_request(data, callback);
29156 });
29157
29158 /*
29159 * Set properties on a user record, only if they do not yet exist.
29160 * This will not overwrite previous people property values, unlike
29161 * people.set().
29162 *
29163 * ### Usage:
29164 *
29165 * mixpanel.people.set_once('First Login Date', new Date());
29166 *
29167 * // or set multiple properties at once
29168 * mixpanel.people.set_once({
29169 * 'First Login Date': new Date(),
29170 * 'Starting Plan': 'Premium'
29171 * });
29172 *
29173 * // properties can be strings, integers or dates
29174 *
29175 * @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.
29176 * @param {*} [to] A value to set on the given property name
29177 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29178 */
29179 MixpanelPeople.prototype.set_once = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
29180 var data = this.set_once_action(prop, to);
29181 if (_.isObject(prop)) {
29182 callback = to;
29183 }
29184 return this._send_request(data, callback);
29185 });
29186
29187 /*
29188 * Unset properties on a user record (permanently removes the properties and their values from a profile).
29189 *
29190 * ### Usage:
29191 *
29192 * mixpanel.people.unset('gender');
29193 *
29194 * // or unset multiple properties at once
29195 * mixpanel.people.unset(['gender', 'Company']);
29196 *
29197 * @param {Array|String} prop If a string, this is the name of the property. If an array, this is a list of property names.
29198 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29199 */
29200 MixpanelPeople.prototype.unset = addOptOutCheckMixpanelPeople(function(prop, callback) {
29201 var data = this.unset_action(prop);
29202 return this._send_request(data, callback);
29203 });
29204
29205 /*
29206 * Increment/decrement numeric people analytics properties.
29207 *
29208 * ### Usage:
29209 *
29210 * mixpanel.people.increment('page_views', 1);
29211 *
29212 * // or, for convenience, if you're just incrementing a counter by
29213 * // 1, you can simply do
29214 * mixpanel.people.increment('page_views');
29215 *
29216 * // to decrement a counter, pass a negative number
29217 * mixpanel.people.increment('credits_left', -1);
29218 *
29219 * // like mixpanel.people.set(), you can increment multiple
29220 * // properties at once:
29221 * mixpanel.people.increment({
29222 * counter1: 1,
29223 * counter2: 6
29224 * });
29225 *
29226 * @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.
29227 * @param {Number} [by] An amount to increment the given property
29228 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29229 */
29230 MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop, by, callback) {
29231 var data = {};
29232 var $add = {};
29233 if (_.isObject(prop)) {
29234 _.each(prop, function(v, k) {
29235 if (!this._is_reserved_property(k)) {
29236 if (isNaN(parseFloat(v))) {
29237 console$1.error('Invalid increment value passed to mixpanel.people.increment - must be a number');
29238 return;
29239 } else {
29240 $add[k] = v;
29241 }
29242 }
29243 }, this);
29244 callback = by;
29245 } else {
29246 // convenience: mixpanel.people.increment('property'); will
29247 // increment 'property' by 1
29248 if (_.isUndefined(by)) {
29249 by = 1;
29250 }
29251 $add[prop] = by;
29252 }
29253 data[ADD_ACTION] = $add;
29254
29255 return this._send_request(data, callback);
29256 });
29257
29258 /*
29259 * Append a value to a list-valued people analytics property.
29260 *
29261 * ### Usage:
29262 *
29263 * // append a value to a list, creating it if needed
29264 * mixpanel.people.append('pages_visited', 'homepage');
29265 *
29266 * // like mixpanel.people.set(), you can append multiple
29267 * // properties at once:
29268 * mixpanel.people.append({
29269 * list1: 'bob',
29270 * list2: 123
29271 * });
29272 *
29273 * @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.
29274 * @param {*} [value] value An item to append to the list
29275 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29276 */
29277 MixpanelPeople.prototype.append = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
29278 if (_.isObject(list_name)) {
29279 callback = value;
29280 }
29281 var data = this.append_action(list_name, value);
29282 return this._send_request(data, callback);
29283 });
29284
29285 /*
29286 * Remove a value from a list-valued people analytics property.
29287 *
29288 * ### Usage:
29289 *
29290 * mixpanel.people.remove('School', 'UCB');
29291 *
29292 * @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.
29293 * @param {*} [value] value Item to remove from the list
29294 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29295 */
29296 MixpanelPeople.prototype.remove = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
29297 if (_.isObject(list_name)) {
29298 callback = value;
29299 }
29300 var data = this.remove_action(list_name, value);
29301 return this._send_request(data, callback);
29302 });
29303
29304 /*
29305 * Merge a given list with a list-valued people analytics property,
29306 * excluding duplicate values.
29307 *
29308 * ### Usage:
29309 *
29310 * // merge a value to a list, creating it if needed
29311 * mixpanel.people.union('pages_visited', 'homepage');
29312 *
29313 * // like mixpanel.people.set(), you can append multiple
29314 * // properties at once:
29315 * mixpanel.people.union({
29316 * list1: 'bob',
29317 * list2: 123
29318 * });
29319 *
29320 * // like mixpanel.people.append(), you can append multiple
29321 * // values to the same list:
29322 * mixpanel.people.union({
29323 * list1: ['bob', 'billy']
29324 * });
29325 *
29326 * @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.
29327 * @param {*} [value] Value / values to merge with the given property
29328 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29329 */
29330 MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name, values, callback) {
29331 if (_.isObject(list_name)) {
29332 callback = values;
29333 }
29334 var data = this.union_action(list_name, values);
29335 return this._send_request(data, callback);
29336 });
29337
29338 /*
29339 * Record that you have charged the current user a certain amount
29340 * of money. Charges recorded with track_charge() will appear in the
29341 * Mixpanel revenue report.
29342 *
29343 * ### Usage:
29344 *
29345 * // charge a user $50
29346 * mixpanel.people.track_charge(50);
29347 *
29348 * // charge a user $30.50 on the 2nd of january
29349 * mixpanel.people.track_charge(30.50, {
29350 * '$time': new Date('jan 1 2012')
29351 * });
29352 *
29353 * @param {Number} amount The amount of money charged to the current user
29354 * @param {Object} [properties] An associative array of properties associated with the charge
29355 * @param {Function} [callback] If provided, the callback will be called when the server responds
29356 * @deprecated
29357 */
29358 MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
29359 console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
29360 });
29361
29362 /*
29363 * Permanently clear all revenue report transactions from the
29364 * current user's people analytics profile.
29365 *
29366 * ### Usage:
29367 *
29368 * mixpanel.people.clear_charges();
29369 *
29370 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29371 * @deprecated
29372 */
29373 MixpanelPeople.prototype.clear_charges = function(callback) {
29374 return this.set('$transactions', [], callback);
29375 };
29376
29377 /*
29378 * Permanently deletes the current people analytics profile from
29379 * Mixpanel (using the current distinct_id).
29380 *
29381 * ### Usage:
29382 *
29383 * // remove the all data you have stored about the current user
29384 * mixpanel.people.delete_user();
29385 *
29386 */
29387 MixpanelPeople.prototype.delete_user = function() {
29388 if (!this._identify_called()) {
29389 console$1.error('mixpanel.people.delete_user() requires you to call identify() first');
29390 return;
29391 }
29392 var data = {'$delete': this._mixpanel.get_distinct_id()};
29393 return this._send_request(data);
29394 };
29395
29396 MixpanelPeople.prototype.toString = function() {
29397 return this._mixpanel.toString() + '.people';
29398 };
29399
29400 MixpanelPeople.prototype._send_request = function(data, callback) {
29401 data['$token'] = this._get_config('token');
29402 data['$distinct_id'] = this._mixpanel.get_distinct_id();
29403 var device_id = this._mixpanel.get_property('$device_id');
29404 var user_id = this._mixpanel.get_property('$user_id');
29405 var had_persisted_distinct_id = this._mixpanel.get_property('$had_persisted_distinct_id');
29406 if (device_id) {
29407 data['$device_id'] = device_id;
29408 }
29409 if (user_id) {
29410 data['$user_id'] = user_id;
29411 }
29412 if (had_persisted_distinct_id) {
29413 data['$had_persisted_distinct_id'] = had_persisted_distinct_id;
29414 }
29415
29416 var date_encoded_data = _.encodeDates(data);
29417
29418 if (!this._identify_called()) {
29419 this._enqueue(data);
29420 if (!_.isUndefined(callback)) {
29421 if (this._get_config('verbose')) {
29422 callback({status: -1, error: null});
29423 } else {
29424 callback(-1);
29425 }
29426 }
29427 return _.truncate(date_encoded_data, 255);
29428 }
29429
29430 return this._mixpanel._track_or_batch({
29431 type: 'people',
29432 data: date_encoded_data,
29433 endpoint: this._mixpanel.get_api_host('people') + '/' + this._get_config('api_routes')['engage'],
29434 batcher: this._mixpanel.request_batchers.people
29435 }, callback);
29436 };
29437
29438 MixpanelPeople.prototype._get_config = function(conf_var) {
29439 return this._mixpanel.get_config(conf_var);
29440 };
29441
29442 MixpanelPeople.prototype._identify_called = function() {
29443 return this._mixpanel._flags.identify_called === true;
29444 };
29445
29446 // Queue up engage operations if identify hasn't been called yet.
29447 MixpanelPeople.prototype._enqueue = function(data) {
29448 if (SET_ACTION in data) {
29449 this._mixpanel['persistence']._add_to_people_queue(SET_ACTION, data);
29450 } else if (SET_ONCE_ACTION in data) {
29451 this._mixpanel['persistence']._add_to_people_queue(SET_ONCE_ACTION, data);
29452 } else if (UNSET_ACTION in data) {
29453 this._mixpanel['persistence']._add_to_people_queue(UNSET_ACTION, data);
29454 } else if (ADD_ACTION in data) {
29455 this._mixpanel['persistence']._add_to_people_queue(ADD_ACTION, data);
29456 } else if (APPEND_ACTION in data) {
29457 this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, data);
29458 } else if (REMOVE_ACTION in data) {
29459 this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, data);
29460 } else if (UNION_ACTION in data) {
29461 this._mixpanel['persistence']._add_to_people_queue(UNION_ACTION, data);
29462 } else {
29463 console$1.error('Invalid call to _enqueue():', data);
29464 }
29465 };
29466
29467 MixpanelPeople.prototype._flush_one_queue = function(action, action_method, callback, queue_to_params_fn) {
29468 var _this = this;
29469 var queued_data = _.extend({}, this._mixpanel['persistence'].load_queue(action));
29470 var action_params = queued_data;
29471
29472 if (!_.isUndefined(queued_data) && _.isObject(queued_data) && !_.isEmptyObject(queued_data)) {
29473 _this._mixpanel['persistence']._pop_from_people_queue(action, queued_data);
29474 _this._mixpanel['persistence'].save();
29475 if (queue_to_params_fn) {
29476 action_params = queue_to_params_fn(queued_data);
29477 }
29478 action_method.call(_this, action_params, function(response, data) {
29479 // on bad response, we want to add it back to the queue
29480 if (response === 0) {
29481 _this._mixpanel['persistence']._add_to_people_queue(action, queued_data);
29482 }
29483 if (!_.isUndefined(callback)) {
29484 callback(response, data);
29485 }
29486 });
29487 }
29488 };
29489
29490 // Flush queued engage operations - order does not matter,
29491 // and there are network level race conditions anyway
29492 MixpanelPeople.prototype._flush = function(
29493 _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
29494 ) {
29495 var _this = this;
29496
29497 this._flush_one_queue(SET_ACTION, this.set, _set_callback);
29498 this._flush_one_queue(SET_ONCE_ACTION, this.set_once, _set_once_callback);
29499 this._flush_one_queue(UNSET_ACTION, this.unset, _unset_callback, function(queue) { return _.keys(queue); });
29500 this._flush_one_queue(ADD_ACTION, this.increment, _add_callback);
29501 this._flush_one_queue(UNION_ACTION, this.union, _union_callback);
29502
29503 // we have to fire off each $append individually since there is
29504 // no concat method server side
29505 var $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29506 if (!_.isUndefined($append_queue) && _.isArray($append_queue) && $append_queue.length) {
29507 var $append_item;
29508 var append_callback = function(response, data) {
29509 if (response === 0) {
29510 _this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, $append_item);
29511 }
29512 if (!_.isUndefined(_append_callback)) {
29513 _append_callback(response, data);
29514 }
29515 };
29516 for (var i = $append_queue.length - 1; i >= 0; i--) {
29517 $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29518 $append_item = $append_queue.pop();
29519 _this._mixpanel['persistence'].save();
29520 if (!_.isEmptyObject($append_item)) {
29521 _this.append($append_item, append_callback);
29522 }
29523 }
29524 }
29525
29526 // same for $remove
29527 var $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29528 if (!_.isUndefined($remove_queue) && _.isArray($remove_queue) && $remove_queue.length) {
29529 var $remove_item;
29530 var remove_callback = function(response, data) {
29531 if (response === 0) {
29532 _this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, $remove_item);
29533 }
29534 if (!_.isUndefined(_remove_callback)) {
29535 _remove_callback(response, data);
29536 }
29537 };
29538 for (var j = $remove_queue.length - 1; j >= 0; j--) {
29539 $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29540 $remove_item = $remove_queue.pop();
29541 _this._mixpanel['persistence'].save();
29542 if (!_.isEmptyObject($remove_item)) {
29543 _this.remove($remove_item, remove_callback);
29544 }
29545 }
29546 }
29547 };
29548
29549 MixpanelPeople.prototype._is_reserved_property = function(prop) {
29550 return prop === '$distinct_id' || prop === '$token' || prop === '$device_id' || prop === '$user_id' || prop === '$had_persisted_distinct_id';
29551 };
29552
29553 // MixpanelPeople Exports
29554 MixpanelPeople.prototype['set'] = MixpanelPeople.prototype.set;
29555 MixpanelPeople.prototype['set_once'] = MixpanelPeople.prototype.set_once;
29556 MixpanelPeople.prototype['unset'] = MixpanelPeople.prototype.unset;
29557 MixpanelPeople.prototype['increment'] = MixpanelPeople.prototype.increment;
29558 MixpanelPeople.prototype['append'] = MixpanelPeople.prototype.append;
29559 MixpanelPeople.prototype['remove'] = MixpanelPeople.prototype.remove;
29560 MixpanelPeople.prototype['union'] = MixpanelPeople.prototype.union;
29561 MixpanelPeople.prototype['track_charge'] = MixpanelPeople.prototype.track_charge;
29562 MixpanelPeople.prototype['clear_charges'] = MixpanelPeople.prototype.clear_charges;
29563 MixpanelPeople.prototype['delete_user'] = MixpanelPeople.prototype.delete_user;
29564 MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
29565
29566 /* eslint camelcase: "off" */
29567
29568
29569 /*
29570 * Constants
29571 */
29572 /** @const */ var SET_QUEUE_KEY = '__mps';
29573 /** @const */ var SET_ONCE_QUEUE_KEY = '__mpso';
29574 /** @const */ var UNSET_QUEUE_KEY = '__mpus';
29575 /** @const */ var ADD_QUEUE_KEY = '__mpa';
29576 /** @const */ var APPEND_QUEUE_KEY = '__mpap';
29577 /** @const */ var REMOVE_QUEUE_KEY = '__mpr';
29578 /** @const */ var UNION_QUEUE_KEY = '__mpu';
29579 // This key is deprecated, but we want to check for it to see whether aliasing is allowed.
29580 /** @const */ var PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id';
29581 /** @const */ var ALIAS_ID_KEY = '__alias';
29582 /** @const */ var EVENT_TIMERS_KEY = '__timers';
29583 /** @const */ var RESERVED_PROPERTIES = [
29584 SET_QUEUE_KEY,
29585 SET_ONCE_QUEUE_KEY,
29586 UNSET_QUEUE_KEY,
29587 ADD_QUEUE_KEY,
29588 APPEND_QUEUE_KEY,
29589 REMOVE_QUEUE_KEY,
29590 UNION_QUEUE_KEY,
29591 PEOPLE_DISTINCT_ID_KEY,
29592 ALIAS_ID_KEY,
29593 EVENT_TIMERS_KEY
29594 ];
29595
29596 /**
29597 * Mixpanel Persistence Object
29598 * @constructor
29599 */
29600 var MixpanelPersistence = function(config) {
29601 this['props'] = {};
29602 this.campaign_params_saved = false;
29603
29604 if (config['persistence_name']) {
29605 this.name = 'mp_' + config['persistence_name'];
29606 } else {
29607 this.name = 'mp_' + config['token'] + '_mixpanel';
29608 }
29609
29610 var storage_type = config['persistence'];
29611 if (storage_type !== 'cookie' && storage_type !== 'localStorage') {
29612 console$1.critical('Unknown persistence type ' + storage_type + '; falling back to cookie');
29613 storage_type = config['persistence'] = 'cookie';
29614 }
29615
29616 if (storage_type === 'localStorage' && _.localStorage.is_supported()) {
29617 this.storage = _.localStorage;
29618 } else {
29619 this.storage = _.cookie;
29620 }
29621
29622 this.load();
29623 this.update_config(config);
29624 this.upgrade();
29625 this.save();
29626 };
29627
29628 MixpanelPersistence.prototype.properties = function() {
29629 var p = {};
29630
29631 this.load();
29632
29633 // Filter out reserved properties
29634 _.each(this['props'], function(v, k) {
29635 if (!_.include(RESERVED_PROPERTIES, k)) {
29636 p[k] = v;
29637 }
29638 });
29639 return p;
29640 };
29641
29642 MixpanelPersistence.prototype.load = function() {
29643 if (this.disabled) { return; }
29644
29645 var entry = this.storage.parse(this.name);
29646
29647 if (entry) {
29648 this['props'] = _.extend({}, entry);
29649 }
29650 };
29651
29652 MixpanelPersistence.prototype.upgrade = function() {
29653 var old_cookie,
29654 old_localstorage;
29655
29656 // if transferring from cookie to localStorage or vice-versa, copy existing
29657 // super properties over to new storage mode
29658 if (this.storage === _.localStorage) {
29659 old_cookie = _.cookie.parse(this.name);
29660
29661 _.cookie.remove(this.name);
29662 _.cookie.remove(this.name, true);
29663
29664 if (old_cookie) {
29665 this.register_once(old_cookie);
29666 }
29667 } else if (this.storage === _.cookie) {
29668 old_localstorage = _.localStorage.parse(this.name);
29669
29670 _.localStorage.remove(this.name);
29671
29672 if (old_localstorage) {
29673 this.register_once(old_localstorage);
29674 }
29675 }
29676 };
29677
29678 MixpanelPersistence.prototype.save = function() {
29679 if (this.disabled) { return; }
29680
29681 this.storage.set(
29682 this.name,
29683 JSONStringify(this['props']),
29684 this.expire_days,
29685 this.cross_subdomain,
29686 this.secure,
29687 this.cross_site,
29688 this.cookie_domain
29689 );
29690 };
29691
29692 MixpanelPersistence.prototype.load_prop = function(key) {
29693 this.load();
29694 return this['props'][key];
29695 };
29696
29697 MixpanelPersistence.prototype.remove = function() {
29698 // remove both domain and subdomain cookies
29699 this.storage.remove(this.name, false, this.cookie_domain);
29700 this.storage.remove(this.name, true, this.cookie_domain);
29701 };
29702
29703 // removes the storage entry and deletes all loaded data
29704 // forced name for tests
29705 MixpanelPersistence.prototype.clear = function() {
29706 this.remove();
29707 this['props'] = {};
29708 };
29709
29710 /**
29711 * @param {Object} props
29712 * @param {*=} default_value
29713 * @param {number=} days
29714 */
29715 MixpanelPersistence.prototype.register_once = function(props, default_value, days) {
29716 if (_.isObject(props)) {
29717 if (typeof(default_value) === 'undefined') { default_value = 'None'; }
29718 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29719
29720 this.load();
29721
29722 _.each(props, function(val, prop) {
29723 if (!this['props'].hasOwnProperty(prop) || this['props'][prop] === default_value) {
29724 this['props'][prop] = val;
29725 }
29726 }, this);
29727
29728 this.save();
29729
29730 return true;
29731 }
29732 return false;
29733 };
29734
29735 /**
29736 * @param {Object} props
29737 * @param {number=} days
29738 */
29739 MixpanelPersistence.prototype.register = function(props, days) {
29740 if (_.isObject(props)) {
29741 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29742
29743 this.load();
29744 _.extend(this['props'], props);
29745 this.save();
29746
29747 return true;
29748 }
29749 return false;
29750 };
29751
29752 MixpanelPersistence.prototype.unregister = function(prop) {
29753 this.load();
29754 if (prop in this['props']) {
29755 delete this['props'][prop];
29756 this.save();
29757 }
29758 };
29759
29760 MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
29761 this.register(_.info.searchInfo(referrer));
29762 };
29763
29764 // EXPORTED METHOD, we test this directly.
29765 MixpanelPersistence.prototype.update_referrer_info = function(referrer) {
29766 // If referrer doesn't exist, we want to note the fact that it was type-in traffic.
29767 this.register_once({
29768 '$initial_referrer': referrer || '$direct',
29769 '$initial_referring_domain': _.info.referringDomain(referrer) || '$direct'
29770 }, '');
29771 };
29772
29773 MixpanelPersistence.prototype.get_referrer_info = function() {
29774 return _.strip_empty_properties({
29775 '$initial_referrer': this['props']['$initial_referrer'],
29776 '$initial_referring_domain': this['props']['$initial_referring_domain']
29777 });
29778 };
29779
29780 MixpanelPersistence.prototype.update_config = function(config) {
29781 this.default_expiry = this.expire_days = config['cookie_expiration'];
29782 this.set_disabled(config['disable_persistence']);
29783 this.set_cookie_domain(config['cookie_domain']);
29784 this.set_cross_site(config['cross_site_cookie']);
29785 this.set_cross_subdomain(config['cross_subdomain_cookie']);
29786 this.set_secure(config['secure_cookie']);
29787 };
29788
29789 MixpanelPersistence.prototype.set_disabled = function(disabled) {
29790 this.disabled = disabled;
29791 if (this.disabled) {
29792 this.remove();
29793 } else {
29794 this.save();
29795 }
29796 };
29797
29798 MixpanelPersistence.prototype.set_cookie_domain = function(cookie_domain) {
29799 if (cookie_domain !== this.cookie_domain) {
29800 this.remove();
29801 this.cookie_domain = cookie_domain;
29802 this.save();
29803 }
29804 };
29805
29806 MixpanelPersistence.prototype.set_cross_site = function(cross_site) {
29807 if (cross_site !== this.cross_site) {
29808 this.cross_site = cross_site;
29809 this.remove();
29810 this.save();
29811 }
29812 };
29813
29814 MixpanelPersistence.prototype.set_cross_subdomain = function(cross_subdomain) {
29815 if (cross_subdomain !== this.cross_subdomain) {
29816 this.cross_subdomain = cross_subdomain;
29817 this.remove();
29818 this.save();
29819 }
29820 };
29821
29822 MixpanelPersistence.prototype.get_cross_subdomain = function() {
29823 return this.cross_subdomain;
29824 };
29825
29826 MixpanelPersistence.prototype.set_secure = function(secure) {
29827 if (secure !== this.secure) {
29828 this.secure = secure ? true : false;
29829 this.remove();
29830 this.save();
29831 }
29832 };
29833
29834 MixpanelPersistence.prototype._add_to_people_queue = function(queue, data) {
29835 var q_key = this._get_queue_key(queue),
29836 q_data = data[queue],
29837 set_q = this._get_or_create_queue(SET_ACTION),
29838 set_once_q = this._get_or_create_queue(SET_ONCE_ACTION),
29839 unset_q = this._get_or_create_queue(UNSET_ACTION),
29840 add_q = this._get_or_create_queue(ADD_ACTION),
29841 union_q = this._get_or_create_queue(UNION_ACTION),
29842 remove_q = this._get_or_create_queue(REMOVE_ACTION, []),
29843 append_q = this._get_or_create_queue(APPEND_ACTION, []);
29844
29845 if (q_key === SET_QUEUE_KEY) {
29846 // Update the set queue - we can override any existing values
29847 _.extend(set_q, q_data);
29848 // if there was a pending increment, override it
29849 // with the set.
29850 this._pop_from_people_queue(ADD_ACTION, q_data);
29851 // if there was a pending union, override it
29852 // with the set.
29853 this._pop_from_people_queue(UNION_ACTION, q_data);
29854 this._pop_from_people_queue(UNSET_ACTION, q_data);
29855 } else if (q_key === SET_ONCE_QUEUE_KEY) {
29856 // only queue the data if there is not already a set_once call for it.
29857 _.each(q_data, function(v, k) {
29858 if (!(k in set_once_q)) {
29859 set_once_q[k] = v;
29860 }
29861 });
29862 this._pop_from_people_queue(UNSET_ACTION, q_data);
29863 } else if (q_key === UNSET_QUEUE_KEY) {
29864 _.each(q_data, function(prop) {
29865
29866 // undo previously-queued actions on this key
29867 _.each([set_q, set_once_q, add_q, union_q], function(enqueued_obj) {
29868 if (prop in enqueued_obj) {
29869 delete enqueued_obj[prop];
29870 }
29871 });
29872 _.each(append_q, function(append_obj) {
29873 if (prop in append_obj) {
29874 delete append_obj[prop];
29875 }
29876 });
29877
29878 unset_q[prop] = true;
29879
29880 });
29881 } else if (q_key === ADD_QUEUE_KEY) {
29882 _.each(q_data, function(v, k) {
29883 // If it exists in the set queue, increment
29884 // the value
29885 if (k in set_q) {
29886 set_q[k] += v;
29887 } else {
29888 // If it doesn't exist, update the add
29889 // queue
29890 if (!(k in add_q)) {
29891 add_q[k] = 0;
29892 }
29893 add_q[k] += v;
29894 }
29895 }, this);
29896 this._pop_from_people_queue(UNSET_ACTION, q_data);
29897 } else if (q_key === UNION_QUEUE_KEY) {
29898 _.each(q_data, function(v, k) {
29899 if (_.isArray(v)) {
29900 if (!(k in union_q)) {
29901 union_q[k] = [];
29902 }
29903 // Prevent duplicate values
29904 _.each(v, function(item) {
29905 if (!_.include(union_q[k], item)) {
29906 union_q[k].push(item);
29907 }
29908 });
29909 }
29910 });
29911 this._pop_from_people_queue(UNSET_ACTION, q_data);
29912 } else if (q_key === REMOVE_QUEUE_KEY) {
29913 remove_q.push(q_data);
29914 this._pop_from_people_queue(APPEND_ACTION, q_data);
29915 } else if (q_key === APPEND_QUEUE_KEY) {
29916 append_q.push(q_data);
29917 this._pop_from_people_queue(UNSET_ACTION, q_data);
29918 }
29919
29920 console$1.log('MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):');
29921 console$1.log(data);
29922
29923 this.save();
29924 };
29925
29926 MixpanelPersistence.prototype._pop_from_people_queue = function(queue, data) {
29927 var q = this['props'][this._get_queue_key(queue)];
29928 if (!_.isUndefined(q)) {
29929 _.each(data, function(v, k) {
29930 if (queue === APPEND_ACTION || queue === REMOVE_ACTION) {
29931 // list actions: only remove if both k+v match
29932 // e.g. remove should not override append in a case like
29933 // append({foo: 'bar'}); remove({foo: 'qux'})
29934 _.each(q, function(queued_action) {
29935 if (queued_action[k] === v) {
29936 delete queued_action[k];
29937 }
29938 });
29939 } else {
29940 delete q[k];
29941 }
29942 }, this);
29943 }
29944 };
29945
29946 MixpanelPersistence.prototype.load_queue = function(queue) {
29947 return this.load_prop(this._get_queue_key(queue));
29948 };
29949
29950 MixpanelPersistence.prototype._get_queue_key = function(queue) {
29951 if (queue === SET_ACTION) {
29952 return SET_QUEUE_KEY;
29953 } else if (queue === SET_ONCE_ACTION) {
29954 return SET_ONCE_QUEUE_KEY;
29955 } else if (queue === UNSET_ACTION) {
29956 return UNSET_QUEUE_KEY;
29957 } else if (queue === ADD_ACTION) {
29958 return ADD_QUEUE_KEY;
29959 } else if (queue === APPEND_ACTION) {
29960 return APPEND_QUEUE_KEY;
29961 } else if (queue === REMOVE_ACTION) {
29962 return REMOVE_QUEUE_KEY;
29963 } else if (queue === UNION_ACTION) {
29964 return UNION_QUEUE_KEY;
29965 } else {
29966 console$1.error('Invalid queue:', queue);
29967 }
29968 };
29969
29970 MixpanelPersistence.prototype._get_or_create_queue = function(queue, default_val) {
29971 var key = this._get_queue_key(queue);
29972 default_val = _.isUndefined(default_val) ? {} : default_val;
29973 return this['props'][key] || (this['props'][key] = default_val);
29974 };
29975
29976 MixpanelPersistence.prototype.set_event_timer = function(event_name, timestamp) {
29977 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29978 timers[event_name] = timestamp;
29979 this['props'][EVENT_TIMERS_KEY] = timers;
29980 this.save();
29981 };
29982
29983 MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
29984 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29985 var timestamp = timers[event_name];
29986 if (!_.isUndefined(timestamp)) {
29987 delete this['props'][EVENT_TIMERS_KEY][event_name];
29988 this.save();
29989 }
29990 return timestamp;
29991 };
29992
29993 /* eslint camelcase: "off" */
29994
29995 /*
29996 * Mixpanel JS Library
29997 *
29998 * Copyright 2012, Mixpanel, Inc. All Rights Reserved
29999 * http://mixpanel.com/
30000 *
30001 * Includes portions of Underscore.js
30002 * http://documentcloud.github.com/underscore/
30003 * (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
30004 * Released under the MIT License.
30005 */
30006
30007 /*
30008 SIMPLE STYLE GUIDE:
30009
30010 this.x === public function
30011 this._x === internal - only use within this file
30012 this.__x === private - only use within the class
30013
30014 Globals should be all caps
30015 */
30016
30017 var init_type; // MODULE or SNIPPET loader
30018 // allow bundlers to specify how extra code (recorder bundle) should be loaded
30019 // eslint-disable-next-line no-unused-vars
30020 var load_extra_bundle = function(src, _onload) {
30021 throw new Error(src + ' not available in this build.');
30022 };
30023
30024 var mixpanel_master; // main mixpanel instance / object
30025 var INIT_MODULE = 0;
30026 var INIT_SNIPPET = 1;
30027
30028 var IDENTITY_FUNC = function(x) {return x;};
30029
30030 /** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
30031 /** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
30032 /** @const */ var PAYLOAD_TYPE_JSON = 'json';
30033 /** @const */ var DEVICE_ID_PREFIX = '$device:';
30034
30035
30036 /*
30037 * Dynamic... constants? Is that an oxymoron?
30038 */
30039 // http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
30040 // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#withCredentials
30041 var USE_XHR = (win.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest());
30042
30043 // IE<10 does not support cross-origin XHR's but script tags
30044 // with defer won't block window.onload; ENQUEUE_REQUESTS
30045 // should only be true for Opera<12
30046 var ENQUEUE_REQUESTS = !USE_XHR && (userAgent.indexOf('MSIE') === -1) && (userAgent.indexOf('Mozilla') === -1);
30047
30048 // save reference to navigator.sendBeacon so it can be minified
30049 var sendBeacon = null;
30050 if (navigator['sendBeacon']) {
30051 sendBeacon = function() {
30052 // late reference to navigator.sendBeacon to allow patching/spying
30053 return navigator['sendBeacon'].apply(navigator, arguments);
30054 };
30055 }
30056
30057 var DEFAULT_API_ROUTES = {
30058 'track': 'track/',
30059 'engage': 'engage/',
30060 'groups': 'groups/',
30061 'record': 'record/',
30062 'flags': 'flags/'
30063 };
30064
30065 /*
30066 * Module-level globals
30067 */
30068 var DEFAULT_CONFIG = {
30069 'api_host': 'https://api-js.mixpanel.com',
30070 'api_hosts': {},
30071 'api_routes': DEFAULT_API_ROUTES,
30072 'api_extra_query_params': {},
30073 'api_method': 'POST',
30074 'api_transport': 'XHR',
30075 'api_payload_format': PAYLOAD_TYPE_BASE64,
30076 'app_host': 'https://mixpanel.com',
30077 'autocapture': false,
30078 'cdn': 'https://cdn.mxpnl.com',
30079 'cross_site_cookie': false,
30080 'cross_subdomain_cookie': true,
30081 'error_reporter': NOOP_FUNC,
30082 'flags': false,
30083 'persistence': 'cookie',
30084 'persistence_name': '',
30085 'cookie_domain': '',
30086 'cookie_name': '',
30087 'loaded': NOOP_FUNC,
30088 'mp_loader': null,
30089 'track_marketing': true,
30090 'track_pageview': false,
30091 'skip_first_touch_marketing': false,
30092 'store_google': true,
30093 'stop_utm_persistence': false,
30094 'save_referrer': true,
30095 'test': false,
30096 'verbose': false,
30097 'img': false,
30098 'debug': false,
30099 'track_links_timeout': 300,
30100 'cookie_expiration': 365,
30101 'upgrade': false,
30102 'disable_persistence': false,
30103 'disable_cookie': false,
30104 'secure_cookie': false,
30105 'ip': true,
30106 'opt_out_tracking_by_default': false,
30107 'opt_out_persistence_by_default': false,
30108 'opt_out_tracking_persistence_type': 'localStorage',
30109 'opt_out_tracking_cookie_prefix': null,
30110 'property_blacklist': [],
30111 'xhr_headers': {}, // { header: value, header2: value }
30112 'ignore_dnt': false,
30113 'batch_requests': true,
30114 'batch_size': 50,
30115 'batch_flush_interval_ms': 5000,
30116 'batch_request_timeout_ms': 90000,
30117 'batch_autostart': true,
30118 'hooks': {},
30119 'record_block_class': new RegExp('^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$'),
30120 'record_block_selector': 'img, video, audio',
30121 'record_canvas': false,
30122 'record_collect_fonts': false,
30123 'record_heatmap_data': false,
30124 'record_idle_timeout_ms': 30 * 60 * 1000, // 30 minutes
30125 'record_mask_text_class': new RegExp('^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$'),
30126 'record_mask_text_selector': '*',
30127 'record_max_ms': MAX_RECORDING_MS,
30128 'record_min_ms': 0,
30129 'record_sessions_percent': 0,
30130 'recorder_src': 'https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js'
30131 };
30132
30133 var DOM_LOADED = false;
30134
30135 /**
30136 * Mixpanel Library Object
30137 * @constructor
30138 */
30139 var MixpanelLib = function() {};
30140
30141
30142 /**
30143 * create_mplib(token:string, config:object, name:string)
30144 *
30145 * This function is used by the init method of MixpanelLib objects
30146 * as well as the main initializer at the end of the JSLib (that
30147 * initializes document.mixpanel as well as any additional instances
30148 * declared before this file has loaded).
30149 */
30150 var create_mplib = function(token, config, name) {
30151 var instance,
30152 target = (name === PRIMARY_INSTANCE_NAME) ? mixpanel_master : mixpanel_master[name];
30153
30154 if (target && init_type === INIT_MODULE) {
30155 instance = target;
30156 } else {
30157 if (target && !_.isArray(target)) {
30158 console$1.error('You have already initialized ' + name);
30159 return;
30160 }
30161 instance = new MixpanelLib();
30162 }
30163
30164 instance._cached_groups = {}; // cache groups in a pool
30165
30166 instance._init(token, config, name);
30167
30168 instance['people'] = new MixpanelPeople();
30169 instance['people']._init(instance);
30170
30171 if (!instance.get_config('skip_first_touch_marketing')) {
30172 // We need null UTM params in the object because
30173 // UTM parameters act as a tuple. If any UTM param
30174 // is present, then we set all UTM params including
30175 // empty ones together
30176 var utm_params = _.info.campaignParams(null);
30177 var initial_utm_params = {};
30178 var has_utm = false;
30179 _.each(utm_params, function(utm_value, utm_key) {
30180 initial_utm_params['initial_' + utm_key] = utm_value;
30181 if (utm_value) {
30182 has_utm = true;
30183 }
30184 });
30185 if (has_utm) {
30186 instance['people'].set_once(initial_utm_params);
30187 }
30188 }
30189
30190 // if any instance on the page has debug = true, we set the
30191 // global debug to be true
30192 Config.DEBUG = Config.DEBUG || instance.get_config('debug');
30193
30194 // if target is not defined, we called init after the lib already
30195 // loaded, so there won't be an array of things to execute
30196 if (!_.isUndefined(target) && _.isArray(target)) {
30197 // Crunch through the people queue first - we queue this data up &
30198 // flush on identify, so it's better to do all these operations first
30199 instance._execute_array.call(instance['people'], target['people']);
30200 instance._execute_array(target);
30201 }
30202
30203 return instance;
30204 };
30205
30206 // Initialization methods
30207
30208 /**
30209 * This function initializes a new instance of the Mixpanel tracking object.
30210 * All new instances are added to the main mixpanel object as sub properties (such as
30211 * mixpanel.library_name) and also returned by this function. To define a
30212 * second instance on the page, you would call:
30213 *
30214 * mixpanel.init('new token', { your: 'config' }, 'library_name');
30215 *
30216 * and use it like so:
30217 *
30218 * mixpanel.library_name.track(...);
30219 *
30220 * @param {String} token Your Mixpanel API token
30221 * @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>.
30222 * @param {String} [name] The name for the new mixpanel instance that you want created
30223 */
30224 MixpanelLib.prototype.init = function (token, config, name) {
30225 if (_.isUndefined(name)) {
30226 this.report_error('You must name your new library: init(token, config, name)');
30227 return;
30228 }
30229 if (name === PRIMARY_INSTANCE_NAME) {
30230 this.report_error('You must initialize the main mixpanel object right after you include the Mixpanel js snippet');
30231 return;
30232 }
30233
30234 var instance = create_mplib(token, config, name);
30235 mixpanel_master[name] = instance;
30236 instance._loaded();
30237
30238 return instance;
30239 };
30240
30241 // mixpanel._init(token:string, config:object, name:string)
30242 //
30243 // This function sets up the current instance of the mixpanel
30244 // library. The difference between this method and the init(...)
30245 // method is this one initializes the actual instance, whereas the
30246 // init(...) method sets up a new library and calls _init on it.
30247 //
30248 MixpanelLib.prototype._init = function(token, config, name) {
30249 config = config || {};
30250
30251 this['__loaded'] = true;
30252 this['config'] = {};
30253
30254 var variable_features = {};
30255
30256 // default to JSON payload for standard mixpanel.com API hosts
30257 if (!('api_payload_format' in config)) {
30258 var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
30259 if (api_host.match(/\.mixpanel\.com/)) {
30260 variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
30261 }
30262 }
30263
30264 this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
30265 'name': name,
30266 'token': token,
30267 'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
30268 }));
30269
30270 this['_jsc'] = NOOP_FUNC;
30271
30272 this.__dom_loaded_queue = [];
30273 this.__request_queue = [];
30274 this.__disabled_events = [];
30275 this._flags = {
30276 'disable_all_events': false,
30277 'identify_called': false
30278 };
30279
30280 // set up request queueing/batching
30281 this.request_batchers = {};
30282 this._batch_requests = this.get_config('batch_requests');
30283 if (this._batch_requests) {
30284 if (!_.localStorage.is_supported(true) || !USE_XHR) {
30285 this._batch_requests = false;
30286 console$1.log('Turning off Mixpanel request-queueing; needs XHR and localStorage support');
30287 _.each(this.get_batcher_configs(), function(batcher_config) {
30288 console$1.log('Clearing batch queue ' + batcher_config.queue_key);
30289 _.localStorage.remove(batcher_config.queue_key);
30290 });
30291 } else {
30292 this.init_batchers();
30293 if (sendBeacon && win.addEventListener) {
30294 // Before page closes or hides (user tabs away etc), attempt to flush any events
30295 // queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
30296 // events will not be removed from the persistent store; if the site is loaded again,
30297 // the events will be flushed again on startup and deduplicated on the Mixpanel server
30298 // side.
30299 // There is no reliable way to capture only page close events, so we lean on the
30300 // visibilitychange and pagehide events as recommended at
30301 // https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event#usage_notes.
30302 // These events fire when the user clicks away from the current page/tab, so will occur
30303 // more frequently than page unload, but are the only mechanism currently for capturing
30304 // this scenario somewhat reliably.
30305 var flush_on_unload = _.bind(function() {
30306 if (!this.request_batchers.events.stopped) {
30307 this.request_batchers.events.flush({unloading: true});
30308 }
30309 }, this);
30310 win.addEventListener('pagehide', function(ev) {
30311 if (ev['persisted']) {
30312 flush_on_unload();
30313 }
30314 });
30315 win.addEventListener('visibilitychange', function() {
30316 if (document$1['visibilityState'] === 'hidden') {
30317 flush_on_unload();
30318 }
30319 });
30320 }
30321 }
30322 }
30323
30324 this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config']);
30325 this.unpersisted_superprops = {};
30326 this._gdpr_init();
30327
30328 var uuid = _.UUID();
30329 if (!this.get_distinct_id()) {
30330 // There is no need to set the distinct id
30331 // or the device id if something was already stored
30332 // in the persitence
30333 this.register_once({
30334 'distinct_id': DEVICE_ID_PREFIX + uuid,
30335 '$device_id': uuid
30336 }, '');
30337 }
30338
30339 this.flags = new FeatureFlagManager({
30340 getFullApiRoute: _.bind(function() {
30341 return this.get_api_host('flags') + '/' + this.get_config('api_routes')['flags'];
30342 }, this),
30343 getConfigFunc: _.bind(this.get_config, this),
30344 setConfigFunc: _.bind(this.set_config, this),
30345 getPropertyFunc: _.bind(this.get_property, this),
30346 trackingFunc: _.bind(this.track, this)
30347 });
30348 this.flags.init();
30349 this['flags'] = this.flags;
30350
30351 this.autocapture = new Autocapture(this);
30352 this.autocapture.init();
30353
30354 this._init_tab_id();
30355 this._check_and_start_session_recording();
30356 };
30357
30358 /**
30359 * Assigns a unique UUID to this tab / window by leveraging sessionStorage.
30360 * This is primarily used for session recording, where data must be isolated to the current tab.
30361 */
30362 MixpanelLib.prototype._init_tab_id = function() {
30363 if (this.get_config('disable_persistence')) {
30364 console$1.log('Tab ID initialization skipped due to disable_persistence config');
30365 } else if (_.sessionStorage.is_supported()) {
30366 try {
30367 var key_suffix = this.get_config('name') + '_' + this.get_config('token');
30368 var tab_id_key = 'mp_tab_id_' + key_suffix;
30369
30370 // A flag is used to determine if sessionStorage is copied over and we need to generate a new tab ID.
30371 // This enforces a unique ID in the cases like duplicated tab, window.open(...)
30372 var should_generate_new_tab_id_key = 'mp_gen_new_tab_id_' + key_suffix;
30373 if (_.sessionStorage.get(should_generate_new_tab_id_key) || !_.sessionStorage.get(tab_id_key)) {
30374 _.sessionStorage.set(tab_id_key, '$tab-' + _.UUID());
30375 }
30376
30377 _.sessionStorage.set(should_generate_new_tab_id_key, '1');
30378 this.tab_id = _.sessionStorage.get(tab_id_key);
30379
30380 // 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,
30381 // but reliable in cases where the user remains in the tab e.g. a refresh or href navigation.
30382 // If the flag is absent, this indicates to the next SDK instance that we can reuse the stored tab_id.
30383 win.addEventListener('beforeunload', function () {
30384 _.sessionStorage.remove(should_generate_new_tab_id_key);
30385 });
30386 } catch(err) {
30387 this.report_error('Error initializing tab id', err);
30388 }
30389 } else {
30390 this.report_error('Session storage is not supported, cannot keep track of unique tab ID.');
30391 }
30392 };
30393
30394 MixpanelLib.prototype.get_tab_id = function () {
30395 return this.tab_id || null;
30396 };
30397
30398 MixpanelLib.prototype._should_load_recorder = function () {
30399 if (this.get_config('disable_persistence')) {
30400 console$1.log('Load recorder check skipped due to disable_persistence config');
30401 return Promise.resolve(false);
30402 }
30403
30404 var recording_registry_idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
30405 var tab_id = this.get_tab_id();
30406 return recording_registry_idb.init()
30407 .then(function () {
30408 return recording_registry_idb.getAll();
30409 })
30410 .then(function (recordings) {
30411 for (var i = 0; i < recordings.length; i++) {
30412 // if there are expired recordings in the registry, we should load the recorder to flush them
30413 // if there's a recording for this tab id, we should load the recorder to continue the recording
30414 if (isRecordingExpired(recordings[i]) || recordings[i]['tabId'] === tab_id) {
30415 return true;
30416 }
30417 }
30418 return false;
30419 })
30420 .catch(_.bind(function (err) {
30421 this.report_error('Error checking recording registry', err);
30422 }, this));
30423 };
30424
30425 MixpanelLib.prototype._check_and_start_session_recording = addOptOutCheckMixpanelLib(function(force_start) {
30426 if (!win['MutationObserver']) {
30427 console$1.critical('Browser does not support MutationObserver; skipping session recording');
30428 return;
30429 }
30430
30431 var loadRecorder = _.bind(function(startNewIfInactive) {
30432 var handleLoadedRecorder = _.bind(function() {
30433 this._recorder = this._recorder || new win['__mp_recorder'](this);
30434 this._recorder['resumeRecording'](startNewIfInactive);
30435 }, this);
30436
30437 if (_.isUndefined(win['__mp_recorder'])) {
30438 load_extra_bundle(this.get_config('recorder_src'), handleLoadedRecorder);
30439 } else {
30440 handleLoadedRecorder();
30441 }
30442 }, this);
30443
30444 /**
30445 * If the user is sampled or start_session_recording is called, we always load the recorder since it's guaranteed a recording should start.
30446 * 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.
30447 */
30448 var is_sampled = this.get_config('record_sessions_percent') > 0 && Math.random() * 100 <= this.get_config('record_sessions_percent');
30449 if (force_start || is_sampled) {
30450 loadRecorder(true);
30451 } else {
30452 this._should_load_recorder()
30453 .then(function (shouldLoad) {
30454 if (shouldLoad) {
30455 loadRecorder(false);
30456 }
30457 });
30458 }
30459 });
30460
30461 MixpanelLib.prototype.start_session_recording = function () {
30462 this._check_and_start_session_recording(true);
30463 };
30464
30465 MixpanelLib.prototype.stop_session_recording = function () {
30466 if (this._recorder) {
30467 return this._recorder['stopRecording']();
30468 }
30469 return Promise.resolve();
30470 };
30471
30472 MixpanelLib.prototype.pause_session_recording = function () {
30473 if (this._recorder) {
30474 return this._recorder['pauseRecording']();
30475 }
30476 return Promise.resolve();
30477 };
30478
30479 MixpanelLib.prototype.resume_session_recording = function () {
30480 if (this._recorder) {
30481 return this._recorder['resumeRecording']();
30482 }
30483 return Promise.resolve();
30484 };
30485
30486 MixpanelLib.prototype.is_recording_heatmap_data = function () {
30487 return this._get_session_replay_id() && this.get_config('record_heatmap_data');
30488 };
30489
30490 MixpanelLib.prototype.get_session_recording_properties = function () {
30491 var props = {};
30492 var replay_id = this._get_session_replay_id();
30493 if (replay_id) {
30494 props['$mp_replay_id'] = replay_id;
30495 }
30496 return props;
30497 };
30498
30499 MixpanelLib.prototype.get_session_replay_url = function () {
30500 var replay_url = null;
30501 var replay_id = this._get_session_replay_id();
30502 if (replay_id) {
30503 var query_params = _.HTTPBuildQuery({
30504 'replay_id': replay_id,
30505 'distinct_id': this.get_distinct_id(),
30506 'token': this.get_config('token')
30507 });
30508 replay_url = 'https://mixpanel.com/projects/replay-redirect?' + query_params;
30509 }
30510 return replay_url;
30511 };
30512
30513 MixpanelLib.prototype._get_session_replay_id = function () {
30514 var replay_id = null;
30515 if (this._recorder) {
30516 replay_id = this._recorder['replayId'];
30517 }
30518 return replay_id || null;
30519 };
30520
30521 // "private" public method to reach into the recorder in test cases
30522 MixpanelLib.prototype.__get_recorder = function () {
30523 return this._recorder;
30524 };
30525
30526 // Private methods
30527
30528 MixpanelLib.prototype._loaded = function() {
30529 this.get_config('loaded')(this);
30530 this._set_default_superprops();
30531 this['people'].set_once(this['persistence'].get_referrer_info());
30532
30533 // `store_google` is now deprecated and previously stored UTM parameters are cleared
30534 // from persistence by default.
30535 if (this.get_config('store_google') && this.get_config('stop_utm_persistence')) {
30536 var utm_params = _.info.campaignParams(null);
30537 _.each(utm_params, function(_utm_value, utm_key) {
30538 // We need to unregister persisted UTM parameters so old values
30539 // are not mixed with the new UTM parameters
30540 this.unregister(utm_key);
30541 }.bind(this));
30542 }
30543 };
30544
30545 // update persistence with info on referrer, UTM params, etc
30546 MixpanelLib.prototype._set_default_superprops = function() {
30547 this['persistence'].update_search_keyword(document$1.referrer);
30548 // Registering super properties for UTM persistence by 'store_google' is deprecated.
30549 if (this.get_config('store_google') && !this.get_config('stop_utm_persistence')) {
30550 this.register(_.info.campaignParams());
30551 }
30552 if (this.get_config('save_referrer')) {
30553 this['persistence'].update_referrer_info(document$1.referrer);
30554 }
30555 };
30556
30557 MixpanelLib.prototype._dom_loaded = function() {
30558 _.each(this.__dom_loaded_queue, function(item) {
30559 this._track_dom.apply(this, item);
30560 }, this);
30561
30562 if (!this.has_opted_out_tracking()) {
30563 _.each(this.__request_queue, function(item) {
30564 this._send_request.apply(this, item);
30565 }, this);
30566 }
30567
30568 delete this.__dom_loaded_queue;
30569 delete this.__request_queue;
30570 };
30571
30572 MixpanelLib.prototype._track_dom = function(DomClass, args) {
30573 if (this.get_config('img')) {
30574 this.report_error('You can\'t use DOM tracking functions with img = true.');
30575 return false;
30576 }
30577
30578 if (!DOM_LOADED) {
30579 this.__dom_loaded_queue.push([DomClass, args]);
30580 return false;
30581 }
30582
30583 var dt = new DomClass().init(this);
30584 return dt.track.apply(dt, args);
30585 };
30586
30587 /**
30588 * _prepare_callback() should be called by callers of _send_request for use
30589 * as the callback argument.
30590 *
30591 * If there is no callback, this returns null.
30592 * If we are going to make XHR/XDR requests, this returns a function.
30593 * If we are going to use script tags, this returns a string to use as the
30594 * callback GET param.
30595 */
30596 MixpanelLib.prototype._prepare_callback = function(callback, data) {
30597 if (_.isUndefined(callback)) {
30598 return null;
30599 }
30600
30601 if (USE_XHR) {
30602 var callback_function = function(response) {
30603 callback(response, data);
30604 };
30605 return callback_function;
30606 } else {
30607 // if the user gives us a callback, we store as a random
30608 // property on this instances jsc function and update our
30609 // callback string to reflect that.
30610 var jsc = this['_jsc'];
30611 var randomized_cb = '' + Math.floor(Math.random() * 100000000);
30612 var callback_string = this.get_config('callback_fn') + '[' + randomized_cb + ']';
30613 jsc[randomized_cb] = function(response) {
30614 delete jsc[randomized_cb];
30615 callback(response, data);
30616 };
30617 return callback_string;
30618 }
30619 };
30620
30621 MixpanelLib.prototype._send_request = function(url, data, options, callback) {
30622 var succeeded = true;
30623
30624 if (ENQUEUE_REQUESTS) {
30625 this.__request_queue.push(arguments);
30626 return succeeded;
30627 }
30628
30629 var DEFAULT_OPTIONS = {
30630 method: this.get_config('api_method'),
30631 transport: this.get_config('api_transport'),
30632 verbose: this.get_config('verbose')
30633 };
30634 var body_data = null;
30635
30636 if (!callback && (_.isFunction(options) || typeof options === 'string')) {
30637 callback = options;
30638 options = null;
30639 }
30640 options = _.extend(DEFAULT_OPTIONS, options || {});
30641 if (!USE_XHR) {
30642 options.method = 'GET';
30643 }
30644 var use_post = options.method === 'POST';
30645 var use_sendBeacon = sendBeacon && use_post && options.transport.toLowerCase() === 'sendbeacon';
30646
30647 // needed to correctly format responses
30648 var verbose_mode = options.verbose;
30649 if (data['verbose']) { verbose_mode = true; }
30650
30651 if (this.get_config('test')) { data['test'] = 1; }
30652 if (verbose_mode) { data['verbose'] = 1; }
30653 if (this.get_config('img')) { data['img'] = 1; }
30654 if (!USE_XHR) {
30655 if (callback) {
30656 data['callback'] = callback;
30657 } else if (verbose_mode || this.get_config('test')) {
30658 // Verbose output (from verbose mode, or an error in test mode) is a json blob,
30659 // which by itself is not valid javascript. Without a callback, this verbose output will
30660 // cause an error when returned via jsonp, so we force a no-op callback param.
30661 // See the ECMA script spec: http://www.ecma-international.org/ecma-262/5.1/#sec-12.4
30662 data['callback'] = '(function(){})';
30663 }
30664 }
30665
30666 data['ip'] = this.get_config('ip')?1:0;
30667 data['_'] = new Date().getTime().toString();
30668
30669 if (use_post) {
30670 body_data = 'data=' + encodeURIComponent(data['data']);
30671 delete data['data'];
30672 }
30673
30674 _.extend(data, this.get_config('api_extra_query_params'));
30675
30676 url += '?' + _.HTTPBuildQuery(data);
30677
30678 var lib = this;
30679 if ('img' in data) {
30680 var img = document$1.createElement('img');
30681 img.src = url;
30682 document$1.body.appendChild(img);
30683 } else if (use_sendBeacon) {
30684 try {
30685 succeeded = sendBeacon(url, body_data);
30686 } catch (e) {
30687 lib.report_error(e);
30688 succeeded = false;
30689 }
30690 try {
30691 if (callback) {
30692 callback(succeeded ? 1 : 0);
30693 }
30694 } catch (e) {
30695 lib.report_error(e);
30696 }
30697 } else if (USE_XHR) {
30698 try {
30699 var req = new XMLHttpRequest();
30700 req.open(options.method, url, true);
30701
30702 var headers = this.get_config('xhr_headers');
30703 if (use_post) {
30704 headers['Content-Type'] = 'application/x-www-form-urlencoded';
30705 }
30706 _.each(headers, function(headerValue, headerName) {
30707 req.setRequestHeader(headerName, headerValue);
30708 });
30709
30710 if (options.timeout_ms && typeof req.timeout !== 'undefined') {
30711 req.timeout = options.timeout_ms;
30712 var start_time = new Date().getTime();
30713 }
30714
30715 // send the mp_optout cookie
30716 // withCredentials cannot be modified until after calling .open on Android and Mobile Safari
30717 req.withCredentials = true;
30718 req.onreadystatechange = function () {
30719 if (req.readyState === 4) { // XMLHttpRequest.DONE == 4, except in safari 4
30720 if (req.status === 200) {
30721 if (callback) {
30722 if (verbose_mode) {
30723 var response;
30724 try {
30725 response = _.JSONDecode(req.responseText);
30726 } catch (e) {
30727 lib.report_error(e);
30728 if (options.ignore_json_errors) {
30729 response = req.responseText;
30730 } else {
30731 return;
30732 }
30733 }
30734 callback(response);
30735 } else {
30736 callback(Number(req.responseText));
30737 }
30738 }
30739 } else {
30740 var error;
30741 if (
30742 req.timeout &&
30743 !req.status &&
30744 new Date().getTime() - start_time >= req.timeout
30745 ) {
30746 error = 'timeout';
30747 } else {
30748 error = 'Bad HTTP status: ' + req.status + ' ' + req.statusText;
30749 }
30750 lib.report_error(error);
30751 if (callback) {
30752 if (verbose_mode) {
30753 var response_headers = req['responseHeaders'] || {};
30754 callback({status: 0, httpStatusCode: req['status'], error: error, retryAfter: response_headers['Retry-After']});
30755 } else {
30756 callback(0);
30757 }
30758 }
30759 }
30760 }
30761 };
30762 req.send(body_data);
30763 } catch (e) {
30764 lib.report_error(e);
30765 succeeded = false;
30766 }
30767 } else {
30768 var script = document$1.createElement('script');
30769 script.type = 'text/javascript';
30770 script.async = true;
30771 script.defer = true;
30772 script.src = url;
30773 var s = document$1.getElementsByTagName('script')[0];
30774 s.parentNode.insertBefore(script, s);
30775 }
30776
30777 return succeeded;
30778 };
30779
30780 /**
30781 * _execute_array() deals with processing any mixpanel function
30782 * calls that were called before the Mixpanel library were loaded
30783 * (and are thus stored in an array so they can be called later)
30784 *
30785 * Note: we fire off all the mixpanel function calls && user defined
30786 * functions BEFORE we fire off mixpanel tracking calls. This is so
30787 * identify/register/set_config calls can properly modify early
30788 * tracking calls.
30789 *
30790 * @param {Array} array
30791 */
30792 MixpanelLib.prototype._execute_array = function(array) {
30793 var fn_name, alias_calls = [], other_calls = [], tracking_calls = [];
30794 _.each(array, function(item) {
30795 if (item) {
30796 fn_name = item[0];
30797 if (_.isArray(fn_name)) {
30798 tracking_calls.push(item); // chained call e.g. mixpanel.get_group().set()
30799 } else if (typeof(item) === 'function') {
30800 item.call(this);
30801 } else if (_.isArray(item) && fn_name === 'alias') {
30802 alias_calls.push(item);
30803 } else if (_.isArray(item) && fn_name.indexOf('track') !== -1 && typeof(this[fn_name]) === 'function') {
30804 tracking_calls.push(item);
30805 } else {
30806 other_calls.push(item);
30807 }
30808 }
30809 }, this);
30810
30811 var execute = function(calls, context) {
30812 _.each(calls, function(item) {
30813 if (_.isArray(item[0])) {
30814 // chained call
30815 var caller = context;
30816 _.each(item, function(call) {
30817 caller = caller[call[0]].apply(caller, call.slice(1));
30818 });
30819 } else {
30820 this[item[0]].apply(this, item.slice(1));
30821 }
30822 }, context);
30823 };
30824
30825 execute(alias_calls, this);
30826 execute(other_calls, this);
30827 execute(tracking_calls, this);
30828 };
30829
30830 // request queueing utils
30831
30832 MixpanelLib.prototype.are_batchers_initialized = function() {
30833 return !!this.request_batchers.events;
30834 };
30835
30836 MixpanelLib.prototype.get_batcher_configs = function() {
30837 var queue_prefix = '__mpq_' + this.get_config('token');
30838 this._batcher_configs = this._batcher_configs || {
30839 events: {type: 'events', api_name: 'track', queue_key: queue_prefix + '_ev'},
30840 people: {type: 'people', api_name: 'engage', queue_key: queue_prefix + '_pp'},
30841 groups: {type: 'groups', api_name: 'groups', queue_key: queue_prefix + '_gr'}
30842 };
30843 return this._batcher_configs;
30844 };
30845
30846 MixpanelLib.prototype.init_batchers = function() {
30847 if (!this.are_batchers_initialized()) {
30848 var batcher_for = _.bind(function(attrs) {
30849 return new RequestBatcher(
30850 attrs.queue_key,
30851 {
30852 libConfig: this['config'],
30853 errorReporter: this.get_config('error_reporter'),
30854 sendRequestFunc: _.bind(function(data, options, cb) {
30855 var api_routes = this.get_config('api_routes');
30856 this._send_request(
30857 this.get_api_host(attrs.api_name) + '/' + api_routes[attrs.api_name],
30858 this._encode_data_for_request(data),
30859 options,
30860 this._prepare_callback(cb, data)
30861 );
30862 }, this),
30863 beforeSendHook: _.bind(function(item) {
30864 return this._run_hook('before_send_' + attrs.type, item);
30865 }, this),
30866 stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
30867 usePersistence: true,
30868 }
30869 );
30870 }, this);
30871 var batcher_configs = this.get_batcher_configs();
30872 this.request_batchers = {
30873 events: batcher_for(batcher_configs.events),
30874 people: batcher_for(batcher_configs.people),
30875 groups: batcher_for(batcher_configs.groups)
30876 };
30877 }
30878 if (this.get_config('batch_autostart')) {
30879 this.start_batch_senders();
30880 }
30881 };
30882
30883 MixpanelLib.prototype.start_batch_senders = function() {
30884 this._batchers_were_started = true;
30885 if (this.are_batchers_initialized()) {
30886 this._batch_requests = true;
30887 _.each(this.request_batchers, function(batcher) {
30888 batcher.start();
30889 });
30890 }
30891 };
30892
30893 MixpanelLib.prototype.stop_batch_senders = function() {
30894 this._batch_requests = false;
30895 _.each(this.request_batchers, function(batcher) {
30896 batcher.stop();
30897 batcher.clear();
30898 });
30899 };
30900
30901 /**
30902 * push() keeps the standard async-array-push
30903 * behavior around after the lib is loaded.
30904 * This is only useful for external integrations that
30905 * do not wish to rely on our convenience methods
30906 * (created in the snippet).
30907 *
30908 * ### Usage:
30909 * mixpanel.push(['register', { a: 'b' }]);
30910 *
30911 * @param {Array} item A [function_name, args...] array to be executed
30912 */
30913 MixpanelLib.prototype.push = function(item) {
30914 this._execute_array([item]);
30915 };
30916
30917 /**
30918 * Disable events on the Mixpanel object. If passed no arguments,
30919 * this function disables tracking of any event. If passed an
30920 * array of event names, those events will be disabled, but other
30921 * events will continue to be tracked.
30922 *
30923 * Note: this function does not stop other mixpanel functions from
30924 * firing, such as register() or people.set().
30925 *
30926 * @param {Array} [events] An array of event names to disable
30927 */
30928 MixpanelLib.prototype.disable = function(events) {
30929 if (typeof(events) === 'undefined') {
30930 this._flags.disable_all_events = true;
30931 } else {
30932 this.__disabled_events = this.__disabled_events.concat(events);
30933 }
30934 };
30935
30936 MixpanelLib.prototype._encode_data_for_request = function(data) {
30937 var encoded_data = JSONStringify(data);
30938 if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
30939 encoded_data = _.base64Encode(encoded_data);
30940 }
30941 return {'data': encoded_data};
30942 };
30943
30944 // internal method for handling track vs batch-enqueue logic
30945 MixpanelLib.prototype._track_or_batch = function(options, callback) {
30946 var truncated_data = _.truncate(options.data, 255);
30947 var endpoint = options.endpoint;
30948 var batcher = options.batcher;
30949 var should_send_immediately = options.should_send_immediately;
30950 var send_request_options = options.send_request_options || {};
30951 callback = callback || NOOP_FUNC;
30952
30953 var request_enqueued_or_initiated = true;
30954 var send_request_immediately = _.bind(function() {
30955 if (!send_request_options.skip_hooks) {
30956 truncated_data = this._run_hook('before_send_' + options.type, truncated_data);
30957 }
30958 if (truncated_data) {
30959 console$1.log('MIXPANEL REQUEST:');
30960 console$1.log(truncated_data);
30961 return this._send_request(
30962 endpoint,
30963 this._encode_data_for_request(truncated_data),
30964 send_request_options,
30965 this._prepare_callback(callback, truncated_data)
30966 );
30967 } else {
30968 return null;
30969 }
30970 }, this);
30971
30972 if (this._batch_requests && !should_send_immediately) {
30973 batcher.enqueue(truncated_data).then(function(succeeded) {
30974 if (succeeded) {
30975 callback(1, truncated_data);
30976 } else {
30977 send_request_immediately();
30978 }
30979 });
30980 } else {
30981 request_enqueued_or_initiated = send_request_immediately();
30982 }
30983
30984 return request_enqueued_or_initiated && truncated_data;
30985 };
30986
30987 /**
30988 * Track an event. This is the most important and
30989 * frequently used Mixpanel function.
30990 *
30991 * ### Usage:
30992 *
30993 * // track an event named 'Registered'
30994 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
30995 *
30996 * // track an event using navigator.sendBeacon
30997 * mixpanel.track('Left page', {'duration_seconds': 35}, {transport: 'sendBeacon'});
30998 *
30999 * To track link clicks or form submissions, see track_links() or track_forms().
31000 *
31001 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
31002 * @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.
31003 * @param {Object} [options] Optional configuration for this track request.
31004 * @param {String} [options.transport] Transport method for network request ('xhr' or 'sendBeacon').
31005 * @param {Boolean} [options.send_immediately] Whether to bypass batching/queueing and send track request immediately.
31006 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
31007 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
31008 * with the tracking payload sent to the API server is returned; otherwise false.
31009 */
31010 MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
31011 if (!callback && typeof options === 'function') {
31012 callback = options;
31013 options = null;
31014 }
31015 options = options || {};
31016 var transport = options['transport']; // external API, don't minify 'transport' prop
31017 if (transport) {
31018 options.transport = transport; // 'transport' prop name can be minified internally
31019 }
31020 var should_send_immediately = options['send_immediately'];
31021 if (typeof callback !== 'function') {
31022 callback = NOOP_FUNC;
31023 }
31024
31025 if (_.isUndefined(event_name)) {
31026 this.report_error('No event name provided to mixpanel.track');
31027 return;
31028 }
31029
31030 if (this._event_is_disabled(event_name)) {
31031 callback(0);
31032 return;
31033 }
31034
31035 // set defaults
31036 properties = _.extend({}, properties);
31037 properties['token'] = this.get_config('token');
31038
31039 // set $duration if time_event was previously called for this event
31040 var start_timestamp = this['persistence'].remove_event_timer(event_name);
31041 if (!_.isUndefined(start_timestamp)) {
31042 var duration_in_ms = new Date().getTime() - start_timestamp;
31043 properties['$duration'] = parseFloat((duration_in_ms / 1000).toFixed(3));
31044 }
31045
31046 this._set_default_superprops();
31047
31048 var marketing_properties = this.get_config('track_marketing')
31049 ? _.info.marketingParams()
31050 : {};
31051
31052 // note: extend writes to the first object, so lets make sure we
31053 // don't write to the persistence properties object and info
31054 // properties object by passing in a new object
31055
31056 // update properties with pageview info and super-properties
31057 properties = _.extend(
31058 {},
31059 _.info.properties({'mp_loader': this.get_config('mp_loader')}),
31060 marketing_properties,
31061 this['persistence'].properties(),
31062 this.unpersisted_superprops,
31063 this.get_session_recording_properties(),
31064 properties
31065 );
31066
31067 var property_blacklist = this.get_config('property_blacklist');
31068 if (_.isArray(property_blacklist)) {
31069 _.each(property_blacklist, function(blacklisted_prop) {
31070 delete properties[blacklisted_prop];
31071 });
31072 } else {
31073 this.report_error('Invalid value for property_blacklist config: ' + property_blacklist);
31074 }
31075
31076 var data = {
31077 'event': event_name,
31078 'properties': properties
31079 };
31080 var ret = this._track_or_batch({
31081 type: 'events',
31082 data: data,
31083 endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
31084 batcher: this.request_batchers.events,
31085 should_send_immediately: should_send_immediately,
31086 send_request_options: options
31087 }, callback);
31088
31089 return ret;
31090 });
31091
31092 /**
31093 * Register the current user into one/many groups.
31094 *
31095 * ### Usage:
31096 *
31097 * mixpanel.set_group('company', ['mixpanel', 'google']) // an array of IDs
31098 * mixpanel.set_group('company', 'mixpanel')
31099 * mixpanel.set_group('company', 128746312)
31100 *
31101 * @param {String} group_key Group key
31102 * @param {Array|String|Number} group_ids An array of group IDs, or a singular group ID
31103 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31104 *
31105 */
31106 MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key, group_ids, callback) {
31107 if (!_.isArray(group_ids)) {
31108 group_ids = [group_ids];
31109 }
31110 var prop = {};
31111 prop[group_key] = group_ids;
31112 this.register(prop);
31113 return this['people'].set(group_key, group_ids, callback);
31114 });
31115
31116 /**
31117 * Add a new group for this user.
31118 *
31119 * ### Usage:
31120 *
31121 * mixpanel.add_group('company', 'mixpanel')
31122 *
31123 * @param {String} group_key Group key
31124 * @param {*} group_id A valid Mixpanel property type
31125 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31126 */
31127 MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
31128 var old_values = this.get_property(group_key);
31129 var prop = {};
31130 if (old_values === undefined) {
31131 prop[group_key] = [group_id];
31132 this.register(prop);
31133 } else {
31134 if (old_values.indexOf(group_id) === -1) {
31135 old_values.push(group_id);
31136 prop[group_key] = old_values;
31137 this.register(prop);
31138 }
31139 }
31140 return this['people'].union(group_key, group_id, callback);
31141 });
31142
31143 /**
31144 * Remove a group from this user.
31145 *
31146 * ### Usage:
31147 *
31148 * mixpanel.remove_group('company', 'mixpanel')
31149 *
31150 * @param {String} group_key Group key
31151 * @param {*} group_id A valid Mixpanel property type
31152 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31153 */
31154 MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
31155 var old_value = this.get_property(group_key);
31156 // if the value doesn't exist, the persistent store is unchanged
31157 if (old_value !== undefined) {
31158 var idx = old_value.indexOf(group_id);
31159 if (idx > -1) {
31160 old_value.splice(idx, 1);
31161 this.register({group_key: old_value});
31162 }
31163 if (old_value.length === 0) {
31164 this.unregister(group_key);
31165 }
31166 }
31167 return this['people'].remove(group_key, group_id, callback);
31168 });
31169
31170 /**
31171 * Track an event with specific groups.
31172 *
31173 * ### Usage:
31174 *
31175 * mixpanel.track_with_groups('purchase', {'product': 'iphone'}, {'University': ['UCB', 'UCLA']})
31176 *
31177 * @param {String} event_name The name of the event (see `mixpanel.track()`)
31178 * @param {Object=} properties A set of properties to include with the event you're sending (see `mixpanel.track()`)
31179 * @param {Object=} groups An object mapping group name keys to one or more values
31180 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31181 */
31182 MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(event_name, properties, groups, callback) {
31183 var tracking_props = _.extend({}, properties || {});
31184 _.each(groups, function(v, k) {
31185 if (v !== null && v !== undefined) {
31186 tracking_props[k] = v;
31187 }
31188 });
31189 return this.track(event_name, tracking_props, callback);
31190 });
31191
31192 MixpanelLib.prototype._create_map_key = function (group_key, group_id) {
31193 return group_key + '_' + JSON.stringify(group_id);
31194 };
31195
31196 MixpanelLib.prototype._remove_group_from_cache = function (group_key, group_id) {
31197 delete this._cached_groups[this._create_map_key(group_key, group_id)];
31198 };
31199
31200 /**
31201 * Look up reference to a Mixpanel group
31202 *
31203 * ### Usage:
31204 *
31205 * mixpanel.get_group(group_key, group_id)
31206 *
31207 * @param {String} group_key Group key
31208 * @param {Object} group_id A valid Mixpanel property type
31209 * @returns {Object} A MixpanelGroup identifier
31210 */
31211 MixpanelLib.prototype.get_group = function (group_key, group_id) {
31212 var map_key = this._create_map_key(group_key, group_id);
31213 var group = this._cached_groups[map_key];
31214 if (group === undefined || group._group_key !== group_key || group._group_id !== group_id) {
31215 group = new MixpanelGroup();
31216 group._init(this, group_key, group_id);
31217 this._cached_groups[map_key] = group;
31218 }
31219 return group;
31220 };
31221
31222 /**
31223 * Track a default Mixpanel page view event, which includes extra default event properties to
31224 * improve page view data.
31225 *
31226 * ### Usage:
31227 *
31228 * // track a default $mp_web_page_view event
31229 * mixpanel.track_pageview();
31230 *
31231 * // track a page view event with additional event properties
31232 * mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
31233 *
31234 * // example approach to track page views on different page types as event properties
31235 * mixpanel.track_pageview({'page': 'pricing'});
31236 * mixpanel.track_pageview({'page': 'homepage'});
31237 *
31238 * // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
31239 * // individual pages on the same site or product. Use cases for custom event_name may be page
31240 * // views on different products or internal applications that are considered completely separate
31241 * mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
31242 *
31243 * ### Notes:
31244 *
31245 * The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
31246 * may be turned on for tracking page loads automatically.
31247 *
31248 * // track only page loads
31249 * mixpanel.init(PROJECT_TOKEN, {track_pageview: true});
31250 *
31251 * // track when the URL changes in any manner
31252 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'full-url'});
31253 *
31254 * // track when the URL changes, ignoring any changes in the hash part
31255 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path-and-query-string'});
31256 *
31257 * // track when the path changes, ignoring any query parameter or hash changes
31258 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path'});
31259 *
31260 * @param {Object} [properties] An optional set of additional properties to send with the page view event
31261 * @param {Object} [options] Page view tracking options
31262 * @param {String} [options.event_name] - Alternate name for the tracking event
31263 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
31264 * with the tracking payload sent to the API server is returned; otherwise false.
31265 */
31266 MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
31267 if (typeof properties !== 'object') {
31268 properties = {};
31269 }
31270 options = options || {};
31271 var event_name = options['event_name'] || '$mp_web_page_view';
31272
31273 var default_page_properties = _.extend(
31274 _.info.mpPageViewProperties(),
31275 _.info.campaignParams(),
31276 _.info.clickParams()
31277 );
31278
31279 var event_properties = _.extend(
31280 {},
31281 default_page_properties,
31282 properties
31283 );
31284
31285 return this.track(event_name, event_properties);
31286 });
31287
31288 /**
31289 * Track clicks on a set of document elements. Selector must be a
31290 * valid query. Elements must exist on the page at the time track_links is called.
31291 *
31292 * ### Usage:
31293 *
31294 * // track click for link id #nav
31295 * mixpanel.track_links('#nav', 'Clicked Nav Link');
31296 *
31297 * ### Notes:
31298 *
31299 * This function will wait up to 300 ms for the Mixpanel
31300 * servers to respond. If they have not responded by that time
31301 * it will head to the link without ensuring that your event
31302 * has been tracked. To configure this timeout please see the
31303 * set_config() documentation below.
31304 *
31305 * If you pass a function in as the properties argument, the
31306 * function will receive the DOMElement that triggered the
31307 * event as an argument. You are expected to return an object
31308 * from the function; any properties defined on this object
31309 * will be sent to mixpanel as event properties.
31310 *
31311 * @type {Function}
31312 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
31313 * @param {String} event_name The name of the event to track
31314 * @param {Object|Function} [properties] A properties object or function that returns a dictionary of properties when passed a DOMElement
31315 */
31316 MixpanelLib.prototype.track_links = function() {
31317 return this._track_dom.call(this, LinkTracker, arguments);
31318 };
31319
31320 /**
31321 * Track form submissions. Selector must be a valid query.
31322 *
31323 * ### Usage:
31324 *
31325 * // track submission for form id 'register'
31326 * mixpanel.track_forms('#register', 'Created Account');
31327 *
31328 * ### Notes:
31329 *
31330 * This function will wait up to 300 ms for the mixpanel
31331 * servers to respond, if they have not responded by that time
31332 * it will head to the link without ensuring that your event
31333 * has been tracked. To configure this timeout please see the
31334 * set_config() documentation below.
31335 *
31336 * If you pass a function in as the properties argument, the
31337 * function will receive the DOMElement that triggered the
31338 * event as an argument. You are expected to return an object
31339 * from the function; any properties defined on this object
31340 * will be sent to mixpanel as event properties.
31341 *
31342 * @type {Function}
31343 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
31344 * @param {String} event_name The name of the event to track
31345 * @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
31346 */
31347 MixpanelLib.prototype.track_forms = function() {
31348 return this._track_dom.call(this, FormTracker, arguments);
31349 };
31350
31351 /**
31352 * Time an event by including the time between this call and a
31353 * later 'track' call for the same event in the properties sent
31354 * with the event.
31355 *
31356 * ### Usage:
31357 *
31358 * // time an event named 'Registered'
31359 * mixpanel.time_event('Registered');
31360 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
31361 *
31362 * When called for a particular event name, the next track call for that event
31363 * name will include the elapsed time between the 'time_event' and 'track'
31364 * calls. This value is stored as seconds in the '$duration' property.
31365 *
31366 * @param {String} event_name The name of the event.
31367 */
31368 MixpanelLib.prototype.time_event = function(event_name) {
31369 if (_.isUndefined(event_name)) {
31370 this.report_error('No event name provided to mixpanel.time_event');
31371 return;
31372 }
31373
31374 if (this._event_is_disabled(event_name)) {
31375 return;
31376 }
31377
31378 this['persistence'].set_event_timer(event_name, new Date().getTime());
31379 };
31380
31381 var REGISTER_DEFAULTS = {
31382 'persistent': true
31383 };
31384 /**
31385 * Helper to parse options param for register methods, maintaining
31386 * legacy support for plain "days" param instead of options object
31387 * @param {Number|Object} [days_or_options] 'days' option (Number), or Options object for register methods
31388 * @returns {Object} options object
31389 */
31390 var options_for_register = function(days_or_options) {
31391 var options;
31392 if (_.isObject(days_or_options)) {
31393 options = days_or_options;
31394 } else if (!_.isUndefined(days_or_options)) {
31395 options = {'days': days_or_options};
31396 } else {
31397 options = {};
31398 }
31399 return _.extend({}, REGISTER_DEFAULTS, options);
31400 };
31401
31402 /**
31403 * Register a set of super properties, which are included with all
31404 * events. This will overwrite previous super property values.
31405 *
31406 * ### Usage:
31407 *
31408 * // register 'Gender' as a super property
31409 * mixpanel.register({'Gender': 'Female'});
31410 *
31411 * // register several super properties when a user signs up
31412 * mixpanel.register({
31413 * 'Email': 'jdoe@example.com',
31414 * 'Account Type': 'Free'
31415 * });
31416 *
31417 * // register only for the current pageload
31418 * mixpanel.register({'Name': 'Pat'}, {persistent: false});
31419 *
31420 * @param {Object} properties An associative array of properties to store about the user
31421 * @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)
31422 * @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)
31423 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
31424 */
31425 MixpanelLib.prototype.register = function(props, days_or_options) {
31426 var options = options_for_register(days_or_options);
31427 if (options['persistent']) {
31428 this['persistence'].register(props, options['days']);
31429 } else {
31430 _.extend(this.unpersisted_superprops, props);
31431 }
31432 };
31433
31434 /**
31435 * Register a set of super properties only once. This will not
31436 * overwrite previous super property values, unlike register().
31437 *
31438 * ### Usage:
31439 *
31440 * // register a super property for the first time only
31441 * mixpanel.register_once({
31442 * 'First Login Date': new Date().toISOString()
31443 * });
31444 *
31445 * // register once, only for the current pageload
31446 * mixpanel.register_once({
31447 * 'First interaction time': new Date().toISOString()
31448 * }, 'None', {persistent: false});
31449 *
31450 * ### Notes:
31451 *
31452 * If default_value is specified, current super properties
31453 * with that value will be overwritten.
31454 *
31455 * @param {Object} properties An associative array of properties to store about the user
31456 * @param {*} [default_value] Value to override if already set in super properties (ex: 'False') Default: 'None'
31457 * @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)
31458 * @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)
31459 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
31460 */
31461 MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
31462 var options = options_for_register(days_or_options);
31463 if (options['persistent']) {
31464 this['persistence'].register_once(props, default_value, options['days']);
31465 } else {
31466 if (typeof(default_value) === 'undefined') {
31467 default_value = 'None';
31468 }
31469 _.each(props, function(val, prop) {
31470 if (!this.unpersisted_superprops.hasOwnProperty(prop) || this.unpersisted_superprops[prop] === default_value) {
31471 this.unpersisted_superprops[prop] = val;
31472 }
31473 }, this);
31474 }
31475 };
31476
31477 /**
31478 * Delete a super property stored with the current user.
31479 *
31480 * @param {String} property The name of the super property to remove
31481 * @param {Object} [options]
31482 * @param {boolean} [options.persistent=true] - whether to look in persistent storage (cookie/localStorage)
31483 */
31484 MixpanelLib.prototype.unregister = function(property, options) {
31485 options = options_for_register(options);
31486 if (options['persistent']) {
31487 this['persistence'].unregister(property);
31488 } else {
31489 delete this.unpersisted_superprops[property];
31490 }
31491 };
31492
31493 MixpanelLib.prototype._register_single = function(prop, value) {
31494 var props = {};
31495 props[prop] = value;
31496 this.register(props);
31497 };
31498
31499 /**
31500 * Identify a user with a unique ID to track user activity across
31501 * devices, tie a user to their events, and create a user profile.
31502 * If you never call this method, unique visitors are tracked using
31503 * a UUID generated the first time they visit the site.
31504 *
31505 * Call identify when you know the identity of the current user,
31506 * typically after login or signup. We recommend against using
31507 * identify for anonymous visitors to your site.
31508 *
31509 * ### Notes:
31510 * If your project has
31511 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31512 * enabled, the identify method will connect pre- and
31513 * post-authentication events when appropriate.
31514 *
31515 * If your project does not have ID Merge enabled, identify will
31516 * change the user's local distinct_id to the unique ID you pass.
31517 * Events tracked prior to authentication will not be connected
31518 * to the same user identity. If ID Merge is disabled, alias can
31519 * be used to connect pre- and post-registration events.
31520 *
31521 * @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.
31522 */
31523 MixpanelLib.prototype.identify = function(
31524 new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
31525 ) {
31526 // Optional Parameters
31527 // _set_callback:function A callback to be run if and when the People set queue is flushed
31528 // _add_callback:function A callback to be run if and when the People add queue is flushed
31529 // _append_callback:function A callback to be run if and when the People append queue is flushed
31530 // _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
31531 // _union_callback:function A callback to be run if and when the People union queue is flushed
31532 // _unset_callback:function A callback to be run if and when the People unset queue is flushed
31533
31534 var previous_distinct_id = this.get_distinct_id();
31535 if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
31536 // we allow the following condition if previous distinct_id is same as new_distinct_id
31537 // so that you can force flush people updates for anonymous profiles.
31538 if (typeof new_distinct_id === 'string' && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
31539 this.report_error('distinct_id cannot have $device: prefix');
31540 return -1;
31541 }
31542 this.register({'$user_id': new_distinct_id});
31543 }
31544
31545 if (!this.get_property('$device_id')) {
31546 // The persisted distinct id might not actually be a device id at all
31547 // it might be a distinct id of the user from before
31548 var device_id = previous_distinct_id;
31549 this.register_once({
31550 '$had_persisted_distinct_id': true,
31551 '$device_id': device_id
31552 }, '');
31553 }
31554
31555 // identify only changes the distinct id if it doesn't match either the existing or the alias;
31556 // if it's new, blow away the alias as well.
31557 if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
31558 this.unregister(ALIAS_ID_KEY);
31559 this.register({'distinct_id': new_distinct_id});
31560 }
31561 this._flags.identify_called = true;
31562 // Flush any queued up people requests
31563 this['people']._flush(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback);
31564
31565 // send an $identify event any time the distinct_id is changing - logic on the server
31566 // will determine whether or not to do anything with it.
31567 if (new_distinct_id !== previous_distinct_id) {
31568 this.track('$identify', {
31569 'distinct_id': new_distinct_id,
31570 '$anon_distinct_id': previous_distinct_id
31571 }, {skip_hooks: true});
31572 }
31573
31574 // check feature flags again if distinct id has changed
31575 if (new_distinct_id !== previous_distinct_id) {
31576 this.flags.fetchFlags();
31577 }
31578 };
31579
31580 /**
31581 * Clears super properties and generates a new random distinct_id for this instance.
31582 * Useful for clearing data when a user logs out.
31583 */
31584 MixpanelLib.prototype.reset = function() {
31585 this.stop_session_recording();
31586 this['persistence'].clear();
31587 this._flags.identify_called = false;
31588 var uuid = _.UUID();
31589 this.register_once({
31590 'distinct_id': DEVICE_ID_PREFIX + uuid,
31591 '$device_id': uuid
31592 }, '');
31593 this._check_and_start_session_recording();
31594 };
31595
31596 /**
31597 * Returns the current distinct id of the user. This is either the id automatically
31598 * generated by the library or the id that has been passed by a call to identify().
31599 *
31600 * ### Notes:
31601 *
31602 * get_distinct_id() can only be called after the Mixpanel library has finished loading.
31603 * init() has a loaded function available to handle this automatically. For example:
31604 *
31605 * // set distinct_id after the mixpanel library has loaded
31606 * mixpanel.init('YOUR PROJECT TOKEN', {
31607 * loaded: function(mixpanel) {
31608 * distinct_id = mixpanel.get_distinct_id();
31609 * }
31610 * });
31611 */
31612 MixpanelLib.prototype.get_distinct_id = function() {
31613 return this.get_property('distinct_id');
31614 };
31615
31616 /**
31617 * The alias method creates an alias which Mixpanel will use to
31618 * remap one id to another. Multiple aliases can point to the
31619 * same identifier.
31620 *
31621 * The following is a valid use of alias:
31622 *
31623 * mixpanel.alias('new_id', 'existing_id');
31624 * // You can add multiple id aliases to the existing ID
31625 * mixpanel.alias('newer_id', 'existing_id');
31626 *
31627 * Aliases can also be chained - the following is a valid example:
31628 *
31629 * mixpanel.alias('new_id', 'existing_id');
31630 * // chain newer_id - new_id - existing_id
31631 * mixpanel.alias('newer_id', 'new_id');
31632 *
31633 * Aliases cannot point to multiple identifiers - the following
31634 * example will not work:
31635 *
31636 * mixpanel.alias('new_id', 'existing_id');
31637 * // this is invalid as 'new_id' already points to 'existing_id'
31638 * mixpanel.alias('new_id', 'newer_id');
31639 *
31640 * ### Notes:
31641 *
31642 * If your project does not have
31643 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31644 * enabled, the best practice is to call alias once when a unique
31645 * ID is first created for a user (e.g., when a user first registers
31646 * for an account). Do not use alias multiple times for a single
31647 * user without ID Merge enabled.
31648 *
31649 * @param {String} alias A unique identifier that you want to use for this user in the future.
31650 * @param {String} [original] The current identifier being used for this user.
31651 */
31652 MixpanelLib.prototype.alias = function(alias, original) {
31653 // If the $people_distinct_id key exists in persistence, there has been a previous
31654 // mixpanel.people.identify() call made for this user. It is VERY BAD to make an alias with
31655 // this ID, as it will duplicate users.
31656 if (alias === this.get_property(PEOPLE_DISTINCT_ID_KEY)) {
31657 this.report_error('Attempting to create alias for existing People user - aborting.');
31658 return -2;
31659 }
31660
31661 var _this = this;
31662 if (_.isUndefined(original)) {
31663 original = this.get_distinct_id();
31664 }
31665 if (alias !== original) {
31666 this._register_single(ALIAS_ID_KEY, alias);
31667 return this.track('$create_alias', {
31668 'alias': alias,
31669 'distinct_id': original
31670 }, {
31671 skip_hooks: true
31672 }, function() {
31673 // Flush the people queue
31674 _this.identify(alias);
31675 });
31676 } else {
31677 this.report_error('alias matches current distinct_id - skipping api call.');
31678 this.identify(alias);
31679 return -1;
31680 }
31681 };
31682
31683 /**
31684 * Provide a string to recognize the user by. The string passed to
31685 * this method will appear in the Mixpanel Streams product rather
31686 * than an automatically generated name. Name tags do not have to
31687 * be unique.
31688 *
31689 * This value will only be included in Streams data.
31690 *
31691 * @param {String} name_tag A human readable name for the user
31692 * @deprecated
31693 */
31694 MixpanelLib.prototype.name_tag = function(name_tag) {
31695 this._register_single('mp_name_tag', name_tag);
31696 };
31697
31698 /**
31699 * Update the configuration of a mixpanel library instance.
31700 *
31701 * The default config is:
31702 *
31703 * {
31704 * // host for requests (customizable for e.g. a local proxy)
31705 * api_host: 'https://api-js.mixpanel.com',
31706 *
31707 * // endpoints for different types of requests
31708 * api_routes: {
31709 * track: 'track/',
31710 * engage: 'engage/',
31711 * groups: 'groups/',
31712 * }
31713 *
31714 * // HTTP method for tracking requests
31715 * api_method: 'POST'
31716 *
31717 * // transport for sending requests ('XHR' or 'sendBeacon')
31718 * // NB: sendBeacon should only be used for scenarios such as
31719 * // page unload where a "best-effort" attempt to send is
31720 * // acceptable; the sendBeacon API does not support callbacks
31721 * // or any way to know the result of the request. Mixpanel
31722 * // tracking via sendBeacon will not support any event-
31723 * // batching or retry mechanisms.
31724 * api_transport: 'XHR'
31725 *
31726 * // request-batching/queueing/retry
31727 * batch_requests: true,
31728 *
31729 * // maximum number of events/updates to send in a single
31730 * // network request
31731 * batch_size: 50,
31732 *
31733 * // milliseconds to wait between sending batch requests
31734 * batch_flush_interval_ms: 5000,
31735 *
31736 * // milliseconds to wait for network responses to batch requests
31737 * // before they are considered timed-out and retried
31738 * batch_request_timeout_ms: 90000,
31739 *
31740 * // override value for cookie domain, only useful for ensuring
31741 * // correct cross-subdomain cookies on unusual domains like
31742 * // subdomain.mainsite.avocat.fr; NB this cannot be used to
31743 * // set cookies on a different domain than the current origin
31744 * cookie_domain: ''
31745 *
31746 * // super properties cookie expiration (in days)
31747 * cookie_expiration: 365
31748 *
31749 * // if true, cookie will be set with SameSite=None; Secure
31750 * // this is only useful in special situations, like embedded
31751 * // 3rd-party iframes that set up a Mixpanel instance
31752 * cross_site_cookie: false
31753 *
31754 * // super properties span subdomains
31755 * cross_subdomain_cookie: true
31756 *
31757 * // debug mode
31758 * debug: false
31759 *
31760 * // if this is true, the mixpanel cookie or localStorage entry
31761 * // will be deleted, and no user persistence will take place
31762 * disable_persistence: false
31763 *
31764 * // if this is true, Mixpanel will automatically determine
31765 * // City, Region and Country data using the IP address of
31766 * //the client
31767 * ip: true
31768 *
31769 * // opt users out of tracking by this Mixpanel instance by default
31770 * opt_out_tracking_by_default: false
31771 *
31772 * // opt users out of browser data storage by this Mixpanel instance by default
31773 * opt_out_persistence_by_default: false
31774 *
31775 * // persistence mechanism used by opt-in/opt-out methods - cookie
31776 * // or localStorage - falls back to cookie if localStorage is unavailable
31777 * opt_out_tracking_persistence_type: 'localStorage'
31778 *
31779 * // customize the name of cookie/localStorage set by opt-in/opt-out methods
31780 * opt_out_tracking_cookie_prefix: null
31781 *
31782 * // type of persistent store for super properties (cookie/
31783 * // localStorage) if set to 'localStorage', any existing
31784 * // mixpanel cookie value with the same persistence_name
31785 * // will be transferred to localStorage and deleted
31786 * persistence: 'cookie'
31787 *
31788 * // name for super properties persistent store
31789 * persistence_name: ''
31790 *
31791 * // names of properties/superproperties which should never
31792 * // be sent with track() calls
31793 * property_blacklist: []
31794 *
31795 * // if this is true, mixpanel cookies will be marked as
31796 * // secure, meaning they will only be transmitted over https
31797 * secure_cookie: false
31798 *
31799 * // disables enriching user profiles with first touch marketing data
31800 * skip_first_touch_marketing: false
31801 *
31802 * // the amount of time track_links will
31803 * // wait for Mixpanel's servers to respond
31804 * track_links_timeout: 300
31805 *
31806 * // adds any UTM parameters and click IDs present on the page to any events fired
31807 * track_marketing: true
31808 *
31809 * // enables automatic page view tracking using default page view events through
31810 * // the track_pageview() method
31811 * track_pageview: false
31812 *
31813 * // if you set upgrade to be true, the library will check for
31814 * // a cookie from our old js library and import super
31815 * // properties from it, then the old cookie is deleted
31816 * // The upgrade config option only works in the initialization,
31817 * // so make sure you set it when you create the library.
31818 * upgrade: false
31819 *
31820 * // extra HTTP request headers to set for each API request, in
31821 * // the format {'Header-Name': value}
31822 * xhr_headers: {}
31823 *
31824 * // whether to ignore or respect the web browser's Do Not Track setting
31825 * ignore_dnt: false
31826 * }
31827 *
31828 *
31829 * @param {Object} config A dictionary of new configuration values to update
31830 */
31831 MixpanelLib.prototype.set_config = function(config) {
31832 if (_.isObject(config)) {
31833 _.extend(this['config'], config);
31834
31835 var new_batch_size = config['batch_size'];
31836 if (new_batch_size) {
31837 _.each(this.request_batchers, function(batcher) {
31838 batcher.resetBatchSize();
31839 });
31840 }
31841
31842 if (!this.get_config('persistence_name')) {
31843 this['config']['persistence_name'] = this['config']['cookie_name'];
31844 }
31845 if (!this.get_config('disable_persistence')) {
31846 this['config']['disable_persistence'] = this['config']['disable_cookie'];
31847 }
31848
31849 if (this['persistence']) {
31850 this['persistence'].update_config(this['config']);
31851 }
31852 Config.DEBUG = Config.DEBUG || this.get_config('debug');
31853
31854 if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
31855 this.autocapture.init();
31856 }
31857 }
31858 };
31859
31860 /**
31861 * returns the current config object for the library.
31862 */
31863 MixpanelLib.prototype.get_config = function(prop_name) {
31864 return this['config'][prop_name];
31865 };
31866
31867 /**
31868 * Fetch a hook function from config, with safe default, and run it
31869 * against the given arguments
31870 * @param {string} hook_name which hook to retrieve
31871 * @returns {any|null} return value of user-provided hook, or null if nothing was returned
31872 */
31873 MixpanelLib.prototype._run_hook = function(hook_name) {
31874 var ret = (this['config']['hooks'][hook_name] || IDENTITY_FUNC).apply(this, slice.call(arguments, 1));
31875 if (typeof ret === 'undefined') {
31876 this.report_error(hook_name + ' hook did not return a value');
31877 ret = null;
31878 }
31879 return ret;
31880 };
31881
31882 /**
31883 * Returns the value of the super property named property_name. If no such
31884 * property is set, get_property() will return the undefined value.
31885 *
31886 * ### Notes:
31887 *
31888 * get_property() can only be called after the Mixpanel library has finished loading.
31889 * init() has a loaded function available to handle this automatically. For example:
31890 *
31891 * // grab value for 'user_id' after the mixpanel library has loaded
31892 * mixpanel.init('YOUR PROJECT TOKEN', {
31893 * loaded: function(mixpanel) {
31894 * user_id = mixpanel.get_property('user_id');
31895 * }
31896 * });
31897 *
31898 * @param {String} property_name The name of the super property you want to retrieve
31899 */
31900 MixpanelLib.prototype.get_property = function(property_name) {
31901 return this['persistence'].load_prop([property_name]);
31902 };
31903
31904 /**
31905 * Get the API host for a specific endpoint type, falling back to the default api_host if not specified
31906 *
31907 * @param {String} endpoint_type The type of endpoint (e.g., "events", "people", "groups")
31908 * @returns {String} The API host to use for this endpoint
31909 */
31910 MixpanelLib.prototype.get_api_host = function(endpoint_type) {
31911 return this.get_config('api_hosts')[endpoint_type] || this.get_config('api_host');
31912 };
31913
31914 MixpanelLib.prototype.toString = function() {
31915 var name = this.get_config('name');
31916 if (name !== PRIMARY_INSTANCE_NAME) {
31917 name = PRIMARY_INSTANCE_NAME + '.' + name;
31918 }
31919 return name;
31920 };
31921
31922 MixpanelLib.prototype._event_is_disabled = function(event_name) {
31923 return _.isBlockedUA(userAgent) ||
31924 this._flags.disable_all_events ||
31925 _.include(this.__disabled_events, event_name);
31926 };
31927
31928 // perform some housekeeping around GDPR opt-in/out state
31929 MixpanelLib.prototype._gdpr_init = function() {
31930 var is_localStorage_requested = this.get_config('opt_out_tracking_persistence_type') === 'localStorage';
31931
31932 // try to convert opt-in/out cookies to localStorage if possible
31933 if (is_localStorage_requested && _.localStorage.is_supported()) {
31934 if (!this.has_opted_in_tracking() && this.has_opted_in_tracking({'persistence_type': 'cookie'})) {
31935 this.opt_in_tracking({'enable_persistence': false});
31936 }
31937 if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({'persistence_type': 'cookie'})) {
31938 this.opt_out_tracking({'clear_persistence': false});
31939 }
31940 this.clear_opt_in_out_tracking({
31941 'persistence_type': 'cookie',
31942 'enable_persistence': false
31943 });
31944 }
31945
31946 // check whether the user has already opted out - if so, clear & disable persistence
31947 if (this.has_opted_out_tracking()) {
31948 this._gdpr_update_persistence({'clear_persistence': true});
31949
31950 // check whether we should opt out by default
31951 // note: we don't clear persistence here by default since opt-out default state is often
31952 // used as an initial state while GDPR information is being collected
31953 } else if (!this.has_opted_in_tracking() && (
31954 this.get_config('opt_out_tracking_by_default') || _.cookie.get('mp_optout')
31955 )) {
31956 _.cookie.remove('mp_optout');
31957 this.opt_out_tracking({
31958 'clear_persistence': this.get_config('opt_out_persistence_by_default')
31959 });
31960 }
31961 };
31962
31963 /**
31964 * Enable or disable persistence based on options
31965 * only enable/disable if persistence is not already in this state
31966 * @param {boolean} [options.clear_persistence] If true, will delete all data stored by the sdk in persistence and disable it
31967 * @param {boolean} [options.enable_persistence] If true, will re-enable sdk persistence
31968 */
31969 MixpanelLib.prototype._gdpr_update_persistence = function(options) {
31970 var disabled;
31971 if (options && options['clear_persistence']) {
31972 disabled = true;
31973 } else if (options && options['enable_persistence']) {
31974 disabled = false;
31975 } else {
31976 return;
31977 }
31978
31979 if (!this.get_config('disable_persistence') && this['persistence'].disabled !== disabled) {
31980 this['persistence'].set_disabled(disabled);
31981 }
31982
31983 if (disabled) {
31984 this.stop_batch_senders();
31985 this.stop_session_recording();
31986 } else {
31987 // only start batchers after opt-in if they have previously been started
31988 // in order to avoid unintentionally starting up batching for the first time
31989 if (this._batchers_were_started) {
31990 this.start_batch_senders();
31991 }
31992 }
31993 };
31994
31995 // call a base gdpr function after constructing the appropriate token and options args
31996 MixpanelLib.prototype._gdpr_call_func = function(func, options) {
31997 options = _.extend({
31998 'track': _.bind(this.track, this),
31999 'persistence_type': this.get_config('opt_out_tracking_persistence_type'),
32000 'cookie_prefix': this.get_config('opt_out_tracking_cookie_prefix'),
32001 'cookie_expiration': this.get_config('cookie_expiration'),
32002 'cross_site_cookie': this.get_config('cross_site_cookie'),
32003 'cross_subdomain_cookie': this.get_config('cross_subdomain_cookie'),
32004 'cookie_domain': this.get_config('cookie_domain'),
32005 'secure_cookie': this.get_config('secure_cookie'),
32006 'ignore_dnt': this.get_config('ignore_dnt')
32007 }, options);
32008
32009 // check if localStorage can be used for recording opt out status, fall back to cookie if not
32010 if (!_.localStorage.is_supported()) {
32011 options['persistence_type'] = 'cookie';
32012 }
32013
32014 return func(this.get_config('token'), {
32015 track: options['track'],
32016 trackEventName: options['track_event_name'],
32017 trackProperties: options['track_properties'],
32018 persistenceType: options['persistence_type'],
32019 persistencePrefix: options['cookie_prefix'],
32020 cookieDomain: options['cookie_domain'],
32021 cookieExpiration: options['cookie_expiration'],
32022 crossSiteCookie: options['cross_site_cookie'],
32023 crossSubdomainCookie: options['cross_subdomain_cookie'],
32024 secureCookie: options['secure_cookie'],
32025 ignoreDnt: options['ignore_dnt']
32026 });
32027 };
32028
32029 /**
32030 * Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
32031 *
32032 * ### Usage:
32033 *
32034 * // opt user in
32035 * mixpanel.opt_in_tracking();
32036 *
32037 * // opt user in with specific event name, properties, cookie configuration
32038 * mixpanel.opt_in_tracking({
32039 * track_event_name: 'User opted in',
32040 * track_event_properties: {
32041 * 'Email': 'jdoe@example.com'
32042 * },
32043 * cookie_expiration: 30,
32044 * secure_cookie: true
32045 * });
32046 *
32047 * @param {Object} [options] A dictionary of config options to override
32048 * @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)
32049 * @param {string} [options.track_event_name=$opt_in] Event name to be used for tracking the opt-in action
32050 * @param {Object} [options.track_properties] Set of properties to be tracked along with the opt-in action
32051 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
32052 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32053 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32054 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32055 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32056 * @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)
32057 * @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)
32058 * @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)
32059 */
32060 MixpanelLib.prototype.opt_in_tracking = function(options) {
32061 options = _.extend({
32062 'enable_persistence': true
32063 }, options);
32064
32065 this._gdpr_call_func(optIn, options);
32066 this._gdpr_update_persistence(options);
32067 };
32068
32069 /**
32070 * Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
32071 *
32072 * ### Usage:
32073 *
32074 * // opt user out
32075 * mixpanel.opt_out_tracking();
32076 *
32077 * // opt user out with different cookie configuration from Mixpanel instance
32078 * mixpanel.opt_out_tracking({
32079 * cookie_expiration: 30,
32080 * secure_cookie: true
32081 * });
32082 *
32083 * @param {Object} [options] A dictionary of config options to override
32084 * @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
32085 * @param {boolean} [options.clear_persistence=true] If true, will delete all data stored by the sdk in persistence
32086 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32087 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32088 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32089 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32090 * @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)
32091 * @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)
32092 * @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)
32093 */
32094 MixpanelLib.prototype.opt_out_tracking = function(options) {
32095 options = _.extend({
32096 'clear_persistence': true,
32097 'delete_user': true
32098 }, options);
32099
32100 // delete user and clear charges since these methods may be disabled by opt-out
32101 if (options['delete_user'] && this['people'] && this['people']._identify_called()) {
32102 this['people'].delete_user();
32103 this['people'].clear_charges();
32104 }
32105
32106 this._gdpr_call_func(optOut, options);
32107 this._gdpr_update_persistence(options);
32108 };
32109
32110 /**
32111 * Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
32112 *
32113 * ### Usage:
32114 *
32115 * var has_opted_in = mixpanel.has_opted_in_tracking();
32116 * // use has_opted_in value
32117 *
32118 * @param {Object} [options] A dictionary of config options to override
32119 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32120 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32121 * @returns {boolean} current opt-in status
32122 */
32123 MixpanelLib.prototype.has_opted_in_tracking = function(options) {
32124 return this._gdpr_call_func(hasOptedIn, options);
32125 };
32126
32127 /**
32128 * Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
32129 *
32130 * ### Usage:
32131 *
32132 * var has_opted_out = mixpanel.has_opted_out_tracking();
32133 * // use has_opted_out value
32134 *
32135 * @param {Object} [options] A dictionary of config options to override
32136 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32137 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32138 * @returns {boolean} current opt-out status
32139 */
32140 MixpanelLib.prototype.has_opted_out_tracking = function(options) {
32141 return this._gdpr_call_func(hasOptedOut, options);
32142 };
32143
32144 /**
32145 * Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
32146 *
32147 * ### Usage:
32148 *
32149 * // clear user's opt-in/out status
32150 * mixpanel.clear_opt_in_out_tracking();
32151 *
32152 * // clear user's opt-in/out status with specific cookie configuration - should match
32153 * // configuration used when opt_in_tracking/opt_out_tracking methods were called.
32154 * mixpanel.clear_opt_in_out_tracking({
32155 * cookie_expiration: 30,
32156 * secure_cookie: true
32157 * });
32158 *
32159 * @param {Object} [options] A dictionary of config options to override
32160 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
32161 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32162 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32163 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32164 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32165 * @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)
32166 * @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)
32167 * @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)
32168 */
32169 MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
32170 options = _.extend({
32171 'enable_persistence': true
32172 }, options);
32173
32174 this._gdpr_call_func(clearOptInOut, options);
32175 this._gdpr_update_persistence(options);
32176 };
32177
32178 MixpanelLib.prototype.report_error = function(msg, err) {
32179 console$1.error.apply(console$1.error, arguments);
32180 try {
32181 if (!err && !(msg instanceof Error)) {
32182 msg = new Error(msg);
32183 }
32184 this.get_config('error_reporter')(msg, err);
32185 } catch(err) {
32186 console$1.error(err);
32187 }
32188 };
32189
32190 // EXPORTS (for closure compiler)
32191
32192 // MixpanelLib Exports
32193 MixpanelLib.prototype['init'] = MixpanelLib.prototype.init;
32194 MixpanelLib.prototype['reset'] = MixpanelLib.prototype.reset;
32195 MixpanelLib.prototype['disable'] = MixpanelLib.prototype.disable;
32196 MixpanelLib.prototype['time_event'] = MixpanelLib.prototype.time_event;
32197 MixpanelLib.prototype['track'] = MixpanelLib.prototype.track;
32198 MixpanelLib.prototype['track_links'] = MixpanelLib.prototype.track_links;
32199 MixpanelLib.prototype['track_forms'] = MixpanelLib.prototype.track_forms;
32200 MixpanelLib.prototype['track_pageview'] = MixpanelLib.prototype.track_pageview;
32201 MixpanelLib.prototype['register'] = MixpanelLib.prototype.register;
32202 MixpanelLib.prototype['register_once'] = MixpanelLib.prototype.register_once;
32203 MixpanelLib.prototype['unregister'] = MixpanelLib.prototype.unregister;
32204 MixpanelLib.prototype['identify'] = MixpanelLib.prototype.identify;
32205 MixpanelLib.prototype['alias'] = MixpanelLib.prototype.alias;
32206 MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
32207 MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
32208 MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
32209 MixpanelLib.prototype['get_api_host'] = MixpanelLib.prototype.get_api_host;
32210 MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
32211 MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
32212 MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
32213 MixpanelLib.prototype['opt_out_tracking'] = MixpanelLib.prototype.opt_out_tracking;
32214 MixpanelLib.prototype['opt_in_tracking'] = MixpanelLib.prototype.opt_in_tracking;
32215 MixpanelLib.prototype['has_opted_out_tracking'] = MixpanelLib.prototype.has_opted_out_tracking;
32216 MixpanelLib.prototype['has_opted_in_tracking'] = MixpanelLib.prototype.has_opted_in_tracking;
32217 MixpanelLib.prototype['clear_opt_in_out_tracking'] = MixpanelLib.prototype.clear_opt_in_out_tracking;
32218 MixpanelLib.prototype['get_group'] = MixpanelLib.prototype.get_group;
32219 MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
32220 MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
32221 MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
32222 MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
32223 MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
32224 MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;
32225 MixpanelLib.prototype['start_session_recording'] = MixpanelLib.prototype.start_session_recording;
32226 MixpanelLib.prototype['stop_session_recording'] = MixpanelLib.prototype.stop_session_recording;
32227 MixpanelLib.prototype['pause_session_recording'] = MixpanelLib.prototype.pause_session_recording;
32228 MixpanelLib.prototype['resume_session_recording'] = MixpanelLib.prototype.resume_session_recording;
32229 MixpanelLib.prototype['get_session_recording_properties'] = MixpanelLib.prototype.get_session_recording_properties;
32230 MixpanelLib.prototype['get_session_replay_url'] = MixpanelLib.prototype.get_session_replay_url;
32231 MixpanelLib.prototype['get_tab_id'] = MixpanelLib.prototype.get_tab_id;
32232 MixpanelLib.prototype['DEFAULT_API_ROUTES'] = DEFAULT_API_ROUTES;
32233
32234 // Exports intended only for testing
32235 MixpanelLib.prototype['__get_recorder'] = MixpanelLib.prototype.__get_recorder;
32236
32237 // MixpanelPersistence Exports
32238 MixpanelPersistence.prototype['properties'] = MixpanelPersistence.prototype.properties;
32239 MixpanelPersistence.prototype['update_search_keyword'] = MixpanelPersistence.prototype.update_search_keyword;
32240 MixpanelPersistence.prototype['update_referrer_info'] = MixpanelPersistence.prototype.update_referrer_info;
32241 MixpanelPersistence.prototype['get_cross_subdomain'] = MixpanelPersistence.prototype.get_cross_subdomain;
32242 MixpanelPersistence.prototype['clear'] = MixpanelPersistence.prototype.clear;
32243
32244
32245 var instances = {};
32246 var extend_mp = function() {
32247 // add all the sub mixpanel instances
32248 _.each(instances, function(instance, name) {
32249 if (name !== PRIMARY_INSTANCE_NAME) { mixpanel_master[name] = instance; }
32250 });
32251
32252 // add private functions as _
32253 mixpanel_master['_'] = _;
32254 };
32255
32256 var override_mp_init_func = function() {
32257 // we override the snippets init function to handle the case where a
32258 // user initializes the mixpanel library after the script loads & runs
32259 mixpanel_master['init'] = function(token, config, name) {
32260 if (name) {
32261 // initialize a sub library
32262 if (!mixpanel_master[name]) {
32263 mixpanel_master[name] = instances[name] = create_mplib(token, config, name);
32264 mixpanel_master[name]._loaded();
32265 }
32266 return mixpanel_master[name];
32267 } else {
32268 var instance = mixpanel_master;
32269
32270 if (instances[PRIMARY_INSTANCE_NAME]) {
32271 // main mixpanel lib already initialized
32272 instance = instances[PRIMARY_INSTANCE_NAME];
32273 } else if (token) {
32274 // intialize the main mixpanel lib
32275 instance = create_mplib(token, config, PRIMARY_INSTANCE_NAME);
32276 instance._loaded();
32277 instances[PRIMARY_INSTANCE_NAME] = instance;
32278 }
32279
32280 mixpanel_master = instance;
32281 if (init_type === INIT_SNIPPET) {
32282 win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
32283 }
32284 extend_mp();
32285 }
32286 };
32287 };
32288
32289 var add_dom_loaded_handler = function() {
32290 // Cross browser DOM Loaded support
32291 function dom_loaded_handler() {
32292 // function flag since we only want to execute this once
32293 if (dom_loaded_handler.done) { return; }
32294 dom_loaded_handler.done = true;
32295
32296 DOM_LOADED = true;
32297 ENQUEUE_REQUESTS = false;
32298
32299 _.each(instances, function(inst) {
32300 inst._dom_loaded();
32301 });
32302 }
32303
32304 function do_scroll_check() {
32305 try {
32306 document$1.documentElement.doScroll('left');
32307 } catch(e) {
32308 setTimeout(do_scroll_check, 1);
32309 return;
32310 }
32311
32312 dom_loaded_handler();
32313 }
32314
32315 if (document$1.addEventListener) {
32316 if (document$1.readyState === 'complete') {
32317 // safari 4 can fire the DOMContentLoaded event before loading all
32318 // external JS (including this file). you will see some copypasta
32319 // on the internet that checks for 'complete' and 'loaded', but
32320 // 'loaded' is an IE thing
32321 dom_loaded_handler();
32322 } else {
32323 document$1.addEventListener('DOMContentLoaded', dom_loaded_handler, false);
32324 }
32325 } else if (document$1.attachEvent) {
32326 // IE
32327 document$1.attachEvent('onreadystatechange', dom_loaded_handler);
32328
32329 // check to make sure we arn't in a frame
32330 var toplevel = false;
32331 try {
32332 toplevel = win.frameElement === null;
32333 } catch(e) {
32334 // noop
32335 }
32336
32337 if (document$1.documentElement.doScroll && toplevel) {
32338 do_scroll_check();
32339 }
32340 }
32341
32342 // fallback handler, always will work
32343 _.register_event(win, 'load', dom_loaded_handler, true);
32344 };
32345
32346 function init_as_module(bundle_loader) {
32347 load_extra_bundle = bundle_loader;
32348 init_type = INIT_MODULE;
32349 mixpanel_master = new MixpanelLib();
32350
32351 override_mp_init_func();
32352 mixpanel_master['init']();
32353 add_dom_loaded_handler();
32354
32355 return mixpanel_master;
32356 }
32357
32358 // For loading separate bundles asynchronously via script tag
32359 // so that we don't load them until they are needed at runtime.
32360
32361 // For builds that have everything in one bundle, no extra work.
32362 function loadNoop (_src, onload) {
32363 onload();
32364 }
32365
32366 /* eslint camelcase: "off" */
32367
32368 var mixpanel = init_as_module(loadNoop);
32369
32370
32371
32372
32373 /***/ }),
32374
32375 /***/ "../node_modules/redux-thunk/es/index.js":
32376 /*!***********************************************!*\
32377 !*** ../node_modules/redux-thunk/es/index.js ***!
32378 \***********************************************/
32379 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32380
32381 "use strict";
32382 __webpack_require__.r(__webpack_exports__);
32383 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32384 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
32385 /* harmony export */ });
32386 /** A function that accepts a potential "extra argument" value to be injected later,
32387 * and returns an instance of the thunk middleware that uses that value
32388 */
32389 function createThunkMiddleware(extraArgument) {
32390 // Standard Redux middleware definition pattern:
32391 // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
32392 var middleware = function middleware(_ref) {
32393 var dispatch = _ref.dispatch,
32394 getState = _ref.getState;
32395 return function (next) {
32396 return function (action) {
32397 // The thunk middleware looks for any functions that were passed to `store.dispatch`.
32398 // If this "action" is really a function, call it and return the result.
32399 if (typeof action === 'function') {
32400 // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
32401 return action(dispatch, getState, extraArgument);
32402 } // Otherwise, pass the action down the middleware chain as usual
32403
32404
32405 return next(action);
32406 };
32407 };
32408 };
32409
32410 return middleware;
32411 }
32412
32413 var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
32414 // with whatever "extra arg" they want to inject into their thunks
32415
32416 thunk.withExtraArgument = createThunkMiddleware;
32417 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (thunk);
32418
32419 /***/ }),
32420
32421 /***/ "../node_modules/redux/es/redux.js":
32422 /*!*****************************************!*\
32423 !*** ../node_modules/redux/es/redux.js ***!
32424 \*****************************************/
32425 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32426
32427 "use strict";
32428 __webpack_require__.r(__webpack_exports__);
32429 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32430 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* binding */ ActionTypes),
32431 /* harmony export */ applyMiddleware: () => (/* binding */ applyMiddleware),
32432 /* harmony export */ bindActionCreators: () => (/* binding */ bindActionCreators),
32433 /* harmony export */ combineReducers: () => (/* binding */ combineReducers),
32434 /* harmony export */ compose: () => (/* binding */ compose),
32435 /* harmony export */ createStore: () => (/* binding */ createStore),
32436 /* harmony export */ legacy_createStore: () => (/* binding */ legacy_createStore)
32437 /* harmony export */ });
32438 /* 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");
32439
32440
32441 /**
32442 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
32443 *
32444 * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
32445 * during build.
32446 * @param {number} code
32447 */
32448 function formatProdErrorMessage(code) {
32449 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. ';
32450 }
32451
32452 // Inlined version of the `symbol-observable` polyfill
32453 var $$observable = (function () {
32454 return typeof Symbol === 'function' && Symbol.observable || '@@observable';
32455 })();
32456
32457 /**
32458 * These are private action types reserved by Redux.
32459 * For any unknown actions, you must return the current state.
32460 * If the current state is undefined, you must return the initial state.
32461 * Do not reference these action types directly in your code.
32462 */
32463 var randomString = function randomString() {
32464 return Math.random().toString(36).substring(7).split('').join('.');
32465 };
32466
32467 var ActionTypes = {
32468 INIT: "@@redux/INIT" + randomString(),
32469 REPLACE: "@@redux/REPLACE" + randomString(),
32470 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
32471 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
32472 }
32473 };
32474
32475 /**
32476 * @param {any} obj The object to inspect.
32477 * @returns {boolean} True if the argument appears to be a plain object.
32478 */
32479 function isPlainObject(obj) {
32480 if (typeof obj !== 'object' || obj === null) return false;
32481 var proto = obj;
32482
32483 while (Object.getPrototypeOf(proto) !== null) {
32484 proto = Object.getPrototypeOf(proto);
32485 }
32486
32487 return Object.getPrototypeOf(obj) === proto;
32488 }
32489
32490 // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
32491 function miniKindOf(val) {
32492 if (val === void 0) return 'undefined';
32493 if (val === null) return 'null';
32494 var type = typeof val;
32495
32496 switch (type) {
32497 case 'boolean':
32498 case 'string':
32499 case 'number':
32500 case 'symbol':
32501 case 'function':
32502 {
32503 return type;
32504 }
32505 }
32506
32507 if (Array.isArray(val)) return 'array';
32508 if (isDate(val)) return 'date';
32509 if (isError(val)) return 'error';
32510 var constructorName = ctorName(val);
32511
32512 switch (constructorName) {
32513 case 'Symbol':
32514 case 'Promise':
32515 case 'WeakMap':
32516 case 'WeakSet':
32517 case 'Map':
32518 case 'Set':
32519 return constructorName;
32520 } // other
32521
32522
32523 return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
32524 }
32525
32526 function ctorName(val) {
32527 return typeof val.constructor === 'function' ? val.constructor.name : null;
32528 }
32529
32530 function isError(val) {
32531 return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
32532 }
32533
32534 function isDate(val) {
32535 if (val instanceof Date) return true;
32536 return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
32537 }
32538
32539 function kindOf(val) {
32540 var typeOfVal = typeof val;
32541
32542 if (true) {
32543 typeOfVal = miniKindOf(val);
32544 }
32545
32546 return typeOfVal;
32547 }
32548
32549 /**
32550 * @deprecated
32551 *
32552 * **We recommend using the `configureStore` method
32553 * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
32554 *
32555 * Redux Toolkit is our recommended approach for writing Redux logic today,
32556 * including store setup, reducers, data fetching, and more.
32557 *
32558 * **For more details, please read this Redux docs page:**
32559 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32560 *
32561 * `configureStore` from Redux Toolkit is an improved version of `createStore` that
32562 * simplifies setup and helps avoid common bugs.
32563 *
32564 * You should not be using the `redux` core package by itself today, except for learning purposes.
32565 * The `createStore` method from the core `redux` package will not be removed, but we encourage
32566 * all users to migrate to using Redux Toolkit for all Redux code.
32567 *
32568 * If you want to use `createStore` without this visual deprecation warning, use
32569 * the `legacy_createStore` import instead:
32570 *
32571 * `import { legacy_createStore as createStore} from 'redux'`
32572 *
32573 */
32574
32575 function createStore(reducer, preloadedState, enhancer) {
32576 var _ref2;
32577
32578 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
32579 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.');
32580 }
32581
32582 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
32583 enhancer = preloadedState;
32584 preloadedState = undefined;
32585 }
32586
32587 if (typeof enhancer !== 'undefined') {
32588 if (typeof enhancer !== 'function') {
32589 throw new Error( false ? 0 : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
32590 }
32591
32592 return enhancer(createStore)(reducer, preloadedState);
32593 }
32594
32595 if (typeof reducer !== 'function') {
32596 throw new Error( false ? 0 : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
32597 }
32598
32599 var currentReducer = reducer;
32600 var currentState = preloadedState;
32601 var currentListeners = [];
32602 var nextListeners = currentListeners;
32603 var isDispatching = false;
32604 /**
32605 * This makes a shallow copy of currentListeners so we can use
32606 * nextListeners as a temporary list while dispatching.
32607 *
32608 * This prevents any bugs around consumers calling
32609 * subscribe/unsubscribe in the middle of a dispatch.
32610 */
32611
32612 function ensureCanMutateNextListeners() {
32613 if (nextListeners === currentListeners) {
32614 nextListeners = currentListeners.slice();
32615 }
32616 }
32617 /**
32618 * Reads the state tree managed by the store.
32619 *
32620 * @returns {any} The current state tree of your application.
32621 */
32622
32623
32624 function getState() {
32625 if (isDispatching) {
32626 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.');
32627 }
32628
32629 return currentState;
32630 }
32631 /**
32632 * Adds a change listener. It will be called any time an action is dispatched,
32633 * and some part of the state tree may potentially have changed. You may then
32634 * call `getState()` to read the current state tree inside the callback.
32635 *
32636 * You may call `dispatch()` from a change listener, with the following
32637 * caveats:
32638 *
32639 * 1. The subscriptions are snapshotted just before every `dispatch()` call.
32640 * If you subscribe or unsubscribe while the listeners are being invoked, this
32641 * will not have any effect on the `dispatch()` that is currently in progress.
32642 * However, the next `dispatch()` call, whether nested or not, will use a more
32643 * recent snapshot of the subscription list.
32644 *
32645 * 2. The listener should not expect to see all state changes, as the state
32646 * might have been updated multiple times during a nested `dispatch()` before
32647 * the listener is called. It is, however, guaranteed that all subscribers
32648 * registered before the `dispatch()` started will be called with the latest
32649 * state by the time it exits.
32650 *
32651 * @param {Function} listener A callback to be invoked on every dispatch.
32652 * @returns {Function} A function to remove this change listener.
32653 */
32654
32655
32656 function subscribe(listener) {
32657 if (typeof listener !== 'function') {
32658 throw new Error( false ? 0 : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
32659 }
32660
32661 if (isDispatching) {
32662 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.');
32663 }
32664
32665 var isSubscribed = true;
32666 ensureCanMutateNextListeners();
32667 nextListeners.push(listener);
32668 return function unsubscribe() {
32669 if (!isSubscribed) {
32670 return;
32671 }
32672
32673 if (isDispatching) {
32674 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.');
32675 }
32676
32677 isSubscribed = false;
32678 ensureCanMutateNextListeners();
32679 var index = nextListeners.indexOf(listener);
32680 nextListeners.splice(index, 1);
32681 currentListeners = null;
32682 };
32683 }
32684 /**
32685 * Dispatches an action. It is the only way to trigger a state change.
32686 *
32687 * The `reducer` function, used to create the store, will be called with the
32688 * current state tree and the given `action`. Its return value will
32689 * be considered the **next** state of the tree, and the change listeners
32690 * will be notified.
32691 *
32692 * The base implementation only supports plain object actions. If you want to
32693 * dispatch a Promise, an Observable, a thunk, or something else, you need to
32694 * wrap your store creating function into the corresponding middleware. For
32695 * example, see the documentation for the `redux-thunk` package. Even the
32696 * middleware will eventually dispatch plain object actions using this method.
32697 *
32698 * @param {Object} action A plain object representing “what changed”. It is
32699 * a good idea to keep actions serializable so you can record and replay user
32700 * sessions, or use the time travelling `redux-devtools`. An action must have
32701 * a `type` property which may not be `undefined`. It is a good idea to use
32702 * string constants for action types.
32703 *
32704 * @returns {Object} For convenience, the same action object you dispatched.
32705 *
32706 * Note that, if you use a custom middleware, it may wrap `dispatch()` to
32707 * return something else (for example, a Promise you can await).
32708 */
32709
32710
32711 function dispatch(action) {
32712 if (!isPlainObject(action)) {
32713 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.");
32714 }
32715
32716 if (typeof action.type === 'undefined') {
32717 throw new Error( false ? 0 : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
32718 }
32719
32720 if (isDispatching) {
32721 throw new Error( false ? 0 : 'Reducers may not dispatch actions.');
32722 }
32723
32724 try {
32725 isDispatching = true;
32726 currentState = currentReducer(currentState, action);
32727 } finally {
32728 isDispatching = false;
32729 }
32730
32731 var listeners = currentListeners = nextListeners;
32732
32733 for (var i = 0; i < listeners.length; i++) {
32734 var listener = listeners[i];
32735 listener();
32736 }
32737
32738 return action;
32739 }
32740 /**
32741 * Replaces the reducer currently used by the store to calculate the state.
32742 *
32743 * You might need this if your app implements code splitting and you want to
32744 * load some of the reducers dynamically. You might also need this if you
32745 * implement a hot reloading mechanism for Redux.
32746 *
32747 * @param {Function} nextReducer The reducer for the store to use instead.
32748 * @returns {void}
32749 */
32750
32751
32752 function replaceReducer(nextReducer) {
32753 if (typeof nextReducer !== 'function') {
32754 throw new Error( false ? 0 : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
32755 }
32756
32757 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
32758 // Any reducers that existed in both the new and old rootReducer
32759 // will receive the previous state. This effectively populates
32760 // the new state tree with any relevant data from the old one.
32761
32762 dispatch({
32763 type: ActionTypes.REPLACE
32764 });
32765 }
32766 /**
32767 * Interoperability point for observable/reactive libraries.
32768 * @returns {observable} A minimal observable of state changes.
32769 * For more information, see the observable proposal:
32770 * https://github.com/tc39/proposal-observable
32771 */
32772
32773
32774 function observable() {
32775 var _ref;
32776
32777 var outerSubscribe = subscribe;
32778 return _ref = {
32779 /**
32780 * The minimal observable subscription method.
32781 * @param {Object} observer Any object that can be used as an observer.
32782 * The observer object should have a `next` method.
32783 * @returns {subscription} An object with an `unsubscribe` method that can
32784 * be used to unsubscribe the observable from the store, and prevent further
32785 * emission of values from the observable.
32786 */
32787 subscribe: function subscribe(observer) {
32788 if (typeof observer !== 'object' || observer === null) {
32789 throw new Error( false ? 0 : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
32790 }
32791
32792 function observeState() {
32793 if (observer.next) {
32794 observer.next(getState());
32795 }
32796 }
32797
32798 observeState();
32799 var unsubscribe = outerSubscribe(observeState);
32800 return {
32801 unsubscribe: unsubscribe
32802 };
32803 }
32804 }, _ref[$$observable] = function () {
32805 return this;
32806 }, _ref;
32807 } // When a store is created, an "INIT" action is dispatched so that every
32808 // reducer returns their initial state. This effectively populates
32809 // the initial state tree.
32810
32811
32812 dispatch({
32813 type: ActionTypes.INIT
32814 });
32815 return _ref2 = {
32816 dispatch: dispatch,
32817 subscribe: subscribe,
32818 getState: getState,
32819 replaceReducer: replaceReducer
32820 }, _ref2[$$observable] = observable, _ref2;
32821 }
32822 /**
32823 * Creates a Redux store that holds the state tree.
32824 *
32825 * **We recommend using `configureStore` from the
32826 * `@reduxjs/toolkit` package**, which replaces `createStore`:
32827 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32828 *
32829 * The only way to change the data in the store is to call `dispatch()` on it.
32830 *
32831 * There should only be a single store in your app. To specify how different
32832 * parts of the state tree respond to actions, you may combine several reducers
32833 * into a single reducer function by using `combineReducers`.
32834 *
32835 * @param {Function} reducer A function that returns the next state tree, given
32836 * the current state tree and the action to handle.
32837 *
32838 * @param {any} [preloadedState] The initial state. You may optionally specify it
32839 * to hydrate the state from the server in universal apps, or to restore a
32840 * previously serialized user session.
32841 * If you use `combineReducers` to produce the root reducer function, this must be
32842 * an object with the same shape as `combineReducers` keys.
32843 *
32844 * @param {Function} [enhancer] The store enhancer. You may optionally specify it
32845 * to enhance the store with third-party capabilities such as middleware,
32846 * time travel, persistence, etc. The only store enhancer that ships with Redux
32847 * is `applyMiddleware()`.
32848 *
32849 * @returns {Store} A Redux store that lets you read the state, dispatch actions
32850 * and subscribe to changes.
32851 */
32852
32853 var legacy_createStore = createStore;
32854
32855 /**
32856 * Prints a warning in the console if it exists.
32857 *
32858 * @param {String} message The warning message.
32859 * @returns {void}
32860 */
32861 function warning(message) {
32862 /* eslint-disable no-console */
32863 if (typeof console !== 'undefined' && typeof console.error === 'function') {
32864 console.error(message);
32865 }
32866 /* eslint-enable no-console */
32867
32868
32869 try {
32870 // This error was thrown as a convenience so that if you enable
32871 // "break on all exceptions" in your console,
32872 // it would pause the execution at this line.
32873 throw new Error(message);
32874 } catch (e) {} // eslint-disable-line no-empty
32875
32876 }
32877
32878 function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
32879 var reducerKeys = Object.keys(reducers);
32880 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
32881
32882 if (reducerKeys.length === 0) {
32883 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
32884 }
32885
32886 if (!isPlainObject(inputState)) {
32887 return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
32888 }
32889
32890 var unexpectedKeys = Object.keys(inputState).filter(function (key) {
32891 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
32892 });
32893 unexpectedKeys.forEach(function (key) {
32894 unexpectedKeyCache[key] = true;
32895 });
32896 if (action && action.type === ActionTypes.REPLACE) return;
32897
32898 if (unexpectedKeys.length > 0) {
32899 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.");
32900 }
32901 }
32902
32903 function assertReducerShape(reducers) {
32904 Object.keys(reducers).forEach(function (key) {
32905 var reducer = reducers[key];
32906 var initialState = reducer(undefined, {
32907 type: ActionTypes.INIT
32908 });
32909
32910 if (typeof initialState === 'undefined') {
32911 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.");
32912 }
32913
32914 if (typeof reducer(undefined, {
32915 type: ActionTypes.PROBE_UNKNOWN_ACTION()
32916 }) === 'undefined') {
32917 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.");
32918 }
32919 });
32920 }
32921 /**
32922 * Turns an object whose values are different reducer functions, into a single
32923 * reducer function. It will call every child reducer, and gather their results
32924 * into a single state object, whose keys correspond to the keys of the passed
32925 * reducer functions.
32926 *
32927 * @param {Object} reducers An object whose values correspond to different
32928 * reducer functions that need to be combined into one. One handy way to obtain
32929 * it is to use ES6 `import * as reducers` syntax. The reducers may never return
32930 * undefined for any action. Instead, they should return their initial state
32931 * if the state passed to them was undefined, and the current state for any
32932 * unrecognized action.
32933 *
32934 * @returns {Function} A reducer function that invokes every reducer inside the
32935 * passed object, and builds a state object with the same shape.
32936 */
32937
32938
32939 function combineReducers(reducers) {
32940 var reducerKeys = Object.keys(reducers);
32941 var finalReducers = {};
32942
32943 for (var i = 0; i < reducerKeys.length; i++) {
32944 var key = reducerKeys[i];
32945
32946 if (true) {
32947 if (typeof reducers[key] === 'undefined') {
32948 warning("No reducer provided for key \"" + key + "\"");
32949 }
32950 }
32951
32952 if (typeof reducers[key] === 'function') {
32953 finalReducers[key] = reducers[key];
32954 }
32955 }
32956
32957 var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
32958 // keys multiple times.
32959
32960 var unexpectedKeyCache;
32961
32962 if (true) {
32963 unexpectedKeyCache = {};
32964 }
32965
32966 var shapeAssertionError;
32967
32968 try {
32969 assertReducerShape(finalReducers);
32970 } catch (e) {
32971 shapeAssertionError = e;
32972 }
32973
32974 return function combination(state, action) {
32975 if (state === void 0) {
32976 state = {};
32977 }
32978
32979 if (shapeAssertionError) {
32980 throw shapeAssertionError;
32981 }
32982
32983 if (true) {
32984 var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
32985
32986 if (warningMessage) {
32987 warning(warningMessage);
32988 }
32989 }
32990
32991 var hasChanged = false;
32992 var nextState = {};
32993
32994 for (var _i = 0; _i < finalReducerKeys.length; _i++) {
32995 var _key = finalReducerKeys[_i];
32996 var reducer = finalReducers[_key];
32997 var previousStateForKey = state[_key];
32998 var nextStateForKey = reducer(previousStateForKey, action);
32999
33000 if (typeof nextStateForKey === 'undefined') {
33001 var actionType = action && action.type;
33002 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.");
33003 }
33004
33005 nextState[_key] = nextStateForKey;
33006 hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
33007 }
33008
33009 hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
33010 return hasChanged ? nextState : state;
33011 };
33012 }
33013
33014 function bindActionCreator(actionCreator, dispatch) {
33015 return function () {
33016 return dispatch(actionCreator.apply(this, arguments));
33017 };
33018 }
33019 /**
33020 * Turns an object whose values are action creators, into an object with the
33021 * same keys, but with every function wrapped into a `dispatch` call so they
33022 * may be invoked directly. This is just a convenience method, as you can call
33023 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
33024 *
33025 * For convenience, you can also pass an action creator as the first argument,
33026 * and get a dispatch wrapped function in return.
33027 *
33028 * @param {Function|Object} actionCreators An object whose values are action
33029 * creator functions. One handy way to obtain it is to use ES6 `import * as`
33030 * syntax. You may also pass a single function.
33031 *
33032 * @param {Function} dispatch The `dispatch` function available on your Redux
33033 * store.
33034 *
33035 * @returns {Function|Object} The object mimicking the original object, but with
33036 * every action creator wrapped into the `dispatch` call. If you passed a
33037 * function as `actionCreators`, the return value will also be a single
33038 * function.
33039 */
33040
33041
33042 function bindActionCreators(actionCreators, dispatch) {
33043 if (typeof actionCreators === 'function') {
33044 return bindActionCreator(actionCreators, dispatch);
33045 }
33046
33047 if (typeof actionCreators !== 'object' || actionCreators === null) {
33048 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\"?");
33049 }
33050
33051 var boundActionCreators = {};
33052
33053 for (var key in actionCreators) {
33054 var actionCreator = actionCreators[key];
33055
33056 if (typeof actionCreator === 'function') {
33057 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
33058 }
33059 }
33060
33061 return boundActionCreators;
33062 }
33063
33064 /**
33065 * Composes single-argument functions from right to left. The rightmost
33066 * function can take multiple arguments as it provides the signature for
33067 * the resulting composite function.
33068 *
33069 * @param {...Function} funcs The functions to compose.
33070 * @returns {Function} A function obtained by composing the argument functions
33071 * from right to left. For example, compose(f, g, h) is identical to doing
33072 * (...args) => f(g(h(...args))).
33073 */
33074 function compose() {
33075 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
33076 funcs[_key] = arguments[_key];
33077 }
33078
33079 if (funcs.length === 0) {
33080 return function (arg) {
33081 return arg;
33082 };
33083 }
33084
33085 if (funcs.length === 1) {
33086 return funcs[0];
33087 }
33088
33089 return funcs.reduce(function (a, b) {
33090 return function () {
33091 return a(b.apply(void 0, arguments));
33092 };
33093 });
33094 }
33095
33096 /**
33097 * Creates a store enhancer that applies middleware to the dispatch method
33098 * of the Redux store. This is handy for a variety of tasks, such as expressing
33099 * asynchronous actions in a concise manner, or logging every action payload.
33100 *
33101 * See `redux-thunk` package as an example of the Redux middleware.
33102 *
33103 * Because middleware is potentially asynchronous, this should be the first
33104 * store enhancer in the composition chain.
33105 *
33106 * Note that each middleware will be given the `dispatch` and `getState` functions
33107 * as named arguments.
33108 *
33109 * @param {...Function} middlewares The middleware chain to be applied.
33110 * @returns {Function} A store enhancer applying the middleware.
33111 */
33112
33113 function applyMiddleware() {
33114 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
33115 middlewares[_key] = arguments[_key];
33116 }
33117
33118 return function (createStore) {
33119 return function () {
33120 var store = createStore.apply(void 0, arguments);
33121
33122 var _dispatch = function dispatch() {
33123 throw new Error( false ? 0 : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
33124 };
33125
33126 var middlewareAPI = {
33127 getState: store.getState,
33128 dispatch: function dispatch() {
33129 return _dispatch.apply(void 0, arguments);
33130 }
33131 };
33132 var chain = middlewares.map(function (middleware) {
33133 return middleware(middlewareAPI);
33134 });
33135 _dispatch = compose.apply(void 0, chain)(store.dispatch);
33136 return (0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])((0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])({}, store), {}, {
33137 dispatch: _dispatch
33138 });
33139 };
33140 };
33141 }
33142
33143
33144
33145
33146 /***/ }),
33147
33148 /***/ "../node_modules/reselect/es/defaultMemoize.js":
33149 /*!*****************************************************!*\
33150 !*** ../node_modules/reselect/es/defaultMemoize.js ***!
33151 \*****************************************************/
33152 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
33153
33154 "use strict";
33155 __webpack_require__.r(__webpack_exports__);
33156 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33157 /* harmony export */ createCacheKeyComparator: () => (/* binding */ createCacheKeyComparator),
33158 /* harmony export */ defaultEqualityCheck: () => (/* binding */ defaultEqualityCheck),
33159 /* harmony export */ defaultMemoize: () => (/* binding */ defaultMemoize)
33160 /* harmony export */ });
33161 // Cache implementation based on Erik Rasmussen's `lru-memoize`:
33162 // https://github.com/erikras/lru-memoize
33163 var NOT_FOUND = 'NOT_FOUND';
33164
33165 function createSingletonCache(equals) {
33166 var entry;
33167 return {
33168 get: function get(key) {
33169 if (entry && equals(entry.key, key)) {
33170 return entry.value;
33171 }
33172
33173 return NOT_FOUND;
33174 },
33175 put: function put(key, value) {
33176 entry = {
33177 key: key,
33178 value: value
33179 };
33180 },
33181 getEntries: function getEntries() {
33182 return entry ? [entry] : [];
33183 },
33184 clear: function clear() {
33185 entry = undefined;
33186 }
33187 };
33188 }
33189
33190 function createLruCache(maxSize, equals) {
33191 var entries = [];
33192
33193 function get(key) {
33194 var cacheIndex = entries.findIndex(function (entry) {
33195 return equals(key, entry.key);
33196 }); // We found a cached entry
33197
33198 if (cacheIndex > -1) {
33199 var entry = entries[cacheIndex]; // Cached entry not at top of cache, move it to the top
33200
33201 if (cacheIndex > 0) {
33202 entries.splice(cacheIndex, 1);
33203 entries.unshift(entry);
33204 }
33205
33206 return entry.value;
33207 } // No entry found in cache, return sentinel
33208
33209
33210 return NOT_FOUND;
33211 }
33212
33213 function put(key, value) {
33214 if (get(key) === NOT_FOUND) {
33215 // TODO Is unshift slow?
33216 entries.unshift({
33217 key: key,
33218 value: value
33219 });
33220
33221 if (entries.length > maxSize) {
33222 entries.pop();
33223 }
33224 }
33225 }
33226
33227 function getEntries() {
33228 return entries;
33229 }
33230
33231 function clear() {
33232 entries = [];
33233 }
33234
33235 return {
33236 get: get,
33237 put: put,
33238 getEntries: getEntries,
33239 clear: clear
33240 };
33241 }
33242
33243 var defaultEqualityCheck = function defaultEqualityCheck(a, b) {
33244 return a === b;
33245 };
33246 function createCacheKeyComparator(equalityCheck) {
33247 return function areArgumentsShallowlyEqual(prev, next) {
33248 if (prev === null || next === null || prev.length !== next.length) {
33249 return false;
33250 } // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
33251
33252
33253 var length = prev.length;
33254
33255 for (var i = 0; i < length; i++) {
33256 if (!equalityCheck(prev[i], next[i])) {
33257 return false;
33258 }
33259 }
33260
33261 return true;
33262 };
33263 }
33264 // defaultMemoize now supports a configurable cache size with LRU behavior,
33265 // and optional comparison of the result value with existing values
33266 function defaultMemoize(func, equalityCheckOrOptions) {
33267 var providedOptions = typeof equalityCheckOrOptions === 'object' ? equalityCheckOrOptions : {
33268 equalityCheck: equalityCheckOrOptions
33269 };
33270 var _providedOptions$equa = providedOptions.equalityCheck,
33271 equalityCheck = _providedOptions$equa === void 0 ? defaultEqualityCheck : _providedOptions$equa,
33272 _providedOptions$maxS = providedOptions.maxSize,
33273 maxSize = _providedOptions$maxS === void 0 ? 1 : _providedOptions$maxS,
33274 resultEqualityCheck = providedOptions.resultEqualityCheck;
33275 var comparator = createCacheKeyComparator(equalityCheck);
33276 var cache = maxSize === 1 ? createSingletonCache(comparator) : createLruCache(maxSize, comparator); // we reference arguments instead of spreading them for performance reasons
33277
33278 function memoized() {
33279 var value = cache.get(arguments);
33280
33281 if (value === NOT_FOUND) {
33282 // @ts-ignore
33283 value = func.apply(null, arguments);
33284
33285 if (resultEqualityCheck) {
33286 var entries = cache.getEntries();
33287 var matchingEntry = entries.find(function (entry) {
33288 return resultEqualityCheck(entry.value, value);
33289 });
33290
33291 if (matchingEntry) {
33292 value = matchingEntry.value;
33293 }
33294 }
33295
33296 cache.put(arguments, value);
33297 }
33298
33299 return value;
33300 }
33301
33302 memoized.clearCache = function () {
33303 return cache.clear();
33304 };
33305
33306 return memoized;
33307 }
33308
33309 /***/ }),
33310
33311 /***/ "../node_modules/reselect/es/index.js":
33312 /*!********************************************!*\
33313 !*** ../node_modules/reselect/es/index.js ***!
33314 \********************************************/
33315 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
33316
33317 "use strict";
33318 __webpack_require__.r(__webpack_exports__);
33319 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33320 /* harmony export */ createSelector: () => (/* binding */ createSelector),
33321 /* harmony export */ createSelectorCreator: () => (/* binding */ createSelectorCreator),
33322 /* harmony export */ createStructuredSelector: () => (/* binding */ createStructuredSelector),
33323 /* harmony export */ defaultEqualityCheck: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultEqualityCheck),
33324 /* harmony export */ defaultMemoize: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize)
33325 /* harmony export */ });
33326 /* harmony import */ var _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultMemoize */ "../node_modules/reselect/es/defaultMemoize.js");
33327
33328
33329
33330 function getDependencies(funcs) {
33331 var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
33332
33333 if (!dependencies.every(function (dep) {
33334 return typeof dep === 'function';
33335 })) {
33336 var dependencyTypes = dependencies.map(function (dep) {
33337 return typeof dep === 'function' ? "function " + (dep.name || 'unnamed') + "()" : typeof dep;
33338 }).join(', ');
33339 throw new Error("createSelector expects all input-selectors to be functions, but received the following types: [" + dependencyTypes + "]");
33340 }
33341
33342 return dependencies;
33343 }
33344
33345 function createSelectorCreator(memoize) {
33346 for (var _len = arguments.length, memoizeOptionsFromArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
33347 memoizeOptionsFromArgs[_key - 1] = arguments[_key];
33348 }
33349
33350 var createSelector = function createSelector() {
33351 for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
33352 funcs[_key2] = arguments[_key2];
33353 }
33354
33355 var _recomputations = 0;
33356
33357 var _lastResult; // Due to the intricacies of rest params, we can't do an optional arg after `...funcs`.
33358 // So, start by declaring the default value here.
33359 // (And yes, the words 'memoize' and 'options' appear too many times in this next sequence.)
33360
33361
33362 var directlyPassedOptions = {
33363 memoizeOptions: undefined
33364 }; // Normally, the result func or "output selector" is the last arg
33365
33366 var resultFunc = funcs.pop(); // If the result func is actually an _object_, assume it's our options object
33367
33368 if (typeof resultFunc === 'object') {
33369 directlyPassedOptions = resultFunc; // and pop the real result func off
33370
33371 resultFunc = funcs.pop();
33372 }
33373
33374 if (typeof resultFunc !== 'function') {
33375 throw new Error("createSelector expects an output function after the inputs, but received: [" + typeof resultFunc + "]");
33376 } // Determine which set of options we're using. Prefer options passed directly,
33377 // but fall back to options given to createSelectorCreator.
33378
33379
33380 var _directlyPassedOption = directlyPassedOptions,
33381 _directlyPassedOption2 = _directlyPassedOption.memoizeOptions,
33382 memoizeOptions = _directlyPassedOption2 === void 0 ? memoizeOptionsFromArgs : _directlyPassedOption2; // Simplifying assumption: it's unlikely that the first options arg of the provided memoizer
33383 // is an array. In most libs I've looked at, it's an equality function or options object.
33384 // Based on that, if `memoizeOptions` _is_ an array, we assume it's a full
33385 // user-provided array of options. Otherwise, it must be just the _first_ arg, and so
33386 // we wrap it in an array so we can apply it.
33387
33388 var finalMemoizeOptions = Array.isArray(memoizeOptions) ? memoizeOptions : [memoizeOptions];
33389 var dependencies = getDependencies(funcs);
33390 var memoizedResultFunc = memoize.apply(void 0, [function recomputationWrapper() {
33391 _recomputations++; // apply arguments instead of spreading for performance.
33392
33393 return resultFunc.apply(null, arguments);
33394 }].concat(finalMemoizeOptions)); // If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
33395
33396 var selector = memoize(function dependenciesChecker() {
33397 var params = [];
33398 var length = dependencies.length;
33399
33400 for (var i = 0; i < length; i++) {
33401 // apply arguments instead of spreading and mutate a local list of params for performance.
33402 // @ts-ignore
33403 params.push(dependencies[i].apply(null, arguments));
33404 } // apply arguments instead of spreading for performance.
33405
33406
33407 _lastResult = memoizedResultFunc.apply(null, params);
33408 return _lastResult;
33409 });
33410 Object.assign(selector, {
33411 resultFunc: resultFunc,
33412 memoizedResultFunc: memoizedResultFunc,
33413 dependencies: dependencies,
33414 lastResult: function lastResult() {
33415 return _lastResult;
33416 },
33417 recomputations: function recomputations() {
33418 return _recomputations;
33419 },
33420 resetRecomputations: function resetRecomputations() {
33421 return _recomputations = 0;
33422 }
33423 });
33424 return selector;
33425 }; // @ts-ignore
33426
33427
33428 return createSelector;
33429 }
33430 var createSelector = /* #__PURE__ */createSelectorCreator(_defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize);
33431 // Manual definition of state and output arguments
33432 var createStructuredSelector = function createStructuredSelector(selectors, selectorCreator) {
33433 if (selectorCreator === void 0) {
33434 selectorCreator = createSelector;
33435 }
33436
33437 if (typeof selectors !== 'object') {
33438 throw new Error('createStructuredSelector expects first argument to be an object ' + ("where each property is a selector, instead received a " + typeof selectors));
33439 }
33440
33441 var objectKeys = Object.keys(selectors);
33442 var resultSelector = selectorCreator( // @ts-ignore
33443 objectKeys.map(function (key) {
33444 return selectors[key];
33445 }), function () {
33446 for (var _len3 = arguments.length, values = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
33447 values[_key3] = arguments[_key3];
33448 }
33449
33450 return values.reduce(function (composition, value, index) {
33451 composition[objectKeys[index]] = value;
33452 return composition;
33453 }, {});
33454 });
33455 return resultSelector;
33456 };
33457
33458 /***/ }),
33459
33460 /***/ "@wordpress/i18n":
33461 /*!**************************!*\
33462 !*** external "wp.i18n" ***!
33463 \**************************/
33464 /***/ ((module) => {
33465
33466 "use strict";
33467 module.exports = wp.i18n;
33468
33469 /***/ })
33470
33471 /******/ });
33472 /************************************************************************/
33473 /******/ // The module cache
33474 /******/ var __webpack_module_cache__ = {};
33475 /******/
33476 /******/ // The require function
33477 /******/ function __webpack_require__(moduleId) {
33478 /******/ // Check if module is in cache
33479 /******/ var cachedModule = __webpack_module_cache__[moduleId];
33480 /******/ if (cachedModule !== undefined) {
33481 /******/ return cachedModule.exports;
33482 /******/ }
33483 /******/ // Create a new module (and put it into the cache)
33484 /******/ var module = __webpack_module_cache__[moduleId] = {
33485 /******/ // no module.id needed
33486 /******/ // no module.loaded needed
33487 /******/ exports: {}
33488 /******/ };
33489 /******/
33490 /******/ // Execute the module function
33491 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
33492 /******/
33493 /******/ // Return the exports of the module
33494 /******/ return module.exports;
33495 /******/ }
33496 /******/
33497 /************************************************************************/
33498 /******/ /* webpack/runtime/define property getters */
33499 /******/ (() => {
33500 /******/ // define getter functions for harmony exports
33501 /******/ __webpack_require__.d = (exports, definition) => {
33502 /******/ for(var key in definition) {
33503 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
33504 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
33505 /******/ }
33506 /******/ }
33507 /******/ };
33508 /******/ })();
33509 /******/
33510 /******/ /* webpack/runtime/global */
33511 /******/ (() => {
33512 /******/ __webpack_require__.g = (function() {
33513 /******/ if (typeof globalThis === 'object') return globalThis;
33514 /******/ try {
33515 /******/ return this || new Function('return this')();
33516 /******/ } catch (e) {
33517 /******/ if (typeof window === 'object') return window;
33518 /******/ }
33519 /******/ })();
33520 /******/ })();
33521 /******/
33522 /******/ /* webpack/runtime/hasOwnProperty shorthand */
33523 /******/ (() => {
33524 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
33525 /******/ })();
33526 /******/
33527 /******/ /* webpack/runtime/make namespace object */
33528 /******/ (() => {
33529 /******/ // define __esModule on exports
33530 /******/ __webpack_require__.r = (exports) => {
33531 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
33532 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
33533 /******/ }
33534 /******/ Object.defineProperty(exports, '__esModule', { value: true });
33535 /******/ };
33536 /******/ })();
33537 /******/
33538 /************************************************************************/
33539 var __webpack_exports__ = {};
33540 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
33541 (() => {
33542 "use strict";
33543 /*!******************************************!*\
33544 !*** ../core/common/assets/js/common.js ***!
33545 \******************************************/
33546
33547
33548 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
33549 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
33550 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
33551 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
33552 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
33553 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
33554 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
33555 var _helpers = _interopRequireDefault(__webpack_require__(/*! ./utils/helpers */ "../core/common/assets/js/utils/helpers.js"));
33556 var _storage = _interopRequireDefault(__webpack_require__(/*! ./utils/storage */ "../core/common/assets/js/utils/storage.js"));
33557 var _debug = _interopRequireDefault(__webpack_require__(/*! ./utils/debug */ "../core/common/assets/js/utils/debug.js"));
33558 var _ajax = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/ajax/assets/js/ajax */ "../core/common/modules/ajax/assets/js/ajax.js"));
33559 var _finder = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/finder/assets/js/finder */ "../core/common/modules/finder/assets/js/finder.js"));
33560 var _connect = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/connect/assets/js/connect */ "../core/common/modules/connect/assets/js/connect.js"));
33561 var _component = _interopRequireDefault(__webpack_require__(/*! ./components/wordpress/component */ "../core/common/assets/js/components/wordpress/component.js"));
33562 var _component2 = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/data/component */ "../core/common/modules/event-tracker/assets/js/data/component.js"));
33563 var _events = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/events */ "../core/common/modules/event-tracker/assets/js/events.js"));
33564 var _module = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/events-manager/assets/js/module */ "../core/common/modules/events-manager/assets/js/module.js"));
33565 var _notifications = _interopRequireDefault(__webpack_require__(/*! elementor-utils/notifications */ "../assets/dev/js/utils/notifications.js"));
33566 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)); }
33567 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
33568 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; }
33569 var ElementorCommonApp = /*#__PURE__*/function (_elementorModules$Vie) {
33570 function ElementorCommonApp() {
33571 (0, _classCallCheck2.default)(this, ElementorCommonApp);
33572 return _callSuper(this, ElementorCommonApp, arguments);
33573 }
33574 (0, _inherits2.default)(ElementorCommonApp, _elementorModules$Vie);
33575 return (0, _createClass2.default)(ElementorCommonApp, [{
33576 key: "setMarionetteTemplateCompiler",
33577 value: function setMarionetteTemplateCompiler() {
33578 Marionette.TemplateCache.prototype.compileTemplate = function (rawTemplate, options) {
33579 options = {
33580 evaluate: /<#([\s\S]+?)#>/g,
33581 interpolate: /{{{([\s\S]+?)}}}/g,
33582 escape: /{{([^}]+?)}}(?!})/g
33583 };
33584 return _.template(rawTemplate, options);
33585 };
33586 }
33587 }, {
33588 key: "getDefaultElements",
33589 value: function getDefaultElements() {
33590 return {
33591 $window: jQuery(window),
33592 $document: jQuery(document),
33593 $body: jQuery(document.body)
33594 };
33595 }
33596 }, {
33597 key: "initComponents",
33598 value: function initComponents() {
33599 this.events = new _events.default();
33600 this.eventsManager = new _module.default();
33601 this.debug = new _debug.default();
33602 this.helpers = new _helpers.default();
33603 this.storage = new _storage.default();
33604 this.dialogsManager = new DialogsManager.Instance();
33605 this.notifications = new _notifications.default();
33606 this.api = window.$e;
33607 $e.components.register(new _component2.default());
33608 elementorCommon.elements.$window.on('elementor:init-components', function () {
33609 $e.components.register(new _component.default());
33610 });
33611 this.initModules();
33612 }
33613 }, {
33614 key: "initModules",
33615 value: function initModules() {
33616 var _this = this;
33617 var activeModules = this.config.activeModules;
33618 var modules = {
33619 ajax: _ajax.default,
33620 finder: _finder.default,
33621 connect: _connect.default
33622 };
33623 activeModules.forEach(function (name) {
33624 if (modules[name]) {
33625 _this[name] = new modules[name](_this.config[name]);
33626 }
33627 });
33628 }
33629 }, {
33630 key: "compileArrayTemplateArgs",
33631 value: function compileArrayTemplateArgs(template, templateArgs) {
33632 return template.replace(/%(?:(\d+)\$)?s/g, function (match, number) {
33633 if (!number) {
33634 number = 1;
33635 }
33636 number--;
33637 return undefined !== templateArgs[number] ? templateArgs[number] : match;
33638 });
33639 }
33640 }, {
33641 key: "compileObjectTemplateArgs",
33642 value: function compileObjectTemplateArgs(template, templateArgs) {
33643 return template.replace(/{{(?:([ \w]+))}}/g, function (match, name) {
33644 return templateArgs[name] ? templateArgs[name] : match;
33645 });
33646 }
33647 }, {
33648 key: "compileTemplate",
33649 value: function compileTemplate(template, templateArgs) {
33650 return jQuery.isPlainObject(templateArgs) ? this.compileObjectTemplateArgs(template, templateArgs) : this.compileArrayTemplateArgs(template, templateArgs);
33651 }
33652 }, {
33653 key: "translate",
33654 value: function translate(stringKey, context, templateArgs, i18nStack) {
33655 if (context) {
33656 i18nStack = this.config[context].i18n;
33657 }
33658 if (!i18nStack) {
33659 i18nStack = this.config.i18n;
33660 }
33661 var string = i18nStack[stringKey];
33662 if (undefined === string) {
33663 string = stringKey;
33664 }
33665 if (templateArgs) {
33666 string = this.compileTemplate(string, templateArgs);
33667 }
33668 return string;
33669 }
33670 }, {
33671 key: "onInit",
33672 value: function onInit() {
33673 _superPropGet(ElementorCommonApp, "onInit", this, 3)([]);
33674 this.config = elementorCommonConfig;
33675 this.setMarionetteTemplateCompiler();
33676 }
33677 }]);
33678 }(elementorModules.ViewModule);
33679 window.elementorCommon = new ElementorCommonApp();
33680 elementorCommon.initComponents();
33681 })();
33682
33683 /******/ })()
33684 ;
33685 //# sourceMappingURL=common.js.map